Sorry about this, accidental commit. Will revert right away.

-David


On Feb 19, 2011, at 2:13 AM, [email protected] wrote:

> Author: jonesde
> Date: Sat Feb 19 10:13:50 2011
> New Revision: 1072292
> 
> URL: http://svn.apache.org/viewvc?rev=1072292&view=rev
> Log:
> VUA-429 full implementation to add a path through the screens for creating a 
> sales order for a contact and add a customer for the contact in the process
> 
> Modified:
>    
> ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java
>    ofbiz/trunk/framework/common/config/general.properties
>    ofbiz/trunk/framework/common/widget/CommonScreens.xml
>    ofbiz/trunk/framework/entity/config/entityengine.xml
>    ofbiz/trunk/framework/entity/fieldtype/fieldtypemysql.xml
> 
> Modified: 
> ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java
> URL: 
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java?rev=1072292&r1=1072291&r2=1072292&view=diff
> ==============================================================================
> --- 
> ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java
>  (original)
> +++ 
> ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java
>  Sat Feb 19 10:13:50 2011
> @@ -21,9 +21,11 @@ package org.ofbiz.product.price;
> import java.math.BigDecimal;
> import java.sql.Timestamp;
> import java.util.Collection;
> +import java.util.HashSet;
> import java.util.List;
> import java.util.Locale;
> import java.util.Map;
> +import java.util.Set;
> import java.util.TreeSet;
> 
> import javolution.util.FastList;
> @@ -1117,6 +1119,31 @@ public class PriceServices {
>         return calcResults;
>     }
> 
> +    public static void getAllSubCategoryIdsByPrimaryField(String 
> productCategoryId, Set<String> productCategoryIdSet, Delegator delegator, 
> Timestamp nowTimestamp) {
> +        if (nowTimestamp == null) {
> +            nowTimestamp = UtilDateTime.nowTimestamp();
> +        }
> +
> +        // first make sure the current category id is in the Set
> +        productCategoryIdSet.add(productCategoryId);
> +
> +        // now find all sub-categories, filtered by effective dates, and 
> call this routine for them
> +        try {
> +            List<GenericValue> productCategoryList = 
> delegator.findByAndCache("ProductCategory", 
> UtilMisc.toMap("primaryParentCategoryId", productCategoryId));
> +            for (GenericValue productCategory: productCategoryList) {
> +                String subProductCategoryId = 
> productCategory.getString("productCategoryId");
> +                if (productCategoryIdSet.contains(subProductCategoryId)) {
> +                    // if this category has already been traversed, no use 
> doing it again; this will also avoid infinite loops
> +                    continue;
> +                }
> +
> +                getAllSubCategoryIdsByPrimaryField(subProductCategoryId, 
> productCategoryIdSet, delegator, nowTimestamp);
> +            }
> +        } catch (GenericEntityException e) {
> +            Debug.logError(e, "Error finding sub-categories for product 
> search", module);
> +        }
> +    }
> +    
>     public static boolean checkPriceCondition(GenericValue productPriceCond, 
> String productId, String virtualProductId, String prodCatalogId,
>             String productStoreGroupId, String webSiteId, String partyId, 
> BigDecimal quantity, BigDecimal listPrice,
>             String currencyUomId, Delegator delegator, Timestamp 
> nowTimestamp) throws GenericEntityException {
> @@ -1128,17 +1155,36 @@ public class PriceServices {
>         } else if 
> ("PRIP_PROD_CAT_ID".equals(productPriceCond.getString("inputParamEnumId"))) {
>             // if a ProductCategoryMember exists for this productId and the 
> specified productCategoryId
>             String productCategoryId = 
> productPriceCond.getString("condValue");
> +            // get all sub-category IDs
> +            Set<String> productCategoryIdSet = new HashSet<String>();
> +            getAllSubCategoryIdsByPrimaryField(productCategoryId, 
> productCategoryIdSet, delegator, nowTimestamp);
> +            
> +            //Debug.logInfo("Checking category condition with category IDs: 
> " + productCategoryIdSet, module);
> +            
> +            // to better handle large numbers of rules with category 
> conditions checked for each product, get all categories for the product from 
> the cache, then filter it in memory (less queries, less cache entries too)
>             List<GenericValue> productCategoryMembers = 
> delegator.findByAndCache("ProductCategoryMember",
> -                    UtilMisc.toMap("productId", productId, 
> "productCategoryId", productCategoryId));
> +                    UtilMisc.toMap("productId", productId));
>             // and from/thru date within range
>             productCategoryMembers = 
> EntityUtil.filterByDate(productCategoryMembers, nowTimestamp, null, null, 
> true);
> -            // then 0 (equals), otherwise 1 (not equals)
> -            if (UtilValidate.isNotEmpty(productCategoryMembers)) {
> +            
> +            // see if the product is in any of the category with ID in 
> productCategoryIdSet
> +            boolean matchFound = false;
> +            for (String testProductCategoryId: productCategoryIdSet) {
> +                List<GenericValue> testProductCategoryMembers = 
> EntityUtil.filterByAnd(productCategoryMembers, 
> +                        UtilMisc.toMap("productCategoryId", 
> testProductCategoryId));
> +                // then 0 (equals), otherwise 1 (not equals)
> +                if (UtilValidate.isNotEmpty(testProductCategoryMembers)) {
> +                    matchFound = true;
> +                    break;
> +                }
> +            }
> +
> +            if (matchFound) {
>                 compare = 0;
>             } else {
>                 compare = 1;
>             }
> -
> +            
>             // if there is a virtualProductId, try that given that this one 
> has failed
>             // NOTE: this is important becuase of the common scenario where a 
> virtual product is a member of a category but the variants will typically NOT 
> be
>             // NOTE: we may want to parameterize this in the future, ie with 
> an indicator on the ProductPriceCond entity
> @@ -1194,7 +1240,8 @@ public class PriceServices {
>             } else {
>                 compare = quantity.compareTo(new 
> BigDecimal(productPriceCond.getString("condValue")));
>             }
> -        } else if 
> ("PRIP_PARTY_ID".equals(productPriceCond.getString("inputParamEnumId"))) {
> +        } else if 
> ("PRIP_PARTY_ID".equals(productPriceCond.getString("inputParamEnumId"))
> +                || 
> "PRIP_CUST_ACCOUNT".equals(productPriceCond.getString("inputParamEnumId"))) {
>             if (UtilValidate.isNotEmpty(partyId)) {
>                 compare = 
> partyId.compareTo(productPriceCond.getString("condValue"));
>             } else {
> @@ -1222,7 +1269,9 @@ public class PriceServices {
>                     }
>                 }
>             }
> -        } else if 
> ("PRIP_PARTY_CLASS".equals(productPriceCond.getString("inputParamEnumId"))) {
> +        } else if 
> ("PRIP_PARTY_CLASS".equals(productPriceCond.getString("inputParamEnumId"))
> +                || 
> "PRIP_ACCOUNT_TYPE".equals(productPriceCond.getString("inputParamEnumId"))
> +                || 
> "PRIP_CLUB_SEGMENT".equals(productPriceCond.getString("inputParamEnumId"))) {
>             if (UtilValidate.isEmpty(partyId)) {
>                 compare = 1;
>             } else {
> @@ -1238,27 +1287,69 @@ public class PriceServices {
>                     compare = 1;
>                 }
>             }
> +        } else if 
> ("PRIP_LIST_PRICE".equals(productPriceCond.getString("inputParamEnumId"))) {
> +            BigDecimal listPriceValue = listPrice;
> +            compare = listPriceValue.compareTo(new 
> BigDecimal(productPriceCond.getString("condValue")));
> +        } else if 
> ("PRIP_CURRENCY_UOMID".equals(productPriceCond.getString("inputParamEnumId")))
>  {
> +            compare = 
> currencyUomId.compareTo(productPriceCond.getString("condValue"));
> +        } else if 
> ("PRIP_CONTACT".equals(productPriceCond.getString("inputParamEnumId"))) {
> +            if (UtilValidate.isEmpty(partyId)) {
> +                compare = 1;
> +            } else {
> +                String partyIdTo = productPriceCond.getString("condValue");
> +                // find Contacts
> +                List<GenericValue> contactList = 
> delegator.findByAndCache("PartyRelationship", 
> UtilMisc.toMap("partyRelationshipTypeId", "CONTACT_REL", "partyIdFrom", 
> partyId, "partyIdTo", partyIdTo));
> +                // and from/thru date within range
> +                contactList = EntityUtil.filterByDate(contactList, 
> nowTimestamp, null, null, true);
> +                // then 0 (equals), otherwise 1 (not equals)
> +                if (UtilValidate.isNotEmpty(contactList)) {
> +                    compare = 0;
> +                } else {
> +                    compare = 1;
> +                }
> +            }
> +        } else if 
> ("PRIP_ACCOUNT_STATE".equals(productPriceCond.getString("inputParamEnumId"))) 
> {
> +            if (UtilValidate.isEmpty(partyId)) {
> +                compare = 1;
> +            } else {
> +                String statusId = productPriceCond.getString("condValue");
> +                List<GenericValue> partyStatusList = 
> delegator.findByAndCache("PartyStatus", UtilMisc.toMap("partyId", partyId, 
> "statusId", statusId));
> +                // then 0 (equals), otherwise 1 (not equals)
> +                if (UtilValidate.isNotEmpty(partyStatusList)) {
> +                    compare = 0;
> +                } else {
> +                    compare = 1;
> +                }
> +            }
>         } else if 
> ("PRIP_ROLE_TYPE".equals(productPriceCond.getString("inputParamEnumId"))) {
> -            if (partyId != null) {
> -                // if a PartyRole exists for this partyId and the specified 
> roleTypeId
> -                GenericValue partyRole = 
> delegator.findByPrimaryKeyCache("PartyRole",
> -                        UtilMisc.toMap("partyId", partyId, "roleTypeId", 
> productPriceCond.getString("condValue")));
> -
> +            if (UtilValidate.isEmpty(partyId)) {
> +                compare = 1;
> +            } else {
> +                String roleTypeId = productPriceCond.getString("condValue");
> +                List<GenericValue> partyRoleList = 
> delegator.findByAndCache("PartyRole", UtilMisc.toMap("partyId", partyId, 
> "roleTypeId", roleTypeId));
>                 // then 0 (equals), otherwise 1 (not equals)
> -                if (partyRole != null) {
> +                if (UtilValidate.isNotEmpty(partyRoleList)) {
>                     compare = 0;
>                 } else {
>                     compare = 1;
>                 }
> +            }            
> +        } else if 
> ("PRIP_CONTACT_TYPE".equals(productPriceCond.getString("inputParamEnumId"))) {
> +            if (UtilValidate.isEmpty(partyId)) {
> +                compare = 1;
>             } else {
> +                String contactTypeId = 
> productPriceCond.getString("condValue");
> +                // find Contacts
> +                List<GenericValue> contactList = 
> delegator.findByAndCache("PartyRelationship", 
> UtilMisc.toMap("partyRelationshipTypeId", "CONTACT_REL", "partyIdFrom", 
> partyId));
> +                // then 0 (equals), otherwise 1 (not equals)
>                 compare = 1;
> +                for (GenericValue contact : contactList) {
> +                    if (delegator.findByAndCache("Person", 
> UtilMisc.toMap("partyId", contact.get("partyIdTo"), "contactTypeId", 
> contactTypeId)).size() > 0) {
> +                        compare = 0;
> +                        break;
>             }
> -        } else if 
> ("PRIP_LIST_PRICE".equals(productPriceCond.getString("inputParamEnumId"))) {
> -            BigDecimal listPriceValue = listPrice;
> -
> -            compare = listPriceValue.compareTo(new 
> BigDecimal(productPriceCond.getString("condValue")));
> -        } else if 
> ("PRIP_CURRENCY_UOMID".equals(productPriceCond.getString("inputParamEnumId")))
>  {
> -            compare = 
> currencyUomId.compareTo(productPriceCond.getString("condValue"));
> +                }
> +            }            
>         } else {
>             Debug.logWarning("An un-supported productPriceCond input 
> parameter (lhs) was used: " + productPriceCond.getString("inputParamEnumId") 
> + ", returning false, ie check failed", module);
>             return false;
> 
> Modified: ofbiz/trunk/framework/common/config/general.properties
> URL: 
> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/general.properties?rev=1072292&r1=1072291&r2=1072292&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/common/config/general.properties (original)
> +++ ofbiz/trunk/framework/common/config/general.properties Sat Feb 19 
> 10:13:50 2011
> @@ -27,7 +27,7 @@ currency.uom.id.default=USD
> # -- the default organizationPartyId for used in dropdowns and reports
> ORGANIZATION_PARTY=Company
> # ID of the VisualTheme to use if there VISUAL_THEME UserPreference record 
> for the current user supported values: FLAT_GREY and BIZZNESS_TIME and 
> BLUELIGHT 
> -VISUAL_THEME=TOMAHAWK
> +VISUAL_THEME=VINOPS
> 
> # -- the default decimal format for currency (used in UtilFormatOut.java)
> currency.decimal.format=#,##0.00
> @@ -42,7 +42,7 @@ locale.properties.fallback=en
> #    which locales the user can select from. If this property is not used,
> #    then the user will be able to select from all the locales available
> #    in the JVM. The list below corresponds to the languages really available 
> OOTB (2010-16-02)
> -#locales.available=ar,de,en,es,fr,hi,it,nl,pt,ro,ru,th,zh
> +locales.available=de,en,es,fr,it
> 
> # -- Time zones made available, separated by commas. This property controls
> #    which time zones the user can select from. If this property is not used,
> @@ -71,13 +71,13 @@ defaultFromEmailAddress=ofbiztest@exampl
> # as 'baseUrl' and 'baseSecureUrl' are set in the url.properties file. 
> 
> # -- mail notifications enabled (Y|N)
> -mail.notifications.enabled=N
> +#mail.notifications.enabled=N
> 
> # -- redirect all mail notifications to this address for testing
> #mail.notifications.redirectTo=
> 
> # -- the default mail server to use
> -mail.smtp.relay.host=localhost
> +#mail.smtp.relay.host=
> 
> # -- SMTP Auth settings
> #mail.smtp.auth.user=
> @@ -129,4 +129,4 @@ https.localhost=ABQIAAAAtt0d8djaYFkk8N5L
> http.localhost=ABQIAAAAtt0d8djaYFkk8N5LJVcDSBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxR3euHYk9bpwvdF2Qg1EYO1LQitHA
> 
> # -- Y if you want to display the multi-tenant textbox in the login page
> -multitenant=N
> +multitenant=Y
> 
> Modified: ofbiz/trunk/framework/common/widget/CommonScreens.xml
> URL: 
> http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/widget/CommonScreens.xml?rev=1072292&r1=1072291&r2=1072292&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/common/widget/CommonScreens.xml (original)
> +++ ofbiz/trunk/framework/common/widget/CommonScreens.xml Sat Feb 19 10:13:50 
> 2011
> @@ -136,7 +136,7 @@ under the License.
>                 <set field="layoutSettings.javaScripts[]" 
> value="/images/selectMultipleRelatedValues.js" global="true"/>
> 
>                 <set field="layoutSettings.commonHeaderImageLinkUrl" 
> from-field="layoutSettings.commonHeaderImageLinkUrl" default-value="main" 
> global="true"/>
> -                <set field="visualThemeId" 
> from-field="userPreferences.VISUAL_THEME" global="true"/>
> +                <set field="visualThemeId" 
> from-field="userPreferences.VISUAL_THEME" default-value="VINOPS" 
> global="true"/>
>                 <service service-name="getVisualThemeResources">
>                     <field-map field-name="visualThemeId"/>
>                     <field-map field-name="themeResources" 
> from-field="layoutSettings"/>
> 
> Modified: ofbiz/trunk/framework/entity/config/entityengine.xml
> URL: 
> http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/config/entityengine.xml?rev=1072292&r1=1072291&r2=1072292&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/entity/config/entityengine.xml (original)
> +++ ofbiz/trunk/framework/entity/config/entityengine.xml Sat Feb 19 10:13:50 
> 2011
> @@ -50,7 +50,7 @@ access. For a detailed description see t
>     <connection-factory 
> class="org.ofbiz.entity.connection.DBCPConnectionFactory"/>
> 
>     <delegator name="default" entity-model-reader="main" 
> entity-group-reader="main" entity-eca-reader="main" 
> distributed-cache-clear-enabled="false">
> -        <group-map group-name="org.ofbiz" datasource-name="localderby"/>
> +        <group-map group-name="org.ofbiz" datasource-name="localmysql"/>
>         <group-map group-name="org.ofbiz.olap" 
> datasource-name="localderbyolap"/>
>         <group-map group-name="org.ofbiz.tenant" 
> datasource-name="localderbytenant"/>
>         <!-- <group-map group-name="org.ofbiz" datasource-name="localmysql"/>
> 
> Modified: ofbiz/trunk/framework/entity/fieldtype/fieldtypemysql.xml
> URL: 
> http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/fieldtype/fieldtypemysql.xml?rev=1072292&r1=1072291&r2=1072292&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/entity/fieldtype/fieldtypemysql.xml (original)
> +++ ofbiz/trunk/framework/entity/fieldtype/fieldtypemysql.xml Sat Feb 19 
> 10:13:50 2011
> @@ -33,6 +33,7 @@ under the License.
>     <field-type-def type="currency-amount" sql-type="DECIMAL(18,2)" 
> java-type="java.math.BigDecimal"/>
>     <field-type-def type="currency-precise" sql-type="DECIMAL(18,3)" 
> java-type="java.math.BigDecimal"/>
>     <field-type-def type="fixed-point" sql-type="DECIMAL(18,6)" 
> java-type="java.math.BigDecimal"/>
> +    <field-type-def type="precise-point" sql-type="DECIMAL(22,10)" 
> java-type="java.math.BigDecimal"/>
>     <field-type-def type="floating-point" sql-type="DOUBLE" 
> java-type="Double"/>
>     <field-type-def type="numeric" sql-type="DECIMAL(20,0)" java-type="Long"/>
> 
> 
> 

Reply via email to