コード例 #1
0
ファイル: LeaveService.java プロジェクト: Cloud-Fly/jeesite
 /**
  * 获取流程详细及工作流参数
  *
  * @param id
  */
 @SuppressWarnings("unchecked")
 public Leave get(String id) {
   Leave leave = leaveDao.get(id);
   Map<String, Object> variables = null;
   HistoricProcessInstance historicProcessInstance =
       historyService
           .createHistoricProcessInstanceQuery()
           .processInstanceId(leave.getProcessInstanceId())
           .singleResult();
   if (historicProcessInstance != null) {
     variables =
         Collections3.extractToMap(
             historyService
                 .createHistoricVariableInstanceQuery()
                 .processInstanceId(historicProcessInstance.getId())
                 .list(),
             "variableName",
             "value");
   } else {
     variables =
         runtimeService.getVariables(
             runtimeService
                 .createProcessInstanceQuery()
                 .processInstanceId(leave.getProcessInstanceId())
                 .active()
                 .singleResult()
                 .getId());
   }
   leave.setVariables(variables);
   return leave;
 }
コード例 #2
0
  /**
   * 跳转到任务执行页面
   *
   * @param request
   * @return
   */
  @RequestMapping(value = "/form.do")
  public String from(
      HttpServletRequest request, @RequestParam("taskId") String taskId, Model model) {

    List<Task> taskList = taskService.createTaskQuery().taskId(taskId).list();
    Task task = taskList.get(0);
    // 获取表单数据
    TaskFormData tfd = formService.getTaskFormData(taskId);
    List<FormProperty> fpList = tfd.getFormProperties();

    Map map = runtimeService.getVariables(task.getExecutionId());

    List<ActivityImpl> activityList = new ArrayList<ActivityImpl>();

    try {
      // 查找所有可驳回的节点
      activityList = processExtensionService.findBackActivity(taskId);
      // model.addAttribute("activityList",activityList);
    } catch (Exception e) {
      e.printStackTrace();
    }

    //        model.addAttribute("task",task);
    //        model.addAttribute("fpList",fpList);
    //        model.addAttribute("map",map);
    //        model.addAttribute("taskId",taskId);

    request.setAttribute("task", task);
    request.setAttribute("fpList", fpList);
    request.setAttribute("map", map);
    request.setAttribute("taskId", taskId);
    request.setAttribute("activityList", activityList);

    return "/simple/form";
  }
コード例 #3
0
  protected void addGlobalVariables(
      Execution execution,
      int variableType,
      Map<String, RestVariable> variableMap,
      UriInfo uriInfo) {
    RuntimeService runtimeService = BPMNOSGIService.getRumtimeService();
    Map<String, Object> rawVariables = runtimeService.getVariables(execution.getId());
    List<RestVariable> globalVariables =
        new RestResponseFactory()
            .createRestVariables(
                rawVariables,
                execution.getId(),
                variableType,
                RestVariable.RestVariableScope.GLOBAL,
                uriInfo.getBaseUri().toString());

    // Overlay global variables over local ones. In case they are present the values are not
    // overridden,
    // since local variables get precedence over global ones at all times.
    for (RestVariable var : globalVariables) {
      if (!variableMap.containsKey(var.getName())) {
        variableMap.put(var.getName(), var);
      }
    }
  }
コード例 #4
0
ファイル: AbstractModelTask.java プロジェクト: Serhiy1996/i
 public static List<String> getVariableValues(
     RuntimeService runtimeService, String processInstanceId, List<String> formFieldIds) {
   List<String> listValueKeys = new ArrayList<String>();
   if (!formFieldIds.isEmpty()) {
     Map<String, Object> variables = runtimeService.getVariables(processInstanceId);
     for (String fieldId : formFieldIds) {
       if (variables.containsKey(fieldId)) {
         listValueKeys.add(String.valueOf(variables.get(fieldId)));
       }
     }
   }
   return listValueKeys;
 }
コード例 #5
0
  protected void addVariables() {
    Label header = new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_HEADER_VARIABLES));
    header.addStyleName(ExplorerLayout.STYLE_H3);
    header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    header.addStyleName(ExplorerLayout.STYLE_NO_LINE);
    panelLayout.addComponent(header);

    panelLayout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));

    // variable sorting is done in-memory (which is ok, since normally there aren't that many vars)
    Map<String, Object> variables =
        new TreeMap<String, Object>(runtimeService.getVariables(processInstance.getId()));

    if (variables.size() > 0) {

      Table variablesTable = new Table();
      variablesTable.setWidth(60, UNITS_PERCENTAGE);
      variablesTable.addStyleName(ExplorerLayout.STYLE_PROCESS_INSTANCE_TASK_LIST);

      variablesTable.addContainerProperty(
          "name",
          String.class,
          null,
          i18nManager.getMessage(Messages.PROCESS_INSTANCE_VARIABLE_NAME),
          null,
          Table.ALIGN_LEFT);
      variablesTable.addContainerProperty(
          "value",
          String.class,
          null,
          i18nManager.getMessage(Messages.PROCESS_INSTANCE_VARIABLE_VALUE),
          null,
          Table.ALIGN_LEFT);

      for (String variable : variables.keySet()) {
        Item variableItem = variablesTable.addItem(variable);
        variableItem.getItemProperty("name").setValue(variable);

        // Get string value to show
        String theValue = variableRendererManager.getStringRepresentation(variables.get(variable));
        variableItem.getItemProperty("value").setValue(theValue);
      }

      variablesTable.setPageLength(variables.size());
      panelLayout.addComponent(variablesTable);
    } else {
      Label noVariablesLabel =
          new Label(i18nManager.getMessage(Messages.PROCESS_INSTANCE_NO_VARIABLES));
      panelLayout.addComponent(noVariablesLabel);
    }
  }
コード例 #6
0
  /**
   * 提交流程
   *
   * @return
   */
  @RequestMapping(value = "/submit.do")
  public String submit(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "taskId", required = false) String taskId,
      @RequestParam(value = "day", required = false) String day,
      @RequestParam(value = "type", required = false) String type,
      @RequestParam(value = "reason", required = false) String reason,
      @RequestParam(value = "result", required = false) String result,
      @RequestParam(value = "toSign", required = false) String toSign,
      @RequestParam(value = "backActivityId", required = false) String backActivityId)
      throws Exception {
    List<Task> taskList = taskService.createTaskQuery().taskId(taskId).list();
    Task task = taskList.get(0);
    String taskName = task.getName();

    // result = new String(result.getBytes("ISO-8859-1"), "UTF-8");

    if (result.equals("同意")) {
      Map map = new HashMap();
      if (StringUtils.isNotBlank(day)) {
        map.put("day", day);
        map.put("reason", reason);
        map.put("type", 0);
        taskService.complete(taskId, map);
      } else {
        taskService.complete(taskId);
      }
    } else if (result.equals("驳回")) {
      ProcessInstance processInstance = processExtensionService.findProcessInstanceByTaskId(taskId);

      Map<String, Object> map = runtimeService.getVariables(processInstance.getId());

      processExtensionService.backProcess(taskId, backActivityId, map);
    } else if (result.equals("转签")) {

      if (processExtensionService.isPermissionInActivity(taskId, toSign)) {
        taskService.setAssignee(taskId, toSign);
      }
    }
    return "redirect:/simple/index.do";
  }