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 ""; }
/** @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 ""; }