We've been using the pattern of passing parameters into new cart items through factory and constructor methods for too long, and it's past the point where it's a bit crazy!

Before this becomes a dependency that is difficult to change for these new parameters, could we change this so that it does not change those method signatures (ie doesn't add the parameters) but instead calls set methods on the cart object AFTER it is created?

-David


On Feb 24, 2008, at 7:22 PM, [EMAIL PROTECTED] wrote:

Author: hansbak
Date: Sun Feb 24 18:22:15 2008
New Revision: 630718

URL: http://svn.apache.org/viewvc?rev=630718&view=rev
Log:
introduction of new reservation entities: OFBIZ-1590

Modified:
   ofbiz/trunk/applications/accounting/entitydef/entitygroup.xml
   ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ OrderServices.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCart.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartEvents.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartHelper.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartItem.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartServices.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ ShoppingListEvents.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ ShoppingListServices.java
   ofbiz/trunk/applications/workeffort/entitydef/entitymodel.xml

Modified: ofbiz/trunk/applications/accounting/entitydef/ entitygroup.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitygroup.xml?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/accounting/entitydef/entitygroup.xml (original) +++ ofbiz/trunk/applications/accounting/entitydef/entitygroup.xml Sun Feb 24 18:22:15 2008
@@ -83,6 +83,11 @@
    <entity-group group="org.ofbiz" entity="FixedAssetType" />
    <entity-group group="org.ofbiz" entity="FixedAssetTypeAttr" />
<entity-group group="org.ofbiz" entity="PartyFixedAssetAssignment" />
+    <entity-group group="org.ofbiz" entity="AccommodationClass"/>
+    <entity-group group="org.ofbiz" entity="AccommodationMap"/>
+    <entity-group group="org.ofbiz" entity="AccommodationSpot"/>
+    <entity-group group="org.ofbiz" entity="AccommodationMapType"/>
+

    <!-- ========================================================= -->
    <!-- org.ofbiz.accounting.invoice -->

Modified: ofbiz/trunk/applications/accounting/entitydef/ entitymodel.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Sun Feb 24 18:22:15 2008
@@ -954,6 +954,62 @@
        </relation>
    </entity>

+  <entity entity-name="AccommodationClass"
+    package-name="org.ofbiz.accounting.fixedasset"
+    title="Accommodation Class">
+    <field name="accommodationClassId" type="id-ne"></field>
+    <field name="parentClassId" type="id-ne"></field>
+    <field name="description" type="description"></field>
+    <prim-key field="accommodationClassId"/>
+ <relation type="one" fk-name="ACCOMM_CLASS_PAR" title="Parent" rel-entity-name="AccommodationClass"> + <key-map field-name="parentClassId" rel-field- name="accommodationClassId"/>
+    </relation>
+  </entity>
+  <entity entity-name="AccommodationSpot"
+    package-name="org.ofbiz.order.reservations"
+    title="Accommodation Spot">
+    <field name="accommodationSpotId" type="id-ne"></field>
+    <field name="accommodationClassId" type="id"></field>
+    <field name="fixedAssetId" type="id"></field>
+    <field name="numberOfSpaces" type="numeric"></field>
+    <field name="description" type="description"></field>
+    <prim-key field="accommodationSpotId"/>
+ <relation type="one" fk-name="ACCOM_CLASS" rel-entity- name="AccommodationClass">
+      <key-map field-name="accommodationClassId"/>
+    </relation>
+ <relation type="one" fk-name="SPOT_FA" rel-entity- name="FixedAsset">
+      <key-map field-name="fixedAssetId"/>
+    </relation>
+  </entity>
+
+  <entity entity-name="AccommodationMap"
+    package-name="org.ofbiz.accounting.fixedasset"
+    title="Accommodation Map">
+    <field name="accommodationMapId" type="id-ne"></field>
+    <field name="accommodationClassId" type="id-ne"></field>
+    <field name="fixedAssetId" type="id"></field>
+    <field name="accommodationMapTypeId" type="id"></field>
+    <field name="numberOfSpaces" type="numeric"></field>
+    <prim-key field="accommodationMapId"/>
+ <relation type="one" fk-name="ACMD_MAP_CLASS" rel-entity- name="AccommodationClass">
+      <key-map field-name="accommodationClassId"/>
+    </relation>
+ <relation type="one" fk-name="ACMD_MAP_FA" rel-entity- name="FixedAsset">
+      <key-map field-name="fixedAssetId"/>
+    </relation>
+ <relation type="one" fk-name="ACMD_MAP_TYPE" rel-entity- name="AccommodationMapType">
+      <key-map field-name="accommodationMapTypeId"/>
+    </relation>
+  </entity>
+
+  <entity entity-name="AccommodationMapType"
+    package-name="org.ofbiz.accounting.fixedasset"
+    title="Accommodation Map Type">
+    <field name="accommodationMapTypeId" type="id-ne"></field>
+    <field name="description" type="description"></field>
+    <prim-key field="accommodationMapTypeId"/>
+  </entity>
+
  <!-- ========================================================= -->
  <!-- org.ofbiz.accounting.invoice -->
  <!-- ========================================================= -->

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ OrderServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ OrderServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ OrderServices.java Sun Feb 24 18:22:15 2008
@@ -369,13 +369,15 @@
                            errorMessages.add(excMsg);
return ServiceUtil .returnError (UtilProperties .getMessage (resource_error ,"OrderCouldNotFindRelatedFixedAssetForTheProduct ",UtilMisc.toMap("productId",orderItem.getString("productId")), locale ));
                        }
