001: package org.enhydra.shark.webclient.presentation;
002:
003: import java.util.HashMap;
004: import java.util.Map;
005:
006: import org.enhydra.shark.api.client.wfmc.wapi.WAPI;
007: import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
008: import org.enhydra.shark.client.utilities.SharkInterfaceWrapper;
009: import org.enhydra.shark.utilities.MiscUtilities;
010: import org.enhydra.shark.webclient.business.SharkUtils;
011: import org.enhydra.shark.webclient.business.XMLReassignTaskBuilder;
012: import org.enhydra.shark.webclient.presentation.utils.NavigConsts;
013: import org.enhydra.shark.webclient.spec.utils.ParamConsts;
014: import org.w3c.dom.Node;
015:
016: import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException;
017: import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
018:
019: public class ReassignTaskPO extends BasePO {
020:
021: private static Map demoMap = new HashMap();
022:
023: public Node handleDefault() throws HttpPresentationException {
024:
025: return showPage();
026: }
027:
028: public Node handleReassign() throws HttpPresentationException {
029:
030: String from_element = myComms.request.getParameter("from");
031: String sortCriterion = myComms.request
032: .getParameter("sortCriterion");
033: String sortOrder = myComms.request.getParameter("sortAsc");
034: String pro_Id = myComms.request.getParameter("proc_id");
035: String act_Id = myComms.request.getParameter("act_id");
036: String user = myComms.request.getParameter("user");
037: String selected_user = myComms.request
038: .getParameter("selected_user");
039:
040: if (sortCriterion == null) {
041: sortCriterion = "";
042: }
043: String sortAsc = "true";
044: if (sortOrder != null
045: && (sortOrder.equalsIgnoreCase("true") || sortOrder
046: .equalsIgnoreCase("false"))) {
047: sortAsc = sortOrder;
048: }
049:
050: if (SharkUtils.sharkEdition.equalsIgnoreCase("demo")) {
051: if (demoMap.containsKey("reassign")) {
052: Integer count = (Integer) demoMap.get("reassign");
053: int i = count.intValue();
054: if (i == 3) {
055: throw new ClientPageRedirectException(
056: NavigConsts.LIMIT_HANDLER);
057:
058: }
059: i++;
060: demoMap.put("reassign", new Integer(i));
061: } else {
062: demoMap.put("reassign", new Integer(1));
063: }
064: }
065:
066: try {
067: WAPI wapi = SharkInterfaceWrapper.getShark()
068: .getWAPIConnection();
069: WMSessionHandle shandle = SharkInterfaceWrapper
070: .makeWAPIConnection(wapi, getUsername(), null);
071: String wiid = MiscUtilities.createAssignmentKey(act_Id,
072: selected_user);
073: wapi.reassignWorkItem(shandle, selected_user, user, pro_Id,
074: wiid);
075: wapi.disconnect(shandle);
076: } catch (Exception e) {
077: e.printStackTrace();
078: }
079: throw new ClientPageRedirectException(
080: NavigConsts.WORKLIST_HANDLER + "?from=" + from_element
081: + "&sortCriterion=" + sortCriterion
082: + "&sortAsc=" + sortAsc + "&selected_user="
083: + selected_user);
084: }
085:
086: public Node handleClose() throws HttpPresentationException {
087:
088: String from_element = myComms.request.getParameter("from");
089: String sortCriterion = myComms.request
090: .getParameter("sortCriterion");
091: String sortOrder = myComms.request.getParameter("sortAsc");
092: String selected_user = myComms.request
093: .getParameter("selected_user");
094:
095: if (sortCriterion == null) {
096: sortCriterion = "";
097: }
098: String sortAsc = "true";
099: if (sortOrder != null
100: && (sortOrder.equalsIgnoreCase("true") || sortOrder
101: .equalsIgnoreCase("false"))) {
102: sortAsc = sortOrder;
103: }
104: throw new ClientPageRedirectException(
105: NavigConsts.WORKLIST_HANDLER + "?from=" + from_element
106: + "&sortCriterion=" + sortCriterion
107: + "&sortAsc=" + sortAsc + "&selected_user="
108: + selected_user);
109: }
110:
111: protected Node showPage() throws HttpPresentationException {
112:
113: try {
114:
115: String pro_Id = myComms.request
116: .getParameter(ParamConsts.PROCESS_ID);
117: String act_Id = myComms.request
118: .getParameter(ParamConsts.ACTIVITY_ID);
119: String pagingFrom = myComms.request.getParameter("from");
120: String selected_user = myComms.request
121: .getParameter("selected_user");
122: String sortCriterion = myComms.request
123: .getParameter("sortCriterion");
124: String sortOrder = myComms.request.getParameter("sortAsc");
125:
126: if (sortCriterion == null) {
127: sortCriterion = "";
128: }
129: String sortAsc = "true";
130: if (sortOrder != null
131: && (sortOrder.equalsIgnoreCase("true") || sortOrder
132: .equalsIgnoreCase("false"))) {
133: sortAsc = sortOrder;
134: }
135:
136: if (selected_user == null) {
137: selected_user = getUsername();
138: }
139: XMLReassignTaskBuilder xmlImp = new XMLReassignTaskBuilder(
140: getUsername(), selected_user, pro_Id, act_Id,
141: myComms.application.getConfig(), pagingFrom,
142: sortCriterion, sortAsc);
143: Node toRet = xmlImp.getResult(xsltParamMap);
144: xsltParamMap.put("selected_user", selected_user);
145: return toRet;
146: } catch (Exception ex) {
147: ex.printStackTrace();
148: throw new PresentationException("Can't show page", ex);
149: }
150: }
151:
152: public String getXSLTransformation() throws Exception {
153: return getXSLTTransformation(ParamConsts.PROPERTY_PREFIX_REASSIGN_TASK);
154: }
155:
156: }
|