public void deployByZip(Map<String, Object> params) {
   ZipInputStream zipInputStream = null;
   try {
     FileItem file = (FileItem) params.get("processFile");
     if (null != file) {
       zipInputStream = new ZipInputStream(file.getInputStream());
       String deploymentId = StringUtil.getString(params.get("deploymentId"));
       DeploymentBuilder deploymentBuilder = modelService.createDeployment();
       deploymentBuilder.addZipInputStream(zipInputStream);
       // 有deploymentID则为更新,否则为新增
       if (StringUtil.isNotEmpty(deploymentId)) {
         deploymentBuilder.updateDeploymentId(deploymentId);
       }
       deploymentBuilder.deploy();
     }
   } catch (IOException e) {
     throw new FoxbpmWebException(e);
   } finally {
     if (null != zipInputStream) {
       try {
         zipInputStream.close();
       } catch (IOException e) {
         throw new FoxbpmWebException(e);
       }
     }
   }
 }
Beispiel #2
0
  public Map<String, Object> getPersistentState() {
    Map<String, Object> persistentState = new HashMap<String, Object>();
    persistentState.put("id", getId());
    persistentState.put("name", getName());
    persistentState.put("subject", getSubject());
    persistentState.put("description", getDescription());
    persistentState.put("completeDescription", getCompleteDescription());
    persistentState.put("processInstanceId", getProcessInstanceId());
    persistentState.put("processDefinitionId", getProcessDefinitionId());
    persistentState.put("processDefinitionKey", getProcessDefinitionKey());
    persistentState.put("processDefinitionName", getProcessDefinitionName());
    persistentState.put("version", getVersion());
    persistentState.put("tokenId", getTokenId());
    persistentState.put("nodeId", getNodeId());
    persistentState.put("nodeName", getNodeName());
    persistentState.put("parentId", getParentId());
    persistentState.put("assignee", getAssignee());
    persistentState.put("claimTime", getClaimTime());
    persistentState.put("createTime", getCreateTime());
    persistentState.put("startTime", getStartTime());
    persistentState.put("endTime", getEndTime());
    persistentState.put("dueDate", getDueDate());
    persistentState.put("processStartTime", getProcessStartTime());
    persistentState.put("processInitiator", getProcessInitiator());
    persistentState.put("priority", String.valueOf(getPriority()));
    persistentState.put("category", String.valueOf(getCategory()));
    persistentState.put("owner", getOwner());
    persistentState.put("delegationState", StringUtil.getString(getDelegationState()));
    persistentState.put("bizKey", getBizKey());
    persistentState.put("taskComment", getTaskComment());
    persistentState.put("formUri", getFormUri());
    persistentState.put("formUriView", getFormUriView());
    persistentState.put("taskGroup", getTaskGroup());
    persistentState.put("taskType", StringUtil.getString(getTaskType()));
    persistentState.put("isBlocking", String.valueOf(isBlocking()));
    persistentState.put("isCancelled", String.valueOf(isCancelled()));
    persistentState.put("isSuspended", String.valueOf(isSuspended()));
    persistentState.put("isOpen", String.valueOf(isOpen()));
    persistentState.put("isDraft", String.valueOf(isDraft()));
    persistentState.put("expectedExecutionTime", String.valueOf(getExpectedExecutionTime()));
    persistentState.put("agent", getAgent());
    persistentState.put("admin", getAdmin());
    persistentState.put("callActivityInstanceId", getCallActivityInstanceId());
    persistentState.put("pendingTaskId", getPendingTaskId());
    persistentState.put("archiveTime", getArchiveTime());
    persistentState.put("commandId", getCommandId());
    persistentState.put("commandType", getCommandType());
    persistentState.put("commandMessage", getCommandMessage());
    persistentState.put("processStartTime", getProcessStartTime());
    persistentState.put("processInitiator", getProcessInitiator());
    persistentState.put("completeDescription", getCompleteDescription());
    persistentState.put("completionRate", getCompletionRate());
    persistentState.put("nextTaskId", getNextTaskId());
    persistentState.put("addSignType", getAddSignType());

    return persistentState;
  }
 public void deleUserDelegationInfo(Map<String, Object> params) {
   String agentInfoJson = StringUtil.getString(params.get("deleteIndex"));
   String agentId = StringUtil.getString(params.get("agentId"));
   if (StringUtil.isNotEmpty(agentId)) {
     if (StringUtil.isNotEmpty(agentInfoJson)) {
       StringTokenizer st = new StringTokenizer(agentInfoJson, ",");
       while (st.hasMoreTokens()) {
         identityService.deleteAgentDetails(st.nextToken());
       }
     }
   }
 }
 public void deleteDeploy(Map<String, Object> params) {
   String deploymentId = StringUtil.getString(params.get("deploymentId"));
   try {
     if (StringUtil.isEmpty(deploymentId)) {
       throw new FoxbpmWebException(
           FoxbpmExceptionCode.FOXBPMEX_DEPLOYMENTID, "deploymentId is null !");
     }
     String[] deploymentIds = deploymentId.split(",");
     for (int i = 0; i < deploymentIds.length; i++) {
       modelService.deleteDeployment(deploymentIds[i]);
     }
   } catch (Exception e) {
     throw new FoxbpmWebException(e);
   }
 }
