001: package org.enhydra.shark.webclient.presentation;
002:
003: import java.util.ArrayList;
004: import java.util.HashMap;
005: import java.util.Iterator;
006: import java.util.Map;
007:
008: import org.enhydra.shark.api.client.wfmc.wapi.WAPI;
009: import org.enhydra.shark.api.client.wfmc.wapi.WMAttribute;
010: import org.enhydra.shark.api.client.wfmc.wapi.WMFilter;
011: import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
012: import org.enhydra.shark.api.client.wfservice.AdminMisc;
013: import org.enhydra.shark.api.client.wfservice.OptionInfo;
014: import org.enhydra.shark.api.client.wfservice.WMEntity;
015: import org.enhydra.shark.api.client.wfservice.XPDLBrowser;
016: import org.enhydra.shark.client.utilities.SharkInterfaceWrapper;
017: import org.enhydra.shark.utilities.WMEntityUtilities;
018: import org.enhydra.shark.webclient.business.SharkUtils;
019: import org.enhydra.shark.webclient.presentation.utils.NavigConsts;
020: import org.enhydra.shark.webclient.spec.SharkParamConsts;
021: import org.enhydra.shark.xpdl.XMLUtil;
022: import org.enhydra.xml.io.OutputOptions;
023: import org.w3c.dom.Node;
024: import org.w3c.dom.html.HTMLAnchorElement;
025:
026: import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException;
027: import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
028:
029: public class DynamicVariablesHandlerPO extends BasePO {
030:
031: private final String PERFORMER = "performer";
032:
033: public OutputOptions getPostProcessingOptions() throws Exception {
034:
035: return null;
036: }
037:
038: public Node handleDefault() throws HttpPresentationException {
039:
040: DynamicVariablesHTML dynamicVariablesPage = (DynamicVariablesHTML) myComms.xmlcFactory
041: .create(DynamicVariablesHTML.class);
042:
043: String from = myComms.request.getParameter("from");
044: String sortCriterion = myComms.request
045: .getParameter("sortCriterion");
046: String sortOrder = myComms.request.getParameter("sortAsc");
047: String proId = myComms.request.getParameter("pro_id");
048: String actId = myComms.request.getParameter("act_id");
049: String errMessage = myComms.request.getParameter("errMessage");
050: String fromPage = myComms.request.getParameter("fromPage");
051: String nextAction = myComms.request.getParameter("nextAction");
052:
053: if (null != proId) {
054:
055: if (sortCriterion == null) {
056: sortCriterion = "";
057: }
058:
059: String sortAsc = "true";
060: if (sortOrder != null
061: && (sortOrder.equalsIgnoreCase("true") || sortOrder
062: .equalsIgnoreCase("false"))) {
063: sortAsc = sortOrder;
064: }
065:
066: dynamicVariablesPage.getElementPro_id().setAttribute(
067: "value", proId);
068: if (null != actId && !actId.equals("")) {
069: dynamicVariablesPage.getElementAct_id().setAttribute(
070: "value", actId);
071: dynamicVariablesPage.getElementCompleteImage().setSrc(
072: "media/complete_n.gif");
073:
074: } else {
075: actId = "";
076: dynamicVariablesPage.getElementAct_id().setAttribute(
077: "value", "");
078: dynamicVariablesPage.getElementCompleteImage().setSrc(
079: "media/create_n.gif");
080: }
081: dynamicVariablesPage.getElementFrom().setAttribute("value",
082: from);
083: dynamicVariablesPage.getElementSortAsc().setAttribute(
084: "value", sortAsc);
085: dynamicVariablesPage.getElementSortCriterion()
086: .setAttribute("value", sortCriterion);
087: dynamicVariablesPage.getElementFromPage().setAttribute(
088: "value", fromPage);
089: dynamicVariablesPage.getElementNextAction().setAttribute(
090: "value", nextAction);
091:
092: if (null != errMessage) {
093: dynamicVariablesPage.setTextErrorText(errMessage);
094: }
095:
096: try {
097: WAPI wapi = SharkInterfaceWrapper.getShark()
098: .getWAPIConnection();
099: WMSessionHandle shandle = SharkInterfaceWrapper
100: .makeWAPIConnection(wapi, getUsername(), null);
101: Map pcnt = null;
102: if (actId.equals("")) {
103: pcnt = WMEntityUtilities
104: .getMapFromWMAttributeArray(wapi
105: .listProcessInstanceAttributes(
106: shandle, proId, null, true)
107: .getArray());
108: } else {
109: pcnt = WMEntityUtilities
110: .getMapFromWMAttributeArray(wapi
111: .listActivityInstanceAttributes(
112: shandle, proId, actId,
113: null, true).getArray());
114:
115: }
116: Node fileRow = dynamicVariablesPage
117: .getElementVariablesRow();
118: HTMLAnchorElement deleteLink = dynamicVariablesPage
119: .getElementDeleteLink();
120: HTMLAnchorElement completeLink = dynamicVariablesPage
121: .getElementCompleteLink();
122:
123: if (pcnt
124: .containsKey(SharkParamConsts.DYNAMIC_VARIABLE_DISPLAY_VARIABLE)) {
125: String dynamicVariableDisplay = (String) pcnt
126: .get(SharkParamConsts.DYNAMIC_VARIABLE_DISPLAY_VARIABLE);
127:
128: String[] ids = null;
129: String[] names = null;
130: String[] mandatories = null;
131: String[] lengths = null;
132: String value = null;
133:
134: if (pcnt
135: .containsKey(SharkParamConsts.DYNAMIC_VARIABLE_IDS_VARIABLE)
136: && pcnt
137: .containsKey(SharkParamConsts.DYNAMIC_VARIABLE_MANDATORIES_VARIABLE)
138: && pcnt
139: .containsKey(SharkParamConsts.DYNAMIC_VARIABLE_NAMES_VARIABLE)
140: && pcnt
141: .containsKey(SharkParamConsts.DYNAMIC_VARIABLE_MAX_LENGTHS_VARIABLE)) {
142:
143: ids = (String[]) pcnt
144: .get(SharkParamConsts.DYNAMIC_VARIABLE_IDS_VARIABLE);
145: names = (String[]) pcnt
146: .get(SharkParamConsts.DYNAMIC_VARIABLE_NAMES_VARIABLE);
147: mandatories = (String[]) pcnt
148: .get(SharkParamConsts.DYNAMIC_VARIABLE_MANDATORIES_VARIABLE);
149: lengths = (String[]) pcnt
150: .get(SharkParamConsts.DYNAMIC_VARIABLE_MAX_LENGTHS_VARIABLE);
151:
152: }
153:
154: if (null != dynamicVariableDisplay) {
155:
156: String[] varIdArray = SharkUtils.stringToArray(
157: dynamicVariableDisplay, ",");
158:
159: for (int i = 0; i < varIdArray.length; i++) {
160: String varId = varIdArray[i];
161:
162: boolean exists = false;
163:
164: if (null != ids && null != names
165: && null != mandatories
166: && null != lengths) {
167:
168: for (int j = 0; j < ids.length; j++) {
169: if (ids[j].equals(varId)) {
170: dynamicVariablesPage
171: .setTextDVariableId(varId);
172: dynamicVariablesPage
173: .setTextDVariableName((null != names[j] && !""
174: .equals(names[j])) ? names[j]
175: : "-");
176: dynamicVariablesPage
177: .setTextDVariableMaxLength(lengths[j]);
178: if (mandatories[j]
179: .equals("true")) {
180: dynamicVariablesPage
181: .setTextDVariableMandatory("Yes");
182: } else {
183: dynamicVariablesPage
184: .setTextDVariableMandatory("No");
185: }
186: value = (String) pcnt
187: .get(varId);
188: dynamicVariablesPage
189: .setTextDVariableValue((null != value && !""
190: .equals(value)) ? value
191: : "-");
192: exists = true;
193: break;
194: }
195: }
196:
197: }
198: if (!exists) {
199: if (pcnt.containsKey(varId)) {
200: dynamicVariablesPage
201: .setTextDVariableId(varId);
202:
203: value = (String) pcnt.get(varId);
204:
205: dynamicVariablesPage
206: .setTextDVariableValue((null != value && !""
207: .equals(value)) ? value
208: : "-");
209: String name = SharkInterfaceWrapper
210: .getShark().getAdminMisc()
211: .getVariableDefinitionInfo(
212: shandle, proId,
213: varId).getName();
214:
215: dynamicVariablesPage
216: .setTextDVariableName((null != name && !""
217: .equals(name)) ? name
218: : "-");
219:
220: WMEntity varEnt = SharkInterfaceWrapper
221: .getShark().getAdminMisc()
222: .getVariableDefinitionInfo(
223: shandle, proId,
224: varId);
225: String mand = WMEntityUtilities
226: .findEAAndGetValue(
227: shandle,
228: SharkInterfaceWrapper
229: .getShark()
230: .getXPDLBrowser(),
231: varEnt,
232: SharkParamConsts.EA_VAR_IS_MANDATORY);
233:
234: // TODO change with Extended Attribute value
235: dynamicVariablesPage
236: .setTextDVariableMandatory(null != mand ? (mand
237: .equals("false") ? "No"
238: : "Yes")
239: : "Yes");
240: String maxLength = WMEntityUtilities
241: .findEAAndGetValue(
242: shandle,
243: SharkInterfaceWrapper
244: .getShark()
245: .getXPDLBrowser(),
246: varEnt,
247: SharkParamConsts.EA_VAR_MAX_LENGTH);
248: dynamicVariablesPage
249: .setTextDVariableMaxLength(null != maxLength ? maxLength
250: : "no limit");
251:
252: } else {
253: System.err
254: .println("Variable with id= "
255: + varId
256: + " doesn't exists!");
257:
258: }
259: }
260:
261: deleteLink
262: .setHref("DynamicVariablesHandlerPO.po?event=delete&varId="
263: + varId
264: + "&from="
265: + from
266: + "&sortCriterion="
267: + sortCriterion
268: + "&sortAsc="
269: + sortAsc
270: + "&pro_id="
271: + proId
272: + "&act_id="
273: + actId
274: + "&fromPage="
275: + fromPage
276: + "&nextAction="
277: + nextAction);
278:
279: fileRow.getParentNode().insertBefore(
280: fileRow.cloneNode(true), fileRow);
281: }
282:
283: }
284:
285: }
286: fileRow.getParentNode().removeChild(fileRow);
287:
288: boolean allowedPerformer = false;
289: if (null != actId && !actId.equals("")) {
290: WMEntity actEnt = SharkInterfaceWrapper.getShark()
291: .getAdminMisc().getActivityDefinitionInfo(
292: shandle, proId, actId);
293:
294: OptionInfo[] optionInfo = SharkInterfaceWrapper
295: .getShark().getAdminMiscExtension()
296: .getNextOptions(shandle, actEnt, false,
297: true);
298:
299: if (optionInfo.length > 0) {
300:
301: WMFilter f = new WMFilter();
302: f.setFilterType(XPDLBrowser.SIMPLE_TYPE_XPDL);
303: f.setAttributeName("Name");
304: f.setFilterString("Performer");
305: for (int i = 0; i < optionInfo.length; i++) {
306: WMAttribute[] attrs = SharkInterfaceWrapper
307: .getShark()
308: .getXPDLBrowser()
309: .listAttributes(
310: shandle,
311: optionInfo[i]
312: .getActivityDefinitionEntity(),
313: f, true).getArray();
314: String perf = (String) attrs[0].getValue();
315:
316: if (perf.equals(PERFORMER)) {
317: allowedPerformer = true;
318: break;
319: }
320: }
321: }
322: }
323: if (SharkUtils.isEAControledOptionTrue(shandle,
324: SharkParamConsts.EA_CHOOSE_NEXT_PERFORMER,
325: proId, actId, null, false)
326: && allowedPerformer) {
327:
328: completeLink
329: .setHref("ChooseNextPerformerPO.po?from="
330: + from + "&sortCriterion="
331: + sortCriterion + "&sortAsc="
332: + sortAsc + "&pro_id=" + proId
333: + "&act_id=" + actId + "&fromPage="
334: + fromPage + "&nextAction="
335: + nextAction);
336:
337: } else {
338: completeLink.setHref(fromPage + "?event="
339: + nextAction + "&from=" + from
340: + "&sortCriterion=" + sortCriterion
341: + "&sortAsc=" + sortAsc + "&pro_id="
342: + proId + "&act_id=" + actId);
343: }
344:
345: wapi.disconnect(shandle);
346: } catch (Exception e) {
347:
348: e.printStackTrace();
349: throw new PresentationException("Can't show page", e);
350: }
351:
352: }
353:
354: return dynamicVariablesPage;
355: }
356:
357: public Node handleDelete() throws HttpPresentationException {
358:
359: String varId = myComms.request.getParameter("varId");
360: String from = myComms.request.getParameter("from");
361: String sortCriterion = myComms.request
362: .getParameter("sortCriterion");
363: String sortOrder = myComms.request.getParameter("sortAsc");
364: String proId = myComms.request.getParameter("pro_id");
365: String actId = myComms.request.getParameter("act_id");
366: String fromPage = myComms.request.getParameter("fromPage");
367: String nextAction = myComms.request.getParameter("nextAction");
368:
369: if (sortCriterion == null) {
370: sortCriterion = "";
371: }
372:
373: String sortAsc = "true";
374: if (sortOrder != null
375: && (sortOrder.equalsIgnoreCase("true") || sortOrder
376: .equalsIgnoreCase("false"))) {
377: sortAsc = sortOrder;
378: }
379:
380: try {
381: WAPI wapi = SharkInterfaceWrapper.getShark()
382: .getWAPIConnection();
383: WMSessionHandle shandle = SharkInterfaceWrapper
384: .makeWAPIConnection(wapi, getUsername(), null);
385: Map pcnt = null;
386: if (actId == null || actId.equals("")) {
387: pcnt = WMEntityUtilities
388: .getMapFromWMAttributeArray(wapi
389: .listProcessInstanceAttributes(shandle,
390: proId, null, true).getArray());
391: } else {
392: pcnt = WMEntityUtilities
393: .getMapFromWMAttributeArray(wapi
394: .listActivityInstanceAttributes(
395: shandle, proId, actId, null,
396: true).getArray());
397: }
398:
399: String dynamicVariableDisplay = (String) pcnt
400: .get(SharkParamConsts.DYNAMIC_VARIABLE_DISPLAY_VARIABLE);
401: String[] varIds = null;
402:
403: varIds = SharkUtils.stringToArray(dynamicVariableDisplay,
404: ",");
405:
406: ArrayList al = new ArrayList();
407:
408: for (int i = 0; i < varIds.length; i++) {
409: if (!varIds[i].equals(varId)) {
410: al.add(varIds[i]);
411: }
412: }
413: dynamicVariableDisplay = al.toString();
414:
415: dynamicVariableDisplay = dynamicVariableDisplay.substring(
416: 1, dynamicVariableDisplay.length() - 1);
417: dynamicVariableDisplay = dynamicVariableDisplay.replaceAll(
418: " ", "");
419:
420: if (actId == null || actId.equals("")) {
421: wapi
422: .assignProcessInstanceAttribute(
423: shandle,
424: proId,
425: SharkParamConsts.DYNAMIC_VARIABLE_DISPLAY_VARIABLE,
426: dynamicVariableDisplay);
427: } else {
428: wapi
429: .assignActivityInstanceAttribute(
430: shandle,
431: proId,
432: actId,
433: SharkParamConsts.DYNAMIC_VARIABLE_DISPLAY_VARIABLE,
434: dynamicVariableDisplay);
435: }
436: wapi.disconnect(shandle);
437: } catch (Exception e) {
438:
439: e.printStackTrace();
440: throw new PresentationException("Can't delete", e);
441: }
442:
443: throw new ClientPageRedirectException(
444: NavigConsts.DYNAMIC_VARIABLES_HANDLER + "?from=" + from
445: + "&sortCriterion=" + sortCriterion
446: + "&sortAsc=" + sortAsc + "&pro_id=" + proId
447: + "&act_id=" + actId + "&fromPage=" + fromPage
448: + "&nextAction=" + nextAction);
449: }
450:
451: public Node handleSave() throws HttpPresentationException {
452:
453: String varId = myComms.request.getParameter("varId");
454: String varName = myComms.request.getParameter("varName");
455: String varValue = myComms.request.getParameter("varValue");
456: String varMandatory = myComms.request
457: .getParameter("varMandatory");
458: String varMaxLength = myComms.request
459: .getParameter("varMaxLength");
460:
461: String from = myComms.request.getParameter("from");
462: String sortCriterion = myComms.request
463: .getParameter("sortCriterion");
464: String sortOrder = myComms.request.getParameter("sortAsc");
465: String proId = myComms.request.getParameter("pro_id");
466: String actId = myComms.request.getParameter("act_id");
467: String fromPage = myComms.request.getParameter("fromPage");
468: String nextAction = myComms.request.getParameter("nextAction");
469:
470: if (varId.length() > 254) {
471: varId = varId.substring(0, 254);
472: }
473:
474: if (varName.length() > 254) {
475: varName = varName.substring(0, 254);
476: }
477:
478: if (varValue.length() > 254) {
479: varValue = varValue.substring(0, 254);
480: }
481:
482: if (sortCriterion == null) {
483: sortCriterion = "";
484: }
485:
486: String sortAsc = "true";
487: if (sortOrder != null
488: && (sortOrder.equalsIgnoreCase("true") || sortOrder
489: .equalsIgnoreCase("false"))) {
490: sortAsc = sortOrder;
491: }
492:
493: if (!XMLUtil.isIdValid(varId)) {
494:
495: throw new ClientPageRedirectException(
496: NavigConsts.DYNAMIC_VARIABLES_HANDLER
497: + "?from="
498: + from
499: + "&sortCriterion="
500: + sortCriterion
501: + "&sortAsc="
502: + sortAsc
503: + "&pro_id="
504: + proId
505: + "&act_id="
506: + actId
507: + "&errMessage=Variable Id contains irregular characters!"
508: + "&fromPage=" + fromPage + "&nextAction="
509: + nextAction);
510:
511: }
512:
513: Map tempMap = new HashMap();
514:
515: try {
516: WAPI wapi = SharkInterfaceWrapper.getShark()
517: .getWAPIConnection();
518: WMSessionHandle shandle = SharkInterfaceWrapper
519: .makeWAPIConnection(wapi, getUsername(), null);
520:
521: Map pcnt = null;
522: if (actId == null || actId.equals("")) {
523: pcnt = WMEntityUtilities
524: .getMapFromWMAttributeArray(wapi
525: .listProcessInstanceAttributes(shandle,
526: proId, null, true).getArray());
527: } else {
528: pcnt = WMEntityUtilities
529: .getMapFromWMAttributeArray(wapi
530: .listActivityInstanceAttributes(
531: shandle, proId, actId, null,
532: true).getArray());
533:
534: }
535: String[] ids = null;
536: String[] names = null;
537: String[] mandatories = null;
538: String[] lengths = null;
539: String dynamicVariableDisplay = null;
540:
541: if (pcnt
542: .containsKey(SharkParamConsts.DYNAMIC_VARIABLE_DISPLAY_VARIABLE)) {
543: dynamicVariableDisplay = (String) pcnt
544: .get(SharkParamConsts.DYNAMIC_VARIABLE_DISPLAY_VARIABLE);
545: }
546: if (pcnt
547: .containsKey(SharkParamConsts.DYNAMIC_VARIABLE_IDS_VARIABLE)
548: && pcnt
549: .containsKey(SharkParamConsts.DYNAMIC_VARIABLE_MANDATORIES_VARIABLE)
550: && pcnt
551: .containsKey(SharkParamConsts.DYNAMIC_VARIABLE_NAMES_VARIABLE)
552: && pcnt
553: .containsKey(SharkParamConsts.DYNAMIC_VARIABLE_MAX_LENGTHS_VARIABLE)) {
554:
555: ids = (String[]) pcnt
556: .get(SharkParamConsts.DYNAMIC_VARIABLE_IDS_VARIABLE);
557: names = (String[]) pcnt
558: .get(SharkParamConsts.DYNAMIC_VARIABLE_NAMES_VARIABLE);
559: mandatories = (String[]) pcnt
560: .get(SharkParamConsts.DYNAMIC_VARIABLE_MANDATORIES_VARIABLE);
561: lengths = (String[]) pcnt
562: .get(SharkParamConsts.DYNAMIC_VARIABLE_MAX_LENGTHS_VARIABLE);
563:
564: }
565: boolean exists = false;
566: if (null != ids) {
567: for (int i = 0; i < ids.length; i++) {
568: if (ids[i].equals(varId)) {
569: exists = true;
570: }
571: }
572: }
573: long maxLengthInt = 0;
574: try {
575: maxLengthInt = Long.parseLong(varMaxLength);
576: if (maxLengthInt < 1) {
577: maxLengthInt = 1;
578: }
579: if (maxLengthInt > 254) {
580: maxLengthInt = 254;
581: }
582: varMaxLength = String.valueOf(maxLengthInt);
583: } catch (Exception ex) {
584: throw new ClientPageRedirectException(
585: NavigConsts.DYNAMIC_VARIABLES_HANDLER
586: + "?from="
587: + from
588: + "&sortCriterion="
589: + sortCriterion
590: + "&sortAsc="
591: + sortAsc
592: + "&pro_id="
593: + proId
594: + "&act_id="
595: + actId
596: + "&errMessage=Max Length must be valid integer value (1-254)!"
597: + "&fromPage=" + fromPage
598: + "&nextAction=" + nextAction);
599: }
600: if (varValue.length() > maxLengthInt) {
601: throw new ClientPageRedirectException(
602: NavigConsts.DYNAMIC_VARIABLES_HANDLER
603: + "?from="
604: + from
605: + "&sortCriterion="
606: + sortCriterion
607: + "&sortAsc="
608: + sortAsc
609: + "&pro_id="
610: + proId
611: + "&act_id="
612: + actId
613: + "&errMessage=Initial value is to long. Max length is "
614: + (maxLengthInt > 0
615: && maxLengthInt < 254 ? varMaxLength
616: : "254") + "!" + "&fromPage="
617: + fromPage + "&nextAction="
618: + nextAction);
619: }
620:
621: if (exists || pcnt.containsKey(varId)) {
622:
623: throw new ClientPageRedirectException(
624: NavigConsts.DYNAMIC_VARIABLES_HANDLER
625: + "?from="
626: + from
627: + "&sortCriterion="
628: + sortCriterion
629: + "&sortAsc="
630: + sortAsc
631: + "&pro_id="
632: + proId
633: + "&act_id="
634: + actId
635: + "&errMessage=Variable Id already exists!"
636: + "&fromPage=" + fromPage
637: + "&nextAction=" + nextAction);
638:
639: }
640:
641: if (null != dynamicVariableDisplay
642: && !dynamicVariableDisplay.equals("")) {
643: dynamicVariableDisplay += "," + varId;
644: } else {
645: dynamicVariableDisplay = varId;
646: }
647: tempMap.put(
648: SharkParamConsts.DYNAMIC_VARIABLE_DISPLAY_VARIABLE,
649: dynamicVariableDisplay);
650:
651: int size = 0;
652: if (null != ids && null != names && null != mandatories
653: && null != lengths) {
654: size = ids.length;
655: }
656:
657: String[] newIdsArr = new String[size + 1];
658: String[] newNamesArr = new String[size + 1];
659: String[] newMandatoriesArr = new String[size + 1];
660: String[] newMaXLengthsArr = new String[size + 1];
661:
662: if (null != ids && null != names && null != mandatories
663: && null != lengths) {
664: for (int i = 0; i < size; i++) {
665: newIdsArr[i] = ids[i];
666: newNamesArr[i] = names[i];
667: newMandatoriesArr[i] = mandatories[i];
668: newMaXLengthsArr[i] = lengths[i];
669: }
670: }
671:
672: newIdsArr[size] = varId;
673: tempMap.put(SharkParamConsts.DYNAMIC_VARIABLE_IDS_VARIABLE,
674: newIdsArr);
675:
676: newNamesArr[size] = varName;
677: tempMap.put(
678: SharkParamConsts.DYNAMIC_VARIABLE_NAMES_VARIABLE,
679: newNamesArr);
680:
681: tempMap.put(varId, varValue);
682:
683: newMandatoriesArr[size] = (null != varMandatory ? "true"
684: : "false");
685: tempMap
686: .put(
687: SharkParamConsts.DYNAMIC_VARIABLE_MANDATORIES_VARIABLE,
688: newMandatoriesArr);
689:
690: newMaXLengthsArr[size] = (varMaxLength);
691: tempMap
692: .put(
693: SharkParamConsts.DYNAMIC_VARIABLE_MAX_LENGTHS_VARIABLE,
694: newMaXLengthsArr);
695: Iterator it = tempMap.entrySet().iterator();
696: while (it.hasNext()) {
697: Map.Entry me = (Map.Entry) it.next();
698: if (actId == null || actId.equals("")) {
699: wapi.assignProcessInstanceAttribute(shandle, proId,
700: me.getKey().toString(), me.getValue());
701: } else {
702: wapi.assignActivityInstanceAttribute(shandle,
703: proId, actId, me.getKey().toString(), me
704: .getValue());
705: }
706: }
707:
708: wapi.disconnect(shandle);
709: } catch (Exception e) {
710:
711: e.printStackTrace();
712: throw new PresentationException("Can't save", e);
713: }
714:
715: throw new ClientPageRedirectException(
716: NavigConsts.DYNAMIC_VARIABLES_HANDLER + "?from=" + from
717: + "&sortCriterion=" + sortCriterion
718: + "&sortAsc=" + sortAsc + "&pro_id=" + proId
719: + "&act_id=" + actId + "&fromPage=" + fromPage
720: + "&nextAction=" + nextAction);
721: }
722:
723: protected boolean chooseNextPerformer(WMSessionHandle shandle,
724: String procId, String actId) throws Exception {
725: if (SharkUtils.sharkEdition
726: .equals(SharkParamConsts.SHARK_EDITION_COMMUNITY)) {
727: return false;
728: }
729: boolean chooseNextPerformer = false;
730: AdminMisc am = SharkInterfaceWrapper.getShark().getAdminMisc();
731:
732: WMEntity actInfo = am.getActivityDefinitionInfo(shandle,
733: procId, actId);
734: String cval = WMEntityUtilities.findEAAndGetValue(shandle,
735: SharkInterfaceWrapper.getShark().getXPDLBrowser(),
736: actInfo, SharkParamConsts.EA_CHOOSE_NEXT_PERFORMER);
737: if (cval == null) {
738: WMEntity procInfo = am.getProcessDefinitionInfo(shandle,
739: procId);
740: cval = WMEntityUtilities
741: .findEAAndGetValue(shandle, SharkInterfaceWrapper
742: .getShark().getXPDLBrowser(), procInfo,
743: SharkParamConsts.EA_CHOOSE_NEXT_PERFORMER);
744: }
745: if (cval == null) {
746: WMEntity pkgInfo = SharkInterfaceWrapper.getShark()
747: .getPackageAdministration().getPackageEntity(
748: shandle, actInfo.getPkgId(),
749: actInfo.getPkgVer());
750: cval = WMEntityUtilities.findEAAndGetValue(shandle,
751: SharkInterfaceWrapper.getShark().getXPDLBrowser(),
752: pkgInfo, SharkParamConsts.EA_CHOOSE_NEXT_PERFORMER);
753: }
754: if (cval != null) {
755: if (cval.equalsIgnoreCase("true")
756: || cval.equalsIgnoreCase("false")) {
757: chooseNextPerformer = new Boolean(cval.toLowerCase())
758: .booleanValue();
759: }
760: }
761:
762: return chooseNextPerformer;
763: }
764:
765: }
|