コード例 #1
0
  @Override
  public FormRowSet load(Element element, String primaryKey, FormData formData) {
    // load form data from DB
    FormRowSet rows = super.load(element, primaryKey, formData);
    if (rows != null) {
      // handle workflow variables
      String activityId = formData.getActivityId();
      String processId = formData.getProcessId();
      WorkflowManager workflowManager =
          (WorkflowManager) WorkflowUtil.getApplicationContext().getBean("workflowManager");
      Collection<WorkflowVariable> variableList = null;
      if (activityId != null && !activityId.isEmpty()) {
        variableList = workflowManager.getActivityVariableList(activityId);
      } else if (processId != null && !processId.isEmpty()) {
        variableList = workflowManager.getProcessVariableList(processId);
      } else {
        variableList = new ArrayList<WorkflowVariable>();
      }

      if (variableList != null && !variableList.isEmpty()) {
        FormRow row = null;
        if (rows.isEmpty()) {
          row = new FormRow();
          rows.add(row);
        } else {
          row = rows.iterator().next();
        }

        Map<String, String> variableMap = new HashMap<String, String>();
        for (WorkflowVariable variable : variableList) {
          Object val = variable.getVal();
          if (val != null) {
            variableMap.put(variable.getId(), val.toString());
          }
        }
        loadWorkflowVariables(element, row, variableMap);
      }
    }
    return rows;
  }