protected String getActivationType() { return "RuleFlowStateEvent-" + this.getProcessInstance().getProcessId(); }
protected void addTimerListener() { ((WorkflowProcessInstance) getProcessInstance()).addEventListener("timerTriggered", this, false); ((WorkflowProcessInstance) getProcessInstance()).addEventListener("timer", this, true); ((WorkflowProcessInstance) getProcessInstance()).addEventListener("slaViolation:" + getId(), this, true); }
public void removeEventListeners() { ((WorkflowProcessInstance) getProcessInstance()).removeEventListener("timerTriggered", this, false); ((WorkflowProcessInstance) getProcessInstance()).removeEventListener("timer", this, true); ((WorkflowProcessInstance) getProcessInstance()).removeEventListener("slaViolation:" + getId(), this, true); }
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()); } }
private void removeActivationListener() { getProcessInstance().removeEventListener(getActivationType(), this, true); }
private void addActivationListener() { getProcessInstance().addEventListener(getActivationType(), this, true); }
public void addEventListeners() { if (timerInstances != null && timerInstances.size() > 0 || slaTimerId > -1) { addTimerListener(); } if (slaCompliance == ProcessInstance.SLA_PENDING) { ((WorkflowProcessInstance) getProcessInstance()).addEventListener("slaViolation:" + getId(), this, true); } }
protected void mapDynamicOutputData(Map<String, Object> results) { if (results != null && !results.isEmpty()) { VariableScope variableScope = (VariableScope) ((ContextContainer) getProcessInstance().getProcess()).getDefaultContext( VariableScope.VARIABLE_SCOPE ); VariableScopeInstance variableScopeInstance = (VariableScopeInstance)getProcessInstance().getContextInstance(VariableScope.VARIABLE_SCOPE); for (Entry<String, Object> result : results.entrySet()) { String variableName = result.getKey(); Variable variable = variableScope.findVariable(variableName); if (variable == null) { // check if there is any match for case file data variableName = VariableScope.CASE_FILE_PREFIX + variableName; // check only those that are defined and avoid dynamically created case file variables List<String> definedVariables = Arrays.asList(variableScope.getVariableNames()); if (definedVariables.contains(variableName)) { variable = variableScope.findVariable(variableName); } } if (variable != null) { variableScopeInstance.getVariableScope().validateVariable(getProcessInstance().getProcessName(), variableName, result.getValue()); variableScopeInstance.setVariable(variableName, result.getValue()); } } } } }
private void cancelSlaTimer() { if (this.slaTimerId > -1) { TimerManager timerManager = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime()).getTimerManager(); timerManager.cancelTimer(this.slaTimerId); logger.debug("SLA Timer {} has been canceled", this.slaTimerId); } }
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); addTimerListener(); } } }
protected boolean checkProcessInstance(Activation activation) { final Map<?, ?> declarations = activation.getSubRule().getOuterDeclarations(); for ( Iterator<?> it = declarations.values().iterator(); it.hasNext(); ) { Declaration declaration = (Declaration) it.next(); if ("processInstance".equals(declaration.getIdentifier()) || "org.kie.api.runtime.process.WorkflowProcessInstance".equals(declaration.getTypeName())) { Object value = declaration.getValue( ((StatefulKnowledgeSessionImpl) getProcessInstance().getKnowledgeRuntime()).getInternalWorkingMemory(), ((InternalFactHandle) activation.getTuple().get(declaration)).getObject()); if (value instanceof ProcessInstance) { return ((ProcessInstance) value).getId() == getProcessInstance().getId(); } } } return true; }
private void cancelTimers() { // deactivate still active timers if (timerInstances != null) { TimerManager timerManager = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime()).getTimerManager(); for (Long id: timerInstances) { timerManager.cancelTimer(id); } } }
timerInstances = new ArrayList<Long>(timers.size()); TimerManager timerManager = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime()).getTimerManager(); for (Timer timer: timers.keySet()) { TimerInstance timerInstance = createTimerInstance(timer); timerManager.registerTimer(timerInstance, (ProcessInstance) getProcessInstance()); timerInstances.add(timerInstance.getId()); boolean isActive = ((InternalAgenda) getProcessInstance().getKnowledgeRuntime().getAgenda()) .isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", name, getProcessInstance().getId()); if (isActive) { getProcessInstance().getKnowledgeRuntime().signalEvent(name, null); } else { addActivationListener(); ((WorkflowProcessInstanceImpl) getProcessInstance()).addActivatingNodeId((String) getNode().getMetaData().get("UniqueId"));
protected TimerInstance createTimerInstance(Timer timer) { TimerInstance timerInstance = new TimerInstance(); KieRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); if (kruntime != null && kruntime.getEnvironment().get("jbpm.business.calendar") != null){ BusinessCalendar businessCalendar = (BusinessCalendar) kruntime.getEnvironment().get("jbpm.business.calendar");
public void removeEventListeners() { ((WorkflowProcessInstance) getProcessInstance()).removeEventListener("timerTriggered", this, false); ((WorkflowProcessInstance) getProcessInstance()).removeEventListener("timer", this, true); ((WorkflowProcessInstance) getProcessInstance()).removeEventListener("slaViolation:" + getId(), this, true); }
protected void addTimerListener() { ((WorkflowProcessInstance) getProcessInstance()).addEventListener("timerTriggered", this, false); ((WorkflowProcessInstance) getProcessInstance()).addEventListener("timer", this, true); ((WorkflowProcessInstance) getProcessInstance()).addEventListener("slaViolation:" + getId(), this, true); }
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()); } }
public void addEventListeners() { if (timerInstances != null && timerInstances.size() > 0 || slaTimerId > -1) { addTimerListener(); } if (slaCompliance == ProcessInstance.SLA_PENDING) { ((WorkflowProcessInstance) getProcessInstance()).addEventListener("slaViolation:" + getId(), this, true); } }
private void cancelSlaTimer() { if (this.slaTimerId > -1) { TimerManager timerManager = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime()).getTimerManager(); timerManager.cancelTimer(this.slaTimerId); logger.debug("SLA Timer {} has been canceled", this.slaTimerId); } }
private void cancelTimers() { // deactivate still active timers if (timerInstances != null) { TimerManager timerManager = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime()).getTimerManager(); for (Long id: timerInstances) { timerManager.cancelTimer(id); } } }