@Override public void addEventListeners() { String eventType = getEventType(); if (isVariableExpression(getEventNode().getType())) { getProcessInstance().addEventListener(eventType, new VariableExternalEventListener(eventType), true); } else { getProcessInstance().addEventListener(eventType, getEventListener(), true); } if (slaTimerId > -1) { addTimerListener(); } }
public void internalTrigger(final NodeInstance from, String type) { if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) { throw new IllegalArgumentException( "An EventNode only accepts default incoming connections!"); } addEventListeners(); // Do nothing, event activated }
public void triggerCompleted() { getProcessInstance().removeEventListener(getEventType(), getEventListener(), true); removeTimerListeners(); if (this.slaCompliance == ProcessInstance.SLA_PENDING) { if (System.currentTimeMillis() > slaDueDate.getTime()) { // completion of the node instance is after expected SLA due date, mark it accordingly this.slaCompliance = ProcessInstance.SLA_VIOLATED; } else { this.slaCompliance = ProcessInstance.STATE_COMPLETED; } } cancelSlaTimer(); ((org.jbpm.workflow.instance.NodeInstanceContainer)getNodeInstanceContainer()).setCurrentLevel(getLevel()); triggerCompleted(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, true); }
@Override public void cancel() { getProcessInstance().removeEventListener(getEventType(), getEventListener(), true); removeTimerListeners(); if (this.slaCompliance == ProcessInstance.SLA_PENDING) { if (System.currentTimeMillis() > slaDueDate.getTime()) { // completion of the process instance is after expected SLA due date, mark it accordingly this.slaCompliance = ProcessInstance.SLA_VIOLATED; } else { this.slaCompliance = ProcessInstance.SLA_ABORTED; } } removeTimerListeners(); super.cancel(); }
public void signalEvent(String type, Object event) { if ("timerTriggered".equals(type)) { TimerInstance timerInstance = (TimerInstance) event; if (timerInstance.getId() == slaTimerId) { handleSLAViolation(); } } else if (("slaViolation:" + getId()).equals(type)) { handleSLAViolation(); } else { String variableName = getEventNode().getVariableName(); if (variableName != null) { VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, variableName); if (variableScopeInstance == null) { throw new IllegalArgumentException( "Could not find variable for event node: " + variableName); } EventTransformer transformer = getEventNode().getEventTransformer(); if (transformer != null) { event = transformer.transformEvent(event); } variableScopeInstance.setVariable(variableName, event); } triggerCompleted(); } }
public String getEventType() { return resolveVariable(getEventNode().getType()); }
protected void handleSLAViolation() { if (slaCompliance == ProcessInstance.SLA_PENDING) { InternalProcessRuntime processRuntime = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime()); processRuntime.getProcessEventSupport().fireBeforeSLAViolated(getProcessInstance(), this, getProcessInstance().getKnowledgeRuntime()); logger.debug("SLA violated on node instance {}", getId()); this.slaCompliance = ProcessInstance.SLA_VIOLATED; this.slaTimerId = -1; processRuntime.getProcessEventSupport().fireAfterSLAViolated(getProcessInstance(), this, getProcessInstance().getKnowledgeRuntime()); } }
protected void configureSla() { String slaDueDateExpression = (String) getNode().getMetaData().get("customSLADueDate"); if (slaDueDateExpression != null) { TimerInstance timer = ((WorkflowProcessInstanceImpl)getProcessInstance()).configureSLATimer(slaDueDateExpression); if (timer != null) { this.slaTimerId = timer.getId(); this.slaDueDate = new Date(System.currentTimeMillis() + timer.getDelay()); this.slaCompliance = ProcessInstance.SLA_PENDING; logger.debug("SLA for node instance {} is PENDING with due date {}", this.getId(), this.slaDueDate); } } }
public static Collection<String> collectActiveSignals(Collection<NodeInstance> activeNodes) { Collection<String> activeNodesComposite = new ArrayList<String>(); for (NodeInstance nodeInstance : activeNodes) { if (nodeInstance instanceof EventNodeInstance) { String type = ((EventNodeInstance) nodeInstance).getEventNode().getType(); if (type != null && !type.startsWith("Message-")) { activeNodesComposite.add(type); } } if (nodeInstance instanceof CompositeNodeInstance) { Collection<NodeInstance> currentNodeInstances = ((CompositeNodeInstance) nodeInstance).getNodeInstances(); // recursively check current nodes activeNodesComposite.addAll(collectActiveSignals(currentNodeInstances)); } } return activeNodesComposite; }
break; case PersisterEnums.EVENT_NODE_INSTANCE: nodeInstance = new EventNodeInstance(); break; case PersisterEnums.JOIN_NODE_INSTANCE:
public void signalEvent(String type, Object event) { if ("timerTriggered".equals(type)) { TimerInstance timerInstance = (TimerInstance) event; if (timerInstance.getId() == slaTimerId) { handleSLAViolation(); } } else if (("slaViolation:" + getId()).equals(type)) { handleSLAViolation(); } else { String variableName = getEventNode().getVariableName(); if (variableName != null) { VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, variableName); if (variableScopeInstance == null) { throw new IllegalArgumentException( "Could not find variable for event node: " + variableName); } EventTransformer transformer = getEventNode().getEventTransformer(); if (transformer != null) { event = transformer.transformEvent(event); } variableScopeInstance.setVariable(variableName, event); } triggerCompleted(); } }
@Override public void cancel() { getProcessInstance().removeEventListener(getEventType(), getEventListener(), true); removeTimerListeners(); if (this.slaCompliance == ProcessInstance.SLA_PENDING) { if (System.currentTimeMillis() > slaDueDate.getTime()) { // completion of the process instance is after expected SLA due date, mark it accordingly this.slaCompliance = ProcessInstance.SLA_VIOLATED; } else { this.slaCompliance = ProcessInstance.SLA_ABORTED; } } removeTimerListeners(); super.cancel(); }
public String getEventType() { return resolveVariable(getEventNode().getType()); }
public void removeTimerListeners() { ((WorkflowProcessInstance) getProcessInstance()).removeEventListener("timerTriggered", new VariableExternalEventListener("timerTriggered"), false); ((WorkflowProcessInstance) getProcessInstance()).removeEventListener("timer", new VariableExternalEventListener("timer"), true); ((WorkflowProcessInstance) getProcessInstance()).removeEventListener("slaViolation:" + getId(), new VariableExternalEventListener("slaViolation"), true); }
protected void configureSla() { String slaDueDateExpression = (String) getNode().getMetaData().get("customSLADueDate"); if (slaDueDateExpression != null) { TimerInstance timer = ((WorkflowProcessInstanceImpl)getProcessInstance()).configureSLATimer(slaDueDateExpression); if (timer != null) { this.slaTimerId = timer.getId(); this.slaDueDate = new Date(System.currentTimeMillis() + timer.getDelay()); this.slaCompliance = ProcessInstance.SLA_PENDING; logger.debug("SLA for node instance {} is PENDING with due date {}", this.getId(), this.slaDueDate); } } }
String type = ((EventNodeInstance)nodeInstance).getEventNode().getType(); if (type != null && !type.startsWith("Message-")) { childToken.setName(type);
break; case EVENT_NODE : nodeInstance = new EventNodeInstance(); break; case JOIN_NODE :
@Override public void addEventListeners() { String eventType = getEventType(); if (isVariableExpression(getEventNode().getType())) { getProcessInstance().addEventListener(eventType, new VariableExternalEventListener(eventType), true); } else { getProcessInstance().addEventListener(eventType, getEventListener(), true); } if (slaTimerId > -1) { addTimerListener(); } }
public void triggerCompleted() { getProcessInstance().removeEventListener(getEventType(), getEventListener(), true); removeTimerListeners(); if (this.slaCompliance == ProcessInstance.SLA_PENDING) { if (System.currentTimeMillis() > slaDueDate.getTime()) { // completion of the node instance is after expected SLA due date, mark it accordingly this.slaCompliance = ProcessInstance.SLA_VIOLATED; } else { this.slaCompliance = ProcessInstance.STATE_COMPLETED; } } cancelSlaTimer(); ((org.jbpm.workflow.instance.NodeInstanceContainer)getNodeInstanceContainer()).setCurrentLevel(getLevel()); triggerCompleted(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, true); }
protected void addTimerListener() { ((WorkflowProcessInstance) getProcessInstance()).addEventListener("timerTriggered", new VariableExternalEventListener("timerTriggered"), false); ((WorkflowProcessInstance) getProcessInstance()).addEventListener("timer", new VariableExternalEventListener("timer"), true); ((WorkflowProcessInstance) getProcessInstance()).addEventListener("slaViolation:" + getId(), new VariableExternalEventListener("slaViolation"), true); }