svn commit: r571103 - in /ofbiz/trunk/applications/workeffort: servicedef/services.xml src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r571103 - in /ofbiz/trunk/applications/workeffort: servicedef/services.xml src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java

jacopoc
Author: jacopoc
Date: Thu Aug 30 03:27:25 2007
New Revision: 571103

URL: http://svn.apache.org/viewvc?rev=571103&view=rev
Log:
Implemented new service to get the list of active events where the logged in user is assigned in a specified role.

Modified:
    ofbiz/trunk/applications/workeffort/servicedef/services.xml
    ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java

Modified: ofbiz/trunk/applications/workeffort/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/servicedef/services.xml?rev=571103&r1=571102&r2=571103&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/workeffort/servicedef/services.xml Thu Aug 30 03:27:25 2007
@@ -133,6 +133,12 @@
     </service>
     
     <!-- Services for finding Assigned WorkEfforts -->
+    <service name="getWorkEffortAssignedEventsForRole" engine="java"
+            location="org.ofbiz.workeffort.workeffort.WorkEffortServices" invoke="getWorkEffortAssignedEventsForRole">
+        <description>Get the active WorkEffort Events where the logged in user is assigned in the specidied role.</description>
+        <attribute name="roleTypeId" type="String" mode="IN" optional="false"/>
+        <attribute name="events" type="java.util.List" mode="OUT" optional="false"/>
+    </service>
     <service name="getWorkEffortAssignedTasks" engine="java"
             location="org.ofbiz.workeffort.workeffort.WorkEffortServices" invoke="getWorkEffortAssignedTasks">
         <description>Get WorkEffort Assigned Tasks</description>

Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java?rev=571103&r1=571102&r2=571103&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java (original)
+++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java Thu Aug 30 03:27:25 2007
@@ -56,6 +56,39 @@
     
     public static final String module = WorkEffortServices.class.getName();
 
+    public static Map getWorkEffortAssignedEventsForRole(DispatchContext ctx, Map context) {
+        GenericDelegator delegator = ctx.getDelegator();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        String roleTypeId = (String) context.get("roleTypeId");
+
+        List validWorkEfforts = null;
+
+        if (userLogin != null && userLogin.get("partyId") != null) {
+            try {
+                List conditionList = UtilMisc.toList(new EntityExpr("partyId", EntityOperator.EQUALS, userLogin.get("partyId")),
+                                new EntityExpr("roleTypeId", EntityOperator.EQUALS, roleTypeId),
+                                new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "EVENT"));
+                conditionList.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));
+                conditionList.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_DELEGATED"));
+                conditionList.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"));
+                conditionList.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"));
+                validWorkEfforts = delegator.findByAnd("WorkEffortAndPartyAssign",
+                                                       conditionList,
+                                                       UtilMisc.toList("estimatedStartDate", "priority"));
+            } catch (GenericEntityException e) {
+                Debug.logWarning(e, module);
+                return ServiceUtil.returnError("Error finding desired WorkEffort records: " + e.toString());
+            }
+        }
+
+        Map result = new HashMap();
+        if (validWorkEfforts == null) {
+            validWorkEfforts = new LinkedList();
+        }
+        result.put("events", validWorkEfforts);
+        return result;
+    }
+
     public static Map getWorkEffortAssignedTasks(DispatchContext ctx, Map context) {
         GenericDelegator delegator = ctx.getDelegator();
         GenericValue userLogin = (GenericValue) context.get("userLogin");