Пример #1
0
  private String statusList(Map<String, String> parameters) throws Exception {
    WorkflowStatus[] list =
        studioController.getWorkflowStatuses(sessionUid, Long.parseLong(parameters.get("uid")));
    WorkflowStatusDefinition[] results = new WorkflowStatusDefinition[list.length];
    int ind = 0;
    for (WorkflowStatus it : list) {
      WorkflowStatusDefinition n = new WorkflowStatusDefinition();
      n.setPosition(ind);
      n.setWorkflowStatus(it);
      WorkflowStatusManager[] mn =
          studioController.getWorkflowStatusManagers(sessionUid, it.getUid());
      n.setWorkflowStatusManagers(mn);
      results[ind] = n;
      ind++;
    }
    XStream xml = new XStream(new DomDriver());
    XStream xstream =
        new XStream(
            new JettisonMappedXmlDriver() {

              public HierarchicalStreamWriter createWriter(Writer writer) {
                return new JsonWriter(writer, "".toCharArray(), "", JsonWriter.DROP_ROOT_MODE);
              }
            });
    xstream.aliasField(
        "securityEntityName", WorkflowStatusManager.class, "localSecurityEntityName");
    xstream.aliasField(
        "securityEntitySource", WorkflowStatusManager.class, "localSecurityEntitySource");
    xstream.aliasField(
        "securityEntityType", WorkflowStatusManager.class, "localSecurityEntityType");
    xstream.aliasField("workflowStatusUid", WorkflowStatusManager.class, "localWorkflowStatusUid");
    xstream.setMode(XStream.NO_REFERENCES);
    String jsonResp = xstream.toXML(results);
    return jsonResp;
  }
Пример #2
0
  private String updateWorflow(Map<String, String> parameters) throws Exception {
    ArrayList<Map<String, String>> statusList =
        (ArrayList<Map<String, String>>)
            new JSONDeserializer().deserialize(parameters.get("jsonParameters"));
    Vector<WorkflowStatusDefinition> statusDefinitionList = new Vector<WorkflowStatusDefinition>();

    for (Map statusMap : statusList) {
      long statusUid =
          statusMap.get("uid") != null ? Long.parseLong(String.valueOf(statusMap.get("uid"))) : -1;
      long successorUid =
          statusMap.get("successorUid") != null
              ? Long.parseLong(String.valueOf(statusMap.get("successorUid")))
              : -1;

      // WorkflowStatus

      WorkflowStatus status = new WorkflowStatus();
      status.setUid(statusUid);
      status.setName(String.valueOf(statusMap.get("name")));
      status.setSuccessorUid(successorUid);

      // WorkflowStatusManagers

      ArrayList<Map<String, String>> managersList =
          (ArrayList<Map<String, String>>) statusMap.get("managers");
      WorkflowStatusManager[] wsmTab = new WorkflowStatusManager[managersList.size()];
      for (int i = 0; i < managersList.size(); ++i) {
        Map managersMap = managersList.get(i);
        WorkflowStatusManager wsm = new WorkflowStatusManager();
        wsm.setSecurityEntityName(String.valueOf(managersMap.get("uid")));
        wsm.setSecurityEntitySource(String.valueOf(managersMap.get("source")));
        wsm.setSecurityEntityType(Integer.parseInt(String.valueOf(managersMap.get("type"))));
        wsmTab[i] = wsm;
      }

      WorkflowStatusDefinition statusDefinition = new WorkflowStatusDefinition();
      statusDefinition.setWorkflowStatus(status);
      statusDefinition.setWorkflowStatusManagers(wsmTab);

      statusDefinitionList.add(statusDefinition);
    }

    studioController.updateWorkflow(
        sessionUid,
        Long.parseLong(parameters.get("uid")),
        parameters.get("name"),
        parameters.get("description"),
        XMLGenerators.getWorkflowXMLDescriptor(-1, statusDefinitionList));
    return "";
  }
Пример #3
0
  /** @deprecated */
  private String createWorkflowStatus(Map<String, String> parameters) throws Exception {
    long workflowUid = Long.parseLong(parameters.get("workflowUid"));
    String workflowName = parameters.get("workflowName");
    String workflowDescription = parameters.get("workflowDescription");
    String statusName = parameters.get("statusName");

    //        Vector<WorkflowStatusDefinition> workflowStatus = new
    // Vector<WorkflowStatusDefinition>();
    //        XMLGenerators.getWorkflowXMLDescriptor(workflowUid, workflowStatus);

    String xmlStream = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    xmlStream += "<workflow uid=\"" + workflowUid + "\">\n";
    for (WorkflowStatus ws : studioController.getWorkflowStatuses(sessionUid, workflowUid)) {
      xmlStream +=
          "<status uid=\"" + ws.getUid() + "\" successor-uid=\"" + ws.getSuccessorUid() + "\">";
      xmlStream += "<name>" + ws.getName() + "</name>\n";
      for (WorkflowStatusManager wsm :
          studioController.getWorkflowStatusManagers(sessionUid, ws.getUid())) {
        xmlStream +=
            "<manager type=\""
                + 1
                + "\" uid=\""
                + wsm.getSecurityEntityName()
                + "\" source=\""
                + wsm.getSecurityEntitySource()
                + "\" />";
      }
      xmlStream += "</status>\n";
    }
    xmlStream += "<status uid=\"-1\" successor-uid=\"-1\">";
    xmlStream += "<name>" + statusName + "</name>";
    xmlStream += "</status>\n";
    xmlStream += "</workflow>\n";

    studioController.updateWorkflow(
        sessionUid, workflowUid, workflowName, workflowDescription, xmlStream);
    return "";
  }