protected List<Object> extractJustificationList(RuleContext kcontext) { // Unlike kcontext.getMatch().getObjects(), this includes the matches of accumulate and exists return ((org.drools.core.spi.Activation) kcontext.getMatch()).getObjectsDeep(); }
public boolean evaluate(NodeInstance instance, Connection connection, Constraint constraint) { Object value; try { ProcessContext context = new ProcessContext(((ProcessInstance)instance.getProcessInstance()).getKnowledgeRuntime()); context.setNodeInstance( instance ); value = this.evaluator.evaluate( context ); } catch ( Exception e ) { throw new RuntimeException( "unable to execute ReturnValueEvaluator: ", e ); } if ( !(value instanceof Boolean) ) { throw new RuntimeException( "Constraints must return boolean values: " + value + " for expression " + constraint); } return ((Boolean) value).booleanValue(); }
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; }
public void handleException(ExceptionHandler handler, String exception, Object params) { if (handler instanceof ActionExceptionHandler) { ActionExceptionHandler exceptionHandler = (ActionExceptionHandler) handler; Action action = (Action) exceptionHandler.getAction().getMetaData("Action"); try { ProcessInstance processInstance = getProcessInstance(); ProcessContext processContext = new ProcessContext(processInstance.getKnowledgeRuntime()); ContextInstanceContainer contextInstanceContainer = getContextInstanceContainer(); if (contextInstanceContainer instanceof NodeInstance) { processContext.setNodeInstance((NodeInstance) contextInstanceContainer); } else { processContext.setProcessInstance(processInstance); } String faultVariable = exceptionHandler.getFaultVariable(); if (faultVariable != null) { processContext.setVariable(faultVariable, params); } action.execute(processContext); } catch (Exception e) { throw new RuntimeException("unable to execute Action", e); } } else { throw new IllegalArgumentException("Unknown exception handler " + handler); } }
ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() ); ((Action) actionNode.getAction().getMetaData("Action")).execute( processContext );
if (ruleFlowGroup != null && !agenda.getRuleFlowGroup(ruleFlowGroup).isActive()) { agenda.getRuleFlowGroup(ruleFlowGroup).setAutoDeactivate(false); agenda.activateRuleFlowGroup(ruleFlowGroup, getProcessInstance().getId(), getUniqueId());
public double getD() { return bit_reader.getDoubleValue( object ); }
public final int compare(final Activation existing, final Activation adding) { final int s1 = existing.getSalience(); final int s2 = adding.getSalience(); if (s1 != s2) { return s1 - s2; } // we know that no two activations will have the same number return (int) (existing.getActivationNumber() - adding.getActivationNumber()); }
public String getName() { // return object.getName(); return (String) name_reader.getValue(object); }
public void setD(double d) { bit_writer.setDoubleValue( object, d ); }
public void setName(String name) { // object.setName( name ); name_writer.setValue(object, name); }
private void handleAssignment(Assignment assignment) { AssignmentAction action = (AssignmentAction) assignment.getMetaData("Action"); try { ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime()); context.setNodeInstance(this); action.execute(getWorkItem(), context); } catch (Exception e) { throw new RuntimeException("unable to execute Assignment", e); } }
ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() ); ((MVELAction) actionNode.getAction().getMetaData("Action")).compile( data ); ((Action)actionNode.getAction().getMetaData("Action")).execute( processContext );
public double getD() { return bit_reader.getDoubleValue( object ); }
public void setD(double d) { bit_writer.setDoubleValue( object, d ); }
public void internalTrigger(final NodeInstance from, String type) { if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) { throw new IllegalArgumentException( "An ActionNode only accepts default incoming connections!"); } Action action = (Action) getActionNode().getAction().getMetaData("Action"); try { ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime()); context.setNodeInstance(this); executeAction(action); } catch( WorkflowRuntimeException wre) { throw wre; } catch (Exception e) { // for the case that one of the following throws an exception // - the ProcessContext() constructor // - or context.setNodeInstance(this) throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e); } triggerCompleted(); }
wm.setGlobal( "list", list ); ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() ); ((Action) actionNode.getAction().getMetaData("Action")).execute( processContext );
/** * This method is used in both instances of the {@link ExtendedNodeInstanceImpl} * and {@link ActionNodeInstance} instances in order to handle * exceptions thrown when executing actions. * * @param action An {@link Action} instance. */ protected void executeAction(Action action) { ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime()); context.setNodeInstance(this); try { action.execute(context); } catch (Exception e) { String exceptionName = e.getClass().getName(); ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName); if (exceptionScopeInstance == null) { throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e); } exceptionScopeInstance.handleException(exceptionName, e); cancel(); } }
ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() ); ((Action) actionNode.getAction().getMetaData("Action")).execute(processContext);