Package com.founder.fix.fixflow.core.impl.runtime

Examples of com.founder.fix.fixflow.core.impl.runtime.TokenEntity


    // 执行处理命令中的开发人员设置的表达式
    runCommandExpression();

    // 获取当前操作任务的令牌
    TokenEntity token = getTaskInstanceEntity().getToken();
    // 恢复令牌
    token.suspend();

    try {
      // 保存流程实例
      saveProcessInstance(commandContext);
View Full Code Here


      UserTaskBehavior userTask = (UserTaskBehavior) processDefinition.getDefinitions().getElement(recoverNodeId);

     

      TokenEntity tokenEntity = processInstanceImpl.getTokenMap().get(tokenId);

      tokenEntity.terminationChildTokenWithTask(taskCommand.getTaskCommandType(), taskCommand.getName(), this.taskComment, userId, this.agent, this.admin);

      //TokenEntity token = processInstanceImpl.getTokenMap().get(tokenId);

      ExecutionContext executionContext = ProcessObjectFactory.FACTORYINSTANCE.createExecutionContext(tokenEntity);

      //taskInstanceTemp.setAssigneeWithoutCascade(userId);
      taskInstanceTemp.customEnd(taskCommand, taskComment);

      tokenEntity.removeTaskInstanceSynchronization(taskCommand.getTaskCommandType(), taskCommand.getName(), this.taskComment, userId, this.agent, this.admin);

      if (recoverToTask.getTaskGroup() != null) {

        if (taskCommand != null) {

          userTask.enter(executionContext);

        }

        try {
          saveProcessInstance(commandContext);
        } catch (Exception e) {
          throw new FixFlowException("流程实例持久化失败!", e);
        }
        return null;

      } else {

        if (taskCommand != null) {

          executionContext.setRollBackAssignee(recoverToTask.getAssignee());
          userTask.enter(executionContext);

        }

        try {
          saveProcessInstance(commandContext);
        } catch (Exception e) {
          throw new FixFlowException("流程实例持久化失败!", e);
        }
        return null;

      }

    } else {
     
     
      ProcessDefinitionBehavior processDefinition = processInstanceImpl.getProcessDefinition();

      UserTaskBehavior userTask = (UserTaskBehavior) processDefinition.getDefinitions().getElement(recoverNodeId);

     
     

      TokenEntity tokenEntity = processInstanceImpl.getRootToken();

      tokenEntity.terminationChildTokenWithTask(taskCommand.getTaskCommandType(), taskCommand.getName(), this.taskComment, userId, this.agent, this.admin);

      //TokenEntity token = processInstanceImpl.getTokenMap().get(tokenId);

      ExecutionContext executionContext = ProcessObjectFactory.FACTORYINSTANCE.createExecutionContext(tokenEntity);

      //taskInstanceTemp.setAssigneeWithoutCascade(userId);
      taskInstanceTemp.customEnd(taskCommand, taskComment);

      tokenEntity.removeTaskInstanceSynchronization(taskCommand.getTaskCommandType(), taskCommand.getName(), this.taskComment, userId, this.agent, this.admin);

      if (recoverToTask.getTaskGroup() != null) {

        if (taskCommand != null) {
View Full Code Here

      ProcessInstanceEntity processInstanceImpl = processInstanceManager.findProcessInstanceById(processInstanceId, processDefinition);
      if(processInstanceImpl.hasEnded()){
        return false;
      }
      TokenEntity token = processInstanceImpl.getTokenMap().get(tokenId);

      ExecutionContext executionContext = ProcessObjectFactory.FACTORYINSTANCE.createExecutionContext(token);

      Object returnValueObject = null;
      if (taskCommandInst != null && taskCommandInst.getExpression() != null) {
View Full Code Here

  public TokenEntity removeTimeOutTask() {

    if (getNode().getBoundaryEventRefs().size() > 0) {

      TokenEntity tokenEntity = this.getToken();
      String parentTokenId = tokenEntity.getParent().getId();
      try {
        Scheduler scheduler = Context.getProcessEngineConfiguration().getSchedulerFactory().getScheduler();

        Map<String, TokenEntity> tokenBrothers = tokenEntity.getParent().getChildren();

        int colseTokenBrothersNum = 0;

        for (String tokenBrotherKey : tokenBrothers.keySet()) {

          if (!tokenBrotherKey.equals(tokenEntity.getId())) {

            scheduler.deleteJob(JobKey.jobKey(tokenBrothers.get(tokenBrotherKey).getId(), "FixTimeOutTask_" + parentTokenId));
            tokenBrothers.get(tokenBrotherKey).end();
            colseTokenBrothersNum = colseTokenBrothersNum + 1;
            break;

          }
        }

        if (colseTokenBrothersNum == (tokenBrothers.keySet().size() - 1)) {
          tokenEntity.getParent().terminationChildToken();
          return tokenEntity.getParent();
        }

      } catch (SchedulerException e) {
        e.printStackTrace();
        throw new FixFlowException("流程在离开节点 " + this.getId() + " 的时候发生错误! 错误信息: " + e.toString(), e);
View Full Code Here

    if (taskDefinition != null) {
      taskInstance.setTaskDefinition(taskDefinition);
    }

    if (executionContext != null) {
      TokenEntity token = executionContext.getToken();
      taskInstance.setToken(token);

      // taskInstance.initializeVariables();

      try {
        // update the executionContext
        executionContext.setTaskDefinition(taskDefinition);
        executionContext.setTaskInstance(taskInstance);
        // executionContext.setEventSource(task);
        // 设置会签分组
        if (taskGroup != null) {
          taskInstance.setTaskGroup(taskGroup);
        }

        // 通过表达式获取任务主题
        // String description = null;
        if (taskDefinition != null && taskDefinition.getDescriptionExpression() != null) {

          Object result = ExpressionMgmt.execute(taskDefinition.getDescriptionExpression(), executionContext);
          if (result != null) {
            taskInstance.setDescription(result.toString());
          } else {
            taskInstance.setDescription(token.getFlowNode().getName());
          }
        } else {

          // ProcessDefinitionBehavior processDefinitionBehavior =
          // token.getProcessInstance().getProcessDefinition();

          if (token.getProcessInstance().getSubject() != null && !token.getProcessInstance().getSubject().equals("")) {
            taskInstance.setDescription(token.getProcessInstance().getSubject());
          } else {
            taskInstance.setDescription(token.getFlowNode().getName());
          }

          /*
           * if (processDefinitionBehavior.getTaskSubject() != null &&
           * processDefinitionBehavior
           * .getTaskSubject().getExpressionValue() != null) {
           *
           * Object result =
           * ExpressionMgmt.execute(token.getProcessInstance
           * ().getProcessDefinition
           * ().getTaskSubject().getExpressionValue(),
           * executionContext);
           *
           * if (result != null) {
           * taskInstance.setDescription(result.toString()); } } else
           * {
           * taskInstance.setDescription(token.getFlowNode().getName(
           * )); }
           */

        }

        // 设置任务预计执行时间

        taskInstance.setExpectedExecutionTime(taskDefinition.getExpectedExecutionTimeValue());

        UserTaskBehavior userTask = (UserTaskBehavior) taskDefinition.getUserTaskNode();

        // 获取操作表单
        String formUri = userTask.getFormUri();
        // 获取浏览表单
        String formUriView = userTask.getFormUriView();

        if (formUri != null && !formUri.equals("")) {

          Object returnObject = ExpressionMgmt.execute(formUri, executionContext);
          if (returnObject != null) {
            taskInstance.setFormUri(returnObject.toString());
          }

        } else {

         
          FormUri formUriObj=token.getProcessInstance().getProcessDefinition().getFormUriObj();
         
          String expressionValue=null;
          if (formUriObj != null && formUriObj.getExpression() != null) {
            expressionValue = formUriObj.getExpression().getValue();
          }
         
          Object returnObject = ExpressionMgmt.execute(expressionValue, executionContext);
          if (returnObject != null) {
            taskInstance.setFormUri(StringUtil.getString(returnObject));
          }
           else {
            throw new FixFlowException(userTask.getId() + " 节点没有指定表单,请检查流程配置!");
          }
        }
        if (taskInstance.getFormUri() == null || taskInstance.getFormUri().equals("")) {
          throw new FixFlowException(userTask.getId() + " 节点没有指定表单,请检查流程配置!");
        }

        if (formUriView != null && !formUriView.equals("")) {

          Object returnObject = ExpressionMgmt.execute(formUriView, executionContext);
          if (returnObject != null) {
            taskInstance.setFormUriView(returnObject.toString());
          }

        } else {

          taskInstance.setFormUriView(taskInstance.getFormUri());

        }
        if (taskInstance.getFormUriView() == null || taskInstance.getFormUriView().equals("")) {
          throw new FixFlowException(userTask.getId() + " 节点没有指定添加、浏览表单,请检查流程配置!");
        }

        String taskPriorityExpression = userTask.getTaskPriority();

        if (taskPriorityExpression != null && !taskPriorityExpression.equals("")) {

          Object returnObject = ExpressionMgmt.execute(taskPriorityExpression, executionContext);
          if (returnObject != null) {
            int taskPriority = StringUtil.getInt(returnObject);
            taskInstance.setPriority(taskPriority);
          }

        }

        // 创建任务实例
        taskInstance.create(executionContext);
       
       
        //设置任务的类型
        taskInstance.setTaskInstanceType(taskDefinition.getTaskInstanceType());

        // 对已经分配的任务进行分配
        if (taskDefinition != null) {
          // 如果为退回任务的话则读取退回任务的处理者
          if (executionContext.getRollBackAssignee() != null) {
            taskInstance.setAssignee(executionContext.getRollBackAssignee());
          } else {
            taskInstance.assign(executionContext);
          }

          // 任务分配事件
          ((FlowNodeImpl) token.getFlowNode()).fireEvent(BaseElementEvent.EVENTTYPE_TASK_ASSIGN, executionContext, taskInstance);

        }

      } catch (Exception e) {
        throw new FixFlowException("任务分配出错", e);
View Full Code Here

      ProcessInstanceEntity processInstanceImpl = processInstanceManager.findProcessInstanceById(processInstanceId, processDefinition);
      if(processInstanceImpl.hasEnded()){
        return false;
      }

      TokenEntity token = processInstanceImpl.getTokenMap().get(tokenId);
 
      ExecutionContext executionContext = ProcessObjectFactory.FACTORYINSTANCE.createExecutionContext(token);
     
      Object returnValueObject=null;
      if (taskCommandInst != null && taskCommandInst.getExpression() != null) {
View Full Code Here

   */
  @Deployment(resources = { "com/founder/fix/fixflow/test/engine/api/task/TaskServiceNewTest.bpmn"})
  public void testSaveToken() throws Exception{
    //创建实体
    String guid = GuidUtil.CreateGuid();
    TokenEntity tokenEntity = new TokenEntity();
    tokenEntity.setId(guid);
    tokenEntity.setName("测试令牌");
    tokenEntity.setProcessInstanceId("流程实例编号");
    tokenEntity.setNodeId("节点编号");
    tokenEntity.setParentTokenId("父令牌编号");
    tokenEntity.setParentFreeTokenId("父自由令牌编号");
    tokenEntity.setStartTime(new SimpleDateFormat("yyyy-MM-dd").parse("2012-12-25"));
    tokenEntity.setEndTime(new SimpleDateFormat("yyyy-MM-dd").parse("2012-12-30"));
    tokenEntity.setNodeEnterTime(new SimpleDateFormat("yyyy-MM-dd").parse("2012-12-26"));
    tokenEntity.setLockedString("true");
    tokenEntity.setSuspendedString("true");
    tokenEntity.setSubProcessRootTokenString("true");
    tokenEntity.setAbleToReactivateParentString("true");
    tokenEntity.setFreeTokenString("true");
   
    //保存实体
    Context.getCommandContext().getTokenManager().saveToken(tokenEntity);
   
    //查询实体
    TokenEntity token = Context.getCommandContext().getTokenManager().findTokenById(guid);
   
    //验证属性正确
    assertEquals(guid, token.getId());
    assertEquals("测试令牌", token.getName());
    assertEquals("流程实例编号", token.getProcessInstanceId());
    assertEquals("节点编号", token.getNodeId());
    assertEquals("父令牌编号", token.getParentTokenId());
    assertEquals("父自由令牌编号", token.getParentFreeTokenId());
    assertEquals(new SimpleDateFormat("yyyy-MM-dd").parse("2012-12-25"), token.getStartTime());
    assertTrue(token.getlock());
    assertTrue(token.isSuspended());
    assertTrue(token.isSubProcessRootToken());
    assertTrue(token.isAbleToReactivateParent());
    assertTrue(token.isFreeToken());
  }
View Full Code Here

   */
  @Deployment(resources = { "com/founder/fix/fixflow/test/engine/api/task/TaskServiceNewTest.bpmn"})
  public void testDeleteTokenByProcessInstanceId(){
    //创建实体
    String guid = GuidUtil.CreateGuid();
    TokenEntity tokenEntity = new TokenEntity();
    tokenEntity.setId(guid);
    tokenEntity.setName("测试令牌");
    //设置processinstanceId的关联
    tokenEntity.setProcessInstanceId("processInstanceId");
    //保存实体
    Context.getCommandContext().getTokenManager().saveToken(tokenEntity);
    //查询实体
    TokenEntity token = Context.getCommandContext().getTokenManager().findTokenById(guid);
    //验证保存成功
    assertEquals(guid, token.getId());
   
    //根据processInstanceId删除实体
    Context.getCommandContext().getTokenManager().deleteTokenByProcessInstanceId("processInstanceId");
   
    //查询实体
View Full Code Here

  public Object execute(Object parameter, SqlCommand sqlCommand,
      ProcessEngineConfigurationImpl processEngineConfiguration) {
    // TODO Auto-generated method stub
    Map<String,Object> objectParam = new HashMap<String, Object>();
    TokenEntity token = (TokenEntity)parameter;
    objectParam.put("tokenId", token.getId());
    objectParam.put("name", token.getName());
    objectParam.put("startTime", token.getStartTime());
    objectParam.put("endTime", token.getEndTime());
    objectParam.put("nodeEnterTime", token.getNodeEnterTime());
    objectParam.put("isAbleToReactivateParent", String.valueOf(token.isAbleToReactivateParent()));
    objectParam.put("isSubProcessRootToken", String.valueOf(token.isSubProcessRootToken()));
    objectParam.put("isSuspended", String.valueOf(token.isSuspended()));
    objectParam.put("isLocked", String.valueOf(token.getlock()));
    objectParam.put("nodeId", token.getNodeId());
    objectParam.put("processInstanceId", token.getProcessInstanceId());
    objectParam.put("parentTokenId", token.getParentTokenId());
    objectParam.put("archiveTime", token.getArchiveTime());
    objectParam.put("freeToken", String.valueOf(token.isFreeToken()));
    objectParam.put("parentFreeTokenId", token.getParentFreeTokenId());
   
    Map<String,Object> persistenceExtensionFields=token.getPersistenceExtensionFields()
    for (String key : persistenceExtensionFields.keySet()) {
      objectParam.put(key, persistenceExtensionFields.get(key))
    }
    return objectParam;
  }
View Full Code Here

public class TokenPersistentDbMap implements BusinessRulesScript {

  public Object execute(Object parameter, SqlCommand sqlCommand, ProcessEngineConfigurationImpl processEngineConfiguration) {
   
    TokenEntity token=(TokenEntity)parameter;
   
    Map<String, Object> objectParam = new HashMap<String, Object>();
    objectParam.put("TOKEN_ID", token.getId());
    objectParam.put("NAME", token.getName());
    objectParam.put("PROCESSINSTANCE_ID", token.getProcessInstanceId());
    objectParam.put("NODE_ID", token.getNodeId());
    objectParam.put("PARENT_ID", token.getParentTokenId());
    objectParam.put("PARENT_FREETOKEN_ID", token.getParentFreeTokenId());
    objectParam.put("START_TIME", token.getStartTime());
    objectParam.put("END_TIME", token.getEndTime());
    objectParam.put("NODEENTER_TIME", token.getNodeEnterTime());
    objectParam.put("ARCHIVE_TIME", token.getArchiveTime());
    objectParam.put("TOKEN_LOCK", String.valueOf(token.getlock()));
    objectParam.put("ISSUSPENDED", String.valueOf(token.isSuspended()));
    objectParam.put("ISSUBPROCESSROOTTOKEN", String.valueOf(token.isSubProcessRootToken()));
    objectParam.put("ISABLETOREACTIVATEPARENT", String.valueOf(token.isAbleToReactivateParent()));
    objectParam.put("FREETOKEN", String.valueOf(token.isFreeToken()));
   
    Map<String, Object> persistenceExtensionFields=token.getPersistenceExtensionFields();   
    for (String key : persistenceExtensionFields.keySet()) {
      objectParam.put(key, persistenceExtensionFields.get(key));
    }
    return objectParam;
   
View Full Code Here

TOP

Related Classes of com.founder.fix.fixflow.core.impl.runtime.TokenEntity

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.