Author: jleroux
Date: Thu Jan 2 15:15:32 2014 New Revision: 1554827 URL: http://svn.apache.org/r1554827 Log: Merges trunk HEAD Added: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/base/lib/scripting/groovy-all-2.2.1.jar - copied unchanged from r1554826, ofbiz/trunk/framework/base/lib/scripting/groovy-all-2.2.1.jar ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/images/webapp/images/OpenLayers-2.13.1.js - copied unchanged from r1554826, ofbiz/trunk/framework/images/webapp/images/OpenLayers-2.13.1.js ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/images/webapp/images/img/ - copied from r1554826, ofbiz/trunk/framework/images/webapp/images/img/ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/images/webapp/images/theme.openlayer.unused.ootb/ - copied from r1554826, ofbiz/trunk/framework/images/webapp/images/theme.openlayer.unused.ootb/ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/lib/lucene-analyzers-common-4.6.0.jar - copied unchanged from r1554826, ofbiz/trunk/specialpurpose/lucene/lib/lucene-analyzers-common-4.6.0.jar ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/lib/lucene-core-4.6.0.jar - copied unchanged from r1554826, ofbiz/trunk/specialpurpose/lucene/lib/lucene-core-4.6.0.jar ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/lib/lucene-queryparser-4.6.0.jar - copied unchanged from r1554826, ofbiz/trunk/specialpurpose/lucene/lib/lucene-queryparser-4.6.0.jar Removed: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/script/org/ofbiz/accounting/test/TaxAuthorityTests.xml ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/testdef/taxauthoritytests.xml ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/base/lib/scripting/groovy-all-2.1.9.jar ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/lib/lucene-analyzers-common-4.5.1.jar ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/lib/lucene-core-4.5.1.jar ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/lib/lucene-queryparser-4.5.1.jar Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/ (props changed) ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/.classpath ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/LICENSE ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/ofbiz-component.xml ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/party/editGeoLocation.ftl ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/build.xml ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/config/general.properties ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/webcommon/includes/geolocation.ftl ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/widget/CommonScreens.xml ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/dtd/simple-methods-v2.xsd ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/method/MethodContext.java ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/dtd/widget-form.xsd ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/dtd/widget-screen.xsd ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/macros.xml ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/LICENSE ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/example/widget/example/ExampleScreens.xml ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/src/org/ofbiz/content/search/SearchWorker.java Propchange: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/ ------------------------------------------------------------------------------ Merged /ofbiz/trunk:r1553945-1554826 Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/.classpath URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/.classpath?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/.classpath (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/.classpath Thu Jan 2 15:15:32 2014 @@ -94,7 +94,7 @@ <classpathentry kind="lib" path="framework/base/lib/scripting/asm-util-3.2.jar"/> <classpathentry kind="lib" path="framework/base/lib/scripting/bsf-2.4.0.jar"/> <classpathentry kind="lib" path="framework/base/lib/scripting/bsh-2.0b4.jar"/> - <classpathentry kind="lib" path="framework/base/lib/scripting/groovy-all-2.1.9.jar"/> + <classpathentry kind="lib" path="framework/base/lib/scripting/groovy-all-2.2.1.jar"/> <classpathentry kind="lib" path="framework/base/lib/scripting/jakarta-oro-2.0.8.jar"/> <classpathentry kind="lib" path="framework/base/lib/scripting/jython-nooro.jar"/> <classpathentry kind="lib" path="specialpurpose/birt/lib/org.eclipse.birt.runtime_3.7.2.v20120214-1408.jar"/> @@ -154,9 +154,9 @@ <classpathentry kind="lib" path="specialpurpose/ebaystore/lib/ebaycalls.jar"/> <classpathentry kind="lib" path="specialpurpose/ebaystore/lib/ebaysdkcore.jar"/> <classpathentry kind="lib" path="specialpurpose/ebaystore/lib/helper.jar"/> - <classpathentry kind="lib" path="specialpurpose/lucene/lib/lucene-analyzers-common-4.5.1.jar"/> - <classpathentry kind="lib" path="specialpurpose/lucene/lib/lucene-core-4.5.1.jar"/> - <classpathentry kind="lib" path="specialpurpose/lucene/lib/lucene-queryparser-4.5.1.jar"/> + <classpathentry kind="lib" path="specialpurpose/lucene/lib/lucene-analyzers-common-4.6.0.jar"/> + <classpathentry kind="lib" path="specialpurpose/lucene/lib/lucene-core-4.6.0.jar"/> + <classpathentry kind="lib" path="specialpurpose/lucene/lib/lucene-queryparser-4.6.0.jar"/> <classpathentry excluding="org/ofbiz/accounting/thirdparty/cybersource/**|org/ofbiz/accounting/thirdparty/verisign/**|org/ofbiz/accounting/thirdparty/worldpay/**|org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java|org/ofbiz/accounting/thirdparty/orbital/**|org/ofbiz/accounting/thirdparty/securepay/**|org/ofbiz/accounting/thirdparty/ideal/**" kind="src" path="applications/accounting/src"/> <classpathentry excluding="org/ofbiz/content/openoffice/|org/ofbiz/content/report/" kind="src" path="applications/content/src"/> <classpathentry kind="src" path="applications/manufacturing/src"/> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/LICENSE URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/LICENSE?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/LICENSE (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/LICENSE Thu Jan 2 15:15:32 2014 @@ -69,7 +69,7 @@ framework/base/lib/j2eespecs/jsp-api-2.2 framework/base/lib/j2eespecs/servlet-api-3.0.jar framework/base/lib/scripting/bsf-2.4.0.jar framework/base/lib/scripting/jakarta-oro-2.0.8.jar -framework/base/lib/scripting/groovy-all-2.1.9.jar +framework/base/lib/scripting/groovy-all-2.2.1.jar framework/base/lib/scripting/jansi-1.2.1.jar framework/base/lib/xmlrpc-client-3.1.2.jar framework/base/lib/xmlrpc-common-3.1.2.jar Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/ofbiz-component.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/ofbiz-component.xml?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/ofbiz-component.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/ofbiz-component.xml Thu Jan 2 15:15:32 2014 @@ -101,7 +101,6 @@ under the License. <test-suite loader="main" location="testdef/paymentappltests.xml"/> <test-suite loader="main" location="testdef/invoicetests.xml"/> <test-suite loader="main" location="testdef/fixedassettests.xml"/> - <test-suite loader="main" location="testdef/taxauthoritytests.xml"/> <webapp name="accounting" title="Accounting" Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java Thu Jan 2 15:15:32 2014 @@ -20,13 +20,12 @@ package org.ofbiz.accounting.test; import java.math.BigDecimal; +import java.util.HashMap; import java.util.Map; -import javolution.util.FastMap; - import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericValue; -import org.ofbiz.service.ModelService; +import org.ofbiz.service.ServiceUtil; import org.ofbiz.service.testtools.OFBizTestCase; /** @@ -34,49 +33,35 @@ import org.ofbiz.service.testtools.OFBiz */ public class FinAccountTests extends OFBizTestCase { - protected GenericValue userLogin = null; - public FinAccountTests(String name) { super(name); } - @Override - protected void setUp() throws Exception { - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), false); - } - - @Override - protected void tearDown() throws Exception { - } - - public void testCreateFinAccount() throws Exception { - Map<String, Object> ctx = FastMap.newInstance(); + public void testFinAccountOperations() throws Exception { + GenericValue userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), false); + Map<String, Object> ctx = new HashMap<String, Object>(); ctx.put("finAccountId", "TESTACCOUNT1"); ctx.put("finAccountName", "Test Financial Account"); ctx.put("finAccountTypeId", "BANK_ACCOUNT"); ctx.put("userLogin", userLogin); Map<String, Object> resp = dispatcher.runSync("createFinAccount", ctx); - assertEquals("Service result success", ModelService.RESPOND_SUCCESS, resp.get(ModelService.RESPONSE_MESSAGE)); - } - - public void testDeposit() throws Exception { - Map<String, Object> ctx = FastMap.newInstance(); + assertTrue("Service 'createFinAccount' result success", ServiceUtil.isSuccess(resp)); + ctx.clear(); ctx.put("finAccountId", "TESTACCOUNT1"); ctx.put("amount", new BigDecimal("100.00")); ctx.put("userLogin", userLogin); - Map<String, Object> resp = dispatcher.runSync("finAccountDeposit", ctx); + resp = dispatcher.runSync("finAccountDeposit", ctx); + assertTrue("Service 'finAccountDeposit' result success", ServiceUtil.isSuccess(resp)); BigDecimal balance = (BigDecimal) resp.get("balance"); assertEquals(balance.toPlainString(), "100.00"); - } - - public void testWithdraw() throws Exception { - Map<String, Object> ctx = FastMap.newInstance(); + ctx.clear(); ctx.put("finAccountId", "TESTACCOUNT1"); ctx.put("amount", new BigDecimal("50.00")); ctx.put("userLogin", userLogin); - Map<String, Object> resp = dispatcher.runSync("finAccountWithdraw", ctx); + resp = dispatcher.runSync("finAccountWithdraw", ctx); + assertTrue("Service 'finAccountWithdraw' result success", ServiceUtil.isSuccess(resp)); BigDecimal previousBalance = (BigDecimal) resp.get("previousBalance"); - BigDecimal balance = ((BigDecimal) resp.get("balance")); + balance = ((BigDecimal) resp.get("balance")); assertEquals(balance.add(new BigDecimal("50.00")).toPlainString(), previousBalance.toPlainString()); } } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Thu Jan 2 15:15:32 2014 @@ -2714,7 +2714,7 @@ public class ShoppingCart implements Ite } itemsTotal = itemsTotal.add(cartItem.getItemSubTotal()); } - return itemsTotal; + return itemsTotal.add(this.getOrderOtherAdjustmentTotal()); } /** @@ -3142,12 +3142,12 @@ public class ShoppingCart implements Ite return new HashMap<GenericPK, String>(this.desiredAlternateGiftByAction); } - public void addProductPromoUse(String productPromoId, String productPromoCodeId, BigDecimal totalDiscountAmount, BigDecimal quantityLeftInActions) { + public void addProductPromoUse(String productPromoId, String productPromoCodeId, BigDecimal totalDiscountAmount, BigDecimal quantityLeftInActions, Map<ShoppingCartItem,BigDecimal> usageInfoMap) { if (UtilValidate.isNotEmpty(productPromoCodeId) && !this.productPromoCodes.contains(productPromoCodeId)) { throw new IllegalStateException("Cannot add a use to a promo code use for a code that has not been entered."); } if (Debug.verboseOn()) Debug.logVerbose("Used promotion [" + productPromoId + "] with code [" + productPromoCodeId + "] for total discount [" + totalDiscountAmount + "] and quantity left in actions [" + quantityLeftInActions + "]", module); - this.productPromoUseInfoList.add(new ProductPromoUseInfo(productPromoId, productPromoCodeId, totalDiscountAmount, quantityLeftInActions)); + this.productPromoUseInfoList.add(new ProductPromoUseInfo(productPromoId, productPromoCodeId, totalDiscountAmount, quantityLeftInActions, usageInfoMap)); } public void removeProductPromoUse(String productPromoId) { @@ -4385,23 +4385,43 @@ public class ShoppingCart implements Ite } } - public static class ProductPromoUseInfo implements Serializable { + public static class ProductPromoUseInfo implements Serializable, Comparable<ProductPromoUseInfo> { public String productPromoId = null; public String productPromoCodeId = null; public BigDecimal totalDiscountAmount = BigDecimal.ZERO; public BigDecimal quantityLeftInActions = BigDecimal.ZERO; + private Map<ShoppingCartItem,BigDecimal> usageInfoMap = null; - public ProductPromoUseInfo(String productPromoId, String productPromoCodeId, BigDecimal totalDiscountAmount, BigDecimal quantityLeftInActions) { + public ProductPromoUseInfo(String productPromoId, String productPromoCodeId, BigDecimal totalDiscountAmount, BigDecimal quantityLeftInActions, Map<ShoppingCartItem,BigDecimal> usageInfoMap) { this.productPromoId = productPromoId; this.productPromoCodeId = productPromoCodeId; this.totalDiscountAmount = totalDiscountAmount; this.quantityLeftInActions = quantityLeftInActions; + this.usageInfoMap = usageInfoMap; } public String getProductPromoId() { return this.productPromoId; } public String getProductPromoCodeId() { return this.productPromoCodeId; } public BigDecimal getTotalDiscountAmount() { return this.totalDiscountAmount; } public BigDecimal getQuantityLeftInActions() { return this.quantityLeftInActions; } + public Map<ShoppingCartItem,BigDecimal> getUsageInfoMap() { return this.usageInfoMap; } + public BigDecimal getUsageWeight() { + Iterator<ShoppingCartItem> lineItems = this.usageInfoMap.keySet().iterator(); + BigDecimal totalAmount = BigDecimal.ZERO; + while (lineItems.hasNext()) { + ShoppingCartItem lineItem = lineItems.next(); + totalAmount = totalAmount.add(lineItem.getBasePrice().multiply(usageInfoMap.get(lineItem))); + } + if (totalAmount.compareTo(BigDecimal.ZERO) == 0) { + return BigDecimal.ZERO; + } else { + return getTotalDiscountAmount().negate().divide(totalAmount); + } + } + + public int compareTo(ProductPromoUseInfo other) { + return other.getUsageWeight().compareTo(getUsageWeight()); + } } public static class CartShipInfo implements Serializable { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Thu Jan 2 15:15:32 2014 @@ -21,6 +21,7 @@ package org.ofbiz.order.shoppingcart; import java.math.BigDecimal; import java.math.MathContext; import java.sql.Timestamp; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -629,7 +630,7 @@ public class ShoppingCartServices { cart.addProductPromoCode(productPromoCode, dispatcher); } for (GenericValue productPromoUse: orh.getProductPromoUse()) { - cart.addProductPromoUse(productPromoUse.getString("productPromoId"), productPromoUse.getString("productPromoCodeId"), productPromoUse.getBigDecimal("totalDiscountAmount"), productPromoUse.getBigDecimal("quantityLeftInActions")); + cart.addProductPromoUse(productPromoUse.getString("productPromoId"), productPromoUse.getString("productPromoCodeId"), productPromoUse.getBigDecimal("totalDiscountAmount"), productPromoUse.getBigDecimal("quantityLeftInActions"), new HashMap<ShoppingCartItem, BigDecimal>()); } } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Thu Jan 2 15:15:32 2014 @@ -22,6 +22,8 @@ import java.math.BigDecimal; import java.math.MathContext; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -51,6 +53,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.order.shoppingcart.CartItemModifyException; import org.ofbiz.order.shoppingcart.ShoppingCart; +import org.ofbiz.order.shoppingcart.ShoppingCart.ProductPromoUseInfo; import org.ofbiz.order.shoppingcart.ShoppingCartEvents; import org.ofbiz.order.shoppingcart.ShoppingCartItem; import org.ofbiz.product.product.ProductContentWrapper; @@ -318,44 +321,62 @@ public class ProductPromoWorker { // do a calculate only run through the promotions, then order by descending totalDiscountAmount for each promotion // NOTE: on this run, with isolatedTestRun passed as false it should not apply any adjustments // or track which cart items are used for which promotions, but it will track ProductPromoUseInfo and - // useLimits; we are basicly just trying to run each promo "independently" to see how much each is worth + // useLimits; we are basically just trying to run each promo "independently" to see how much each is worth runProductPromos(productPromoList, cart, delegator, dispatcher, nowTimestamp, true); - // NOTE: after that first pass we could remove any that have a 0 totalDiscountAmount from the run list, but we won't because by the time they are run the cart may have changed enough to get them to go; also, certain actions like free shipping should always be run even though we won't know what the totalDiscountAmount is at the time the promotion is run - // each ProductPromoUseInfo on the shopping cart will contain it's total value, so add up all totals for each promoId and put them in a List of Maps - // create a List of Maps with productPromo and totalDiscountAmount, use the Map sorter to sort them descending by totalDiscountAmount - - // before sorting split into two lists and sort each list; one list for promos that have a order total condition, and the other list for all promos that don't; then we'll always run the ones that have no condition on the order total first - List<Map<Object, Object>> productPromoDiscountMapList = FastList.newInstance(); - List<Map<Object, Object>> productPromoDiscountMapListOrderTotal = FastList.newInstance(); + // NOTE: we can easily recognize the promos for the order total: they are the ones with usage set to 0 + Iterator<ProductPromoUseInfo> promoUses = cart.getProductPromoUseInfoIter(); + List<ProductPromoUseInfo> sortedPromoUses = new ArrayList<ProductPromoUseInfo>(); + while (promoUses.hasNext()) { + ProductPromoUseInfo promoUse = promoUses.next(); + sortedPromoUses.add(promoUse); + } + Collections.sort(sortedPromoUses); + List<GenericValue> sortedExplodedProductPromoList = new ArrayList<GenericValue>(sortedPromoUses.size()); + Map<String, Long> usesPerPromo = new HashMap<String, Long>(); + int indexOfFirstOrderTotalPromo = -1; + for (ProductPromoUseInfo promoUse: sortedPromoUses) { + GenericValue productPromo = delegator.findOne("ProductPromo", UtilMisc.toMap("productPromoId", promoUse.getProductPromoId()), true); + GenericValue newProductPromo = (GenericValue)productPromo.clone(); + if (!usesPerPromo.containsKey(promoUse.getProductPromoId())) { + usesPerPromo.put(promoUse.getProductPromoId(), 0l); + } + long uses = usesPerPromo.get(promoUse.getProductPromoId()); + uses = uses + 1; + long useLimitPerOrder = (newProductPromo.get("useLimitPerOrder") != null? newProductPromo.getLong("useLimitPerOrder"): -1); + if (useLimitPerOrder == -1 || uses < useLimitPerOrder) { + newProductPromo.set("useLimitPerOrder", uses); + } + usesPerPromo.put(promoUse.getProductPromoId(), uses); + sortedExplodedProductPromoList.add(newProductPromo); + if (indexOfFirstOrderTotalPromo == -1 && BigDecimal.ZERO.equals(promoUse.getUsageWeight())) { + indexOfFirstOrderTotalPromo = sortedExplodedProductPromoList.size() - 1; + } + } + if (indexOfFirstOrderTotalPromo == -1) { + indexOfFirstOrderTotalPromo = sortedExplodedProductPromoList.size() - 1; + } + for (GenericValue productPromo : productPromoList) { Map<Object, Object> productPromoDiscountMap = UtilGenerics.checkMap(UtilMisc.toMap("productPromo", productPromo, "totalDiscountAmount", cart.getProductPromoUseTotalDiscount(productPromo.getString("productPromoId")))); if (hasOrderTotalCondition(productPromo, delegator)) { - productPromoDiscountMapListOrderTotal.add(productPromoDiscountMap); + if (!usesPerPromo.containsKey(productPromo.getString("productPromoId"))) { + sortedExplodedProductPromoList.add(productPromo); + } } else { - productPromoDiscountMapList.add(productPromoDiscountMap); + if (!usesPerPromo.containsKey(productPromo.getString("productPromoId"))) { + if (indexOfFirstOrderTotalPromo != -1) { + sortedExplodedProductPromoList.add(indexOfFirstOrderTotalPromo, productPromo); + } else { + sortedExplodedProductPromoList.add(0, productPromo); + } + } } } - - // sort the Map List, do it ascending because the discount amounts will be negative, so the lowest number is really the highest discount - productPromoDiscountMapList = UtilMisc.sortMaps(productPromoDiscountMapList, UtilMisc.toList("+totalDiscountAmount")); - productPromoDiscountMapListOrderTotal = UtilMisc.sortMaps(productPromoDiscountMapListOrderTotal, UtilMisc.toList("+totalDiscountAmount")); - - productPromoDiscountMapList.addAll(productPromoDiscountMapListOrderTotal); - - List<GenericValue> sortedProductPromoList = new ArrayList<GenericValue>(productPromoDiscountMapList.size()); - Iterator<Map<Object, Object>> productPromoDiscountMapIter = productPromoDiscountMapList.iterator(); - while (productPromoDiscountMapIter.hasNext()) { - Map<Object, Object> productPromoDiscountMap = UtilGenerics.checkMap(productPromoDiscountMapIter.next()); - GenericValue productPromo = (GenericValue) productPromoDiscountMap.get("productPromo"); - sortedProductPromoList.add(productPromo); - if (Debug.verboseOn()) Debug.logVerbose("Sorted Promo [" + productPromo.getString("productPromoId") + "] with total discount: " + productPromoDiscountMap.get("totalDiscountAmount"), module); - } - // okay, all ready, do the real run, clearing the temporary result first... cart.clearAllPromotionInformation(); - runProductPromos(sortedProductPromoList, cart, delegator, dispatcher, nowTimestamp, false); + runProductPromos(sortedExplodedProductPromoList, cart, delegator, dispatcher, nowTimestamp, false); } catch (NumberFormatException e) { Debug.logError(e, "Number not formatted correctly in promotion rules, not completed...", module); } catch (GenericEntityException e) { @@ -436,7 +457,7 @@ public class ProductPromoWorker { GenericValue productPromoCode = productPromoCodeIter.next(); String productPromoCodeId = productPromoCode.getString("productPromoCodeId"); Long codeUseLimit = getProductPromoCodeUseLimit(productPromoCode, partyId, delegator); - if (runProductPromoRules(cart, cartChanged, useLimit, true, productPromoCodeId, codeUseLimit, maxUseLimit, productPromo, productPromoRules, dispatcher, delegator, nowTimestamp)) { + if (runProductPromoRules(cart, useLimit, true, productPromoCodeId, codeUseLimit, maxUseLimit, productPromo, productPromoRules, dispatcher, delegator, nowTimestamp)) { cartChanged = true; } @@ -448,7 +469,7 @@ public class ProductPromoWorker { } } else { try { - if (runProductPromoRules(cart, cartChanged, useLimit, false, null, null, maxUseLimit, productPromo, productPromoRules, dispatcher, delegator, nowTimestamp)) { + if (runProductPromoRules(cart, useLimit, false, null, null, maxUseLimit, productPromo, productPromoRules, dispatcher, delegator, nowTimestamp)) { cartChanged = true; } } catch (RuntimeException e) { @@ -735,8 +756,10 @@ public class ProductPromoWorker { return promoDescBuf.toString(); } - protected static boolean runProductPromoRules(ShoppingCart cart, boolean cartChanged, Long useLimit, boolean requireCode, String productPromoCodeId, Long codeUseLimit, long maxUseLimit, + protected static boolean runProductPromoRules(ShoppingCart cart, Long useLimit, boolean requireCode, String productPromoCodeId, Long codeUseLimit, long maxUseLimit, GenericValue productPromo, List<GenericValue> productPromoRules, LocalDispatcher dispatcher, Delegator delegator, Timestamp nowTimestamp) throws GenericEntityException, UseLimitException { + boolean cartChanged = false; + Map<ShoppingCartItem,BigDecimal> usageInfoMap = prepareProductUsageInfoMap(cart); String productPromoId = productPromo.getString("productPromoId"); while ((useLimit == null || useLimit.longValue() > cart.getProductPromoUseCount(productPromoId)) && (!requireCode || UtilValidate.isNotEmpty(productPromoCodeId)) && @@ -755,17 +778,17 @@ public class ProductPromoWorker { // loop through conditions for rule, if any false, set allConditionsTrue to false List<GenericValue> productPromoConds = delegator.findByAnd("ProductPromoCond", UtilMisc.toMap("productPromoId", productPromo.get("productPromoId")), UtilMisc.toList("productPromoCondSeqId"), true); productPromoConds = EntityUtil.filterByAnd(productPromoConds, UtilMisc.toMap("productPromoRuleId", productPromoRule.get("productPromoRuleId"))); - // using the other method to consolodate cache entries because the same cache is used elsewhere: List productPromoConds = productPromoRule.getRelated("ProductPromoCond", null, UtilMisc.toList("productPromoCondSeqId"), true); + // using the other method to consolidate cache entries because the same cache is used elsewhere: List productPromoConds = productPromoRule.getRelated("ProductPromoCond", null, UtilMisc.toList("productPromoCondSeqId"), true); if (Debug.verboseOn()) Debug.logVerbose("Checking " + productPromoConds.size() + " conditions for rule " + productPromoRule, module); Iterator<GenericValue> productPromoCondIter = UtilMisc.toIterator(productPromoConds); while (productPromoCondIter != null && productPromoCondIter.hasNext()) { GenericValue productPromoCond = productPromoCondIter.next(); - boolean condResult = checkCondition(productPromoCond, cart, delegator, dispatcher, nowTimestamp); + boolean conditionSatisfied = checkCondition(productPromoCond, cart, delegator, dispatcher, nowTimestamp); // any false condition will cause it to NOT perform the action - if (condResult == false) { + if (!conditionSatisfied) { performActions = false; break; } @@ -797,13 +820,16 @@ public class ProductPromoWorker { } if (promoUsed) { - cart.addProductPromoUse(productPromo.getString("productPromoId"), productPromoCodeId, totalDiscountAmount, quantityLeftInActions); + // Get product use information from the cart + Map<ShoppingCartItem,BigDecimal> newUsageInfoMap = prepareProductUsageInfoMap(cart); + Map<ShoppingCartItem,BigDecimal> deltaUsageInfoMap = prepareDeltaProductUsageInfoMap(usageInfoMap, newUsageInfoMap); + usageInfoMap = newUsageInfoMap; + cart.addProductPromoUse(productPromo.getString("productPromoId"), productPromoCodeId, totalDiscountAmount, quantityLeftInActions, deltaUsageInfoMap); } else { // the promotion was not used, don't try again until we finish a full pass and come back to see the promo conditions are now satisfied based on changes to the cart break; } - if (cart.getProductPromoUseCount(productPromoId) > maxUseLimit) { throw new UseLimitException("ERROR: While calculating promotions the promotion [" + productPromoId + "] action was applied more than " + maxUseLimit + " times, so the calculation has been ended. This should generally never happen unless you have bad rule definitions."); } @@ -812,6 +838,34 @@ public class ProductPromoWorker { return cartChanged; } + private static Map<ShoppingCartItem,BigDecimal> prepareProductUsageInfoMap(ShoppingCart cart) { + Map<ShoppingCartItem,BigDecimal> usageInfoMap = new HashMap<ShoppingCartItem, BigDecimal>(); + List<ShoppingCartItem> lineOrderedByBasePriceList = cart.getLineListOrderedByBasePrice(false); + for (ShoppingCartItem cartItem : lineOrderedByBasePriceList) { + BigDecimal used = cartItem.getPromoQuantityUsed(); + if (used.compareTo(BigDecimal.ZERO) != 0) { + usageInfoMap.put(cartItem, used); + } + } + return usageInfoMap; + } + + private static Map<ShoppingCartItem,BigDecimal> prepareDeltaProductUsageInfoMap(Map<ShoppingCartItem,BigDecimal> oldMap, Map<ShoppingCartItem,BigDecimal> newMap) { + Map<ShoppingCartItem,BigDecimal> deltaUsageInfoMap = new HashMap<ShoppingCartItem, BigDecimal>(newMap); + Iterator<ShoppingCartItem> cartLines = oldMap.keySet().iterator(); + while (cartLines.hasNext()) { + ShoppingCartItem cartLine = cartLines.next(); + BigDecimal oldUsed = oldMap.get(cartLine); + BigDecimal newUsed = newMap.get(cartLine); + if (newUsed.compareTo(oldUsed) > 0) { + deltaUsageInfoMap.put(cartLine, newUsed.add(oldUsed.negate())); + } else { + deltaUsageInfoMap.remove(cartLine); + } + } + return deltaUsageInfoMap; + } + protected static boolean checkCondition(GenericValue productPromoCond, ShoppingCart cart, Delegator delegator, LocalDispatcher dispatcher, Timestamp nowTimestamp) throws GenericEntityException { String condValue = productPromoCond.getString("condValue"); String otherValue = productPromoCond.getString("otherValue"); @@ -1772,8 +1826,8 @@ public class ProductPromoWorker { actionResultInfo.ranAction = false; } + // in action, if doesn't have enough quantity to use the promo at all, remove candidate promo uses and increment promoQuantityUsed; this should go for all actions, if any action runs we confirm if (actionResultInfo.ranAction) { - // in action, if doesn't have enough quantity to use the promo at all, remove candidate promo uses and increment promoQuantityUsed; this should go for all actions, if any action runs we confirm cart.confirmPromoRuleUse(productPromoAction.getString("productPromoId"), productPromoAction.getString("productPromoRuleId")); } else { cart.resetPromoRuleUse(productPromoAction.getString("productPromoId"), productPromoAction.getString("productPromoRuleId")); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml Thu Jan 2 15:15:32 2014 @@ -128,13 +128,13 @@ under the License. <simple-method method-name="editGeoLocation" short-description="Edit GeoLocation"> <if-empty field="parameters.geoPointId"> <set field="createGeoPointMap.dataSourceId" value="GEOPT_GOOGLE"/> - <set field="createGeoPointMap.latitude" from-field="parameters.lat"/> - <set field="createGeoPointMap.longitude" from-field="parameters.lng"/> + <set field="createGeoPointMap.latitude" from-field="parameters.lat" type="Double" locale="en"/> + <set field="createGeoPointMap.longitude" from-field="parameters.lng" type="Double" locale="en"/> <call-service service-name="createGeoPoint" in-map-name="createGeoPointMap"> <result-to-field result-name="geoPointId" field="geoPointId"/> </call-service> - <now-timestamp field="nowTimestamp"/> + <now field="nowTimestamp"/> <make-value value-field="partyGeoPoint" entity-name="PartyGeoPoint"/> <set field="partyGeoPoint.partyId" from-field="parameters.partyId"/> <set field="partyGeoPoint.geoPointId" from-field="geoPointId"/> @@ -143,8 +143,8 @@ under the License. <else> <set field="updateGeoPointMap.geoPointId" from-field="parameters.geoPointId"/> <set field="updateGeoPointMap.dataSourceId" value="GEOPT_GOOGLE"/> - <set field="updateGeoPointMap.latitude" from-field="parameters.lat"/> - <set field="updateGeoPointMap.longitude" from-field="parameters.lng"/> + <set field="updateGeoPointMap.latitude" from-field="parameters.lat" type="Double" locale="en"/> + <set field="updateGeoPointMap.longitude" from-field="parameters.lng" type="Double" locale="en"/> <call-service service-name="updateGeoPoint" in-map-name="updateGeoPointMap"/> </else> </if-empty> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy Thu Jan 2 15:15:32 2014 @@ -23,14 +23,18 @@ import org.ofbiz.base.util.*; import org.ofbiz.base.util.string.*; import org.ofbiz.party.contact.ContactHelper; import org.ofbiz.common.geo.*; +import java.text.NumberFormat; if (partyId) { context.partyId = partyId; latestGeoPoint = GeoWorker.findLatestGeoPoint(delegator, "PartyAndGeoPoint", "partyId", partyId, null, null); if (latestGeoPoint) { context.geoPointId = latestGeoPoint.geoPointId; - context.latitude = latestGeoPoint.latitude; - context.longitude = latestGeoPoint.longitude; + NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH); + nf.setMinimumFractionDigits(5); + nf.setMaximumFractionDigits(10); + context.latitude = nf.format(latestGeoPoint.latitude); + context.longitude = nf.format(latestGeoPoint.longitude); } else { context.latitude = 0; context.longitude = 0; Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy Thu Jan 2 15:15:32 2014 @@ -23,15 +23,11 @@ postalAddressTemplateSuffix = context.po if (!postalAddressTemplateSuffix) { postalAddressTemplateSuffix = ".ftl"; } - +context.postalAddressTemplate = "PostalAddress" + postalAddressTemplateSuffix; if (postalAddressForTemplate && postalAddressForTemplate.countryGeoId) { postalAddressTemplate = "PostalAddress_" + postalAddressForTemplate.countryGeoId + postalAddressTemplateSuffix; file = new File(addressTemplatePath + postalAddressTemplate); if (file.exists()) { context.postalAddressTemplate = postalAddressTemplate; - } else { - context.postalAddressTemplate = "PostalAddress" + postalAddressTemplateSuffix; } } - -context.postalAddress = postalAddressForTemplate; Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/party/editGeoLocation.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/party/editGeoLocation.ftl?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/party/editGeoLocation.ftl (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/webapp/partymgr/party/editGeoLocation.ftl Thu Jan 2 15:15:32 2014 @@ -17,106 +17,117 @@ specific language governing permissions under the License. --> -<#assign defaultUrl = "https." + request.getServerName()> -<#assign defaultGogleMapKey = Static["org.ofbiz.base.util.UtilProperties"].getPropertyValue("general.properties", defaultUrl)> -<script src="http://maps.google.com/maps?file=api&v=2&key=${defaultGogleMapKey}" type="text/javascript"></script> +<script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script> <script type="text/javascript"> function load() { - if (GBrowserIsCompatible()) { - var map = new GMap2(document.getElementById("map")); - map.addControl(new GSmallMapControl()); - map.addControl(new GMapTypeControl()); - var center = new GLatLng(${latitude?if_exists}, ${longitude?if_exists}); - map.setCenter(center, 15); - geocoder = new GClientGeocoder(); - var marker = new GMarker(center, {draggable: true}); + var geocoder = new google.maps.Geocoder(); + var center = new google.maps.LatLng(${latitude!38}, ${longitude!15}); + var map = new google.maps.Map(document.getElementById("map"), + { center: center, + zoom: 15, // 0=World, 19=max zoom in + mapTypeId: google.maps.MapTypeId.ROADMAP + }); + + var marker = new google.maps.Marker({ + position: center, + map: map, + draggable: true + }); + + document.getElementById("lat").value = center.lat().toFixed(5); + document.getElementById("lng").value = center.lng().toFixed(5); + + google.maps.event.addListener(marker, "dragend", function() { + var point = marker.getPosition(); + map.panTo(point); + document.getElementById("lat").value = point.lat().toFixed(5); + document.getElementById("lng").value = point.lng().toFixed(5); + }); + + + google.maps.event.addListener(map, "moveend", function() { + map.clearOverlays(); + var center = map.getCenter(); + var marker = new GMarker(center, {draggable: true}); map.addOverlay(marker); document.getElementById("lat").value = center.lat().toFixed(5); document.getElementById("lng").value = center.lng().toFixed(5); - - GEvent.addListener(marker, "dragend", function() { - var point = marker.getPoint(); - map.panTo(point); - document.getElementById("lat").value = point.lat().toFixed(5); - document.getElementById("lng").value = point.lng().toFixed(5); - }); - - GEvent.addListener(map, "moveend", function() { - map.clearOverlays(); - var center = map.getCenter(); - var marker = new GMarker(center, {draggable: true}); - map.addOverlay(marker); - document.getElementById("lat").value = center.lat().toFixed(5); - document.getElementById("lng").value = center.lng().toFixed(5); + }); - GEvent.addListener(marker, "dragend", function() { - var point =marker.getPoint(); - map.panTo(point); - document.getElementById("lat").value = point.lat().toFixed(5); - document.getElementById("lng").value = point.lng().toFixed(5); - }); - }); - } + google.maps.event.addListener(marker, "dragend", function() { + var point = marker.getPoint(); + map.panTo(point); + document.getElementById("lat").value = point.lat().toFixed(5); + document.getElementById("lng").value = point.lng().toFixed(5); + }); } function showAddress(address) { - var map = new GMap2(document.getElementById("map")); - map.addControl(new GSmallMapControl()); - map.addControl(new GMapTypeControl()); + var map = new google.maps.Map(document.getElementById("map"), + { center: new google.maps.LatLng(${latitude!38}, ${longitude!15}), + zoom: 15, // 0=World, 19=max zoom in + mapTypeId: google.maps.MapTypeId.ROADMAP + }); + var geocoder = new google.maps.Geocoder(); if (geocoder) { - geocoder.getLatLng( - address, - function(point) { - if (!point) { - alert(address + " not found"); - } else { - document.getElementById("lat").value = point.lat().toFixed(5); - document.getElementById("lng").value = point.lng().toFixed(5); - map.clearOverlays() - map.setCenter(point, 14); - var marker = new GMarker(point, {draggable: true}); + geocoder.geocode({'address': address}, function(result, status) { + if (status != google.maps.GeocoderStatus.OK) { + showErrorAlert("${uiLabelMap.CommonErrorMessage2}","${uiLabelMap.CommonAddressNotFound}"); + } else { + var point = result[0].geometry.location; + var lat = point.lat().toFixed(5); + var lng = point.lng().toFixed(5); + document.getElementById("lat").value = lat; + document.getElementById("lng").value = lng; + //map.clearOverlays() + map.setCenter(point, 14); + + var marker = new google.maps.Marker({ + position: new google.maps.LatLng(lat, lng), + map: map, + draggable: true + }); + + google.maps.event.addListener(marker, "dragend", function() { + var point = marker.getPosition(); + map.panTo(point); + document.getElementById("lat").value = point.lat().toFixed(5); + document.getElementById("lng").value = point.lng().toFixed(5); + }); + + google.maps.event.addListener(map, "moveend", function() { + //map.clearOverlays(); + var center = map.getCenter(); + var marker = new google.maps.Marker(center, {draggable: true}); map.addOverlay(marker); - - GEvent.addListener(marker, "dragend", function() { - var pt = marker.getPoint(); - map.panTo(pt); - document.getElementById("lat").value = pt.lat().toFixed(5); - document.getElementById("lng").value = pt.lng().toFixed(5); - }); - - GEvent.addListener(map, "moveend", function() { - map.clearOverlays(); - var center = map.getCenter(); - var marker = new GMarker(center, {draggable: true}); - map.addOverlay(marker); - document.getElementById("lat").value = center.lat().toFixed(5); - document.getElementById("lng").value = center.lng().toFixed(5); - - GEvent.addListener(marker, "dragend", function() { - var pt = marker.getPoint(); - map.panTo(pt); - document.getElementById("lat").value = pt.lat().toFixed(5); - document.getElementById("lng").value = pt.lng().toFixed(5); - }); - }); - } - }); + document.getElementById("lat").value = center.lat().toFixed(5); + document.getElementById("lng").value = center.lng().toFixed(5); + }); + + google.maps.event.addListener(marker, "dragend", function() { + var pt = marker.getPoint(); + map.panTo(pt); + document.getElementById("lat").value = pt.lat().toFixed(5); + document.getElementById("lng").value = pt.lng().toFixed(5); + }); + } + }); } } </script> -<body onload="load()" onunload="GUnload()" > +<body onload="load()"> <center> <div align="center" id="map" style="border:1px solid #979797; background-color:#e5e3df; width:500px; height:450px; margin:2em auto;"><br/></div> <form action="#" onsubmit="showAddress(this.address.value); return false"> <input type="text" size="50" name="address"/> - <input type="submit" value="Search"/> + <input type="submit" value="${uiLabelMap.CommonSearch}"/> </form> <br/><br/> <form id="updateMapForm" method="post" action="<@ofbizUrl>editGeoLocation</@ofbizUrl>"> <input type="hidden" name="partyId" value="${partyId?if_exists}"/> <input type="hidden" name="geoPointId" value="${geoPointId?if_exists}"/> - <input type="hidden" name="lat" id="lat"/> + <input type="hidden" name="lat" id="lat"/> <input type="hidden" name="lng" id="lng"/> <input type="submit" id="createMapButton" class="smallSubmit" value="${uiLabelMap.CommonSubmit}"> </form> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/build.xml?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/build.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/build.xml Thu Jan 2 15:15:32 2014 @@ -910,12 +910,13 @@ under the License. </target> <target name="run-tests" - description="Run OFBiz default tests; you have to manually execute 'ant load-demo' before (and if needed even clear your data before) and see results in runtime/logs/test-results/html/all-tests.html."> + description="Run OFBiz default tests; you have to manually execute 'ant load-demo' before (and if needed even clear your data before) and see results in runtime/logs/test-results/html/all-tests.html. Use -Dportoffset=portNumber to shift all ports with the portNumber value."> <java jar="ofbiz.jar" fork="true" resultproperty="test.result"> <jvmarg value="${memory.initial.param}"/> <jvmarg value="${memory.max.param}"/> <jvmarg value="${memory.maxpermsize.param}"/> <arg value="test"/> + <arg value="-portoffset=${portoffset}"/> <env key="LC_ALL" value="C"/> </java> <mkdir dir="runtime/logs/test-results/html"/> @@ -1063,8 +1064,8 @@ under the License. </cobertura-report> </target> - <target name="cobertura-report-xml" - description="Generate a XML file from the cobertura report, this will be use by sonar"> + <target name="cobertura-report-xml" depends="_setup-separated-test-run" + description="Generate a XML file from the cobertura report, this will be used by sonar"> <delete dir="runtime/logs/cobertura-report"/> <mkdir dir="runtime/logs/cobertura-report"/> <taskdef resource="tasks.properties"> @@ -1136,7 +1137,10 @@ under the License. <target name="full-sonar"> <antcall target="clean-all"/> <antcall target="load-demo"/> - <antcall target="run-tests"/> + <antcall target="download-cobertura"/> + <antcall target="run-tests"> + <param name="-portoffset" value="${portoffset}"/> + </antcall> <antcall target="cobertura-report-xml"/> <antcall target="sonar"/> </target> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/config/general.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/config/general.properties?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/config/general.properties (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/config/general.properties Thu Jan 2 15:15:32 2014 @@ -128,13 +128,6 @@ http.upload.max.size=-1 mail.spam.name=X-Spam-Flag mail.spam.value=YES -# -- Google Map key (by domain, see http://code.google.com/intl/en/apis/maps/signup.html, note that it works for http://localhost) -https.demo-trunk.ofbiz.apache.org=ABQIAAAAtt0d8djaYFkk8N5LJVcDSBTl26GJHIFzHZYG8GNWSTKWDUTxchRLjgT9hY3-DDYk27lvZS84RH4aiQ -https.demo-stable.ofbiz.apache.org=ABQIAAAAtt0d8djaYFkk8N5LJVcDSBR8L_-1UdAfCE2bleqTaEvMtKARZxSrkTzKktKY2_Znm0TRq2DF4YhGPg - -https.localhost=ABQIAAAAtt0d8djaYFkk8N5LJVcDSBQN-clGH2vvMMwJjYtcwF78UzZgEBTN70S6uIgRoAtXRkADNoesbw5etg -http.localhost=ABQIAAAAtt0d8djaYFkk8N5LJVcDSBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxR3euHYk9bpwvdF2Qg1EYO1LQitHA - # -- Y if you want to display the multi-tenant textbox in the login page and install specify components which related to each tenant multitenant=N Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/webcommon/includes/geolocation.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/webcommon/includes/geolocation.ftl?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/webcommon/includes/geolocation.ftl (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/webcommon/includes/geolocation.ftl Thu Jan 2 15:15:32 2014 @@ -17,93 +17,111 @@ specific language governing permissions under the License. --> <#if geoChart?has_content> + <#-- ================================= Golbal Init ======================================--> + <#if geoChart.id?has_content> + <#assign id = geoChart.id> + <#else> + <#assign id = "map_canvas"> + </#if> + + <#if geoChart.center?has_content> + <#assign center = geoChart.center> + <#assign zoom = geoChart.center.zoom> + <#elseif geoChart.points?has_content> + <#assign center = geoChart.points[0]> + <#assign zoom = 15> <#-- 0=World, 19=max zoom in --> + <#else> + <#-- hardcoded in GEOPT_ADDRESS_GOOGLE, simpler --> + </#if> + + <#-- ================================= Google Maps Init ======================================--> <#if geoChart.dataSourceId?has_content> - <#if geoChart.dataSourceId == "GEOPT_GOOGLE"> - <div id="<#if geoChart.id?has_content>${geoChart.id}<#else>map_canvas</#if>" style="border:1px solid #979797; background-color:#e5e3df; width:${geoChart.width}; height:${geoChart.height}; margin:2em auto;"> + <#if geoChart.dataSourceId?substring(geoChart.dataSourceId?length-6 , geoChart.dataSourceId?length) == "GOOGLE"> + <div id="${id}" style="border:1px solid #979797; background-color:#e5e3df; width:${geoChart.width}; height:${geoChart.height}; margin:2em auto;"> <div style="padding:1em; color:gray;">${uiLabelMap.CommonLoading}</div> </div> - <#assign defaultUrl = "https." + request.getServerName()> - <#assign defaultGogleMapKey = Static["org.ofbiz.base.util.UtilProperties"].getPropertyValue("general.properties", defaultUrl)> - <script src="http://maps.google.com/maps?file=api&v=2&key=${defaultGogleMapKey}" type="text/javascript"></script> - <script type="text/javascript"><!-- - if (GBrowserIsCompatible()) { - var map = new GMap2(document.getElementById("<#if geoChart.id?has_content>${geoChart.id}<#else>map_canvas</#if>")); - <#if geoChart.center?has_content> - map.setCenter(new GLatLng(${geoChart.center.lat?c}, ${geoChart.center.lon?c}), ${geoChart.center.zoom}); - <#else> - <#if geoChart.points?has_content> - var latlng = [ - <#list geoChart.points as point> - new GLatLng(${point.lat?c}, ${point.lon?c})<#if point_has_next>,</#if> - </#list> - ]; - var latlngbounds = new GLatLngBounds(); - for (var i = 0; i < latlng.length; i++) { - latlngbounds.extend(latlng[i]); + <script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script> + </#if> + + <#-- ================================= Here we go with different types of maps renderer ======================================--> + <#if geoChart.dataSourceId == "GEOPT_GOOGLE"> + <script type="text/javascript"> + function showAllMarkers(map, points) { + if (points.length > 1) { + var latlngbounds = new google.maps.LatLngBounds(); + for (var i = 0; i < latlngs.length; i++) { + latlngbounds.extend(latlngs[i]); + } + map.fitBounds(latlngbounds); } - map.setCenter(latlngbounds.getCenter(), Math.min (15, map.getBoundsZoomLevel(latlngbounds)));//reduce bounds zoom level to see all markers - <#else> - map.setCenter(new GLatLng(0, 0), 1); - map.setZoom(15); // 0=World, 19=max zoom in - </#if> - </#if> - <#if geoChart.controlUI?has_content && geoChart.controlUI == "small"> - map.addControl(new GSmallMapControl()); - <#else> - map.setUIToDefault(); - </#if> + } + + var map = new google.maps.Map(document.getElementById("${id}"), <#if geoChart.points?has_content> + { center: new google.maps.LatLng(${center.lat?c}, ${center.lon?c}), + zoom: ${zoom}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }); + <#list geoChart.points as point> + var marker_${point_index} = new google.maps.Marker({ + position: new google.maps.LatLng(${point.lat?c}, ${point.lon?c}), + map: map + }); + <#if point.link?has_content> + var infoWindow = new google.maps.InfoWindow(); + google.maps.event.addListener(marker_${point_index}, "click", function() { + infoWindow.setContent(("<div style=\"width:210px; padding-right:10px;\"><a href=${point.link.url}>${point.link.label}</a></div>")); + infoWindow.setPosition(marker_${point_index}.getPosition()); + infoWindow.open(map); + }); + </#if> + </#list> + var latlngs = [ <#list geoChart.points as point> - var marker_${point_index} = new GMarker(new GLatLng(${point.lat?c}, ${point.lon?c})); - map.addOverlay(marker_${point_index}); - //map.addOverlay(new GMarker(new GLatLng(${point.lat?c}, ${point.lon?c}))); - <#if point.link?has_content> - GEvent.addListener(marker_${point_index}, "click", function() { - marker_${point_index}.openInfoWindowHtml("<div style=\"width:210px; padding-right:10px;\"><a href=${point.link.url}>${point.link.label}</a></div>"); - }); - </#if> + new google.maps.LatLng(${point.lat?c}, ${point.lon?c})<#if point_has_next>,</#if> </#list> + ]; + showAllMarkers(map, latlngs); </#if> - } - --></script> + </script> <#elseif geoChart.dataSourceId == "GEOPT_YAHOO"> <#elseif geoChart.dataSourceId == "GEOPT_MICROSOFT"> <#elseif geoChart.dataSourceId == "GEOPT_MAPTP"> <#elseif geoChart.dataSourceId == "GEOPT_ADDRESS_GOOGLE"> - <div id="<#if geoChart.id?has_content>${geoChart.id}<#else>map_canvas</#if>" style="border:1px solid #979797; background-color:#e5e3df; width:${geoChart.width}px; height:${geoChart.height}px; margin:2em auto;"> - <div style="padding:1em; color:gray;">${uiLabelMap.CommonLoading}</div> - </div> - <#assign defaultUrl = "https." + request.getServerName()> - <#assign defaultGogleMapKey = Static["org.ofbiz.base.util.UtilProperties"].getPropertyValue("general.properties", defaultUrl)> - <script src="http://maps.google.com/maps?file=api&v=2&key=${defaultGogleMapKey}" type="text/javascript"></script> - <script type="text/javascript"><!-- - if (GBrowserIsCompatible()) { - var geocoder = new GClientGeocoder(); - var map = new GMap2(document.getElementById("<#if geoChart.id?has_content>${geoChart.id}<#else>map_canvas</#if>")); - geocoder.getLatLng("${pointAddress}", function(point) { - if (!point) { showErrorAlert("${uiLabelMap.CommonErrorMessage2}","${uiLabelMap.CommonAddressNotFound}");} - map.setUIToDefault(); - map.setCenter(point, 13); - map.addOverlay(new GMarker(point)); - map.setZoom(15); // 0=World, 19=max zoom in + <script type="text/javascript"> + var geocoder = new google.maps.Geocoder(); + var map = new google.maps.Map(document.getElementById("${id}"), + { center: new google.maps.LatLng(38, 15), + zoom: 15, // 0=World, 19=max zoom in + mapTypeId: google.maps.MapTypeId.ROADMAP + }); + geocoder.geocode({'address': "${pointAddress}"}, function(result, status) { + if (status != google.maps.GeocoderStatus.OK) { + showErrorAlert("${uiLabelMap.CommonErrorMessage2}","${uiLabelMap.CommonAddressNotFound}"); + } else { + var position = result[0].geometry.location; + map.setCenter(position); + map.fitBounds(result[0].geometry.viewport); + var marker = new google.maps.Marker({ + position: position, + map: map + }); + } }); - } - --></script> + </script> <#elseif geoChart.dataSourceId == "GEOPT_OSM"> - <div id="<#if geoChart.id?has_content>${geoChart.id}<#else>map_canvas</#if>" style="border:1px solid #979797; background-color:#e5e3df; width:${geoChart.width}; height:${geoChart.height}; margin:2em auto;"> - </div> - <script src="http://www.openlayers.org/api/OpenLayers.js"></script> - <script> - map = new OpenLayers.Map("<#if geoChart.id?has_content>${geoChart.id}<#else>map_canvas</#if>"); + <div id="${id}" style="border:1px solid #979797; background-color:#e5e3df; width:${geoChart.width}; height:${geoChart.height}; margin:2em auto;"></div> + <#-- due to https://github.com/openlayers/openlayers/issues/1025 rather use a local version loaded by framework/common/widget/CommonScreens.xml --> + <#-- script src="//www.openlayers.org/api/OpenLayers.js"></script--> + <script type="text/javascript"> + map = new OpenLayers.Map("${id}"); map.addLayer(new OpenLayers.Layer.OSM()); - <#if geoChart.center?has_content> - var zoom = ${geoChart.center.zoom}; - var center= new OpenLayers.LonLat(${geoChart.center.lon?c},${geoChart.center.lat?c}) + var zoom = ${zoom}; + var center= new OpenLayers.LonLat(${center.lon?c},${center.lat?c}) .transform(new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984 - map.getProjectionObject() // to Spherical Mercator Projection - ); - </#if> - var markers = new OpenLayers.Layer.Markers( "Markers" ); + map.getProjectionObject() // to Spherical Mercator Projection + ); + var markers = new OpenLayers.Layer.Markers("Markers"); map.addLayer(markers); <#if geoChart.points?has_content> <#list geoChart.points as point> @@ -111,8 +129,12 @@ under the License. new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))); </#list> </#if> + map.addControl(new OpenLayers.Control.PanZoomBar()); + map.addControl(new OpenLayers.Control.NavToolbar()); + map.setCenter(center, zoom); - map.setZoom(15); // 0=World, 19=max zoom in + var newBound = markers.getDataExtent(); + map.zoomToExtent(newBound); </script> </#if> </#if> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/widget/CommonScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/widget/CommonScreens.xml?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/widget/CommonScreens.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/common/widget/CommonScreens.xml Thu Jan 2 15:15:32 2014 @@ -153,6 +153,8 @@ under the License. <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/jquery-1.8.2.min.js" global="true" /> <!-- jQuery CSSs --> <set field="layoutSettings.styleSheets[+0]" value="/images/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.css" global="true" /> + + <set field="layoutSettings.javaScripts[]" value="/images/OpenLayers-2.13.1.js" global="true" /> <set field="layoutSettings.javaScripts[]" value="/images/selectall.js" global="true" /> <set field="layoutSettings.javaScripts[]" value="/images/fieldlookup.js" global="true" /> <set field="layoutSettings.javaScripts[]" value="/images/GooglemapMarkers.js" global="true" /> @@ -483,8 +485,7 @@ under the License. <!-- jQuery CSSs --> <set field="layoutSettings.styleSheets[+0]" value="/images/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.css" global="true"/> - - + <set field="layoutSettings.javaScripts[]" value="/images/OpenLayers-2.13.1.js" global="true" /> <set field="layoutSettings.javaScripts[]" value="/images/selectall.js" global="true"/> <set field="layoutSettings.javaScripts[]" value="/images/fieldlookup.js" global="true"/> <set field="layoutSettings.javaScripts[]" value="/images/GooglemapSimple.js" global="true"/> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/dtd/simple-methods-v2.xsd URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/dtd/simple-methods-v2.xsd?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/dtd/simple-methods-v2.xsd (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/dtd/simple-methods-v2.xsd Thu Jan 2 15:15:32 2014 @@ -1218,6 +1218,16 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> + <xs:attribute type="xs:string" name="locale"> + <xs:annotation> + <xs:documentation> + A locale value (eg: en). The locale allows to pass values whose types are locale dependent (like Float, etc.). + Defaults to the environment locale. Works only if a type which makes sense is also passed. + + Optional. Attribute types: constant, ${expression}. + </xs:documentation> + </xs:annotation> + </xs:attribute> <xs:attribute name="set-if-null" type="booleanConst"> <xs:annotation> <xs:documentation> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/method/MethodContext.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/method/MethodContext.java?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/method/MethodContext.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/method/MethodContext.java Thu Jan 2 15:15:32 2014 @@ -183,6 +183,10 @@ public final class MethodContext { return this.locale; } + public void setLocale(Locale locale) { + this.locale = locale; + } + public int getMethodType() { return this.methodType; } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java Thu Jan 2 15:15:32 2014 @@ -20,6 +20,7 @@ package org.ofbiz.minilang.method.envops import java.util.HashMap; import java.util.LinkedList; +import java.util.Locale; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; @@ -76,6 +77,7 @@ public final class SetOperation extends private final FlexibleStringExpander defaultFse; private final FlexibleStringExpander formatFse; + private final FlexibleStringExpander localeFse; private final FlexibleMapAccessor<Object> fieldFma; private final FlexibleMapAccessor<Object> fromFma; private final Scriptlet scriptlet; @@ -90,7 +92,7 @@ public final class SetOperation extends if (MiniLangValidate.validationOn()) { MiniLangValidate.deprecatedAttribute(simpleMethod, element, "from-field", "replace with \"from\""); MiniLangValidate.deprecatedAttribute(simpleMethod, element, "default-value", "replace with \"default\""); - MiniLangValidate.attributeNames(simpleMethod, element, "field", "from-field", "from", "value", "default-value", "default", "format", "type", "set-if-null", "set-if-empty"); + MiniLangValidate.attributeNames(simpleMethod, element, "field", "from-field", "from", "value", "default-value", "default", "format", "type", "set-if-null", "set-if-empty", "locale"); MiniLangValidate.requiredAttributes(simpleMethod, element, "field"); MiniLangValidate.requireAnyAttribute(simpleMethod, element, "from-field", "from", "value"); MiniLangValidate.constantPlusExpressionAttributes(simpleMethod, element, "value"); @@ -114,6 +116,7 @@ public final class SetOperation extends this.valueFse = FlexibleStringExpander.getInstance(element.getAttribute("value")); this.defaultFse = FlexibleStringExpander.getInstance(element.getAttribute("default")); this.formatFse = FlexibleStringExpander.getInstance(element.getAttribute("format")); + this.localeFse = FlexibleStringExpander.getInstance(element.getAttribute("locale")); this.type = element.getAttribute("type"); Class<?> targetClass = null; if (!this.type.isEmpty() && !"NewList".equals(this.type) && !"NewMap".equals(this.type)) { @@ -141,7 +144,15 @@ public final class SetOperation extends Debug.logWarning(exc, "Error evaluating scriptlet [" + this.scriptlet + "]: " + exc, module); } } else if (!this.fromFma.isEmpty()) { - newValue = this.fromFma.get(methodContext.getEnvMap()); + Locale localeTemp = null; // FIXME this is a temporary hack waiting for a better geolocation data model, related with OFBIZ-5453 + if (!this.localeFse.isEmpty() && this.type.length() > 0) { + localeTemp = methodContext.getLocale(); + methodContext.setLocale(new Locale(this.localeFse.expandString(methodContext.getEnvMap()))); + newValue = this.fromFma.get(methodContext.getEnvMap()); + methodContext.setLocale(localeTemp); + } else { + newValue = this.fromFma.get(methodContext.getEnvMap()); + } if (Debug.verboseOn()) Debug.logVerbose("In screen getting value for field from [" + this.fromFma.toString() + "]: " + newValue, module); } else if (!this.valueFse.isEmpty()) { @@ -176,7 +187,12 @@ public final class SetOperation extends if (targetClass == null) { targetClass = MiniLangUtil.getObjectClassForConversion(newValue); } - newValue = MiniLangUtil.convertType(newValue, targetClass, methodContext.getLocale(), methodContext.getTimeZone(), format); + if (!this.localeFse.isEmpty() && this.type.length() > 0) {// FIXME this is a temporary hack waiting for a better geolocation data model, related with OFBIZ-5453 + Locale localeTemp = new Locale(this.localeFse.expandString(methodContext.getEnvMap())); + newValue = MiniLangUtil.convertType(newValue, targetClass, localeTemp, methodContext.getTimeZone(), format); + } else { + newValue = MiniLangUtil.convertType(newValue, targetClass, methodContext.getLocale(), methodContext.getTimeZone(), format); + } } catch (Exception e) { String errMsg = "Could not convert field value for the field: [" + this.fieldFma.toString() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.getMessage(); Debug.logWarning(e, errMsg, module); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/dtd/widget-form.xsd URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/dtd/widget-form.xsd?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/dtd/widget-form.xsd (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/dtd/widget-form.xsd Thu Jan 2 15:15:32 2014 @@ -1908,6 +1908,16 @@ under the License. </xs:restriction> </xs:simpleType> </xs:attribute> + <xs:attribute type="xs:string" name="locale"> + <xs:annotation> + <xs:documentation> + A locale value (eg: en). The locale allows to pass values with types which are locale dependent (like Float, etc.). + Defaults to the environment locale. Works only if a type which makes sense is also passed. + + Optional. Attribute types: constant, ${expression}. + </xs:documentation> + </xs:annotation> + </xs:attribute> </xs:complexType> </xs:element> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/dtd/widget-screen.xsd URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/dtd/widget-screen.xsd?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/dtd/widget-screen.xsd (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/dtd/widget-screen.xsd Thu Jan 2 15:15:32 2014 @@ -346,6 +346,16 @@ under the License. </xs:restriction> </xs:simpleType> </xs:attribute> + <xs:attribute type="xs:string" name="locale"> + <xs:annotation> + <xs:documentation> + A locale value (eg: en). The locale allows to pass values with types which are locale dependent (like Float, etc.). + Defaults to the environment locale. Works only if a type which makes sense is also passed. + + Optional. Attribute types: constant, ${expression}. + </xs:documentation> + </xs:annotation> + </xs:attribute> </xs:complexType> </xs:element> <xs:element name="property-map" substitutionGroup="AllActions"> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java Thu Jan 2 15:15:32 2014 @@ -33,7 +33,6 @@ import javax.servlet.http.HttpSession; import javolution.util.FastList; import javolution.util.FastMap; -import org.w3c.dom.Element; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; @@ -59,6 +58,7 @@ import org.ofbiz.minilang.method.MethodC import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.ModelService; +import org.w3c.dom.Element; @SuppressWarnings("serial") public abstract class ModelWidgetAction implements Serializable { @@ -121,6 +121,7 @@ public abstract class ModelWidgetAction protected FlexibleStringExpander valueExdr; protected FlexibleStringExpander defaultExdr; protected FlexibleStringExpander globalExdr; + protected FlexibleStringExpander localeExdr; protected String type; protected String toScope; protected String fromScope; @@ -132,6 +133,7 @@ public abstract class ModelWidgetAction this.valueExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("value")); this.defaultExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("default-value")); this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global")); + this.localeExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("locale")); this.type = setElement.getAttribute("type"); this.toScope = setElement.getAttribute("to-scope"); this.fromScope = setElement.getAttribute("from-scope"); @@ -184,7 +186,11 @@ public abstract class ModelWidgetAction newValue = FastList.newInstance(); } else { try { - newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); + Locale locale = (Locale) context.get("locale"); + if (!this.localeExdr.isEmpty()) { + locale = new Locale(this.globalExdr.expandString(context)); + } + newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), locale, true); } catch (GeneralException e) { String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); Debug.logError(e, errMsg, module); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=1554827&r1=1554826&r2=1554827&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java Thu Jan 2 15:15:32 2014 @@ -116,6 +116,7 @@ public abstract class ModelFormAction { protected FlexibleStringExpander valueExdr; protected FlexibleStringExpander defaultExdr; protected FlexibleStringExpander globalExdr; + protected FlexibleStringExpander localeExdr; protected String type; public SetField(ModelForm modelForm, Element setElement) { @@ -125,6 +126,7 @@ public abstract class ModelFormAction { this.valueExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("value")); this.defaultExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("default-value")); this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global")); + this.localeExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("locale")); this.type = setElement.getAttribute("type"); if (!this.fromField.isEmpty() && !this.valueExdr.isEmpty()) { throw new IllegalArgumentException("Cannot specify a from-field [" + setElement.getAttribute("from-field") + "] and a value [" + setElement.getAttribute("value") + "] on the set action in a screen widget"); @@ -157,7 +159,11 @@ public abstract class ModelFormAction { newValue = FastList.newInstance(); } else { try { - newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); + Locale locale = (Locale) context.get("locale"); + if (!this.localeExdr.isEmpty()) { + locale = new Locale(this.globalExdr.expandString(context)); + } + newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), locale, true); } catch (GeneralException e) { String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); Debug.logError(e, errMsg, module); |
Free forum by Nabble | Edit this page |