use of org.compiere.model.X_AD_WF_Node in project adempiere by adempiere.
the class WorkflowNodeElementHandler method startElement.
public void startElement(Properties ctx, Element element) throws SAXException {
Attributes atts = element.attributes;
String elementValue = element.getElementValue();
log.info(elementValue + " " + atts.getValue("Name"));
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;
}
if (element.parent != null && element.parent.getElementValue().equals("workflow") && element.parent.defer) {
element.unresolved = "Parent element mark as defer: " + atts.getValue("ADWorkflowNameID");
element.defer = true;
return;
}
int workflowId = 0;
String workflowName = atts.getValue("ADWorkflowNameID");
if (element.parent != null && element.parent.getElementValue().equals("workflow") && element.parent.recordId > 0)
workflowId = element.parent.recordId;
else {
workflowId = get_IDWithColumn(ctx, "AD_Workflow", "name", workflowName);
if (workflowId <= 0) {
element.defer = true;
element.unresolved = "AD_Workflow: " + workflowName;
return;
} else if (element.parent != null && element.parent.getElementValue().equals("workflow"))
element.parent.recordId = workflowId;
}
String workflowNodeName = atts.getValue("Name").trim();
StringBuffer sqlB = new StringBuffer("SELECT ad_wf_node_id FROM AD_WF_Node WHERE AD_Workflow_ID=? and Name =?");
int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), workflowId, workflowNodeName);
X_AD_WF_Node m_WFNode = new X_AD_WF_Node(ctx, id, getTrxName(ctx));
int AD_Backup_ID = -1;
String Object_Status = null;
if (id <= 0 && atts.getValue("AD_WF_Node_ID") != null && Integer.parseInt(atts.getValue("AD_WF_Node_ID")) <= PackOut.MAX_OFFICIAL_ID)
m_WFNode.setAD_WF_Node_ID(Integer.parseInt(atts.getValue("AD_WF_Node_ID")));
if (id > 0) {
AD_Backup_ID = copyRecord(ctx, "AD_WF_Node", m_WFNode);
Object_Status = "Update";
} else {
Object_Status = "New";
AD_Backup_ID = 0;
}
m_WFNode.setValue(atts.getValue("Value"));
m_WFNode.setName(workflowNodeName);
m_WFNode.setAD_Workflow_ID(workflowId);
String name = atts.getValue("ADProcessNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Process", "Name", name);
if (id <= 0) {
element.defer = true;
element.unresolved = "AD_Process: " + name;
return;
}
m_WFNode.setAD_Process_ID(id);
}
name = atts.getValue("ADFormNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Form", "Name", name);
if (id <= 0) {
element.defer = true;
element.unresolved = "AD_Form: " + name;
return;
}
m_WFNode.setAD_Form_ID(id);
}
name = atts.getValue("ADWorkflowResponsibleNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_WF_Responsible", "Name", name);
/*
if (id <= 0) {
element.defer = true;
return;
}*/
if (id > 0)
m_WFNode.setAD_WF_Responsible_ID(id);
}
name = atts.getValue("ADWindowNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Window", "Name", name);
if (id <= 0) {
element.defer = true;
element.unresolved = "AD_Window: " + name;
return;
}
m_WFNode.setAD_Window_ID(id);
}
name = atts.getValue("ADImageNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Image", "Name", name);
/*
if (id <= 0) {
element.defer = true;
return;
}*/
if (id > 0)
m_WFNode.setAD_Image_ID(id);
}
name = atts.getValue("ADWorkflowBlockNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_WF_Block", "Name", name);
/*
if (id <= 0) {
element.defer = true;
return;
}*/
if (id > 0)
m_WFNode.setAD_WF_Block_ID(id);
}
String columnName = atts.getValue("ADColumnNameID");
int tableId = DB.getSQLValue(getTrxName(ctx), "SELECT AD_Table_ID FROM AD_Workflow WHERE AD_Workflow_ID=?", workflowId);
get_IDWithColumn(ctx, "AD_Workflow", "AD_Table_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;
} else if (columnId > 0)
m_WFNode.setAD_Column_ID(columnId);
//[Bugs-1789058 ]
/*
name = atts.getValue("WorkflowNameID");
if (name != null && name.trim().length() > 0) {
id = get_IDWithColumn(ctx, "AD_Workflow", "Name", name);
//TODO: export and import of ad_workflow
if (id <= 0) {
element.defer = true;
element.unresolved = "Sub Workflow: " + name;
return;
}
if (id > 0)
m_WFNode.setWorkflow_ID(id);
}*/
/*
* FIXME: Do we need TaskName ? if
* (atts.getValue("ADTaskNameID")!=null){ String name =
* atts.getValue("ADTaskNameID"); sqlB = new StringBuffer ("SELECT
* AD_Task_ID FROM AD_Task WHERE Name= ?"); taskid =
* DB.getSQLValue(m_trxName,sqlB.toString(),name); }
*/
m_WFNode.setValue(atts.getValue("Value"));
m_WFNode.setEntityType(atts.getValue("EntityType"));
m_WFNode.setAction(getStringValue(atts, "Action"));
m_WFNode.setDocAction(getStringValue(atts, "DocAction"));
m_WFNode.setDescription(getStringValue(atts, "Description"));
m_WFNode.setJoinElement(atts.getValue("JoinElement"));
m_WFNode.setSplitElement(atts.getValue("SplitElement"));
if (getStringValue(atts, "XPosition") != null)
m_WFNode.setXPosition(Integer.valueOf(atts.getValue("XPosition")));
if (getStringValue(atts, "YPosition") != null)
m_WFNode.setYPosition(Integer.valueOf(atts.getValue("YPosition")));
m_WFNode.setWaitingTime(Integer.valueOf(atts.getValue("WaitingTime")));
if (getStringValue(atts, "WaitTime") != null)
m_WFNode.setWaitTime(Integer.valueOf(atts.getValue("WaitTime")));
m_WFNode.setWorkingTime(Integer.valueOf(atts.getValue("WorkingTime")));
if (getStringValue(atts, "Cost") != null)
m_WFNode.setCost(new BigDecimal(atts.getValue("Cost")));
if (getStringValue(atts, "Duration") != null)
m_WFNode.setDuration(Integer.valueOf(atts.getValue("Duration")));
if (getStringValue(atts, "Priority") != null)
m_WFNode.setPriority(Integer.valueOf(atts.getValue("Priority")));
m_WFNode.setStartMode(getStringValue(atts, "StartMode"));
m_WFNode.setSubflowExecution(getStringValue(atts, "SubflowExecution"));
m_WFNode.setIsCentrallyMaintained(Boolean.valueOf(atts.getValue("IsCentrallyMaintained")).booleanValue());
if (getStringValue(atts, "DynPriorityChange") != null)
m_WFNode.setDynPriorityChange(new BigDecimal(atts.getValue("DynPriorityChange")));
// m_WFNode.setAccessLevel (atts.getValue("AccessLevel"));
m_WFNode.setDynPriorityUnit(getStringValue(atts, "DynPriorityUnit"));
m_WFNode.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
m_WFNode.setValue(atts.getValue("Value"));
log.info("about to execute m_WFNode.save");
if (m_WFNode.save(getTrxName(ctx)) == true) {
log.info("m_WFNode save success");
record_log(ctx, 1, m_WFNode.getName(), "WFNode", m_WFNode.get_ID(), AD_Backup_ID, Object_Status, "AD_WF_Node", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_WF_Node"));
} else {
log.info("m_WFNode save failure");
record_log(ctx, 0, m_WFNode.getName(), "WFNode", m_WFNode.get_ID(), AD_Backup_ID, Object_Status, "AD_WF_Node", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_WF_Node"));
throw new POSaveFailedException("WorkflowNode");
}
} else {
element.skip = true;
}
}
use of org.compiere.model.X_AD_WF_Node in project adempiere by adempiere.
the class WorkflowNodeElementHandler method create.
public void create(Properties ctx, TransformerHandler document) throws SAXException {
int AD_WF_Node_ID = Env.getContextAsInt(ctx, X_AD_WF_Node.COLUMNNAME_AD_WF_Node_ID);
AttributesImpl atts = new AttributesImpl();
X_AD_WF_Node m_WF_Node = new X_AD_WF_Node(ctx, AD_WF_Node_ID, getTrxName(ctx));
createWorkflowNodeBinding(atts, m_WF_Node);
document.startElement("", "", "workflowNode", atts);
document.endElement("", "", "workflowNode");
}
Aggregations