Package org.jbpm.graph.exe

Examples of org.jbpm.graph.exe.Token


      if (taskControllerDelegation != null) {
        TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
        ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
        ContextInstance contextInstance = (processInstance != null ? processInstance.getContextInstance() : null);
        Token token = taskInstance.getToken();

        if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
          UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerSubmission(taskControllerHandler, taskInstance, contextInstance, token);
        } else {
          taskControllerHandler.submitTaskVariables(taskInstance, contextInstance, token);
        }

      } else {

        Token token = taskInstance.getToken();
        ProcessInstance processInstance = token.getProcessInstance();
        ContextInstance contextInstance = processInstance.getContextInstance();

        if (variableAccesses != null) {
          String missingTaskVariables = null;
          for (VariableAccess variableAccess : variableAccesses) {
View Full Code Here


  public void take(ExecutionContext executionContext)
  {
    // update the runtime context information
    executionContext.getToken().setNode(null);

    Token token = executionContext.getToken();

    if ((condition != null) && (isConditionEnforced))
    {
      Object result = JbpmExpressionEvaluator.evaluate(condition, executionContext);
      if (result == null)
      {
        throw new JbpmException("transition condition " + condition + " evaluated to null");
      }
      else if (!(result instanceof Boolean))
      {
        throw new JbpmException("transition condition " + condition + " evaluated to non-boolean: " + result.getClass().getName());
      }
      else if (!((Boolean)result).booleanValue())
      {
        throw new JbpmException("transition condition " + condition + " evaluated to 'false'");
      }
    }

    // start the transition log
    TransitionLog transitionLog = new TransitionLog(this, executionContext.getTransitionSource());
    token.startCompositeLog(transitionLog);
    try
    {

      // fire leave events for superstates (if any)
      fireSuperStateLeaveEvents(executionContext);

      // fire the transition event (if any)
      fireEvent(Event.EVENTTYPE_TRANSITION, executionContext);

      // fire enter events for superstates (if any)
      Node destination = fireSuperStateEnterEvents(executionContext);
      // update the ultimate destinationNode of this transition
      transitionLog.setDestinationNode(destination);

    }
    finally
    {
      // end the transition log
      token.endCompositeLog();
    }

    // pass the token to the destinationNode node
    to.enter(executionContext);
  }
View Full Code Here

    // assign an id to the task instance
    Services.assignId(taskInstance);

    if (executionContext != null)
    {
      Token token = executionContext.getToken();
      taskInstance.setToken(token);
      taskInstance.setProcessInstance(token.getProcessInstance());

      taskInstance.initializeVariables();

      if (task != null && task.getDueDate() != null)
      {
        Date baseDate;
        String dueDateString = task.getDueDate();
        String durationString = null;

        if (dueDateString.startsWith("#"))
        {
          String baseDateEL = dueDateString.substring(0, dueDateString.indexOf("}") + 1);
          Object result = JbpmExpressionEvaluator.evaluate(baseDateEL, executionContext);
          if (result instanceof Date)
          {
            baseDate = (Date)result;
          }
          else if (result instanceof Calendar)
          {
            baseDate = ((Calendar)result).getTime();
          }
          else
          {
            throw new JbpmException("Invalid basedate type: " + baseDateEL + " is of type " + result.getClass().getName()
                + ". Only Date and Calendar are supported");
          }
          int endOfELIndex = dueDateString.indexOf("}");
          if (endOfELIndex < (dueDateString.length() - 1))
          {
            char durationSeparator = dueDateString.substring(endOfELIndex + 1).trim().charAt(0);
            if (durationSeparator != '+' && durationSeparator != '-')
            {
              throw new JbpmException("Invalid duedate, + or - missing after EL");
            }
            durationString = dueDateString.substring(endOfELIndex + 1).trim();
          }
        }
        else
        {
          baseDate = Clock.getCurrentTime();
          durationString = dueDateString;
        }
        Date dueDate;
        if (durationString == null || durationString.length() == 0)
        {
          dueDate = baseDate;
        }
        else
        {
          BusinessCalendar businessCalendar = new BusinessCalendar();
          dueDate = businessCalendar.add(baseDate, new Duration(durationString));
        }
        taskInstance.setDueDate(dueDate);
      }

      try
      {
        // update the executionContext
        executionContext.setTask(task);
        executionContext.setTaskInstance(taskInstance);
        executionContext.setEventSource(task);

        // evaluate the description
        if (task != null)
        {
          String description = task.getDescription();
          if ((description != null) && (description.indexOf("#{") != -1))
          {
            Object result = JbpmExpressionEvaluator.evaluate(description, executionContext);
            if (result != null)
            {
              taskInstance.setDescription(result.toString());
            }
          }
        }

        // create the task instance
        taskInstance.create(executionContext);

        // if this task instance is created for a task, perform assignment
        if (task != null)
        {
          taskInstance.assign(executionContext);
        }

      }
      finally
      {
        // clean the executionContext
        executionContext.setTask(null);
        executionContext.setTaskInstance(null);
        executionContext.setEventSource(null);
      }

      // log this creation
      // WARNING: The events create and assign are fired in the right order, but
      // the logs are still not ordered properly.
      token.addLog(new TaskCreateLog(taskInstance, taskInstance.getActorId()));

    }
    else
    {
      taskInstance.create();
View Full Code Here

  {
    TaskInstance taskInstance = null;
    Task startTask = taskMgmtDefinition.getStartTask();
    if (startTask != null)
    {
      Token rootToken = processInstance.getRootToken();
      ExecutionContext executionContext = new ExecutionContext(rootToken);
      taskInstance = createTaskInstance(startTask, executionContext);
      taskInstance.setActorId(SecurityHelper.getAuthenticatedActorId());
    }
    return taskInstance;
View Full Code Here

    Set<String> outputNames = getOutputNames();
    return eval(inputMap, outputNames);
  }

  public Map<String, Object> createInputMap(ExecutionContext executionContext) {
    Token token = executionContext.getToken();

    Map<String, Object> inputMap = new HashMap<String, Object>();
    inputMap.put("executionContext", executionContext);
    inputMap.put("token", token);
    inputMap.put("node", executionContext.getNode());
View Full Code Here

  void setVariables(Map<String, Object> outputMap, ExecutionContext executionContext) {
    if ((outputMap != null) && (!outputMap.isEmpty()) && (executionContext != null)) {
      Map<String, String> variableNames = getVariableNames();
      ContextInstance contextInstance = executionContext.getContextInstance();
      Token token = executionContext.getToken();

      for (Map.Entry<String, String> entry : variableNames.entrySet()) {
        String mappedName = entry.getKey();
        String variableName = entry.getValue();
        contextInstance.setVariable(variableName, outputMap.get(mappedName), token);
View Full Code Here

    }
    else
    {
      ContextInstance contextInstance = executionContext.getContextInstance();
      TaskMgmtInstance taskMgmtInstance = executionContext.getTaskMgmtInstance();
      Token token = executionContext.getToken();

      if ((contextInstance != null) && (contextInstance.hasVariable(name, token)))
      {
        value = contextInstance.getVariable(name, token);
      }
View Full Code Here

            final Map<String,Object> updatesMap;
            if (value instanceof ProcessInstance) {
                final ProcessInstance processInstance = (ProcessInstance) value;
                updatesMap = new UpdatesHashMap(processInstance.getContextInstance().getVariables());
            } else if (value instanceof Token) {
                final Token token = (Token) value;
                updatesMap = new UpdatesHashMap(token.getProcessInstance().getContextInstance().getVariables(token));
            } else if (value instanceof TaskInstance) {
                final TaskInstance task = (TaskInstance) value;
                updatesMap = new UpdatesHashMap(task.getVariables());
            } else if (value == null) {
                context.setError("Error getting variable map", "The value was given as null");
View Full Code Here

                    forUpdate = Boolean.parseBoolean(forUpdateValue.toString());
                }
            } else {
                forUpdate = event.getPhaseId() != PhaseId.RENDER_RESPONSE;
            }
            final Token token;
            if (forUpdate) {
                token = context.getJbpmContext().getTokenForUpdate(id);
            } else {
                token = context.getJbpmContext().getToken(id);
            }
View Full Code Here

            if (entity instanceof TaskInstance) {
                final TaskInstance task = (TaskInstance) entity;
                oldValue = task.getVariable(name);
                task.deleteVariable(name);
            } else if (entity instanceof Token) {
                final Token token = (Token) entity;
                final ContextInstance contextInstance = token.getProcessInstance().getContextInstance();
                oldValue = contextInstance.getVariable(name, token);
                contextInstance.deleteVariable(name, token);
            } else if (entity instanceof ProcessInstance) {
                final ProcessInstance processInstance = (ProcessInstance) entity;
                final ContextInstance contextInstance = processInstance.getContextInstance();
View Full Code Here

TOP

Related Classes of org.jbpm.graph.exe.Token

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.