KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > workeffort > workeffort > WorkEffortPartyAssignmentServices


1 /*
2  * $Id: WorkEffortPartyAssignmentServices.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2002 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */

25 package org.ofbiz.workeffort.workeffort;
26
27 import java.util.Map JavaDoc;
28
29 import org.ofbiz.base.util.Debug;
30 import org.ofbiz.base.util.UtilMisc;
31 import org.ofbiz.entity.GenericDelegator;
32 import org.ofbiz.entity.GenericEntityException;
33 import org.ofbiz.entity.GenericValue;
34 import org.ofbiz.service.GenericServiceException;
35 import org.ofbiz.service.LocalDispatcher;
36 import org.ofbiz.service.ModelService;
37
38 /**
39  * WorkEffortPartyAssignmentServices - Services to handle form input and other data changes.
40  *
41  * @author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
42  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
43  * @version $Rev: 5462 $
44  * @since 2.0
45  */

46 public class WorkEffortPartyAssignmentServices {
47     
48     public static final String JavaDoc module = WorkEffortPartyAssignmentServices.class.getName();
49
50     public static void updateWorkflowEngine(GenericValue wepa, GenericValue userLogin, LocalDispatcher dispatcher) {
51         // if the WorkEffort is an ACTIVITY, check for accept or complete new status...
52
GenericDelegator delegator = wepa.getDelegator();
53         GenericValue workEffort = null;
54
55         try {
56             workEffort = delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId", wepa.get("workEffortId")));
57         } catch (GenericEntityException e) {
58             Debug.logWarning(e, module);
59         }
60         if (workEffort != null && "ACTIVITY".equals(workEffort.getString("workEffortTypeId"))) {
61             // TODO: restrict status transitions
62

63             String JavaDoc statusId = (String JavaDoc) wepa.get("statusId");
64             Map JavaDoc context = UtilMisc.toMap("workEffortId", wepa.get("workEffortId"), "partyId", wepa.get("partyId"),
65                     "roleTypeId", wepa.get("roleTypeId"), "fromDate", wepa.get("fromDate"),
66                     "userLogin", userLogin);
67
68             if ("CAL_ACCEPTED".equals(statusId)) {
69                 // accept the activity assignment
70
try {
71                     Map JavaDoc results = dispatcher.runSync("wfAcceptAssignment", context);
72
73                     if (results != null && results.get(ModelService.ERROR_MESSAGE) != null)
74                         Debug.logWarning((String JavaDoc) results.get(ModelService.ERROR_MESSAGE), module);
75                 } catch (GenericServiceException e) {
76                     Debug.logWarning(e, module);
77                 }
78             } else if ("CAL_COMPLETED".equals(statusId)) {
79                 // complete the activity assignment
80
try {
81                     Map JavaDoc results = dispatcher.runSync("wfCompleteAssignment", context);
82
83                     if (results != null && results.get(ModelService.ERROR_MESSAGE) != null)
84                         Debug.logWarning((String JavaDoc) results.get(ModelService.ERROR_MESSAGE), module);
85                 } catch (GenericServiceException e) {
86                     Debug.logWarning(e, module);
87                 }
88             } else if ("CAL_DECLINED".equals(statusId)) {
89                 // decline the activity assignment
90
try {
91                     Map JavaDoc results = dispatcher.runSync("wfDeclineAssignment", context);
92
93                     if (results != null && results.get(ModelService.ERROR_MESSAGE) != null)
94                         Debug.logWarning((String JavaDoc) results.get(ModelService.ERROR_MESSAGE), module);
95                 } catch (GenericServiceException e) {
96                     Debug.logWarning(e, module);
97                 }
98             } else {// do nothing...
99
}
100         }
101     }
102 }
103
Popular Tags