use of org.compiere.wf.MWFNextCondition in project adempiere by adempiere.
the class WorkflowNodeNextConditionElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
Attributes atts = element.attributes;
String entitytype = atts.getValue("EntityType");
log.info("entitytype " + atts.getValue("EntityType"));
if (isProcessElement(ctx, entitytype)) {
if (element.parent != null && element.parent.skip) {
element.skip = true;
return;
}
String workflowName = atts.getValue("ADWorkflowNameID");
int workflowId = get_IDWithColumn(ctx, "AD_Workflow", "name", workflowName);
if (workflowId <= 0) {
element.defer = true;
element.unresolved = "AD_Workflow: " + workflowName;
return;
}
String workflowNodeName = atts.getValue("ADWorkflowNodeNameID");
String workflowNodeNextName = atts.getValue("ADWorkflowNodeNextNameID");
StringBuffer sqlB = new StringBuffer("SELECT ad_wf_node_id FROM AD_WF_Node WHERE AD_Workflow_ID=? and Name =?");
int wfNodeId = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), workflowId, workflowNodeName);
if (wfNodeId <= 0) {
element.unresolved = "AD_WF_Node=" + workflowNodeName;
element.defer = true;
return;
}
int wfNodeNextId = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), workflowId, workflowNodeNextName);
if (wfNodeNextId <= 0) {
element.unresolved = "AD_WF_Node=" + workflowNodeNextName;
element.defer = true;
return;
}
String columnName = atts.getValue("ADColumnNameID");
int tableId = DB.getSQLValue(getTrxName(ctx), "SELECT AD_Table_ID FROM AD_Workflow WHERE AD_Workflow_ID=?", workflowId);
int columnId = get_IDWithMasterAndColumn(ctx, "AD_Column", "ColumnName", columnName, "AD_Table", tableId);
if (columnId <= 0 && tableId > 0 && columnName != null && columnName.length() > 0) {
element.unresolved = "AD_Column=" + columnName;
element.defer = true;
return;
}
sqlB = new StringBuffer("SELECT ad_wf_nodenext_id FROM AD_WF_NodeNext WHERE ad_wf_node_id =? and ad_wf_next_id =?");
int wfNodeNextTablePKId = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), wfNodeId, wfNodeNextId);
sqlB = new StringBuffer("SELECT ad_wf_nextcondition_id FROM AD_WF_NextCondition WHERE ad_wf_nodenext_id =?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), wfNodeNextTablePKId);
MWFNextCondition m_WFNodeNextCondition = new MWFNextCondition(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_WF_NextCondition_ID") != null && Integer.parseInt(atts.getValue("AD_WF_NextCondition_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_WFNodeNextCondition.setAD_WF_NextCondition_ID(Integer.parseInt(atts.getValue("AD_WF_NextCondition_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_WF_NextCondition", m_WFNodeNextCondition);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_WFNodeNextCondition.setAD_WF_NodeNext_ID(wfNodeNextTablePKId);
m_WFNodeNextCondition.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_WFNodeNextCondition.setAD_WF_NodeNext_ID(wfNodeNextTablePKId);
m_WFNodeNextCondition.setSeqNo(Integer.valueOf(atts.getValue("SeqNo")));
m_WFNodeNextCondition.setEntityType(atts.getValue("EntityType"));
m_WFNodeNextCondition.setAndOr(atts.getValue("AndOr"));
m_WFNodeNextCondition.setOperation(atts.getValue("Operation"));
m_WFNodeNextCondition.setValue(atts.getValue("Value"));
m_WFNodeNextCondition.setValue2(atts.getValue("Value2"));
m_WFNodeNextCondition.setAD_Column_ID(columnId);
log.info("about to execute m_WFNodeNextCondition.save");
if (m_WFNodeNextCondition.save(getTrxName(ctx)) == true) {
log.info("m_WFNodeNextCondition save success");
record_log(ctx, 1, String.valueOf(m_WFNodeNextCondition.get_ID()), "WFNextCondition", m_WFNodeNextCondition.get_ID(), AD_Backup_ID, Object_Status, "AD_WF_NextCondition", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_WF_NextCondition"));
} else {
log.info("m_WFNodeNextCondition save failure");
record_log(ctx, 0, String.valueOf(m_WFNodeNextCondition.get_ID()), "WFNextCondition", m_WFNodeNextCondition.get_ID(), AD_Backup_ID, Object_Status, "AD_WF_NextCondition", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_WF_NextCondition"));
throw new POSaveFailedException("WorkflowNodeNextCondition");
}
} else {
element.skip = true;
}
}
Aggregations