Validate order details when back office submits
Learn about step to customize validate data with DAO.
Requirement
For all order items, summary of all "Order Unit" at module supplier list must equal to "Unit" of order item.
Procedure
1. From ONEWEB workspace, create java file name "com.manual.service.ManualJDBCServiceLocator" in MasterWeb with coding below.
package com.manual.service;
import java.sql.Connection;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
public class ManualJDBCServiceLocator {
private final static transient Logger log = LogManager.getLogger(ManualJDBCServiceLocator.class);
public static ManualJDBCServiceLocator serviceLocator;
private final static String JAVA_ENV = "";
public final static int MASTER_DB = 0;
public final static int ONEWEB_DB = 1;
public final static String MASTER_DATA_SOURCE = "jdbc/master";
public final static String APPLICATION_DATA_SOURCE = "jdbc/application";
public static synchronized ManualJDBCServiceLocator getInstance() {
if (serviceLocator == null) {
serviceLocator = new ManualJDBCServiceLocator();
}
return serviceLocator;
}
private ManualJDBCServiceLocator() {
}
/**
*
* @param dbType
* @return DataSource.getConnection()
* @throws Exception
*/
public Connection getConnection(int dbType) throws Exception {
DataSource ds = null;
try{
InitialContext ctx = new InitialContext();
switch(dbType){
case MASTER_DB:
ds = (DataSource)ctx.lookup(JAVA_ENV+MASTER_DATA_SOURCE);
break;
case ONEWEB_DB:
ds = (DataSource)ctx.lookup(JAVA_ENV+APPLICATION_DATA_SOURCE);
break;
default:
return null;
}
return ds.getConnection();
} catch(Exception e){
e.printStackTrace();
throw new Exception(e.toString());
}
}
/**
*
* @param jndiName (For example, "jdbc/master")
* @return DataSource.getConnection()
* @throws Exception
*/
public Connection getConnection(String jndiName) throws Exception{
try{
DataSource ds = null;
InitialContext ctx = new InitialContext();
if(null != jndiName && !"".equalsIgnoreCase(jndiName)){
ds = (DataSource)ctx.lookup(JAVA_ENV+jndiName);
}else{
return null;
}
return ds.getConnection();
}catch(Exception e){
e.printStackTrace();
throw new Exception(e.toString());
}
}
public static String getPoolName(int dbType) {
switch (dbType) {
default:
return MASTER_DATA_SOURCE;
}
}
}2. From ONEWEB workspace, create java file name "com.manual.doc.order.dao.ManualDocObjectDAO" in MasterWeb with coding below
3. From ONEWEB workspace, create java file name "com.manual.doc.order.dao.ManualDocOrderDAO" at MasterWeb with coding below.
4. From ONEWEB workspace, create java file name "com.manual.doc.order.dao.ManualDocOrderDAOImpl" at MasterWeb with coding below.
5. From ONEWEB workspace, create java file name "com.manual.service.ManualDAOFactory" at MasterWeb with coding below.
6. From ONEWEB workspace, create java file name "com.manual.doc.order.java.OrderRequestBackOfficeUpdateMode" at MasterWeb with coding below.
7. From ONEWEB workspace, export EafMasterEar.ear and deploy update to server. The class name from step 1-6 will update to server.
8. Test by logging in to FrontWeb. 8.1. Login with Back Office user. 8.2. Go to To Do List and claim job. 8.3. Click save or submit. 8.4. If found at least one record of order item that Unit not equal to summary of order unit, the system must show error message "Please verify un-assign order unit."
Last updated