+
if (selFixedAssetProduct != null && selFixedAssetProduct.size() > 0) { Iterator firstOne = selFixedAssetProduct.iterator();
                            if(firstOne.hasNext())        {
GenericValue fixedAssetProduct = delegator.makeValue("FixedAssetProduct"); - fixedAssetProduct = (GenericValue) firstOne.next(); - workEffort.set("fixedAssetId",fixedAssetProduct.get("fixedAssetId")); + fixedAssetProduct = (GenericValue) firstOne.next(); + workEffort.set("fixedAssetId",fixedAssetProduct.get("fixedAssetId")); workEffort.set("quantityToProduce",orderItem.get("quantity")); // have quantity easy available later... + workEffort.set("createdByUserLogin", userLogin.get("userLoginId"));
                            }
                        }
break; // item found, so go to next orderitem.

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/ShoppingCart.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCart.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCart.java Sun Feb 24 18:22:15 2008
@@ -448,6 +448,17 @@
public int addOrIncreaseItem(String productId, Double selectedAmountDbl, double quantity, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map features, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
+
+ return addOrIncreaseItem (productId ,selectedAmountDbl ,quantity,reservStart,reservLengthDbl,reservPersonsDbl, + null ,null,shipBeforeDate,shipAfterDate,features,attributes,prodCatalogId, + configWrapper,itemType,itemGroupNumber,parentProductId,dispatcher);
+    }
+
+    /** add rental (with accommodation) item to cart  */
+ public int addOrIncreaseItem(String productId, Double selectedAmountDbl, double quantity, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl,
+               String accommodationMapId, String accommodationSpotId,
+ Timestamp shipBeforeDate, Timestamp shipAfterDate, Map features, Map attributes, String prodCatalogId, + ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException {
        if (isReadOnlyCart()) {
throw new CartItemModifyException("Cart items cannot be changed");
        }
@@ -463,7 +474,7 @@
ShoppingCartItem sci = (ShoppingCartItem) cartLines.get(i);


- if (sci.equals(productId, reservStart, reservLength, reservPersons, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, selectedAmount)) { + if (sci.equals(productId, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, features, attributes, prodCatalogId,selectedAmount, configWrapper, itemType, itemGroup, false)) {
                double newQuantity = sci.getQuantity() + quantity;

if (Debug.verboseOn()) Debug.logVerbose("Found a match for id " + productId + " on line " + i + ", updating quantity to " + newQuantity, module);
@@ -492,7 +503,7 @@
            }
        } else {
return this.addItem(0, ShoppingCartItem.makeItem(new Integer(0), productId, selectedAmountDbl, quantity, null, - reservStart, reservLengthDbl, reservPersonsDbl, shipBeforeDate, shipAfterDate, + reservStart, reservLengthDbl, reservPersonsDbl, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, this, Boolean.TRUE, Boolean.TRUE, parentProductId, Boolean.FALSE, Boolean.FALSE));
        }
@@ -556,6 +567,21 @@
public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl, HashMap features, HashMap attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLengthDbl, reservPersonsDbl, null, null, features, attributes, prodCatalogId, configWrapper, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
    }
+
+    /** Add an accommodation(rental )item to the shopping cart. */
+ public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl, String accommodationMapId, String accommodationSpotId, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException { + return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLengthDbl, reservPersonsDbl, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, Boolean.FALSE, Boolean.FALSE));
+    }
+
+    /** Add an accommodation(rental)item to the shopping cart. */
+ public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl,String accommodationMapId, String accommodationSpotId, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { + return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLengthDbl, reservPersonsDbl, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
+    }
+
+ /** Add an accommodation(rental/aggregated)item to the shopping cart. */ + public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl,String accommodationMapId, String accommodationSpotId, HashMap features, HashMap attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { + return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLengthDbl, reservPersonsDbl, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, configWrapper, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
+    }

    /** Add an item to the shopping cart. */
