use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class StateBasedNodeInstance method internalTrigger.
@Override
public void internalTrigger(NodeInstance from, String type) {
super.internalTrigger(from, type);
// if node instance was cancelled, abort
if (getNodeInstanceContainer().getNodeInstance(getId()) == null) {
return;
}
addCompletionListeners();
// activate timers
Map<Timer, ProcessAction> timers = getEventBasedNode().getTimers();
if (timers != null) {
addTimerListener();
timerInstances = new ArrayList<>(timers.size());
JobsService jobService = getProcessInstance().getProcessRuntime().getJobsService();
for (Timer timer : timers.keySet()) {
ExpirationTime expirationTime = createTimerInstance(timer);
String jobId = jobService.scheduleProcessInstanceJob(ProcessInstanceJobDescription.of(timer.getId(), expirationTime, getProcessInstanceIdWithParent(), getProcessInstance().getRootProcessInstanceId(), getProcessInstance().getProcessId(), getProcessInstance().getProcess().getVersion(), getProcessInstance().getRootProcessId()));
timerInstances.add(jobId);
}
}
((WorkflowProcessInstanceImpl) getProcessInstance()).addActivatingNodeId((String) getNode().getMetaData().get("UniqueId"));
if (getExtendedNode().hasCondition()) {
ProcessContext context = new ProcessContext(getProcessInstance().getProcessRuntime());
context.setProcessInstance(getProcessInstance());
if (getExtendedNode().getMetaData("ConditionEventType") != null && getExtendedNode().isMet(context)) {
getProcessInstance().signalEvent((String) getExtendedNode().getMetaData("ConditionEventType"), null);
} else {
getProcessInstance().addEventListener("variableChanged", this, false);
}
}
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class WorkflowProcessInstanceImpl method start.
@Override
public void start(String trigger, Object triggerData) {
synchronized (this) {
setStartDate(new Date());
registerExternalEventNodeListeners();
// activate timer event sub processes
Node[] nodes = getNodeContainer().getNodes();
for (Node node : nodes) {
if (node instanceof EventSubProcessNode) {
Map<Timer, ProcessAction> timers = ((EventSubProcessNode) node).getTimers();
if (timers != null && !timers.isEmpty()) {
EventSubProcessNodeInstance eventSubProcess = (EventSubProcessNodeInstance) getNodeInstance(node);
eventSubProcess.trigger(null, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE);
}
}
}
super.start(trigger, triggerData);
}
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class TimerHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
Element element = parser.endElementBuilder();
StateBasedNode parent = (StateBasedNode) parser.getParent();
String id = element.getAttribute("id");
emptyAttributeCheck(localName, "id", id, parser);
String delay = element.getAttribute("delay");
String period = element.getAttribute("period");
Timer timer = new Timer();
timer.setId(new Long(id));
if (delay != null && delay.length() != 0) {
timer.setDelay(delay);
}
if (period != null && period.length() != 0) {
timer.setPeriod(period);
}
org.w3c.dom.Node xmlNode = element.getFirstChild();
ProcessAction action = null;
if (xmlNode instanceof Element) {
Element actionXml = (Element) xmlNode;
action = AbstractNodeHandler.extractAction(actionXml);
}
parent.addTimer(timer, action);
return null;
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class AbstractNodeHandler method writeActions.
protected void writeActions(final String type, List<ProcessAction> actions, final StringBuilder xmlDump) {
if (actions != null && actions.size() > 0) {
xmlDump.append(" <" + type + ">" + EOL);
for (ProcessAction action : actions) {
writeAction(action, xmlDump);
}
xmlDump.append(" </" + type + ">" + EOL);
}
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class ActionNodeHandler method handleNode.
public void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
ActionNode actionNode = (ActionNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
if (xmlNode instanceof Element) {
Element actionXml = (Element) xmlNode;
ProcessAction action = extractAction(actionXml);
actionNode.setAction(action);
}
}
Aggregations