[ 1846595 ] 2pack do not set the start node in a workflow after import

- Added proper defer endElement processing handling.
This commit is contained in:
Heng Sin Low 2007-12-17 17:06:41 +00:00
parent 6c301fe4cf
commit e23c51352e
3 changed files with 27 additions and 9 deletions

View File

@ -640,6 +640,9 @@ public class PackInHandler extends DefaultHandler {
setupHandlers(); setupHandlers();
} else { } else {
Element e = stack.pop(); Element e = stack.pop();
if (e.defer) {
defer.add(new DeferEntry(e, false));
} else {
ElementHandler handler = handlers.get(elementValue); ElementHandler handler = handlers.get(elementValue);
if (handler != null) if (handler != null)
handler.endElement(m_ctx, e); handler.endElement(m_ctx, e);
@ -648,6 +651,7 @@ public class PackInHandler extends DefaultHandler {
else if (!e.skip) else if (!e.skip)
System.out.println("Processed: " + e.getElementValue() + " - " + e.attributes.getValue(0)); System.out.println("Processed: " + e.getElementValue() + " - " + e.attributes.getValue(0));
} }
}
} // endElement } // endElement
private void processMenuElements() throws SAXException { private void processMenuElements() throws SAXException {
@ -666,12 +670,24 @@ public class PackInHandler extends DefaultHandler {
do { do {
int startSize = defer.size(); int startSize = defer.size();
List<DeferEntry> tmp = new ArrayList<DeferEntry>(defer); List<DeferEntry> tmp = new ArrayList<DeferEntry>(defer);
List<Element> startElements = new ArrayList<Element>();
defer.clear(); defer.clear();
for (DeferEntry d : tmp) { for (DeferEntry d : tmp) {
if (d.startElement) { if (d.startElement) {
d.element.defer = false; d.element.defer = false;
d.element.unresolved = ""; d.element.unresolved = "";
d.element.pass++; d.element.pass++;
startElements.add(d.element);
} else {
if (d.element.defer && startElements.contains(d.element)) {
defer.add(d);
continue;
} else {
//only defer endElement
d.element.defer = false;
d.element.unresolved = "";
d.element.pass++;
}
} }
ElementHandler handler = handlers.get(d.element.getElementValue()); ElementHandler handler = handlers.get(d.element.getElementValue());
if (handler != null) { if (handler != null) {

View File

@ -178,8 +178,8 @@ public class WorkflowElementHandler extends AbstractElementHandler {
MWorkflow m_Workflow = new MWorkflow(ctx, element.recordId, getTrxName(ctx)); MWorkflow m_Workflow = new MWorkflow(ctx, element.recordId, getTrxName(ctx));
int id = get_IDWithColumn(ctx, "AD_WF_Node", "Name", name); int id = get_IDWithColumn(ctx, "AD_WF_Node", "Name", name);
if (id <= 0) { if (id <= 0) {
log.warning("Failed to resolve start node reference for workflow element. Workflow=" element.defer = true;
+ m_Workflow.getName() + " StartNode=" + name); element.unresolved = "AD_WF_Node=" + name;
return; return;
} }
m_Workflow.setAD_WF_Node_ID(id); m_Workflow.setAD_WF_Node_ID(id);

View File

@ -65,6 +65,7 @@ public class WorkflowNodeNextConditionElementHandler extends
int wfNodeId = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), int wfNodeId = DB.getSQLValue(getTrxName(ctx), sqlB.toString(),
workflowId, workflowNodeName); workflowId, workflowNodeName);
if (wfNodeId <= 0) { if (wfNodeId <= 0) {
element.unresolved = "AD_WF_Node=" + workflowNodeName;
element.defer = true; element.defer = true;
return; return;
} }
@ -72,6 +73,7 @@ public class WorkflowNodeNextConditionElementHandler extends
int wfNodeNextId = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), int wfNodeNextId = DB.getSQLValue(getTrxName(ctx), sqlB.toString(),
workflowId, workflowNodeNextName); workflowId, workflowNodeNextName);
if (wfNodeNextId <= 0) { if (wfNodeNextId <= 0) {
element.unresolved = "AD_WF_Node=" + workflowNodeNextName;
element.defer = true; element.defer = true;
return; return;
} }