use of org.compiere.wf.MWorkflow in project adempiere by adempiere.
the class PackInHandler method endElement.
/**
* Receive notification of the end of an element.
* @param uri namespace
* @param localName simple name
* @param qName qualified name
* @throws SAXException
*/
public void endElement(String uri, String localName, String qName) throws SAXException {
// Check namespace.
String elementValue = null;
if ("".equals(uri))
elementValue = qName;
else
elementValue = uri + localName;
if (elementValue.equals("adempiereAD")) {
processDeferElements();
processMenuElements();
if (!PK_Status.equals("Completed with errors"))
PK_Status = "Completed successfully";
//Update package history log with package status
StringBuffer sqlB = new StringBuffer("UPDATE AD_Package_Imp " + "SET PK_Status = '" + PK_Status + "' WHERE AD_Package_Imp_ID = " + AD_Package_Imp_ID);
int no = DB.executeUpdate(sqlB.toString(), m_trxName);
if (no == -1)
log.info("Update to package summary failed");
//Update package list with package status
sqlB = new StringBuffer("UPDATE AD_Package_Imp_Inst " + "SET PK_Status = '" + PK_Status + "' WHERE AD_Package_Imp_Inst_ID = " + AD_Package_Imp_Inst_ID);
no = DB.executeUpdate(sqlB.toString(), m_trxName);
if (no == -1)
log.info("Update to package list failed");
if (workflow.size() > 0) {
for (Element e : workflow) {
Attributes atts = e.attributes;
String workflowName = atts.getValue("Name");
MWorkflow wf = null;
int workflow_id = IDFinder.get_IDWithColumn("AD_Workflow", "Name", workflowName, m_AD_Client_ID, m_trxName);
if (workflow_id > 0) {
wf = new MWorkflow(m_ctx, workflow_id, m_trxName);
int node_id = 0;
String name = atts.getValue("ADWorkflowNodeNameID");
if (name != null && name.trim().length() > 0) {
MWFNode[] nodes = wf.getNodes(false, m_AD_Client_ID);
for (MWFNode node : nodes) {
if (node.getName().trim().equals(name.trim())) {
node_id = node.getAD_WF_Node_ID();
wf.setAD_WF_Node_ID(node_id);
if (!wf.save())
System.out.println("Can not save Start Node " + name + "to Workflow " + workflowName + " do not exist ");
break;
}
}
if (node_id == 0)
System.out.println("Unresolved: Start Node to Workflow " + workflowName + " do not exist ");
else
break;
}
}
}
}
if (nodes.size() > 0) {
for (Element e : nodes) {
Attributes atts = e.attributes;
String nodeName = atts.getValue("Name");
MWFNode node = null;
int id = IDFinder.get_IDWithColumn("AD_WF_Node", "Name", nodeName, m_AD_Client_ID, false, m_trxName);
if (id > 0) {
node = new MWFNode(m_ctx, id, m_trxName);
String workflowNodeName = atts.getValue("WorkflowNameID").trim();
if (workflowNodeName != null && workflowNodeName.trim().length() > 0) {
int workflow_id = IDFinder.get_IDWithColumn("AD_Workflow", "Name", workflowNodeName, m_AD_Client_ID, m_trxName);
if (workflow_id > 0) {
node.setWorkflow_ID(workflow_id);
if (!node.save()) {
System.out.println("can not save Workflow " + workflowNodeName);
}
} else
System.out.println("Unresolved: Workflow " + workflowNodeName + " do not exist ");
}
}
}
}
logDocument.endElement("", "", "adempiereDocument");
logDocument.endDocument();
try {
fw_document.close();
} catch (Exception e) {
}
//reset
setupHandlers();
} else {
Element e = stack.pop();
if (e.defer) {
defer.add(new DeferEntry(e, false));
} else {
ElementHandler handler = handlers.get(elementValue);
if (handler != null)
handler.endElement(m_ctx, e);
if (e.defer || e.deferEnd)
defer.add(new DeferEntry(e, false));
else if (!e.skip) {
if (log.isLoggable(Level.INFO))
log.info("Processed: " + e.getElementValue() + " - " + e.attributes.getValue(0));
}
}
}
}
Aggregations