Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java Mon Nov 10 18:18:07 2008 @@ -166,7 +166,7 @@ if (anyServiceType) { if (storePayment == null) { try { - List storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId)); + List<GenericValue> storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId)); storePayment = EntityUtil.getFirst(storePayments); } catch (GenericEntityException e) { Debug.logError(e, "Problems looking up store payment settings", module); @@ -175,7 +175,7 @@ if (storePayment == null) { try { - List storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId)); + List<GenericValue> storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId)); storePayment = EntityUtil.getFirst(storePayments); } catch (GenericEntityException e) { Debug.logError(e, "Problems looking up store payment settings", module); @@ -186,13 +186,13 @@ return storePayment; } - public static List getProductStoreShipmentMethods(GenericDelegator delegator, String productStoreId, + public static List<GenericValue> getProductStoreShipmentMethods(GenericDelegator delegator, String productStoreId, String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId) { // check for an external service call - Map storeFields = UtilMisc.toMap("productStoreId", productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId, + Map<String, String> storeFields = UtilMisc.toMap("productStoreId", productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId, "partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId); - List storeShipMethods = null; + List<GenericValue> storeShipMethods = null; try { storeShipMethods = delegator.findByAndCache("ProductStoreShipmentMeth", storeFields); } catch (GenericEntityException e) { @@ -209,11 +209,11 @@ return EntityUtil.getFirst(getProductStoreShipmentMethods(delegator, productStoreId, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId)); } - public static List getAvailableStoreShippingMethods(GenericDelegator delegator, String productStoreId, GenericValue shippingAddress, List itemSizes, Map featureIdMap, double weight, double orderTotal) { + public static List<GenericValue> getAvailableStoreShippingMethods(GenericDelegator delegator, String productStoreId, GenericValue shippingAddress, List<Double> itemSizes, Map<String, Double> featureIdMap, double weight, double orderTotal) { if (featureIdMap == null) { featureIdMap = FastMap.newInstance(); } - List shippingMethods = null; + List<GenericValue> shippingMethods = null; try { shippingMethods = delegator.findByAndCache("ProductStoreShipmentMethView", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNumber")); } catch (GenericEntityException e) { @@ -222,12 +222,12 @@ } // clone the list for concurrent modification - List returnShippingMethods = UtilMisc.makeListWritable(shippingMethods); + List<GenericValue> returnShippingMethods = UtilMisc.makeListWritable(shippingMethods); if (shippingMethods != null) { - Iterator i = shippingMethods.iterator(); + Iterator<GenericValue> i = shippingMethods.iterator(); while (i.hasNext()) { - GenericValue method = (GenericValue) i.next(); + GenericValue method = i.next(); //Debug.logInfo("Checking Shipping Method : " + method.getString("shipmentMethodTypeId"), module); // test min/max weight first @@ -265,9 +265,9 @@ boolean allMatch = false; if (itemSizes != null) { allMatch = true; - Iterator isi = itemSizes.iterator(); + Iterator<Double> isi = itemSizes.iterator(); while (isi.hasNext()) { - Double size = (Double) isi.next(); + Double size = isi.next(); if (size.doubleValue() < minSize.doubleValue()) { allMatch = false; } @@ -283,9 +283,9 @@ boolean allMatch = false; if (itemSizes != null) { allMatch = true; - Iterator isi = itemSizes.iterator(); + Iterator<Double> isi = itemSizes.iterator(); while (isi.hasNext()) { - Double size = (Double) isi.next(); + Double size = isi.next(); if (size.doubleValue() > maxSize.doubleValue()) { allMatch = false; } @@ -350,7 +350,7 @@ } } if (includeGeoId != null && includeGeoId.length() > 0) { - List includeGeoGroup = GeoWorker.expandGeoGroup(includeGeoId, delegator); + List<GenericValue> includeGeoGroup = GeoWorker.expandGeoGroup(includeGeoId, delegator); if (!GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("countryGeoId"), delegator) && !GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("stateProvinceGeoId"), delegator) && !GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("postalCodeGeoId"), delegator)) { @@ -361,7 +361,7 @@ } } if (excludeGeoId != null && excludeGeoId.length() > 0) { - List excludeGeoGroup = GeoWorker.expandGeoGroup(excludeGeoId, delegator); + List<GenericValue> excludeGeoGroup = GeoWorker.expandGeoGroup(excludeGeoId, delegator); if (GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("countryGeoId"), delegator) || GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("stateProvinceGeoId"), delegator) || GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("postalCodeGeoId"), delegator)) { @@ -376,7 +376,7 @@ String includeFeatures = method.getString("includeFeatureGroup"); String excludeFeatures = method.getString("excludeFeatureGroup"); if (includeFeatures != null && includeFeatures.length() > 0) { - List includedFeatures = null; + List<GenericValue> includedFeatures = null; try { includedFeatures = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", includeFeatures)); } catch (GenericEntityException e) { @@ -384,9 +384,9 @@ } if (includedFeatures != null) { boolean foundOne = false; - Iterator ifet = includedFeatures.iterator(); + Iterator<GenericValue> ifet = includedFeatures.iterator(); while (ifet.hasNext()) { - GenericValue appl = (GenericValue) ifet.next(); + GenericValue appl = ifet.next(); if (featureIdMap.containsKey(appl.getString("productFeatureId"))) { foundOne = true; break; @@ -400,16 +400,16 @@ } } if (excludeFeatures != null && excludeFeatures.length() > 0) { - List excludedFeatures = null; + List<GenericValue> excludedFeatures = null; try { excludedFeatures = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", excludeFeatures)); } catch (GenericEntityException e) { Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + excludeFeatures, module); } if (excludedFeatures != null) { - Iterator ifet = excludedFeatures.iterator(); + Iterator<GenericValue> ifet = excludedFeatures.iterator(); while (ifet.hasNext()) { - GenericValue appl = (GenericValue) ifet.next(); + GenericValue appl = ifet.next(); if (featureIdMap.containsKey(appl.getString("productFeatureId"))) { returnShippingMethods.remove(method); //Debug.logInfo("Removed shipping method due to an exluded feature being found : " + appl.getString("productFeatureId"), module); @@ -437,34 +437,34 @@ } String partyId = userLogin != null ? userLogin.getString("partyId") : null; - Map passThruFields = UtilHttp.getParameterMap(((HttpServletRequest)request)); + Map<String, Object> passThruFields = UtilHttp.getParameterMap(((HttpServletRequest)request)); return getRandomSurveyWrapper(productStore.getDelegator(), productStore.getString("productStoreId"), groupName, partyId, passThruFields); } - public static ProductStoreSurveyWrapper getRandomSurveyWrapper(GenericDelegator delegator, String productStoreId, String groupName, String partyId, Map passThruFields) { - List randomSurveys = getSurveys(delegator, productStoreId, groupName, null, "RANDOM_POLL", null); + public static ProductStoreSurveyWrapper getRandomSurveyWrapper(GenericDelegator delegator, String productStoreId, String groupName, String partyId, Map<String, Object> passThruFields) { + List<GenericValue> randomSurveys = getSurveys(delegator, productStoreId, groupName, null, "RANDOM_POLL", null); if (!UtilValidate.isEmpty(randomSurveys)) { Random rand = new Random(); int index = rand.nextInt(randomSurveys.size()); - GenericValue appl = (GenericValue) randomSurveys.get(index); + GenericValue appl = randomSurveys.get(index); return new ProductStoreSurveyWrapper(appl, partyId, passThruFields); } else { return null; } } - public static List getProductSurveys(GenericDelegator delegator, String productStoreId, String productId, String surveyApplTypeId) { + public static List<GenericValue> getProductSurveys(GenericDelegator delegator, String productStoreId, String productId, String surveyApplTypeId) { return getSurveys(delegator, productStoreId, null, productId, surveyApplTypeId, null); } - public static List getProductSurveys(GenericDelegator delegator, String productStoreId, String productId, String surveyApplTypeId, String parentProductId) { + public static List<GenericValue> getProductSurveys(GenericDelegator delegator, String productStoreId, String productId, String surveyApplTypeId, String parentProductId) { return getSurveys(delegator, productStoreId, null, productId, surveyApplTypeId,parentProductId); } - public static List getSurveys(GenericDelegator delegator, String productStoreId, String groupName, String productId, String surveyApplTypeId, String parentProductId) { - List surveys = FastList.newInstance(); - List storeSurveys = null; + public static List<GenericValue> getSurveys(GenericDelegator delegator, String productStoreId, String groupName, String productId, String surveyApplTypeId, String parentProductId) { + List<GenericValue> surveys = FastList.newInstance(); + List<GenericValue> storeSurveys = null; try { storeSurveys = delegator.findByAndCache("ProductStoreSurveyAppl", UtilMisc.toMap("productStoreId", productStoreId, "surveyApplTypeId", surveyApplTypeId), UtilMisc.toList("sequenceNum")); } catch (GenericEntityException e) { @@ -483,9 +483,9 @@ Debug.log("getSurvey for product " + productId,module); // limit by product if (!UtilValidate.isEmpty(productId) && !UtilValidate.isEmpty(storeSurveys)) { - Iterator ssi = storeSurveys.iterator(); + Iterator<GenericValue> ssi = storeSurveys.iterator(); while (ssi.hasNext()) { - GenericValue surveyAppl = (GenericValue) ssi.next(); + GenericValue surveyAppl = ssi.next(); GenericValue product = null; String virtualProductId = null; @@ -513,16 +513,16 @@ surveys.add(surveyAppl); } } else if (surveyAppl.get("productCategoryId") != null) { - List categoryMembers = null; + List<GenericValue> categoryMembers = null; try { categoryMembers = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", surveyAppl.get("productCategoryId"))); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductCategoryMemebr records for survey application : " + surveyAppl, module); } if (categoryMembers != null) { - Iterator cmi = categoryMembers.iterator(); + Iterator<GenericValue> cmi = categoryMembers.iterator(); while (cmi.hasNext()) { - GenericValue member = (GenericValue) cmi.next(); + GenericValue member = cmi.next(); if (productId != null && productId.equals(member.getString("productId"))) { surveys.add(surveyAppl); break; @@ -559,7 +559,7 @@ return -1; } - List surveyResponse = null; + List<GenericValue> surveyResponse = null; try { surveyResponse = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("surveyId", surveyId, "partyId", partyId)); } catch (GenericEntityException e) { @@ -611,7 +611,7 @@ try { Boolean requiredOkay = null; if (wantRequired != null) { - Map invReqResult = dispatcher.runSync("isStoreInventoryRequired", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "productStore", productStore)); + Map<String, Object> invReqResult = dispatcher.runSync("isStoreInventoryRequired", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "productStore", productStore)); if (ServiceUtil.isError(invReqResult)) { Debug.logError("Error calling isStoreInventoryRequired service, result is: " + invReqResult, module); return false; @@ -621,7 +621,7 @@ Boolean availableOkay = null; if (wantAvailable != null) { - Map invAvailResult = dispatcher.runSync("isStoreInventoryAvailable", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "productStore", productStore, "quantity", quantity)); + Map<String, Object> invAvailResult = dispatcher.runSync("isStoreInventoryAvailable", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "productStore", productStore, "quantity", quantity)); if (ServiceUtil.isError(invAvailResult)) { Debug.logError("Error calling isStoreInventoryAvailable service, result is: " + invAvailResult, module); return false; @@ -690,7 +690,7 @@ } else { GenericValue product = productConfig.getProduct(); - List productFacilities = null; + List<GenericValue> productFacilities = null; try { productFacilities = delegator.getRelatedCache("ProductFacility", product); @@ -700,11 +700,11 @@ } if (UtilValidate.isNotEmpty(productFacilities)) { - Iterator pfIter = productFacilities.iterator(); + Iterator<GenericValue> pfIter = productFacilities.iterator(); while (pfIter.hasNext()) { try { - GenericValue pfValue = (GenericValue) pfIter.next(); + GenericValue pfValue = pfIter.next(); isInventoryAvailable = ProductWorker.isProductInventoryAvailableByFacility(productConfig, pfValue.getString("facilityId"), quantity, dispatcher); if (isInventoryAvailable == true) { @@ -720,7 +720,7 @@ } } - protected static Map defaultProductStoreEmailScreenLocation = FastMap.newInstance(); + protected static Map<String, String> defaultProductStoreEmailScreenLocation = FastMap.newInstance(); static { defaultProductStoreEmailScreenLocation.put("PRDS_ODR_CONFIRM", "component://ecommerce/widget/EmailOrderScreens.xml#OrderConfirmNotice"); @@ -747,6 +747,6 @@ } public static String getDefaultProductStoreEmailScreenLocation(String emailType) { - return (String) defaultProductStoreEmailScreenLocation.get(emailType); + return defaultProductStoreEmailScreenLocation.get(emailType); } } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java Mon Nov 10 18:18:07 2008 @@ -48,7 +48,7 @@ public static final String module = SubscriptionServices.class.getName(); - public static Map processExtendSubscription(DispatchContext dctx, Map context) throws GenericServiceException{ + public static Map<String, Object> processExtendSubscription(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{ GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); @@ -65,14 +65,14 @@ GenericValue lastSubscription = null; try { - Map subscriptionFindMap = UtilMisc.toMap("partyId", partyId, "subscriptionResourceId", subscriptionResourceId); + Map<String, String> subscriptionFindMap = UtilMisc.toMap("partyId", partyId, "subscriptionResourceId", subscriptionResourceId); // if this subscription is attached to something the customer owns, filter by that too if (UtilValidate.isNotEmpty(inventoryItemId)) subscriptionFindMap.put("inventoryItemId", inventoryItemId); - List subscriptionList = delegator.findByAnd("Subscription", subscriptionFindMap); + List<GenericValue> subscriptionList = delegator.findByAnd("Subscription", subscriptionFindMap); // DEJ20070718 DON'T filter by date, we want to consider all subscriptions: List listFiltered = EntityUtil.filterByDate(subscriptionList, true); - List listOrdered = EntityUtil.orderBy(subscriptionList, UtilMisc.toList("-fromDate")); + List<GenericValue> listOrdered = EntityUtil.orderBy(subscriptionList, UtilMisc.toList("-fromDate")); if (listOrdered.size() > 0) { - lastSubscription = (GenericValue) listOrdered.get(0); + lastSubscription = listOrdered.get(0); } } catch (GenericEntityException e) { return ServiceUtil.returnError(e.toString()); @@ -125,32 +125,32 @@ thruDate = new Timestamp(calendar.getTimeInMillis()); newSubscription.set("thruDate", thruDate); - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); try { if (lastSubscription != null && !alwaysCreateNewRecord) { - Map updateSubscriptionMap = dctx.getModelService("updateSubscription").makeValid(newSubscription, ModelService.IN_PARAM); + Map<String, Object> updateSubscriptionMap = dctx.getModelService("updateSubscription").makeValid(newSubscription, ModelService.IN_PARAM); updateSubscriptionMap.put("userLogin", delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"))); - Map updateSubscriptionResult = dispatcher.runSync("updateSubscription", updateSubscriptionMap); + Map<String, Object> updateSubscriptionResult = dispatcher.runSync("updateSubscription", updateSubscriptionMap); result.put("subscriptionId", updateSubscriptionMap.get("subscriptionId")); if (ServiceUtil.isError(updateSubscriptionResult)) { return ServiceUtil.returnError("Error processing subscription update with ID [" + updateSubscriptionMap.get("subscriptionId") + "]", null, null, updateSubscriptionResult); } } else { - Map createPartyRoleMap = FastMap.newInstance(); + Map<String, Object> createPartyRoleMap = FastMap.newInstance(); if (UtilValidate.isNotEmpty(roleTypeId)) { createPartyRoleMap.put("partyId", partyId); createPartyRoleMap.put("roleTypeId", roleTypeId); createPartyRoleMap.put("userLogin", userLogin); - Map createPartyRoleResult = dispatcher.runSync("createPartyRole", createPartyRoleMap); + Map<String, Object> createPartyRoleResult = dispatcher.runSync("createPartyRole", createPartyRoleMap); if (ServiceUtil.isError(createPartyRoleResult)) { return ServiceUtil.returnError("Error creating new PartyRole while processing subscription update with resource ID [" + subscriptionResourceId + "]", null, null, createPartyRoleResult); } } - Map createSubscriptionMap = dctx.getModelService("createSubscription").makeValid(newSubscription, ModelService.IN_PARAM); + Map<String, Object> createSubscriptionMap = dctx.getModelService("createSubscription").makeValid(newSubscription, ModelService.IN_PARAM); createSubscriptionMap.put("userLogin", delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"))); - Map createSubscriptionResult = dispatcher.runSync("createSubscription", createSubscriptionMap); + Map<String, Object> createSubscriptionResult = dispatcher.runSync("createSubscription", createSubscriptionMap); if (ServiceUtil.isError(createSubscriptionResult)) { return ServiceUtil.returnError("Error creating subscription while processing with resource ID [" + subscriptionResourceId + "]", null, null, createSubscriptionResult); } @@ -164,7 +164,7 @@ return result; } - public static Map processExtendSubscriptionByProduct(DispatchContext dctx, Map context) throws GenericServiceException{ + public static Map<String, Object> processExtendSubscriptionByProduct(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{ GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); String productId = (String) context.get("productId"); @@ -178,7 +178,7 @@ orderCreatedDate = UtilDateTime.nowTimestamp(); } try { - List productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId)); + List<GenericValue> productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId)); productSubscriptionResourceList = EntityUtil.filterByDate(productSubscriptionResourceList, orderCreatedDate, null, null, true); productSubscriptionResourceList = EntityUtil.filterByDate(productSubscriptionResourceList, orderCreatedDate, "purchaseFromDate", "purchaseThruDate", true); @@ -188,25 +188,25 @@ return ServiceUtil.returnError(msg); } - Iterator productSubscriptionResourceIter = productSubscriptionResourceList.iterator(); + Iterator<GenericValue> productSubscriptionResourceIter = productSubscriptionResourceList.iterator(); while (productSubscriptionResourceIter.hasNext()) { - GenericValue productSubscriptionResource = (GenericValue) productSubscriptionResourceIter.next(); - - Long useTime = (Long) productSubscriptionResource.get("useTime"); + GenericValue productSubscriptionResource = productSubscriptionResourceIter.next(); + Long useTime = productSubscriptionResource.getLong("useTime"); Integer newUseTime = Integer.valueOf(0); if (useTime != null) { newUseTime = Integer.valueOf(useTime.intValue() * qty.intValue()); } - context.put("useTime", newUseTime); - context.put("useTimeUomId", productSubscriptionResource.get("useTimeUomId")); - context.put("useRoleTypeId", productSubscriptionResource.get("useRoleTypeId")); - context.put("subscriptionResourceId", productSubscriptionResource.get("subscriptionResourceId")); - context.put("automaticExtend", productSubscriptionResource.get("automaticExtend")); - context.put("canclAutmExtTime", productSubscriptionResource.get("canclAutmExtTime")); - context.put("canclAutmExtTimeUomId", productSubscriptionResource.get("canclAutmExtTimeUomId")); + Map<String, Object> subContext = UtilMisc.makeMapWritable(context); + subContext.put("useTime", newUseTime); + subContext.put("useTimeUomId", productSubscriptionResource.get("useTimeUomId")); + subContext.put("useRoleTypeId", productSubscriptionResource.get("useRoleTypeId")); + subContext.put("subscriptionResourceId", productSubscriptionResource.get("subscriptionResourceId")); + subContext.put("automaticExtend", productSubscriptionResource.get("automaticExtend")); + subContext.put("canclAutmExtTime", productSubscriptionResource.get("canclAutmExtTime")); + subContext.put("canclAutmExtTimeUomId", productSubscriptionResource.get("canclAutmExtTimeUomId")); - Map ctx = dctx.getModelService("processExtendSubscription").makeValid(context, ModelService.IN_PARAM); - Map processExtendSubscriptionResult = dispatcher.runSync("processExtendSubscription", ctx); + Map<String, Object> ctx = dctx.getModelService("processExtendSubscription").makeValid(subContext, ModelService.IN_PARAM); + Map<String, Object> processExtendSubscriptionResult = dispatcher.runSync("processExtendSubscription", ctx); if (ServiceUtil.isError(processExtendSubscriptionResult)) { return ServiceUtil.returnError("Error processing subscriptions for Product with ID [" + productId + "]", null, null, processExtendSubscriptionResult); } @@ -219,20 +219,21 @@ return ServiceUtil.returnSuccess(); } - public static Map processExtendSubscriptionByOrder(DispatchContext dctx, Map context) throws GenericServiceException{ + public static Map<String, Object> processExtendSubscriptionByOrder(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{ GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); + Map<String, Object> subContext = UtilMisc.makeMapWritable(context); String orderId = (String) context.get("orderId"); Debug.logInfo("In processExtendSubscriptionByOrder service with orderId: " + orderId, module); GenericValue orderHeader = null; try { - List orderRoleList = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER")); + List<GenericValue> orderRoleList = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER")); if (orderRoleList.size() > 0 ) { - GenericValue orderRole = (GenericValue)orderRoleList.get(0); + GenericValue orderRole = orderRoleList.get(0); String partyId = (String) orderRole.get("partyId"); - context.put("partyId", partyId); + subContext.put("partyId", partyId); } else { String msg = "No OrderRole found for orderId:" + orderId; return ServiceUtil.returnFailure(msg); @@ -243,27 +244,27 @@ return ServiceUtil.returnError(msg); } Timestamp orderCreatedDate = (Timestamp) orderHeader.get("orderDate"); - context.put("orderCreatedDate", orderCreatedDate); - List orderItemList = orderHeader.getRelated("OrderItem"); - Iterator orderItemIter = orderItemList.iterator(); + subContext.put("orderCreatedDate", orderCreatedDate); + List<GenericValue> orderItemList = orderHeader.getRelated("OrderItem"); + Iterator<GenericValue> orderItemIter = orderItemList.iterator(); while (orderItemIter.hasNext()) { - GenericValue orderItem = (GenericValue)orderItemIter.next(); - Double qty = (Double) orderItem.get("quantity"); - String productId = (String) orderItem.get("productId"); + GenericValue orderItem = orderItemIter.next(); + Double qty = orderItem.getDouble("quantity"); + String productId = orderItem.getString("productId"); if (UtilValidate.isEmpty(productId)) { continue; } - List productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId)); - List productSubscriptionResourceListFiltered = EntityUtil.filterByDate(productSubscriptionResourceList, true); + List<GenericValue> productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId)); + List<GenericValue> productSubscriptionResourceListFiltered = EntityUtil.filterByDate(productSubscriptionResourceList, true); if (productSubscriptionResourceListFiltered.size() > 0) { - context.put("subscriptionTypeId", "PRODUCT_SUBSCR"); - context.put("productId", productId); - context.put("orderId", orderId); - context.put("orderItemSeqId", orderItem.get("orderItemSeqId")); - context.put("inventoryItemId", orderItem.get("fromInventoryItemId")); - context.put("quantity", Integer.valueOf(qty.intValue())); - Map ctx = dctx.getModelService("processExtendSubscriptionByProduct").makeValid(context, ModelService.IN_PARAM); - Map thisResult = dispatcher.runSync("processExtendSubscriptionByProduct", ctx); + subContext.put("subscriptionTypeId", "PRODUCT_SUBSCR"); + subContext.put("productId", productId); + subContext.put("orderId", orderId); + subContext.put("orderItemSeqId", orderItem.get("orderItemSeqId")); + subContext.put("inventoryItemId", orderItem.get("fromInventoryItemId")); + subContext.put("quantity", Integer.valueOf(qty.intValue())); + Map<String, Object> ctx = dctx.getModelService("processExtendSubscriptionByProduct").makeValid(subContext, ModelService.IN_PARAM); + Map<String, Object> thisResult = dispatcher.runSync("processExtendSubscriptionByProduct", ctx); if (ServiceUtil.isError(thisResult)) { return ServiceUtil.returnError("Error processing subscriptions for Order with ID [" + orderId + "]", null, null, thisResult); } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java Mon Nov 10 18:18:07 2008 @@ -29,6 +29,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; @@ -54,8 +55,8 @@ * Result: a List of SupplierProduct entities for productId, * filtered by date and optionally by partyId, ordered with lowest price first */ - public static Map getSuppliersForProduct(DispatchContext dctx, Map context) { - Map results = FastMap.newInstance(); + public static Map<String, Object> getSuppliersForProduct(DispatchContext dctx, Map<String, ? extends Object> context) { + Map<String, Object> results = FastMap.newInstance(); GenericDelegator delegator = dctx.getDelegator(); GenericValue product = null; @@ -71,7 +72,7 @@ results.put("supplierProducts",null); return results; } - List supplierProducts = product.getRelatedCache("SupplierProduct"); + List<GenericValue> supplierProducts = product.getRelatedCache("SupplierProduct"); // if there were no related SupplierProduct entities and the item is a variant, then get the SupplierProducts of the virtual parent product if (supplierProducts.size() == 0 && product.getString("isVariant") != null && product.getString("isVariant").equals("Y")) { @@ -126,23 +127,23 @@ * Service will convert each feature in the Collection, changing their idCode and description based on the * SupplierProduct entity for that supplier party and feature, and return it as convertedProductFeatures */ - public static Map convertFeaturesForSupplier(DispatchContext dctx, Map context) { - Map results = FastMap.newInstance(); + public static Map<String, Object> convertFeaturesForSupplier(DispatchContext dctx, Map<String, ? extends Object> context) { + Map<String, Object> results = FastMap.newInstance(); String partyId = (String) context.get("partyId"); - Collection features = (Collection) context.get("productFeatures"); + Collection<GenericValue> features = UtilGenerics.checkList(context.get("productFeatures")); try { if (partyId != null && UtilValidate.isNotEmpty(features)) { // loop through all the features, find the related SupplierProductFeature for the given partyId, and // substitue description and idCode - for (Iterator fI = features.iterator(); fI.hasNext(); ) { - GenericValue nextFeature = (GenericValue) fI.next(); - List supplierFeatures = EntityUtil.filterByAnd(nextFeature.getRelated("SupplierProductFeature"), + for (Iterator<GenericValue> fI = features.iterator(); fI.hasNext(); ) { + GenericValue nextFeature = fI.next(); + List<GenericValue> supplierFeatures = EntityUtil.filterByAnd(nextFeature.getRelated("SupplierProductFeature"), UtilMisc.toMap("partyId", partyId)); GenericValue supplierFeature = null; if ((supplierFeatures != null) && (supplierFeatures.size() > 0)) { - supplierFeature = (GenericValue) supplierFeatures.get(0); + supplierFeature = supplierFeatures.get(0); if (supplierFeature.get("description") != null) { nextFeature.put("description", supplierFeature.get("description")); } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java Mon Nov 10 18:18:07 2008 @@ -53,7 +53,7 @@ } public void testCreateInventoryItemsTransfer() throws Exception { - Map ctx = FastMap.newInstance(); + Map<String, Object> ctx = FastMap.newInstance(); String statusId = "IXF_REQUESTED"; String inventoryItemId = "9005"; ctx.put("inventoryItemId", inventoryItemId); @@ -61,22 +61,22 @@ ctx.put("facilityId", "WebStoreWarehouse"); ctx.put("facilityIdTo", "WebStoreWarehouse"); ctx.put("receiveDate", UtilDateTime.nowTimestamp()); - ctx.put("xferQty", new Double (transferQty)); + ctx.put("xferQty", Double.valueOf(transferQty)); ctx.put("userLogin", userLogin); - Map resp = dispatcher.runSync("createInventoryTransfer", ctx); + Map<String, Object> resp = dispatcher.runSync("createInventoryTransfer", ctx); inventoryTransferId = (String) resp.get("inventoryTransferId"); assertNotNull(inventoryTransferId); } public void testUpdateInventoryItemTransfer() throws Exception { - Map ctx = FastMap.newInstance(); + Map<String, Object> ctx = FastMap.newInstance(); String statusId = "IXF_COMPLETE"; ctx.put("inventoryTransferId", inventoryTransferId); String inventoryItemId = delegator.findByPrimaryKey("InventoryTransfer", UtilMisc.toMap("inventoryTransferId", inventoryTransferId)).getString("inventoryItemId"); ctx.put("inventoryItemId", inventoryItemId); ctx.put("statusId", statusId); ctx.put("userLogin", userLogin); - Map resp = dispatcher.runSync("updateInventoryTransfer", ctx); + Map<String, Object> resp = dispatcher.runSync("updateInventoryTransfer", ctx); String respMsg = (String) resp.get("responseMessage"); assertNotSame("error", respMsg); } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/test/StockMovesTest.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/test/StockMovesTest.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/test/StockMovesTest.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/test/StockMovesTest.java Mon Nov 10 18:18:07 2008 @@ -55,13 +55,13 @@ } public void testStockMoves() throws Exception { - Map fsmnCtx = FastMap.newInstance(); + Map<String, Object> fsmnCtx = FastMap.newInstance(); Map stockMoveHandled = null; List warningList = FastList.newInstance(); fsmnCtx.put("facilityId", "WebStoreWarehouse"); fsmnCtx.put("userLogin", userLogin); - Map respMap1 = dispatcher.runSync("findStockMovesNeeded", fsmnCtx); + Map<String, Object> respMap1 = dispatcher.runSync("findStockMovesNeeded", fsmnCtx); stockMoveHandled = (Map) respMap1.get("stockMoveHandled"); warningList = (List) respMap1.get("warningMessageList"); assertNull(warningList); @@ -69,17 +69,17 @@ if (stockMoveHandled != null) { fsmnCtx.put("stockMoveHandled", stockMoveHandled); } - Map respMap2 = dispatcher.runSync("findStockMovesRecommended", fsmnCtx); + Map<String, Object> respMap2 = dispatcher.runSync("findStockMovesRecommended", fsmnCtx); warningList = (List) respMap2.get("warningMessageList"); assertNull(warningList); - Map ppsmCtx = FastMap.newInstance(); + Map<String, Object> ppsmCtx = FastMap.newInstance(); ppsmCtx.put("productId", "GZ-2644"); ppsmCtx.put("facilityId", "WebStoreWarehouse"); ppsmCtx.put("locationSeqId","TLTLTLUL01" ); ppsmCtx.put("targetLocationSeqId", "TLTLTLLL01"); ppsmCtx.put("quantityMoved", Double.valueOf(5)); ppsmCtx.put("userLogin", userLogin); - Map respMap3 = dispatcher.runSync("processPhysicalStockMove", ppsmCtx); + Map<String, Object> respMap3 = dispatcher.runSync("processPhysicalStockMove", ppsmCtx); } } |
Free forum by Nabble | Edit this page |