Author: jonesde
Date: Thu Nov 9 01:21:54 2006 New Revision: 472825 URL: http://svn.apache.org/viewvc?view=rev&rev=472825 Log: Added two enhancements for ProductPriceRules: new condition for ProductFeature/Appl, enhancement to group member condition to support a member of a group that is a member of a group in addition to being a direct member of a group Modified: incubator/ofbiz/trunk/applications/party/entitydef/entitygroup.xml incubator/ofbiz/trunk/applications/party/entitydef/entitymodel.xml incubator/ofbiz/trunk/applications/product/data/ProductTypeData.xml incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java Modified: incubator/ofbiz/trunk/applications/party/entitydef/entitygroup.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/entitydef/entitygroup.xml?view=diff&rev=472825&r1=472824&r2=472825 ============================================================================== --- incubator/ofbiz/trunk/applications/party/entitydef/entitygroup.xml (original) +++ incubator/ofbiz/trunk/applications/party/entitydef/entitygroup.xml Thu Nov 9 01:21:54 2006 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Copyright 2001-2006 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -115,6 +114,7 @@ <entity-group group="org.ofbiz" entity="PartyNoteView" /> <entity-group group="org.ofbiz" entity="PartyProfileDefault" /> <entity-group group="org.ofbiz" entity="PartyRelationship" /> + <entity-group group="org.ofbiz" entity="PartyRelationshipToFrom" /> <entity-group group="org.ofbiz" entity="PartyRelationshipType" /> <entity-group group="org.ofbiz" entity="PartyRole" /> <entity-group group="org.ofbiz" entity="PartyRoleAndPartyDetail" /> Modified: incubator/ofbiz/trunk/applications/party/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/entitydef/entitymodel.xml?view=diff&rev=472825&r1=472824&r2=472825 ============================================================================== --- incubator/ofbiz/trunk/applications/party/entitydef/entitymodel.xml (original) +++ incubator/ofbiz/trunk/applications/party/entitydef/entitymodel.xml Thu Nov 9 01:21:54 2006 @@ -1705,6 +1705,19 @@ <key-map field-name="securityGroupId" rel-field-name="groupId"/> </relation> </entity> + <view-entity entity-name="PartyRelationshipToFrom" package-name="org.ofbiz.party.party"> + <description> + Links two PartyRelationships together to be used to get a member of a group that is a member of a group, so links the to party of the first to the from party of the second. + To query the group ID would go on onePartyIdFrom and the member ID would go in twoPartyIdTo. + </description> + <member-entity entity-alias="PR1" entity-name="PartyRelationship"/> + <member-entity entity-alias="PR2" entity-name="PartyRelationship"/> + <alias-all entity-alias="PR1" prefix="one"/> + <alias-all entity-alias="PR2" prefix="two"/> + <view-link entity-alias="PR1" rel-entity-alias="PR2"> + <key-map field-name="partyIdTo" rel-field-name="partyIdFrom"/> + </view-link> + </view-entity> <entity entity-name="PartyRelationshipType" package-name="org.ofbiz.party.party" default-resource-name="PartyEntityLabels" Modified: incubator/ofbiz/trunk/applications/product/data/ProductTypeData.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/data/ProductTypeData.xml?view=diff&rev=472825&r1=472824&r2=472825 ============================================================================== --- incubator/ofbiz/trunk/applications/product/data/ProductTypeData.xml (original) +++ incubator/ofbiz/trunk/applications/product/data/ProductTypeData.xml Thu Nov 9 01:21:54 2006 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Copyright 2001-2006 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -37,15 +36,16 @@ <Enumeration description="Product" enumCode="PRODUCT_ID" enumId="PRIP_PRODUCT_ID" sequenceId="01" enumTypeId="PROD_PRICE_IN_PARAM"/> <Enumeration description="Product Category" enumCode="PRODUCT_CATEGORY_ID" enumId="PRIP_PROD_CAT_ID" sequenceId="02" enumTypeId="PROD_PRICE_IN_PARAM"/> <Enumeration description="Product Catalog" enumCode="PROD_CATALOG_ID" enumId="PRIP_PROD_CLG_ID" sequenceId="03" enumTypeId="PROD_PRICE_IN_PARAM"/> - <Enumeration description="Product Store Group" enumCode="PROD_STORE_GRP_ID" enumId="PRIP_PROD_SGRP_ID" sequenceId="04" enumTypeId="PROD_PRICE_IN_PARAM"/> - <Enumeration description="Website" enumCode="WEBSITE_ID" enumId="PRIP_WEBSITE_ID" sequenceId="05" enumTypeId="PROD_PRICE_IN_PARAM"/> - <Enumeration description="Quantity" enumCode="QUANTITY" enumId="PRIP_QUANTITY" sequenceId="06" enumTypeId="PROD_PRICE_IN_PARAM"/> - <Enumeration description="Party" enumCode="PARTY_ID" enumId="PRIP_PARTY_ID" sequenceId="07" enumTypeId="PROD_PRICE_IN_PARAM"/> - <Enumeration description="Party Group Member" enumCode="PARTY_GROUP_MEMBER" enumId="PRIP_PARTY_GRP_MEM" sequenceId="08" enumTypeId="PROD_PRICE_IN_PARAM"/> - <Enumeration description="Party Classification" enumCode="PARTY_CLASS" enumId="PRIP_PARTY_CLASS" sequenceId="09" enumTypeId="PROD_PRICE_IN_PARAM"/> - <Enumeration description="Role Type" enumCode="ROLE_TYPE" enumId="PRIP_ROLE_TYPE" sequenceId="10" enumTypeId="PROD_PRICE_IN_PARAM"/> - <Enumeration description="List Price" enumCode="LIST_PRICE" enumId="PRIP_LIST_PRICE" sequenceId="11" enumTypeId="PROD_PRICE_IN_PARAM"/> - <Enumeration description="Currency UomId" enumCode="CURRENCY_UOMID" enumId="PRIP_CURRENCY_UOMID" sequenceId="12" enumTypeId="PROD_PRICE_IN_PARAM"/> + <Enumeration description="Product Feature" enumCode="PRODUCT_FEATURE_ID" enumId="PRIP_PROD_FEAT_ID" sequenceId="04" enumTypeId="PROD_PRICE_IN_PARAM"/> + <Enumeration description="Product Store Group" enumCode="PROD_STORE_GRP_ID" enumId="PRIP_PROD_SGRP_ID" sequenceId="05" enumTypeId="PROD_PRICE_IN_PARAM"/> + <Enumeration description="Website" enumCode="WEBSITE_ID" enumId="PRIP_WEBSITE_ID" sequenceId="06" enumTypeId="PROD_PRICE_IN_PARAM"/> + <Enumeration description="Quantity" enumCode="QUANTITY" enumId="PRIP_QUANTITY" sequenceId="07" enumTypeId="PROD_PRICE_IN_PARAM"/> + <Enumeration description="Party" enumCode="PARTY_ID" enumId="PRIP_PARTY_ID" sequenceId="08" enumTypeId="PROD_PRICE_IN_PARAM"/> + <Enumeration description="Party Group Member" enumCode="PARTY_GROUP_MEMBER" enumId="PRIP_PARTY_GRP_MEM" sequenceId="09" enumTypeId="PROD_PRICE_IN_PARAM"/> + <Enumeration description="Party Classification" enumCode="PARTY_CLASS" enumId="PRIP_PARTY_CLASS" sequenceId="10" enumTypeId="PROD_PRICE_IN_PARAM"/> + <Enumeration description="Role Type" enumCode="ROLE_TYPE" enumId="PRIP_ROLE_TYPE" sequenceId="11" enumTypeId="PROD_PRICE_IN_PARAM"/> + <Enumeration description="List Price" enumCode="LIST_PRICE" enumId="PRIP_LIST_PRICE" sequenceId="12" enumTypeId="PROD_PRICE_IN_PARAM"/> + <Enumeration description="Currency UomId" enumCode="CURRENCY_UOMID" enumId="PRIP_CURRENCY_UOMID" sequenceId="13" enumTypeId="PROD_PRICE_IN_PARAM"/> <!-- old style; very technical ... <Enumeration description="==" enumCode="EQ" enumId="PRC_EQ" sequenceId="01" enumTypeId="PROD_PRICE_COND"/> Modified: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java?view=diff&rev=472825&r1=472824&r2=472825 ============================================================================== --- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java (original) +++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java Thu Nov 9 01:21:54 2006 @@ -1,5 +1,4 @@ /* - * * Copyright 2001-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -534,10 +533,10 @@ if ("PRIP_QUANTITY".equals(productPriceCond.getString("inputParamEnumId"))) { foundQuantityInputParam = true; } else { - if (!checkPriceCondition(productPriceCond, productId, prodCatalogId, productStoreGroupId, webSiteId, partyId, new Double(quantity), listPriceDbl.doubleValue(), currencyUomId, delegator)) { + if (!checkPriceCondition(productPriceCond, productId, prodCatalogId, productStoreGroupId, webSiteId, partyId, new Double(quantity), listPriceDbl.doubleValue(), currencyUomId, delegator, nowTimestamp)) { // if there is a virtualProductId, try that given that this one has failed if (virtualProductId != null) { - if (!checkPriceCondition(productPriceCond, virtualProductId, prodCatalogId, productStoreGroupId, webSiteId, partyId, new Double(quantity), listPriceDbl.doubleValue(), currencyUomId, delegator)) { + if (!checkPriceCondition(productPriceCond, virtualProductId, prodCatalogId, productStoreGroupId, webSiteId, partyId, new Double(quantity), listPriceDbl.doubleValue(), currencyUomId, delegator, nowTimestamp)) { allExceptQuantTrue = false; } // otherwise, okay, this one made it so carry on checking @@ -682,6 +681,16 @@ } } + // by productFeatureId + Collection productFeatureIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_FEAT_ID")); + if (productFeatureIdConds != null && productFeatureIdConds.size() > 0) { + Iterator productFeatureIdCondsIter = productFeatureIdConds.iterator(); + while (productFeatureIdCondsIter.hasNext()) { + GenericValue productFeatureIdCond = (GenericValue) productFeatureIdCondsIter.next(); + productPriceRuleIds.add(productFeatureIdCond.getString("productPriceRuleId")); + } + } + // by quantity -- should we really do this one, ie is it necessary? // we could say that all rules with quantity on them must have one of these other values // but, no we'll do it the other way, any that have a quantity will always get compared @@ -873,10 +882,10 @@ totalConds++; - if (!checkPriceCondition(productPriceCond, productId, prodCatalogId, productStoreGroupId, webSiteId, partyId, quantity, listPrice, currencyUomId, delegator)) { + if (!checkPriceCondition(productPriceCond, productId, prodCatalogId, productStoreGroupId, webSiteId, partyId, quantity, listPrice, currencyUomId, delegator, nowTimestamp)) { // if there is a virtualProductId, try that given that this one has failed if (virtualProductId != null) { - if (!checkPriceCondition(productPriceCond, virtualProductId, prodCatalogId, productStoreGroupId, webSiteId, partyId, quantity, listPrice, currencyUomId, delegator)) { + if (!checkPriceCondition(productPriceCond, virtualProductId, prodCatalogId, productStoreGroupId, webSiteId, partyId, quantity, listPrice, currencyUomId, delegator, nowTimestamp)) { allTrue = false; break; } @@ -1088,7 +1097,7 @@ public static boolean checkPriceCondition(GenericValue productPriceCond, String productId, String prodCatalogId, String productStoreGroupId, String webSiteId, String partyId, Double quantity, double listPrice, - String currencyUomId, GenericDelegator delegator) throws GenericEntityException { + String currencyUomId, GenericDelegator delegator, Timestamp nowTimestamp) throws GenericEntityException { if (Debug.verboseOn()) Debug.logVerbose("Checking price condition: " + productPriceCond, module); int compare = 0; @@ -1100,13 +1109,26 @@ List productCategoryMembers = delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productId", productId, "productCategoryId", productCategoryId)); // and from/thru date within range - productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, true); + productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, nowTimestamp, null, null, true); // then 0 (equals), otherwise 1 (not equals) if (productCategoryMembers != null && productCategoryMembers.size() > 0) { compare = 0; } else { compare = 1; } + } else if ("PRIP_PROD_FEAT_ID".equals(productPriceCond.getString("inputParamEnumId"))) { + // if a ProductFeatureAppl exists for this productId and the specified productFeatureId + String productFeatureId = productPriceCond.getString("condValue"); + List productFeatureAppls = delegator.findByAndCache("ProductFeatureAppl", + UtilMisc.toMap("productId", productId, "productFeatureId", productFeatureId)); + // and from/thru date within range + productFeatureAppls = EntityUtil.filterByDate(productFeatureAppls, nowTimestamp, null, null, true); + // then 0 (equals), otherwise 1 (not equals) + if (productFeatureAppls != null && productFeatureAppls.size() > 0) { + compare = 0; + } else { + compare = 1; + } } else if ("PRIP_PROD_CLG_ID".equals(productPriceCond.getString("inputParamEnumId"))) { if (UtilValidate.isNotEmpty(prodCatalogId)) { compare = prodCatalogId.compareTo(productPriceCond.getString("condValue")); @@ -1151,12 +1173,20 @@ // look for PartyRelationship with partyRelationshipTypeId=GROUP_ROLLUP, the partyIdTo is the group member, so the partyIdFrom is the groupPartyId List partyRelationshipList = delegator.findByAndCache("PartyRelationship", UtilMisc.toMap("partyIdFrom", groupPartyId, "partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP")); // and from/thru date within range - partyRelationshipList = EntityUtil.filterByDate(partyRelationshipList, true); + partyRelationshipList = EntityUtil.filterByDate(partyRelationshipList, nowTimestamp, null, null, true); // then 0 (equals), otherwise 1 (not equals) if (partyRelationshipList != null && partyRelationshipList.size() > 0) { compare = 0; } else { - compare = 1; + // before setting 1 try one more query: look for a 2 hop relationship + List partyRelationshipTwoHopList = delegator.findByAndCache("PartyRelationshipToFrom", UtilMisc.toMap("onePartyIdFrom", groupPartyId, "twoPartyIdTo", partyId, "onePartyRelationshipTypeId", "GROUP_ROLLUP", "twoPartyRelationshipTypeId", "GROUP_ROLLUP")); + partyRelationshipTwoHopList = EntityUtil.filterByDate(partyRelationshipTwoHopList, nowTimestamp, "oneFromDate", "oneThruDate", true); + partyRelationshipTwoHopList = EntityUtil.filterByDate(partyRelationshipTwoHopList, nowTimestamp, "twoFromDate", "twoThruDate", true); + if (partyRelationshipTwoHopList != null && partyRelationshipTwoHopList.size() > 0) { + compare = 0; + } else { + compare = 1; + } } } } @@ -1168,7 +1198,7 @@ // find any PartyClassification List partyClassificationList = delegator.findByAndCache("PartyClassification", UtilMisc.toMap("partyId", partyId, "partyClassificationGroupId", partyClassificationGroupId)); // and from/thru date within range - partyClassificationList = EntityUtil.filterByDate(partyClassificationList, true); + partyClassificationList = EntityUtil.filterByDate(partyClassificationList, nowTimestamp, null, null, true); // then 0 (equals), otherwise 1 (not equals) if (partyClassificationList != null && partyClassificationList.size() > 0) { compare = 0; |
Free forum by Nabble | Edit this page |