org.drools.xml.processes.StartNodeHandler Maven / Gradle / Ivy
package org.drools.xml.processes;
import java.util.List;
import java.util.Map;
import org.drools.process.core.event.EventFilter;
import org.drools.process.core.event.EventTypeFilter;
import org.drools.workflow.core.Node;
import org.drools.workflow.core.node.ConstraintTrigger;
import org.drools.workflow.core.node.EventTrigger;
import org.drools.workflow.core.node.StartNode;
import org.drools.workflow.core.node.Trigger;
import org.drools.xml.XmlDumper;
public class StartNodeHandler extends AbstractNodeHandler {
protected Node createNode() {
return new StartNode();
}
@SuppressWarnings("unchecked")
public Class generateNodeFor() {
return StartNode.class;
}
public void writeNode(Node node, StringBuffer xmlDump, boolean includeMeta) {
StartNode startNode = (StartNode) node;
writeNode("start", startNode, xmlDump, includeMeta);
List triggers = startNode.getTriggers();
if (triggers == null || triggers.isEmpty()) {
endNode(xmlDump);
} else {
xmlDump.append(">" + EOL);
xmlDump.append(" " + EOL);
for (Trigger trigger: triggers) {
if (trigger instanceof ConstraintTrigger) {
xmlDump.append(" " + EOL);
xmlDump.append(" "
+ ((ConstraintTrigger) trigger).getConstraint() + " " + EOL);
Map inMappings = trigger.getInMappings();
if (inMappings != null && !inMappings.isEmpty()) {
for (Map.Entry entry: inMappings.entrySet()) {
xmlDump.append(" " + EOL);
}
}
xmlDump.append(" " + EOL);
} else if (trigger instanceof EventTrigger) {
xmlDump.append(" " + EOL);
xmlDump.append(" " + EOL);
for (EventFilter filter: ((EventTrigger) trigger).getEventFilters()) {
if (filter instanceof EventTypeFilter) {
xmlDump.append(" " + EOL);
} else {
throw new IllegalArgumentException(
"Unknown filter type: " + filter);
}
}
xmlDump.append(" " + EOL);
Map inMappings = trigger.getInMappings();
if (inMappings != null && !inMappings.isEmpty()) {
for (Map.Entry entry: inMappings.entrySet()) {
xmlDump.append(" " + EOL);
}
}
xmlDump.append(" " + EOL);
} else {
throw new IllegalArgumentException(
"Unknown trigger type " + trigger);
}
}
xmlDump.append(" " + EOL);
endNode("start", xmlDump);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy