Package org.drools.process.instance

Examples of org.drools.process.instance.ProcessInstance


    if (handler instanceof ActionExceptionHandler) {
      Action action = (Action) ((ActionExceptionHandler) handler).getAction().getMetaData("Action");
      try {
          KnowledgeHelper knowledgeHelper = createKnowledgeHelper();
          ProcessContext context = new ProcessContext();
          ProcessInstance processInstance = getProcessInstance();
          ContextInstanceContainer contextInstanceContainer = getContextInstanceContainer();
          if (contextInstanceContainer instanceof NodeInstance) {
            context.setNodeInstance((NodeInstance) contextInstanceContainer);
          } else {
            context.setProcessInstance(processInstance);
View Full Code Here


        }
        final Process process = ((InternalRuleBase) getRuleBase()).getProcess( processId );
        if ( process == null ) {
            throw new IllegalArgumentException( "Unknown process ID: " + processId );
        }
        ProcessInstance processInstance = (ProcessInstance) getProcessInstance( process );
        processInstance.setWorkingMemory( this );
        processInstance.setProcess( process );
        processInstanceManager.addProcessInstance( processInstance );
        // set variable default values
        // TODO: should be part of processInstanceImpl?
        VariableScope variableScope = (VariableScope) ((ContextContainer) process).getDefaultContext( VariableScope.VARIABLE_SCOPE );
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance) processInstance.getContextInstance( VariableScope.VARIABLE_SCOPE );
        // set input parameters
        if ( parameters != null ) {
            if ( variableScope != null ) {
                for ( Map.Entry<String, Object> entry : parameters.entrySet() ) {
                    variableScopeInstance.setVariable( entry.getKey(),
                                                       entry.getValue() );
                }
            } else {
                throw new IllegalArgumentException( "This process does not support parameters!" );
            }
        }
        // start
        getRuleFlowEventSupport().fireBeforeRuleFlowProcessStarted( processInstance,
                                                                    this );
        processInstance.start();
        getRuleFlowEventSupport().fireAfterRuleFlowProcessStarted( processInstance,
                                                                   this );

        return processInstance;
    }
View Full Code Here

        ProcessInstanceFactoryRegistry processRegistry = ((InternalRuleBase) getRuleBase()).getConfiguration().getProcessInstanceFactoryRegistry();
        ProcessInstanceFactory conf = processRegistry.getProcessInstanceFactory( process );
        if ( conf == null ) {
            throw new IllegalArgumentException( "Illegal process type: " + process.getClass() );
        }
        ProcessInstance processInstance = conf.createProcessInstance();
        if ( processInstance == null ) {
            throw new IllegalArgumentException( "Illegal process type: " + process.getClass() );
        }
        return processInstance;
    }
View Full Code Here

  public Object execute(ReteooWorkingMemory session) {
    if (processInstanceId == -1) {
      session.getSignalManager().signalEvent(eventType, event);
    } else {
      ProcessInstance processInstance = session.getProcessInstance(processInstanceId);
      if (processInstance != null) {
        processInstance.signalEvent(eventType, event);
      }
    }
    return null;
  }
View Full Code Here

    if (data != null) {
      for (Object o: data) {
        session.insert(o);
      }
    }
    ProcessInstance processInstance = (ProcessInstance) session.startProcess(processId, parameters);
    return processInstance;
  }
View Full Code Here

    public void completeWorkItem(long id, Map<String, Object> results) {
        WorkItem workItem = (WorkItem) workItems.get(new Long(id));
        // work item may have been aborted
        if (workItem != null) {
            ((org.drools.process.instance.WorkItem) workItem).setResults(results);
            ProcessInstance processInstance = ( ProcessInstance ) workingMemory.getProcessInstance(workItem.getProcessInstanceId());
            ((org.drools.process.instance.WorkItem) workItem).setState(WorkItem.COMPLETED);
            // process instance may have finished already
            if (processInstance != null) {
                processInstance.signalEvent("workItemCompleted", workItem);
            }
            workItems.remove(new Long(id));
            workingMemory.fireAllRules();
        }
    }
View Full Code Here

    public void abortWorkItem(long id) {
        WorkItemImpl workItem = (WorkItemImpl) workItems.get(new Long(id));
        // work item may have been aborted
        if (workItem != null) {
            ProcessInstance processInstance = ( ProcessInstance ) workingMemory.getProcessInstance(workItem.getProcessInstanceId());
            workItem.setState(WorkItem.ABORTED);
            // process instance may have finished already
            if (processInstance != null) {
                processInstance.signalEvent("workItemAborted", workItem);
            }
            workItems.remove(new Long(id));
            workingMemory.fireAllRules();
        }
    }
View Full Code Here

                throw new IllegalArgumentException( "Could not find process instance for timer " );
            }
           
            ctx.getTimer().setLastTriggered(new Date());
           
            ProcessInstance processInstance = ( ProcessInstance ) workingMemory.getProcessInstance( processInstanceId );
            // process instance may have finished already
            if ( processInstance != null ) {
                workingMemory.getSignalManager().signalEvent(processInstance, "timerTriggered", ctx.getTimer());
            }
View Full Code Here

        }
        final Process process = ((InternalRuleBase) getRuleBase()).getProcess( processId );
        if ( process == null ) {
            throw new IllegalArgumentException( "Unknown process ID: " + processId );
        }
        ProcessInstance processInstance = ( ProcessInstance ) getProcessInstance( process );
        processInstance.setWorkingMemory( this );
        processInstance.setProcess( process );
        processInstanceManager.addProcessInstance( processInstance );
        // set variable default values
        // TODO: should be part of processInstanceImpl?
        VariableScope variableScope = (VariableScope) ((ContextContainer) process).getDefaultContext( VariableScope.VARIABLE_SCOPE );
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance) processInstance.getContextInstance( VariableScope.VARIABLE_SCOPE );
        // set input parameters
        if ( parameters != null ) {
            if ( variableScope != null ) {
                for ( Map.Entry<String, Object> entry : parameters.entrySet() ) {
                    variableScopeInstance.setVariable( entry.getKey(),
                                                       entry.getValue() );
                }
            } else {
                throw new IllegalArgumentException( "This process does not support parameters!" );
            }
        }
        // start
        getRuleFlowEventSupport().fireBeforeRuleFlowProcessStarted( processInstance,
                                                                    this );
        processInstance.start();
        getRuleFlowEventSupport().fireAfterRuleFlowProcessStarted( processInstance,
                                                                   this );

        return processInstance;
    }
View Full Code Here

        ProcessInstanceFactoryRegistry processRegistry = ((InternalRuleBase) getRuleBase()).getConfiguration().getProcessInstanceFactoryRegistry();
        ProcessInstanceFactory conf = processRegistry.getProcessInstanceFactory( process );
        if ( conf == null ) {
            throw new IllegalArgumentException( "Illegal process type: " + process.getClass() );
        }
        ProcessInstance processInstance = conf.createProcessInstance();
        if ( processInstance == null ) {
            throw new IllegalArgumentException( "Illegal process type: " + process.getClass() );
        }
        return processInstance;
    }
View Full Code Here

TOP

Related Classes of org.drools.process.instance.ProcessInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.