[ 1846595 ] 2pack do not set the start node in a workflow after import
- base on patch submitted by tspc ( Tony ), the update should happen in endElement instead of startElement as the start node haven't been created yet when we want to insert a new workflow record. The original patch would only work if it is a reimport.
This commit is contained in:
parent
3557756bc4
commit
2da6fff06e
|
@ -113,6 +113,7 @@ public class WorkflowElementHandler extends AbstractElementHandler {
|
||||||
m_Workflow.setAD_WorkflowProcessor_ID(id);
|
m_Workflow.setAD_WorkflowProcessor_ID(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Workflow.setName(workflowName);
|
m_Workflow.setName(workflowName);
|
||||||
m_Workflow.setAccessLevel(atts.getValue("AccessLevel"));
|
m_Workflow.setAccessLevel(atts.getValue("AccessLevel"));
|
||||||
m_Workflow.setDescription(getStringValue(atts,"Description"));
|
m_Workflow.setDescription(getStringValue(atts,"Description"));
|
||||||
|
@ -163,7 +164,42 @@ public class WorkflowElementHandler extends AbstractElementHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ctx
|
||||||
|
* @param element
|
||||||
|
*/
|
||||||
public void endElement(Properties ctx, Element element) throws SAXException {
|
public void endElement(Properties ctx, Element element) throws SAXException {
|
||||||
|
if (!element.defer && !element.skip && element.recordId > 0) {
|
||||||
|
Attributes atts = element.attributes;
|
||||||
|
//set start node
|
||||||
|
String name = atts.getValue("ADWorkflowNodeNameID");
|
||||||
|
if (name != null && name.trim().length() > 0) {
|
||||||
|
MWorkflow m_Workflow = new MWorkflow(ctx, element.recordId, getTrxName(ctx));
|
||||||
|
int id = get_IDWithColumn(ctx, "AD_WF_Node", "Name", name);
|
||||||
|
if (id <= 0) {
|
||||||
|
log.warning("Failed to resolve start node reference for workflow element. Workflow="
|
||||||
|
+ m_Workflow.getName() + " StartNode=" + name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_Workflow.setAD_WF_Node_ID(id);
|
||||||
|
if (m_Workflow.save(getTrxName(ctx)) == true) {
|
||||||
|
log.info("m_Workflow update success");
|
||||||
|
record_log(ctx, 1, m_Workflow.getName(), "Workflow", m_Workflow
|
||||||
|
.get_ID(), 0, "Update", "AD_Workflow",
|
||||||
|
get_IDWithColumn(ctx, "AD_Table", "TableName",
|
||||||
|
"AD_Workflow"));
|
||||||
|
workflows.add(m_Workflow.getAD_Workflow_ID());
|
||||||
|
element.recordId = m_Workflow.getAD_Workflow_ID();
|
||||||
|
} else {
|
||||||
|
log.info("m_Workflow update fail");
|
||||||
|
record_log(ctx, 0, m_Workflow.getName(), "Workflow", m_Workflow
|
||||||
|
.get_ID(), 0, "Update", "AD_Workflow",
|
||||||
|
get_IDWithColumn(ctx, "AD_Table", "TableName",
|
||||||
|
"AD_Workflow"));
|
||||||
|
throw new POSaveFailedException("MWorkflow");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create(Properties ctx, TransformerHandler document)
|
public void create(Properties ctx, TransformerHandler document)
|
||||||
|
|
Loading…
Reference in New Issue