public int addItemToEnd(String productId, Double amount, double quantity, Double unitPrice, HashMap features, HashMap attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
@@ -3407,7 +3433,8 @@
workEffort.set("reservPersons",new Double(item.getReservPersons())); workEffort.set("reserv2ndPPPerc", new Double(item.getReserv2ndPPPerc())); workEffort.set("reservNthPPPerc", new Double(item.getReservNthPPPerc()));
-
+ workEffort.set("accommodationMapId", item.getAccommodationMapId()); + workEffort.set("accommodationSpotId",item.getAccommodationSpotId());
                allWorkEfforts.add(workEffort);
            }
        }

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/ShoppingCartEvents.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartEvents.java Sun Feb 24 18:22:15 2008
@@ -133,6 +133,8 @@
        Double reservLength = null;
        String reservPersonsStr = null;
        Double reservPersons = null;
+        String accommodationMapId = null;
+        String accommodationSpotId = null;
        String shipBeforeDateStr = null;
        String shipAfterDateStr = null;
        java.sql.Timestamp shipBeforeDate = null;
@@ -321,6 +323,13 @@
request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage(resource, "cart.addToCart.enterBookingInforamtionBeforeAddingToCart", locale));
                return "product";
            }
+
+            //check accommodation for reservations
+ if((paramMap.containsKey("accommodationMapId")) && (paramMap.containsKey("accommodationSpotId"))){ + accommodationMapId = (String) paramMap.remove("accommodationMapId"); + accommodationSpotId = (String) paramMap.remove("accommodationSpotId");
+
+            }

        }

@@ -492,6 +501,7 @@
        // Translate the parameters and add to the cart
