use of org.jbpm.process.instance.impl.JavaAction in project jbpm by kiegroup.
the class ActionNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
ActionNode actionNode = (ActionNode) node;
String eventType = (String) actionNode.getMetaData("EventType");
String ref = (String) actionNode.getMetaData("Ref");
String variableRef = (String) actionNode.getMetaData("Variable");
if (actionNode.getAction() instanceof DroolsConsequenceAction) {
DroolsConsequenceAction action = (DroolsConsequenceAction) actionNode.getAction();
String s = action.getConsequence();
if (s.startsWith("org.drools.core.process.instance.impl.WorkItemImpl workItem = new org.drools.core.process.instance.impl.WorkItemImpl();")) {
writeNode("intermediateThrowEvent", actionNode, xmlDump, metaDataType);
xmlDump.append(">" + EOL);
writeExtensionElements(actionNode, xmlDump);
String variable = (String) actionNode.getMetaData("MappingVariable");
if (variable != null) {
xmlDump.append(" <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(actionNode) + "_Input\" />" + EOL + " <dataInputAssociation>" + EOL + " <sourceRef>" + XmlDumper.replaceIllegalChars(variable) + "</sourceRef>" + EOL + " <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(actionNode) + "_Input</targetRef>" + EOL + " </dataInputAssociation>" + EOL + " <inputSet>" + EOL + " <dataInputRefs>" + XmlBPMNProcessDumper.getUniqueNodeId(actionNode) + "_Input</dataInputRefs>" + EOL + " </inputSet>" + EOL);
}
xmlDump.append(" <messageEventDefinition messageRef=\"" + XmlBPMNProcessDumper.getUniqueNodeId(actionNode) + "_Message\"/>" + EOL);
endNode("intermediateThrowEvent", xmlDump);
} else if ("signal".equals(eventType)) {
writeNode("intermediateThrowEvent", actionNode, xmlDump, metaDataType);
xmlDump.append(">" + EOL);
writeExtensionElements(actionNode, xmlDump);
if (!s.startsWith("null")) {
xmlDump.append(" <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(actionNode) + "_Input\" />" + EOL + " <dataInputAssociation>" + EOL + " <sourceRef>" + XmlDumper.replaceIllegalChars(variableRef) + "</sourceRef>" + EOL + " <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(actionNode) + "_Input</targetRef>" + EOL + " </dataInputAssociation>" + EOL + " <inputSet>" + EOL + " <dataInputRefs>" + XmlBPMNProcessDumper.getUniqueNodeId(actionNode) + "_Input</dataInputRefs>" + EOL + " </inputSet>" + EOL);
}
xmlDump.append(" <signalEventDefinition signalRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(ref) + "\"/>" + EOL);
endNode("intermediateThrowEvent", xmlDump);
} else if (s.startsWith(RUNTIME_SIGNAL_EVENT)) {
writeNode("intermediateThrowEvent", actionNode, xmlDump, metaDataType);
xmlDump.append(">" + EOL);
writeExtensionElements(actionNode, xmlDump);
s = s.substring(44);
String type = s.substring(0, s.indexOf("\""));
s = s.substring(s.indexOf(",") + 2);
String variable = null;
if (!s.startsWith("null")) {
variable = s.substring(0, s.indexOf(")"));
xmlDump.append(" <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(actionNode) + "_Input\" />" + EOL + " <dataInputAssociation>" + EOL + " <sourceRef>" + XmlDumper.replaceIllegalChars(variable) + "</sourceRef>" + EOL + " <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(actionNode) + "_Input</targetRef>" + EOL + " </dataInputAssociation>" + EOL + " <inputSet>" + EOL + " <dataInputRefs>" + XmlBPMNProcessDumper.getUniqueNodeId(actionNode) + "_Input</dataInputRefs>" + EOL + " </inputSet>" + EOL);
}
xmlDump.append(" <signalEventDefinition signalRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(type) + "\"/>" + EOL);
endNode("intermediateThrowEvent", xmlDump);
} else if (s.startsWith(PROCESS_INSTANCE_SIGNAL_EVENT)) {
writeNode("intermediateThrowEvent", actionNode, xmlDump, metaDataType);
xmlDump.append(">" + EOL);
writeExtensionElements(actionNode, xmlDump);
s = s.substring(43);
assert "Compensation".equals(s.substring(0, s.indexOf("\""))) : "Type is not \"Compensation\" but \"" + s.substring(0, s.indexOf("\"")) + "\"";
String activityRef = "";
// : Compensation
int begin = 12;
// ");
int end = s.length() - 3;
String compensationEvent = s.substring(begin, end);
if (!compensationEvent.startsWith(CompensationScope.IMPLICIT_COMPENSATION_PREFIX)) {
// specific
activityRef = "activityRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(activityRef) + "\" ";
}
// else general: activityRef = "" (above)
xmlDump.append(" <compensateEventDefinition " + activityRef + "/>" + EOL);
endNode("intermediateThrowEvent", xmlDump);
} else if (s.startsWith("org.drools.core.process.instance.context.exception.ExceptionScopeInstance scopeInstance = (org.drools.core.process.instance.context.exception.ExceptionScopeInstance) ((org.drools.workflow.instance.NodeInstance) kcontext.getNodeInstance()).resolveContextInstance(org.drools.core.process.core.context.exception.ExceptionScope.EXCEPTION_SCOPE, \"")) {
writeNode("intermediateThrowEvent", actionNode, xmlDump, metaDataType);
xmlDump.append(">" + EOL);
writeExtensionElements(actionNode, xmlDump);
s = s.substring(327);
String type = s.substring(0, s.indexOf("\""));
xmlDump.append(" <escalationEventDefinition escalationRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(type) + "\"/>" + EOL);
endNode("intermediateThrowEvent", xmlDump);
} else if ("IntermediateThrowEvent-None".equals(actionNode.getMetaData("NodeType"))) {
writeNode("intermediateThrowEvent", actionNode, xmlDump, metaDataType);
xmlDump.append(">" + EOL);
writeExtensionElements(actionNode, xmlDump);
endNode("intermediateThrowEvent", xmlDump);
} else {
writeNode("scriptTask", actionNode, xmlDump, metaDataType);
if (JavaDialect.ID.equals(action.getDialect())) {
xmlDump.append("scriptFormat=\"" + XmlBPMNProcessDumper.JAVA_LANGUAGE + "\" ");
} else if ("JavaScript".equals(action.getDialect())) {
xmlDump.append("scriptFormat=\"" + XmlBPMNProcessDumper.JAVASCRIPT_LANGUAGE + "\" ");
}
Object isForCompensationObj = actionNode.getMetaData("isForCompensation");
if (isForCompensationObj != null && (Boolean) isForCompensationObj) {
xmlDump.append("isForCompensation=\"true\" ");
}
xmlDump.append(">" + EOL);
writeExtensionElements(actionNode, xmlDump);
if (action.getConsequence() != null) {
xmlDump.append(" <script>" + XmlDumper.replaceIllegalChars(action.getConsequence()) + "</script>" + EOL);
}
endNode("scriptTask", xmlDump);
}
} else if (actionNode.getAction() instanceof JavaDroolsAction) {
JavaAction action = ((JavaDroolsAction) actionNode.getAction()).getAction();
writeNode("intermediateThrowEvent", actionNode, xmlDump, metaDataType);
xmlDump.append(">" + EOL);
writeExtensionElements(actionNode, xmlDump);
writeJavaAction(node, action, xmlDump);
endNode("intermediateThrowEvent", xmlDump);
} else {
writeNode("scriptTask", actionNode, xmlDump, metaDataType);
xmlDump.append(">" + EOL);
writeExtensionElements(actionNode, xmlDump);
endNode("scriptTask", xmlDump);
}
}
use of org.jbpm.process.instance.impl.JavaAction in project jbpm by kiegroup.
the class EndNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
EndNode endNode = (EndNode) node;
String eventType = (String) endNode.getMetaData("EventType");
String ref = (String) endNode.getMetaData("Ref");
String variableRef = (String) endNode.getMetaData("Variable");
writeNode("endEvent", endNode, xmlDump, metaDataType);
if (endNode.isTerminate()) {
xmlDump.append(">" + EOL);
writeExtensionElements(endNode, xmlDump);
xmlDump.append(" <terminateEventDefinition " + (endNode.getScope() == EndNode.PROCESS_SCOPE ? "tns:scope=\"process\"" : "") + "/>" + EOL);
endNode("endEvent", xmlDump);
} else {
String scope = (String) endNode.getMetaData("customScope");
List<DroolsAction> actions = endNode.getActions(EndNode.EVENT_NODE_ENTER);
if (actions != null && !actions.isEmpty()) {
if (actions.size() == 1) {
DroolsAction droolsAction = actions.get(0);
if (droolsAction instanceof DroolsConsequenceAction) {
DroolsConsequenceAction action = (DroolsConsequenceAction) actions.get(0);
String s = action.getConsequence();
if (s.startsWith("org.drools.core.process.instance.impl.WorkItemImpl workItem = new org.drools.core.process.instance.impl.WorkItemImpl();")) {
xmlDump.append(">" + EOL);
writeExtensionElements(endNode, xmlDump);
String variable = (String) endNode.getMetaData("MappingVariable");
if (variable != null) {
xmlDump.append(" <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input\" />" + EOL + " <dataInputAssociation>" + EOL + " <sourceRef>" + XmlDumper.replaceIllegalChars(variable) + "</sourceRef>" + EOL + " <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input</targetRef>" + EOL + " </dataInputAssociation>" + EOL + " <inputSet>" + EOL + " <dataInputRefs>" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input</dataInputRefs>" + EOL + " </inputSet>" + EOL);
}
xmlDump.append(" <messageEventDefinition messageRef=\"" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Message\"/>" + EOL);
endNode("endEvent", xmlDump);
} else if ("signal".equals(eventType)) {
xmlDump.append(">" + EOL);
writeExtensionElements(endNode, xmlDump);
if (!s.startsWith("null")) {
xmlDump.append(" <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input\" />" + EOL + " <dataInputAssociation>" + EOL + " <sourceRef>" + XmlDumper.replaceIllegalChars(variableRef) + "</sourceRef>" + EOL + " <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input</targetRef>" + EOL + " </dataInputAssociation>" + EOL + " <inputSet>" + EOL + " <dataInputRefs>" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input</dataInputRefs>" + EOL + " </inputSet>" + EOL);
}
xmlDump.append(" <signalEventDefinition signalRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(ref) + "\"/>" + EOL);
endNode("endEvent", xmlDump);
} else if (s.startsWith(RUNTIME_SIGNAL_EVENT)) {
xmlDump.append(">" + EOL);
writeExtensionElements(endNode, xmlDump);
s = s.substring(44);
String type = s.substring(0, s.indexOf("\""));
s = s.substring(s.indexOf(",") + 2);
String variable = null;
if (!s.startsWith("null")) {
variable = s.substring(0, s.indexOf(")"));
xmlDump.append(" <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input\" />" + EOL + " <dataInputAssociation>" + EOL + " <sourceRef>" + XmlDumper.replaceIllegalChars(variable) + "</sourceRef>" + EOL + " <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input</targetRef>" + EOL + " </dataInputAssociation>" + EOL + " <inputSet>" + EOL + " <dataInputRefs>" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input</dataInputRefs>" + EOL + " </inputSet>" + EOL);
}
xmlDump.append(" <signalEventDefinition signalRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(type) + "\"/>" + EOL);
endNode("endEvent", xmlDump);
} else if (s.startsWith(PROCESS_INSTANCE_SIGNAL_EVENT) && "processInstance".equals(scope)) {
xmlDump.append(">" + EOL);
writeExtensionElements(endNode, xmlDump);
s = s.substring(43);
String type = s.substring(0, s.indexOf("\""));
s = s.substring(s.indexOf(",") + 2);
String variable = null;
if (!s.startsWith("null")) {
variable = s.substring(0, s.indexOf(")"));
xmlDump.append(" <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input\" />" + EOL + " <dataInputAssociation>" + EOL + " <sourceRef>" + XmlDumper.replaceIllegalChars(variable) + "</sourceRef>" + EOL + " <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input</targetRef>" + EOL + " </dataInputAssociation>" + EOL + " <inputSet>" + EOL + " <dataInputRefs>" + XmlBPMNProcessDumper.getUniqueNodeId(endNode) + "_Input</dataInputRefs>" + EOL + " </inputSet>" + EOL);
}
xmlDump.append(" <signalEventDefinition signalRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(type) + "\"/>" + EOL);
endNode("endEvent", xmlDump);
} else if (s.startsWith(PROCESS_INSTANCE_SIGNAL_EVENT)) {
xmlDump.append(">" + EOL);
writeExtensionElements(endNode, xmlDump);
int begin = (PROCESS_INSTANCE_SIGNAL_EVENT + "Compensation\", ").length() - 2;
int end = s.length() - 3;
String compensationEvent = s.substring(begin, end);
String activityRef = "";
if (!compensationEvent.startsWith(CompensationScope.IMPLICIT_COMPENSATION_PREFIX)) {
// specific
activityRef = "activityRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(activityRef) + "\" ";
}
// else general: activityRef = "" (above)
xmlDump.append(" <compensateEventDefinition " + activityRef + "/>" + EOL);
endNode("endEvent", xmlDump);
} else {
throw new IllegalArgumentException("Unknown action " + s);
}
} else if (droolsAction instanceof JavaDroolsAction) {
JavaAction action = ((JavaDroolsAction) droolsAction).getAction();
xmlDump.append(">" + EOL);
writeExtensionElements(endNode, xmlDump);
writeJavaAction(endNode, action, xmlDump);
endNode("endEvent", xmlDump);
}
}
} else {
endNode(xmlDump);
}
}
}
Aggregations