Package com.founder.fix.fixflow.core.exception

Examples of com.founder.fix.fixflow.core.exception.FixFlowException


  }

  public Void execute(CommandContext commandContext) {

    if (taskId == null) {
      throw new FixFlowException("任务编号为空!");
    }

     
     
      TaskManager taskManager = commandContext.getTaskManager();

      TaskInstance taskInstanceQuery = taskManager.findTaskById(taskId);

     
      String processDefinitionId = taskInstanceQuery.getProcessDefinitionId();
      ProcessInstanceManager processInstanceManager = commandContext.getProcessInstanceManager();

      String processInstanceId = taskInstanceQuery.getProcessInstanceId();

      ProcessDefinitionManager processDefinitionManager = commandContext.getProcessDefinitionManager();

      ProcessDefinitionBehavior processDefinition = processDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);

     
     
      ProcessInstanceEntity processInstanceImpl = processInstanceManager.findProcessInstanceById(processInstanceId, processDefinition);

   

      List<TaskInstanceEntity> taskInstances = processInstanceImpl.getTaskMgmtInstance().getTaskInstanceEntitys();

      for (TaskInstanceEntity taskInstance : taskInstances) {
        if (taskInstance.getId().equals(taskId)) {
       
         
          TaskInstanceEntity taskInstanceImpl= taskInstance;
            taskInstanceImpl.setTaskComment(this.taskComment);
           
        }
      }

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


  }
View Full Code Here


    // 是否启用验证
    if (executionContext.getProcessDefinition().isVerification()) {
      // 这里是验证的设计阶段有没有配置处理者
      if (!checkResources()) {
        throw new FixFlowException("节点: " + this.getId() + " 没有定义处理者,请重新检查节点定义!");
      }
    }

    // 创建并分配任务
    TaskInstanceEntity taskInstance = null;

    if (executionContext.getGroupID() != null) {
      taskInstance = tmi.createTaskInstanceEntity(getTaskDefinition(), executionContext, executionContext.getGroupID());
    } else {
      taskInstance = tmi.createTaskInstanceEntity(getTaskDefinition(), executionContext);
    }

    // 是否启用验证
    // if (!executionContext.getProcessDefinition().isVerification()) {
    // return;
    //

    // 当独占任务和候选任务都没有的时候则直接弹出异常消息.
    if (taskInstance.getAssignee() == null && taskInstance.getTaskIdentityLinks().size() == 0) {
      throw new FixFlowException("节点: " + this.getId() + " 无对应处理者,请重新检查节点定义!");
    } else {
      // 检查分配的用户或者组是否存在,不存在则抛出异常
      if (taskInstance.getAssignee() != null) {
        if (taskInstance.getAssignee().equals("fixflow_allusers")) {
          throw new FixFlowException("独占处理者不能是所有人");
          // return;
        }
        UserTo userTo = Authentication.findUserInfoByUserId(taskInstance.getAssignee());
        if (userTo == null) {
          throw new FixFlowException("节点: " + this.getId() + " 指定的处理者 " + taskInstance.getAssignee() + " 不存在,请重新检查节点定义!");
        }
      }

      if (taskInstance.getTaskIdentityLinks().size() > 0) {
        for (IdentityLink identityLink : taskInstance.getTaskIdentityLinks()) {

          if (identityLink.getUserId() != null) {
            if (identityLink.getUserId().equals("fixflow_allusers")) {
              return;
            }
            UserTo userTo = Authentication.findUserInfoByUserId(identityLink.getUserId());
            if (userTo == null) {
              // throw new
              // FixFlowException("节点: "+this.getId()+" 指定的处理者 "+
              // identityLink.getUserId() +" 不存在,请重新检查节点定义!");
            } else {
              return;
            }
          } else {
            String groupIdString = identityLink.getGroupId();
            String groupTypeString = identityLink.getGroupType();
            GroupTo groupTo = Authentication.findGroupByGroupIdAndType(groupIdString, groupTypeString);
            if (groupTo == null) {

            } else {

              // 这里是否需要验证一下组里边是否还有人?

              return;
            }
            // identityLink.getGroupId()
          }

        }

        throw new FixFlowException("节点: " + this.getId() + " 您所指定的应处理者都不存在,请重新检查节点定义!");

      }

    }
