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; }
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 ""; }