svn commit: r478992 - in /incubator/ofbiz/trunk/applications/product: servicedef/services_shipment.xml src/org/ofbiz/shipment/shipment/ShipmentServices.java webapp/facility/WEB-INF/controller.xml webapp/facility/shipment/EditShipmentRouteSegments.ftl

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

svn commit: r478992 - in /incubator/ofbiz/trunk/applications/product: servicedef/services_shipment.xml src/org/ofbiz/shipment/shipment/ShipmentServices.java webapp/facility/WEB-INF/controller.xml webapp/facility/shipment/EditShipmentRouteSegments.ftl

sichen
Author: sichen
Date: Fri Nov 24 12:44:26 2006
New Revision: 478992

URL: http://svn.apache.org/viewvc?view=rev&rev=478992
Log:
ability to duplicate shipment route segments

Modified:
    incubator/ofbiz/trunk/applications/product/servicedef/services_shipment.xml
    incubator/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java
    incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml
    incubator/ofbiz/trunk/applications/product/webapp/facility/shipment/EditShipmentRouteSegments.ftl

Modified: incubator/ofbiz/trunk/applications/product/servicedef/services_shipment.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/servicedef/services_shipment.xml?view=diff&rev=478992&r1=478991&r2=478992
==============================================================================
--- incubator/ofbiz/trunk/applications/product/servicedef/services_shipment.xml (original)
+++ incubator/ofbiz/trunk/applications/product/servicedef/services_shipment.xml Fri Nov 24 12:44:26 2006
@@ -290,6 +290,13 @@
         <description>Delete ShipmentRouteSegment</description>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
+    <service name="duplicateShipmentRouteSegment" default-entity-name="ShipmentRouteSegment" engine="java"
+            location="org.ofbiz.shipment.shipment.ShipmentServices" invoke="duplicateShipmentRouteSegment" auth="true">
+        <description>Duplicates a shipment route segment and creates the new route segment in the NOT_STARTED status</description>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <attribute name="newShipmentRouteSegmentId" type="String" mode="OUT" optional="false"/>
+    </service>
     <service name="quickScheduleShipmentRouteSegment" default-entity-name="ShipmentRouteSegment" engine="java"
             location="org.ofbiz.shipment.shipment.ShipmentServices" invoke="quickScheduleShipmentRouteSegment" auth="true">
         <description>Schedules a shipment route segment with the carrier and service level in the ShipmentRouteSegment entity.

Modified: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java?view=diff&rev=478992&r1=478991&r2=478992
==============================================================================
--- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java (original)
+++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java Fri Nov 24 12:44:26 2006
@@ -838,6 +838,43 @@
         return ServiceUtil.returnSuccess("Intentional error at end to keep from committing.");
     }
 
+    public static Map duplicateShipmentRouteSegment(DispatchContext dctx, Map context) {
+        GenericDelegator delegator = dctx.getDelegator();
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+
+        String shipmentId = (String) context.get("shipmentId");
+        String shipmentRouteSegmentId = (String) context.get("shipmentRouteSegmentId");
+    
+        Map results = ServiceUtil.returnSuccess();
+
+        try {
+            GenericValue shipmentRouteSeg = delegator.findByPrimaryKey("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId));
+            if (shipmentRouteSeg == null) {
+                return ServiceUtil.returnError("Shipment Route Segment not found for shipment [" + shipmentId + "] route segment [" + shipmentRouteSegmentId + "]");
+            }
+
+            Map params = UtilMisc.toMap("shipmentId", shipmentId, "carrierPartyId", shipmentRouteSeg.getString("carrierPartyId"), "shipmentMethodTypeId", shipmentRouteSeg.getString("shipmentMethodTypeId"),
+                    "originFacilityId", shipmentRouteSeg.getString("originFacilityId"), "originContactMechId", shipmentRouteSeg.getString("originContactMechId"),
+                    "originTelecomNumberId", shipmentRouteSeg.getString("originTelecomNumberId"));
+            params.put("destFacilityId", shipmentRouteSeg.getString("destFacilityId"));
+            params.put("destContactMechId", shipmentRouteSeg.getString("destContactMechId"));
+            params.put("destTelecomNumberId", shipmentRouteSeg.getString("destTelecomNumberId"));
+            params.put("userLogin", userLogin);
+
+            Map tmpResult = dispatcher.runSync("createShipmentRouteSegment", params);
+            if (ServiceUtil.isError(tmpResult)) {
+                return tmpResult;
+            } else {
+                results.put("newShipmentRouteSegmentId", tmpResult.get("shipmentRouteSegmentId"));
+                return results;
+            }
+        } catch (GenericEntityException ex) {
+            return ServiceUtil.returnError(ex.getMessage());
+        } catch (GenericServiceException ex) {
+            return ServiceUtil.returnError(ex.getMessage());
+        }
+    }
     /**
      * Service to call a ShipmentRouteSegment.carrierPartyId's confirm shipment method asynchronously
      */

Modified: incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml?view=diff&rev=478992&r1=478991&r2=478992
==============================================================================
--- incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml (original)
+++ incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/controller.xml Fri Nov 24 12:44:26 2006
@@ -852,6 +852,12 @@
         <response name="success" type="view" value="EditShipmentRouteSegments"/>
         <response name="error" type="view" value="EditShipmentRouteSegments"/>
     </request-map>
+    <request-map uri="duplicateShipmentRouteSegment">
+        <security https="true" auth="true"/>
+        <event type="service" path="" invoke="duplicateShipmentRouteSegment"/>
+        <response name="success" type="view" value="EditShipmentRouteSegments"/>
+        <response name="error" type="view" value="EditShipmentRouteSegments"/>
+    </request-map>
     <request-map uri="createRouteSegmentShipmentPackage">
         <security https="true" auth="true"/>
         <event type="service" path="" invoke="createShipmentPackageRouteSeg"/>

Modified: incubator/ofbiz/trunk/applications/product/webapp/facility/shipment/EditShipmentRouteSegments.ftl
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/facility/shipment/EditShipmentRouteSegments.ftl?view=diff&rev=478992&r1=478991&r2=478992
==============================================================================
--- incubator/ofbiz/trunk/applications/product/webapp/facility/shipment/EditShipmentRouteSegments.ftl (original)
+++ incubator/ofbiz/trunk/applications/product/webapp/facility/shipment/EditShipmentRouteSegments.ftl Fri Nov 24 12:44:26 2006
@@ -201,7 +201,8 @@
             <br/>
             <input type="text" size="8" name="actualCost" value="${shipmentRouteSegment.actualCost?if_exists}" class="inputBox"/>
         </td>
-        <td><a href="javascript:document.updateShipmentRouteSegmentForm${shipmentRouteSegmentData_index}.submit();" class="buttontext">${uiLabelMap.CommonUpdate}</a></td>
+        <td><a href="javascript:document.updateShipmentRouteSegmentForm${shipmentRouteSegmentData_index}.submit();" class="buttontext">${uiLabelMap.CommonUpdate}</a>
+        <br/><div class="tabletext"><a href="<@ofbizUrl>duplicateShipmentRouteSegment?shipmentId=${shipmentId}&shipmentRouteSegmentId=${shipmentRouteSegment.shipmentRouteSegmentId}</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonDuplicate}</a></div></td>
         <td><div class="tabletext"><a href="<@ofbizUrl>deleteShipmentRouteSegment?shipmentId=${shipmentId}&shipmentRouteSegmentId=${shipmentRouteSegment.shipmentRouteSegmentId}</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonDelete}</a></div></td>
     </tr>
     </form>