svn commit: r423836 - /incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java

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

svn commit: r423836 - /incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java

hansbak-2
Author: hansbak
Date: Thu Jul 20 01:56:18 2006
New Revision: 423836

URL: http://svn.apache.org/viewvc?rev=423836&view=rev
Log:
if there are partyassignments to the routingTask, valid date records will
be copied over to the productionTask.

Modified:
    incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java

Modified: incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=423836&r1=423835&r2=423836&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Thu Jul 20 01:56:18 2006
@@ -331,6 +331,35 @@
                 } catch (GenericServiceException e) {
                     Debug.logError(e, "Problem calling the createWorkEffortAssoc service", module);
                 }
+                // copy date valid WorkEffortPartyAssignments from the routing task to the run task
+                List workEffortPartyAssignments = null;
+                try {
+                    workEffortPartyAssignments = EntityUtil.filterByDate(delegator.findByAnd("WorkEffortPartyAssignment",
+                            UtilMisc.toMap("workEffortId", routingTaskAssoc.getString("workEffortIdTo"))));
+                } catch (GenericEntityException e) {
+                    Debug.logError(e.getMessage(),  module);
+                }
+                if (workEffortPartyAssignments != null) {
+                    Iterator i = workEffortPartyAssignments.iterator();
+                    while(i.hasNext()) {
+                        GenericValue workEffortPartyAssignment = (GenericValue) i.next();
+                        Map partyToWorkEffort = UtilMisc.toMap(
+                                "workEffortId",  productionRunTaskId,
+                                "partyId",  workEffortPartyAssignment.getString("partyId"),
+                                "roleTypeId",  workEffortPartyAssignment.getString("roleTypeId"),
+                                "fromDate",  workEffortPartyAssignment.getTimestamp("fromDate"),
+                                "statusId",  workEffortPartyAssignment.getString("statusId"),
+                                "userLogin", userLogin
+                        );
+                        try {
+                            resultService = dispatcher.runSync("assignPartyToWorkEffort", partyToWorkEffort);
+                        } catch (GenericServiceException e) {
+                            Debug.logError(e, "Problem calling the assignPartyToWorkEffort service", module);
+                        }
+                        if (Debug.infoOn()) Debug.logInfo("ProductionRunPartyassigment for party: " + workEffortPartyAssignment.get("partyId") + " created", module);
+                    }
+                }
+
                 // Now we iterate thru the components returned by the getManufacturingComponents service
                 // TODO: if in the BOM a routingWorkEffortId is specified, but the task is not in the routing
                 //       the component is not added to the production run.
@@ -1160,6 +1189,34 @@
         productionRun.setEstimatedCompletionDate(productionRun.recalculateEstimatedCompletionDate());
         if (!productionRun.store()) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingAddProductionRunRoutingTaskNotCreated", locale));
+        }
+        
+        // copy date valid WorkEffortPartyAssignments from the routing task to the run task
+        List workEffortPartyAssignments = null;
+        try {
+            workEffortPartyAssignments = EntityUtil.filterByDate(delegator.findByAnd("WorkEffortPartyAssignment", UtilMisc.toMap("workEffortId", routingTaskId)));
+        } catch (GenericEntityException e) {
+            Debug.logError(e.getMessage(),  module);
+        }
+        if (workEffortPartyAssignments != null) {
+            Iterator i = workEffortPartyAssignments.iterator();
+            while(i.hasNext()) {
+                GenericValue workEffortPartyAssignment = (GenericValue) i.next();
+                Map partyToWorkEffort = UtilMisc.toMap(
+                        "workEffortId",  productionRunTaskId,
+                        "partyId",  workEffortPartyAssignment.getString("partyId"),
+                        "roleTypeId",  workEffortPartyAssignment.getString("roleTypeId"),
+                        "fromDate",  workEffortPartyAssignment.getTimestamp("fromDate"),
+                        "statusId",  workEffortPartyAssignment.getString("statusId"),
+                        "userLogin", userLogin
+                );
+                try {
+                    resultService = dispatcher.runSync("assignPartyToWorkEffort", partyToWorkEffort);
+                } catch (GenericServiceException e) {
+                    Debug.logError(e, "Problem calling the assignPartyToWorkEffort service", module);
+                }
+                if (Debug.infoOn()) Debug.logInfo("ProductionRunPartyassigment for party: " + workEffortPartyAssignment.get("partyId") + " created", module);
+            }
         }
         
         result.put("routingTaskId", productionRunTaskId);