Beispiel #5
0
 public boolean isAddSign() {
   if (StringUtil.isEmpty(this.addSignType)) {
     return false;
   } else {
     return true;
   }
 }
  public List<Map<String, Object>> queryProcessDef(
      Pagination<String> pageInfor, Map<String, Object> params) throws FoxbpmWebException {
    // 返回结果
    List<Map<String, Object>> resultData = new ArrayList<Map<String, Object>>();
    // 创建流程定义查询
    ProcessDefinitionQuery pdq = modelService.createProcessDefinitionQuery();
    String processName = StringUtil.getString(params.get("queryProcessName"));
    if (StringUtil.isNotEmpty(processName)) {
      pdq.processDefinitionNameLike(assembleLikeParam(processName));
    }
    String processId = StringUtil.getString(params.get("queryProcessId"));
    if (StringUtil.isNotEmpty(processId)) {
      pdq.processDefinitionId(processId);
    }
    String processCategory = StringUtil.getString(params.get("queryType"));
    if (StringUtil.isNotEmpty(processCategory)) {
      pdq.processDefinitionCategoryLike(assembleLikeParam(processCategory));
    }
    String queryProcessKey = StringUtil.getString(params.get("queryProcessKey"));
    if (StringUtil.isNotEmpty(queryProcessKey)) {
      pdq.processDefinitionKeyLike(assembleLikeParam(queryProcessKey));
    }

    pdq.orderByDeploymentId().desc();
    List<ProcessDefinition> pdList = null;
    if (null == pageInfor) {
      pdList = pdq.list();
    } else {
      pdList = pdq.listPagination(pageInfor.getPageIndex(), pageInfor.getPageSize());
      pageInfor.setTotal(StringUtil.getInt(pdq.count()));
    }
    Map<String, Object> attrMap = null;
    for (int i = 0, size = (null == pdList) ? 0 : pdList.size(); i < size; i++) {
      attrMap = pdList.get(i).getPersistentState();
      resultData.add(attrMap);
    }
    return resultData;
  }