View Full Code Here

          skipAssigneeString = StringUtil.getString(ExpressionMgmt.execute(skipAssignee.getExpression().getValue(),
              executionContext));

        } catch (Exception e) {

          throw new FixFlowException("节点 " + this.getId() + " " + this.getName() + " 的跳过策略出错请检查流程配置!", e);
        }
      }
    }

    if (skipComment != null && skipComment.getExpression() != null) {
      if (skipComment.getExpression().getValue() != null && !skipComment.getExpression().getValue().equals("")) {
        try {
          skipCommentString = StringUtil.getString(ExpressionMgmt.execute(skipComment.getExpression().getValue(),
              executionContext));

        } catch (Exception e) {

          throw new FixFlowException("节点 " + this.getId() + " " + this.getName() + " 的跳过策略出错请检查流程配置!", e);
        }
      }
    }

    TokenEntity token = executionContext.getToken();
View Full Code Here

      try {
        commandContext.getProcessInstanceManager().saveProcessInstance(processInstance);
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        throw new FixFlowException(e.toString(), e);
      }
     
     
    }else{
     
View Full Code Here

    this.processInstanceId=processInstanceId;
  }
 
  public Void execute(CommandContext commandContext) {
    if (processInstanceId == null || processInstanceId.equals("")) {
      throw new FixFlowException("流程实例编号为空!");
    }

    // 创建流程实例管理器
    ProcessInstanceManager processInstanceManager = commandContext.getProcessInstanceManager();

    // 获取流程实例
    ProcessInstanceEntity processInstanceImpl = processInstanceManager.findProcessInstanceById(processInstanceId);

   
    if(processInstanceImpl.isSuspended()){
      throw new FixFlowException("流程实例已经暂停,不能再次暂停");
    }
   
    if(processInstanceImpl.hasEnded()){
      throw new FixFlowException("流程实例已经结束,不能暂停");
    }
   
    //暂停流程实例
    processInstanceImpl.suspend();
 
    try {
      // 持久化实例
      processInstanceManager.saveProcessInstance(processInstanceImpl);
    } catch (Exception e) {
      throw new FixFlowException("流程实例持久化失败!", e);
    }
    return null;
  }
View Full Code Here

     
    }
    // 节点后面没有线的处理
    if (sequenceFlowList.size()==0) {
      if(getOutgoing().size()==0){
        throw new FixFlowException(this.getName()+"("+this.getId()+") 节点后面没有处理线条!");
      }
      else{
        throw new FixFlowException(this.getName()+"("+this.getId()+") 节点后面的条件都不满足导致节点后面没有处理线条,请检查后续线条条件!");
      }
     
     
    }
