001: package org.enhydra.shark.webclient.business;
002:
003: import java.sql.Date;
004: import java.util.ArrayList;
005: import java.util.Arrays;
006: import java.util.GregorianCalendar;
007: import java.util.List;
008:
009: import org.enhydra.shark.api.client.wfmc.wapi.WAPI;
010: import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
011: import org.enhydra.shark.client.utilities.SharkInterfaceWrapper;
012: import org.enhydra.shark.xpil.XPILExtendedWorkflowFacilityInstanceDocument;
013: import org.enhydra.shark.xpil.XPILExtendedWorkflowFacilityInstanceDocument.ExtendedWorkflowFacilityInstance;
014: import org.enhydra.shark.xpil.XPILHeaderDocument.Header;
015: import org.enhydra.shark.xpil.XPILInstanceExtendedAttributeDocument.InstanceExtendedAttribute;
016: import org.enhydra.shark.xpil.XPILInstanceExtendedAttributesDocument.InstanceExtendedAttributes;
017: import org.w3c.dom.Node;
018:
019: import com.lutris.util.Config;
020:
021: public class XMLReassignTaskBuilder extends XMLBuilderImpl {
022:
023: String procId = null;
024:
025: String actId = null;
026:
027: public XMLReassignTaskBuilder(String username, String selectedUser,
028: String procId, String actId, Config config,
029: String startElement, String sortCriterion, String sortAsc) {
030:
031: this .username = username;
032: this .config = config;
033: this .from_element = startElement;
034: this .sortCriterion = sortCriterion;
035: this .sortAsc = sortAsc;
036: this .procId = procId;
037: this .actId = actId;
038:
039: if (selectedUser != null) {
040: this .map.put("selected_user", selectedUser);
041: }
042: }
043:
044: protected Node fillXMLElements() throws Exception {
045: WAPI wapi = SharkInterfaceWrapper.getShark()
046: .getWAPIConnection();
047: WMSessionHandle shandle = SharkInterfaceWrapper
048: .makeWAPIConnection(wapi, username, null);
049:
050: XPILExtendedWorkflowFacilityInstanceDocument tws = XPILExtendedWorkflowFacilityInstanceDocument.Factory
051: .newInstance();
052:
053: tws.addNewExtendedWorkflowFacilityInstance();
054:
055: ExtendedWorkflowFacilityInstance ins = tws
056: .getExtendedWorkflowFacilityInstance();
057: ins.addNewHeader();
058: Header header = tws.getExtendedWorkflowFacilityInstance()
059: .getHeader();
060: header.setXPILVersion("1.0");
061: header.setXPILVendor("Shark");
062:
063: GregorianCalendar gC = new GregorianCalendar();
064: gC.setTime(new Date(System.currentTimeMillis()));
065:
066: header.setCreationTime(gC);
067:
068: header.setInstanceDescription("Shark's packages instance list");
069: String selectedUser = (String) this .map.get("selected_user");
070: if (selectedUser == null) {
071: selectedUser = username;
072: map.put("selected_user", selectedUser);
073: }
074: List existingUsers = new ArrayList(Arrays
075: .asList(SharkInterfaceWrapper.getShark().getAdminMisc()
076: .getAllUsers(shandle)));
077: existingUsers.remove(selectedUser);
078:
079: InstanceExtendedAttribute ea = ins
080: .addNewInstanceExtendedAttribute();
081: ea.setName("procId");
082: ea.setValue(procId);
083: InstanceExtendedAttribute ea1 = ins
084: .addNewInstanceExtendedAttribute();
085: ea1.setName("actId");
086: ea1.setValue(actId);
087:
088: InstanceExtendedAttributes eas = ins
089: .addNewInstanceExtendedAttributes();
090: for (int i = 0; i < existingUsers.size(); i++) {
091: InstanceExtendedAttribute e = eas
092: .addNewInstanceExtendedAttribute();
093: e.setName("user");
094: e.setValue((String) existingUsers.get(i));
095:
096: }
097: int startAt = Integer
098: .parseInt(from_element != null ? from_element : "0");
099:
100: from_element = Integer.toString(startAt);
101:
102: from_element = Integer.toString(startAt);
103: to_element = Integer.toString(10);
104: total_number = Integer.toString(existingUsers.size());
105:
106: wapi.disconnect(shandle);
107:
108: return tws.getDomNode();
109:
110: }
111:
112: }
|