Beispiel #7
0
  /** 结束任务,并驱动流程向下运转。 指定需要去的节点和指定节点的任务处理者 */
  public void complete(KernelFlowNodeImpl toFlowNode, String assignee) {

    /** 设置任务结束状态 */
    end();
    /** 正常处理任务不能处理已经暂停的任务 */
    if (this.isSuspended) {
      throw ExceptionUtil.getException("10303001");
    }
    /** 获取令牌 */
    if (tokenId != null) {
      TokenEntity token = null;
      token = getToken();
      if (toFlowNode != null) {
        // 如果指定了目标节点,则首先判断本令牌是否走过该节点
        // 如果走过该节点(taskCount != 0)则正常退回
        // 如果未走过该节点,则递归查询父令牌是否经过,如果父令牌走过,则结束父令牌的child,并推动父令牌退回,如果父令牌也未走过,则抛出异常
        String nodeId = toFlowNode.getId();
        TaskQuery taskQuery = new TaskQueryImpl(Context.getCommandContext());
        long taskCount = taskQuery.tokenId(tokenId).nodeId(nodeId).count();
        if (taskCount == 0) {
          token = getParentTokenByNodeId((TokenEntity) token.getParent(), toFlowNode.getId());
          if (token == null) {
            throw ExceptionUtil.getException("10303002");
          }
          token.terminationChildToken();
        }
        token.setToFlowNode(toFlowNode);
      }
      /** 移除令牌上注册任务 */
      token.removeTask(this);
      if (StringUtil.isNotEmpty(assignee)) {
        token.setTaskAssignee(assignee);
      }
      /** 驱动令牌向下 */
      token.signal();
    } else {
      log.warn("任务:" + id + "没有令牌号,仅做结束任务处理,不驱动流程向下。");
    }
  }
  public void saveUserDelegationInfo(Map<String, Object> params) {
    String addInfo = StringUtil.getString(params.get("add"));
    String updateInfo = StringUtil.getString(params.get("update"));
    String deleteInfo = StringUtil.getString(params.get("delete"));

    String agentUser = StringUtil.getString(params.get("agentUser"));
    String agentId = StringUtil.getString(params.get("agentId"));
    String startTime = StringUtil.getString(params.get("startTime"));
    String endTime = StringUtil.getString(params.get("endTime"));
    String status = StringUtil.getString(params.get("status"));

    if (StringUtil.isNotEmpty(agentUser)) {

      AgentEntity agentEntity = new AgentEntity();
      agentEntity.setAgentFrom(agentUser);
      agentEntity.setStatus(status);
      agentEntity.setId(agentId);
      if (StringUtil.isNotEmpty(startTime)) {
        agentEntity.setStartTime(DateUtil.stringToyyyyMmDdDate(startTime));
      }
      if (StringUtil.isNotEmpty(endTime)) {
        agentEntity.setEndTime(DateUtil.stringToyyyyMmDdDate(endTime));
      }

      // 代理id为空说明是新增
      if (StringUtil.isEmpty(agentId)) {
        agentEntity.setId(GuidUtil.CreateGuid());
        identityService.addAgent(agentEntity);
      } else {
        identityService.updateAgentEntity(agentEntity);
      }

      // 新增
      if (StringUtil.isNotEmpty(addInfo)) {
        Map<String, Object> agentInfo = JSONUtil.parseJSON2Map(addInfo);
        Iterator<String> iterator = agentInfo.keySet().iterator();
        String key = null;
        AgentDetailsEntity agentDetailsEntity = null;
        while (iterator.hasNext()) {
          key = iterator.next();
          agentDetailsEntity = new AgentDetailsEntity();
          agentDetailsEntity.setId(GuidUtil.CreateGuid());
          agentDetailsEntity.setAgentId(agentEntity.getId());
          agentDetailsEntity.setAgentTo(StringUtil.getString(agentInfo.get(key)));
          agentDetailsEntity.setProcessKey(key);
          identityService.addAgentDetails(agentDetailsEntity);
        }
      }
      // 更新
      if (StringUtil.isNotEmpty(updateInfo)) {
        Map<String, Object> agentInfo = JSONUtil.parseJSON2Map(updateInfo);
        Iterator<String> iterator = agentInfo.keySet().iterator();
        String key = null;
        Map<String, String> value = null;
        AgentDetailsEntity agentDetailsEntity = null;
        while (iterator.hasNext()) {
          key = iterator.next();
          value = (Map<String, String>) agentInfo.get(key);
          agentDetailsEntity = new AgentDetailsEntity();
          agentDetailsEntity.setId(key);
          agentDetailsEntity.setAgentId(agentEntity.getId());
          agentDetailsEntity.setAgentTo(value.get("user"));
          agentDetailsEntity.setProcessKey(value.get("key"));
          identityService.updateAgentDetailsEntity(agentDetailsEntity);
        }
      }
      // 删除
      if (StringUtil.isNotEmpty(deleteInfo)) {
        StringTokenizer st = new StringTokenizer(deleteInfo, ",");
        while (st.hasMoreTokens()) {
          identityService.deleteAgentDetails(st.nextToken());
        }
      }
    }
  }
  /**
   * 查询所有流程实例信息
   *
   * @param pageInfor 分页对象
   * @param params 查询条件参数
   * @return 返回查询结果
   * @throws FoxbpmWebException
   */
  public List<Map<String, Object>> queryProcessInst(
      Pagination<String> pageInfor, Map<String, Object> params) throws FoxbpmWebException {
    // 返回结果
    List<Map<String, Object>> resultData = new ArrayList<Map<String, Object>>();
    ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery();
    // 获取查询条件参数
    String userId = StringUtil.getString(params.get("userId"));
    String processDefinitionKey = StringUtil.getString(params.get("processDefinitionKey"));
    String processInstanceId = StringUtil.getString(params.get("processInstanceId"));
    String processDefinitionName = StringUtil.getString(params.get("processDefinitionName"));
    String title = StringUtil.getString(params.get("title"));
    String bizKey = StringUtil.getString(params.get("bizKey"));
    String initor = StringUtil.getString(params.get("initor"));
    String status = StringUtil.getString(params.get("status"));
    String processType = StringUtil.getString(params.get("processType"));

    String dss = StringUtil.getString(params.get("startTimeS"));
    String dse = StringUtil.getString(params.get("startTimeE"));
    if (StringUtil.isNotEmpty(processDefinitionKey)) {
      piq.processDefinitionKey(processDefinitionKey);
    }
    if (StringUtil.isNotEmpty(processInstanceId)) {
      piq.processInstanceId(processInstanceId);
    }
    if (StringUtil.isNotEmpty(title)) {
      piq.subjectLike(assembleLikeParam(title));
    }
    if (StringUtil.isNotEmpty(bizKey)) {
      piq.processInstanceBusinessKeyLike(assembleLikeParam(bizKey));
    }
    if (StringUtil.isNotEmpty(status)) {
      piq.processInstanceStatus(status);
    }

    if (StringUtil.isNotEmpty(initor)) {
      piq.initiator(initor);
    }

    if (StringUtil.isNotEmpty(processType)) {
      if (processType.equals("initor")) {
        piq.initiator(userId);
      } else {
        piq.taskParticipants(userId);
      }
    }
    if (StringUtil.isNotEmpty(processDefinitionName)) {
      piq.processDefinitionNameLike(assembleLikeParam(processDefinitionName));
    }
    Date dates = null;
    Date datee = null;

    if (StringUtil.isNotEmpty(dss)) {
      dates = DateUtil.stringToDate(dss, "yyyy-MM-dd");
    }
    if (StringUtil.isNotEmpty(dse)) {
      String endTime = "235959999";
      dse += endTime;
      datee = DateUtil.stringToDate(dse, "yyyy-MM-ddHHmmssSSS");
    }
    if (null != dates) {
      piq.startTimeBefore(dates);
    }
    if (null != datee) {
      piq.startTimeAfter(datee);
    }

    List<ProcessInstance> piList = null;
    piq.orderByUpdateTime().desc();
    if (null == pageInfor) {
      piList = piq.list();
    } else {
      // 执行分页查询
      piList = piq.listPagination(pageInfor.getPageIndex(), pageInfor.getPageSize());
      // 设置分页信息
      pageInfor.setTotal(StringUtil.getInt(piq.count()));
    }
    // 流程实例属性集
    Map<String, Object> attrMap = null;
    ProcessInstance pi = null;
    for (int i = 0, size = (null == piList) ? 0 : piList.size(); i < size; i++) {
      pi = piList.get(i);
      attrMap = pi.getPersistentState();
      attrMap.put(
          "processDefinitionName",
          modelService.getProcessDefinition(pi.getProcessDefinitionId()).getName());
      attrMap.put("initiatorName", getUserName(StringUtil.getString(attrMap.get("initiator"))));
      resultData.add(attrMap);
    }

    return resultData;
  }