View Full Code Here

        {
          super.execute(executionContext);
        }
        else
        {
          throw new FixFlowException("名称为: "+this.name+" 的条件网关条件不满足!");
        }
      }
      else
      {
        throw new FixFlowException("名称为: "+this.name+" 的条件网关表达式解释出错!");
      }
    }
    else
    {
      LOG.info("ComplexGateway id: "+this.id+" 条件网关未配置条件!");
View Full Code Here

    if (returnTransientCachedObjects == null) {

      if (cachedObjects.getCacheData(persistentObjectName + "_access") != null) {

        if (cachedObjects.getCacheData(persistentObjectName + "_access").toString().equals("use")) {
          throw new FixFlowException("当前流程实例正在被另一个用户处理中!请稍后再试!");
        }

        if (cachedObjects.getCacheData(persistentObjectName + "_access").toString().equals("dirty")) {
          cachedObjects.putCacheData(persistentObjectName + "_access", "use");
          transientCachedObjects.put(persistentObjectName, null);
View Full Code Here

    }
   
    String expressionText=formalExpression.getBody();
   
    if(expressionText==null){
      throw new FixFlowException("超时表达式不能为空");
    }
    Date date=null;
    String expressionTemp=null;//"0 0-5 14 * * ?" 在每天下午2点到下午2:05期间的每1分钟触发
    List<Object> timeObjects=new ArrayList<Object>();
    try {
      Object dateObj=ExpressionMgmt.execute(expressionText, executionContext);
      if(dateObj instanceof Date){
        date=(Date)dateObj;
      }
      else{
        if(dateObj instanceof List){
          timeObjects=(List<Object>)dateObj;
        }else{
          expressionTemp=StringUtil.getString(dateObj);
        }
       
      }
     
    } catch (Exception e) {
      throw new FixFlowException("超时表达式计算失败!原因是: "+e.toString(),e);
    }
   
    TokenEntity tokenEntity=executionContext.getToken();
    String processInstanceId=tokenEntity.getProcessInstance().getId();
    /*VariableTransferEntity variableTransferEntity = new VariableTransferEntity();
    Map<String, Object> transientVariableMap=tokenEntity.getProcessInstance().getContextInstance().getTransientVariableMap();
    String guidString=GuidUtil.CreateGuid();
    variableTransferEntity.addVariable(guidString, transientVariableMap);
   
    if (processInstanceId != null && !processInstanceId.equals("")) {
      VariableFlowTypeEntity variableFlowTypeEntity = new VariableFlowTypeEntity(VariableFlowType.PROCESSINSTANCE, processInstanceId);
      variableTransferEntity.addVariableFlowType(variableFlowTypeEntity);
    }
 
    Context.getCommandContext().getVariableManager().saveVariable(variableTransferEntity);
    */
   
   
    Scheduler scheduler=Context.getProcessEngineConfiguration().getScheduler();

   
   
   
    Map<JobDetail, List<Trigger>> jobList=new HashMap<JobDetail, List<Trigger>>();
   
   
   
   
   
   
   
    JobDetail job = QuartzUtil.createJobDetail(
        TokenTimeOutJob.class,  GuidUtil.CreateGuid()+"_"+tokenEntity.getId(), tokenEntity.getId()+"_"+processInstanceId+"_"+tokenEntity.getProcessInstance().getProcessDefinitionId());
    job.getJobDataMap().put("tokenId", tokenEntity.getId());
    //job.getJobDataMap().put("transientVariableId", guidString);
    job.getJobDataMap().put("processInstanceId", processInstanceId);
    job.getJobDataMap().put("nodeId", event.getId());
    job.getJobDataMap().put("processKey", tokenEntity.getProcessInstance().getProcessDefinitionKey());
    job.getJobDataMap().put("processId", tokenEntity.getProcessInstance().getProcessDefinitionId());
    job.getJobDataMap().put("processName", tokenEntity.getProcessInstance().getProcessDefinition().getName());
    job.getJobDataMap().put("bizKey", tokenEntity.getProcessInstance().getBizKey());
    job.getJobDataMap().put("jobType", "fixTimeOutTask");
   
   
    if(date==null){
     
      if(expressionTemp!=null&&!expressionTemp.equals("")){
        Trigger trigger = null;
        trigger =  QuartzUtil.createCronTrigger(
            GuidUtil.CreateGuid(), "FixTimeOutTask_"+tokenEntity.getId(), expressionTemp);
       
        List<Trigger> triggers=new ArrayList<Trigger>();
        triggers.add(trigger);
        jobList.put(job, triggers);
       
      }else{
       
        if(timeObjects.size()>0){
         
          List<Trigger> triggers=new ArrayList<Trigger>();
          for (Object object : timeObjects) {
            if(object instanceof Date){
              Trigger trigger = null;
             
             
             
              trigger = (SimpleTrigger) QuartzUtil.createSimpleTrigger(
                  GuidUtil.CreateGuid(), "FixTimeOutTask_"+tokenEntity.getId(), StringUtil.getDate(object));
             
              triggers.add(trigger);
             
            }
            if(object instanceof String){
              Trigger trigger = null;
              trigger =  QuartzUtil.createCronTrigger(
                  GuidUtil.CreateGuid(), "FixTimeOutTask_"+tokenEntity.getId(), StringUtil.getString(object));
              triggers.add(trigger);
            }
          }
          jobList.put(job, triggers);
        }else{
          throw new FixFlowBizException("定时任务节点没有设置时间!");
        }
       
     
       
      }
     
     
     
     
    }else{
     
     
      Trigger trigger = null;
     
     
     
      trigger = (SimpleTrigger) QuartzUtil.createSimpleTrigger(
          GuidUtil.CreateGuid(), "FixTimeOutTask_"+tokenEntity.getId(), date);
      List<Trigger> triggers=new ArrayList<Trigger>();
      triggers.add(trigger);
      jobList.put(job, triggers);
    }
   
   
   
   
    //QuartzUtil.createCronTrigger(jobName, groupName, cronExpression);
   
   
    try {
      scheduler.scheduleJobs(jobList, true);//.scheduleJob(job, trigger);
    } catch (Exception e) {
      throw new FixFlowException("超时任务启动记录失败!错误信息: "+e.toString(), e);
    }
   
 
  }
View Full Code Here

    }
   
    try {
      processInstanceManager.saveProcessInstance(processInstanceImpl);
    } catch (Exception e) {
      throw new FixFlowException("流程实例持久化失败!", e);
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of com.founder.fix.fixflow.core.exception.FixFlowException

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.