}
if (modelId == null && modelIdRef == null)
modelId = UUID.randomUUID().toString();
ModelGraph graph = null;
if (modelId != null) {
if (workflowNode.getElement().getNodeName().equals("workflow")
|| workflowNode.getElement().getNodeName().equals("conditions")
|| workflowNode.getElement().getNodeName().equals("tasks")) {
if (executionType == null) {
LOG.log(Level.WARNING, "workflow model '"
+ workflowNode.getElement().getNodeName()
+ "' missing execution type: assuming sequential");
executionType = "sequential";
}
} else {
executionType = workflowNode.getElement().getNodeName();
}
if (!supportedProcessorIds.contains(executionType))
LOG.log(Level.WARNING, "Unsupported execution type id '"
+ executionType + "'");
ModelNode modelNode = new ModelNode(workflowNode.getFile());
modelNode.setModelId(modelId);
modelNode.setModelName(modelName);
modelNode.setExecutionType(executionType);
modelNode.setStaticMetadata(staticMetadata);
modelNode.setExcusedSubProcessorIds(excused);
modelNode.setInstanceClass(clazz);
modelNode.setEntryPoint(entryPoint);
modelNode.setTimeout(timeout);
modelNode.setOptional(optional);
loadConfiguration(rootElements, workflowNode, modelNode, globalConfGroups);
graph = new ModelGraph(modelNode);
boolean loadedPreConditions = false;
NodeList children = workflowNode.getElement().getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node curChild = children.item(i);
if (curChild.getNodeType() == Node.ELEMENT_NODE) {
if (curChild.getNodeName().equals("conditions")) {
boolean isPreCondition = !loadedPreConditions;
String type = ((Element) curChild).getAttribute("type");
if (type.length() > 0)
isPreCondition = type.toLowerCase().equals("pre");
if (isPreCondition)
graph.setPreConditions(this.loadGraph(rootElements,
new FileBasedElement(workflowNode.getFile(),
(Element) curChild), new Metadata(staticMetadata),
globalConfGroups, supportedProcessorIds));
else
graph.setPostConditions(this.loadGraph(rootElements,
new FileBasedElement(workflowNode.getFile(),
(Element) curChild), new Metadata(staticMetadata),
globalConfGroups, supportedProcessorIds));
loadedPreConditions = true;
} else if (!curChild.getNodeName().equals("configuration")
&& !curChild.getNodeName().equals("requiredMetFields")) {
graph.addChild(this.loadGraph(rootElements, new FileBasedElement(
workflowNode.getFile(), (Element) curChild), new Metadata(
staticMetadata), globalConfGroups, supportedProcessorIds));
}
}
}
} else if (modelIdRef != null) {
graph = this.findGraph(rootElements, modelIdRef, new Metadata(
staticMetadata), globalConfGroups, supportedProcessorIds);
if (graph == null)
throw new Exception("Workflow '" + modelIdRef
+ "' has not been defined in this context");
graph.setIsRef(true);
graph.getModel().setStaticMetadata(new Metadata());
loadConfiguration(rootElements, workflowNode, graph.getModel(),
globalConfGroups);
graph.getModel().setAlias(alias);
}
if (entryPoint && graph.getParent() != null) {
this.graphs.add(graph);
}
return graph;
}