result = cartHelper.addToCart(catalogId, shoppingListId, shoppingListItemSeqId, productId, productCategoryId, itemType, itemDescription, price, amount, quantity, reservStart, reservLength, reservPersons,
+                accommodationMapId, accommodationSpotId,
shipBeforeDate, shipAfterDate, configWrapper, itemGroupNumber, paramMap, parentProductId);
        controlDirective = processResult(result, request);


Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/ShoppingCartHelper.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartHelper.java Sun Feb 24 18:22:15 2008
@@ -103,6 +103,20 @@
java.sql.Timestamp reservStart, Double reservLength, Double reservPersons, java.sql.Timestamp shipBeforeDate, java.sql.Timestamp shipAfterDate, ProductConfigWrapper configWrapper, String itemGroupNumber, Map context, String parentProductId) {
+
+ return addToCart(catalogId,shoppingListId,shoppingListItemSeqId,productId, + productCategoryId,itemType,itemDescription,price,amount,quantity, + reservStart ,reservLength,reservPersons,null,null,shipBeforeDate,shipAfterDate, + configWrapper,itemGroupNumber,context,parentProductId);
+    }
+
+ /** Event to add an item to the shopping cart with accommodation. */ + public Map addToCart(String catalogId, String shoppingListId, String shoppingListItemSeqId, String productId, + String productCategoryId, String itemType, String itemDescription,
+            Double price, Double amount, double quantity,
+ java.sql.Timestamp reservStart, Double reservLength, Double reservPersons, String accommodationMapId,String accommodationSpotId, + java.sql.Timestamp shipBeforeDate, java.sql.Timestamp shipAfterDate, + ProductConfigWrapper configWrapper, String itemGroupNumber, Map context, String parentProductId) {
        Map result = null;
        Map attributes = null;
        String pProductId = null;
@@ -215,9 +229,11 @@
        try {
            int itemId = -1;
            if (productId != null) {
- itemId = cart.addOrIncreaseItem(productId, amount, quantity, reservStart, reservLength, - reservPersons, shipBeforeDate, shipAfterDate, additionalFeaturesMap, attributes,
+
+ itemId = cart.addOrIncreaseItem(productId, amount, quantity, reservStart, reservLength, + reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, additionalFeaturesMap, attributes, catalogId, configWrapper, itemType, itemGroupNumber, pProductId, dispatcher);
+
            } else {
itemId = cart.addNonProductItem(itemType, itemDescription, productCategoryId, price, quantity, attributes, catalogId, itemGroupNumber, dispatcher);
            }
@@ -666,14 +682,16 @@
} else if (parameterName.toUpperCase().startsWith("DESCRIPTION")) { itemDescription = quantString; // the quantString is actually the description if the field name starts with DESCRIPTION } else if (parameterName.startsWith("reservStart")) { - // should have format: yyyy-mm-dd hh:mm:ss.fffffffff
-                        quantString += " 00:00:00.000000000";
-                        if (item != null) {
- Timestamp reservStart = Timestamp.valueOf(quantString);
-                            item.setReservStart(reservStart);
-                        }
+                       if (quantString.length() ==0){
+ // should have format: yyyy-mm-dd hh:mm:ss.fffffffff
+                               quantString += " 00:00:00.000000000";
+                       }
+                       if (item != null) {
+ Timestamp reservStart = Timestamp.valueOf(quantString);
+                               item.setReservStart(reservStart);
+                       }
} else if (parameterName.startsWith("reservLength")) {
-                        if (item != null) {
+                       if (item != null) {
double reservLength = nf.parse(quantString).doubleValue();
                            item.setReservLength(reservLength);
                        }

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/ShoppingCartItem.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartItem.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartItem.java Sun Feb 24 18:22:15 2008
@@ -96,6 +96,8 @@
    private double reservLength = 0;
    /** for reservations: number of persons using */
    private double reservPersons = 0;
+    private String accommodationMapId = null;
+    private String accommodationSpotId = null;
    private double quantity = 0.0;
    private double basePrice = 0.0;
    private Double displayPrice = null;
@@ -282,6 +284,25 @@
Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher, ShoppingCart cart, Boolean triggerExternalOpsBool, Boolean triggerPriceRulesBool, String parentProductId, Boolean skipInventoryChecks, Boolean skipProductChecks)
            throws CartItemModifyException, ItemNotFoundException {
+
+ return makeItem (cartLocation,productId,selectedAmountDbl,quantity,unitPriceDbl, + reservStart ,reservLengthDbl ,reservPersonsDbl,null,null,shipBeforeDate,shipAfterDate, + additionalProductFeatureAndAppls ,attributes,prodCatalogId,configWrapper, + itemType ,itemGroup ,dispatcher,cart,triggerExternalOpsBool,triggerPriceRulesBool, + parentProductId,skipInventoryChecks,skipProductChecks);
+
+    }
+
+    /**
+     * Makes a ShoppingCartItem and adds it to the cart.
+ * @param accommodationMapId Optional. reservations add into workeffort + * @param accommodationSpotId Optional. reservations add into workeffort
+     */
+ public static ShoppingCartItem makeItem(Integer cartLocation, String productId, Double selectedAmountDbl, double quantity, Double unitPriceDbl, + Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl,String accommodationMapId,String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, + Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, + String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher, ShoppingCart cart, Boolean triggerExternalOpsBool, Boolean triggerPriceRulesBool, String parentProductId, Boolean skipInventoryChecks, Boolean skipProductChecks)
+            throws CartItemModifyException, ItemNotFoundException {
        GenericDelegator delegator = cart.getDelegator();
        GenericValue product = null;
        GenericValue parentProduct = null;
@@ -322,7 +343,7 @@
            }
        }
return makeItem(cartLocation, product, selectedAmountDbl, quantity, unitPriceDbl, - reservStart, reservLengthDbl, reservPersonsDbl, shipBeforeDate, shipAfterDate, + reservStart, reservLengthDbl, reservPersonsDbl, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, cart, triggerExternalOpsBool, triggerPriceRulesBool, parentProduct, skipInventoryChecks, skipProductChecks);
    }
@@ -362,6 +383,25 @@
String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher, ShoppingCart cart, Boolean triggerExternalOpsBool, Boolean triggerPriceRulesBool, GenericValue parentProduct, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException {

+        return makeItem(cartLocation,product,selectedAmountDbl,
+ quantity,unitPriceDbl,reservStart,reservLengthDbl,reservPersonsDbl, + null ,null ,shipBeforeDate ,shipAfterDate,additionalProductFeatureAndAppls,attributes, + prodCatalogId,configWrapper,itemType,itemGroup,dispatcher,cart, + triggerExternalOpsBool ,triggerPriceRulesBool ,parentProduct,skipInventoryChecks,skipProductChecks);
+    }
+
+    /**
+     * Makes a ShoppingCartItem and adds it to the cart.
+ * @param accommodationMapId Optional. reservations add into workeffort + * @param accommodationSpotId Optional. reservations add into workeffort
+    */
+ public static ShoppingCartItem makeItem(Integer cartLocation, GenericValue product, Double selectedAmountDbl, + double quantity, Double unitPriceDbl, Timestamp reservStart, Double reservLengthDbl, Double reservPersonsDbl,
+            String accommodationMapId,String accommodationSpotId,
+ Timestamp shipBeforeDate, Timestamp shipAfterDate, Map additionalProductFeatureAndAppls, Map attributes, + String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, LocalDispatcher dispatcher, + ShoppingCart cart, Boolean triggerExternalOpsBool, Boolean triggerPriceRulesBool, GenericValue parentProduct, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException {
+
ShoppingCartItem newItem = new ShoppingCartItem(product, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, cart.getLocale(), itemType, itemGroup, parentProduct);

double selectedAmount = selectedAmountDbl == null ? 0.0 : selectedAmountDbl.doubleValue();
@@ -468,7 +508,11 @@

             if (product.get("reservNthPPPerc") != null)
newItem .setReservNthPPPerc (product.getDouble("reservNthPPPerc").doubleValue());
-
+
+ if ((accommodationMapId != null) && (accommodationSpotId != null)) { + newItem.setAccommodationId(accommodationMapId,accommodationSpotId);
+             }
+
// check to see if the related fixed asset is available for rent String isAvailable = checkAvailability(product.getString("productId"), quantity, reservStart, reservLength, cart);
            if(isAvailable.compareTo("OK") != 0) {
@@ -594,6 +638,8 @@
        this.reservStart = item.getReservStart();
        this.reservLength = item.getReservLength();
        this.reservPersons = item.getReservPersons();
+        this.accommodationMapId = item.getAccommodationMapId();
+        this.accommodationSpotId = item.getAccommodationSpotId();
        this.selectedAmount = item.getSelectedAmount();
        this.setBasePrice(item.getBasePrice());
        this.setDisplayPrice(item.getDisplayPrice());
@@ -767,6 +813,11 @@
    public void setReservPersons(double reservPersons)    {
        this.reservPersons = reservPersons;
    }
+    /** Sets accommodationId using the reservation */
+ public void setAccommodationId(String accommodationMapId,String accommodationSpotId) {
+        this.accommodationMapId = accommodationMapId;
+        this.accommodationSpotId = accommodationSpotId;
+    }

/** Sets the quantity for the item and validates the change in quantity, etc */ public void setQuantity(double quantity, LocalDispatcher dispatcher, ShoppingCart cart) throws CartItemModifyException {
@@ -1168,7 +1219,16 @@
    public double getReservPersons() {
        return this.reservPersons;
    }
-
+
+    /** Returns accommodationMapId */
+    public String getAccommodationMapId()    {
+        return this.accommodationMapId;
+    }
+    /** Returns accommodationSpotId  */
+    public String getAccommodationSpotId()    {
+        return this.accommodationSpotId;
+    }
+
    public double getPromoQuantityUsed() {
        if (this.getIsPromo()) {
            return this.quantity;
@@ -2151,21 +2211,20 @@

/** Compares the specified object with this cart item. Defaults isPromo to false. */ public boolean equals(String productId, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, double selectedAmount) { - return equals(productId, null, 0.00, 0.00, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, configWrapper, itemType, itemGroup, false); + return equals(productId, null, 0.00, 0.00, null, null, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, configWrapper, itemType, itemGroup, false);
    }
-
/** Compares the specified object with this cart item including rental data. Defaults isPromo to false. */ public boolean equals(String productId, Timestamp reservStart, double reservLength, double reservPersons, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, double selectedAmount) { - return equals(productId, reservStart, reservLength, reservPersons, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, configWrapper, itemType, itemGroup, false); + return equals(productId, reservStart, reservLength, reservPersons, null, null, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, configWrapper, itemType, itemGroup, false);
    }
-
+
/** Compares the specified object with this cart item. Defaults isPromo to false. */ public boolean equals(String productId, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, double selectedAmount, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, boolean isPromo) { - return equals(productId, null, 0.00, 0.00, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, null, itemType, itemGroup, isPromo); + return equals(productId, null, 0.00, 0.00, null, null, additionalProductFeatureAndAppls, attributes, prodCatalogId, selectedAmount, null, itemType, itemGroup, isPromo);
    }

    /** Compares the specified object with this cart item. */
- public boolean equals(String productId, Timestamp reservStart, double reservLength, double reservPersons, + public boolean equals(String productId, Timestamp reservStart, double reservLength, double reservPersons, String accommodationMapId, String accommodationSpotId, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, double selectedAmount, ProductConfigWrapper configWrapper, String itemType, ShoppingCart.ShoppingCartItemGroup itemGroup, boolean isPromo) {
        if (this.productId == null || productId == null) {
@@ -2199,6 +2258,13 @@
        }

        if (this.reservPersons != reservPersons) {
+            return false;
+        }
+
+ if (this.accommodationMapId != null && ! this.accommodationMapId.equals(accommodationMapId)) {
+            return false;
+        }
+ if (this.accommodationSpotId != null && ! this.accommodationSpotId.equals(accommodationSpotId)) {
            return false;
        }


Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/ShoppingCartServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ ShoppingCartServices.java Sun Feb 24 18:22:15 2008
@@ -324,6 +324,8 @@
                    Timestamp reservStart = null;
                    Double reservLength = null;
                    Double reservPersons = null;
+                    String accommodationMapId = null;
+                    String accommodationSpotId = null;

                    GenericValue workEffort = null;
String workEffortId = orh.getCurrentOrderItemWorkEffort(item);
@@ -338,6 +340,9 @@
reservStart = workEffort.getTimestamp("estimatedStartDate"); reservLength = OrderReadHelper.getWorkEffortRentalLenght(workEffort); reservPersons = workEffort.getDouble("reservPersons"); + accommodationMapId = workEffort.getString("accommodationMapId"); + accommodationSpotId = workEffort.getString("accommodationSpotId");
+
                    }    //end of rental data

                    //check for AGGREGATED products
@@ -361,7 +366,9 @@
configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, productId, productStoreId, prodCatalogId, website, currency, locale, userLogin);
                    }
                    try {
- itemIndex = cart.addItemToEnd(productId, amount, quantityDbl, null, reservStart, reservLength, reservPersons, null, null, prodCatalogId, configWrapper, item.getString("orderItemTypeId"), dispatcher, null, null, skipInventoryChecks, skipProductChecks);
+
+ itemIndex = cart.addItemToEnd(productId, amount, quantityDbl, null, reservStart, reservLength, reservPersons,accommodationMapId,accommodationSpotId, null, null, prodCatalogId, configWrapper, item.getString("orderItemTypeId"), dispatcher, null, null, skipInventoryChecks, skipProductChecks);
+
                    } catch (ItemNotFoundException e) {
                        Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -613,6 +620,8 @@
Timestamp reservStart = item.getTimestamp("reservStart");
                Double reservLength = item.getDouble("reservLength");
Double reservPersons = item.getDouble("reservPersons"); + String accommodationMapId = item.getString("accommodationMapId"); + String accommodationSpotId = item.getString("accommodationSpotId");

                int itemIndex = -1;
                if (item.get("productId") == null) {
@@ -633,7 +642,8 @@
configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, item.getString("configId"), productId, productStoreId, null, null, currency, locale, userLogin);
                    }
                    try {
- itemIndex = cart.addItemToEnd(productId, amount, quantity.doubleValue(), quoteUnitPrice, reservStart, reservLength, reservPersons, null, null, null, configWrapper, null, dispatcher, new Boolean(!applyQuoteAdjustments), new Boolean(quoteUnitPrice.doubleValue() == 0), Boolean.FALSE, Boolean.FALSE); + itemIndex = cart.addItemToEnd(productId, amount, quantity.doubleValue(), quoteUnitPrice, reservStart, reservLength, reservPersons,accommodationMapId,accommodationSpotId, null, null, null, configWrapper, null, dispatcher, new Boolean(! applyQuoteAdjustments), new Boolean(quoteUnitPrice.doubleValue() == 0), Boolean.FALSE, Boolean.FALSE);
+
                    } catch (ItemNotFoundException e) {
                        Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppinglist/ShoppingListEvents.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ ShoppingListEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ ShoppingListEvents.java Sun Feb 24 18:22:15 2008
@@ -147,6 +147,8 @@
                        ctx.put("reservStart", item.getReservStart());
ctx.put("reservLength", new Double(item.getReservLength())); ctx.put("reservPersons", new Double(item.getReservPersons())); + ctx.put("accommodationMapId", new Double(item.getAccommodationMapId())); + ctx.put("accommodationSpotId", new Double(item.getAccommodationSpotId()));
                        if (item.getConfigWrapper() != null) {
ctx.put("configId", item.getConfigWrapper().getConfigId());
                        }
@@ -258,6 +260,8 @@
Timestamp reservStart = shoppingListItem.getTimestamp("reservStart"); Double reservLength = shoppingListItem.getDouble("reservLength"); Double reservPersons = shoppingListItem.getDouble("reservPersons"); + String accommodationMapId = shoppingListItem.getString("accommodationMapId"); + String accommodationSpotId = shoppingListItem.getString("accommodationSpotId");
            String configId = shoppingListItem.getString("configId");
            try {
String listId = shoppingListItem.getString("shoppingListId");
@@ -283,9 +287,9 @@

// i cannot get the addOrDecrease function to accept a null reservStart field: i get a null pointer exception a null constant works....
                if (reservStart == null) {
- cart.addOrIncreaseItem(productId, null, quantity.doubleValue(), null, null, null, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher);
-                } else {
- cart.addOrIncreaseItem(productId, null, quantity.doubleValue(), reservStart, reservLength, reservPersons, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher); + cart.addOrIncreaseItem(productId, null, quantity.doubleValue(), null, null, null, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher);
+                }else{
+ cart.addOrIncreaseItem(productId, null, quantity.doubleValue(), reservStart, reservLength, reservPersons,accommodationMapId,accommodationSpotId, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher);
                }
Map messageMap = UtilMisc.toMap("productId", productId); errMsg = UtilProperties .getMessage(resource,"shoppinglistevents.added_product_to_cart", messageMap, cart.getLocale());

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppinglist/ShoppingListServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ ShoppingListServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ ShoppingListServices.java Sun Feb 24 18:22:15 2008
@@ -475,6 +475,9 @@
Timestamp reservStart = shoppingListItem.getTimestamp("reservStart");
                    Double reservLength = null;
String configId = shoppingListItem.getString("configId"); + String accommodationMapId = shoppingListItem.getString("accommodationMapId"); + String accommodationSpotId = shoppingListItem.getString("accommodationSpotId");
+
if (shoppingListItem.get("reservLength") != null) { reservLength = shoppingListItem.getDouble("reservLength");
                    }
@@ -482,6 +485,12 @@
if (shoppingListItem.get("reservPersons") != null) { reservPersons = shoppingListItem.getDouble("reservPersons");
                    }
+ if (shoppingListItem.get("accommodationMapId") ! = null) { + accommodationMapId = shoppingListItem.getString("accommodationMapId");
+                    }
+ if (shoppingListItem.get("accommodationSpotId") != null) { + accommodationSpotId = shoppingListItem.getString("accommodationSpotId");
+                    }
if (UtilValidate.isNotEmpty(productId) && quantity != null) {

                    if (UtilValidate.isNotEmpty(configId)) {
@@ -493,7 +502,7 @@
Map attributes = UtilMisc.toMap("shoppingListId", listId, "shoppingListItemSeqId", itemId);

                        try {
- listCart.addOrIncreaseItem(productId, null, quantity.doubleValue(), reservStart, reservLength, reservPersons, null, null, null, attributes, null, configWrapper, null, null, null, dispatcher); + listCart.addOrIncreaseItem(productId, null, quantity.doubleValue(), reservStart, reservLength, reservPersons,accommodationMapId,accommodationSpotId, null, null, null, attributes, null, configWrapper, null, null, null, dispatcher);
                        } catch (CartItemModifyException e) {
Debug.logError(e, "Unable to add product to List Cart - " + productId, module);
                        } catch (ItemNotFoundException e) {

Modified: ofbiz/trunk/applications/workeffort/entitydef/ entitymodel.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/entitydef/entitymodel.xml?rev=630718&r1=630717&r2=630718&view=diff
= = = = = = = = ====================================================================== --- ofbiz/trunk/applications/workeffort/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/applications/workeffort/entitydef/entitymodel.xml Sun Feb 24 18:22:15 2008
@@ -278,6 +278,8 @@
<field name="reservPersons" type="floating- point"><description>the number of persons renting the attached asset</description></field> <field name="reserv2ndPPPerc" type="floating- point"><description>reservationSecondPersonPricePercentage: percentage of the end price for the 2nd person renting this asset connected to the workEffort</description></field> <field name="reservNthPPPerc" type="floating- point"><description>reservationNthPersonPricePercentage: percentage of the end price for the Nth (2+) person renting this asset connected to the workEffort</description></field>
+      <field name="accommodationMapId" type="id"/>
+      <field name="accommodationSpotId" type="id"/>
      <field name="revisionNumber" type="numeric"></field>
      <field name="createdDate" type="date-time"></field>
      <field name="createdByUserLogin" type="id-vlong"></field>
@@ -340,6 +342,12 @@
<relation type="one" fk-name="WK_EFFRT_CUS_MET" rel-entity- name="CustomMethod"> <key-map field-name="estimateCalcMethod" rel-field- name="customMethodId"/>
      </relation>
+ <relation type="one" fk-name="WK_EFFRT_ACC_MAP" rel-entity- name="AccommodationMap">
+        <key-map field-name="accommodationMapId"/>
+      </relation>
+ <relation type="one" fk-name="WK_EFFRT_ACC_SPOT" rel-entity- name="AccommodationSpot">
+        <key-map field-name="accommodationSpotId"/>
+      </relation>
    </entity>
    <entity entity-name="WorkEffortAssoc"
            package-name="org.ofbiz.workeffort.workeffort"



Reply via email to