This is an automated email from the ASF dual-hosted git repository.
surajk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/trunk by this push: new c6399ef Improved: Corrected some line is longer than 150 characters checkstyle issues in applications component. Also fixed some extra spaces and naming conventions related checkstyle issues. (OFBIZ-11921) c6399ef is described below commit c6399ef668f24606e3a5cd7c76a666e09fd5aaaf Author: Suraj Khurana <[hidden email]> AuthorDate: Mon Aug 3 10:14:20 2020 +0530 Improved: Corrected some line is longer than 150 characters checkstyle issues in applications component. Also fixed some extra spaces and naming conventions related checkstyle issues. (OFBIZ-11921) --- .../java/org/apache/ofbiz/accounting/GlEvents.java | 4 +- .../finaccount/FinAccountPaymentServices.java | 4 +- .../finaccount/FinAccountProductServices.java | 4 +- .../ofbiz/accounting/invoice/InvoiceServices.java | 52 +- .../payment/GiftCertificateServices.java | 69 +- .../accounting/payment/PaymentGatewayServices.java | 116 +-- .../accounting/payment/PaymentMethodServices.java | 12 +- .../ofbiz/accounting/payment/PaymentWorker.java | 4 +- .../authorizedotnet/AIMPaymentServices.java | 4 +- .../clearcommerce/CCPaymentServices.java | 2 +- .../accounting/thirdparty/eway/EwayServices.java | 4 +- .../thirdparty/eway/GatewayConnector.java | 4 +- .../thirdparty/eway/GatewayResponse.java | 2 +- .../accounting/thirdparty/paypal/PayPalEvents.java | 10 +- .../thirdparty/paypal/PayPalServices.java | 12 +- .../thirdparty/sagepay/SagePayPaymentServices.java | 2 +- .../securepay/SecurePayPaymentServices.java | 2 +- .../thirdparty/securepay/SecurePayServiceTest.java | 8 +- .../thirdparty/valuelink/ValueLinkServices.java | 6 +- .../accounting/thirdparty/verisign/PayflowPro.java | 6 +- .../thirdparty/worldpay/WorldPayEvents.java | 4 +- .../ofbiz/accounting/util/UtilAccounting.java | 4 +- .../ofbiz/content/ContentManagementEvents.java | 12 +- .../java/org/apache/ofbiz/content/ConvertTree.java | 2 +- .../apache/ofbiz/content/blog/BlogRssServices.java | 2 +- .../ofbiz/content/compdoc/CompDocEvents.java | 6 +- .../ofbiz/content/compdoc/CompDocServices.java | 41 +- .../content/content/ContentPermissionServices.java | 2 +- .../ofbiz/content/content/ContentSearch.java | 2 +- .../content/content/ContentServicesComplex.java | 7 +- .../ofbiz/content/content/ContentUrlFilter.java | 4 +- .../ofbiz/content/content/ContentWorker.java | 4 +- .../content/content/UploadContentAndImage.java | 4 +- .../org/apache/ofbiz/content/data/DataEvents.java | 6 +- .../ofbiz/content/data/DataResourceWorker.java | 4 +- .../apache/ofbiz/content/layout/LayoutEvents.java | 37 +- .../apache/ofbiz/content/layout/LayoutWorker.java | 8 +- .../ofbiz/content/output/OutputServices.java | 2 +- .../webapp/ftl/OfbizContentAltUrlTransforms.java | 2 +- .../org/apache/ofbiz/humanres/HumanResEvents.java | 4 +- .../apache/ofbiz/manufacturing/bom/BOMNode.java | 2 +- .../ofbiz/manufacturing/bom/BOMServices.java | 22 +- .../jobshopmgt/ProductionRunServices.java | 16 +- .../ofbiz/manufacturing/mrp/ProposedOrder.java | 2 +- .../marketing/tracking/TrackingCodeEvents.java | 89 ++- .../java/org/apache/ofbiz/sfa/vcard/VCard.java | 2 +- .../org/apache/ofbiz/order/OrderManagerEvents.java | 4 +- .../apache/ofbiz/order/order/OrderReadHelper.java | 8 +- .../ofbiz/order/order/OrderReturnServices.java | 16 +- .../apache/ofbiz/order/order/OrderServices.java | 788 +++++++++++++-------- .../apache/ofbiz/order/quote/QuoteServices.java | 10 +- .../order/requirement/RequirementServices.java | 73 +- .../ofbiz/order/shoppingcart/CheckOutHelper.java | 47 +- .../ofbiz/order/shoppingcart/ShoppingCart.java | 554 ++++++++++----- .../order/shoppingcart/ShoppingCartEvents.java | 8 +- .../ofbiz/order/shoppingcart/ShoppingCartItem.java | 9 +- .../order/shoppingcart/ShoppingCartServices.java | 183 +++-- .../ofbiz/order/shoppingcart/WebShoppingCart.java | 18 +- .../shoppingcart/product/ProductPromoWorker.java | 100 +-- .../shoppingcart/shipping/ShippingEvents.java | 109 +-- .../order/shoppinglist/ShoppingListEvents.java | 62 +- .../order/shoppinglist/ShoppingListServices.java | 52 +- .../apache/ofbiz/order/test/OrderTestServices.java | 2 +- .../apache/ofbiz/order/test/SalesOrderTest.java | 44 +- .../thirdparty/zipsales/ZipSalesServices.java | 66 +- .../communication/CommunicationEventServices.java | 6 +- .../ofbiz/party/content/PartyContentWrapper.java | 8 +- .../product/category/CatalogUrlDirective.java | 2 +- .../ofbiz/product/category/CatalogUrlFilter.java | 6 +- .../product/category/CatalogUrlSeoFilter.java | 2 +- .../ofbiz/product/category/CategoryServices.java | 6 +- .../product/category/SeoContentUrlFilter.java | 2 +- .../category/ftl/OfbizCatalogAltUrlTransform.java | 2 +- .../category/ftl/OfbizCatalogUrlTransform.java | 2 +- .../ofbiz/product/config/ProductConfigWrapper.java | 6 +- .../ofbiz/product/inventory/InventoryServices.java | 4 +- .../ofbiz/product/inventory/InventoryWorker.java | 2 +- .../apache/ofbiz/product/price/PriceServices.java | 2 +- .../ofbiz/product/product/ProductEvents.java | 2 +- .../ofbiz/product/product/ProductServices.java | 8 +- .../apache/ofbiz/product/promo/PromoServices.java | 4 +- .../ofbiz/product/store/ProductStoreEvents.java | 2 +- .../product/subscription/SubscriptionServices.java | 6 +- .../ofbiz/shipment/packing/PackingSession.java | 4 +- .../ofbiz/shipment/shipment/ShipmentServices.java | 26 +- .../ofbiz/shipment/thirdparty/dhl/DhlServices.java | 50 +- .../shipment/thirdparty/fedex/FedexServices.java | 54 +- .../ofbiz/shipment/thirdparty/ups/UpsServices.java | 162 ++--- .../shipment/thirdparty/usps/UspsServices.java | 108 +-- .../content/WorkEffortContentWrapper.java | 8 +- .../ofbiz/workeffort/workeffort/ICalConverter.java | 8 +- .../ofbiz/workeffort/workeffort/ICalWorker.java | 4 +- 92 files changed, 1940 insertions(+), 1326 deletions(-) diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/GlEvents.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/GlEvents.java index 232ffc0..f9bf132 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/GlEvents.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/GlEvents.java @@ -82,8 +82,8 @@ public class GlEvents { } } - Map<String, Object> fieldMap = UtilMisc.toMap("glReconciliationName", "Reconciliation at date " + UtilDateTime.nowTimestamp(), "glAccountId" - , glAccountId, "organizationPartyId", organizationPartyId, "reconciledDate", UtilDateTime.nowTimestamp(), "reconciledBalance", + Map<String, Object> fieldMap = UtilMisc.toMap("glReconciliationName", "Reconciliation at date " + UtilDateTime.nowTimestamp(), "glAccountId", + glAccountId, "organizationPartyId", organizationPartyId, "reconciledDate", UtilDateTime.nowTimestamp(), "reconciledBalance", reconciledBalance, "userLogin", userLogin); Map<String, Object> glReconResult = null; try { diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java index dca9894..36ff3c6 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountPaymentServices.java @@ -363,8 +363,8 @@ public class FinAccountPaymentServices { Debug.logError(e, MODULE); return ServiceUtil.returnError(e.getMessage()); } - Debug.logInfo("Financial account capture [" + finAccountAuth.get("finAccountId") + "] for the amount of $" + - amount + " Tx #" + finAccountAuth.get("finAccountAuthId"), MODULE); + Debug.logInfo("Financial account capture [" + finAccountAuth.get("finAccountId") + "] for the amount of $" + + amount + " Tx #" + finAccountAuth.get("finAccountAuthId"), MODULE); // get the financial account GenericValue finAccount; diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountProductServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountProductServices.java index d5c378d..40450d3 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountProductServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/finaccount/FinAccountProductServices.java @@ -51,7 +51,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class FinAccountProductServices { private static final String MODULE = FinAccountProductServices.class.getName(); - private static final String RES_ORDERError = "OrderErrorUiLabels"; + private static final String RES_ORDER_ERROR = "OrderErrorUiLabels"; private static final String RES_ERROR = "AccountingErrorUiLabels"; public static Map<String, Object> createPartyFinAccountFromPurchase(DispatchContext dctx, Map<String, Object> context) { @@ -72,7 +72,7 @@ public class FinAccountProductServices { orderHeader = orderItem.getRelatedOne("OrderHeader", false); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get OrderHeader from OrderItem", MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderCannotGetOrderHeader", UtilMisc.toMap("orderId", orderId), locale)); } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java index 198c58f..16b0743 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java @@ -730,8 +730,8 @@ public class InvoiceServices { BigDecimal thisAdjAmount = amount; // adjustments only apply to totals when they are not tax or shipping adjustments - if (!"SALES_TAX".equals(adj.getString("orderAdjustmentTypeId")) && - !"SHIPPING_ADJUSTMENT".equals(adj.getString("orderAdjustmentTypeId"))) { + if (!"SALES_TAX".equals(adj.getString("orderAdjustmentTypeId")) + && !"SHIPPING_ADJUSTMENT".equals(adj.getString("orderAdjustmentTypeId"))) { // increment the invoice subtotal invoiceSubTotal = invoiceSubTotal.add(thisAdjAmount).setScale(100, ROUNDING); @@ -958,8 +958,8 @@ public class InvoiceServices { List<String> salesRepPartyIds = UtilGenerics.cast(context.get("partyIds")); BigDecimal amountTotal = InvoiceWorker.getInvoiceTotal(delegator, salesInvoiceId); if (amountTotal.signum() == 0) { - Debug.logWarning("Invoice [" + salesInvoiceId + "] has an amount total of [" + amountTotal + "], so no commission invoice will be " + - "created", MODULE); + Debug.logWarning("Invoice [" + salesInvoiceId + "] has an amount total of [" + amountTotal + "], so no commission invoice will be " + + "created", MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingInvoiceCommissionZeroInvoiceAmount", locale)); } @@ -1176,8 +1176,8 @@ public class InvoiceServices { Map<String, Object> result = ServiceUtil.returnSuccess(UtilProperties.getMessage(RESOURCE, "AccountingCommissionInvoicesCreated", UtilMisc.toMap("invoicesCreated", invCreated), locale)); - Debug.logInfo("Created Commission invoices for each commission receiving parties " + - invCreated, MODULE); + Debug.logInfo("Created Commission invoices for each commission receiving parties " + + invCreated, MODULE); result.put("invoicesCreated", invoicesCreated); return result; } @@ -2705,18 +2705,18 @@ public class InvoiceServices { List<String> errorMessageList = new LinkedList<>(); if (debug) { - Debug.logInfo("updatePaymentApplicationDefBd input parameters..." + - " defaultInvoiceProcessing: " + defaultInvoiceProcessing + - " changeDefaultInvoiceProcessing: " + changeProcessing + - " useHighestAmount: " + useHighestAmount + - " paymentApplicationId: " + paymentApplicationId + - " PaymentId: " + paymentId + - " InvoiceId: " + invoiceId + - " InvoiceItemSeqId: " + invoiceItemSeqId + - " BillingAccountId: " + billingAccountId + - " toPaymentId: " + toPaymentId + - " amountApplied: " + amountApplied + - " TaxAuthGeoId: " + taxAuthGeoId, MODULE); + Debug.logInfo("updatePaymentApplicationDefBd input parameters..." + + " defaultInvoiceProcessing: " + defaultInvoiceProcessing + + " changeDefaultInvoiceProcessing: " + changeProcessing + + " useHighestAmount: " + useHighestAmount + + " paymentApplicationId: " + paymentApplicationId + + " PaymentId: " + paymentId + + " InvoiceId: " + invoiceId + + " InvoiceItemSeqId: " + invoiceItemSeqId + + " BillingAccountId: " + billingAccountId + + " toPaymentId: " + toPaymentId + + " amountApplied: " + amountApplied + + " TaxAuthGeoId: " + taxAuthGeoId, MODULE); } if (changeProcessing == null) { @@ -2892,8 +2892,8 @@ public class InvoiceServices { return ServiceUtil.returnError(errorMessageList); } // check the currency - if (billingAccount.get("accountCurrencyUomId") != null && currencyUomId != null && - !billingAccount.getString("accountCurrencyUomId").equals(currencyUomId)) { + if (billingAccount.get("accountCurrencyUomId") != null && currencyUomId != null + && !billingAccount.getString("accountCurrencyUomId").equals(currencyUomId)) { errorMessageList.add(UtilProperties.getMessage(RESOURCE, "AccountingBillingAccountCurrencyProblem", UtilMisc.toMap("billingAccountId", billingAccountId, "accountCurrencyUomId", billingAccount.getString("accountCurrencyUomId"), @@ -2930,8 +2930,8 @@ public class InvoiceServices { } // check the currency - if (currencyUomId != null && invoice.get("currencyUomId") != null && - !currencyUomId.equals(invoice.getString("currencyUomId"))) { + if (currencyUomId != null && invoice.get("currencyUomId") != null + && !currencyUomId.equals(invoice.getString("currencyUomId"))) { Debug.logInfo(UtilProperties.getMessage(RESOURCE, "AccountingInvoicePaymentCurrencyProblem", UtilMisc.toMap("invoiceCurrency", invoice.getString("currencyUomId"), "paymentCurrency", payment.getString( "currencyUomId")), locale), MODULE); @@ -3019,8 +3019,8 @@ public class InvoiceServices { // check here for too much application if a new record is added if (paymentApplicationId == null && amountApplied.compareTo(invoiceItemApplyAvailable) > 0) { // new record - errorMessageList.add("Invoice(" + invoiceId + ") item(" + invoiceItemSeqId + ") has " + invoiceItemApplyAvailable + " to " + - "apply but " + amountApplied + " is requested\n"); + errorMessageList.add("Invoice(" + invoiceId + ") item(" + invoiceItemSeqId + ") has " + invoiceItemApplyAvailable + " to " + + "apply but " + amountApplied + " is requested\n"); String uomId = invoice.getString("currencyUomId"); errorMessageList.add(UtilProperties.getMessage(RESOURCE, "AccountingInvoiceItemLessRequested", UtilMisc.<String, Object>toMap("invoiceId", invoiceId, "invoiceItemSeqId", invoiceItemSeqId, @@ -3261,8 +3261,8 @@ public class InvoiceServices { } } if (toPaymentId != null) { - Debug.logInfo(" toPayment(" + toPaymentId + ") amount not yet applied: " + newToPaymentApplyAvailable + " Payment(" + paymentId + - ") amount not yet applied: " + newPaymentApplyAvailable + " Requested amount to apply:" + amountApplied, MODULE); + Debug.logInfo(" toPayment(" + toPaymentId + ") amount not yet applied: " + newToPaymentApplyAvailable + " Payment(" + paymentId + + ") amount not yet applied: " + newPaymentApplyAvailable + " Requested amount to apply:" + amountApplied, MODULE); toMessage = UtilProperties.getMessage(RESOURCE, "AccountingApplicationToPayment", UtilMisc.toMap("paymentId", toPaymentId), locale); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java index d6be139..f281a59 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/GiftCertificateServices.java @@ -51,7 +51,7 @@ public class GiftCertificateServices { private static final String MODULE = GiftCertificateServices.class.getName(); private static final String RES_ERROR = "AccountingErrorUiLabels"; - private static final String RES_ORDERError = "OrderErrorUiLabels"; + private static final String RES_ORDER_ERROR = "OrderErrorUiLabels"; // These are default settings, in case ProductStoreFinActSetting does not have them public static final int CARD_NUMBER_LENGTH = 14; public static final int PIN_NUMBER_LENGTH = 6; @@ -138,7 +138,7 @@ public class GiftCertificateServices { // do something tricky here: run as the "system" user // that can actually create a financial account transaction GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); - refNum = createTransaction(delegator, dispatcher, permUserLogin, initialAmount, productStoreId, + refNum = createTransaction(delegator, dispatcher, permUserLogin, initialAmount, productStoreId, partyId, currencyUom, deposit, finAccountId, locale, orderId); } catch (GenericEntityException | GenericServiceException e) { @@ -203,8 +203,8 @@ public class GiftCertificateServices { } } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "AccountingFinAccountSetting", - UtilMisc.toMap("productStoreId", productStoreId, + "AccountingFinAccountSetting", + UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.getGiftCertFinAccountTypeId()), locale)); } @@ -290,8 +290,8 @@ public class GiftCertificateServices { } } catch (GenericEntityException ex) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "AccountingFinAccountSetting", - UtilMisc.toMap("productStoreId", productStoreId, + "AccountingFinAccountSetting", + UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.getGiftCertFinAccountTypeId()), locale)); } Debug.logInfo("Attempting to redeem GC for " + amount, MODULE); @@ -402,7 +402,7 @@ public class GiftCertificateServices { Timestamp authExpiration = finAccountAuth.getTimestamp("thruDate"); if ((authExpiration != null) && (authExpiration.before(UtilDateTime.nowTimestamp()))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "AccountingFinAccountAuthorizationExpired", + "AccountingFinAccountAuthorizationExpired", UtilMisc.toMap("paymentGatewayResponseId", authTransaction.getString("paymentGatewayResponseId"), "authExpiration", authExpiration), locale)); } @@ -436,7 +436,7 @@ public class GiftCertificateServices { } // now release the authorization should this use the gift card release service? - Map<String, Object> releaseResult = dispatcher.runSync("expireFinAccountAuth", + Map<String, Object> releaseResult = dispatcher.runSync("expireFinAccountAuth", UtilMisc.<String, Object>toMap("userLogin", userLogin, "finAccountAuthId", finAccountAuthId)); if (ServiceUtil.isError(releaseResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(releaseResult)); @@ -506,8 +506,8 @@ public class GiftCertificateServices { } } else { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "AccountingFinAccountSetting", - UtilMisc.toMap("productStoreId", productStoreId, + "AccountingFinAccountSetting", + UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.getGiftCertFinAccountTypeId()), locale)); } @@ -538,8 +538,8 @@ public class GiftCertificateServices { if (giftCertSettings.getLong("authValidDays") != null) { thruDate = UtilDateTime.getDayEnd(UtilDateTime.nowTimestamp(), giftCertSettings.getLong("authValidDays")); } - Map<String, Object> tmpResult = dispatcher.runSync("createFinAccountAuth", - UtilMisc.<String, Object>toMap("finAccountId", finAccountId, + Map<String, Object> tmpResult = dispatcher.runSync("createFinAccountAuth", + UtilMisc.<String, Object>toMap("finAccountId", finAccountId, "amount", amount, "currencyUomId", currency, "thruDate", thruDate, "userLogin", userLogin)); if (ServiceUtil.isError(tmpResult)) { @@ -556,7 +556,6 @@ public class GiftCertificateServices { result.put("processAmount", amount); result.put("authResult", processResult); - result.put("processAmount", amount); result.put("authFlag", "2"); result.put("authCode", "A"); result.put("captureCode", "C"); @@ -595,7 +594,7 @@ public class GiftCertificateServices { return ServiceUtil.returnError(err + UtilProperties.getMessage(RES_ERROR, "AccountingFinAccountCannotFindAuthorization", locale)); } - Map<String, Object> input = UtilMisc.<String, Object>toMap("userLogin", userLogin, + Map<String, Object> input = UtilMisc.<String, Object>toMap("userLogin", userLogin, "finAccountAuthId", authTransaction.get("referenceNum")); Map<String, Object> serviceResults = dispatcher.runSync("expireFinAccountAuth", input); if (ServiceUtil.isError(serviceResults)) { @@ -614,7 +613,7 @@ public class GiftCertificateServices { } } - private static Map<String, Object> giftCertificateRestore(DispatchContext dctx, GenericValue userLogin, GenericValue paymentPref, + private static Map<String, Object> giftCertificateRestore(DispatchContext dctx, GenericValue userLogin, GenericValue paymentPref, BigDecimal amount, String currency, String resultPrefix, Locale locale) { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); @@ -701,7 +700,7 @@ public class GiftCertificateServices { orderHeader = orderItem.getRelatedOne("OrderHeader", false); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get OrderHeader from OrderItem", MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderCannotGetOrderHeader", UtilMisc.toMap("orderId", orderId), locale)); } @@ -759,8 +758,8 @@ public class GiftCertificateServices { } catch (GenericEntityException e) { Debug.logError(e, "Unable to get Product Store FinAccount settings for " + FinAccountHelper.getGiftCertFinAccountTypeId(), MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "AccountingFinAccountSetting", - UtilMisc.toMap("productStoreId", productStoreId, + "AccountingFinAccountSetting", + UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.getGiftCertFinAccountTypeId()), locale) + ": " + e.getMessage()); } @@ -944,7 +943,7 @@ public class GiftCertificateServices { orderHeader = orderItem.getRelatedOne("OrderHeader", false); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get OrderHeader from OrderItem", MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderCannotGetOrderHeader", UtilMisc.toMap("orderId", orderId), locale)); } @@ -965,7 +964,7 @@ public class GiftCertificateServices { productStoreId = orh.getProductStoreId(); } if (productStoreId == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "AccountingGiftCertificateNumberCannotReload", UtilMisc.toMap("orderId", orderId), locale)); } @@ -976,7 +975,7 @@ public class GiftCertificateServices { paymentConfig = paymentSetting.getString("paymentPropertiesPath"); } if (paymentConfig == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "AccountingGiftCertificateNumberCannotGetPaymentConfiguration", locale)); } @@ -1002,7 +1001,7 @@ public class GiftCertificateServices { .orderBy("-responseDate").queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "AccountingGiftCertificateNumberCannotReload", locale)); } @@ -1012,7 +1011,7 @@ public class GiftCertificateServices { responseAnswers = surveyResponse.getRelated("SurveyResponseAnswer", null, null, false); } catch (GenericEntityException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "AccountingGiftCertificateNumberCannotReloadFromSurveyAnswers", locale)); } @@ -1025,7 +1024,7 @@ public class GiftCertificateServices { question = answer.getRelatedOne("SurveyQuestion", false); } catch (GenericEntityException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "AccountingGiftCertificateNumberCannotReloadFromSurveyAnswers", locale)); } if (question != null) { @@ -1093,7 +1092,7 @@ public class GiftCertificateServices { // process the return try { - Map<String, Object> refundCtx = UtilMisc.toMap("orderItem", orderItem, + Map<String, Object> refundCtx = UtilMisc.toMap("orderItem", orderItem, "partyId", partyId, "userLogin", userLogin); dispatcher.runAsync("refundGcPurchase", refundCtx, null, true, 300, true); } catch (GenericServiceException e) { @@ -1202,14 +1201,14 @@ public class GiftCertificateServices { Map<String, Object> returnableInfo = null; try { - returnableInfo = dispatcher.runSync("getReturnableQuantity", UtilMisc.toMap("orderItem", orderItem, + returnableInfo = dispatcher.runSync("getReturnableQuantity", UtilMisc.toMap("orderItem", orderItem, "userLogin", userLogin)); if (ServiceUtil.isError(returnableInfo)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(returnableInfo)); } } catch (GenericServiceException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderErrorUnableToGetReturnItemInformation", locale)); } @@ -1227,7 +1226,7 @@ public class GiftCertificateServices { returnHeaderResp = dispatcher.runSync("createReturnHeader", returnHeaderInfo); } catch (GenericServiceException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderErrorUnableToCreateReturnHeader", locale)); } @@ -1236,7 +1235,7 @@ public class GiftCertificateServices { } String returnId = (String) returnHeaderResp.get("returnId"); if (UtilValidate.isEmpty(returnId)) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderErrorCreateReturnHeaderWithoutId", locale)); } @@ -1257,7 +1256,7 @@ public class GiftCertificateServices { returnItemResp = dispatcher.runSync("createReturnItem", returnItemInfo); } catch (GenericServiceException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderErrorUnableToCreateReturnItem", locale)); } @@ -1268,7 +1267,7 @@ public class GiftCertificateServices { String returnItemSeqId = (String) returnItemResp.get("returnItemSeqId"); if (returnItemSeqId == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderErrorCreateReturnItemWithoutId", locale)); } if (Debug.verboseOn()) { @@ -1281,7 +1280,7 @@ public class GiftCertificateServices { admin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); } catch (GenericEntityException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderErrorUnableToUpdateReturnHeaderStatusWithoutUserLogin", locale)); } @@ -1296,7 +1295,7 @@ public class GiftCertificateServices { updateReturnResp = dispatcher.runSync("updateReturnHeader", updateReturnInfo); } catch (GenericServiceException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderErrorUnableToUpdateReturnHeaderStatus", locale)); } @@ -1324,7 +1323,7 @@ public class GiftCertificateServices { if (dbPin != null && dbPin.equals(pinNumber)) { return true; } - } + } if (Debug.infoOn()) { Debug.logInfo("GC FinAccount record not found (" + cardNumber + ")", MODULE); } @@ -1337,7 +1336,7 @@ public class GiftCertificateServices { partyId, currencyUom, txType, finAccountId, locale, null); } private static String createTransaction(Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin, - BigDecimal amount, String productStoreId, String partyId, String currencyUom, String txType, + BigDecimal amount, String productStoreId, String partyId, String currencyUom, String txType, String finAccountId, Locale locale, String orderId) throws GeneralException { final String coParty = getPayToPartyId(delegator, productStoreId); final String paymentMethodType = "GIFT_CERTIFICATE"; diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java index 3e056fd..0e4a575 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java @@ -130,8 +130,8 @@ public class PaymentGatewayServices { } catch (GenericEntityException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + - orderPaymentPreferenceId); + "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + + orderPaymentPreferenceId); } OrderReadHelper orh = new OrderReadHelper(orderHeader); @@ -237,7 +237,7 @@ public class PaymentGatewayServices { orderPaymentPreference.set("paymentMethodId", otherPaymentMethodAndCreditCard.getString("paymentMethodId")); Map<String, Object> authRetryResult = authPayment(dispatcher, userLogin, orh, orderPaymentPreference, totalRemaining, reAuth, transAmount); try { - boolean processRetryResult = processResult(dctx, authPaymentResult, userLogin, + boolean processRetryResult = processResult(dctx, authPaymentResult, userLogin, orderPaymentPreference, locale); if (processRetryResult) { @@ -303,7 +303,7 @@ public class PaymentGatewayServices { } catch (GeneralException e) { Debug.logError(e, "Error processing payment authorization", MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "AccountingPaymentCannotBeAuthorized", + "AccountingPaymentCannotBeAuthorized", UtilMisc.toMap("errroString", e.toString()), locale)); } } @@ -728,14 +728,13 @@ public class PaymentGatewayServices { if (orderPaymentPreferenceId != null) { paymentPref = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne(); orderId = paymentPref.getString("orderId"); - } - else { + } else { orderId = (String) context.get("orderId"); } } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + - orderPaymentPreferenceId); + "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + + orderPaymentPreferenceId); } // get the payment preferences @@ -776,11 +775,11 @@ public class PaymentGatewayServices { try { releaseResult = dispatcher.runSync("releaseOrderPaymentPreference", releaseContext); } catch (GenericServiceException e) { - Debug.logError(e, "Problem calling releaseOrderPaymentPreference service for orderPaymentPreferenceId" + - paymentPref.getString("orderPaymentPreferenceId"), MODULE); + Debug.logError(e, "Problem calling releaseOrderPaymentPreference service for orderPaymentPreferenceId" + + paymentPref.getString("orderPaymentPreferenceId"), MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingTroubleCallingReleaseOrderPaymentPreferenceService", locale) + " " + - paymentPref.getString("orderPaymentPreferenceId")); + "AccountingTroubleCallingReleaseOrderPaymentPreferenceService", locale) + " " + + paymentPref.getString("orderPaymentPreferenceId")); } if (ServiceUtil.isError(releaseResult)) { Debug.logError(ServiceUtil.getErrorMessage(releaseResult), MODULE); @@ -873,7 +872,7 @@ public class PaymentGatewayServices { } else { Debug.logError("Credit failed for pref : " + paymentPref, MODULE); return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, - "AccountingTroubleCallingCreditOrderPaymentPreferenceService", + "AccountingTroubleCallingCreditOrderPaymentPreferenceService", UtilMisc.toMap("paymentPref", paymentPref), locale)); } return ServiceUtil.returnSuccess(); @@ -896,19 +895,19 @@ public class PaymentGatewayServices { try { paymentPref = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne(); } catch (GenericEntityException e) { - Debug.logWarning(e, "Problem getting OrderPaymentPreference for orderPaymentPreferenceId " + - orderPaymentPreferenceId, MODULE); + Debug.logWarning(e, "Problem getting OrderPaymentPreference for orderPaymentPreferenceId " + + orderPaymentPreferenceId, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + - orderPaymentPreferenceId); + "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + + orderPaymentPreferenceId); } // Error if no OrderPaymentPreference was found if (paymentPref == null) { - Debug.logWarning("Could not find OrderPaymentPreference with orderPaymentPreferenceId: " + - orderPaymentPreferenceId, MODULE); + Debug.logWarning("Could not find OrderPaymentPreference with orderPaymentPreferenceId: " + + orderPaymentPreferenceId, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + - orderPaymentPreferenceId); + "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + + orderPaymentPreferenceId); } // Get the OrderHeader GenericValue orderHeader = null; @@ -922,8 +921,8 @@ public class PaymentGatewayServices { } // Error if no OrderHeader was found if (orderHeader == null) { - Debug.logWarning("Could not find OrderHeader with orderId: " + - orderId + "; not processing payments.", MODULE); + Debug.logWarning("Could not find OrderHeader with orderId: " + + orderId + "; not processing payments.", MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER, "OrderOrderNotFound", UtilMisc.toMap("orderId", orderId), locale)); } @@ -948,14 +947,14 @@ public class PaymentGatewayServices { if (serviceName == null) { Debug.logWarning("No payment release service for - " + paymentPref.getString("paymentMethodTypeId"), MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER, - "AccountingTroubleCallingReleaseOrderPaymentPreferenceService", locale) + " " + - paymentPref.getString("paymentMethodTypeId")); + "AccountingTroubleCallingReleaseOrderPaymentPreferenceService", locale) + " " + + paymentPref.getString("paymentMethodTypeId")); } } else { Debug.logWarning("No payment release settings found for - " + paymentPref.getString("paymentMethodTypeId"), MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER, - "AccountingTroubleCallingReleaseOrderPaymentPreferenceService", locale) + " " + - paymentPref.getString("paymentMethodTypeId")); + "AccountingTroubleCallingReleaseOrderPaymentPreferenceService", locale) + " " + + paymentPref.getString("paymentMethodTypeId")); } if (UtilValidate.isEmpty(paymentConfig)) { paymentConfig = "payment.properties"; @@ -989,8 +988,8 @@ public class PaymentGatewayServices { } catch (GenericServiceException e) { Debug.logError(e, "Trouble processing the release results", MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER, - "AccountingTroubleCallingReleaseOrderPaymentPreferenceService", locale) + " " + - e.getMessage()); + "AccountingTroubleCallingReleaseOrderPaymentPreferenceService", locale) + " " + + e.getMessage()); } if (releaseResRes != null && ServiceUtil.isError(releaseResRes)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(releaseResRes)); @@ -1077,8 +1076,8 @@ public class PaymentGatewayServices { } else { Debug.logError("Release failed for pref : " + paymentPref, MODULE); return ServiceUtil.returnFailure(UtilProperties.getMessage(RES_ORDER, - "AccountingTroubleCallingReleaseOrderPaymentPreferenceService", locale) + " " + - paymentPref); + "AccountingTroubleCallingReleaseOrderPaymentPreferenceService", locale) + " " + + paymentPref); } return ServiceUtil.returnSuccess(); } @@ -1117,7 +1116,7 @@ public class PaymentGatewayServices { } catch (GenericEntityException e) { Debug.logError("Trouble getting OrderItemBilling(s) from Invoice #" + invoiceId, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingProblemLookingUpOrderItemBilling", + "AccountingProblemLookingUpOrderItemBilling", UtilMisc.toMap("billFields", invoiceId), locale)); } @@ -1146,7 +1145,7 @@ public class PaymentGatewayServices { if (testOrderId == null || !allSameOrder) { Debug.logWarning("Attempt to settle Invoice #" + invoiceId + " which contained none/multiple orders", MODULE); return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, - "AccountingInvoiceCannotBeSettle", + "AccountingInvoiceCannotBeSettle", UtilMisc.toMap("invoiceId", invoiceId), locale)); } @@ -1297,8 +1296,9 @@ public class PaymentGatewayServices { captureResult.put("captureResult", Boolean.TRUE); captureResult.put("orderPaymentPreference", paymentPref); if (context.get("captureRefNum") == null) { - captureResult.put("captureRefNum", ""); // FIXME: this is an hack to avoid a service validation error for processCaptureResult (captureRefNum is mandatory, but it is not used for billing accounts) - } + captureResult.put("captureRefNum", ""); + // FIXME: this is an hack to avoid a service validation error for processCaptureResult (captureRefNum is mandatory, but it is not used for billing accounts) + } // process the capture's results try { @@ -1586,12 +1586,12 @@ public class PaymentGatewayServices { return results; } - private static Map<String, Object> capturePayment(DispatchContext dctx, GenericValue userLogin, OrderReadHelper orh, + private static Map<String, Object> capturePayment(DispatchContext dctx, GenericValue userLogin, OrderReadHelper orh, GenericValue paymentPref, BigDecimal amount, Locale locale) { return capturePayment(dctx, userLogin, orh, paymentPref, amount, null, locale); } - private static Map<String, Object> capturePayment(DispatchContext dctx, GenericValue userLogin, OrderReadHelper orh, + private static Map<String, Object> capturePayment(DispatchContext dctx, GenericValue userLogin, OrderReadHelper orh, GenericValue paymentPref, BigDecimal amount, GenericValue authTrans, Locale locale) { LocalDispatcher dispatcher = dctx.getDispatcher(); // look up the payment configuration settings @@ -1677,12 +1677,12 @@ public class PaymentGatewayServices { captureContext.put("processAmount", amount); } else { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingPaymentServiceMissingAmount", + "AccountingPaymentServiceMissingAmount", UtilMisc.toMap("serviceName", serviceName, "inParams", inParams), locale)); } } catch (GenericServiceException ex) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingPaymentServiceCannotGetModel", + "AccountingPaymentServiceCannotGetModel", UtilMisc.toMap("serviceName", serviceName), locale)); } @@ -1788,7 +1788,7 @@ public class PaymentGatewayServices { return ServiceUtil.returnSuccess(); } - private static boolean processResult(DispatchContext dctx, Map<String, Object> result, GenericValue userLogin, + private static boolean processResult(DispatchContext dctx, Map<String, Object> result, GenericValue userLogin, GenericValue paymentPreference, Locale locale) throws GeneralException { Boolean authResult = (Boolean) result.get("authResult"); Boolean captureResult = (Boolean) result.get("captureResult"); @@ -2029,12 +2029,12 @@ public class PaymentGatewayServices { return getAuthTransaction(paymentPreference); } - private static void processCaptureResult(DispatchContext dctx, Map<String, Object> result, GenericValue userLogin, + private static void processCaptureResult(DispatchContext dctx, Map<String, Object> result, GenericValue userLogin, GenericValue paymentPreference, Locale locale) throws GeneralException { processCaptureResult(dctx, result, userLogin, paymentPreference, null, locale); } - private static void processCaptureResult(DispatchContext dctx, Map<String, Object> result, GenericValue userLogin, + private static void processCaptureResult(DispatchContext dctx, Map<String, Object> result, GenericValue userLogin, GenericValue paymentPreference, String authServiceType, Locale locale) throws GeneralException { if (result == null) { throw new GeneralException("Null capture result sent to processCaptureResult; fatal error"); @@ -2084,7 +2084,7 @@ public class PaymentGatewayServices { } } - private static void processReAuthFromCaptureFailure(DispatchContext dctx, Map<String, Object> result, BigDecimal amount, + private static void processReAuthFromCaptureFailure(DispatchContext dctx, Map<String, Object> result, BigDecimal amount, GenericValue userLogin, GenericValue paymentPreference, Locale locale) throws GeneralException { LocalDispatcher dispatcher = dctx.getDispatcher(); @@ -2280,8 +2280,8 @@ public class PaymentGatewayServices { } else { // otherwise default to Company and print a big warning about this partyIdTo = EntityUtilProperties.getPropertyValue("general", "ORGANIZATION_PARTY", "Company", delegator); - Debug.logWarning("Using default value of [" + partyIdTo + "] for payTo on invoice [" + invoiceId + "] and orderPaymentPreference [" + - paymentPreference.getString("orderPaymentPreferenceId") + "]", MODULE); + Debug.logWarning("Using default value of [" + partyIdTo + "] for payTo on invoice [" + invoiceId + "] and orderPaymentPreference [" + + paymentPreference.getString("orderPaymentPreferenceId") + "]", MODULE); } @@ -2347,8 +2347,8 @@ public class PaymentGatewayServices { } catch (GenericEntityException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + - orderPaymentPreferenceId); + "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + + orderPaymentPreferenceId); } // call the service refundPayment Map<String, Object> refundResponse = null; @@ -2383,8 +2383,8 @@ public class PaymentGatewayServices { } catch (GenericEntityException e) { Debug.logError(e, "Cannot get OrderHeader from OrderPaymentPreference", MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + - e.toString()); + "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + + e.toString()); } OrderReadHelper orh = new OrderReadHelper(orderHeader); @@ -2699,7 +2699,7 @@ public class PaymentGatewayServices { EntityQuery eq = EntityQuery.use(delegator) .from("OrderPaymentPreference") - .where(EntityCondition.makeCondition("needsNsfRetry", EntityOperator.EQUALS, "Y"), + .where(EntityCondition.makeCondition("needsNsfRetry", EntityOperator.EQUALS, "Y"), EntityCondition.makeCondition(ModelEntity.STAMP_FIELD, EntityOperator.LESS_THAN_EQUAL_TO, oneWeekAgo)) .orderBy("orderId"); try (EntityListIterator eli = eq.queryIterator()) { @@ -3087,19 +3087,19 @@ public class PaymentGatewayServices { try { paymentPref = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne(); } catch (GenericEntityException e) { - Debug.logWarning(e, "Problem getting OrderPaymentPreference for orderPaymentPreferenceId " + - orderPaymentPreferenceId, MODULE); + Debug.logWarning(e, "Problem getting OrderPaymentPreference for orderPaymentPreferenceId " + + orderPaymentPreferenceId, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + - orderPaymentPreferenceId); + "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + + orderPaymentPreferenceId); } // Error if no OrderPaymentPreference was found if (paymentPref == null) { - Debug.logWarning("Could not find OrderPaymentPreference with orderPaymentPreferenceId: " + - orderPaymentPreferenceId, MODULE); + Debug.logWarning("Could not find OrderPaymentPreference with orderPaymentPreferenceId: " + + orderPaymentPreferenceId, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + - orderPaymentPreferenceId); + "AccountingProblemGettingOrderPaymentPreferences", locale) + " " + + orderPaymentPreferenceId); } // Get the OrderHeader GenericValue orderHeader = null; diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java index 97ad5c0..881c2c5 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentMethodServices.java @@ -101,7 +101,7 @@ public class PaymentMethodServices { } catch (GenericEntityException e) { Debug.logWarning(e.toString(), MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "AccountingPaymentMethodCannotBeDeletedWriteFailure", + "AccountingPaymentMethodCannotBeDeletedWriteFailure", UtilMisc.toMap("errorString", e.getMessage()), locale)); } @@ -294,7 +294,7 @@ public class PaymentMethodServices { } if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin) && !security.hasEntityPermission("ACCOUNTING", "_UPDATE", userLogin)) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "AccountingCreditCardUpdateWithoutPermission", UtilMisc.toMap("partyId", partyId, + "AccountingCreditCardUpdateWithoutPermission", UtilMisc.toMap("partyId", partyId, "paymentMethodId", paymentMethodId), locale)); } @@ -307,7 +307,7 @@ public class PaymentMethodServices { // get the masked card number from the db String origCardNumber = creditCard.getString("cardNumber"); int cardLength = origCardNumber.length() - 4; - // use builder for better performance + // use builder for better performance StringBuilder builder = new StringBuilder(); for (int i = 0; i < cardLength; i++) { builder.append("*"); @@ -472,7 +472,7 @@ public class PaymentMethodServices { // expire the payment method LocalDispatcher dispatcher = dctx.getDispatcher(); - Map<String, Object> expireCtx = UtilMisc.<String, Object>toMap("userLogin", userLogin, + Map<String, Object> expireCtx = UtilMisc.<String, Object>toMap("userLogin", userLogin, "paymentMethodId", paymentMethodId); Map<String, Object> expireResp; try { @@ -753,7 +753,7 @@ public class PaymentMethodServices { if (tempVal == null) { // no value found, create a new one newPartyContactMechPurpose = delegator.makeValue("PartyContactMechPurpose", - UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, + UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId, "fromDate", now)); } } @@ -883,7 +883,7 @@ public class PaymentMethodServices { if (tempVal == null) { // no value found, create a new one newPartyContactMechPurpose = delegator.makeValue("PartyContactMechPurpose", - UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, + UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId, "fromDate", now)); } } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java index 81a7fe9..e033712 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentWorker.java @@ -332,9 +332,9 @@ public final class PaymentWorker { } public static BigDecimal getPaymentNotApplied(GenericValue payment) { - if (payment != null) { + if (payment != null) { return payment.getBigDecimal("amount").subtract(getPaymentApplied(payment)).setScale(DECIMALS, ROUNDING_MODE); - } + } return BigDecimal.ZERO; } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java index c54429d..e337e35 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java @@ -50,7 +50,7 @@ import com.ibm.icu.util.Calendar; public class AIMPaymentServices { private static final String MODULE = AIMPaymentServices.class.getName(); - public final static String RESOURCE = "AccountingUiLabels"; + private static final String RESOURCE = "AccountingUiLabels"; // The list of refund failure response codes that would cause the ccRefund service // to attempt to void the refund's associated authorization transaction. This list @@ -460,7 +460,7 @@ public class AIMPaymentServices { AIMRequest.put("x_cpversion", cpVersion); } - // Check duplicateWindow time frame. If same transaction happens in the predefined time frame then return error. + // Check duplicateWindow time frame. If same transaction happens in the predefined time frame then return error. String duplicateWindow = props.getProperty("duplicateWindow"); if (UtilValidate.isNotEmpty(duplicateWindow)) { AIMRequest.put("x_duplicate_window", props.getProperty("duplicateWindow")); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java index b4ef15c..d66003f 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java @@ -57,7 +57,7 @@ public class CCPaymentServices { private static final String RESOURCE = "AccountingUiLabels"; private static final int DECIMALS = UtilNumber.getBigDecimalScale("invoice.decimals"); private static final RoundingMode ROUNDING_MODE = UtilNumber.getRoundingMode("invoice.rounding"); - private final static int MAX_SEV_COMP = 4; + private static final int MAX_SEV_COMP = 4; public static Map<String, Object> ccAuth(DispatchContext dctx, Map<String, Object> context) { String ccAction = (String) context.get("ccAction"); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/EwayServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/EwayServices.java index d7e6d77..6aba66a 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/EwayServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/EwayServices.java @@ -83,7 +83,7 @@ public class EwayServices { } // send the request - GatewayConnector con = new GatewayConnector(); + GatewayConnector con = new GatewayConnector(); GatewayResponse reply; try { reply = con.sendRequest(req); @@ -209,7 +209,7 @@ public class EwayServices { req.setCardExpiryYear(exp[1]); } // send the request - GatewayConnector con = new GatewayConnector(); + GatewayConnector con = new GatewayConnector(); GatewayResponse reply; try { reply = con.sendRequest(req); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayConnector.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayConnector.java index 144b414..df7e61a 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayConnector.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayConnector.java @@ -73,9 +73,9 @@ public class GatewayConnector { * @param request the request object, can be any of the 3 supported payment * methods. Its data have to be filled in by its setter methods before * calling sendRequest(). - * @return the response object, containing the gateway's response to the + * @return the response object, containing the gateway's response to the * request - * @throws Exception in case of networking and xml parsing errors + * @throws Exception in case of networking and xml parsing errors */ public GatewayResponse sendRequest(GatewayRequest request) throws Exception { // determine the gateway url to be used, based on the request type diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayResponse.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayResponse.java index f2d0f70..14f8284 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayResponse.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayResponse.java @@ -186,7 +186,7 @@ public class GatewayResponse { case "ewayTrxnReference": txTrxnReference = value; break; - case "ewayBeagleScore": + case "ewayBeagleScore": if (!value.equals("")) { txBeagleScore = Double.parseDouble(value); } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java index 607cd3a..9db40b7 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java @@ -115,8 +115,8 @@ public class PayPalEvents { String company = UtilFormatOut.checkEmpty(productStore.getString("companyName"), ""); // create the item name - String itemName = UtilProperties.getMessage(RESOURCE, "AccountingOrderNr", locale) + orderId + " " + - (company != null ? UtilProperties.getMessage(commonResource, "CommonFrom", locale) + " "+ company : ""); + String itemName = UtilProperties.getMessage(RESOURCE, "AccountingOrderNr", locale) + orderId + " " + + (company != null ? UtilProperties.getMessage(commonResource, "CommonFrom", locale) + " "+ company : ""); String itemNumber = "0"; // get the redirect url @@ -135,8 +135,8 @@ public class PayPalEvents { String imageUrl = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "imageUrl", configString, "payment.paypal.image"); // get the paypal account - String payPalAccount = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "businessEmail", configString, "payment.paypal" + - ".business"); + String payPalAccount = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "businessEmail", configString, "payment.paypal" + + ".business"); if (UtilValidate.isEmpty(redirectUrl) || UtilValidate.isEmpty(notifyUrl) @@ -184,7 +184,7 @@ public class PayPalEvents { return "success"; } - /** PayPal Call-Back Event + /** PayPal Call-Back Event * @throws IOException */ public static String payPalIPN(HttpServletRequest request, HttpServletResponse response) throws IOException { Locale locale = UtilHttp.getLocale(request); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalServices.java index bab1e67..6a20533 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/paypal/PayPalServices.java @@ -83,7 +83,7 @@ import com.paypal.sdk.services.NVPCallerServices; public class PayPalServices { private static final String MODULE = PayPalServices.class.getName(); - public final static String RESOURCE = "AccountingErrorUiLabels"; + private static final String RESOURCE = "AccountingErrorUiLabels"; // Used to maintain a weak reference to the ShoppingCart for customers who have gone to PayPal to checkout // so that we can quickly grab the cart, perform shipment estimates and send the info back to PayPal. @@ -456,8 +456,8 @@ public class PayPalServices { // No email found so we'll need to create one but first check if it should be PRIMARY or just BILLING long primaryEmails = EntityQuery.use(delegator) .from("PartyContactWithPurpose") - .where("partyId", partyId, - "contactMechTypeId", "EMAIL_ADDRESS", + .where("partyId", partyId, + "contactMechTypeId", "EMAIL_ADDRESS", "contactMechPurposeTypeId", "PRIMARY_EMAIL") .filterByDate("contactFromDate", "contactThruDate", "purposeFromDate", "purposeThruDate") .queryCount(); @@ -597,9 +597,9 @@ public class PayPalServices { try { GenericValue shipmentMethod = EntityQuery.use(delegator) .from("ProductStoreShipmentMethView") - .where("productStoreId", cart.getProductStoreId(), - "partyId", shipMethodSplit[0], - "roleTypeId", "CARRIER", + .where("productStoreId", cart.getProductStoreId(), + "partyId", shipMethodSplit[0], + "roleTypeId", "CARRIER", "description", shippingMethodTypeDesc) .queryFirst(); cart.setAllShipmentMethodTypeId(shipmentMethod.getString("shipmentMethodTypeId")); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java index 2e7a8b9..1d7d47d 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java @@ -45,7 +45,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class SagePayPaymentServices { private static final String MODULE = SagePayPaymentServices.class.getName(); - public final static String RESOURCE = "AccountingUiLabels"; + private static final String RESOURCE = "AccountingUiLabels"; private static Map<String, String> buildCustomerBillingInfo(Map<String, Object> context) { Debug.logInfo("SagePay - Entered buildCustomerBillingInfo", MODULE); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java index 45c334b..cdbfc48 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java @@ -43,7 +43,7 @@ import securepay.jxa.api.Txn; public class SecurePayPaymentServices { private static final String MODULE = SecurePayPaymentServices.class.getName(); - public final static String RESOURCE = "AccountingUiLabels"; + private static final String RESOURCE = "AccountingUiLabels"; public static Map<String, Object> doAuth(DispatchContext dctx, Map<String, Object> context) { Locale locale = (Locale) context.get("locale"); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java index 5aedd27..e206823 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java @@ -96,10 +96,10 @@ public class SecurePayServiceTest extends OFBizTestCase { paymentGatewayConfigId = "SECUREPAY_CONFIG"; refundAmount = new BigDecimal("100.08"); orderPaymentPreference = delegator.makeValue("OrderPaymentPreference", UtilMisc.toMap( - "orderPaymentPreferenceId", "testOrder1000_01", - "orderId", "Demo1002", - "paymentMethodTypeId", "CREDIT_CARD", - "maxAmount", new BigDecimal("200.00"), + "orderPaymentPreferenceId", "testOrder1000_01", + "orderId", "Demo1002", + "paymentMethodTypeId", "CREDIT_CARD", + "maxAmount", new BigDecimal("200.00"), "statusId", "PAYMENT_AUTHORIZED")); GenericValue checkOrderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", "testOrder1000_01").queryOne(); if (UtilValidate.isEmpty(checkOrderPaymentPreference)) { diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java index 6643fce..b13ee13 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java @@ -51,9 +51,9 @@ import org.apache.ofbiz.service.ServiceUtil; public class ValueLinkServices { private static final String MODULE = ValueLinkServices.class.getName(); - public final static String RESOURCE = "AccountingUiLabels"; - public final static String RES_ERROR = "AccountingErrorUiLabels"; - public final static String RES_ORDER = "OrderUiLabels"; + private static final String RESOURCE = "AccountingUiLabels"; + private static final String RES_ERROR = "AccountingErrorUiLabels"; + private static final String RES_ORDER = "OrderUiLabels"; // generate/display new public/private/kek keys public static Map<String, Object> createKeys(DispatchContext dctx, Map<String, Object> context) { diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/verisign/PayflowPro.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/verisign/PayflowPro.java index a4a74c8..1c3023b 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/verisign/PayflowPro.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/verisign/PayflowPro.java @@ -58,7 +58,7 @@ import paypal.payflow.SDKProperties; public class PayflowPro { private static final String MODULE = PayflowPro.class.getName(); - public final static String RESOURCE = "AccountingUiLabels"; + private static final String RESOURCE = "AccountingUiLabels"; /** * Authorize credit card payment service. Service wrapper around PayFlow Pro API. @@ -443,7 +443,7 @@ public class PayflowPro { String configString = "payment.properties"; if (cart == null || cart.items().size() <= 0) { - return ServiceUtil.returnError(UtilProperties.getMessage("AccountingErrorUiLabels", + return ServiceUtil.returnError(UtilProperties.getMessage("AccountingErrorUiLabels", "AccountingPayPalShoppingCartIsEmpty", locale)); } @@ -592,7 +592,7 @@ public class PayflowPro { Map<String, String> responseMap = parseResponse(resp); if (!"0".equals(responseMap.get("RESULT"))) { Debug.logError("A problem occurred while requesting the checkout details from paypal: Result = " + responseMap.get("RESULT") + ", Message = " + responseMap.get("RESPMSG"), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage("AccountingErrorUiLabels", + return ServiceUtil.returnError(UtilProperties.getMessage("AccountingErrorUiLabels", "AccountingPayPalCommunicationError", locale)); } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java index 5846f2e..7ace333 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java @@ -226,8 +226,8 @@ public class WorldPayEvents { // get the currency String defCur = UtilFormatOut.checkEmpty(productStore.getString("defaultCurrencyUomId"), "USD"); // order description - String description = UtilProperties.getMessage(RESOURCE, "AccountingOrderNr", locale) + orderId + " " + - (company != null ? UtilProperties.getMessage(commonResource, "CommonFrom", locale) + " "+ company : ""); + String description = UtilProperties.getMessage(RESOURCE, "AccountingOrderNr", locale) + orderId + " " + + (company != null ? UtilProperties.getMessage(commonResource, "CommonFrom", locale) + " " + company : ""); // check the instId - very important if (instId == null || "NONE".equals(instId)) { Debug.logError("Worldpay InstId not found, cannot continue", MODULE); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java index 6c47977..46db0a6 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/util/UtilAccounting.java @@ -119,8 +119,8 @@ public final class UtilAccounting { String parentTypeId = paymentType.getString("parentTypeId"); // isPaymentTypeRecurse => otherwise, we have to go to the grandparent (recurse) - return !(parentTypeId == null) && - (parentTypeId.equals(inputTypeId) || isPaymentTypeRecurse(paymentType.getRelatedOne("ParentPaymentType", false), inputTypeId)); + return !(parentTypeId == null) + && (parentTypeId.equals(inputTypeId) || isPaymentTypeRecurse(paymentType.getRelatedOne("ParentPaymentType", false), inputTypeId)); } diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java index cf126b2..80489fc 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementEvents.java @@ -233,9 +233,9 @@ public class ContentManagementEvents { // disable existing link if (UtilValidate.isNotEmpty(origSubContentId) && origFromDate != null) { List<GenericValue> oldActiveValues = EntityQuery.use(delegator).from("ContentAssoc") - .where("contentId", targContentId, - "contentIdTo", origSubContentId, - "contentAssocTypeId", "PUBLISH_LINK", + .where("contentId", targContentId, + "contentIdTo", origSubContentId, + "contentAssocTypeId", "PUBLISH_LINK", "thruDate", null) .queryList(); for (GenericValue cAssoc : oldActiveValues) { @@ -295,9 +295,9 @@ public class ContentManagementEvents { } else if (UtilValidate.isNotEmpty(origSubContentId)) { // if no current link is passed in, look to see if there is an existing link(s) that must be disabled List<GenericValue> oldActiveValues = EntityQuery.use(delegator).from("ContentAssoc") - .where("contentId", targContentId, - "contentIdTo", origSubContentId, - "contentAssocTypeId", "PUBLISH_LINK", + .where("contentId", targContentId, + "contentIdTo", origSubContentId, + "contentAssocTypeId", "PUBLISH_LINK", "thruDate", null) .queryList(); for (GenericValue cAssoc : oldActiveValues) { diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java b/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java index 261b91c..44a5a16 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ConvertTree.java @@ -181,7 +181,7 @@ In order to make this service active add the following to the service definition rootContent = "HOME_DOCUMENT"; } contentAssocs = EntityQuery.use(delegator).from("ContentAssoc") - .where("contentId", contentId, + .where("contentId", contentId, "contentIdTo", rootContent, "contentAssocTypeId", "TREE_CHILD") .queryList(); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/blog/BlogRssServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/blog/BlogRssServices.java index 09cddfe..c3f7e4e 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/blog/BlogRssServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/blog/BlogRssServices.java @@ -80,7 +80,7 @@ public class BlogRssServices { if (content == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "ContentCannotGenerateBlogRssFeed", + "ContentCannotGenerateBlogRssFeed", UtilMisc.toMap("contentId", contentId), locale)); } diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java index fa7d648..43a1c24 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java @@ -44,7 +44,6 @@ import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ModelService; import org.apache.ofbiz.service.ServiceUtil; -import org.apache.ofbiz.webapp.event.CoreEvents; import org.apache.ofbiz.webapp.website.WebSiteWorker; @@ -53,6 +52,7 @@ import org.apache.ofbiz.webapp.website.WebSiteWorker; */ public class CompDocEvents { private static final String MODULE = CompDocEvents.class.getName(); + private static final String ERR_RESOURCE = "WebappUiLabels"; /** * @@ -81,10 +81,10 @@ public class CompDocEvents { EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error running serviceName persistContentAndAssoc", MODULE); - String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.error_modelservice_for_srv_name", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "coreEvents.error_modelservice_for_srv_name", locale); request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + " [" + "persistContentAndAssoc" + "]: " + e.toString()); return "error"; - } + } } ModelService modelService = null; diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocServices.java index 8e36748..0f66ad9 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocServices.java @@ -44,7 +44,6 @@ import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ModelService; import org.apache.ofbiz.service.ServiceUtil; -import org.apache.ofbiz.webapp.event.CoreEvents; import org.apache.ofbiz.webapp.view.ViewHandlerException; import com.lowagie.text.Document; @@ -61,13 +60,14 @@ import com.lowagie.text.pdf.PdfReader; public class CompDocServices { private static final String MODULE = CompDocServices.class.getName(); private static final String RESOURCE = "ContentUiLabels"; + private static final String ERR_RESOURCE = "WebappUiLabels"; /** - * * Creates the topmost Content entity of a Composite Document tree. * Also creates an "empty" Composite Document Instance Content entity. * Creates ContentRevision/Item records for each, as well. - * @param dctx the dispatch context + * + * @param dctx the dispatch context * @param context the context * @return Creates the topmost Content entity of a Composite Document tree */ @@ -85,8 +85,9 @@ public class CompDocServices { EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error running serviceName persistContentAndAssoc", MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(CoreEvents.err_resource, "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale)); - } + return ServiceUtil.returnError(UtilProperties.getMessage(ERR_RESOURCE, "ContentNoContentFound", + UtilMisc.toMap("contentId", contentId), locale)); + } } ModelService modelService = null; @@ -94,14 +95,15 @@ public class CompDocServices { modelService = dispatcher.getDispatchContext().getModelService("persistContentAndAssoc"); } catch (GenericServiceException e) { Debug.logError("Error getting model service for serviceName, 'persistContentAndAssoc'. " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.error_modelservice_for_srv_name", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(ERR_RESOURCE, "coreEvents.error_modelservice_for_srv_name", locale)); } Map<String, Object> persistMap = modelService.makeValid(context, ModelService.IN_PARAM); persistMap.put("userLogin", userLogin); try { Map<String, Object> persistContentResult = dispatcher.runSync("persistContentAndAssoc", persistMap); if (ServiceUtil.isError(persistContentResult)) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentContentCreatingError", UtilMisc.toMap("serviceName", "persistContentAndAssoc"), locale), null, null, persistContentResult); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentContentCreatingError", + UtilMisc.toMap("serviceName", "persistContentAndAssoc"), locale), null, null, persistContentResult); } contentId = (String) persistContentResult.get("contentId"); @@ -121,7 +123,8 @@ public class CompDocServices { return result; } catch (GenericServiceException e) { Debug.logError(e, "Error running serviceName, 'persistContentAndAssoc'. " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentContentCreatingError", UtilMisc.toMap("serviceName", "persistContentAndAssoc"), locale) + e.toString()); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentContentCreatingError", + UtilMisc.toMap("serviceName", "persistContentAndAssoc"), locale) + e.toString()); } } @@ -148,7 +151,8 @@ public class CompDocServices { } List<GenericValue> compDocParts = EntityQuery.use(delegator) - .select("rootRevisionContentId", "itemContentId", "maxRevisionSeqId", "contentId", "dataResourceId", "contentIdTo", "contentAssocTypeId", "fromDate", "sequenceNum") + .select("rootRevisionContentId", "itemContentId", "maxRevisionSeqId", "contentId", "dataResourceId", "contentIdTo", + "contentAssocTypeId", "fromDate", "sequenceNum") .from("ContentAssocRevisionItemView") .where(exprList) .orderBy("sequenceNum").filterByDate().queryList(); @@ -168,11 +172,13 @@ public class CompDocServices { byte[] inputByteArray = null; PdfReader reader = null; if (inputMimeType != null && "application/pdf".equals(inputMimeType)) { - ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, thisDataResourceId, https, webSiteId, locale, rootDir); + ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, thisDataResourceId, https, webSiteId, locale, + rootDir); inputByteArray = byteBuffer.array(); reader = new PdfReader(inputByteArray); } else if (inputMimeType != null && "text/html".equals(inputMimeType)) { - ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, thisDataResourceId, https, webSiteId, locale, rootDir); + ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, thisDataResourceId, https, webSiteId, locale, + rootDir); inputByteArray = byteBuffer.array(); String s = new String(inputByteArray, "UTF-8"); Debug.logInfo("text/html string:" + s, MODULE); @@ -271,11 +277,12 @@ public class CompDocServices { dataResourceId = content.getString("dataResourceId"); Debug.logInfo("SCVH(0b)- dataResourceId:" + dataResourceId, MODULE); dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne(); - } else { - GenericValue contentRevisionItem = EntityQuery.use(delegator).from("ContentRevisionItem").where("contentId", contentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId).cache().queryOne(); + } else { + GenericValue contentRevisionItem = EntityQuery.use(delegator).from("ContentRevisionItem").where("contentId", contentId, + "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId).cache().queryOne(); if (contentRevisionItem == null) { throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + contentId - + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId); + + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId); } Debug.logInfo("SCVH(1)- contentRevisionItem:" + contentRevisionItem, MODULE); Debug.logInfo("SCVH(2)-contentId=" + contentId @@ -330,9 +337,11 @@ public class CompDocServices { inputByteArray = outByteBuffer.array(); } else { // Fill in acroForm - Map<String, Object> survey2AcroFieldResults = dispatcher.runSync("setAcroFieldsFromSurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId)); + Map<String, Object> survey2AcroFieldResults = dispatcher.runSync("setAcroFieldsFromSurveyResponse", + UtilMisc.toMap("surveyResponseId", surveyResponseId)); if (ServiceUtil.isError(survey2AcroFieldResults)) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentSurveyErrorSettingAcroFields", locale), null, null, survey2AcroFieldResults); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentSurveyErrorSettingAcroFields", locale), null, + null, survey2AcroFieldResults); } ByteBuffer outByteBuffer = (ByteBuffer) survey2AcroFieldResults.get("outByteBuffer"); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentPermissionServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentPermissionServices.java index e7274a4..b6a682e 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentPermissionServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentPermissionServices.java @@ -277,7 +277,7 @@ public class ContentPermissionServices { } if (contentTo == null || contentFrom == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "ContentContentToOrFromIsNull", + "ContentContentToOrFromIsNull", UtilMisc.toMap("contentTo", contentTo, "contentFrom", contentFrom), locale)); } Map<String, Object> permResults = new HashMap<>(); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java index b9ced14..3231d00 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java @@ -274,7 +274,7 @@ public class ContentSearch { /** * @param delegator the delegator * @return EntityListIterator representing the result of the query: NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE - * DONE WITH IT (preferably in a finally block), + * DONE WITH IT (preferably in a finally block), * AND DON'T LEAVE IT OPEN TOO LONG BECAUSE IT WILL MAINTAIN A DATABASE CONNECTION. */ public EntityListIterator doQuery(Delegator delegator) { diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServicesComplex.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServicesComplex.java index 0a79c42..e497961 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServicesComplex.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServicesComplex.java @@ -139,9 +139,10 @@ public class ContentServicesComplex { return ServiceUtil.returnError(e.getMessage()); } for (GenericValue a : relatedAssocs) { - if (Debug.verboseOn()) - Debug.logVerbose(" contentId:" + a.get("contentId") + " To:" + a.get("caContentIdTo") + " fromDate:" + a.get("caFromDate") + - " thruDate:" + a.get("caThruDate") + " AssocTypeId:" + a.get("caContentAssocTypeId"), null); + if (Debug.verboseOn()) { + Debug.logVerbose(" contentId:" + a.get("contentId") + " To:" + a.get("caContentIdTo") + " fromDate:" + a.get("caFromDate") + + " thruDate:" + a.get("caThruDate") + " AssocTypeId:" + a.get("caContentAssocTypeId"), null); + } } Map<String, Object> results = new HashMap<>(); results.put("entityList", relatedAssocs); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentUrlFilter.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentUrlFilter.java index 718c7b1..42e27b2 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentUrlFilter.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentUrlFilter.java @@ -42,7 +42,7 @@ import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.webapp.WebAppUtil; public class ContentUrlFilter implements Filter { - public final static String MODULE = ContentUrlFilter.class.getName(); + private static final String MODULE = ContentUrlFilter.class.getName(); private FilterConfig config; @Override @@ -67,7 +67,7 @@ public class ContentUrlFilter implements Filter { .orderBy("createdDate DESC").queryFirst(); if (contentDataResourceView != null) { GenericValue content = EntityQuery.use(delegator).from("ContentAssoc") - .where("contentAssocTypeId", "ALTERNATIVE_URL", + .where("contentAssocTypeId", "ALTERNATIVE_URL", "contentIdTo", contentDataResourceView.get("contentId")) .filterByDate().queryFirst(); if (content != null) { diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java index f06a36c..b92ea7a 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java @@ -350,7 +350,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor || rendered.contains("<a")) { rendered = encoder.sanitize(rendered, contentTypeId); } - return rendered; + return rendered; } public static String renderContentAsText(LocalDispatcher dispatcher, String contentId, Appendable out, Map<String, Object> templateContext, @@ -1039,7 +1039,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor Map<String, Object> permResults = new HashMap<>(); String skipPermissionCheck = (String) context.get("skipPermissionCheck"); - if (UtilValidate.isEmpty(skipPermissionCheck) + if (UtilValidate.isEmpty(skipPermissionCheck) || (!"true".equalsIgnoreCase(skipPermissionCheck) && !"granted".equalsIgnoreCase(skipPermissionCheck))) { GenericValue userLogin = (GenericValue) context.get("userLogin"); Map<String, Object> serviceInMap = new HashMap<>(); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java index 4835880..0645b95 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/UploadContentAndImage.java @@ -64,7 +64,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class UploadContentAndImage { private static final String MODULE = UploadContentAndImage.class.getName(); - public static final String err_resource = "ContentErrorUiLabels"; + private static final String ERR_RESOURCE = "ContentErrorUiLabels"; public UploadContentAndImage() { } @@ -92,7 +92,7 @@ public class UploadContentAndImage { } if (lst.size() == 0) { - String errMsg = UtilProperties.getMessage(UploadContentAndImage.err_resource, "uploadContentAndImage.no_files_uploaded", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "uploadContentAndImage.no_files_uploaded", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); Debug.logWarning("[DataEvents.uploadImage] No files uploaded", MODULE); return "error"; diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataEvents.java index 2abf58d..bf95263 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataEvents.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataEvents.java @@ -51,7 +51,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class DataEvents { private static final String MODULE = DataEvents.class.getName(); - public static final String err_resource = "ContentErrorUiLabels"; + private static final String ERR_RESOURCE = "ContentErrorUiLabels"; public static String uploadImage(HttpServletRequest request, HttpServletResponse response) { return DataResourceWorker.uploadAndStoreImage(request, "dataResourceId", "imageData"); @@ -328,7 +328,7 @@ public class DataEvents { if (mode != null && "UPDATE".equals(mode)) { result = dispatcher.runSync("updateDataResource", serviceInMap); if (ServiceUtil.isError(result)) { - String errMsg = UtilProperties.getMessage(DataEvents.err_resource, "dataEvents.error_call_update_service", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "dataEvents.error_call_update_service", locale); String errorMsg = ServiceUtil.getErrorMessage(result); Debug.logError(errorMsg, MODULE); request.setAttribute("_ERROR_MESSAGE_", errMsg); @@ -338,7 +338,7 @@ public class DataEvents { mode = "CREATE"; result = dispatcher.runSync("createDataResource", serviceInMap); if (ServiceUtil.isError(result)) { - String errMsg = UtilProperties.getMessage(DataEvents.err_resource, "dataEvents.error_call_create_service", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "dataEvents.error_call_create_service", locale); String errorMsg = ServiceUtil.getErrorMessage(result); Debug.logError(errorMsg, MODULE); request.setAttribute("_ERROR_MESSAGE_", errMsg); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java index a166c4b..904746d 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java @@ -106,7 +106,7 @@ import freemarker.template.TemplateException; public class DataResourceWorker implements org.apache.ofbiz.widget.content.DataResourceWorkerInterface { private static final String MODULE = DataResourceWorker.class.getName(); - public static final String err_resource = "ContentErrorUiLabels"; + private static final String ERR_RESOURCE = "ContentErrorUiLabels"; /** * Traverses the DataCategory parent/child structure and put it in categoryNode. Returns non-null error string if there is an error. @@ -217,7 +217,7 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data } if (lst.size() == 0) { - String errMsg = UtilProperties.getMessage(DataResourceWorker.err_resource, "dataResourceWorker.no_files_uploaded", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "dataResourceWorker.no_files_uploaded", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); Debug.logWarning("[DataEvents.uploadImage] No files uploaded", MODULE); return "error"; diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java index feb5d8f..44584e0 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java @@ -56,7 +56,7 @@ import org.apache.ofbiz.service.ServiceUtil; public class LayoutEvents { private static final String MODULE = LayoutEvents.class.getName(); - public static final String err_resource = "ContentErrorUiLabels"; + private static final String ERR_RESOURCE = "ContentErrorUiLabels"; public static String createLayoutImage(HttpServletRequest request, HttpServletResponse response) { Locale locale = UtilHttp.getLocale(request); @@ -70,7 +70,7 @@ public class LayoutEvents { Map<String, Object> context = new HashMap<>(); ByteBuffer byteWrap = (ByteBuffer) uploadResults.get("imageData"); if (byteWrap == null) { - String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.image_data_null", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.image_data_null", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } @@ -177,7 +177,7 @@ public class LayoutEvents { Map<String, Object> context = UtilGenerics.cast(uploadResults.get("formInput")); ByteBuffer byteWrap = (ByteBuffer) uploadResults.get("imageData"); if (byteWrap == null) { - String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.image_data_null", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.image_data_null", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } @@ -242,13 +242,13 @@ public class LayoutEvents { } String dataResourceId = (String) paramMap.get("dataResourceId"); if (UtilValidate.isEmpty(dataResourceId)) { - String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.data_ressource_id_null", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.data_ressource_id_null", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } String contentIdTo = (String) paramMap.get("contentIdTo"); if (UtilValidate.isEmpty(contentIdTo)) { - String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.content_id_to_null", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.content_id_to_null", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } @@ -311,7 +311,7 @@ public class LayoutEvents { Debug.logVerbose("in cloneLayout, contentId:" + contentId, ""); } if (UtilValidate.isEmpty(contentId)) { - String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.content_id_empty", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.content_id_empty", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } @@ -332,7 +332,7 @@ public class LayoutEvents { Debug.logVerbose("in cloneLayout, content:" + content, ""); } if (content == null) { - String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.content_empty", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.content_empty", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } @@ -401,7 +401,7 @@ public class LayoutEvents { } entityList = UtilGenerics.cast(results.get("entityList")); if (UtilValidate.isEmpty(entityList)) { - String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.no_subcontent", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.no_subcontent", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); } } catch (GenericServiceException e) { @@ -430,8 +430,8 @@ public class LayoutEvents { Timestamp fromDate = (Timestamp) view.get("caFromDate"); Timestamp thruDate = (Timestamp) view.get("caThruDate"); if (Debug.verboseOn()) - Debug.logVerbose("in cloneLayout, contentIdFrom:" + contentIdFrom + " fromDate:" + fromDate + " thruDate:" + thruDate + - " mapKey:" + mapKey, ""); + Debug.logVerbose("in cloneLayout, contentIdFrom:" + contentIdFrom + " fromDate:" + fromDate + " thruDate:" + thruDate + + " mapKey:" + mapKey, ""); if (beenThere.get(contentIdFrom) == null) { serviceIn.put("contentIdFrom", contentIdFrom); serviceIn.put("contentIdTo", newId); @@ -564,9 +564,12 @@ public class LayoutEvents { String rootDir = request.getSession().getServletContext().getRealPath("/"); context.put("rootDir", rootDir); try { - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentIn", paramMap, context, errorMessages, loc); - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "dataResourceIn", paramMap, context, errorMessages, loc); - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocIn", paramMap, context, errorMessages, loc); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "contentIn", paramMap, context, errorMessages, loc); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "dataResourceIn", paramMap, context, errorMessages, loc); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "contentAssocIn", paramMap, context, errorMessages, loc); } catch (MiniLangException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; @@ -606,7 +609,7 @@ public class LayoutEvents { Locale locale = UtilHttp.getLocale(request); if (UtilValidate.isEmpty(entityName)) { - String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.entityname_empty", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.entityname_empty", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } @@ -619,15 +622,15 @@ public class LayoutEvents { attrVal = (String) paramMap.get(attrName); } if (Debug.verboseOn()) { - Debug.logVerbose("in copyToClip, attrName:" + attrName,""); + Debug.logVerbose("in copyToClip, attrName:" + attrName, ""); } if (Debug.verboseOn()) { - Debug.logVerbose("in copyToClip, attrVal:" + attrVal,""); + Debug.logVerbose("in copyToClip, attrVal:" + attrVal, ""); } if (UtilValidate.isNotEmpty(attrVal)) { passedPK.put(attrName, attrVal); } else { - String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.empty", locale); + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.empty", locale); request.setAttribute("_ERROR_MESSAGE_", attrName + " " + errMsg); return "error"; } diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java index 9c862ec..739a2ec 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutWorker.java @@ -45,7 +45,7 @@ import org.apache.ofbiz.service.ServiceUtil; public final class LayoutWorker { private static final String MODULE = LayoutWorker.class.getName(); - private static final String err_resource = "ContentErrorUiLabels"; + private static final String ERR_RESOURCE = "ContentErrorUiLabels"; private LayoutWorker() { } @@ -81,10 +81,10 @@ public final class LayoutWorker { lst = UtilGenerics.cast(request.getAttribute("fileItems")); } if (lst.size() == 0) { - String errMsg = UtilProperties.getMessage(err_resource, + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.no_files_uploaded", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); - return ServiceUtil.returnError(UtilProperties.getMessage(err_resource, + return ServiceUtil.returnError(UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.no_files_uploaded", locale)); } @@ -108,7 +108,7 @@ public final class LayoutWorker { } if (imageFi == null) { - String errMsg = UtilProperties.getMessage(err_resource, + String errMsg = UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.image_null", UtilMisc.toMap("imageFi", imageFi), locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); return null; diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java index e26698b..51311f9 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java @@ -82,7 +82,7 @@ import freemarker.template.TemplateException; */ public class OutputServices { - public final static String MODULE = OutputServices.class.getName(); + private static final String MODULE = OutputServices.class.getName(); protected static final FoFormRenderer foFormRenderer = new FoFormRenderer(); private static final String RESOURCE = "ContentUiLabels"; diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/OfbizContentAltUrlTransforms.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/OfbizContentAltUrlTransforms.java index bb37289..c3681e1 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/OfbizContentAltUrlTransforms.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/OfbizContentAltUrlTransforms.java @@ -46,7 +46,7 @@ import freemarker.template.TemplateModelException; import freemarker.template.TemplateTransformModel; public class OfbizContentAltUrlTransforms implements TemplateTransformModel { - public final static String MODULE = OfbizContentAltUrlTransforms.class.getName(); + private static final String MODULE = OfbizContentAltUrlTransforms.class.getName(); private static final String defaultViewRequest = "contentViewInfo"; public String getStringArg(Map<String, Object> args, String key) { diff --git a/applications/humanres/src/main/java/org/apache/ofbiz/humanres/HumanResEvents.java b/applications/humanres/src/main/java/org/apache/ofbiz/humanres/HumanResEvents.java index da4b915..e64a1c1 100644 --- a/applications/humanres/src/main/java/org/apache/ofbiz/humanres/HumanResEvents.java +++ b/applications/humanres/src/main/java/org/apache/ofbiz/humanres/HumanResEvents.java @@ -161,7 +161,7 @@ public class HumanResEvents { josonMap.put("title", title); //Check child existing List<GenericValue> childOfSubComs = EntityQuery.use(delegator).from("PartyRelationship") - .where("partyIdFrom", catId, + .where("partyIdFrom", catId, "partyRelationshipTypeId", "GROUP_ROLLUP") .filterByDate().queryList(); //check employee position @@ -220,7 +220,7 @@ public class HumanResEvents { GenericValue emplContext = EntityQuery.use(delegator).from("EmplPositionType").where("emplPositionTypeId", typeId).queryOne(); String title = null; if (UtilValidate.isNotEmpty(emplContext)) { - title = (String) emplContext.get("description") + " " +"["+ emplId +"]"; + title = (String) emplContext.get("description") + " " + "[" + emplId +"]"; } String hrefStr = "emplPositionView?emplPositionId=" + emplId; emplAttrMap.put("href", hrefStr); diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java index 3448182..ebfc874 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMNode.java @@ -653,7 +653,7 @@ public class BOMNode { /** * A part is considered manufactured if it has child nodes AND unless ignoreSupplierProducts is set, if it also has no unexpired SupplierProducts defined * @param ignoreSupplierProducts - * @return return if a part is considered manufactured + * @return return if a part is considered manufactured */ public boolean isManufactured(boolean ignoreSupplierProducts) { List<GenericValue> supplierProducts = null; diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java index 9a2ef39..e33d02d 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMServices.java @@ -116,8 +116,8 @@ public class BOMServices { * It also updates the llc of all the product's descendants. * For the llc only the manufacturing bom ("MANUF_COMPONENT") is considered. * @param dctx the distach context - * @param context the context - * @return the results of the updates the product's low level code + * @param context the context + * @return the results of the updates the product's low level code */ public static Map<String, Object> updateLowLevelCode(DispatchContext dctx, Map<String, ? extends Object> context) { Map<String, Object> result = new HashMap<>(); @@ -209,8 +209,8 @@ public class BOMServices { /** Updates the product's low level code (llc) for all the products in the Product entity. * For the llc only the manufacturing bom ("MANUF_COMPONENT") is considered. * @param dctx the distach context - * @param context the context - * @return the results of the updates the product's low level code + * @param context the context + * @return the results of the updates the product's low level code */ public static Map<String, Object> initLowLevelCode(DispatchContext dctx, Map<String, ? extends Object> context) { Map<String, Object> result = new HashMap<>(); @@ -242,8 +242,8 @@ public class BOMServices { } // FIXME: also all the variants llc should be updated? } catch (GenericEntityException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorRunningInitLowLevelCode" - , UtilMisc.toMap("errorString", e.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, + "ManufacturingBomErrorRunningInitLowLevelCode", UtilMisc.toMap("errorString", e.getMessage()), locale)); } return result; } @@ -253,8 +253,8 @@ public class BOMServices { * Useful to avoid loops when adding new assocs (components) * to a bill of materials. * @param dctx the distach context - * @param context the context - * @return returns the ProductAssoc generic value for a duplicate productIdKey ancestor if present + * @param context the context + * @return returns the ProductAssoc generic value for a duplicate productIdKey ancestor if present */ public static Map<String, Object> searchDuplicatedAncestor(DispatchContext dctx, Map<String, ? extends Object> context) { Map<String, Object> result = new HashMap<>(); @@ -286,7 +286,7 @@ public class BOMServices { * configured bill of material tree. * Useful for tree traversal (breakdown, explosion, implosion). * @param dctx the distach context - * @param context the context + * @param context the context * @return return the bill of material tree */ public static Map<String, Object> getBOMTree(DispatchContext dctx, Map<String, ? extends Object> context) { @@ -337,7 +337,7 @@ public class BOMServices { * if necessary configures it, and it returns its (possibly configured) components in * a List of {@link BOMNode}). * @param dctx the distach context - * @param context the context + * @param context the context * @return return the list of manufacturing components */ public static Map<String, Object> getManufacturingComponents(DispatchContext dctx, Map<String, ? extends Object> context) { @@ -755,7 +755,7 @@ public class BOMServices { * if necessary configures it, and it returns its (possibly configured) components in * a List of {@link BOMNode}). * @param dctx the distach context - * @param context the context + * @param context the context * @return returns the list of products in packages */ public static Map<String, Object> getProductsInPackages(DispatchContext dctx, Map<String, ? extends Object> context) { diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java index 2439158..eb8caab 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java @@ -547,8 +547,8 @@ public class ProductionRunServices { ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); if (productionRun.exist()) { - if (!"PRUN_CREATED".equals(productionRun.getGenericValue().getString("currentStatusId")) && - !"PRUN_SCHEDULED".equals(productionRun.getGenericValue().getString("currentStatusId"))) { + if (!"PRUN_CREATED".equals(productionRun.getGenericValue().getString("currentStatusId")) + && !"PRUN_SCHEDULED".equals(productionRun.getGenericValue().getString("currentStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunPrinted", locale)); } @@ -877,8 +877,8 @@ public class ProductionRunServices { // change the production run task status to PRUN_RUNNING // if necessary change the production run (header) status to PRUN_RUNNING if (!allPrecTaskCompletedOrRunning) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunTaskCannotStartPrevTasksNotCompleted" - , locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, + "ManufacturingProductionRunTaskCannotStartPrevTasksNotCompleted", locale)); } if ("PRUN_CREATED".equals(productionRun.getGenericValue().getString("currentStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunTaskCannotStartDocsNotPrinted", @@ -1352,8 +1352,8 @@ public class ProductionRunServices { ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); if (productionRun.exist()) { - if (!"PRUN_CREATED".equals(productionRun.getGenericValue().getString("currentStatusId")) && - !"PRUN_SCHEDULED".equals(productionRun.getGenericValue().getString("currentStatusId"))) { + if (!"PRUN_CREATED".equals(productionRun.getGenericValue().getString("currentStatusId")) + && !"PRUN_SCHEDULED".equals(productionRun.getGenericValue().getString("currentStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunPrinted", locale)); } @@ -3430,8 +3430,8 @@ public class ProductionRunServices { "workEffortPurposeTypeId", "WEPT_PRODUCTION_RUN", "currentStatusId", "CAL_COMPLETED"); serviceContext.put("workEffortName", - "Decomposing product [" + inventoryItem.getString("productId") + "] inventory item [" + inventoryItem.getString("inventoryItemId") + - "]"); + "Decomposing product [" + inventoryItem.getString("productId") + "] inventory item [" + inventoryItem.getString("inventoryItemId") + + "]"); serviceContext.put("facilityId", inventoryItem.getString("facilityId")); serviceContext.put("estimatedStartDate", now); serviceContext.put("userLogin", userLogin); diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java index 7c77cf1..df1b4ff 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/ProposedOrder.java @@ -100,7 +100,7 @@ public class ProposedOrder { * <li>For the bought product, the first ProductFacility.daysToShip is used to calculated the startDate</li> * </ul> * @return - * <ul> + * <ul> * <li>if ProposedOrder.isBuild a Map with all the routingTaskId as keys and estimatedStartDate as value.</li> * <li>else null.</li> * </ul> diff --git a/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java b/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java index e8fbabe..a23cd12 100644 --- a/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java +++ b/applications/marketing/src/main/java/org/apache/ofbiz/marketing/tracking/TrackingCodeEvents.java @@ -49,7 +49,8 @@ public class TrackingCodeEvents { private static final String MODULE = TrackingCodeEvents.class.getName(); - /** If TrackingCode monitoring is desired this event should be added to the list + /** + * If TrackingCode monitoring is desired this event should be added to the list * of events that run on every request. This event looks for the parameter * <code>autoTrackingCode</code> or a shortened version: <code>atc</code>. */ @@ -79,10 +80,11 @@ public class TrackingCodeEvents { } } - /** If TrackingCode monitoring is desired this event should be added to the list + /** + * If TrackingCode monitoring is desired this event should be added to the list * of events that run on every request. This event looks for the parameter * <code>ptc</code> and handles the value as a Partner Managed Tracking Code. - * + * <p> * If the specified trackingCodeId exists then it is used as is, otherwise a new one * is created with the ptc value as the trackingCodeId. The values for the fields of * the new TrackingCode can come from one of two places: if a <code>dtc</code> parameter @@ -116,7 +118,8 @@ public class TrackingCodeEvents { try { defaultTrackingCode = EntityQuery.use(delegator).from("TrackingCode").where("trackingCodeId", dtc).cache().queryOne(); } catch (GenericEntityException e) { - Debug.logError(e, "Error looking up Default values TrackingCode with trackingCodeId [" + dtc + "], not using the dtc value for new TrackingCode defaults", MODULE); + Debug.logError(e, "Error looking up Default values TrackingCode with trackingCodeId [" + dtc + "], not using the dtc value " + + "for new TrackingCode defaults", MODULE); } if (defaultTrackingCode != null) { @@ -132,7 +135,8 @@ public class TrackingCodeEvents { try { trackingCode.create(); } catch (GenericEntityException e) { - Debug.logError(e, "Error creating new Partner TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this trackingCodeId", MODULE); + Debug.logError(e, "Error creating new Partner TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this " + + "trackingCodeId", MODULE); return "error"; } } @@ -154,12 +158,14 @@ public class TrackingCodeEvents { trackingCode.set("comments", "This TrackingCode has default values because no default TrackingCode could be found."); - Debug.logWarning("No default TrackingCode record was found, using a TrackingCode with hard coded default values: " + trackingCode, MODULE); + Debug.logWarning("No default TrackingCode record was found, using a TrackingCode with hard coded default values: " + + trackingCode, MODULE); try { trackingCode.create(); } catch (GenericEntityException e) { - Debug.logError(e, "Error creating new Partner TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this trackingCodeId", MODULE); + Debug.logError(e, "Error creating new Partner TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this " + + "trackingCodeId", MODULE); return "error"; } } @@ -171,7 +177,8 @@ public class TrackingCodeEvents { } } - public static String processTrackingCode(GenericValue trackingCode, HttpServletRequest request, HttpServletResponse response, String sourceEnumId) { + public static String processTrackingCode(GenericValue trackingCode, HttpServletRequest request, HttpServletResponse response, + String sourceEnumId) { Delegator delegator = (Delegator) request.getAttribute("delegator"); String trackingCodeId = trackingCode.getString("trackingCodeId"); @@ -195,7 +202,7 @@ public class TrackingCodeEvents { if (visit != null) { GenericValue trackingCodeVisit = delegator.makeValue("TrackingCodeVisit", UtilMisc.toMap("trackingCodeId", trackingCodeId, "visitId", visit.get("visitId"), - "fromDate", UtilDateTime.nowTimestamp(), "sourceEnumId", sourceEnumId)); + "fromDate", UtilDateTime.nowTimestamp(), "sourceEnumId", sourceEnumId)); try { trackingCodeVisit.create(); } catch (GenericEntityException e) { @@ -226,7 +233,8 @@ public class TrackingCodeEvents { cookieDomain = EntityUtilProperties.getPropertyValue("url", "cookie.domain", "", delegator); } - // if trackingCode.trackableLifetime not null and is > 0 write a trackable cookie with name in the form: TKCDT_{trackingCode.trackingCodeTypeId} and timeout will be trackingCode.trackableLifetime + // if trackingCode.trackableLifetime not null and is > 0 write a trackable cookie with name in the form: TKCDT_{trackingCode + // .trackingCodeTypeId} and timeout will be trackingCode.trackableLifetime Long trackableLifetime = trackingCode.getLong("trackableLifetime"); if (trackableLifetime != null && (trackableLifetime > 0 || trackableLifetime == -1)) { Cookie trackableCookie = new Cookie("TKCDT_" + trackingCode.getString("trackingCodeTypeId"), trackingCode.getString("trackingCodeId")); @@ -238,7 +246,8 @@ public class TrackingCodeEvents { response.addCookie(trackableCookie); } - // if trackingCode.billableLifetime not null and is > 0 write a billable cookie with name in the form: TKCDB_{trackingCode.trackingCodeTypeId} and timeout will be trackingCode.billableLifetime + // if trackingCode.billableLifetime not null and is > 0 write a billable cookie with name in the form: TKCDB_{trackingCode + // .trackingCodeTypeId} and timeout will be trackingCode.billableLifetime Long billableLifetime = trackingCode.getLong("billableLifetime"); if (billableLifetime != null && (billableLifetime > 0 || billableLifetime == -1)) { Cookie billableCookie = new Cookie("TKCDB_" + trackingCode.getString("trackingCodeTypeId"), trackingCode.getString("trackingCodeId")); @@ -273,12 +282,14 @@ public class TrackingCodeEvents { } if (visitorSiteId == null || (siteId != null && !visitorSiteId.equals(siteId))) { - // if trackingCode.siteId is not null write a trackable cookie with name in the form: Ofbiz.TKCSiteId and timeout will be 60 * 60 * 24 * 365 + // if trackingCode.siteId is not null write a trackable cookie with name in the form: Ofbiz.TKCSiteId and timeout will be 60 * 60 + // * 24 * 365 String siteIdEnc; try { siteIdEnc = URLEncoder.encode(siteId, "UTF-8"); } catch (UnsupportedEncodingException e) { - Debug.logWarning("There went something wrong while encoding for the cookie creation in TrackingCodeEvents.processTrackingCode", MODULE); + Debug.logWarning("There went something wrong while encoding for the cookie creation in TrackingCodeEvents.processTrackingCode", + MODULE); return "error"; } Cookie siteIdCookie = new Cookie("Ofbiz.TKCD.SiteId", siteIdEnc); @@ -288,7 +299,8 @@ public class TrackingCodeEvents { siteIdCookie.setSecure(true); siteIdCookie.setHttpOnly(true); response.addCookie(siteIdCookie); - // if trackingCode.siteId is not null write a trackable cookie with name in the form: Ofbiz.TKCSiteId and timeout will be 60 * 60 * 24 * 365 + // if trackingCode.siteId is not null write a trackable cookie with name in the form: Ofbiz.TKCSiteId and timeout will be 60 * 60 + // * 24 * 365 Cookie updatedTimeStampCookie = new Cookie("Ofbiz.TKCD.UpdatedTimeStamp", UtilDateTime.nowTimestamp().toString()); updatedTimeStampCookie.setMaxAge(siteIdCookieAge); updatedTimeStampCookie.setPath("/"); @@ -302,11 +314,13 @@ public class TrackingCodeEvents { // if we have overridden logo, css and/or catalogId set some session attributes HttpSession session = request.getSession(); String overrideLogo = trackingCode.getString("overrideLogo"); - if (overrideLogo != null) + if (overrideLogo != null) { session.setAttribute("overrideLogo", overrideLogo); + } String overrideCss = trackingCode.getString("overrideCss"); - if (overrideCss != null) + if (overrideCss != null) { session.setAttribute("overrideCss", overrideCss); + } String prodCatalogId = trackingCode.getString("prodCatalogId"); if (UtilValidate.isNotEmpty(prodCatalogId)) { session.setAttribute("CURRENT_CATALOG_ID", prodCatalogId); @@ -327,7 +341,8 @@ public class TrackingCodeEvents { return "success"; } - /** If attaching TrackingCode Cookies to the visit is desired this event should be added to the list + /** + * If attaching TrackingCode Cookies to the visit is desired this event should be added to the list * of events that run on the first hit in a visit. */ public static String checkTrackingCodeCookies(HttpServletRequest request, HttpServletResponse response) { @@ -346,12 +361,14 @@ public class TrackingCodeEvents { try { trackingCode = EntityQuery.use(delegator).from("TrackingCode").where("trackingCodeId", trackingCodeId).cache().queryOne(); } catch (GenericEntityException e) { - Debug.logError(e, "Error looking up TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this trackingCodeId", MODULE); + Debug.logError(e, "Error looking up TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this " + + "trackingCodeId", MODULE); continue; } if (trackingCode == null) { - Debug.logError("TrackingCode not found for trackingCodeId [" + trackingCodeId + "], ignoring this trackingCodeId.", MODULE); + Debug.logError("TrackingCode not found for trackingCodeId [" + trackingCodeId + "], ignoring this trackingCodeId.", + MODULE); //this return value will be ignored, but we'll designate this as an error anyway continue; } @@ -359,7 +376,8 @@ public class TrackingCodeEvents { //check effective dates if (trackingCode.get("fromDate") != null && nowStamp.before(trackingCode.getTimestamp("fromDate"))) { if (Debug.infoOn()) { - Debug.logInfo("The TrackingCode with ID [" + trackingCodeId + "] has not yet gone into effect, ignoring this trackingCodeId", MODULE); + Debug.logInfo("The TrackingCode with ID [" + trackingCodeId + "] has not yet gone into effect, ignoring this " + + "trackingCodeId", MODULE); } continue; } @@ -373,7 +391,7 @@ public class TrackingCodeEvents { // for each trackingCodeId found in this way attach to the visit with the TKCDSRC_COOKIE sourceEnumId GenericValue trackingCodeVisit = delegator.makeValue("TrackingCodeVisit", UtilMisc.toMap("trackingCodeId", trackingCodeId, "visitId", visit.get("visitId"), - "fromDate", nowStamp, "sourceEnumId", "TKCDSRC_COOKIE")); + "fromDate", nowStamp, "sourceEnumId", "TKCDSRC_COOKIE")); try { //not doing this inside a transaction, want each one possible to go in trackingCodeVisit.create(); @@ -423,13 +441,16 @@ public class TrackingCodeEvents { // tracking code is valid return "success"; } else { - if (Debug.infoOn()) + if (Debug.infoOn()) { Debug.logInfo("The TrackingCode with ID [" + trackingCodeId + "] has expired, ignoring this trackingCodeId", MODULE); + } request.setAttribute("_ERROR_MESSAGE_", "Access code [" + trackingCodeId + "], is not valid."); } } else { - if (Debug.infoOn()) - Debug.logInfo("The TrackingCode with ID [" + trackingCodeId + "] has not yet gone into effect, ignoring this trackingCodeId", MODULE); + if (Debug.infoOn()) { + Debug.logInfo("The TrackingCode with ID [" + trackingCodeId + "] has not yet gone into effect, ignoring this " + + "trackingCodeId", MODULE); + } request.setAttribute("_ERROR_MESSAGE_", "Access code [" + trackingCodeId + "], is not valid."); } } else { @@ -445,7 +466,9 @@ public class TrackingCodeEvents { return ":_protect_:"; } - /** Removes the ACCESS tracking code cookie */ + /** + * Removes the ACCESS tracking code cookie + */ public static String removeAccesTrackingCodeCookie(HttpServletRequest request, HttpServletResponse response) { Cookie[] cookies = request.getCookies(); if (cookies != null) { @@ -459,7 +482,10 @@ public class TrackingCodeEvents { return "success"; } - /** Makes a list of TrackingCodeOrder entities to be attached to the current order; called by the createOrder event; the values in the returned List will not have the orderId set */ + /** + * Makes a list of TrackingCodeOrder entities to be attached to the current order; called by the createOrder event; the values in the returned + * List will not have the orderId set + */ public static List<GenericValue> makeTrackingCodeOrders(HttpServletRequest request) { Delegator delegator = (Delegator) request.getAttribute("delegator"); java.sql.Timestamp nowStamp = UtilDateTime.nowTimestamp(); @@ -481,10 +507,10 @@ public class TrackingCodeEvents { // find the referred timestamp cookie if it exists if ("Ofbiz.TKCD.UpdatedTimeStamp".equals(cookieName)) { String affiliateReferredTime = cookies[i].getValue(); - if (affiliateReferredTime !=null && !affiliateReferredTime.equals("")) { + if (affiliateReferredTime != null && !affiliateReferredTime.equals("")) { try { affiliateReferredTimeStamp = Timestamp.valueOf(affiliateReferredTime); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { Debug.logError(e, "Error parsing affiliateReferredTimeStamp value from cookie", MODULE); } } @@ -514,7 +540,8 @@ public class TrackingCodeEvents { //check effective dates if (trackingCode.get("fromDate") != null && nowStamp.before(trackingCode.getTimestamp("fromDate"))) { if (Debug.infoOn()) { - Debug.logInfo("The TrackingCode with ID [" + trackingCodeId + "] has not yet gone into effect, ignoring this trackingCodeId", MODULE); + Debug.logInfo("The TrackingCode with ID [" + trackingCodeId + "] has not yet gone into effect, ignoring this trackingCodeId", + MODULE); } } if (trackingCode.get("thruDate") != null && nowStamp.after(trackingCode.getTimestamp("thruDate"))) { @@ -524,8 +551,8 @@ public class TrackingCodeEvents { } GenericValue trackingCodeOrder = delegator.makeValue("TrackingCodeOrder", UtilMisc.toMap("trackingCodeTypeId", trackingCode.get("trackingCodeTypeId"), - "trackingCodeId", trackingCodeId, "isBillable", isBillable, "siteId", siteId, - "hasExported", "N", "affiliateReferredTimeStamp", affiliateReferredTimeStamp)); + "trackingCodeId", trackingCodeId, "isBillable", isBillable, "siteId", siteId, + "hasExported", "N", "affiliateReferredTimeStamp", affiliateReferredTimeStamp)); Debug.logInfo(" trackingCodeOrder is " + trackingCodeOrder, MODULE); trackingCodeOrders.add(trackingCodeOrder); diff --git a/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java b/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java index b6932b1..e8a4453 100644 --- a/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java +++ b/applications/marketing/src/main/java/org/apache/ofbiz/sfa/vcard/VCard.java @@ -73,7 +73,7 @@ public class VCard { * @param dctx * @param context * @return - * @throws IOException + * @throws IOException */ public static Map<String, Object> importVCard(DispatchContext dctx, Map<String, ? extends Object> context) throws IOException { LocalDispatcher dispatcher = dctx.getDispatcher(); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java index 7cc515b..995a8fd 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/OrderManagerEvents.java @@ -194,10 +194,10 @@ public class OrderManagerEvents { // create a payment, payment reference and payment appl record, when not exist yet. Map<String, Object> results = null; try { - results = dispatcher.runSync("createPaymentFromOrder", + results = dispatcher.runSync("createPaymentFromOrder", UtilMisc.toMap("orderId", orderId, "paymentMethodId", paymentMethodId, - "paymentRefNum", paymentMethodReference, + "paymentRefNum", paymentMethodReference, "comments", "Payment received offline and manually entered.", "userLogin", userLogin)); if (ServiceUtil.isError(results)) { diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java index 3d32603..b777bc2 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReadHelper.java @@ -354,8 +354,8 @@ public class OrderReadHelper { GenericValue shipmentMethodType = carrierShipmentMethod.getRelatedOne("ShipmentMethodType", false); if (shipmentMethodType != null) { - return UtilFormatOut.checkNull(shipGroup.getString("carrierPartyId")) + " " + - UtilFormatOut.checkNull(shipmentMethodType.getString("description")); + return UtilFormatOut.checkNull(shipGroup.getString("carrierPartyId")) + " " + + UtilFormatOut.checkNull(shipmentMethodType.getString("description")); } } return UtilFormatOut.checkNull(shipGroup.getString("carrierPartyId")); @@ -1256,7 +1256,7 @@ public class OrderReadHelper { public BigDecimal getOrderGrandTotal() { if (totalPrice == null) { totalPrice = getOrderGrandTotal(getValidOrderItems(), getAdjustments()); - }// else already set + } // else already set return totalPrice; } @@ -2849,7 +2849,7 @@ public class OrderReadHelper { /** * When you call this function after a OrderReadHelper instantiation * all OrderItemAttributes related to the orderHeader are load on local cache - * to optimize database call, after we just filter the cache with attributeName and + * to optimize database call, after we just filter the cache with attributeName and * orderItemSeqId wanted. * @param orderItemSeqId * @param attributeName diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java index 714217b..dc7b183 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderReturnServices.java @@ -390,15 +390,15 @@ public class OrderReturnServices { boolean returnable = true; // first check returnable flag - if (product != null && product.get("returnable") != null && - "N".equalsIgnoreCase(product.getString("returnable"))) { + if (product != null && product.get("returnable") != null + && "N".equalsIgnoreCase(product.getString("returnable"))) { // the product is not returnable at all returnable = false; } // next check support discontinuation - if (product != null && product.get("supportDiscontinuationDate") != null && - !UtilDateTime.nowTimestamp().before(product.getTimestamp("supportDiscontinuationDate"))) { + if (product != null && product.get("supportDiscontinuationDate") != null + && !UtilDateTime.nowTimestamp().before(product.getTimestamp("supportDiscontinuationDate"))) { // support discontinued either now or in the past returnable = false; } @@ -2297,8 +2297,8 @@ public class OrderReturnServices { if ((returnItemResponse != null) && (orderId != null)) { // TODO should we filter on payment's status (PMNT_SENT, PMNT_RECEIVED) GenericValue payment = returnItemResponse.getRelatedOne("Payment", false); - if ((payment != null) && (payment.getBigDecimal("amount") != null) && - !paymentList.contains(payment.get("paymentId"))) { + if ((payment != null) && (payment.getBigDecimal("amount") != null) + && !paymentList.contains(payment.get("paymentId"))) { UtilMisc.addToBigDecimalInMap(returnAmountByOrder, orderId, payment.getBigDecimal("amount")); paymentList.add(payment.getString("paymentId")); // make sure we don't add duplicated payment amount } @@ -2397,8 +2397,8 @@ public class OrderReturnServices { // we don't have the returnItemSeqId but before we consider this // an header adjustment we try to get a return item in this return // associated to the same order item to which the adjustments refers (if any) - if (UtilValidate.isNotEmpty(orderAdjustment.getString("orderItemSeqId")) && - !"_NA_".equals(orderAdjustment.getString("orderItemSeqId"))) { + if (UtilValidate.isNotEmpty(orderAdjustment.getString("orderItemSeqId")) + && !"_NA_".equals(orderAdjustment.getString("orderItemSeqId"))) { returnItem = EntityQuery.use(delegator).from("ReturnItem") .where("returnId", returnId, "orderId", orderAdjustment.getString("orderId"), "orderItemSeqId", orderAdjustment.getString("orderItemSeqId")) .queryFirst(); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java index 21cbe66..400baf9 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java @@ -97,6 +97,12 @@ public class OrderServices { private static final Map<String, String> SALES_ROLE_MAP = new HashMap<>(); private static final Map<String, String> PURCHASE_ROLE_MAP = new HashMap<>(); + private static final int TAX_SCALE = UtilNumber.getBigDecimalScale("salestax.calc.decimals"); + private static final RoundingMode TAX_ROUNDING = UtilNumber.getRoundingMode("salestax.rounding"); + private static final int DECIMALS = UtilNumber.getBigDecimalScale("order.decimals"); + private static final RoundingMode ROUNDING = UtilNumber.getRoundingMode("order.rounding"); + private static final BigDecimal ZERO = BigDecimal.ZERO.setScale(TAX_SCALE, TAX_ROUNDING); + static { SALES_ROLE_MAP.put("placingCustomerPartyId", "PLACING_CUSTOMER"); SALES_ROLE_MAP.put("billToCustomerPartyId", "BILL_TO_CUSTOMER"); @@ -109,11 +115,6 @@ public class OrderServices { PURCHASE_ROLE_MAP.put("shipFromVendorPartyId", "SHIP_FROM_VENDOR"); PURCHASE_ROLE_MAP.put("supplierAgentPartyId", "SUPPLIER_AGENT"); } - private static final int TAX_SCALE = UtilNumber.getBigDecimalScale("salestax.calc.decimals"); - private static final RoundingMode TAX_ROUNDING = UtilNumber.getRoundingMode("salestax.rounding"); - private static final int DECIMALS = UtilNumber.getBigDecimalScale("order.decimals"); - private static final RoundingMode ROUNDING = UtilNumber.getRoundingMode("order.rounding"); - private static final BigDecimal ZERO = BigDecimal.ZERO.setScale(TAX_SCALE, TAX_ROUNDING); private static boolean hasPermission(String orderId, GenericValue userLogin, String action, Security security, Delegator delegator) { OrderReadHelper orh = new OrderReadHelper(delegator, orderId); @@ -130,7 +131,8 @@ public class OrderServices { if (!hasPermission) { GenericValue placingCustomer = null; try { - placingCustomer = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "partyId", userLogin.getString("partyId"), "roleTypeId", "PLACING_CUSTOMER").queryOne(); + placingCustomer = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "partyId", userLogin.getString("partyId"), + "roleTypeId", "PLACING_CUSTOMER").queryOne(); } catch (GenericEntityException e) { Debug.logError("Could not select OrderRoles for order " + orderId + " due to " + e.getMessage(), MODULE); } @@ -149,21 +151,27 @@ public class OrderServices { // check sales agent/customer relationship List<GenericValue> repsCustomers = new LinkedList<>(); try { - repsCustomers = EntityUtil.filterByDate(userLogin.getRelatedOne("Party", false).getRelated("FromPartyRelationship", UtilMisc.toMap("roleTypeIdFrom", "AGENT", "roleTypeIdTo", "CUSTOMER", "partyIdTo", partyId), null, false)); + repsCustomers = EntityUtil.filterByDate(userLogin.getRelatedOne("Party", false).getRelated("FromPartyRelationship", + UtilMisc.toMap("roleTypeIdFrom", "AGENT", "roleTypeIdTo", "CUSTOMER", "partyIdTo", partyId), null, false)); } catch (GenericEntityException ex) { - Debug.logError("Could not determine if " + partyId + " is a customer of user " + userLogin.getString("userLoginId") + " due to " + ex.getMessage(), MODULE); + Debug.logError("Could not determine if " + partyId + " is a customer of user " + userLogin.getString("userLoginId") + " due" + + " to " + ex.getMessage(), MODULE); } - if ((repsCustomers != null) && (repsCustomers.size() > 0) && (security.hasEntityPermission("ORDERMGR", "_ROLE_" + action, userLogin))) { + if ((repsCustomers != null) && (repsCustomers.size() > 0) && (security.hasEntityPermission("ORDERMGR", "_ROLE_" + action, + userLogin))) { hasPermission = true; } if (!hasPermission) { // check sales sales rep/customer relationship try { - repsCustomers = EntityUtil.filterByDate(userLogin.getRelatedOne("Party", false).getRelated("FromPartyRelationship", UtilMisc.toMap("roleTypeIdFrom", "SALES_REP", "roleTypeIdTo", "CUSTOMER", "partyIdTo", partyId), null, false)); + repsCustomers = EntityUtil.filterByDate(userLogin.getRelatedOne("Party", false).getRelated("FromPartyRelationship", + UtilMisc.toMap("roleTypeIdFrom", "SALES_REP", "roleTypeIdTo", "CUSTOMER", "partyIdTo", partyId), null, false)); } catch (GenericEntityException ex) { - Debug.logError("Could not determine if " + partyId + " is a customer of user " + userLogin.getString("userLoginId") + " due to " + ex.getMessage(), MODULE); + Debug.logError("Could not determine if " + partyId + " is a customer of user " + userLogin.getString("userLoginId") + + " due to " + ex.getMessage(), MODULE); } - if ((repsCustomers != null) && (repsCustomers.size() > 0) && (security.hasEntityPermission("ORDERMGR", "_ROLE_" + action, userLogin))) { + if ((repsCustomers != null) && (repsCustomers.size() > 0) && (security.hasEntityPermission("ORDERMGR", "_ROLE_" + action, + userLogin))) { hasPermission = true; } } @@ -174,7 +182,10 @@ public class OrderServices { } return hasPermission; } - /** Service for creating a new order */ + + /** + * Service for creating a new order + */ public static Map<String, Object> createOrder(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); @@ -212,7 +223,7 @@ public class OrderServices { productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).cache().queryOne(); } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "OrderErrorCouldNotFindProductStoreWithID", UtilMisc.toMap("productStoreId", productStoreId), locale) + e.toString()); + "OrderErrorCouldNotFindProductStoreWithID", UtilMisc.toMap("productStoreId", productStoreId), locale) + e.toString()); } } @@ -279,7 +290,8 @@ public class OrderServices { try { // count product ordered quantities // run this synchronously so it will run in the same transaction - Map<String, Object> result = dispatcher.runSync("countProductQuantityOrdered", UtilMisc.<String, Object>toMap("productId", currentProductId, "quantity", orderItem.getBigDecimal("quantity"), "userLogin", userLogin)); + Map<String, Object> result = dispatcher.runSync("countProductQuantityOrdered", UtilMisc.<String, Object>toMap("productId", + currentProductId, "quantity", orderItem.getBigDecimal("quantity"), "userLogin", userLogin)); if (ServiceUtil.isError(result)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); } @@ -307,14 +319,14 @@ public class OrderServices { try { product = EntityQuery.use(delegator).from("Product").where("productId", currentProductId).cache().queryOne(); } catch (GenericEntityException e) { - String errMsg = UtilProperties.getMessage(RES_ERROR, "product.not_found", new Object[] {currentProductId }, locale); + String errMsg = UtilProperties.getMessage(RES_ERROR, "product.not_found", new Object[]{currentProductId}, locale); Debug.logError(e, errMsg, MODULE); errorMessages.add(errMsg); continue; } if (product == null) { - String errMsg = UtilProperties.getMessage(RES_ERROR, "product.not_found", new Object[] {currentProductId }, locale); + String errMsg = UtilProperties.getMessage(RES_ERROR, "product.not_found", new Object[]{currentProductId}, locale); Debug.logError(errMsg, MODULE); errorMessages.add(errMsg); continue; @@ -324,7 +336,7 @@ public class OrderServices { // check to see if introductionDate hasn't passed yet if (product.get("introductionDate") != null && nowTimestamp.before(product.getTimestamp("introductionDate"))) { String excMsg = UtilProperties.getMessage(RES_ERROR, "product.not_yet_for_sale", - new Object[] { getProductName(product, itemName), product.getString("productId") }, locale); + new Object[]{getProductName(product, itemName), product.getString("productId")}, locale); Debug.logWarning(excMsg, MODULE); errorMessages.add(excMsg); continue; @@ -333,16 +345,19 @@ public class OrderServices { if ("SALES_ORDER".equals(orderTypeId)) { boolean salesDiscontinuationFlag = false; - // When past orders are imported, they should be imported even if sales discontinuation date is in the past but if the order date was before it + // When past orders are imported, they should be imported even if sales discontinuation date is in the past but if the order date + // was before it if (orderDate != null && product.get("salesDiscontinuationDate") != null) { - salesDiscontinuationFlag = orderDate.after(product.getTimestamp("salesDiscontinuationDate")) && nowTimestamp.after(product.getTimestamp("salesDiscontinuationDate")); + salesDiscontinuationFlag = + orderDate.after(product.getTimestamp("salesDiscontinuationDate")) && nowTimestamp.after(product.getTimestamp( + "salesDiscontinuationDate")); } else if (product.get("salesDiscontinuationDate") != null) { salesDiscontinuationFlag = nowTimestamp.after(product.getTimestamp("salesDiscontinuationDate")); } // check to see if salesDiscontinuationDate has passed if (salesDiscontinuationFlag) { String excMsg = UtilProperties.getMessage(RES_ERROR, "product.no_longer_for_sale", - new Object[] { getProductName(product, itemName), product.getString("productId") }, locale); + new Object[]{getProductName(product, itemName), product.getString("productId")}, locale); Debug.logWarning(excMsg, MODULE); errorMessages.add(excMsg); continue; @@ -352,14 +367,15 @@ public class OrderServices { if ("SALES_ORDER".equals(orderTypeId)) { // check to see if we have inventory available try { - Map<String, Object> invReqResult = dispatcher.runSync("isStoreInventoryAvailableOrNotRequired", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "quantity", currentQuantity)); + Map<String, Object> invReqResult = dispatcher.runSync("isStoreInventoryAvailableOrNotRequired", UtilMisc.toMap("productStoreId", + productStoreId, "productId", product.get("productId"), "product", product, "quantity", currentQuantity)); if (ServiceUtil.isError(invReqResult)) { errorMessages.add(ServiceUtil.getErrorMessage(invReqResult)); List<String> errMsgList = UtilGenerics.cast(invReqResult.get(ModelService.ERROR_MESSAGE_LIST)); errorMessages.addAll(errMsgList); } else if (!"Y".equals(invReqResult.get("availableOrNotRequired"))) { String invErrMsg = UtilProperties.getMessage(RES_ERROR, "product.out_of_stock", - new Object[] {getProductName(product, itemName), currentProductId }, locale); + new Object[]{getProductName(product, itemName), currentProductId}, locale); Debug.logWarning(invErrMsg, MODULE); errorMessages.add(invErrMsg); continue; @@ -373,7 +389,8 @@ public class OrderServices { } // add the fixedAsset id to the workefforts map by obtaining the fixed Asset number from the FixedAssetProduct table - List<GenericValue> workEfforts = UtilGenerics.cast(context.get("workEfforts")); // is an optional parameter from this service but mandatory for rental items + List<GenericValue> workEfforts = UtilGenerics.cast(context.get("workEfforts")); // is an optional parameter from this service but mandatory + // for rental items for (GenericValue orderItem : orderItems) { if ("RENTAL_ORDER_ITEM".equals(orderItem.getString("orderItemTypeId"))) { // check to see if workefforts are available for this order type. @@ -390,13 +407,15 @@ public class OrderServices { if (workEffort.getString("workEffortId").equals(orderItem.getString("orderItemSeqId"))) { List<GenericValue> selFixedAssetProduct = null; try { - selFixedAssetProduct = EntityQuery.use(delegator).from("FixedAssetProduct").where("productId", orderItem.getString("productId"), "fixedAssetProductTypeId", "FAPT_USE").filterByDate(nowTimestamp, "fromDate", "thruDate").queryList(); + selFixedAssetProduct = EntityQuery.use(delegator).from("FixedAssetProduct").where("productId", orderItem.getString( + "productId"), "fixedAssetProductTypeId", "FAPT_USE").filterByDate(nowTimestamp, "fromDate", "thruDate").queryList(); } catch (GenericEntityException e) { String excMsg = "Could not find related Fixed Asset for the product: " + orderItem.getString("productId"); Debug.logError(excMsg, MODULE); errorMessages.add(excMsg); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "OrderCouldNotFindRelatedFixedAssetForTheProduct", UtilMisc.toMap("productId", orderItem.getString("productId")), locale)); + "OrderCouldNotFindRelatedFixedAssetForTheProduct", UtilMisc.toMap("productId", + orderItem.getString("productId")), locale)); } if (UtilValidate.isNotEmpty(selFixedAssetProduct)) { @@ -476,7 +495,8 @@ public class OrderServices { orderHeaderMap.put("orderName", context.get("orderName")); orderHeaderMap.put("agreementId", context.get("agreementId")); if (isImmediatelyFulfilled) { - // also flag this order as needing inventory issuance so that when it is set to complete it will be issued immediately (needsInventoryIssuance = Y) + // also flag this order as needing inventory issuance so that when it is set to complete it will be issued immediately + // (needsInventoryIssuance = Y) orderHeaderMap.put("needsInventoryIssuance", "Y"); } GenericValue orderHeader = delegator.makeValue("OrderHeader", orderHeaderMap); @@ -625,9 +645,9 @@ public class OrderServices { for (String orderInternalNote : orderInternalNotes) { try { Map<String, Object> noteOutputMap = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, - "internalNote", "Y", - "note", orderInternalNote, - "userLogin", userLogin)); + "internalNote", "Y", + "note", orderInternalNote, + "userLogin", userLogin)); if (ServiceUtil.isError(noteOutputMap)) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "OrderOrderNoteCannotBeCreated", UtilMisc.toMap("errorString", ""), locale), @@ -647,13 +667,13 @@ public class OrderServices { for (String orderNote : orderNotes) { try { Map<String, Object> noteOutputMap = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, - "internalNote", "N", - "note", orderNote, - "userLogin", userLogin)); + "internalNote", "N", + "note", orderNote, + "userLogin", userLogin)); if (ServiceUtil.isError(noteOutputMap)) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "OrderOrderNoteCannotBeCreated", UtilMisc.toMap("errorString", ""), locale), - null, null, noteOutputMap); + "OrderOrderNoteCannotBeCreated", UtilMisc.toMap("errorString", ""), locale), + null, null, noteOutputMap); } } catch (GenericServiceException e) { Debug.logError(e, "Error creating notes while creating order: " + e.toString(), MODULE); @@ -719,7 +739,8 @@ public class OrderServices { tempList.add(fixedAsset); } // then create the workEffort and the workOrderItemFulfillment to connect to the order and orderItem - workOrderItemFulfillment.set("orderItemSeqId", workEffort.get("workEffortId").toString()); // orderItemSeqNo is stored here so save first + workOrderItemFulfillment.set("orderItemSeqId", workEffort.get("workEffortId").toString()); // orderItemSeqNo is stored here so save + // first // workeffort String workEffortId = delegator.getNextSeqId("WorkEffort"); // find next available workEffortId workEffort.set("workEffortId", workEffortId); @@ -741,13 +762,15 @@ public class OrderServices { // find an existing Day exception record Timestamp exceptionDateStartTime = UtilDateTime.getDayStart(new Timestamp(estimatedStartDate.getTime()), (int) dayCount); try { - techDataCalendarExcDay = EntityQuery.use(delegator).from("TechDataCalendarExcDay").where("calendarId", fixedAsset.get("calendarId"), "exceptionDateStartTime", exceptionDateStartTime).queryOne(); + techDataCalendarExcDay = EntityQuery.use(delegator).from("TechDataCalendarExcDay").where("calendarId", fixedAsset.get( + "calendarId"), "exceptionDateStartTime", exceptionDateStartTime).queryOne(); } catch (GenericEntityException e) { Debug.logInfo(" techData excday record not found so creating........", MODULE); } if (techDataCalendarExcDay == null) { for (GenericValue currentValue : tempList) { - if ("TechDataCalendarExcDay".equals(currentValue.getEntityName()) && currentValue.getString("calendarId").equals(fixedAsset.getString("calendarId")) + if ("TechDataCalendarExcDay".equals(currentValue.getEntityName()) + && currentValue.getString("calendarId").equals(fixedAsset.getString("calendarId")) && currentValue.getTimestamp("exceptionDateStartTime").equals(exceptionDateStartTime)) { techDataCalendarExcDay = currentValue; break; @@ -762,11 +785,15 @@ public class OrderServices { techDataCalendarExcDay.set("exceptionCapacity", fixedAsset.getBigDecimal("productionCapacity")); } // add the quantity to the quantity on the date record - BigDecimal newUsedCapacity = techDataCalendarExcDay.getBigDecimal("usedCapacity").add(workEffort.getBigDecimal("quantityToProduce")); - // check to see if the requested quantity is available on the requested day but only when the maximum capacity is set on the fixed asset + BigDecimal newUsedCapacity = techDataCalendarExcDay.getBigDecimal("usedCapacity").add(workEffort.getBigDecimal( + "quantityToProduce")); + // check to see if the requested quantity is available on the requested day but only when the maximum capacity is set on the + // fixed asset if (fixedAsset.get("productionCapacity") != null) { - if (newUsedCapacity.compareTo(techDataCalendarExcDay.getBigDecimal("exceptionCapacity")) > 0) { - String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderFixedAssetSoldOut", UtilMisc.toMap("fixedAssetId", workEffort.get("fixedAssetId"), "exceptionDateStartTime", techDataCalendarExcDay.getString("exceptionDateStartTime")), locale); + if (newUsedCapacity.compareTo(techDataCalendarExcDay.getBigDecimal("exceptionCapacity")) > 0) { + String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderFixedAssetSoldOut", UtilMisc.toMap("fixedAssetId", + workEffort.get("fixedAssetId"), "exceptionDateStartTime", + techDataCalendarExcDay.getString("exceptionDateStartTime")), locale); Debug.logError(errMsg, MODULE); errorMessages.add(errMsg); continue; @@ -828,7 +855,8 @@ public class OrderServices { } // set the order item ship groups - List<String> dropShipGroupIds = new LinkedList<>(); // this list will contain the ids of all the ship groups for drop shipments (no reservations) + List<String> dropShipGroupIds = new LinkedList<>(); // this list will contain the ids of all the ship groups for drop shipments (no + // reservations) if (UtilValidate.isNotEmpty(orderItemShipGroupInfo)) { for (GenericValue valueObj : orderItemShipGroupInfo) { valueObj.set("orderId", orderId); @@ -861,8 +889,10 @@ public class OrderServices { List<String> parties = entry.getValue(); if (parties != null) { for (String additionalPartyId : parties) { - toBeStored.add(delegator.makeValue("PartyRole", UtilMisc.toMap("partyId", additionalPartyId, "roleTypeId", additionalRoleTypeId))); - toBeStored.add(delegator.makeValue("OrderRole", UtilMisc.toMap("orderId", orderId, "partyId", additionalPartyId, "roleTypeId", additionalRoleTypeId))); + toBeStored.add(delegator.makeValue("PartyRole", UtilMisc.toMap("partyId", additionalPartyId, "roleTypeId", + additionalRoleTypeId))); + toBeStored.add(delegator.makeValue("OrderRole", UtilMisc.toMap("orderId", orderId, "partyId", additionalPartyId, + "roleTypeId", additionalRoleTypeId))); } } } @@ -908,7 +938,7 @@ public class OrderServices { // store the orderProductPromoUseInfos List<GenericValue> orderProductPromoUses = UtilGenerics.cast(context.get("orderProductPromoUses")); if (UtilValidate.isNotEmpty(orderProductPromoUses)) { - for (GenericValue productPromoUse : orderProductPromoUses) { + for (GenericValue productPromoUse : orderProductPromoUses) { productPromoUse.set("orderId", orderId); toBeStored.add(productPromoUse); } @@ -933,8 +963,10 @@ public class OrderServices { for (Map.Entry<String, String> attributeRoleEntry : attributeRoleMap.entrySet()) { if (UtilValidate.isNotEmpty(context.get(attributeRoleEntry.getKey()))) { // make sure the party is in the role before adding - toBeStored.add(delegator.makeValue("PartyRole", UtilMisc.toMap("partyId", context.get(attributeRoleEntry.getKey()), "roleTypeId", attributeRoleEntry.getValue()))); - toBeStored.add(delegator.makeValue("OrderRole", UtilMisc.toMap("orderId", orderId, "partyId", context.get(attributeRoleEntry.getKey()), "roleTypeId", attributeRoleEntry.getValue()))); + toBeStored.add(delegator.makeValue("PartyRole", UtilMisc.toMap("partyId", context.get(attributeRoleEntry.getKey()), "roleTypeId", + attributeRoleEntry.getValue()))); + toBeStored.add(delegator.makeValue("OrderRole", UtilMisc.toMap("orderId", orderId, "partyId", + context.get(attributeRoleEntry.getKey()), "roleTypeId", attributeRoleEntry.getValue()))); } } @@ -953,7 +985,8 @@ public class OrderServices { UtilMisc.toMap("orderId", orderId, "partyId", distributorId, "roleTypeId", "DISTRIBUTOR"))); } - // find all parties in role VENDOR associated with WebSite OR ProductStore (where WebSite overrides, if specified), associated first valid with the Order + // find all parties in role VENDOR associated with WebSite OR ProductStore (where WebSite overrides, if specified), associated first valid + // with the Order if (UtilValidate.isNotEmpty(context.get("productStoreId"))) { try { GenericValue productStoreRole = EntityQuery.use(delegator).from("ProductStoreRole") @@ -972,7 +1005,8 @@ public class OrderServices { } if (UtilValidate.isNotEmpty(context.get("webSiteId"))) { try { - GenericValue webSiteRole = EntityQuery.use(delegator).from("WebSiteRole").where("roleTypeId", "VENDOR", "webSiteId", context.get("webSiteId")).orderBy("-fromDate").filterByDate().queryFirst(); + GenericValue webSiteRole = EntityQuery.use(delegator).from("WebSiteRole").where("roleTypeId", "VENDOR", "webSiteId", context.get( + "webSiteId")).orderBy("-fromDate").filterByDate().queryFirst(); if (webSiteRole != null) { toBeStored.add(delegator.makeValue("OrderRole", UtilMisc.toMap("orderId", orderId, "partyId", webSiteRole.get("partyId"), "roleTypeId", "VENDOR"))); @@ -1011,7 +1045,7 @@ public class OrderServices { } } - // store the OrderTerm entities + // store the OrderTerm entities List<GenericValue> orderTerms = UtilGenerics.cast(context.get("orderTerms")); if (UtilValidate.isNotEmpty(orderTerms)) { @@ -1042,17 +1076,19 @@ public class OrderServices { // add a product service to inventory if (UtilValidate.isNotEmpty(orderItems)) { - for (GenericValue orderItem: orderItems) { + for (GenericValue orderItem : orderItems) { String productId = (String) orderItem.get("productId"); GenericValue product = delegator.getRelatedOne("Product", orderItem, false); - if (product != null && ("SERVICE_PRODUCT".equals(product.get("productTypeId")) || "AGGREGATEDSERV_CONF".equals(product.get("productTypeId")))) { + if (product != null && ("SERVICE_PRODUCT".equals(product.get("productTypeId")) || "AGGREGATEDSERV_CONF".equals(product.get( + "productTypeId")))) { String inventoryFacilityId = null; if ("Y".equals(productStore.getString("oneInventoryFacility"))) { inventoryFacilityId = productStore.getString("inventoryFacilityId"); if (UtilValidate.isEmpty(inventoryFacilityId)) { - Debug.logWarning("ProductStore with id " + productStoreId + " has Y for oneInventoryFacility but inventoryFacilityId is empty, returning false for inventory check", MODULE); + Debug.logWarning("ProductStore with id " + productStoreId + " has Y for oneInventoryFacility but " + + "inventoryFacilityId is empty, returning false for inventory check", MODULE); } } else { List<GenericValue> productFacilities = null; @@ -1071,7 +1107,8 @@ public class OrderServices { } Map<String, Object> ripCtx = new HashMap<>(); - if (UtilValidate.isNotEmpty(inventoryFacilityId) && UtilValidate.isNotEmpty(productId) && orderItem.getBigDecimal("quantity").compareTo(BigDecimal.ZERO) > 0) { + if (UtilValidate.isNotEmpty(inventoryFacilityId) && UtilValidate.isNotEmpty(productId) && orderItem.getBigDecimal("quantity") + .compareTo(BigDecimal.ZERO) > 0) { ripCtx.put("productId", productId); ripCtx.put("facilityId", inventoryFacilityId); ripCtx.put("inventoryItemTypeId", "SERIALIZED_INV_ITEM"); @@ -1085,7 +1122,8 @@ public class OrderServices { if (ServiceUtil.isError(ripResult)) { String errMsg = ServiceUtil.getErrorMessage(ripResult); @SuppressWarnings("unchecked") - Collection<? extends String> map = (Collection<? extends String>) UtilMisc.<String, String>toMap("reasonCode", "ReceiveInventoryServiceError", "description", errMsg); + Collection<? extends String> map = (Collection<? extends String>) UtilMisc.<String, String>toMap("reasonCode", + "ReceiveInventoryServiceError", "description", errMsg); resErrorMessages.addAll(map); } } catch (GenericServiceException e) { @@ -1167,7 +1205,9 @@ public class OrderServices { return ServiceUtil.returnSuccess(); } - public static void reserveInventory(Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin, Locale locale, List<GenericValue> orderItemShipGroupInfo, List<String> dropShipGroupIds, Map<String, GenericValue> itemValuesBySeqId, String orderTypeId, String productStoreId, List<String> resErrorMessages) throws GeneralException { + public static void reserveInventory(Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin, Locale locale, + List<GenericValue> orderItemShipGroupInfo, List<String> dropShipGroupIds, Map<String, GenericValue> itemValuesBySeqId, + String orderTypeId, String productStoreId, List<String> resErrorMessages) throws GeneralException { boolean isImmediatelyFulfilled = false; GenericValue productStore = null; if (UtilValidate.isNotEmpty(productStoreId)) { @@ -1199,11 +1239,12 @@ public class OrderServices { continue; } GenericValue orderItem = itemValuesBySeqId.get(orderItemShipGroupAssoc.get("orderItemSeqId")); - if ("SALES_ORDER".equals(orderTypeId) && orderItem != null && productStore != null && "Y".equals(productStore.getString("allocateInventory"))) { + if ("SALES_ORDER".equals(orderTypeId) && orderItem != null && productStore != null && "Y".equals(productStore.getString( + "allocateInventory"))) { //If the 'autoReserve' flag is not set for the order item, don't reserve the inventory String autoReserve = OrderReadHelper.getOrderItemAttribute(orderItem, "autoReserve"); if (autoReserve == null || !"true".equals(autoReserve)) { - continue; + continue; } } if ("SALES_ORDER".equals(orderTypeId) && orderItem != null) { @@ -1217,7 +1258,8 @@ public class OrderServices { String shipGroupFacilityId = orderItemShipGroup.getString("facilityId"); String itemStatus = orderItem.getString("statusId"); if ("ITEM_REJECTED".equals(itemStatus) || "ITEM_CANCELLED".equals(itemStatus) || "ITEM_COMPLETED".equals(itemStatus)) { - Debug.logInfo("Order item [" + orderItem.getString("orderId") + " / " + orderItem.getString("orderItemSeqId") + "] is not in a proper status for reservation", MODULE); + Debug.logInfo("Order item [" + orderItem.getString("orderId") + " / " + orderItem.getString("orderItemSeqId") + "] is not " + + "in a proper status for reservation", MODULE); continue; } if (UtilValidate.isNotEmpty(orderItem.getString("productId")) && // only reserve product items, ignore non-product items @@ -1232,8 +1274,10 @@ public class OrderServices { } if (reserveInventory) { // for MARKETING_PKG_PICK reserve the components - if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG_PICK")) { - Map<String, Object> componentsRes = dispatcher.runSync("getAssociatedProducts", UtilMisc.toMap("productId", orderItem.getString("productId"), "type", "PRODUCT_COMPONENT")); + if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), + "parentTypeId", "MARKETING_PKG_PICK")) { + Map<String, Object> componentsRes = dispatcher.runSync("getAssociatedProducts", UtilMisc.toMap("productId", + orderItem.getString("productId"), "type", "PRODUCT_COMPONENT")); if (ServiceUtil.isError(componentsRes)) { resErrorMessages.add(ServiceUtil.getErrorMessage(componentsRes)); continue; @@ -1256,7 +1300,8 @@ public class OrderServices { if (ServiceUtil.isError(reserveResult)) { String invErrMsg = "The product "; invErrMsg += getProductName(product, orderItem); - invErrMsg += " with ID " + orderItem.getString("productId") + " is no longer in stock. Please try reducing the quantity or removing the product from this order."; + invErrMsg += " with ID " + orderItem.getString("productId") + " is no longer in stock. Please try " + + "reducing the quantity or removing the product from this order."; resErrorMessages.add(invErrMsg); } } @@ -1277,17 +1322,21 @@ public class OrderServices { if (ServiceUtil.isError(reserveResult)) { String invErrMsg = "The product "; invErrMsg += getProductName(product, orderItem); - invErrMsg += " with ID " + orderItem.getString("productId") + " is no longer in stock. Please try reducing the quantity or removing the product from this order."; + invErrMsg += " with ID " + orderItem.getString("productId") + " is no longer in stock. Please try reducing " + + "the quantity or removing the product from this order."; resErrorMessages.add(invErrMsg); } } } // Reserving inventory or not we still need to create a marketing package - // If the product is a marketing package auto, attempt to create enough packages to bring ATP back to 0, won't necessarily create enough to cover this order. - if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG_AUTO")) { + // If the product is a marketing package auto, attempt to create enough packages to bring ATP back to 0, won't + // necessarily create enough to cover this order. + if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), + "parentTypeId", "MARKETING_PKG_AUTO")) { // do something tricky here: run as the "system" user // that can actually create and run a production run - GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); + GenericValue permUserLogin = + EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); Map<String, Object> inputMap = new HashMap<>(); if (UtilValidate.isNotEmpty(shipGroupFacilityId)) { inputMap.put("facilityId", shipGroupFacilityId); @@ -1310,7 +1359,8 @@ public class OrderServices { } // rent item - if (UtilValidate.isNotEmpty(orderItem.getString("productId")) && "RENTAL_ORDER_ITEM".equals(orderItem.getString("orderItemTypeId"))) { + if (UtilValidate.isNotEmpty(orderItem.getString("productId")) && "RENTAL_ORDER_ITEM".equals(orderItem.getString( + "orderItemTypeId"))) { try { // get the product of the order item GenericValue product = orderItem.getRelatedOne("Product", false); @@ -1325,8 +1375,10 @@ public class OrderServices { if ("ASSET_USAGE_OUT_IN".equals(productType)) { if (reserveInventory) { // for MARKETING_PKG_PICK reserve the components - if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG_PICK")) { - Map<String, Object> componentsRes = dispatcher.runSync("getAssociatedProducts", UtilMisc.toMap("productId", orderItem.getString("productId"), "type", "PRODUCT_COMPONENT")); + if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), + "parentTypeId", "MARKETING_PKG_PICK")) { + Map<String, Object> componentsRes = dispatcher.runSync("getAssociatedProducts", UtilMisc.toMap("productId", + orderItem.getString("productId"), "type", "PRODUCT_COMPONENT")); if (ServiceUtil.isError(componentsRes)) { resErrorMessages.add((String) componentsRes.get(ModelService.ERROR_MESSAGE)); continue; @@ -1350,7 +1402,8 @@ public class OrderServices { if (ServiceUtil.isError(reserveResult)) { String invErrMsg = "The product "; invErrMsg += getProductName(product, orderItem); - invErrMsg += " with ID " + orderItem.getString("productId") + " is no longer in stock. Please try reducing the quantity or removing the product from this order."; + invErrMsg += " with ID " + orderItem.getString("productId") + " is no longer in stock. Please try " + + "reducing the quantity or removing the product from this order."; resErrorMessages.add(invErrMsg); } } @@ -1363,7 +1416,8 @@ public class OrderServices { reserveInput.put("orderItemSeqId", orderItem.getString("orderItemSeqId")); reserveInput.put("shipGroupSeqId", orderItemShipGroupAssoc.getString("shipGroupSeqId")); reserveInput.put("facilityId", shipGroupFacilityId); - // use the quantity from the orderItemShipGroupAssoc, NOT the orderItem, these are reserved by item-group assoc + // use the quantity from the orderItemShipGroupAssoc, NOT the orderItem, these are reserved by item-group + // assoc reserveInput.put("quantity", orderItemShipGroupAssoc.getBigDecimal("quantity")); reserveInput.put("userLogin", userLogin); Map<String, Object> reserveResult = dispatcher.runSync("reserveStoreInventory", reserveInput); @@ -1371,14 +1425,17 @@ public class OrderServices { if (ServiceUtil.isError(reserveResult)) { String invErrMsg = "The product "; invErrMsg += getProductName(product, orderItem); - invErrMsg += " with ID " + orderItem.getString("productId") + " is no longer in stock. Please try reducing the quantity or removing the product from this order."; + invErrMsg += " with ID " + orderItem.getString("productId") + " is no longer in stock. Please try " + + "reducing the quantity or removing the product from this order."; resErrorMessages.add(invErrMsg); } } } - if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG_AUTO")) { - GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); + if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), + "parentTypeId", "MARKETING_PKG_AUTO")) { + GenericValue permUserLogin = + EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); Map<String, Object> inputMap = new HashMap<>(); if (UtilValidate.isNotEmpty(shipGroupFacilityId)) { inputMap.put("facilityId", shipGroupFacilityId); @@ -1429,7 +1486,9 @@ public class OrderServices { return null; } - /** Service for resetting the OrderHeader grandTotal */ + /** + * Service for resetting the OrderHeader grandTotal + */ public static Map<String, Object> resetGrandTotal(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); Locale locale = (Locale) context.get("locale"); @@ -1439,7 +1498,8 @@ public class OrderServices { try { orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); } catch (GenericEntityException e) { - String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderCouldNotSetGrantTotalOnOrderHeader", UtilMisc.toMap("errorString", e.toString()), locale); + String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderCouldNotSetGrantTotalOnOrderHeader", UtilMisc.toMap("errorString", + e.toString()), locale); Debug.logError(e, errMsg, MODULE); return ServiceUtil.returnError(errMsg); } @@ -1483,7 +1543,8 @@ public class OrderServices { try { orderHeader.store(); } catch (GenericEntityException e) { - String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderCouldNotSetGrantTotalOnOrderHeader", UtilMisc.toMap("errorString", e.toString()), locale); + String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderCouldNotSetGrantTotalOnOrderHeader", UtilMisc.toMap("errorString", + e.toString()), locale); Debug.logError(e, errMsg, MODULE); return ServiceUtil.returnError(errMsg); } @@ -1493,7 +1554,9 @@ public class OrderServices { return ServiceUtil.returnSuccess(); } - /** Service for setting the OrderHeader grandTotal for all OrderHeaders with no grandTotal */ + /** + * Service for setting the OrderHeader grandTotal for all OrderHeaders with no grandTotal + */ public static Map<String, Object> setEmptyGrandTotals(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); @@ -1519,7 +1582,8 @@ public class OrderServices { String orderId = orderHeader.getString("orderId"); Map<String, Object> resetResult = null; try { - resetResult = dispatcher.runSync("resetGrandTotal", UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", userLogin)); + resetResult = dispatcher.runSync("resetGrandTotal", UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", + userLogin)); if (ServiceUtil.isError(resetResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resetResult)); } @@ -1542,7 +1606,9 @@ public class OrderServices { return ServiceUtil.returnSuccess(); } - /** Service for checking and re-calc the tax amount */ + /** + * Service for checking and re-calc the tax amount + */ public static Map<String, Object> recalcOrderTax(DispatchContext ctx, Map<String, ? extends Object> context) { LocalDispatcher dispatcher = ctx.getDispatcher(); Delegator delegator = ctx.getDelegator(); @@ -1576,7 +1642,8 @@ public class OrderServices { // Retrieve the order tax adjustments List<GenericValue> orderTaxAdjustments = null; try { - orderTaxAdjustments = EntityQuery.use(delegator).from("OrderAdjustment").where("orderId", orderId, "orderAdjustmentTypeId", "SALES_TAX").queryList(); + orderTaxAdjustments = EntityQuery.use(delegator).from("OrderAdjustment").where("orderId", orderId, "orderAdjustmentTypeId", + "SALES_TAX").queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to retrieve SALES_TAX adjustments for order : " + orderId, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, @@ -1595,7 +1662,8 @@ public class OrderServices { BigDecimal totalManuallyAddedOrderTax = ZERO; for (GenericValue orderTaxAdjustment : orderTaxAdjustments) { if (orderTaxAdjustment.get("amount") != null && "Y".equals(orderTaxAdjustment.getString("isManual"))) { - totalManuallyAddedOrderTax = totalManuallyAddedOrderTax.add(orderTaxAdjustment.getBigDecimal("amount").setScale(TAX_SCALE, TAX_ROUNDING)); + totalManuallyAddedOrderTax = totalManuallyAddedOrderTax.add(orderTaxAdjustment.getBigDecimal("amount").setScale(TAX_SCALE, + TAX_ROUNDING)); } } @@ -1632,9 +1700,11 @@ public class OrderServices { GenericValue orderItem = validOrderItems.get(i); String productId = orderItem.getString("productId"); try { - products.add(i, EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne()); // get the product entity + products.add(i, EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne()); // get the + // product entity amounts.add(i, OrderReadHelper.getOrderItemSubTotal(orderItem, allAdjustments, true, false)); // get the item amount - shipAmts.add(i, OrderReadHelper.getOrderItemAdjustmentsTotal(orderItem, allAdjustments, false, false, true)); // get the shipping amount + shipAmts.add(i, OrderReadHelper.getOrderItemAdjustmentsTotal(orderItem, allAdjustments, false, false, true)); // get + // the shipping amount itPrices.add(i, orderItem.getBigDecimal("unitPrice")); itQuantities.add(i, orderItem.getBigDecimal("quantity")); } catch (GenericEntityException e) { @@ -1659,10 +1729,12 @@ public class OrderServices { // face-to-face order; use the facility address String facilityId = orderHeader.getString("originFacilityId"); if (facilityId != null) { - GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); + GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, + UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); if (facilityContactMech != null) { try { - shippingAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", facilityContactMech.getString("contactMechId")).queryOne(); + shippingAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", + facilityContactMech.getString("contactMechId")).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, MODULE); } @@ -1670,15 +1742,19 @@ public class OrderServices { } } - // if shippingAddress is still null then don't calculate tax; it may be an situation where no tax is applicable, or the data is bad and we don't have a way to find an address to check tax for + // if shippingAddress is still null then don't calculate tax; it may be an situation where no tax is applicable, or the data is + // bad and we don't have a way to find an address to check tax for if (shippingAddress == null) { - Debug.logWarning("Not calculating tax for Order [" + orderId + "] because there is no shippingAddress, and no address on the origin facility [" + orderHeader.getString("originFacilityId") + "]", MODULE); + Debug.logWarning("Not calculating tax for Order [" + orderId + "] because there is no shippingAddress, and no address on " + + "the origin facility [" + orderHeader.getString("originFacilityId") + "]", MODULE); continue; } // prepare the service context - Map<String, Object> serviceContext = UtilMisc.<String, Object>toMap("productStoreId", orh.getProductStoreId(), "itemProductList", products, "itemAmountList", amounts, - "itemShippingList", shipAmts, "itemPriceList", itPrices, "itemQuantityList", itQuantities, "orderShippingAmount", orderShipping); + Map<String, Object> serviceContext = UtilMisc.<String, Object>toMap("productStoreId", orh.getProductStoreId(), "itemProductList", + products, "itemAmountList", amounts, + "itemShippingList", shipAmts, "itemPriceList", itPrices, "itemQuantityList", itQuantities, "orderShippingAmount", + orderShipping); serviceContext.put("shippingAddress", shippingAddress); serviceContext.put("orderPromotionsAmount", orderPromotions); if (orh.getBillToParty() != null) { @@ -1770,7 +1846,9 @@ public class OrderServices { return ServiceUtil.returnSuccess(); } - /** Service for checking and re-calc the shipping amount */ + /** + * Service for checking and re-calc the shipping amount + */ public static Map<String, Object> recalcOrderShipping(DispatchContext ctx, Map<String, ? extends Object> context) { LocalDispatcher dispatcher = ctx.getDispatcher(); Delegator delegator = ctx.getDelegator(); @@ -1817,7 +1895,8 @@ public class OrderServices { shippingTotal = ZERO; Debug.logInfo("No valid order items found - " + shippingTotal, MODULE); } else { - shippingTotal = UtilValidate.isEmpty(shippingEstMap.get("shippingTotal")) ? ZERO : (BigDecimal) shippingEstMap.get("shippingTotal"); + shippingTotal = UtilValidate.isEmpty(shippingEstMap.get("shippingTotal")) ? ZERO : (BigDecimal) shippingEstMap.get( + "shippingTotal"); shippingTotal = shippingTotal.setScale(DECIMALS, ROUNDING); Debug.logInfo("Got new shipping estimate - " + shippingTotal, MODULE); } @@ -1825,8 +1904,10 @@ public class OrderServices { Debug.logInfo("New Shipping Total [" + orderId + " / " + shipGroupSeqId + "] : " + shippingTotal, MODULE); } - BigDecimal currentShipping = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orh.getOrderItemAndShipGroupAssoc(shipGroupSeqId), orh.getAdjustments(), false, false, true); - currentShipping = currentShipping.add(OrderReadHelper.calcOrderAdjustments(orh.getOrderHeaderAdjustments(shipGroupSeqId), orh.getOrderItemsSubTotal(), false, false, true)); + BigDecimal currentShipping = OrderReadHelper.getAllOrderItemsAdjustmentsTotal(orh.getOrderItemAndShipGroupAssoc(shipGroupSeqId), + orh.getAdjustments(), false, false, true); + currentShipping = currentShipping.add(OrderReadHelper.calcOrderAdjustments(orh.getOrderHeaderAdjustments(shipGroupSeqId), + orh.getOrderItemsSubTotal(), false, false, true)); if (Debug.infoOn()) { Debug.logInfo("Old Shipping Total [" + orderId + " / " + shipGroupSeqId + "] : " + currentShipping, MODULE); @@ -1834,7 +1915,8 @@ public class OrderServices { List<String> errorMessageList = UtilGenerics.cast(shippingEstMap.get(ModelService.ERROR_MESSAGE_LIST)); if (errorMessageList != null) { - Debug.logWarning("Problem finding shipping estimates for [" + orderId + "/ " + shipGroupSeqId + "] = " + errorMessageList, MODULE); + Debug.logWarning("Problem finding shipping estimates for [" + orderId + "/ " + shipGroupSeqId + "] = " + errorMessageList, + MODULE); continue; } @@ -1867,7 +1949,9 @@ public class OrderServices { } - /** Service for checking to see if an order is fully completed or canceled */ + /** + * Service for checking to see if an order is fully completed or canceled + */ public static Map<String, Object> checkItemStatus(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); @@ -1937,17 +2021,22 @@ public class OrderServices { } else if (allApproved) { boolean changeToApprove = true; - // NOTE DEJ20070805 I'm not sure why we would want to auto-approve the header... adding at least this one exeption so that we don't have to add processing, held, etc statuses to the item status list - // NOTE2 related to the above: appears this was a weird way to set the order header status by setting all order item statuses... changing that to be less weird and more direct - // this is a bit of a pain: if the current statusId = ProductStore.headerApprovedStatus and we don't have that status in the history then we don't want to change it on approving the items + // NOTE DEJ20070805 I'm not sure why we would want to auto-approve the header... adding at least this one exeption so that we don't + // have to add processing, held, etc statuses to the item status list + // NOTE2 related to the above: appears this was a weird way to set the order header status by setting all order item statuses... + // changing that to be less weird and more direct + // this is a bit of a pain: if the current statusId = ProductStore.headerApprovedStatus and we don't have that status in the + // history then we don't want to change it on approving the items if (UtilValidate.isNotEmpty(orderHeader.getString("productStoreId"))) { try { - GenericValue productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", orderHeader.getString("productStoreId")).queryOne(); + GenericValue productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", orderHeader.getString( + "productStoreId")).queryOne(); if (productStore != null) { String headerApprovedStatus = productStore.getString("headerApprovedStatus"); if (UtilValidate.isNotEmpty(headerApprovedStatus)) { if (headerApprovedStatus.equals(orderHeaderStatusId)) { - List<GenericValue> orderStatusList = EntityQuery.use(delegator).from("OrderStatus").where("orderId", orderId, "statusId", headerApprovedStatus, "orderItemSeqId", null).queryList(); + List<GenericValue> orderStatusList = EntityQuery.use(delegator).from("OrderStatus").where("orderId", orderId, + "statusId", headerApprovedStatus, "orderItemSeqId", null).queryList(); // should be 1 in the history, but just in case accept 0 too if (orderStatusList.size() <= 1) { changeToApprove = false; @@ -1956,7 +2045,8 @@ public class OrderServices { } } } catch (GenericEntityException e) { - String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderDatabaseErrorCheckingIfWeShouldChangeOrderHeaderStatusToApproved", UtilMisc.toMap("errorString", e.toString()), locale); + String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderDatabaseErrorCheckingIfWeShouldChangeOrderHeaderStatusToApproved" + , UtilMisc.toMap("errorString", e.toString()), locale); Debug.logError(e, errMsg, MODULE); return ServiceUtil.returnError(errMsg); } @@ -1985,7 +2075,8 @@ public class OrderServices { // now set the new order status if (newStatus != null && !newStatus.equals(orderHeaderStatusId)) { - Map<String, Object> serviceContext = UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", newStatus, "userLogin", userLogin); + Map<String, Object> serviceContext = UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", newStatus, "userLogin", + userLogin); Map<String, Object> newSttsResult = null; try { newSttsResult = dispatcher.runSync("changeOrderStatus", serviceContext); @@ -2004,7 +2095,9 @@ public class OrderServices { return ServiceUtil.returnSuccess(); } - /** Service to cancel an order item quantity */ + /** + * Service to cancel an order item quantity + */ public static Map<String, Object> cancelOrderItem(DispatchContext ctx, Map<String, ? extends Object> context) { LocalDispatcher dispatcher = ctx.getDispatcher(); Delegator delegator = ctx.getDelegator(); @@ -2131,7 +2224,7 @@ public class OrderServices { "shipGroupSeqId", orderItemShipGroupAssoc.getString("shipGroupSeqId")); if (availableQuantity.compareTo(thisCancelQty) == 0) { try { - resp= dispatcher.runSync("deleteOrderItemShipGroupAssoc", localCtx); + resp = dispatcher.runSync("deleteOrderItemShipGroupAssoc", localCtx); if (ServiceUtil.isError(resp)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resp)); } @@ -2188,17 +2281,20 @@ public class OrderServices { if (thisCancelQty.compareTo(itemQuantity) >= 0) { if ("ITEM_COMPLETED".equals(itemStatus) && "SALES_ORDER".equals(orh.getOrderTypeId())) { //If partial item shipped then release remaining inventory of SO item and marked SO item as completed. - Map<String, Object> cancelOrderItemInvResCtx = UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.getString("orderItemSeqId"), "shipGroupSeqId", + Map<String, Object> cancelOrderItemInvResCtx = UtilMisc.toMap("orderId", orderId, "orderItemSeqId", + orderItem.getString("orderItemSeqId"), "shipGroupSeqId", shipGroupSeqId, "cancelQuantity", thisCancelQty, "userLogin", userLogin); try { dispatcher.runSyncIgnore("cancelOrderItemInvResQty", cancelOrderItemInvResCtx); } catch (GenericServiceException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToUpdateInventoryReservations", UtilMisc.toMap("itemMsgInfo", itemMsgInfo), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToUpdateInventoryReservations", + UtilMisc.toMap("itemMsgInfo", itemMsgInfo), locale)); } } // all items are cancelled -- mark the item as cancelled - Map<String, Object> statusCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItem.getString("orderItemSeqId"), "statusId", itemStatus, "userLogin", userLogin); + Map<String, Object> statusCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItem.getString( + "orderItemSeqId"), "statusId", itemStatus, "userLogin", userLogin); try { dispatcher.runSyncIgnore("changeOrderItemStatus", statusCtx); } catch (GenericServiceException e) { @@ -2208,7 +2304,8 @@ public class OrderServices { } } else { // reverse the inventory reservation - Map<String, Object> invCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItem.getString("orderItemSeqId"), "shipGroupSeqId", + Map<String, Object> invCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItem.getString( + "orderItemSeqId"), "shipGroupSeqId", shipGroupSeqId, "cancelQuantity", thisCancelQty, "userLogin", userLogin); try { dispatcher.runSyncIgnore("cancelOrderItemInvResQty", invCtx); @@ -2231,7 +2328,9 @@ public class OrderServices { return ServiceUtil.returnSuccess(); } - /** Service for changing the status on order item(s) */ + /** + * Service for changing the status on order item(s) + */ public static Map<String, Object> setItemStatus(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); @@ -2255,7 +2354,8 @@ public class OrderServices { exprs.add(EntityCondition.makeCondition("orderId", orderId)); if (orderItemSeqId != null) { exprs.add(EntityCondition.makeCondition("orderItemSeqId", orderItemSeqId)); - } if (fromStatusId != null) { + } + if (fromStatusId != null) { exprs.add(EntityCondition.makeCondition("statusId", fromStatusId)); } else { exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_IN, UtilMisc.toList("ITEM_COMPLETED", "ITEM_CANCELLED"))); @@ -2277,7 +2377,8 @@ public class OrderServices { "OrderErrorCannotChangeItemStatusItemNotFound", locale)); } if (Debug.verboseOn()) { - Debug.logVerbose("[OrderServices.setItemStatus] : Status Change: [" + orderId + "] (" + orderItem.getString("orderItemSeqId"), MODULE); + Debug.logVerbose("[OrderServices.setItemStatus] : Status Change: [" + orderId + "] (" + orderItem.getString("orderItemSeqId"), + MODULE); } if (Debug.verboseOn()) { Debug.logVerbose("[OrderServices.setItemStatus] : From Status : " + orderItem.getString("statusId"), MODULE); @@ -2291,11 +2392,13 @@ public class OrderServices { } try { - GenericValue statusChange = EntityQuery.use(delegator).from("StatusValidChange").where("statusId", orderItem.getString("statusId"), "statusIdTo", statusId).queryOne(); + GenericValue statusChange = EntityQuery.use(delegator).from("StatusValidChange").where("statusId", orderItem.getString( + "statusId"), "statusIdTo", statusId).queryOne(); if (statusChange == null) { Debug.logWarning(UtilProperties.getMessage(RES_ERROR, - "OrderItemStatusNotChangedIsNotAValidChange", UtilMisc.toMap("orderStatusId", orderItem.getString("statusId"), "statusId", statusId), locale), MODULE); + "OrderItemStatusNotChangedIsNotAValidChange", UtilMisc.toMap("orderStatusId", orderItem.getString("statusId"), + "statusId", statusId), locale), MODULE); continue; } } catch (GenericEntityException e) { @@ -2335,7 +2438,9 @@ public class OrderServices { return ServiceUtil.returnSuccess(); } - /** Service for changing the status on an order header */ + /** + * Service for changing the status on an order header + */ public static Map<String, Object> setOrderStatus(DispatchContext ctx, Map<String, ? extends Object> context) { LocalDispatcher dispatcher = ctx.getDispatcher(); Delegator delegator = ctx.getDelegator(); @@ -2374,14 +2479,17 @@ public class OrderServices { if (orderHeader.getString("statusId").equals(statusId)) { Debug.logWarning(UtilProperties.getMessage(RES_ERROR, - "OrderTriedToSetOrderStatusWithTheSameStatusIdforOrderWithId", UtilMisc.toMap("statusId", statusId, "orderId", orderId), locale), MODULE); + "OrderTriedToSetOrderStatusWithTheSameStatusIdforOrderWithId", UtilMisc.toMap("statusId", statusId, "orderId", orderId), + locale), MODULE); return successResult; } try { - GenericValue statusChange = EntityQuery.use(delegator).from("StatusValidChange").where("statusId", orderHeader.getString("statusId"), "statusIdTo", statusId).cache(true).queryOne(); + GenericValue statusChange = EntityQuery.use(delegator).from("StatusValidChange").where("statusId", + orderHeader.getString("statusId"), "statusIdTo", statusId).cache(true).queryOne(); if (statusChange == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "OrderErrorCouldNotChangeOrderStatusStatusIsNotAValidChange", locale) + ": [" + orderHeader.getString("statusId") + "] -> [" + statusId + "]"); + "OrderErrorCouldNotChangeOrderStatusStatusIsNotAValidChange", locale) + ": [" + orderHeader.getString("statusId") + "] " + + "-> [" + statusId + "]"); } } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, @@ -2422,7 +2530,8 @@ public class OrderServices { if (newItemStatusId != null) { try { - Map<String, Object> resp = dispatcher.runSync("changeOrderItemStatus", UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", newItemStatusId, "userLogin", userLogin)); + Map<String, Object> resp = dispatcher.runSync("changeOrderItemStatus", UtilMisc.<String, Object>toMap("orderId", orderId, + "statusId", newItemStatusId, "userLogin", userLogin)); if (ServiceUtil.isError(resp)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderErrorCouldNotChangeItemStatus", locale) + newItemStatusId, null, null, resp); @@ -2439,7 +2548,9 @@ public class OrderServices { return successResult; } - /** Service to update the order tracking number */ + /** + * Service to update the order tracking number + */ public static Map<String, Object> updateTrackingNumber(DispatchContext dctx, Map<String, ? extends Object> context) { Map<String, Object> result = new HashMap<>(); Delegator delegator = dctx.getDelegator(); @@ -2448,7 +2559,8 @@ public class OrderServices { String trackingNumber = (String) context.get("trackingNumber"); try { - GenericValue shipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", shipGroupSeqId).queryOne(); + GenericValue shipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", + shipGroupSeqId).queryOne(); if (shipGroup == null) { result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); @@ -2466,7 +2578,9 @@ public class OrderServices { return result; } - /** Service to add a role type to an order */ + /** + * Service to add a role type to an order + */ public static Map<String, Object> addRoleType(DispatchContext ctx, Map<String, ? extends Object> context) { Map<String, Object> result = new HashMap<>(); Delegator delegator = ctx.getDelegator(); @@ -2505,7 +2619,9 @@ public class OrderServices { return result; } - /** Service to remove a role type from an order */ + /** + * Service to remove a role type from an order + */ public static Map<String, Object> removeRoleType(DispatchContext ctx, Map<String, ? extends Object> context) { Map<String, Object> result = new HashMap<>(); Delegator delegator = ctx.getDelegator(); @@ -2515,7 +2631,8 @@ public class OrderServices { GenericValue testValue = null; try { - testValue = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "partyId", partyId, "roleTypeId", roleTypeId).queryOne(); + testValue = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "partyId", partyId, "roleTypeId", roleTypeId) + .queryOne(); } catch (GenericEntityException e) { result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); result.put(ModelService.ERROR_MESSAGE, "ERROR: Could not add role to order (" + e.getMessage() + ")."); @@ -2528,7 +2645,8 @@ public class OrderServices { } try { - GenericValue value = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "partyId", partyId, "roleTypeId", roleTypeId).queryOne(); + GenericValue value = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "partyId", partyId, "roleTypeId", + roleTypeId).queryOne(); value.remove(); } catch (GenericEntityException e) { @@ -2540,27 +2658,37 @@ public class OrderServices { return result; } - /** Service to email a customer with initial order confirmation */ + /** + * Service to email a customer with initial order confirmation + */ public static Map<String, Object> sendOrderConfirmNotification(DispatchContext ctx, Map<String, ? extends Object> context) { return sendOrderNotificationScreen(ctx, context, "PRDS_ODR_CONFIRM"); } - /** Service to email a customer with order changes */ + /** + * Service to email a customer with order changes + */ public static Map<String, Object> sendOrderCompleteNotification(DispatchContext ctx, Map<String, ? extends Object> context) { return sendOrderNotificationScreen(ctx, context, "PRDS_ODR_COMPLETE"); } - /** Service to email a customer with order changes */ + /** + * Service to email a customer with order changes + */ public static Map<String, Object> sendOrderBackorderNotification(DispatchContext ctx, Map<String, ? extends Object> context) { return sendOrderNotificationScreen(ctx, context, "PRDS_ODR_BACKORDER"); } - /** Service to email a customer with order changes */ + /** + * Service to email a customer with order changes + */ public static Map<String, Object> sendOrderChangeNotification(DispatchContext ctx, Map<String, ? extends Object> context) { return sendOrderNotificationScreen(ctx, context, "PRDS_ODR_CHANGE"); } - /** Service to email a customer with order payment retry results */ + /** + * Service to email a customer with order payment retry results + */ public static Map<String, Object> sendOrderPayRetryNotification(DispatchContext ctx, Map<String, ? extends Object> context) { return sendOrderNotificationScreen(ctx, context, "PRDS_ODR_PAYRETRY"); } @@ -2607,9 +2735,11 @@ public class OrderServices { GenericValue productStoreEmail = null; try { - productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", orderHeader.get("productStoreId"), "emailType", emailType).queryOne(); + productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", + orderHeader.get("productStoreId"), "emailType", emailType).queryOne(); } catch (GenericEntityException e) { - Debug.logError(e, "Problem getting the ProductStoreEmailSetting for productStoreId=" + orderHeader.get("productStoreId") + " and emailType=" + emailType, MODULE); + Debug.logError(e, "Problem getting the ProductStoreEmailSetting for productStoreId=" + orderHeader.get("productStoreId") + " and " + + "emailType=" + emailType, MODULE); } if (productStoreEmail == null) { return ServiceUtil.returnFailure(UtilProperties.getMessage(RES_PRODUCT, @@ -2629,7 +2759,8 @@ public class OrderServices { String xslfoAttachScreenLocation = productStoreEmail.getString("xslfoAttachScreenLocation"); sendMap.put("xslfoAttachScreenLocation", xslfoAttachScreenLocation); // add attachmentName param to get an attachment namend "[oderId].pdf" instead of default "Details.pdf" - sendMap.put("attachmentName", (UtilValidate.isNotEmpty(shipGroupSeqId) ? orderId + "-" + StringUtils.stripStart(shipGroupSeqId, "0") : orderId) + ".pdf"); + sendMap.put("attachmentName", (UtilValidate.isNotEmpty(shipGroupSeqId) ? orderId + "-" + StringUtils.stripStart(shipGroupSeqId, "0") + : orderId) + ".pdf"); sendMap.put("attachmentType", MimeConstants.MIME_PDF); } else { sendMap.put("bodyScreenUri", screenUri); @@ -2657,7 +2788,8 @@ public class OrderServices { // or if not available then the system Locale Locale locale = null; GenericValue placingParty = orh.getPlacingParty(); - GenericValue placingUserLogin = placingParty == null ? null : PartyWorker.findPartyLatestUserLogin(placingParty.getString("partyId"), delegator); + GenericValue placingUserLogin = placingParty == null ? null : PartyWorker.findPartyLatestUserLogin(placingParty.getString("partyId"), + delegator); if (placingParty != null) { locale = PartyWorker.findPartyLastLocale(placingParty.getString("partyId"), delegator); } @@ -2678,8 +2810,9 @@ public class OrderServices { locale = Locale.getDefault(); } - Map<String, Object> bodyParameters = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "userLogin", placingUserLogin, "locale", locale); - if (placingParty!= null) { + Map<String, Object> bodyParameters = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "userLogin", + placingUserLogin, "locale", locale); + if (placingParty != null) { bodyParameters.put("partyId", placingParty.get("partyId")); } bodyParameters.put("note", note); @@ -2732,7 +2865,9 @@ public class OrderServices { return sendResp; } - /** Service to email order notifications for pending actions */ + /** + * Service to email order notifications for pending actions + */ public static Map<String, Object> sendProcessNotification(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); @@ -2824,7 +2959,9 @@ public class OrderServices { return ServiceUtil.returnSuccess(); } - /** Service to get order header information as standard results. */ + /** + * Service to get order header information as standard results. + */ public static Map<String, Object> getOrderHeaderInformation(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); String orderId = (String) context.get("orderId"); @@ -2847,7 +2984,9 @@ public class OrderServices { "OrderErrorGettingOrderHeaderInformationNull", locale)); } - /** Service to get the total shipping for an order. */ + /** + * Service to get the total shipping for an order. + */ public static Map<String, Object> getOrderShippingAmount(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); String orderId = (String) context.get("orderId"); @@ -2877,7 +3016,7 @@ public class OrderServices { result.put("shippingAmount", shippingAmount); } else { result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "OrderUnableToFindOrderHeaderCannotGetShippingAmount", locale)); + "OrderUnableToFindOrderHeaderCannotGetShippingAmount", locale)); } return result; } @@ -2889,8 +3028,8 @@ public class OrderServices { String orderId = (String) context.get("orderId"); Locale locale = (Locale) context.get("locale"); //appears to not be used: GenericValue v = null; - String purpose[] = {"BILLING_LOCATION", "SHIPPING_LOCATION" }; - String outKey[] = {"billingAddress", "shippingAddress" }; + String purpose[] = {"BILLING_LOCATION", "SHIPPING_LOCATION"}; + String outKey[] = {"billingAddress", "shippingAddress"}; GenericValue orderHeader = null; try { @@ -2912,7 +3051,8 @@ public class OrderServices { } for (int i = 0; i < purpose.length; i++) { try { - GenericValue orderContactMech = EntityUtil.getFirst(orderHeader.getRelated("OrderContactMech", UtilMisc.toMap("contactMechPurposeTypeId", purpose[i]), null, false)); + GenericValue orderContactMech = EntityUtil.getFirst(orderHeader.getRelated("OrderContactMech", UtilMisc.toMap( + "contactMechPurposeTypeId", purpose[i]), null, false)); GenericValue contactMech = orderContactMech.getRelatedOne("ContactMech", false); if (contactMech != null) { @@ -2982,7 +3122,8 @@ public class OrderServices { if (!security.hasEntityPermission("ORDERMGR", "_UPDATE", userLogin)) { GenericValue placingCustomer = null; try { - placingCustomer = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "partyId", userLogin.getString("partyId"), "roleTypeId", "PLACING_CUSTOMER").queryOne(); + placingCustomer = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "partyId", userLogin.getString("partyId"), + "roleTypeId", "PLACING_CUSTOMER").queryOne(); } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderErrorCannotGetOrderRoleEntity", locale) + e.getMessage()); @@ -3078,7 +3219,8 @@ public class OrderServices { Date nowDate = new Date(); if (cancelDate.equals(nowDate) || nowDate.after(cancelDate)) { // cancel the order item(s) - Map<String, Object> svcCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", "ITEM_CANCELLED", "userLogin", userLogin); + Map<String, Object> svcCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", "ITEM_CANCELLED", "userLogin", + userLogin); try { // TODO: looks like result is ignored here, but we should be looking for errors Map<String, Object> serviceResult = dispatcher.runSync("changeOrderItemStatus", svcCtx); @@ -3096,7 +3238,8 @@ public class OrderServices { // create the query expressions itemsExprs.add(EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderId)); - itemsExprs.add(EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ITEM_CREATED"), + itemsExprs.add(EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, + "ITEM_CREATED"), EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ITEM_APPROVED")), EntityOperator.OR)); itemsExprs.add(EntityCondition.makeCondition("dontCancelSetUserLogin", EntityOperator.EQUALS, GenericEntity.NULL_FIELD)); itemsExprs.add(EntityCondition.makeCondition("dontCancelSetDate", EntityOperator.EQUALS, GenericEntity.NULL_FIELD)); @@ -3116,7 +3259,8 @@ public class OrderServices { if (autoCancelDate != null) { if (nowTimestamp.equals(autoCancelDate) || nowTimestamp.after(autoCancelDate)) { // cancel the order item - Map<String, Object> svcCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "statusId", "ITEM_CANCELLED", "userLogin", userLogin); + Map<String, Object> svcCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, + "statusId", "ITEM_CANCELLED", "userLogin", userLogin); try { // TODO: check service result for an error return Map<String, Object> serviceResult = dispatcher.runSync("changeOrderItemStatus", svcCtx); @@ -3230,7 +3374,8 @@ public class OrderServices { Map<String, Object> invoiceResult = null; try { GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); - Map<String, Object> invoiceContext = UtilMisc.<String, Object>toMap("orderId", orderId, "billItems", itemsToInvoice, "userLogin", permUserLogin); + Map<String, Object> invoiceContext = UtilMisc.<String, Object>toMap("orderId", orderId, "billItems", itemsToInvoice, "userLogin" + , permUserLogin); invoiceResult = dispatcher.runSync("createInvoiceForOrder", invoiceContext); if (ServiceUtil.isError(invoiceResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(invoiceResult)); @@ -3286,7 +3431,8 @@ public class OrderServices { } // fulfill the digital goods - Map<String, Object> fulfillContext = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItems", digitalItems, "userLogin", userLogin); + Map<String, Object> fulfillContext = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItems", digitalItems, "userLogin", + userLogin); Map<String, Object> fulfillResult = null; try { // will be running in an isolated transaction to prevent rollbacks @@ -3332,7 +3478,8 @@ public class OrderServices { } List<EntityExpr> exprs = new ArrayList<>(); - exprs.add(EntityCondition.makeCondition("productContentTypeId", EntityOperator.IN, UtilMisc.toList("FULFILLMENT_EXTASYNC", "FULFILLMENT_EXTSYNC", "FULFILLMENT_EMAIL", "DIGITAL_DOWNLOAD"))); + exprs.add(EntityCondition.makeCondition("productContentTypeId", EntityOperator.IN, UtilMisc.toList("FULFILLMENT_EXTASYNC", + "FULFILLMENT_EXTSYNC", "FULFILLMENT_EMAIL", "DIGITAL_DOWNLOAD"))); exprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, product.getString("productId"))); // try looking up the parent product if the product has no content and is a variant @@ -3350,8 +3497,8 @@ public class OrderServices { if (UtilValidate.isNotEmpty(allProductContent)) { // only keep ones with valid dates productContent = EntityUtil.filterByDate(allProductContent, UtilDateTime.nowTimestamp(), "fromDate", "thruDate", true); - Debug.logInfo("Product has " + allProductContent.size() + " associations, " + - (productContent == null ? "0" : "" + productContent.size()) + " has valid from/thru dates", MODULE); + Debug.logInfo("Product has " + allProductContent.size() + " associations, " + + (productContent == null ? "0" : "" + productContent.size()) + " has valid from/thru dates", MODULE); } } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, @@ -3375,7 +3522,8 @@ public class OrderServices { GenericValue custMethod = null; if (UtilValidate.isNotEmpty(content.getString("customMethodId"))) { try { - custMethod = EntityQuery.use(delegator).from("CustomMethod").where("customMethodId", content.get("customMethodId")).cache().queryOne(); + custMethod = EntityQuery.use(delegator).from("CustomMethod").where("customMethodId", content.get( + "customMethodId")).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "ERROR: Cannot get CustomMethod associate to Content entity: " + e.getMessage(), MODULE); continue; @@ -3385,7 +3533,8 @@ public class OrderServices { fulfillmentService = custMethod.getString("customMethodName"); } if (fulfillmentService == null) { - Debug.logError("ProductContent of type FULFILLMENT_EXTERNAL had Content with empty serviceName, can not run fulfillment", MODULE); + Debug.logError("ProductContent of type FULFILLMENT_EXTERNAL had Content with empty serviceName, can not run " + + "fulfillment", MODULE); } Map<String, Object> serviceCtx = UtilMisc.<String, Object>toMap("userLogin", userLogin, "orderItem", orderItem); serviceCtx.putAll(productContentItem.getPrimaryKey()); @@ -3401,7 +3550,8 @@ public class OrderServices { } } } catch (GenericServiceException e) { - Debug.logError(e, "ERROR: Could not run external fulfillment service '" + fulfillmentService + "'; " + e.getMessage(), MODULE); + Debug.logError(e, "ERROR: Could not run external fulfillment service '" + fulfillmentService + "'; " + + e.getMessage(), MODULE); } } else if ("FULFILLMENT_EMAIL".equals(fulfillmentType)) { // digital email fulfillment @@ -3410,7 +3560,6 @@ public class OrderServices { "OrderEmailFulfillmentTypeNotYetImplemented", locale)); } else if ("DIGITAL_DOWNLOAD".equals(fulfillmentType)) { // digital download fulfillment - // Nothing to do for here. Downloads are made available to the user // though a query of OrderItems with related ProductContent. } else { @@ -3580,7 +3729,8 @@ public class OrderServices { if ("PURCHASE_ORDER".equals(cart.getOrderType())) { GenericValue supplierProduct = cart.getSupplierProduct(productId, quantity, dispatcher); if (supplierProduct != null) { - item = ShoppingCartItem.makePurchaseOrderItem(null, productId, null, quantity, null, null, prodCatalogId, null, orderItemTypeId, null, dispatcher, cart, supplierProduct, itemDesiredDeliveryDate, itemDesiredDeliveryDate, null); + item = ShoppingCartItem.makePurchaseOrderItem(null, productId, null, quantity, null, null, prodCatalogId, null, orderItemTypeId, + null, dispatcher, cart, supplierProduct, itemDesiredDeliveryDate, itemDesiredDeliveryDate, null); cart.addItem(0, item); } else { throw new CartItemModifyException("No supplier information found for product [" + productId + "] and quantity quantity [" + quantity + "], cannot add to cart."); @@ -3596,7 +3746,8 @@ public class OrderServices { cart.clearItemShipInfo(item); cart.setItemShipGroupQty(item, item.getQuantity(), shipGroupIdx); } else { - item = ShoppingCartItem.makeItem(null, productId, null, quantity, null, null, null, null, null, null, null, null, prodCatalogId, null, null, null, dispatcher, cart, null, null, null, Boolean.FALSE, Boolean.FALSE); + item = ShoppingCartItem.makeItem(null, productId, null, quantity, null, null, null, null, null, null, null, null, prodCatalogId, + null, null, null, dispatcher, cart, null, null, null, Boolean.FALSE, Boolean.FALSE); if (basePrice != null && overridePrice != null) { item.setBasePrice(basePrice); // special hack to make sure we re-calc the promos after a price change @@ -3637,7 +3788,7 @@ public class OrderServices { } Map<String, Object> changeMap = UtilMisc.<String, Object>toMap("itemReasonMap", UtilMisc.<String, Object>toMap("reasonEnumId", reasonEnumId), - "itemCommentMap", UtilMisc.<String, Object>toMap("changeComments", changeComments)); + "itemCommentMap", UtilMisc.<String, Object>toMap("changeComments", changeComments)); // save all the updated information try { saveUpdatedCartToOrder(dispatcher, delegator, cart, locale, userLogin, orderId, changeMap, calcTax, false); @@ -3648,8 +3799,8 @@ public class OrderServices { // log an order note try { String addedItemToOrder = UtilProperties.getMessage(RESOURCE, "OrderAddedItemToOrder", locale); - Map<String, Object> result = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", addedItemToOrder - + productId + " (" + quantity + ")", "internalNote", "Y", "userLogin", userLogin)); + Map<String, Object> result = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", + addedItemToOrder + productId + " (" + quantity + ")", "internalNote", "Y", "userLogin", userLogin)); if (ServiceUtil.isError(result)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); } @@ -3733,7 +3884,8 @@ public class OrderServices { if (!ProductWorker.isDecimalQuantityOrderAllowed(delegator, cartItem.getProductId(), cart.getProductStoreId())) { BigDecimal remainder = qty.remainder(BigDecimal.ONE); if (remainder.compareTo(BigDecimal.ZERO) != 0) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", + locale)); } qty = qty.setScale(0, UtilNumber.getRoundingMode("order.rounding")); } else { @@ -3746,7 +3898,8 @@ public class OrderServices { // set quantity try { - cartItem.setQuantity(qty, dispatcher, cart, false, false); // trigger external ops, don't reset ship groups (and update prices for both PO and SO items) + cartItem.setQuantity(qty, dispatcher, cart, false, false); // trigger external ops, don't reset ship groups (and update prices + // for both PO and SO items) } catch (CartItemModifyException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(e.getMessage()); @@ -3896,7 +4049,8 @@ public class OrderServices { if (!ProductWorker.isDecimalQuantityOrderAllowed(delegator, cartItem.getProductId(), cart.getProductStoreId())) { BigDecimal remainder = groupQty.remainder(BigDecimal.ONE); if (remainder.compareTo(BigDecimal.ZERO) != 0) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", + locale)); } groupQty = groupQty.setScale(0, UtilNumber.getRoundingMode("order.rounding")); } else { @@ -3908,19 +4062,22 @@ public class OrderServices { } int shipGroupIndex = cart.getShipInfoIndex(itemInfo[1]); if (Debug.infoOn()) { - Debug.logInfo("Shipping info (before) for group #" + (shipGroupIndex) + " [" + cart.getShipmentMethodTypeId(shipGroupIndex) + " / " + cart.getCarrierPartyId(shipGroupIndex) + "]", MODULE); + Debug.logInfo("Shipping info (before) for group #" + (shipGroupIndex) + " [" + cart.getShipmentMethodTypeId(shipGroupIndex) + + " / " + cart.getCarrierPartyId(shipGroupIndex) + "]", MODULE); } cart.setItemShipGroupQty(cartItem, groupQty, shipGroupIndex); if (Debug.infoOn()) { Debug.logInfo("Set ship group qty: [" + itemInfo[0] + " / " + itemInfo[1] + " (" + (shipGroupIndex) + ")] " + groupQty, MODULE); - Debug.logInfo("Shipping info (after) for group #" + (shipGroupIndex) + " [" + cart.getShipmentMethodTypeId(shipGroupIndex) + " / " + cart.getCarrierPartyId(shipGroupIndex) + "]", MODULE); + Debug.logInfo("Shipping info (after) for group #" + (shipGroupIndex) + " [" + cart.getShipmentMethodTypeId(shipGroupIndex) + " " + + "/ " + cart.getCarrierPartyId(shipGroupIndex) + "]", MODULE); } } } // save all the updated information try { - saveUpdatedCartToOrder(dispatcher, delegator, cart, locale, userLogin, orderId, UtilMisc.<String, Object>toMap("itemReasonMap", itemReasonMap, "itemCommentMap", itemCommentMap), calcTax, false); + saveUpdatedCartToOrder(dispatcher, delegator, cart, locale, userLogin, orderId, UtilMisc.<String, Object>toMap("itemReasonMap", + itemReasonMap, "itemCommentMap", itemCommentMap), calcTax, false); } catch (GeneralException e) { return ServiceUtil.returnError(e.getMessage()); } @@ -3930,7 +4087,8 @@ public class OrderServices { // log an order note try { - Map<String, Object> result = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", "Updated order.", "internalNote", "Y", "userLogin", userLogin)); + Map<String, Object> result = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", "Updated " + + "order.", "internalNote", "Y", "userLogin", userLogin)); if (ServiceUtil.isError(result)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); } @@ -3974,14 +4132,15 @@ public class OrderServices { * must be stored back using the method saveUpdatedCartToOrder(...), * because that method will recreate the data. */ - private static ShoppingCart loadCartForUpdate(LocalDispatcher dispatcher, Delegator delegator, GenericValue userLogin, String orderId) throws GeneralException { + private static ShoppingCart loadCartForUpdate(LocalDispatcher dispatcher, Delegator delegator, GenericValue userLogin, String orderId) + throws GeneralException { // load the order into a shopping cart Map<String, Object> loadCartResp = null; try { loadCartResp = dispatcher.runSync("loadCartFromOrder", UtilMisc.<String, Object>toMap("orderId", orderId, - "skipInventoryChecks", Boolean.TRUE, // the items are already reserved, no need to check again - "skipProductChecks", Boolean.TRUE, // the products are already in the order, no need to check their validity now - "userLogin", userLogin)); + "skipInventoryChecks", Boolean.TRUE, // the items are already reserved, no need to check again + "skipProductChecks", Boolean.TRUE, // the products are already in the order, no need to check their validity now + "userLogin", userLogin)); } catch (GenericServiceException e) { Debug.logError(e, MODULE); throw new GeneralException(e.getMessage()); @@ -4182,12 +4341,13 @@ public class OrderServices { } private static void saveUpdatedCartToOrder(LocalDispatcher dispatcher, Delegator delegator, ShoppingCart cart, - Locale locale, GenericValue userLogin, String orderId, Map<String, Object> changeMap, boolean calcTax, - boolean deleteItems) throws GeneralException { + Locale locale, GenericValue userLogin, String orderId, Map<String, Object> changeMap, boolean calcTax, + boolean deleteItems) throws GeneralException { // get/set the shipping estimates. If it's a SALES ORDER, then return an error if there are no ship estimates int shipGroupsSize = cart.getShipGroupSize(); int realShipGroupsSize = (new OrderReadHelper(delegator, orderId)).getOrderItemShipGroups().size(); - // If an empty csi has initially been added to cart.shipInfo by ShoppingCart.setItemShipGroupQty() (called indirectly by ShoppingCart.setUserLogin() and then ProductPromoWorker.doPromotions(), etc.) + // If an empty csi has initially been added to cart.shipInfo by ShoppingCart.setItemShipGroupQty() (called indirectly by ShoppingCart + // .setUserLogin() and then ProductPromoWorker.doPromotions(), etc.) // shipGroupsSize > realShipGroupsSize are different (+1 for shipGroupsSize), then simply bypass the 1st empty csi! int origin = realShipGroupsSize == shipGroupsSize ? 0 : 1; for (int gi = origin; gi < shipGroupsSize; gi++) { @@ -4253,10 +4413,10 @@ public class OrderServices { if (!deleteItems) { for (long itr = 1; itr <= groupIndex; itr++) { List<GenericValue> removeList = new ArrayList<>(); - for (GenericValue stored: toStore) { + for (GenericValue stored : toStore) { if ("OrderAdjustment".equals(stored.getEntityName())) { if (("SHIPPING_CHARGES".equals(stored.get("orderAdjustmentTypeId")) - || "SALES_TAX".equals(stored.get("orderAdjustmentTypeId"))) + || "SALES_TAX".equals(stored.get("orderAdjustmentTypeId"))) && stored.get("orderId").equals(orderId)) { // Removing objects from toStore list for old Shipping and Handling Charges Adjustment and Sales Tax Adjustment. removeList.add(stored); @@ -4269,10 +4429,11 @@ public class OrderServices { } toStore.removeAll(removeList); } - for (GenericValue toAdd: toAddList) { + for (GenericValue toAdd : toAddList) { if ("OrderAdjustment".equals(toAdd.getEntityName())) { if ("Y".equals(toAdd.getString("isManual")) && (("PROMOTION_ADJUSTMENT".equals(toAdd.get("orderAdjustmentTypeId"))) - || ("SHIPPING_CHARGES".equals(toAdd.get("orderAdjustmentTypeId"))) || ("SALES_TAX".equals(toAdd.get("orderAdjustmentTypeId"))))) { + || ("SHIPPING_CHARGES".equals(toAdd.get("orderAdjustmentTypeId"))) || ("SALES_TAX".equals(toAdd.get( + "orderAdjustmentTypeId"))))) { toStore.add(toAdd); } } @@ -4331,7 +4492,8 @@ public class OrderServices { toRemove.addAll(existingPromoUses); // set the orderId & other information on all new value objects - List<String> dropShipGroupIds = new LinkedList<>(); // this list will contain the ids of all the ship groups for drop shipments (no reservations) + // this list will contain the ids of all the ship groups for drop shipments (no reservations) + List<String> dropShipGroupIds = new LinkedList<>(); for (GenericValue valueObj : toStore) { valueObj.set("orderId", orderId); if ("OrderItemShipGroup".equals(valueObj.getEntityName())) { @@ -4376,7 +4538,8 @@ public class OrderServices { } GenericValue oldOrderItem = null; try { - oldOrderItem = EntityQuery.use(delegator).from("OrderItem").where("orderId", valueObj.getString("orderId"), "orderItemSeqId", valueObj.getString("orderItemSeqId")).queryOne(); + oldOrderItem = EntityQuery.use(delegator).from("OrderItem").where("orderId", valueObj.getString("orderId"), "orderItemSeqId", + valueObj.getString("orderItemSeqId")).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, MODULE); throw new GeneralException(e.getMessage()); @@ -4385,8 +4548,10 @@ public class OrderServices { // Existing order item found. Check for modifications and store if any String oldItemDescription = oldOrderItem.getString("itemDescription") != null ? oldOrderItem.getString("itemDescription") : ""; - BigDecimal oldQuantity = oldOrderItem.getBigDecimal("quantity") != null ? oldOrderItem.getBigDecimal("quantity") : BigDecimal.ZERO; - BigDecimal oldUnitPrice = oldOrderItem.getBigDecimal("unitPrice") != null ? oldOrderItem.getBigDecimal("unitPrice") : BigDecimal.ZERO; + BigDecimal oldQuantity = oldOrderItem.getBigDecimal("quantity") != null ? oldOrderItem.getBigDecimal("quantity") + : BigDecimal.ZERO; + BigDecimal oldUnitPrice = oldOrderItem.getBigDecimal("unitPrice") != null ? oldOrderItem.getBigDecimal("unitPrice") + : BigDecimal.ZERO; String oldItemComment = oldOrderItem.getString("comments") != null ? oldOrderItem.getString("comments") : ""; boolean changeFound = false; @@ -4451,7 +4616,7 @@ public class OrderServices { } if (Debug.verboseOn()) { - Debug.logVerbose("To Store Contains: " + toStore, MODULE); + Debug.logVerbose("To Store Contains: " + toStore, MODULE); } // remove any order item attributes that were set to empty @@ -4472,7 +4637,7 @@ public class OrderServices { // store the OrderItemChange if (UtilValidate.isNotEmpty(modifiedItems)) { - for (Map<String, Object> modifiendItem: modifiedItems) { + for (Map<String, Object> modifiendItem : modifiedItems) { Map<String, Object> serviceCtx = new HashMap<>(); serviceCtx.put("orderId", modifiendItem.get("orderId")); serviceCtx.put("orderItemSeqId", modifiendItem.get("orderItemSeqId")); @@ -4496,7 +4661,7 @@ public class OrderServices { } } - //To create record of OrderStatus entity + //To create record of OrderStatus entity if (UtilValidate.isNotEmpty(newItems)) { for (Map<String, Object> newItem : newItems) { String itemStatusId = delegator.getNextSeqId("OrderStatus"); @@ -4563,7 +4728,8 @@ public class OrderServices { Map<String, Object> paymentResp = null; try { Debug.logInfo("Calling process payments...", MODULE); - paymentResp = CheckOutHelper.processPayment(orderId, orh.getOrderGrandTotal(), orh.getCurrency(), productStore, userLogin, false, false, dispatcher, delegator); + paymentResp = CheckOutHelper.processPayment(orderId, orh.getOrderGrandTotal(), orh.getCurrency(), productStore, userLogin, false, + false, dispatcher, delegator); } catch (GeneralException | GeneralRuntimeException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(e.getMessage()); @@ -4582,7 +4748,8 @@ public class OrderServices { Locale locale = (Locale) context.get("locale"); ShoppingCart cart = new ShoppingCart(dctx.getDelegator(), "9000", "webStore", locale, "USD"); try { - cart.addOrIncreaseItem("GZ-1005", null, BigDecimal.ONE, null, null, null, null, null, null, null, "DemoCatalog", null, null, null, null, dctx.getDispatcher()); + cart.addOrIncreaseItem("GZ-1005", null, BigDecimal.ONE, null, null, null, null, null, null, null, "DemoCatalog", null, null, null, null, + dctx.getDispatcher()); } catch (CartItemModifyException | ItemNotFoundException e) { Debug.logError(e, MODULE); } @@ -4604,6 +4771,7 @@ public class OrderServices { /** * Service to create a payment using an order payment preference. + * * @return Map */ public static Map<String, Object> createPaymentFromPreference(DispatchContext dctx, Map<String, ? extends Object> context) { @@ -4621,7 +4789,8 @@ public class OrderServices { } try { // get the order payment preference - GenericValue orderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne(); + GenericValue orderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", + orderPaymentPreferenceId).queryOne(); if (orderPaymentPreference == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "OrderOrderPaymentCannotBeCreated", @@ -4839,7 +5008,8 @@ public class OrderServices { } List<GenericValue> invInfo = null; try { - invInfo = EntityQuery.use(delegator).from("OrderItemAndShipGrpInvResAndItem").where("orderId", orderId, "statusId", "ITEM_APPROVED").queryList(); + invInfo = EntityQuery.use(delegator).from("OrderItemAndShipGrpInvResAndItem").where("orderId", orderId, "statusId", + "ITEM_APPROVED").queryList(); } catch (GenericEntityException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(e.getMessage()); @@ -5014,14 +5184,14 @@ public class OrderServices { for (GenericValue item : items) { try { int itemIndex = cart.addOrIncreaseItem(item.getString("productId"), - null, // amount - item.getBigDecimal("quantity"), - null, null, null, // reserv - item.getTimestamp("shipBeforeDate"), - item.getTimestamp("shipAfterDate"), - null, null, null, - null, null, null, - null, dispatcher); + null, // amount + item.getBigDecimal("quantity"), + null, null, null, // reserv + item.getTimestamp("shipBeforeDate"), + item.getTimestamp("shipAfterDate"), + null, null, null, + null, null, null, + null, dispatcher); ShoppingCartItem sci = cart.findCartItem(itemIndex); sci.setAssociatedOrderId(orderId); sci.setAssociatedOrderItemSeqId(item.getString("orderItemSeqId")); @@ -5077,7 +5247,8 @@ public class OrderServices { String statusId = (String) context.get("statusId"); try { - GenericValue opp = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne(); + GenericValue opp = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId) + .queryOne(); String paymentMethodId = null; String paymentMethodTypeId = null; @@ -5092,7 +5263,8 @@ public class OrderServices { } } if (paymentMethodTypeId == null) { - GenericValue method = EntityQuery.use(delegator).from("PaymentMethod").where("paymentMethodTypeId", paymentMethodTypeId).queryOne(); + GenericValue method = EntityQuery.use(delegator).from("PaymentMethod").where("paymentMethodTypeId", paymentMethodTypeId) + .queryOne(); paymentMethodId = checkOutPaymentId; paymentMethodTypeId = (String) method.get("paymentMethodTypeId"); } @@ -5125,7 +5297,8 @@ public class OrderServices { /** * Generates a product requirement for the total cancelled quantity over all order items for each product - * @param dctx the dispatch context + * + * @param dctx the dispatch context * @param context the context * @return the result of the service execution */ @@ -5185,7 +5358,9 @@ public class OrderServices { // Generate requirements for each of the product quantities for (String productId : productRequirementQuantities.keySet()) { BigDecimal requiredQuantity = (BigDecimal) productRequirementQuantities.get(productId); - Map<String, Object> createRequirementResult = dispatcher.runSync("createRequirement", UtilMisc.<String, Object>toMap("requirementTypeId", "PRODUCT_REQUIREMENT", "facilityId", facilityId, "productId", productId, "quantity", requiredQuantity, "userLogin", userLogin)); + Map<String, Object> createRequirementResult = dispatcher.runSync("createRequirement", UtilMisc.<String, Object>toMap( + "requirementTypeId", "PRODUCT_REQUIREMENT", "facilityId", facilityId, "productId", productId, "quantity", requiredQuantity, + "userLogin", userLogin)); if (ServiceUtil.isError(createRequirementResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(createRequirementResult)); } @@ -5201,7 +5376,7 @@ public class OrderServices { /** * Cancels remaining (unreceived) quantities for items of an order. Does not consider received-but-rejected quantities. - * @param dctx the dispatch context + * @param dctx the dispatch context * @param context the context * @return cancels remaining (unreceived) quantities for items of an order */ @@ -5258,16 +5433,18 @@ public class OrderServices { BigDecimal quantityToCancel = orderItemQuantity.subtract(orderItemCancelQuantity).subtract(receivedQuantity); if (quantityToCancel.compareTo(BigDecimal.ZERO) > 0) { - Map<String, Object> cancelOrderItemResult = dispatcher.runSync("cancelOrderItem", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "cancelQuantity", quantityToCancel, "userLogin", userLogin)); - if (ServiceUtil.isError(cancelOrderItemResult)) { - return ServiceUtil.returnError(ServiceUtil.getErrorMessage(cancelOrderItemResult)); - } + Map<String, Object> cancelOrderItemResult = dispatcher.runSync("cancelOrderItem", UtilMisc.toMap("orderId", orderId, + "orderItemSeqId", orderItem.get("orderItemSeqId"), "cancelQuantity", quantityToCancel, "userLogin", userLogin)); + if (ServiceUtil.isError(cancelOrderItemResult)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(cancelOrderItemResult)); + } } // If there's nothing to cancel, the item should be set to completed, if it isn't already orderItem.refresh(); if ("ITEM_APPROVED".equals(orderItem.getString("statusId"))) { - Map<String, Object> changeOrderItemStatusResult = dispatcher.runSync("changeOrderItemStatus", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "statusId", "ITEM_COMPLETED", "userLogin", userLogin)); + Map<String, Object> changeOrderItemStatusResult = dispatcher.runSync("changeOrderItemStatus", UtilMisc.toMap("orderId", orderId, + "orderItemSeqId", orderItem.get("orderItemSeqId"), "statusId", "ITEM_COMPLETED", "userLogin", userLogin)); if (ServiceUtil.isError(changeOrderItemStatusResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(changeOrderItemStatusResult)); } @@ -5426,10 +5603,11 @@ public class OrderServices { /** * Determines the total amount invoiced for a given order item over all invoices by totalling the item subtotal (via OrderItemBilling), - * any adjustments for that item (via OrderAdjustmentBilling), and the item's share of any order-level adjustments (that calculated - * by applying the percentage of the items total that the item represents to the order-level adjustments total (also via - * OrderAdjustmentBilling). Also returns the quantity invoiced for the item over all invoices, to aid in prorating. - * @param dctx DispatchContext + * any adjustments for that item (via OrderAdjustmentBilling), and the item's share of any order-level adjustments (that calculated + * by applying the percentage of the items total that the item represents to the order-level adjustments total (also via + * OrderAdjustmentBilling). Also returns the quantity invoiced for the item over all invoices, to aid in prorating. + * + * @param dctx DispatchContext * @param context Map * @return Map */ @@ -5469,7 +5647,8 @@ public class OrderServices { List<GenericValue> orderItems = orderHeader.getRelated("OrderItem", null, UtilMisc.toList("orderItemSeqId"), false); for (GenericValue orderItem : orderItems) { // Look at the orderItemBillings to discover the amount and quantity ever invoiced for this order item - List<GenericValue> orderItemBillings = EntityQuery.use(delegator).from("OrderItemBilling").where("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId")).queryList(); + List<GenericValue> orderItemBillings = EntityQuery.use(delegator).from("OrderItemBilling").where("orderId", orderId, + "orderItemSeqId", orderItem.get("orderItemSeqId")).queryList(); for (GenericValue orderItemBilling : orderItemBillings) { BigDecimal quantity = orderItemBilling.getBigDecimal("quantity"); BigDecimal amount = orderItemBilling.getBigDecimal("amount").setScale(DECIMALS, ROUNDING); @@ -5488,12 +5667,14 @@ public class OrderServices { } // Retrieve the adjustments for this item - List<GenericValue> orderAdjustments = EntityQuery.use(delegator).from("OrderAdjustment").where("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId")).queryList(); + List<GenericValue> orderAdjustments = EntityQuery.use(delegator).from("OrderAdjustment").where("orderId", orderId, "orderItemSeqId", + orderItem.get("orderItemSeqId")).queryList(); for (GenericValue orderAdjustment : orderAdjustments) { String orderAdjustmentTypeId = orderAdjustment.getString("orderAdjustmentTypeId"); // Look at the orderAdjustmentBillings to discove the amount ever invoiced for this order adjustment - List<GenericValue> orderAdjustmentBillings = EntityQuery.use(delegator).from("OrderAdjustmentBilling").where("orderAdjustmentId", orderAdjustment.get("orderAdjustmentId")).queryList(); + List<GenericValue> orderAdjustmentBillings = EntityQuery.use(delegator).from("OrderAdjustmentBilling").where("orderAdjustmentId", + orderAdjustment.get("orderAdjustmentId")).queryList(); for (GenericValue orderAjustmentBilling : orderAdjustmentBillings) { BigDecimal amount = orderAjustmentBilling.getBigDecimal("amount").setScale(DECIMALS, ROUNDING); if (UtilValidate.isEmpty(amount)) { @@ -5522,9 +5703,11 @@ public class OrderServices { // Total the order-header-level adjustments for the order BigDecimal orderHeaderAdjustmentsTotalValue = ZERO; - List<GenericValue> orderHeaderAdjustments = EntityQuery.use(delegator).from("OrderAdjustment").where("orderId", orderId, "orderItemSeqId", "_NA_").queryList(); + List<GenericValue> orderHeaderAdjustments = EntityQuery.use(delegator).from("OrderAdjustment").where("orderId", orderId, + "orderItemSeqId", "_NA_").queryList(); for (GenericValue orderHeaderAdjustment : orderHeaderAdjustments) { - List<GenericValue> orderHeaderAdjustmentBillings = EntityQuery.use(delegator).from("OrderAdjustmentBilling").where("orderAdjustmentId", orderHeaderAdjustment.get("orderAdjustmentId")).queryList(); + List<GenericValue> orderHeaderAdjustmentBillings = EntityQuery.use(delegator).from("OrderAdjustmentBilling").where( + "orderAdjustmentId", orderHeaderAdjustment.get("orderAdjustmentId")).queryList(); for (GenericValue orderHeaderAdjustmentBilling : orderHeaderAdjustmentBillings) { BigDecimal amount = orderHeaderAdjustmentBilling.getBigDecimal("amount").setScale(DECIMALS, ROUNDING); if (UtilValidate.isEmpty(amount)) { @@ -5564,7 +5747,8 @@ public class OrderServices { String changeReason = (String) context.get("changeReason"); Locale locale = (Locale) context.get("locale"); try { - GenericValue orderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne(); + GenericValue orderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", + orderPaymentPreferenceId).queryOne(); String orderId = orderPaymentPreference.getString("orderId"); String statusUserLogin = orderPaymentPreference.getString("createdByUserLogin"); GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); @@ -5585,7 +5769,8 @@ public class OrderServices { orderStatus.put("changeReason", changeReason); // Check that the status has actually changed before creating a new record - GenericValue previousStatus = EntityQuery.use(delegator).from("OrderStatus").where("orderId", orderId, "orderPaymentPreferenceId", orderPaymentPreferenceId).orderBy("-statusDatetime").queryFirst(); + GenericValue previousStatus = EntityQuery.use(delegator).from("OrderStatus").where("orderId", orderId, "orderPaymentPreferenceId", + orderPaymentPreferenceId).orderBy("-statusDatetime").queryFirst(); if (previousStatus != null) { // Temporarily set some values on the new status so that we can do an equals() check orderStatus.put("orderStatusId", previousStatus.get("orderStatusId")); @@ -5606,6 +5791,7 @@ public class OrderServices { return ServiceUtil.returnSuccess(); } + public static Map<String, Object> runSubscriptionAutoReorders(DispatchContext dctx, Map<String, ? extends Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); @@ -5741,6 +5927,7 @@ public class OrderServices { /** * Create an OrderItemShipGroup record + * * @param dctx * @param context * @return @@ -5764,9 +5951,11 @@ public class OrderServices { try { //test if party is a valid carrier String carrierPartyId = (String) context.get("carrierPartyId"); - GenericValue carrierRole = EntityQuery.use(delegator).from("PartyRole").where("partyId", carrierPartyId, "roleTypeId", "CARRIER").cache().queryOne(); + GenericValue carrierRole = EntityQuery.use(delegator).from("PartyRole").where("partyId", carrierPartyId, "roleTypeId", "CARRIER") + .cache().queryOne(); if (UtilValidate.isNotEmpty(carrierPartyId) && UtilValidate.isEmpty(carrierRole)) { - String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderCartShipGroupPartyCarrierNotFound", UtilMisc.toMap("partyId", carrierPartyId), locale); + String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderCartShipGroupPartyCarrierNotFound", UtilMisc.toMap( + "partyId", carrierPartyId), locale); return ServiceUtil.returnError(errMsg); } @@ -5775,9 +5964,11 @@ public class OrderServices { if (UtilValidate.isNotEmpty(shipmentMethodTypeId)) { // carrierPartyId is not in shipmentMethodTypeId if (shipmentMethodTypeId.indexOf("_o_") == -1) { - GenericValue shipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod").where("partyId", carrierPartyId, "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentMethodTypeId).cache().queryOne(); + GenericValue shipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod").where("partyId", carrierPartyId, + "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentMethodTypeId).cache().queryOne(); if (UtilValidate.isEmpty(shipmentMethod)) { - String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderCartShipGroupShipmentMethodNotFound", UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId), locale); + String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderCartShipGroupShipmentMethodNotFound", + UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId), locale); return ServiceUtil.returnError(errMsg); } } else { @@ -5792,7 +5983,8 @@ public class OrderServices { } } - List<GenericValue> oisgs = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId).orderBy("shipGroupSeqId DESC").queryList(); + List<GenericValue> oisgs = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId).orderBy("shipGroupSeqId " + + "DESC").queryList(); if (UtilValidate.isNotEmpty(oisgs)) { GenericValue oisg = EntityUtil.getFirst(oisgs); // set shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId, contactMechId when shipmentMethodTypeId and carrierPartyId are empty @@ -5831,6 +6023,7 @@ public class OrderServices { /** * Remove an OrderItemShipGroup record + * * @param ctx * @param context a map containing in paramaters * @return result: a map containing out parameters @@ -5843,11 +6036,12 @@ public class OrderServices { GenericValue orderItemShipGroup = (GenericValue) context.get("orderItemShipGroup"); if (UtilValidate.isEmpty(orderItemShipGroup)) { - String orderId= (String) context.get("orderId"); + String orderId = (String) context.get("orderId"); GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); - String shipGroupSeqId= (String) context.get("shipGroupSeqId"); + String shipGroupSeqId = (String) context.get("shipGroupSeqId"); if (orderHeader != null && UtilValidate.isNotEmpty(shipGroupSeqId)) { - orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", shipGroupSeqId).queryOne(); + orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", + shipGroupSeqId).queryOne(); if (UtilValidate.isEmpty(orderItemShipGroup)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderItemShipGroupDoesNotExist", locale)); } @@ -5862,6 +6056,7 @@ public class OrderServices { /** * Create orderItem and shipGroup association + * * @param dctx * @param context * @return @@ -5882,7 +6077,8 @@ public class OrderServices { //test orderItem and check status GenericValue orderItem = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryOne(); if (orderItem == null) { - String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderErrorOrderItemNotFound", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId), locale); + String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderErrorOrderItemNotFound", UtilMisc.toMap("orderId", + orderId, "orderItemSeqId", orderItemSeqId), locale); return ServiceUtil.returnError(errMsg); } String statusId = orderItem.getString("statusId"); @@ -5920,9 +6116,11 @@ public class OrderServices { return ServiceUtil.returnError(errMsg); } } - GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", shipGroupSeqId).queryOne(); + GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", + shipGroupSeqId).queryOne(); if (UtilValidate.isEmpty(orderItemShipGroup)) { - String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderCartShipGroupNotFound", UtilMisc.toMap("groupIndex", shipGroupSeqId), locale); + String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderCartShipGroupNotFound", UtilMisc.toMap("groupIndex", + shipGroupSeqId), locale); return ServiceUtil.returnError(errMsg); } //now test quantity parameter @@ -5932,13 +6130,15 @@ public class OrderServices { return ServiceUtil.returnError(errMsg); } //test if this association already exist if yes display error - GenericValue oisgAssoc = EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "shipGroupSeqId", shipGroupSeqId).queryOne(); + GenericValue oisgAssoc = EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId", orderId, "orderItemSeqId", + orderItem.get("orderItemSeqId"), "shipGroupSeqId", shipGroupSeqId).queryOne(); if (oisgAssoc != null) { String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderErrorOrderItemAlreadyRelatedToShipGroup", locale); return ServiceUtil.returnError(errMsg); } //no error, create OISGA - oisgAssoc = delegator.makeValue("OrderItemShipGroupAssoc", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "shipGroupSeqId", shipGroupSeqId)); + oisgAssoc = delegator.makeValue("OrderItemShipGroupAssoc", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.get( + "orderItemSeqId"), "shipGroupSeqId", shipGroupSeqId)); oisgAssoc.set("quantity", quantity); oisgAssoc.create(); return ServiceUtil.returnSuccess(); @@ -5949,6 +6149,7 @@ public class OrderServices { /** * Update orderItem and shipgroup association + * * @param dctx * @param context * @return @@ -5981,13 +6182,15 @@ public class OrderServices { Integer rowNumber = (Integer) context.get("rowNumber"); //total row number if (rowNumber == null) { - Long count = EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryCount(); + Long count = EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId", orderId, "orderItemSeqId", orderItemSeqId) + .queryCount(); rowNumber = count.intValue(); result.put("rowNumber", rowNumber); } //find OISG Assoc - GenericValue oisga = EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId", orderId, "orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId).queryOne(); + GenericValue oisga = EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId", orderId, "orderItemSeqId", orderItemSeqId, "shipGroupSeqId", + shipGroupSeqId).queryOne(); if (UtilValidate.isEmpty(oisga)) { String errMsg = mainErrorMessage + " : Order Item Ship Group Assoc Does Not Exist"; Debug.logError(errMsg, MODULE); @@ -5995,11 +6198,13 @@ public class OrderServices { } // find OISG associated with oisga - GenericValue oisg = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", shipGroupSeqId).queryOne(); + GenericValue oisg = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", shipGroupSeqId) + .queryOne(); //find OrderItem GenericValue orderItem = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryOne(); if (UtilValidate.isEmpty(orderItem)) { - String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderErrorOrderItemNotFound", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId), locale); + String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderErrorOrderItemNotFound", UtilMisc.toMap("orderId", + orderId, "orderItemSeqId", orderItemSeqId), locale); return ServiceUtil.returnError(errMsg); } @@ -6014,12 +6219,14 @@ public class OrderServices { return ServiceUtil.returnError(errMsg); } try { - Map<String, Object> cancelOrderInventoryReservationMap = dctx.makeValidContext("cancelOrderInventoryReservation", ModelService.IN_PARAM, context); + Map<String, Object> cancelOrderInventoryReservationMap = dctx.makeValidContext("cancelOrderInventoryReservation", + ModelService.IN_PARAM, context); Map<String, Object> localResult = dispatcher.runSync("cancelOrderInventoryReservation", cancelOrderInventoryReservationMap); if (ServiceUtil.isError(localResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(localResult)); } - Map<String, Object> deleteOrderItemShipGroupAssocMap = dctx.makeValidContext("deleteOrderItemShipGroupAssoc", ModelService.IN_PARAM, context); + Map<String, Object> deleteOrderItemShipGroupAssocMap = dctx.makeValidContext("deleteOrderItemShipGroupAssoc", + ModelService.IN_PARAM, context); localResult = dispatcher.runSync("deleteOrderItemShipGroupAssoc", deleteOrderItemShipGroupAssocMap); if (ServiceUtil.isError(localResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(localResult)); @@ -6035,7 +6242,8 @@ public class OrderServices { try { message = validateOrderItemShipGroupAssoc(delegator, dispatcher, orderItem, totalQuantity, oisga, userLogin, locale); } catch (GeneralException e) { - String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderQuantityAssociatedIsLessThanOrderItemQuantity", locale); + String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, + "OrderQuantityAssociatedIsLessThanOrderItemQuantity", locale); Debug.logError(errMsg, MODULE); return ServiceUtil.returnError(errMsg); } @@ -6067,7 +6275,8 @@ public class OrderServices { //if quantity is bigger than OI then display error if (quantity.compareTo(orderItemQuantity) > 0) { - String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderQuantityAssociatedIsBiggerThanOrderItemQuantity", locale); + String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderQuantityAssociatedIsBiggerThanOrderItemQuantity", + locale); Debug.logError(errMsg, MODULE); return ServiceUtil.returnError(errMsg); } @@ -6077,7 +6286,8 @@ public class OrderServices { // reserve the inventory GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); if (orderHeader != null) { - Map<String, Object> cancelResp = dispatcher.runSync("cancelOrderInventoryReservation", UtilMisc.toMap("userLogin", userLogin, "orderId", orderId, "orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId )); + Map<String, Object> cancelResp = dispatcher.runSync("cancelOrderInventoryReservation", UtilMisc.toMap("userLogin", userLogin, + "orderId", orderId, "orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId)); if (ServiceUtil.isError(cancelResp)) { throw new GeneralException(ServiceUtil.getErrorMessage(cancelResp)); } @@ -6087,7 +6297,8 @@ public class OrderServices { if (Debug.infoOn()) { Debug.logInfo("Calling reserve inventory...", MODULE); } - reserveInventory(delegator, dispatcher, userLogin, locale, UtilMisc.toList(oisga), null, UtilMisc.<String, GenericValue>toMap(orderItemSeqId, orderItem), orderTypeId, productStoreId, resErrorMessages); + reserveInventory(delegator, dispatcher, userLogin, locale, UtilMisc.toList(oisga), null, + UtilMisc.<String, GenericValue>toMap(orderItemSeqId, orderItem), orderTypeId, productStoreId, resErrorMessages); } //update totalQuantity @@ -6102,7 +6313,8 @@ public class OrderServices { try { message = validateOrderItemShipGroupAssoc(delegator, dispatcher, orderItem, totalQuantity, oisga, userLogin, locale); } catch (GeneralException e) { - String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderQuantityAssociatedIsLessThanOrderItemQuantity", locale); + String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderQuantityAssociatedIsLessThanOrderItemQuantity", + locale); Debug.logError(errMsg, MODULE); return ServiceUtil.returnError(errMsg); } @@ -6124,13 +6336,13 @@ public class OrderServices { * This service should be called after updateOrderItemShipGroupAssoc * test if orderItem quantity equals OrderItemShipGroupAssocs quantities * if not then get the last orderItemShipgroupAssoc estimated shipDate and add quantity to this OrderItemShipGroupAssoc - * @param ctx - * @param context + * @return * @throws GeneralException */ - private static String validateOrderItemShipGroupAssoc(Delegator delegator, LocalDispatcher dispatcher, GenericValue orderItem, BigDecimal totalQuantity, GenericValue lastOISGAssoc, GenericValue userLogin, Locale locale) - throws GeneralException { + private static String validateOrderItemShipGroupAssoc(Delegator delegator, LocalDispatcher dispatcher, GenericValue orderItem, + BigDecimal totalQuantity, GenericValue lastOISGAssoc, GenericValue userLogin, Locale locale) + throws GeneralException { String result = null; BigDecimal qty = (BigDecimal) orderItem.get("quantity"); if (UtilValidate.isEmpty(qty)) { @@ -6144,7 +6356,7 @@ public class OrderServices { BigDecimal orderItemQuantity = qty.subtract(cancelQty); if (totalQuantity.compareTo(orderItemQuantity) < 0) { //if quantity in orderItem is bigger than in totalQUantity then added missing quantity in ShipGroupAssoc - BigDecimal adjustementQuantity = orderItemQuantity.subtract( totalQuantity); + BigDecimal adjustementQuantity = orderItemQuantity.subtract(totalQuantity); BigDecimal lastOISGAssocQuantity = (BigDecimal) lastOISGAssoc.get("quantity"); if (UtilValidate.isEmpty(lastOISGAssocQuantity)) { lastOISGAssocQuantity = BigDecimal.ZERO; @@ -6170,7 +6382,9 @@ public class OrderServices { if (Debug.infoOn()) { Debug.logInfo("Calling reserve inventory...", MODULE); } - reserveInventory(delegator, dispatcher, userLogin, locale, UtilMisc.toList(lastOISGAssoc), null, UtilMisc.<String, GenericValue>toMap(lastOISGAssoc.getString("orderItemSeqId"), orderItem), orderTypeId, productStoreId, resErrorMessages); + reserveInventory(delegator, dispatcher, userLogin, locale, UtilMisc.toList(lastOISGAssoc), null, + UtilMisc.<String, GenericValue>toMap(lastOISGAssoc.getString("orderItemSeqId"), orderItem), orderTypeId, productStoreId, + resErrorMessages); } //return warning message @@ -6185,7 +6399,8 @@ public class OrderServices { String shipGroupSeqId = (String) context.get("shipGroupSeqId"); String shippingInstructions = (String) context.get("shippingInstructions"); try { - GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", shipGroupSeqId).queryFirst(); + GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", + shipGroupSeqId).queryFirst(); orderItemShipGroup.set("shippingInstructions", shippingInstructions); orderItemShipGroup.store(); } catch (GenericEntityException e) { @@ -6200,7 +6415,8 @@ public class OrderServices { String shipGroupSeqId = (String) context.get("shipGroupSeqId"); String giftMessage = (String) context.get("giftMessage"); try { - GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", shipGroupSeqId).queryFirst(); + GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", + shipGroupSeqId).queryFirst(); orderItemShipGroup.set("giftMessage", giftMessage); orderItemShipGroup.set("isGift", "Y"); orderItemShipGroup.store(); @@ -6220,11 +6436,13 @@ public class OrderServices { if (orderEntryFromDateTime == null && !processAllOrders) { // No from date supplied, check to see when this service last ran and use the startDateTime // FIXME: This code is unreliable - the JobSandbox value might have been purged. Use another mechanism to persist orderEntryFromDateTime. - EntityCondition cond = EntityCondition.makeCondition(UtilMisc.toMap("statusId", "SERVICE_FINISHED", "serviceName", "createAlsoBoughtProductAssocs")); + EntityCondition cond = EntityCondition.makeCondition(UtilMisc.toMap("statusId", "SERVICE_FINISHED", "serviceName", + "createAlsoBoughtProductAssocs")); EntityFindOptions efo = new EntityFindOptions(); efo.setMaxRows(1); try { - GenericValue lastRunJobSandbox = EntityUtil.getFirst(delegator.findList("JobSandbox", cond, null, UtilMisc.toList("startDateTime DESC"), efo, false)); + GenericValue lastRunJobSandbox = EntityUtil.getFirst(delegator.findList("JobSandbox", cond, null, UtilMisc.toList("startDateTime " + + "DESC"), efo, false)); if (lastRunJobSandbox != null) { orderEntryFromDateTime = lastRunJobSandbox.getTimestamp("startDateTime"); } @@ -6276,7 +6494,7 @@ public class OrderServices { return ServiceUtil.returnError(e.getMessage()); } - for (String orderId: orderIds) { + for (String orderId : orderIds) { Map<String, Object> svcIn = new HashMap<>(); svcIn.put("userLogin", context.get("userLogin")); svcIn.put("orderId", orderId); @@ -6409,7 +6627,7 @@ public class OrderServices { shipmentMethodTypeId = orderItemshipGroup.getString("shipmentMethodTypeId"); carrierPartyId = orderItemshipGroup.getString("carrierPartyId"); } - int groupIdx =Integer.parseInt(shipGroupSeqId); + int groupIdx = Integer.parseInt(shipGroupSeqId); /* check whether new selected contact address is same as old contact. If contact address is different, get applicable ship methods for changed contact */ @@ -6430,7 +6648,8 @@ public class OrderServices { boolean isShippingMethodAvailable = false; // search shipping method for ship group is applicable to new address or not. for (GenericValue shippingMethod : shippingMethods) { - isShippingMethodAvailable = shippingMethod.getString("partyId").equals(carrierPartyId) && shippingMethod.getString("shipmentMethodTypeId").equals(shipmentMethodTypeId); + isShippingMethodAvailable = shippingMethod.getString("partyId").equals(carrierPartyId) && shippingMethod.getString( + "shipmentMethodTypeId").equals(shipmentMethodTypeId); if (isShippingMethodAvailable) { shoppingCart.setShipmentMethodTypeId(groupIdx - 1, shipmentMethodTypeId); shoppingCart.setCarrierPartyId(groupIdx - 1, carrierPartyId); @@ -6446,15 +6665,18 @@ public class OrderServices { String newShipMethTypeDesc = null; String shipMethTypeDesc = null; try { - shipMethTypeDesc = EntityQuery.use(delegator).from("ShipmentMethodType").where("shipmentMethodTypeId", shipmentMethodTypeId).queryOne().getString("description"); - newShipMethTypeDesc = EntityQuery.use(delegator).from("ShipmentMethodType").where("shipmentMethodTypeId", shippingMethods.get(0).getString("shipmentMethodTypeId")).queryOne().getString("description"); + shipMethTypeDesc = EntityQuery.use(delegator).from("ShipmentMethodType").where("shipmentMethodTypeId", + shipmentMethodTypeId).queryOne().getString("description"); + newShipMethTypeDesc = EntityQuery.use(delegator).from("ShipmentMethodType").where("shipmentMethodTypeId", + shippingMethods.get(0).getString("shipmentMethodTypeId")).queryOne().getString("description"); } catch (GenericEntityException e) { Debug.logError(e, MODULE); } // message to notify user for not applicability of shipping method - message = "Shipping Method " + carrierPartyId + " " + shipMethTypeDesc + " is not applicable to shipping address. " + shippingMethods.get(0).getString("carrierPartyId") + " " + newShipMethTypeDesc + " has been set for shipping address."; + message = "Shipping Method " + carrierPartyId + " " + shipMethTypeDesc + " is not applicable to shipping address. " + + shippingMethods.get(0).getString("carrierPartyId") + " " + newShipMethTypeDesc + " has been set for shipping address."; } - shoppingCart.setShippingContactMechId(groupIdx-1, contactMechId); + shoppingCart.setShippingContactMechId(groupIdx - 1, contactMechId); } } @@ -6492,7 +6714,8 @@ public class OrderServices { String orderItemSeqId = orderItem.getString("orderItemSeqId"); String productId = orderItem.getString("productId"); String planMethodEnumId = null; - GenericValue orderItemAttribute = EntityQuery.use(delegator).from("OrderItemAttribute").where("orderId", orderId, "orderItemSeqId", orderItemSeqId, "attrName", "autoReserve").queryOne(); + GenericValue orderItemAttribute = EntityQuery.use(delegator).from("OrderItemAttribute").where("orderId", orderId, "orderItemSeqId", + orderItemSeqId, "attrName", "autoReserve").queryOne(); if (orderItemAttribute != null && "true".equals(orderItemAttribute.getString("attrValue"))) { planMethodEnumId = "AUTO"; } else { @@ -6503,7 +6726,8 @@ public class OrderServices { List<EntityCondition> headerConditions = new ArrayList<>(); headerConditions.add(EntityCondition.makeCondition("productId", productId)); headerConditions.add(EntityCondition.makeCondition("planTypeId", "SALES_ORD_ALLOCATION")); - headerConditions.add(EntityCondition.makeCondition("statusId", EntityOperator.IN, UtilMisc.toList("ALLOC_PLAN_CREATED", "ALLOC_PLAN_APPROVED"))); + headerConditions.add(EntityCondition.makeCondition("statusId", EntityOperator.IN, UtilMisc.toList("ALLOC_PLAN_CREATED", + "ALLOC_PLAN_APPROVED"))); GenericValue allocationPlanHeader = EntityQuery.use(delegator).from("AllocationPlanHeader").where(headerConditions).queryFirst(); if (allocationPlanHeader == null) { planId = delegator.getNextSeqId("AllocationPlanHeader"); @@ -6624,7 +6848,8 @@ public class OrderServices { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); } serviceCtx.clear(); - GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", allocationPlanItem.getString("orderId")).queryOne(); + GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", allocationPlanItem.getString("orderId")) + .queryOne(); if (orderHeader != null) { //For now considering single facility case only facilityId = orderHeader.getString("originFacilityId"); @@ -6710,10 +6935,12 @@ public class OrderServices { for (GenericValue allocationPlanHeader : allocationPlanHeaders) { oldStatusId = allocationPlanHeader.getString("statusId"); try { - GenericValue statusChange = EntityQuery.use(delegator).from("StatusValidChange").where("statusId", oldStatusId, "statusIdTo", statusId).queryOne(); + GenericValue statusChange = EntityQuery.use(delegator).from("StatusValidChange").where("statusId", oldStatusId, "statusIdTo", + statusId).queryOne(); if (statusChange == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "OrderErrorCouldNotChangeAllocationPlanStatusStatusIsNotAValidChange", locale) + ": [" + oldStatusId + "] -> [" + statusId + "]"); + "OrderErrorCouldNotChangeAllocationPlanStatusStatusIsNotAValidChange", locale) + ": [" + oldStatusId + "] -> [" + + statusId + "]"); } } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, @@ -6754,17 +6981,20 @@ public class OrderServices { String oldStatusId = null; Map<String, Object> serviceResult = new HashMap<>(); try { - GenericValue allocationPlanItem = EntityQuery.use(delegator).from("AllocationPlanItem").where("planId", planId, "planItemSeqId", planItemSeqId).queryOne(); + GenericValue allocationPlanItem = EntityQuery.use(delegator).from("AllocationPlanItem").where("planId", planId, "planItemSeqId", + planItemSeqId).queryOne(); if (allocationPlanItem == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "OrderErrorAllocationPlanIsNotAvailable", locale) + ": [" + planId + ":"+ planItemSeqId + "]"); + "OrderErrorAllocationPlanIsNotAvailable", locale) + ": [" + planId + ":" + planItemSeqId + "]"); } oldStatusId = allocationPlanItem.getString("statusId"); try { - GenericValue statusChange = EntityQuery.use(delegator).from("StatusValidChange").where("statusId", oldStatusId, "statusIdTo", statusId).queryOne(); + GenericValue statusChange = EntityQuery.use(delegator).from("StatusValidChange").where("statusId", oldStatusId, "statusIdTo", + statusId).queryOne(); if (statusChange == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "OrderErrorCouldNotChangeAllocationPlanItemStatusStatusIsNotAValidChange", locale) + ": [" + oldStatusId + "] -> [" + statusId + "]"); + "OrderErrorCouldNotChangeAllocationPlanItemStatusStatusIsNotAValidChange", locale) + ": [" + + oldStatusId + "] -> [" + statusId + "]"); } } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, @@ -6805,7 +7035,8 @@ public class OrderServices { if (orderItemSeqId != null) { exprs.add(EntityCondition.makeCondition("orderItemSeqId", orderItemSeqId)); } else { - exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_IN, UtilMisc.toList("ALLOC_PLAN_ITEM_CMPL", "ALLOC_PLAN_ITEM_CNCL"))); + exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_IN, UtilMisc.toList("ALLOC_PLAN_ITEM_CMPL", + "ALLOC_PLAN_ITEM_CNCL"))); } List<GenericValue> allocationPlanItems = EntityQuery.use(delegator).from("AllocationPlanItem").where(exprs).queryList(); @@ -6871,7 +7102,8 @@ public class OrderServices { if (orderItemSeqId != null) { exprs.add(EntityCondition.makeCondition("orderItemSeqId", orderItemSeqId)); } else { - exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_IN, UtilMisc.toList("ALLOC_PLAN_ITEM_CMPL", "ALLOC_PLAN_ITEM_CNCL"))); + exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_IN, UtilMisc.toList("ALLOC_PLAN_ITEM_CMPL", + "ALLOC_PLAN_ITEM_CNCL"))); } List<GenericValue> allocationPlanItems = EntityQuery.use(delegator).from("AllocationPlanItem").where(exprs).queryList(); @@ -6924,6 +7156,7 @@ public class OrderServices { } return ServiceUtil.returnSuccess(); } + public static Map<String, Object> updateAllocatedQuantityOnOrderItemChange(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); @@ -6939,11 +7172,13 @@ public class OrderServices { exprs.add(EntityCondition.makeCondition("orderItemSeqId", orderItemSeqId)); exprs.add(EntityCondition.makeCondition("changeTypeEnumId", "ODR_ITM_UPDATE")); exprs.add(EntityCondition.makeCondition("quantity", EntityOperator.NOT_EQUAL, null)); - GenericValue orderItemChange = EntityQuery.use(delegator).from("OrderItemChange").where(exprs).orderBy("-changeDatetime").queryFirst(); + GenericValue orderItemChange = EntityQuery.use(delegator).from("OrderItemChange").where(exprs).orderBy("-changeDatetime") + .queryFirst(); if (orderItemChange != null) { BigDecimal quantityChanged = orderItemChange.getBigDecimal("quantity"); if (quantityChanged.compareTo(BigDecimal.ZERO) < 0) { - GenericValue allocationPlanItem = EntityQuery.use(delegator).from("AllocationPlanItem").where("orderId", orderId, "orderItemSeqId", orderItemSeqId, "statusId", "ALLOC_PLAN_ITEM_CRTD", "productId", orderItem.getString("productId")).queryFirst(); + GenericValue allocationPlanItem = EntityQuery.use(delegator).from("AllocationPlanItem").where("orderId", orderId, + "orderItemSeqId", orderItemSeqId, "statusId", "ALLOC_PLAN_ITEM_CRTD", "productId", orderItem.getString("productId")).queryFirst(); if (allocationPlanItem != null) { BigDecimal revisedQuantity = orderItem.getBigDecimal("quantity"); BigDecimal allocatedQuantity = allocationPlanItem.getBigDecimal("allocatedQuantity"); @@ -7004,7 +7239,7 @@ public class OrderServices { serviceCtx.clear(); //Create Allocation Plan Items - for (int i = 0; i<itemListSize; i++) { + for (int i = 0; i < itemListSize; i++) { String orderId = itemOrderIdMap.get(String.valueOf(i)); String orderItemSeqId = itemOrderItemSeqIdMap.get(String.valueOf(i)); String allocatedQuantityStr = itemAllocatedQuantityMap.get(String.valueOf(i)); @@ -7092,7 +7327,8 @@ public class OrderServices { } } - GenericValue allocationPlanItem = EntityQuery.use(delegator).from("AllocationPlanItem").where("planId", planId, "planItemSeqId", planItemSeqId, "productId", productId).queryOne(); + GenericValue allocationPlanItem = EntityQuery.use(delegator).from("AllocationPlanItem").where("planId", planId, "planItemSeqId", + planItemSeqId, "productId", productId).queryOne(); if (allocationPlanItem != null) { BigDecimal oldAllocatedQuantity = allocationPlanItem.getBigDecimal("allocatedQuantity"); if (oldAllocatedQuantity != null && oldAllocatedQuantity.compareTo(allocatedQuantity) > 0) { diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/quote/QuoteServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/quote/QuoteServices.java index 7c0d57f..0bd116f 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/quote/QuoteServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/quote/QuoteServices.java @@ -70,7 +70,7 @@ public class QuoteServices { if (quote == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "OrderOrderQuoteCannotBeFound", + "OrderOrderQuoteCannotBeFound", UtilMisc.toMap("quoteId", quoteId), locale)); } @@ -82,15 +82,15 @@ public class QuoteServices { } if (productStoreEmail == null) { return ServiceUtil.returnFailure(UtilProperties.getMessage(RES_PRODUCT, - "ProductProductStoreEmailSettingsNotValid", - UtilMisc.toMap("productStoreId", quote.get("productStoreId"), + "ProductProductStoreEmailSettingsNotValid", + UtilMisc.toMap("productStoreId", quote.get("productStoreId"), "emailType", emailType), locale)); } String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation"); if (UtilValidate.isEmpty(bodyScreenLocation)) { return ServiceUtil.returnFailure(UtilProperties.getMessage(RES_PRODUCT, - "ProductProductStoreEmailSettingsNotValidBodyScreenLocation", - UtilMisc.toMap("productStoreId", quote.get("productStoreId"), + "ProductProductStoreEmailSettingsNotValidBodyScreenLocation", + UtilMisc.toMap("productStoreId", quote.get("productStoreId"), "emailType", emailType), locale)); } sendMap.put("bodyScreenUri", bodyScreenLocation); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/requirement/RequirementServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/requirement/RequirementServices.java index 537cfe8..2766283 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/requirement/RequirementServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/requirement/RequirementServices.java @@ -140,7 +140,8 @@ public class RequirementServices { // for good identification, get the UPCA type (UPC code) GenericValue gid = gids.get(productId); if (gid == null) { - gid = EntityQuery.use(delegator).from("GoodIdentification").where("goodIdentificationTypeId", "UPCA", "productId", requirement.get("productId")).queryOne(); + gid = EntityQuery.use(delegator).from("GoodIdentification").where("goodIdentificationTypeId", "UPCA", "productId", + requirement.get("productId")).queryOne(); gids.put(productId, gid); } if (gid != null) union.put("idValue", gid.get("idValue")); @@ -150,7 +151,8 @@ public class RequirementServices { String inventoryKey = facilityId + "^" + productId; Map<String, Object> inventory = inventories.get(inventoryKey); if (inventory == null) { - inventory = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId)); + inventory = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, "facilityId", + facilityId)); if (ServiceUtil.isError(inventory)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(inventory)); } @@ -166,12 +168,15 @@ public class RequirementServices { BigDecimal sold = productsSold.get(productId); if (sold == null) { EntityCondition prodConditions = EntityCondition.makeCondition(UtilMisc.toList( - EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId), - EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER"), - EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_IN, UtilMisc.toList("ORDER_REJECTED", "ORDER_CANCELLED")), - EntityCondition.makeCondition("orderItemStatusId", EntityOperator.NOT_IN, UtilMisc.toList("ITEM_REJECTED", "ITEM_CANCELLED")), - EntityCondition.makeCondition("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, timePeriodStart)), EntityOperator.AND); - GenericValue count = EntityQuery.use(delegator).select("quantityOrdered").from("OrderItemQuantityReportGroupByProduct").where(prodConditions).queryFirst(); + EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId), + EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER"), + EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_IN, UtilMisc.toList("ORDER_REJECTED", + "ORDER_CANCELLED")), + EntityCondition.makeCondition("orderItemStatusId", EntityOperator.NOT_IN, UtilMisc.toList("ITEM_REJECTED", + "ITEM_CANCELLED")), + EntityCondition.makeCondition("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, timePeriodStart)), EntityOperator.AND); + GenericValue count = EntityQuery.use(delegator).select("quantityOrdered").from("OrderItemQuantityReportGroupByProduct") + .where(prodConditions).queryFirst(); if (count != null) { sold = count.getBigDecimal("quantityOrdered"); if (sold != null) productsSold.put(productId, sold); @@ -206,7 +211,8 @@ public class RequirementServices { } } - // note that this service is designed to work only when a sales order status changes from CREATED -> APPROVED because HOLD -> APPROVED is too complex + // note that this service is designed to work only when a sales order status changes from CREATED -> APPROVED because HOLD -> APPROVED is too + // complex public static Map<String, Object> createAutoRequirementsForOrder(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); @@ -220,9 +226,11 @@ public class RequirementServices { Debug.logInfo("ProductStore for order ID " + orderId + " not found, requirements not created", MODULE); return ServiceUtil.returnSuccess(); } - List<GenericValue> orderItemAndShipGroups = EntityQuery.use(delegator).select("orderId", "shipGroupSeqId", "orderItemSeqId").from("OrderItemAndShipGroupAssoc").where("orderId", orderId).distinct().queryList(); + List<GenericValue> orderItemAndShipGroups = EntityQuery.use(delegator).select("orderId", "shipGroupSeqId", "orderItemSeqId").from( + "OrderItemAndShipGroupAssoc").where("orderId", orderId).distinct().queryList(); for (GenericValue orderItemAndShipGroup : orderItemAndShipGroups) { - GenericValue item = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderItemAndShipGroup.getString("orderId"), "orderItemSeqId", orderItemAndShipGroup.getString("orderItemSeqId")).queryOne(); + GenericValue item = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderItemAndShipGroup.getString("orderId"), + "orderItemSeqId", orderItemAndShipGroup.getString("orderItemSeqId")).queryOne(); GenericValue product = item.getRelatedOne("Product", false); if (product == null) continue; if ((!"PRODRQM_AUTO".equals(product.get("requirementMethodEnumId")) @@ -233,15 +241,18 @@ public class RequirementServices { BigDecimal cancelQuantity = item.getBigDecimal("cancelQuantity"); BigDecimal required = quantity.subtract(cancelQuantity == null ? BigDecimal.ZERO : cancelQuantity); if (required.compareTo(BigDecimal.ZERO) <= 0) continue; - GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", orderItemAndShipGroup.getString("shipGroupSeqId")).cache().queryOne(); - Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "facilityId", orderItemShipGroup.getString("facilityId"), "productId", product.get("productId"), "quantity", required, "requirementTypeId", "PRODUCT_REQUIREMENT"); + GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", + orderItemAndShipGroup.getString("shipGroupSeqId")).cache().queryOne(); + Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "facilityId", orderItemShipGroup.getString("facilityId"), + "productId", product.get("productId"), "quantity", required, "requirementTypeId", "PRODUCT_REQUIREMENT"); Map<String, Object> results = dispatcher.runSync("createRequirement", input); if (ServiceUtil.isError(results)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); } String requirementId = (String) results.get("requirementId"); - input = UtilMisc.toMap("userLogin", userLogin, "orderId", order.get("orderId"), "orderItemSeqId", item.get("orderItemSeqId"), "requirementId", requirementId, "quantity", required); + input = UtilMisc.toMap("userLogin", userLogin, "orderId", order.get("orderId"), "orderItemSeqId", item.get("orderItemSeqId"), + "requirementId", requirementId, "quantity", required); results = dispatcher.runSync("createOrderRequirementCommitment", input); if (ServiceUtil.isError(results)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); @@ -253,7 +264,8 @@ public class RequirementServices { return ServiceUtil.returnSuccess(); } - // note that this service is designed to work only when a sales order status changes from CREATED -> APPROVED because HOLD -> APPROVED is too complex + // note that this service is designed to work only when a sales order status changes from CREATED -> APPROVED because HOLD -> APPROVED is too + // complex public static Map<String, Object> createATPRequirementsForOrder(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); @@ -288,22 +300,26 @@ public class RequirementServices { if (product == null) continue; if (!("PRODRQM_ATP".equals(product.get("requirementMethodEnumId")) - || ("PRODRQM_ATP".equals(productStore.get("requirementMethodEnumId")) && product.get("requirementMethodEnumId") == null))) continue; + || ("PRODRQM_ATP".equals(productStore.get("requirementMethodEnumId")) && product.get("requirementMethodEnumId") == null))) + continue; BigDecimal quantity = item.getBigDecimal("quantity"); BigDecimal cancelQuantity = item.getBigDecimal("cancelQuantity"); BigDecimal ordered = quantity.subtract(cancelQuantity == null ? BigDecimal.ZERO : cancelQuantity); if (ordered.compareTo(BigDecimal.ZERO) <= 0) continue; - // get the minimum stock for this facility (if not configured assume a minimum of zero, ie create requirements when it goes into backorder) - GenericValue productFacility = EntityQuery.use(delegator).from("ProductFacility").where("facilityId", facilityId, "productId", product.get("productId")).queryOne(); + // get the minimum stock for this facility (if not configured assume a minimum of zero, ie create requirements when it goes into + // backorder) + GenericValue productFacility = EntityQuery.use(delegator).from("ProductFacility").where("facilityId", facilityId, "productId", + product.get("productId")).queryOne(); BigDecimal minimumStock = BigDecimal.ZERO; if (productFacility != null && productFacility.get("minimumStock") != null) { minimumStock = productFacility.getBigDecimal("minimumStock"); } // get the facility ATP for product, which should be updated for this item's reservation - Map<String, Object> results = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("userLogin", userLogin, "productId", product.get("productId"), "facilityId", facilityId)); + Map<String, Object> results = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("userLogin", userLogin, + "productId", product.get("productId"), "facilityId", facilityId)); if (ServiceUtil.isError(results)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); } @@ -320,22 +336,26 @@ public class RequirementServices { EntityOperator.AND); List<GenericValue> requirements = EntityQuery.use(delegator).from("Requirement").where(ecl).queryList(); for (GenericValue requirement : requirements) { - pendingRequirements = pendingRequirements.add(requirement.get("quantity") == null ? BigDecimal.ZERO : requirement.getBigDecimal("quantity")); + pendingRequirements = pendingRequirements.add(requirement.get("quantity") == null ? BigDecimal.ZERO + : requirement.getBigDecimal("quantity")); } - // the minimum stock is an upper bound, therefore we either require up to the minimum stock or the input required quantity, whichever is less + // the minimum stock is an upper bound, therefore we either require up to the minimum stock or the input required quantity, + // whichever is less BigDecimal shortfall = minimumStock.subtract(atp).subtract(pendingRequirements); BigDecimal required = ordered.compareTo(shortfall) < 0 ? ordered : shortfall; if (required.compareTo(BigDecimal.ZERO) <= 0) continue; - Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "facilityId", facilityId, "productId", product.get("productId"), "quantity", required, "requirementTypeId", "PRODUCT_REQUIREMENT"); + Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "facilityId", facilityId, "productId", product.get("productId"), + "quantity", required, "requirementTypeId", "PRODUCT_REQUIREMENT"); results = dispatcher.runSync("createRequirement", input); if (ServiceUtil.isError(results)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); } String requirementId = (String) results.get("requirementId"); - input = UtilMisc.toMap("userLogin", userLogin, "orderId", order.get("orderId"), "orderItemSeqId", item.get("orderItemSeqId"), "requirementId", requirementId, "quantity", required); + input = UtilMisc.toMap("userLogin", userLogin, "orderId", order.get("orderId"), "orderItemSeqId", item.get("orderItemSeqId"), + "requirementId", requirementId, "quantity", required); results = dispatcher.runSync("createOrderRequirementCommitment", input); if (ServiceUtil.isError(results)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(results)); @@ -347,21 +367,22 @@ public class RequirementServices { return ServiceUtil.returnSuccess(); } - public static Map<String, Object> updateRequirementsToOrdered (DispatchContext ctx, Map<String, ? extends Object> context) { + public static Map<String, Object> updateRequirementsToOrdered(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); String orderId = (String) context.get("orderId"); OrderReadHelper orh = new OrderReadHelper(delegator, orderId); try { - for (GenericValue orderItem: orh.getOrderItems()) { + for (GenericValue orderItem : orh.getOrderItems()) { GenericValue orderRequirementCommitment = EntityQuery.use(delegator).from("OrderRequirementCommitment") .where(UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.getString("orderItemSeqId"))) .queryFirst(); if (orderRequirementCommitment != null) { String requirementId = orderRequirementCommitment.getString("requirementId"); /* Change status of requirement to ordered */ - Map<String, Object> inputMap = UtilMisc.<String, Object>toMap("userLogin", userLogin, "requirementId", requirementId, "statusId", "REQ_ORDERED", "quantity", orderItem.getBigDecimal("quantity")); + Map<String, Object> inputMap = UtilMisc.<String, Object>toMap("userLogin", userLogin, "requirementId", requirementId, "statusId", + "REQ_ORDERED", "quantity", orderItem.getBigDecimal("quantity")); // TODO: check service result for an error return Map<String, Object> results = dispatcher.runSync("updateRequirement", inputMap); if (ServiceUtil.isError(results)) { diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java index 2811553..d44a72c 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutHelper.java @@ -346,13 +346,13 @@ public class CheckOutHelper { boolean singleUse = singleUsePayments.contains(checkOutPaymentId); ShoppingCart.CartPaymentInfo inf = cart.addPaymentAmount(checkOutPaymentId, paymentAmount, singleUse); if (finAccountId != null) { - inf.finAccountId = finAccountId; + inf.setFinAccountId(finAccountId); } if (securityCode != null) { - inf.securityCode = securityCode; + inf.setSecurityCode(securityCode); } if (refNum != null) { - inf.refNum[0] = refNum; + inf.setRefNum(refNum); } } } else if (cart.getGrandTotal().compareTo(BigDecimal.ZERO) != 0) { @@ -374,8 +374,8 @@ public class CheckOutHelper { this.cart.setShipBeforeDate(shipBefore); this.cart.setShipAfterDate(shipAfter); } else { - errMsg = UtilProperties.getMessage(RES_ERROR, "checkhelper.no_items_in_cart", - (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(RES_ERROR, "checkhelper.no_items_in_cart", (cart != null + ? cart.getLocale() : Locale.getDefault())); errorMessages.add(errMsg); } @@ -826,14 +826,14 @@ public class CheckOutHelper { } // need to manually clear the order adjustments - csi.shipTaxAdj.clear(); - csi.shipTaxAdj.addAll(orderAdj); + csi.clearShipTaxAdj(); + csi.addShipTaxAdj(orderAdj); } } private Map<String, Object> makeTaxContext(int shipGroup, GenericValue shipAddress, Map<Integer, ShoppingCartItem> shoppingCartItemIndexMap, String originFacilityId, boolean skipEmptyAddresses) { ShoppingCart.CartShipInfo csi = cart.getShipInfo(shipGroup); - int totalItems = csi.shipItemInfo.size(); + int totalItems = csi.getShipItemInfo().size(); List<GenericValue> product = new ArrayList<>(totalItems); List<BigDecimal> amount = new ArrayList<>(totalItems); @@ -841,12 +841,12 @@ public class CheckOutHelper { List<BigDecimal> quantity = new ArrayList<>(totalItems); List<BigDecimal> shipAmt = new ArrayList<>(totalItems); - Iterator<ShoppingCartItem> it = csi.shipItemInfo.keySet().iterator(); + Iterator<ShoppingCartItem> it = csi.getShipItemInfo().keySet().iterator(); for (int i = 0; i < totalItems; i++) { ShoppingCartItem cartItem = it.next(); ShoppingCart.CartShipInfo.CartShipItemInfo itemInfo = csi.getShipItemInfo(cartItem); product.add(i, cartItem.getProduct()); - amount.add(i, cartItem.getItemSubTotal(itemInfo.quantity)); + amount.add(i, cartItem.getItemSubTotal(itemInfo.getItemQuantity())); price.add(i, cartItem.getBasePrice()); quantity.add(i, cartItem.getQuantity()); shipAmt.add(i, BigDecimal.ZERO); // no per item shipping yet @@ -857,7 +857,7 @@ public class CheckOutHelper { List<GenericValue> allAdjustments = cart.getAdjustments(); BigDecimal orderPromoAmt = OrderReadHelper.calcOrderPromoAdjustmentsBd(allAdjustments); - BigDecimal shipAmount = csi.shipEstimate; + BigDecimal shipAmount = csi.getShipEstimate(); if (shipAddress == null) { shipAddress = cart.getShippingAddress(shipGroup); } @@ -1033,8 +1033,6 @@ public class CheckOutHelper { // Check the payment preferences; if we have ANY w/ status PAYMENT_NOT_AUTH invoke payment service. // Invoke payment processing. - Debug.log("==========allPaymentPreferences=======" + allPaymentPreferences); - Debug.log("==========onlinePaymentPrefs=======" + onlinePaymentPrefs); if (UtilValidate.isNotEmpty(onlinePaymentPrefs)) { boolean autoApproveOrder = UtilValidate.isEmpty(productStore.get("autoApproveOrder")) || "Y".equalsIgnoreCase(productStore.getString("autoApproveOrder")); if (orderTotal.compareTo(BigDecimal.ZERO) == 0 && autoApproveOrder) { @@ -1160,7 +1158,6 @@ public class CheckOutHelper { EntityCondition.makeCondition("paymentMethodTypeId", EntityOperator.EQUALS, "EXT_BILLACT")); List<GenericValue> cashCodPcBaPaymentPreferences = EntityUtil.filterByOr(allPaymentPreferences, cashCodPcBaExpr); - Debug.log("==========cashCodPcBaPaymentPreferences=======" + cashCodPcBaPaymentPreferences); if (UtilValidate.isNotEmpty(cashCodPcBaPaymentPreferences) && UtilValidate.isNotEmpty(allPaymentPreferences) && cashCodPcBaPaymentPreferences.size() == allPaymentPreferences.size()) { @@ -1182,8 +1179,6 @@ public class CheckOutHelper { } } - } else { - // There is nothing to do, we just treat this as a success } } @@ -1245,7 +1240,7 @@ public class CheckOutHelper { EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("blacklistString"), EntityOperator.EQUALS, EntityFunction.UPPER(shippingAddress)), EntityOperator.AND, EntityCondition.makeCondition("orderBlacklistTypeId", EntityOperator.EQUALS, "BLACKLIST_ADDRESS"))); - String errMsg=null; + String errMsg = null; List<GenericValue> paymentMethods = this.cart.getPaymentMethods(); for (GenericValue paymentMethod : paymentMethods) { @@ -1303,8 +1298,8 @@ public class CheckOutHelper { public Map<String, Object> failedBlacklistCheck(GenericValue userLogin, GenericValue productStore) { Map<String, Object> result; - String errMsg=null; - String REJECT_MESSAGE = productStore.getString("authFraudMessage"); + String errMsg = null; + String rejectMessage = productStore.getString("authFraudMessage"); String orderId = this.cart.getOrderId(); try { @@ -1325,7 +1320,7 @@ public class CheckOutHelper { // set the order/item status - reverse inv OrderChangeHelper.rejectOrder(dispatcher, userLogin, orderId); result = ServiceUtil.returnSuccess(); - result.put(ModelService.ERROR_MESSAGE, REJECT_MESSAGE); + result.put(ModelService.ERROR_MESSAGE, rejectMessage); // wipe the cart and session this.cart.clear(); @@ -1617,20 +1612,20 @@ public class CheckOutHelper { Debug.logVerbose("Remaining total is - " + newAmount, MODULE); } if (newAmount.compareTo(BigDecimal.ZERO) > 0) { - info.amount = newAmount; + info.setAmount(newAmount); if (Debug.verboseOn()) { - Debug.logVerbose("Set null paymentMethodId - " + info.paymentMethodId + " / " + info.amount, MODULE); + Debug.logVerbose("Set null paymentMethodId - " + info.getPaymentMethodId() + " / " + newAmount, MODULE); } } else { - info.amount = BigDecimal.ZERO; + info.setAmount(BigDecimal.ZERO); if (Debug.verboseOn()) { - Debug.logVerbose("Set null paymentMethodId - " + info.paymentMethodId + " / " + info.amount, MODULE); + Debug.logVerbose("Set null paymentMethodId - " + info.getPaymentMethodId() + " / " + BigDecimal.ZERO, MODULE); } } if (!setOverflow) { - info.overflow = true; + info.setOverflow(true); if (Debug.verboseOn()) { - Debug.logVerbose("Set overflow flag on payment - " + info.paymentMethodId, MODULE); + Debug.logVerbose("Set overflow flag on payment - " + info.getPaymentMethodId(), MODULE); } } } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java index 5ad2ca2..d6a1666 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java @@ -26,7 +26,6 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; @@ -137,8 +136,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { private List<ShoppingCartItem> cartLines = new LinkedList<>(); private Map<String, ShoppingCartItemGroup> itemGroupByNumberMap = new HashMap<>(); - protected long nextGroupNumber = 1; - protected List<CartPaymentInfo> paymentInfo = new LinkedList<>(); + private long nextGroupNumber = 1; + private List<CartPaymentInfo> paymentInfo = new LinkedList<>(); private List<CartShipInfo> shipInfo = new LinkedList<>(); private Map<String, String> contactMechIdsMap = new HashMap<>(); private Map<String, String> orderAttributes = new HashMap<>(); @@ -169,36 +168,36 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { private transient Delegator delegator = null; private String delegatorName = null; - protected String productStoreId = null; - protected boolean doPromotions = true; - protected String transactionId = null; - protected String facilityId = null; - protected String webSiteId = null; - protected String terminalId = null; - protected String autoOrderShoppingListId = null; + private String productStoreId = null; + private boolean doPromotions = true; + private String transactionId = null; + private String facilityId = null; + private String webSiteId = null; + private String terminalId = null; + private String autoOrderShoppingListId = null; /** General partyId for the Order, all other IDs default to this one if not specified explicitly */ - protected String orderPartyId = null; + private String orderPartyId = null; // sales order parties - protected String placingCustomerPartyId = null; - protected String billToCustomerPartyId = null; - protected String shipToCustomerPartyId = null; - protected String endUserCustomerPartyId = null; + private String placingCustomerPartyId = null; + private String billToCustomerPartyId = null; + private String shipToCustomerPartyId = null; + private String endUserCustomerPartyId = null; // purchase order parties - protected String billFromVendorPartyId = null; - protected String shipFromVendorPartyId = null; - protected String supplierAgentPartyId = null; + private String billFromVendorPartyId = null; + private String shipFromVendorPartyId = null; + private String supplierAgentPartyId = null; - protected GenericValue userLogin = null; - protected GenericValue autoUserLogin = null; + private GenericValue userLogin = null; + private GenericValue autoUserLogin = null; - protected Locale locale; // holds the locale from the user session - protected String currencyUom = null; - protected boolean holdOrder = false; - protected Timestamp orderDate = null; - protected Timestamp cancelBackOrderDate = null; + private Locale locale; // holds the locale from the user session + private String currencyUom = null; + private boolean holdOrder = false; + private Timestamp orderDate = null; + private Timestamp cancelBackOrderDate = null; /** don't allow empty constructor */ protected ShoppingCart() { } @@ -311,6 +310,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { this(delegator, productStoreId, null, locale, currencyUom); } + /** get delegator */ public Delegator getDelegator() { if (delegator == null) { delegator = DelegatorFactory.getDelegator(delegatorName); @@ -318,14 +318,17 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return delegator; } + /** get product store */ public String getProductStoreId() { return this.productStoreId; } + /** get do promotions */ public boolean getDoPromotions() { return this.doPromotions; } + /** set do promotions */ public void setDoPromotions(boolean doPromotions) { this.doPromotions = doPromotions; } @@ -335,9 +338,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * - some items in the cart may not be valid in any catalog in the new store * - promotions need to be recalculated for the products that remain * - what else? lots of settings on the ProductStore... - * * So for now this can only be called if the cart is empty... otherwise it wil throw an exception - * */ public void setProductStoreId(String productStoreId) { if ((productStoreId == null && this.productStoreId == null) || (productStoreId != null && productStoreId.equals(this.productStoreId))) { @@ -351,42 +352,52 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** get transaction id */ public String getTransactionId() { return this.transactionId; } + /** set transaction id */ public void setTransactionId(String transactionId) { this.transactionId = transactionId; } + /** get terminal id */ public String getTerminalId() { return this.terminalId; } + /** set terminal id */ public void setTerminalId(String terminalId) { this.terminalId = terminalId; } + /** get auto order shopping list id */ public String getAutoOrderShoppingListId() { return this.autoOrderShoppingListId; } + /** set auto order shopping list id */ public void setAutoOrderShoppingListId(String autoOrderShoppingListId) { this.autoOrderShoppingListId = autoOrderShoppingListId; } + /** get facility id */ public String getFacilityId() { return this.facilityId; } + /** set facility id */ public void setFacilityId(String facilityId) { this.facilityId = facilityId; } + /** get locale */ public Locale getLocale() { return locale; } + /** set locale */ public void setLocale(Locale locale) { this.locale = locale; for (ShoppingCartItem cartItem : cartLines) { @@ -394,6 +405,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** set order name */ public void setOrderName(String orderName) { this.orderName = orderName; } @@ -401,56 +413,55 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { public String getOrderName() { return orderName; } - + /** set work effort id */ public void setWorkEffortId(String workEffortId) { this.workEffortId = workEffortId; } - + /** get workeffort id */ public String getWorkEffortId() { return workEffortId; } - + /** set attribute */ public void setAttribute(String name, Object value) { this.attributes.put(name, value); } - + /** remove attribute */ public void removeAttribute(String name) { this.attributes.remove(name); } - + /** get attribute */ @SuppressWarnings("unchecked") public <T> T getAttribute(String name) { return (T) this.attributes.get(name); } - + /** remove order attribute */ public void removeOrderAttribute(String name) { this.orderAttributes.remove(name); } - + /** set order attribute */ public void setOrderAttribute(String name, String value) { this.orderAttributes.put(name, value); } - + /** get order attribute */ public String getOrderAttribute(String name) { return this.orderAttributes.get(name); } - + /** set hold order */ public void setHoldOrder(boolean b) { this.holdOrder = b; } - + /** get hold order */ public boolean getHoldOrder() { return this.holdOrder; } - + /** set order date */ public void setOrderDate(Timestamp t) { this.orderDate = t != null ? (Timestamp) t.clone() : null; } - + /** get order date */ public Timestamp getOrderDate() { return this.orderDate != null ? (Timestamp) this.orderDate.clone() : null; } - /** Sets the currency for the cart. */ public void setCurrency(LocalDispatcher dispatcher, String currencyUom) throws CartItemModifyException { if (isReadOnlyCart()) { @@ -724,8 +735,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { */ public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, - HashMap<String, GenericValue> features, HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher - , Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException { + HashMap<String, GenericValue> features, HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, + Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, Boolean.FALSE, Boolean.FALSE)); @@ -736,8 +747,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { */ public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, - HashMap<String, GenericValue> features, HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher - , Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { + HashMap<String, GenericValue> features, HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, + Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks)); @@ -849,6 +860,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } // =============== some misc utility methods, mostly for dealing with lists of items ================= + /** remove extra items */ public void removeExtraItems(List<ShoppingCartItem> multipleItems, LocalDispatcher dispatcher, int maxItems) throws CartItemModifyException { // if 1 or 0 items, do nothing if (multipleItems.size() <= maxItems) { @@ -886,6 +898,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return productList; } + /** Ensure item total quantity */ public void ensureItemsQuantity(List<ShoppingCartItem> cartItems, LocalDispatcher dispatcher, BigDecimal quantity) throws CartItemModifyException { for (ShoppingCartItem item : cartItems) { if (item.getQuantity() != quantity) { @@ -894,6 +907,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** Ensure item total quantity */ public BigDecimal ensureItemsTotalQuantity(List<ShoppingCartItem> cartItems, LocalDispatcher dispatcher, BigDecimal quantity) throws CartItemModifyException { BigDecimal quantityRemoved = BigDecimal.ZERO; // go through the items and reduce quantityToKeep by the item quantities until it is 0, then remove the remaining... @@ -930,6 +944,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return false; } + /** contain all work effort cart item check */ public boolean containAllWorkEffortCartItems() { // Check for existing cart item. for (ShoppingCartItem cartItem : this.cartLines) { @@ -997,6 +1012,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } + /** find an item from the cart object. */ public ShoppingCartItem findCartItem(String orderItemSeqId) { if (orderItemSeqId != null) { for (int i = 0; i < this.cartLines.size(); i++) { @@ -1010,6 +1026,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return null; } + /** Remove an item from the cart object. */ public void removeCartItem(ShoppingCartItem item, LocalDispatcher dispatcher) throws CartItemModifyException { if (item == null) { return; @@ -1325,14 +1342,14 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } public Timestamp getDefaultShipAfterDate() { - return this.defaultShipAfterDate != null ? (Timestamp) this.defaultShipAfterDate.clone() : null; + return this.defaultShipAfterDate != null ? (Timestamp) this.defaultShipAfterDate.clone() : null; } public void setDefaultReserveAfterDate(Timestamp defaultReserveAfterDate) { - this.defaultReserveAfterDate = defaultReserveAfterDate != null ? (Timestamp) defaultReserveAfterDate.clone() : null; + this.defaultReserveAfterDate = defaultReserveAfterDate != null ? (Timestamp) defaultReserveAfterDate.clone() : null; } public Timestamp getDefaultReserveAfterDate() { - return this.defaultReserveAfterDate != null ? (Timestamp) this.defaultReserveAfterDate.clone() : null; + return this.defaultReserveAfterDate != null ? (Timestamp) this.defaultReserveAfterDate.clone() : null; } public String getOrderPartyId() { @@ -1784,11 +1801,13 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return this.getPaymentInfo(id).amount; } + /** adds a payment ref */ public void addPaymentRef(String id, String ref, String authCode) { this.getPaymentInfo(id).refNum[0] = ref; this.getPaymentInfo(id).refNum[1] = authCode; } + /** get a payment ref */ public String getPaymentRef(String id) { for (CartPaymentInfo inf : paymentInfo) { if (inf.paymentMethodId.equals(id) || inf.paymentMethodTypeId.equals(id)) { @@ -1809,10 +1828,12 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return total; } + /** returns size of paymentInfo */ public int selectedPayments() { return paymentInfo.size(); } + /** is Payment Selected */ public boolean isPaymentSelected(String id) { CartPaymentInfo inf = this.getPaymentInfo(id); return paymentInfo.contains(inf); @@ -3029,12 +3050,12 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } public boolean isOrderTermSet() { - return orderTermSet; + return orderTermSet; } public void setOrderTermSet(boolean orderTermSet) { - this.orderTermSet = orderTermSet; - } + this.orderTermSet = orderTermSet; + } public boolean hasOrderTerm(String termTypeId) { if (termTypeId == null) { @@ -3049,12 +3070,12 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } public boolean isReadOnlyCart() { - return readOnlyCart; + return readOnlyCart; } public void setReadOnlyCart(boolean readOnlyCart) { - this.readOnlyCart = readOnlyCart; - } + this.readOnlyCart = readOnlyCart; + } /** go through the order adjustments and remove all adjustments with the given type */ public void removeAdjustmentByType(String orderAdjustmentTypeId) { @@ -3207,7 +3228,6 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return shippingApplies; } - /** Returns true when there are taxable items in the cart */ public boolean taxApplies() { boolean taxApplies = false; @@ -3219,7 +3239,6 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return taxApplies; } - /** Returns a Map of all features applied to products in the cart with quantities for a specific ship group. */ public Map<String, BigDecimal> getFeatureIdQtyMap(int idx) { CartShipInfo info = this.getShipInfo(idx); @@ -3234,44 +3253,38 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return featureMap; } - /** Returns true if the user wishes to view the cart everytime an item is added. */ public boolean viewCartOnAdd() { return viewCartOnAdd; } - /** Returns true if the user wishes to view the cart everytime an item is added. */ public void setViewCartOnAdd(boolean viewCartOnAdd) { this.viewCartOnAdd = viewCartOnAdd; } - /** Returns the order ID associated with this cart or null if no order has been created yet. */ public String getOrderId() { return this.orderId; } - /** Returns the first attempt order ID associated with this cart or null if no order has been created yet. */ public String getFirstAttemptOrderId() { return this.firstAttemptOrderId; } - /** Sets the orderId associated with this cart. */ public void setOrderId(String orderId) { this.orderId = orderId; } - + /** set next item seq */ public void setNextItemSeq(long seq) throws GeneralException { if (this.nextItemSeq != 1) { throw new GeneralException("Cannot set the item sequence once the sequence has been incremented!"); } this.nextItemSeq = seq; } - /** TODO: Sets the first attempt orderId for this cart. */ public void setFirstAttemptOrderId(String orderId) { this.firstAttemptOrderId = orderId; } - + /** remove all free shipping product promo action */ public void removeAllFreeShippingProductPromoActions() { this.freeShippingProductPromoActions.clear(); } @@ -3289,32 +3302,34 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return; } // is this a free shipping action? - if (!"PROMO_FREE_SHIPPING".equals(productPromoAction.getString("productPromoActionEnumId"))) - { + if (!"PROMO_FREE_SHIPPING".equals(productPromoAction.getString("productPromoActionEnumId"))) { return; // Changed 1-5-04 by Si Chen } - // to easily make sure that no duplicate exists, do a remove first this.removeFreeShippingProductPromoAction(productPromoAction.getPrimaryKey()); this.freeShippingProductPromoActions.add(productPromoAction); } + /** get free shipping product promo action */ public List<GenericValue> getFreeShippingProductPromoActions() { return this.freeShippingProductPromoActions; } - + /** remove all desired alternative gift by action */ public void removeAllDesiredAlternateGiftByActions() { this.desiredAlternateGiftByAction.clear(); } + /** set all desired alternative gift by action */ public void setDesiredAlternateGiftByAction(GenericPK productPromoActionPK, String productId) { this.desiredAlternateGiftByAction.put(productPromoActionPK, productId); } + /** get desired alternate gift by action */ public String getDesiredAlternateGiftByAction(GenericPK productPromoActionPK) { return this.desiredAlternateGiftByAction.get(productPromoActionPK); } + /** get all desired alternative gift by action copy */ public Map<GenericPK, String> getAllDesiredAlternateGiftByActionCopy() { return new HashMap<>(this.desiredAlternateGiftByAction); } - + /** add product promo use */ 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."); @@ -3324,7 +3339,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } this.productPromoUseInfoList.add(new ProductPromoUseInfo(productPromoId, productPromoCodeId, totalDiscountAmount, quantityLeftInActions, usageInfoMap)); } - + /** remove product promo use */ public void removeProductPromoUse(String productPromoId) { if (!productPromoId.isEmpty()) { int index = -1; @@ -3339,23 +3354,22 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } } - + /** clear out info for general promo use */ public void clearProductPromoUseInfo() { - // clear out info for general promo use this.productPromoUseInfoList.clear(); } - + /** clear cart item use in promo info */ public void clearCartItemUseInPromoInfo() { // clear out info about which cart items have been used in promos for (ShoppingCartItem cartLine : this) { cartLine.clearPromoRuleUseInfo(); } } - + /** get product promo use info iter */ public Iterator<ProductPromoUseInfo> getProductPromoUseInfoIter() { return productPromoUseInfoList.iterator(); } - + /** get product promo total */ public BigDecimal getProductPromoTotal() { BigDecimal totalDiscount = BigDecimal.ZERO; List<GenericValue> cartAdjustments = this.getAdjustments(); @@ -3399,7 +3413,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return totalDiscount; } - + /** get product promo use count */ public int getProductPromoUseCount(String productPromoId) { if (productPromoId == null) { return 0; @@ -3412,7 +3426,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return useCount; } - + /** get product promo code use */ public int getProductPromoCodeUse(String productPromoCodeId) { if (productPromoCodeId == null) { return 0; @@ -3425,7 +3439,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return useCount; } - + /** clear all promotion information */ public void clearAllPromotionInformation() { this.clearAllPromotionAdjustments(); @@ -3436,7 +3450,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { this.clearProductPromoUseInfo(); this.clearCartItemUseInPromoInfo(); } - + /** clear all promotion adjustments */ public void clearAllPromotionAdjustments() { // remove cart adjustments from promo actions List<GenericValue> cartAdjustments = this.getAdjustments(); @@ -3464,7 +3478,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } } - + /** clear all adjustments */ public void clearAllAdjustments() { // remove all the promotion information (including adjustments) clearAllPromotionInformation(); @@ -3475,7 +3489,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { checkItem.getAdjustments().clear(); } } - + /** clear all item status */ public void clearAllItemStatus() { for (ShoppingCartItem item : this) { item.setStatusId(null); @@ -3504,17 +3518,17 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return checkResult; } - + /** get product promo codes entered */ public Set<String> getProductPromoCodesEntered() { return this.productPromoCodes; } - + /** reset promo rule use */ public synchronized void resetPromoRuleUse(String productPromoId, String productPromoRuleId) { for (ShoppingCartItem cartItem : this) { cartItem.resetPromoRuleUse(productPromoId, productPromoRuleId); } } - + /** confirm promo rule use */ public synchronized void confirmPromoRuleUse(String productPromoId, String productPromoRuleId) { for (ShoppingCartItem cartItem : this) { cartItem.confirmPromoRuleUse(productPromoId, productPromoRuleId); @@ -3564,7 +3578,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } } - + /** get additional party role map */ public Map<String, List<String>> getAdditionalPartyRoleMap() { return additionalPartyRole; } @@ -3579,7 +3593,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * @param item * @param dispatcher */ - public String getAggregatedInstanceId (ShoppingCartItem item, LocalDispatcher dispatcher) { + public String getAggregatedInstanceId(ShoppingCartItem item, LocalDispatcher dispatcher) { if (UtilValidate.isEmpty(item.getConfigWrapper()) || UtilValidate.isEmpty(item.getConfigWrapper().getConfigId())) { return null; } @@ -3638,7 +3652,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { //create a new WorkEffortGoodStandard based on existing one of AGGREGATED product . //Another approach could be to get WorkEffortGoodStandard of the AGGREGATED product while creating production run. - GenericValue productionRunTemplate = EntityQuery.use(delegator).from("WorkEffortGoodStandard").where("productId", item.getProductId(), "workEffortGoodStdTypeId", "ROU_PROD_TEMPLATE", "statusId", "WEGS_CREATED").filterByDate().queryFirst(); + GenericValue productionRunTemplate = EntityQuery.use(delegator).from("WorkEffortGoodStandard").where("productId", item.getProductId(), + "workEffortGoodStdTypeId", "ROU_PROD_TEMPLATE", "statusId", "WEGS_CREATED").filterByDate().queryFirst(); if (productionRunTemplate != null) { serviceContext.clear(); serviceContext.put("workEffortId", productionRunTemplate.getString("workEffortId")); @@ -3658,7 +3673,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return newProductId; } - + /** make order item groups */ public List<GenericValue> makeOrderItemGroups() { List<GenericValue> result = new LinkedList<>(); for (ShoppingCart.ShoppingCartItemGroup itemGroup : this.itemGroupByNumberMap.values()) { @@ -3724,11 +3739,11 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } } - + /** make order items */ public List<GenericValue> makeOrderItems(LocalDispatcher dispatcher) { return makeOrderItems(false, false, dispatcher); } - + /** make order items */ public List<GenericValue> makeOrderItems(boolean explodeItems, boolean replaceAggregatedId, LocalDispatcher dispatcher) { // do the explosion if (explodeItems && dispatcher != null) { @@ -3849,9 +3864,9 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { if ("SHIPPING_CHARGES".equals(orderAdjustment.get("orderAdjustmentTypeId"))) { Iterator<GenericValue> fsppas = this.freeShippingProductPromoActions.iterator(); - while (fsppas.hasNext()) { + //while (fsppas.hasNext()) { // TODO - we need to change the way free shipping promotions work - } + //} } } @@ -3964,6 +3979,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return allInfos; } + /** make product promo uses */ public List<GenericValue> makeProductPromoUses() { List<GenericValue> productPromoUses = new LinkedList<>(); String partyId = this.getPartyId(); @@ -4064,15 +4080,15 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return groups; } - + /** get ship info size */ public int getShipInfoSize() { return this.shipInfo.size(); } - + /** make All Order Item Attributes */ public List<GenericValue> makeAllOrderItemAttributes() { return makeAllOrderItemAttributes(null, ALL); } - + /** make All Order Item Attributes */ public List<GenericValue> makeAllOrderItemAttributes(String orderId, int mode) { // now build order item attributes @@ -4103,11 +4119,11 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return result; } } - + /** make All Order Attributes */ public List<GenericValue> makeAllOrderAttributes() { return makeAllOrderAttributes(null, ALL); } - + /** make all order attributes */ public List<GenericValue> makeAllOrderAttributes(String orderId, int mode) { List<GenericValue> allOrderAttributes = new LinkedList<>(); @@ -4143,7 +4159,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return allOrderAttributes; } - + /** make all order item associations */ public List<GenericValue> makeAllOrderItemAssociations() { List<GenericValue> allOrderItemAssociations = new LinkedList<>(); @@ -4188,7 +4204,6 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return allOrderItemAssociations; } - /** Returns a Map of cart values to pass to the storeOrder service */ public Map<String, Object> makeCartMap(LocalDispatcher dispatcher, boolean explodeItems) { Map<String, Object> result = new HashMap<>(); @@ -4249,12 +4264,14 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return result; } + /** get line list ordered by base price */ public List<ShoppingCartItem> getLineListOrderedByBasePrice(boolean ascending) { List<ShoppingCartItem> result = new ArrayList<>(this.cartLines); result.sort(new BasePriceOrderComparator(ascending)); return result; } + /** get ship groups by supplier */ public TreeMap<Integer, CartShipInfo> getShipGroupsBySupplier(String supplierPartyId) { TreeMap<Integer, CartShipInfo> shipGroups = new TreeMap<>(); for (int i = 0; i < this.shipInfo.size(); i++) { @@ -4513,23 +4530,23 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { this.groupName = itemGroup.groupName; this.parentGroup = parentGroup; } - + /** get group number */ public String getGroupNumber() { return this.groupNumber; } - + /** get group name */ public String getGroupName() { return this.groupName; } - + /** set group name */ public void setGroupName(String str) { this.groupName = str; } - - public ShoppingCartItemGroup getParentGroup () { + /** get parent group */ + public ShoppingCartItemGroup getParentGroup() { return this.parentGroup; } - + /** make order item group */ protected GenericValue makeOrderItemGroup(Delegator delegator) { GenericValue orderItemGroup = delegator.makeValue("OrderItemGroup"); orderItemGroup.set("orderItemGroupSeqId", this.getGroupNumber()); @@ -4539,13 +4556,13 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return orderItemGroup; } - + /** inherit parents parent */ public void inheritParentsParent() { if (this.parentGroup != null) { this.parentGroup = this.parentGroup.getParentGroup(); } } - + /** has code */ @Override public int hashCode() { final int prime = 31; @@ -4556,6 +4573,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return result; } + /** equals */ @Override public boolean equals(Object obj) { if (obj instanceof ShoppingCartItemGroup) { @@ -4583,11 +4601,25 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { 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 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<Entry<ShoppingCartItem, BigDecimal>> lineItems = this.usageInfoMap.entrySet().iterator(); BigDecimal totalAmount = BigDecimal.ZERO; @@ -4603,7 +4635,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { @Override public int compareTo(ProductPromoUseInfo other) { - return other.getUsageWeight().compareTo(getUsageWeight()); + return other.getUsageWeight().compareTo(getUsageWeight()); } @Override @@ -4670,82 +4702,146 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } public static class CartShipInfo implements Serializable { - public Map<ShoppingCartItem, CartShipItemInfo> shipItemInfo = new HashMap<>(); - public List<GenericValue> shipTaxAdj = new LinkedList<>(); - public String orderTypeId = null; + private Map<ShoppingCartItem, CartShipItemInfo> shipItemInfo = new HashMap<>(); + private List<GenericValue> shipTaxAdj = new LinkedList<>(); + private String orderTypeId = null; private String internalContactMechId = null; - public String telecomContactMechId = null; - public String shipmentMethodTypeId = null; - public String supplierPartyId = null; - public String supplierAgreementId = null; - public String carrierRoleTypeId = null; - public String carrierPartyId = null; + private String telecomContactMechId = null; + private String shipmentMethodTypeId = null; + private String supplierPartyId = null; + private String supplierAgreementId = null; + private String carrierRoleTypeId = null; + private String carrierPartyId = null; private String facilityId = null; - public String giftMessage = null; - public String shippingInstructions = null; - public String maySplit = "N"; - public String isGift = "N"; - public BigDecimal shipEstimate = BigDecimal.ZERO; - public Timestamp shipBeforeDate = null; - public Timestamp shipAfterDate = null; + private String giftMessage = null; + private String shippingInstructions = null; + private String maySplit = "N"; + private String isGift = "N"; + private BigDecimal shipEstimate = BigDecimal.ZERO; + private Timestamp shipBeforeDate = null; + private Timestamp shipAfterDate = null; private String shipGroupSeqId = null; private String associatedShipGroupSeqId = null; - public String vendorPartyId = null; - public String productStoreShipMethId = null; - public Map<String, Object> attributes = new HashMap<>(); + private String vendorPartyId = null; + private String productStoreShipMethId = null; + private Map<String, Object> attributes = new HashMap<>(); + /** set ship before date */ + public void setShipBeforeDate(Timestamp shipBeforeDate) { + this.shipBeforeDate = shipBeforeDate; + } + /** set ship after date */ + public void setShipAfterDate(Timestamp shipAfterDate) { + this.shipAfterDate = shipAfterDate; + } + /** get ship item info */ + public Map<ShoppingCartItem, CartShipItemInfo> getShipItemInfo() { + return this.shipItemInfo; + } + /** set attribute */ public void setAttribute(String name, Object value) { this.attributes.put(name, value); } - + /** set gift message */ + public void setGiftMessage(String giftMessage) { + this.giftMessage = giftMessage; + } + /** set shipping instructions */ + public void setShippingInstructions(String shippingInstructions) { + this.shippingInstructions = shippingInstructions; + } + /** remove attribute */ public void removeAttribute(String name) { this.attributes.remove(name); } - + /** get attribute */ @SuppressWarnings("unchecked") public <T> T getAttribute(String name) { return (T) this.attributes.get(name); } - - public String getOrderTypeId() { return orderTypeId; } - - public String getContactMechId() { return internalContactMechId; } + /** get order type id */ + public String getOrderTypeId() { + return orderTypeId; + } + /** get contact mech id */ + public String getContactMechId() { + return internalContactMechId; + } + /** set contact mech id */ public void setContactMechId(String contactMechId) { this.internalContactMechId = contactMechId; } - - public String getCarrierPartyId() { return carrierPartyId; } - public String getSupplierPartyId() { return supplierPartyId; } - public String getSupplierAgreementId() { return supplierAgreementId; } - public String getShipmentMethodTypeId() { return shipmentMethodTypeId; } - public BigDecimal getShipEstimate() { return shipEstimate; } - - public String getShipGroupSeqId() { return shipGroupSeqId; } + /** get carrier party id */ + public String getCarrierPartyId() { + return carrierPartyId; + } + /** set carrier party id */ + public void setCarrierPartyId(String carrierPartyId) { + this.carrierPartyId = carrierPartyId; + } + /** get supplier party id */ + public String getSupplierPartyId() { + return supplierPartyId; + } + /** set supplier party id */ + public void setSupplierPartyId(String supplierPartyId) { + this.supplierPartyId = supplierPartyId; + } + /** get supplier agreement id */ + public String getSupplierAgreementId() { + return supplierAgreementId; + } + /** get shipment method type id */ + public String getShipmentMethodTypeId() { + return shipmentMethodTypeId; + } + /** set shipment method type id */ + public void setShipmentMethodTypeId(String shipmentMethodTypeId) { + this.shipmentMethodTypeId = shipmentMethodTypeId; + } + /** get ship estimate */ + public BigDecimal getShipEstimate() { + return shipEstimate; + } + /** get ship group seq id */ + public String getShipGroupSeqId() { + return shipGroupSeqId; + } + /** set ship group seq id */ public void setShipGroupSeqId(String shipGroupSeqId) { this.shipGroupSeqId = shipGroupSeqId; } - - public String getAssociatedShipGroupSeqId() { return associatedShipGroupSeqId; } + /** get associated ship groups eq id */ + public String getAssociatedShipGroupSeqId() { + return associatedShipGroupSeqId; + } + /** set associated ship grou seq id */ public void setAssociatedShipGroupSeqId(String shipGroupSeqId) { this.associatedShipGroupSeqId = shipGroupSeqId; } - - public String getFacilityId() { return facilityId; } + /** get facility Id */ + public String getFacilityId() { + return facilityId; + } + /** set facility id */ public void setFacilityId(String facilityId) { this.facilityId = facilityId; } - - public String getVendorPartyId() { return vendorPartyId;} + /** get vendor party */ + public String getVendorPartyId() { + return vendorPartyId; + } + /** set vendor party */ public void setVendorPartyId(String vendorPartyId) { this.vendorPartyId = vendorPartyId; } - + /** set may split */ public void setMaySplit(Boolean maySplit) { if (UtilValidate.isNotEmpty(maySplit)) { this.maySplit = maySplit ? "Y" : "N"; } } - + /** get origin address */ public GenericValue getOriginAddress(ShoppingCart cart) { GenericValue originAddress = null; Delegator delegator = cart.delegator; @@ -4778,6 +4874,19 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return originAddress; } + /** clear all tax info */ + public void clearShipTaxAdj() { + this.shipTaxAdj.clear(); + } + /** add ship tax adj */ + public void addShipTaxAdj(GenericValue shipTaxAdj) { + this.shipTaxAdj.add(shipTaxAdj); + } + /** add ship tax adj */ + public void addShipTaxAdj(List<GenericValue> shipTaxAdj) { + this.shipTaxAdj.addAll(shipTaxAdj); + } + /** clear all tax info */ public void clearAllTaxInfo() { this.shipTaxAdj.clear(); for (CartShipItemInfo itemInfo : shipItemInfo.values()) { @@ -4785,11 +4894,13 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** make Item Ship Group And Assoc */ @Deprecated public List<GenericValue> makeItemShipGroupAndAssoc(LocalDispatcher dispatcher, Delegator delegator, ShoppingCart cart, String shipGroupSeqId, boolean newShipGroup) { return makeItemShipGroupAndAssoc(dispatcher, delegator, cart, shipGroupSeqId); } + /** make item ship group assoc */ public List<GenericValue> makeItemShipGroupAndAssoc(LocalDispatcher dispatcher, Delegator delegator, ShoppingCart cart, String shipGroupSeqId) { List<GenericValue> values = new LinkedList<>(); @@ -4936,6 +5047,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return values; } + /** set item info */ public CartShipItemInfo setItemInfo(ShoppingCartItem item, BigDecimal quantity, List<GenericValue> taxAdj) { CartShipItemInfo itemInfo = shipItemInfo.get(item); if (itemInfo == null) { @@ -4956,18 +5068,22 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return itemInfo; } + /** set item info */ public CartShipItemInfo setItemInfo(ShoppingCartItem item, List<GenericValue> taxAdj) { return setItemInfo(item, BigDecimal.ONE.negate(), taxAdj); } + /** set item info */ public CartShipItemInfo setItemInfo(ShoppingCartItem item, BigDecimal quantity) { return setItemInfo(item, quantity, null); } + /** get ship item info */ public CartShipItemInfo getShipItemInfo(ShoppingCartItem item) { return shipItemInfo.get(item); } + /** get ship items */ public Set<ShoppingCartItem> getShipItems() { return shipItemInfo.keySet(); } @@ -5016,6 +5132,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** get total tax */ public BigDecimal getTotalTax(ShoppingCart cart) { List<GenericValue> taxAdjustments = new LinkedList<>(); taxAdjustments.addAll(shipTaxAdj); @@ -5027,6 +5144,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return taxTotal; } + /** get total */ public BigDecimal getTotal() { BigDecimal shipItemTotal = BigDecimal.ZERO; for (CartShipItemInfo info : shipItemInfo.values()) { @@ -5038,9 +5156,13 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { public static class CartShipItemInfo implements Serializable { public List<GenericValue> itemTaxAdj = new LinkedList<>(); - public ShoppingCartItem item = null; - public BigDecimal quantity = BigDecimal.ZERO; - + private ShoppingCartItem item = null; + private BigDecimal quantity = BigDecimal.ZERO; + /** get item tax adj*/ + public List<GenericValue> getItemTaxAdj() { + return this.itemTaxAdj; + } + /** get item tax */ public BigDecimal getItemTax(ShoppingCart cart) { BigDecimal itemTax = BigDecimal.ZERO; @@ -5051,15 +5173,15 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return itemTax.setScale(TAX_SCALE, TAX_ROUNDING); } - + /** get item */ public ShoppingCartItem getItem() { return this.item; } - + /** get item qty */ public BigDecimal getItemQuantity() { return this.quantity; } - + /** get item sub total */ public BigDecimal getItemSubTotal() { return item.getItemSubTotal(quantity); } @@ -5067,19 +5189,86 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } public static class CartPaymentInfo implements Serializable, Comparable<Object> { - public String paymentMethodTypeId = null; - public String paymentMethodId = null; - public String finAccountId = null; - public String securityCode = null; - public String postalCode = null; - public String[] refNum = new String[2]; - public String track2 = null; - public BigDecimal amount = null; - public boolean singleUse = false; - public boolean isPresent = false; - public boolean isSwiped = false; - public boolean overflow = false; - + private String paymentMethodTypeId = null; + private String paymentMethodId = null; + private String finAccountId = null; + private String securityCode = null; + private String postalCode = null; + private String[] refNum = new String[2]; + private String track2 = null; + private BigDecimal amount = null; + private boolean singleUse = false; + private boolean isPresent = false; + private boolean isSwiped = false; + private boolean overflow = false; + /** set postal code */ + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + /** set payment method id */ + public void setPaymentMethodId(String paymentMethodId) { + this.paymentMethodId = paymentMethodId; + } + /** get payment method id */ + public String getPaymentMethodId() { + return this.paymentMethodId; + } + /** get payment method type id */ + public String getPaymentMethodTypeId() { + return this.paymentMethodTypeId; + } + /** set overflow */ + public void setOverflow(boolean overflow) { + this.overflow = overflow; + } + /** get overflow */ + public boolean getOverflow() { + return this.overflow; + } + /** set is swiped */ + public void setIsSwiped(boolean isSwiped) { + this.isSwiped = isSwiped; + } + /** get is swiped */ + public boolean getIsSwiped() { + return this.isSwiped; + } + /** set finaccount id */ + public void setFinAccountId(String finAccountId) { + this.finAccountId = finAccountId; + } + /** get finaccount id */ + public String getFinAccountId() { + return this.finAccountId; + } + /** set security code */ + public void setSecurityCode(String securityCode) { + this.securityCode = securityCode; + } + /** get security code */ + public String getSecurityCode() { + return this.securityCode; + } + /** set refNum and auth code */ + public void setRefNum(String refNum, String authCode) { + this.refNum[0] = refNum; + if (UtilValidate.isNotEmpty(authCode)) { + this.refNum[1] = authCode; + } + } + /** set refNum*/ + public void setRefNum(String refNum) { + setRefNum(refNum, null); + } + /** set amount */ + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + /** get amount */ + public BigDecimal getAmount() { + return this.amount; + } + /** get value object */ public GenericValue getValueObject(Delegator delegator) { String entityName = null; Map<String, String> lookupFields = null; @@ -5101,7 +5290,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return null; } - + /** get billing address */ public GenericValue getBillingAddress(Delegator delegator) { GenericValue valueObj = this.getValueObject(delegator); GenericValue postalAddress = null; @@ -5137,6 +5326,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return postalAddress; } + /** make order payment info */ public List<GenericValue> makeOrderPaymentInfos(Delegator delegator, ShoppingCart cart) { BigDecimal maxAmount = BigDecimal.ZERO; GenericValue valueObj = this.getValueObject(delegator); @@ -5199,7 +5389,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { opp.set("securityCode", securityCode); } if (track2 != null) { - opp.set("track2", track2); + opp.set("track2", track2); } if (paymentMethodId != null || "FIN_ACCOUNT".equals(paymentMethodTypeId)) { opp.set("statusId", "PAYMENT_NOT_AUTH"); @@ -5259,6 +5449,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return values; } + /** compare to */ @Override public int compareTo(Object o) { CartPaymentInfo that = (CartPaymentInfo) o; @@ -5310,7 +5501,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return pmtCmp; } - + /** hash code */ @Override public int hashCode() { final int prime = 31; @@ -5329,7 +5520,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { result = prime * result + ((track2 == null) ? 0 : track2.hashCode()); return result; } - + /** equals */ @Override public boolean equals(Object obj) { if (this == obj) { @@ -5408,38 +5599,45 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } return true; } - + /** to string */ @Override public String toString() { return "Pm: " + paymentMethodId + " / PmType: " + paymentMethodTypeId + " / Amt: " + amount + " / Ref: " + refNum[0] + "!" + refNum[1]; } } + /** get order attributes */ public Map<String, String> getOrderAttributes() { return orderAttributes; } + /** set order attributes */ public void setOrderAttributes(Map<String, String> orderAttributes) { this.orderAttributes = orderAttributes; } + /** get order status id */ public String getOrderStatusId() { return orderStatusId; } + /** set order status id */ public void setOrderStatusId(String orderStatusId) { this.orderStatusId = orderStatusId; } + /** get order status string */ public String getOrderStatusString() { return orderStatusString; } + /** set order status string */ public void setOrderStatusString(String orderStatusString) { this.orderStatusString = orderStatusString; } - public static BigDecimal getMinimumOrderQuantity(Delegator delegator, BigDecimal itemBasePrice, String itemProductId) throws GenericEntityException { + public static BigDecimal getMinimumOrderQuantity(Delegator delegator, BigDecimal itemBasePrice, String itemProductId) + throws GenericEntityException { BigDecimal minQuantity = BigDecimal.ZERO; BigDecimal minimumOrderPrice = BigDecimal.ZERO; diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java index d4eaf9c..1d2ff58 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java @@ -1889,8 +1889,8 @@ public class ShoppingCartEvents { Map<String, Object> itemAttributes = UtilMisc.<String, Object>toMap("itemDesiredDeliveryDate", itemDesiredDeliveryDateStr); if (quantity.compareTo(BigDecimal.ZERO) > 0) { - Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + null + - ", quantity = " + quantity + ", itemType = " + itemType + " and itemDescription = " + itemDescription, MODULE); + Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + null + + ", quantity = " + quantity + ", itemType = " + itemType + " and itemDescription = " + itemDescription, MODULE); result = cartHelper.addToCart(catalogId, shoppingListId, shoppingListItemSeqId, productId, null, itemType, itemDescription, null, amount, quantity, null, null, null, null, null, null, @@ -2094,8 +2094,8 @@ public class ShoppingCartEvents { shipGroupSeqId = (String) paramMap.remove("shipGroupSeqId" + thisSuffix); } if (quantity.compareTo(BigDecimal.ZERO) > 0) { - Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + null + - ", quantity = " + quantity + ", itemType = " + itemType + " and itemDescription = " + itemDescription, MODULE); + Debug.logInfo("Attempting to add to cart with productId = " + productId + ", categoryId = " + null + + ", quantity = " + quantity + ", itemType = " + itemType + " and itemDescription = " + itemDescription, MODULE); HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); Map<String, Object> appendOrderItemMap = new HashMap<>(); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java index dc63e7d..6018ded 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java @@ -697,8 +697,8 @@ public class ShoppingCartItem implements java.io.Serializable { this.quantityUsedPerPromoCandidate = new HashMap<>(item.quantityUsedPerPromoCandidate); this.quantityUsedPerPromoFailed = new HashMap<>(item.quantityUsedPerPromoFailed); this.quantityUsedPerPromoActual = new HashMap<>(item.quantityUsedPerPromoActual); - this.additionalProductFeatureAndAppls = item.getAdditionalProductFeatureAndAppls() == null ? - null : new HashMap<>(item.getAdditionalProductFeatureAndAppls()); + this.additionalProductFeatureAndAppls = item.getAdditionalProductFeatureAndAppls() == null + ? null : new HashMap<>(item.getAdditionalProductFeatureAndAppls()); if (item.getAlternativeOptionProductIds() != null) { List<String> tempAlternativeOptionProductIds = new LinkedList<>(); tempAlternativeOptionProductIds.addAll(item.getAlternativeOptionProductIds()); @@ -980,9 +980,8 @@ public class ShoppingCartItem implements java.io.Serializable { } if (exceptionCapacity.compareTo(quantity.add(usedCapacity)) < 0) { resultMessage = resultMessage.concat(exceptionDateStartTime.toString().substring(0, 10) + ", "); - Debug.logInfo("No rental fixed Asset available: " + exceptionCapacity + - " already used: " + usedCapacity + - " Requested now: " + quantity, MODULE); + Debug.logInfo("No rental fixed Asset available: " + exceptionCapacity + + " already used: " + usedCapacity + " Requested now: " + quantity, MODULE); } } } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java index b90fd3c..fcfd3e9 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java @@ -62,10 +62,10 @@ import org.apache.ofbiz.service.ServiceUtil; */ public class ShoppingCartServices { + private static final MathContext GEN_ROUNDING = new MathContext(10); private static final String MODULE = ShoppingCartServices.class.getName(); private static final String RES_ERROR = "OrderErrorUiLabels"; - public static final MathContext GEN_ROUNDING = new MathContext(10); public static Map<String, Object> assignItemShipGroup(DispatchContext dctx, Map<String, Object> context) { ShoppingCart cart = (ShoppingCart) context.get("shoppingCart"); Integer fromGroupIndex = (Integer) context.get("fromGroupIndex"); @@ -91,7 +91,7 @@ public class ShoppingCartServices { return ServiceUtil.returnSuccess(); } - public static Map<String, Object>setShippingOptions(DispatchContext dctx, Map<String, Object> context) { + public static Map<String, Object> setShippingOptions(DispatchContext dctx, Map<String, Object> context) { ShoppingCart cart = (ShoppingCart) context.get("shoppingCart"); Integer groupIndex = (Integer) context.get("groupIndex"); String shippingContactMechId = (String) context.get("shippingContactMechId"); @@ -114,7 +114,7 @@ public class ShoppingCartServices { if (delimiterPos > 0) { shipmentMethodTypeId = shipmentMethodString.substring(0, delimiterPos); carrierPartyId = shipmentMethodString.substring(delimiterPos + 1); - } + } cart.setShipmentMethodTypeId(idx, shipmentMethodTypeId); cart.setCarrierPartyId(idx, carrierPartyId); @@ -131,18 +131,19 @@ public class ShoppingCartServices { cart.setIsGift(idx, isGift); } } else { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderCartShipGroupNotFound", UtilMisc.toMap("groupIndex", groupIndex), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderCartShipGroupNotFound", UtilMisc.toMap("groupIndex", + groupIndex), locale)); } return ServiceUtil.returnSuccess(); } - public static Map<String, Object>setPaymentOptions(DispatchContext dctx, Map<String, Object> context) { + public static Map<String, Object> setPaymentOptions(DispatchContext dctx, Map<String, Object> context) { Locale locale = (Locale) context.get("locale"); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderServiceNotYetImplemented", locale)); } - public static Map<String, Object>setOtherOptions(DispatchContext dctx, Map<String, Object> context) { + public static Map<String, Object> setOtherOptions(DispatchContext dctx, Map<String, Object> context) { ShoppingCart cart = (ShoppingCart) context.get("shoppingCart"); String orderAdditionalEmails = (String) context.get("orderAdditionalEmails"); String correspondingPoId = (String) context.get("correspondingPoId"); @@ -157,7 +158,7 @@ public class ShoppingCartServices { return ServiceUtil.returnSuccess(); } - public static Map<String, Object>loadCartFromOrder(DispatchContext dctx, Map<String, Object> context) { + public static Map<String, Object> loadCartFromOrder(DispatchContext dctx, Map<String, Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); @@ -184,7 +185,8 @@ public class ShoppingCartServices { try { orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); orderTerms = orderHeader.getRelated("OrderTerm", null, null, false); - orderContactMechs = EntityQuery.use(delegator).select("orderId", "contactMechId", "contactMechPurposeTypeId").from("OrderAndPartyContactMech").where("orderId", orderId).filterByDate("contactFromDate", "contactThruDate").distinct().queryList(); + orderContactMechs = EntityQuery.use(delegator).select("orderId", "contactMechId", "contactMechPurposeTypeId").from( + "OrderAndPartyContactMech").where("orderId", orderId).filterByDate("contactFromDate", "contactThruDate").distinct().queryList(); } catch (GenericEntityException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(e.getMessage()); @@ -301,7 +303,7 @@ public class ShoppingCartServices { } // for finance account the finAccountId needs to be set if ("FIN_ACCOUNT".equals(paymentId)) { - cpi.finAccountId = opp.getString("finAccountId"); + cpi.setFinAccountId(opp.getString("finAccountId")); } // set the billing account and amount cart.setBillingAccount(orderHeader.getString("billingAccountId"), orh.getBillingAccountMaxAmount()); @@ -321,7 +323,8 @@ public class ShoppingCartServices { termDays = Long.parseLong(orderTerm.getString("termDays").trim()); } String orderItemSeqId = orderTerm.getString("orderItemSeqId"); - cart.addOrderTerm(orderTerm.getString("termTypeId"), orderItemSeqId, termValue, termDays, orderTerm.getString("textValue"), orderTerm.getString("description")); + cart.addOrderTerm(orderTerm.getString("termTypeId"), orderItemSeqId, termValue, termDays, orderTerm.getString("textValue"), + orderTerm.getString("description")); } } if (UtilValidate.isNotEmpty(orderContactMechs)) { @@ -330,26 +333,26 @@ public class ShoppingCartServices { } } List<GenericValue> orderItemShipGroupList = orh.getOrderItemShipGroups(); - for (GenericValue orderItemShipGroup: orderItemShipGroupList) { + for (GenericValue orderItemShipGroup : orderItemShipGroupList) { // should be sorted by shipGroupSeqId int groupIdx = Integer.parseInt(orderItemShipGroup.getString("shipGroupSeqId")); - CartShipInfo cartShipInfo = cart.getShipInfo(groupIdx-1); + CartShipInfo cartShipInfo = cart.getShipInfo(groupIdx - 1); if (cartShipInfo == null) { cartShipInfo = cart.getShipInfo(cart.addShipInfo()); } - cartShipInfo.shipAfterDate = orderItemShipGroup.getTimestamp("shipAfterDate"); - cartShipInfo.shipBeforeDate = orderItemShipGroup.getTimestamp("shipByDate"); - cartShipInfo.shipmentMethodTypeId = orderItemShipGroup.getString("shipmentMethodTypeId"); - cartShipInfo.carrierPartyId = orderItemShipGroup.getString("carrierPartyId"); - cartShipInfo.supplierPartyId = orderItemShipGroup.getString("supplierPartyId"); + cartShipInfo.setShipAfterDate(orderItemShipGroup.getTimestamp("shipAfterDate")); + cartShipInfo.setShipBeforeDate(orderItemShipGroup.getTimestamp("shipByDate")); + cartShipInfo.setShipmentMethodTypeId(orderItemShipGroup.getString("shipmentMethodTypeId")); + cartShipInfo.setCarrierPartyId(orderItemShipGroup.getString("carrierPartyId")); + cartShipInfo.setSupplierPartyId(orderItemShipGroup.getString("supplierPartyId")); cartShipInfo.setMaySplit(orderItemShipGroup.getBoolean("maySplit")); - cartShipInfo.giftMessage = orderItemShipGroup.getString("giftMessage"); + cartShipInfo.setGiftMessage(orderItemShipGroup.getString("giftMessage")); cartShipInfo.setContactMechId(orderItemShipGroup.getString("contactMechId")); - cartShipInfo.shippingInstructions = orderItemShipGroup.getString("shippingInstructions"); + cartShipInfo.setShippingInstructions(orderItemShipGroup.getString("shippingInstructions")); cartShipInfo.setFacilityId(orderItemShipGroup.getString("facilityId")); cartShipInfo.setVendorPartyId(orderItemShipGroup.getString("vendorPartyId")); cartShipInfo.setShipGroupSeqId(orderItemShipGroup.getString("shipGroupSeqId")); - cartShipInfo.shipTaxAdj.addAll(orh.getOrderHeaderAdjustmentsTax(orderItemShipGroup.getString("shipGroupSeqId"))); + cartShipInfo.addShipTaxAdj(orh.getOrderHeaderAdjustmentsTax(orderItemShipGroup.getString("shipGroupSeqId"))); } List<GenericValue> orderItems = orh.getOrderItems(); @@ -383,11 +386,13 @@ public class ShoppingCartServices { if ("DIGITAL_GOOD".equals(product.getString("productTypeId"))) { Map<String, Object> surveyResponseMap = new HashMap<>(); Map<String, Object> answers = new HashMap<>(); - List<GenericValue> surveyResponseAndAnswers = EntityQuery.use(delegator).from("SurveyResponseAndAnswer").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryList(); + List<GenericValue> surveyResponseAndAnswers = EntityQuery.use(delegator).from("SurveyResponseAndAnswer").where("orderId", + orderId, "orderItemSeqId", orderItemSeqId).queryList(); if (UtilValidate.isNotEmpty(surveyResponseAndAnswers)) { String surveyId = EntityUtil.getFirst(surveyResponseAndAnswers).getString("surveyId"); for (GenericValue surveyResponseAndAnswer : surveyResponseAndAnswers) { - answers.put((surveyResponseAndAnswer.get("surveyQuestionId").toString()), surveyResponseAndAnswer.get("textResponse")); + answers.put((surveyResponseAndAnswer.get("surveyQuestionId").toString()), + surveyResponseAndAnswer.get("textResponse")); } surveyResponseMap.put("answers", answers); surveyResponseMap.put("surveyId", surveyId); @@ -474,11 +479,12 @@ public class ShoppingCartServices { String configId = null; try { product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); - if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "AGGREGATED")) { + if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), + "parentTypeId", "AGGREGATED")) { GenericValue productAssoc = EntityQuery.use(delegator).from("ProductAssoc") - .where("productAssocTypeId", "PRODUCT_CONF", "productIdTo", product.getString("productId")) - .filterByDate() - .queryFirst(); + .where("productAssocTypeId", "PRODUCT_CONF", "productIdTo", product.getString("productId")) + .filterByDate() + .queryFirst(); if (productAssoc != null) { productId = productAssoc.getString("productId"); configId = product.getString("configId"); @@ -489,10 +495,14 @@ public class ShoppingCartServices { } if (UtilValidate.isNotEmpty(configId)) { - configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, productId, productStoreId, prodCatalogId, website, currency, locale, userLogin); + configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, productId, productStoreId, + prodCatalogId, website, currency, locale, userLogin); } try { - itemIndex = cart.addItemToEnd(productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, null, null, prodCatalogId, configWrapper, item.getString("orderItemTypeId"), dispatcher, null, unitPrice == null ? null : false, skipInventoryChecks, skipProductChecks); + itemIndex = cart.addItemToEnd(productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, + accommodationMapId, accommodationSpotId, null, null, prodCatalogId, configWrapper, + item.getString("orderItemTypeId"), dispatcher, null, unitPrice == null ? null : false, skipInventoryChecks, + skipProductChecks); } catch (ItemNotFoundException | CartItemModifyException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(e.getMessage()); @@ -535,7 +545,8 @@ public class ShoppingCartServices { // load order item attributes List<GenericValue> orderItemAttributesList = null; try { - orderItemAttributesList = EntityQuery.use(delegator).from("OrderItemAttribute").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryList(); + orderItemAttributesList = EntityQuery.use(delegator).from("OrderItemAttribute").where("orderId", orderId, "orderItemSeqId", + orderItemSeqId).queryList(); if (UtilValidate.isNotEmpty(orderItemAttributesList)) { for (GenericValue orderItemAttr : orderItemAttributesList) { String name = orderItemAttr.getString("attrName"); @@ -551,7 +562,8 @@ public class ShoppingCartServices { // load order item contact mechs List<GenericValue> orderItemContactMechList = null; try { - orderItemContactMechList = EntityQuery.use(delegator).from("OrderItemContactMech").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryList(); + orderItemContactMechList = EntityQuery.use(delegator).from("OrderItemContactMech").where("orderId", orderId, "orderItemSeqId", + orderItemSeqId).queryList(); if (UtilValidate.isNotEmpty(orderItemContactMechList)) { for (GenericValue orderItemContactMech : orderItemContactMechList) { String contactMechPurposeTypeId = orderItemContactMech.getString("contactMechPurposeTypeId"); @@ -616,24 +628,27 @@ public class ShoppingCartServices { if (cartItem == null || cartItem.getQuantity() == null || BigDecimal.ZERO.equals(cartItem.getQuantity()) || shipGroupQty.equals(cartItem.getQuantity())) { - Debug.logInfo("In loadCartFromOrder not adding item [" + item.getString("orderItemSeqId") + - "] to ship group with index [" + itemIndex + "]; group quantity is [" + shipGroupQty + - "] item quantity is [" + (cartItem != null ? cartItem.getQuantity() : "no cart item") + - "] cartShipGroupIndex is [" + cartShipGroupIndex + "], csi.shipItemInfo.size(): " + - (cartShipGroupIndex < 0 ? 0 : csi.shipItemInfo.size()), MODULE); + Debug.logInfo("In loadCartFromOrder not adding item [" + item.getString("orderItemSeqId") + + "] to ship group with index [" + itemIndex + "]; group quantity is [" + shipGroupQty + + "] item quantity is [" + (cartItem != null ? cartItem.getQuantity() : "no cart item") + + "] cartShipGroupIndex is [" + cartShipGroupIndex + "], csi.shipItemInfo.size(): " + + (cartShipGroupIndex < 0 ? 0 : csi.getShipItemInfo().size()), MODULE); } else { cart.setItemShipGroupQty(itemIndex, shipGroupQty, cartShipGroupIndex); } - List<GenericValue> shipGroupItemAdjustments = EntityUtil.filterByAnd(orderItemAdjustments, UtilMisc.toMap("shipGroupSeqId", cartShipGroupIndexStr)); + List<GenericValue> shipGroupItemAdjustments = EntityUtil.filterByAnd(orderItemAdjustments, UtilMisc.toMap("shipGroupSeqId", + cartShipGroupIndexStr)); if (cartItem == null || cartShipGroupIndex < 0) { - Debug.logWarning("In loadCartFromOrder could not find cart item for itemIndex=" + itemIndex + ", for orderId=" + orderId, MODULE); + Debug.logWarning("In loadCartFromOrder could not find cart item for itemIndex=" + itemIndex + ", for orderId=" + + orderId, MODULE); } else { CartShipItemInfo cartShipItemInfo = csi.getShipItemInfo(cartItem); if (cartShipItemInfo == null) { - Debug.logWarning("In loadCartFromOrder could not find CartShipItemInfo for itemIndex=" + itemIndex + ", for orderId=" + orderId, MODULE); + Debug.logWarning("In loadCartFromOrder could not find CartShipItemInfo for itemIndex=" + itemIndex + ", for " + + "orderId=" + orderId, MODULE); } else { - List<GenericValue> itemTaxAdj = cartShipItemInfo.itemTaxAdj; + List<GenericValue> itemTaxAdj = cartShipItemInfo.getItemTaxAdj(); for (GenericValue shipGroupItemAdjustment : shipGroupItemAdjustments) { if (isTaxAdjustment(shipGroupItemAdjustment)) { itemTaxAdj.add(shipGroupItemAdjustment); @@ -642,7 +657,7 @@ public class ShoppingCartServices { } } } - itemIndex ++; + itemIndex++; } } @@ -658,11 +673,13 @@ public class ShoppingCartServices { } if (includePromoItems) { - for (String productPromoCode: orh.getProductPromoCodesEntered()) { + for (String productPromoCode : orh.getProductPromoCodesEntered()) { cart.addProductPromoCode(productPromoCode, dispatcher); } - for (GenericValue productPromoUse: orh.getProductPromoUse()) { - cart.addProductPromoUse(productPromoUse.getString("productPromoId"), productPromoUse.getString("productPromoCodeId"), productPromoUse.getBigDecimal("totalDiscountAmount"), productPromoUse.getBigDecimal("quantityLeftInActions"), new HashMap<ShoppingCartItem, BigDecimal>()); + for (GenericValue productPromoUse : orh.getProductPromoUse()) { + cart.addProductPromoUse(productPromoUse.getString("productPromoId"), productPromoUse.getString("productPromoCodeId"), + productPromoUse.getBigDecimal("totalDiscountAmount"), productPromoUse.getBigDecimal("quantityLeftInActions"), + new HashMap<ShoppingCartItem, BigDecimal>()); } } @@ -720,11 +737,11 @@ public class ShoppingCartServices { cart.setOrderName(quote.getString("quoteName")); cart.setChannelType(quote.getString("salesChannelEnumId")); - List<GenericValue>quoteItems = null; - List<GenericValue>quoteAdjs = null; - List<GenericValue>quoteRoles = null; - List<GenericValue>quoteAttributes = null; - List<GenericValue>quoteTerms = null; + List<GenericValue> quoteItems = null; + List<GenericValue> quoteAdjs = null; + List<GenericValue> quoteRoles = null; + List<GenericValue> quoteAttributes = null; + List<GenericValue> quoteTerms = null; try { quoteItems = quote.getRelated("QuoteItem", null, UtilMisc.toList("quoteItemSeqId"), false); quoteAdjs = quote.getRelated("QuoteAdjustment", null, null, false); @@ -770,7 +787,8 @@ public class ShoppingCartServices { termDays = Long.parseLong(quoteTerm.getString("termDays").trim()); } String orderItemSeqId = quoteTerm.getString("quoteItemSeqId"); - cart.addOrderTerm(quoteTerm.getString("termTypeId"), orderItemSeqId, termValue, termDays, quoteTerm.getString("textValue"), quoteTerm.getString("description")); + cart.addOrderTerm(quoteTerm.getString("termTypeId"), orderItemSeqId, termValue, termDays, quoteTerm.getString("textValue"), + quoteTerm.getString("description")); } } @@ -785,10 +803,12 @@ public class ShoppingCartServices { // put them in a map: the key/values pairs are quoteItemSeqId/List of adjs Map<String, List<GenericValue>> orderAdjsMap = new HashMap<>(); for (GenericValue quoteAdj : quoteAdjs) { - List<GenericValue> orderAdjs = orderAdjsMap.get(UtilValidate.isNotEmpty(quoteAdj.getString("quoteItemSeqId")) ? quoteAdj.getString("quoteItemSeqId") : quoteId); + List<GenericValue> orderAdjs = orderAdjsMap.get(UtilValidate.isNotEmpty(quoteAdj.getString("quoteItemSeqId")) ? quoteAdj.getString( + "quoteItemSeqId") : quoteId); if (orderAdjs == null) { orderAdjs = new LinkedList<>(); - orderAdjsMap.put(UtilValidate.isNotEmpty(quoteAdj.getString("quoteItemSeqId")) ? quoteAdj.getString("quoteItemSeqId") : quoteId, orderAdjs); + orderAdjsMap.put(UtilValidate.isNotEmpty(quoteAdj.getString("quoteItemSeqId")) ? quoteAdj.getString("quoteItemSeqId") : quoteId, + orderAdjs); } // convert quote adjustments to order adjustments GenericValue orderAdj = delegator.makeValue("OrderAdjustment"); @@ -882,10 +902,13 @@ public class ShoppingCartServices { String productId = quoteItem.getString("productId"); ProductConfigWrapper configWrapper = null; if (UtilValidate.isNotEmpty(quoteItem.getString("configId"))) { - configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, quoteItem.getString("configId"), productId, productStoreId, null, null, currency, locale, userLogin); + configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, quoteItem.getString("configId"), + productId, productStoreId, null, null, currency, locale, userLogin); } try { - itemIndex = cart.addItemToEnd(productId, amount, quantity, quoteUnitPrice, reservStart, reservLength, reservPersons, null, null, null, null, null, configWrapper, null, dispatcher, !applyQuoteAdjustments, quoteUnitPrice.compareTo(BigDecimal.ZERO) == 0, Boolean.FALSE, Boolean.FALSE); + itemIndex = cart.addItemToEnd(productId, amount, quantity, quoteUnitPrice, reservStart, reservLength, reservPersons, null, + null, null, null, null, configWrapper, null, dispatcher, !applyQuoteAdjustments, + quoteUnitPrice.compareTo(BigDecimal.ZERO) == 0, Boolean.FALSE, Boolean.FALSE); } catch (ItemNotFoundException | CartItemModifyException e) { Debug.logError(e, MODULE); @@ -922,7 +945,7 @@ public class ShoppingCartServices { if (adjs != null) { for (GenericValue adj : adjs) { if (isTaxAdjustment(adj)) { - shipInfo.shipTaxAdj.add(adj); + shipInfo.addShipTaxAdj(adj); } else { cartAdjs.add(adj); } @@ -976,12 +999,13 @@ public class ShoppingCartServices { String adjType = cartAdj.getString("orderAdjustmentTypeId"); return "SALES_TAX".equals(adjType) || "VAT_TAX".equals(adjType) || "VAT_PRICE_CORRECT".equals(adjType); } + private static boolean isPromoAdjustment(GenericValue cartAdj) { String adjType = cartAdj.getString("orderAdjustmentTypeId"); return "PROMOTION_ADJUSTMENT".equals(adjType); } - public static Map<String, Object>loadCartFromShoppingList(DispatchContext dctx, Map<String, Object> context) { + public static Map<String, Object> loadCartFromShoppingList(DispatchContext dctx, Map<String, Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); @@ -1016,7 +1040,7 @@ public class ShoppingCartServices { } // If we still have no currency, use the default from general.properties. Failing that, use USD if (currency == null) { - currency = EntityUtilProperties.getPropertyValue("general", "currency.uom.id.default", "USD", delegator); + currency = EntityUtilProperties.getPropertyValue("general", "currency.uom.id.default", "USD", delegator); } // create the cart @@ -1036,7 +1060,7 @@ public class ShoppingCartServices { cart.setOrderPartyId(shoppingList.getString("partyId")); } - List<GenericValue>shoppingListItems = null; + List<GenericValue> shoppingListItems = null; try { shoppingListItems = shoppingList.getRelated("ShoppingListItem", null, null, false); } catch (GenericEntityException e) { @@ -1072,10 +1096,12 @@ public class ShoppingCartServices { String productId = shoppingListItem.getString("productId"); ProductConfigWrapper configWrapper = null; if (UtilValidate.isNotEmpty(shoppingListItem.getString("configId"))) { - configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, shoppingListItem.getString("configId"), productId, productStoreId, null, null, currency, locale, userLogin); + configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, shoppingListItem.getString("configId"), + productId, productStoreId, null, null, currency, locale, userLogin); } try { - itemIndex = cart.addItemToEnd(productId, null, quantity, null, null, null, null, null, configWrapper, dispatcher, Boolean.TRUE, Boolean.TRUE); + itemIndex = cart.addItemToEnd(productId, null, quantity, null, null, null, null, null, configWrapper, dispatcher, + Boolean.TRUE, Boolean.TRUE); } catch (ItemNotFoundException | CartItemModifyException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(e.getMessage()); @@ -1115,7 +1141,7 @@ public class ShoppingCartServices { return result; } - public static Map<String, Object>getShoppingCartData(DispatchContext dctx, Map<String, Object> context) { + public static Map<String, Object> getShoppingCartData(DispatchContext dctx, Map<String, Object> context) { Map<String, Object> result = ServiceUtil.returnSuccess(); Locale locale = (Locale) context.get("locale"); ShoppingCart shoppingCart = (ShoppingCart) context.get("shoppingCart"); @@ -1124,30 +1150,40 @@ public class ShoppingCartServices { result.put("totalQuantity", shoppingCart.getTotalQuantity()); result.put("currencyIsoCode", isoCode); result.put("subTotal", shoppingCart.getSubTotal()); - result.put("subTotalCurrencyFormatted", org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getSubTotal(), isoCode, locale)); + result.put("subTotalCurrencyFormatted", org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getSubTotal(), isoCode, + locale)); result.put("totalShipping", shoppingCart.getTotalShipping()); - result.put("totalShippingCurrencyFormatted", org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getTotalShipping(), isoCode, locale)); + result.put("totalShippingCurrencyFormatted", org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getTotalShipping(), + isoCode, locale)); result.put("totalSalesTax", shoppingCart.getTotalSalesTax()); - result.put("totalSalesTaxCurrencyFormatted", org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getTotalSalesTax(), isoCode, locale)); + result.put("totalSalesTaxCurrencyFormatted", org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getTotalSalesTax(), + isoCode, locale)); result.put("displayGrandTotal", shoppingCart.getDisplayGrandTotal()); - result.put("displayGrandTotalCurrencyFormatted", org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getDisplayGrandTotal(), isoCode, locale)); - BigDecimal orderAdjustmentsTotal = OrderReadHelper.calcOrderAdjustments(OrderReadHelper.getOrderHeaderAdjustments(shoppingCart.getAdjustments(), null), shoppingCart.getSubTotal(), true, true, true); - result.put("displayOrderAdjustmentsTotalCurrencyFormatted", org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(orderAdjustmentsTotal, isoCode, locale)); + result.put("displayGrandTotalCurrencyFormatted", + org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getDisplayGrandTotal(), isoCode, locale)); + BigDecimal orderAdjustmentsTotal = + OrderReadHelper.calcOrderAdjustments(OrderReadHelper.getOrderHeaderAdjustments(shoppingCart.getAdjustments(), null), + shoppingCart.getSubTotal(), true, true, true); + result.put("displayOrderAdjustmentsTotalCurrencyFormatted", + org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(orderAdjustmentsTotal, isoCode, locale)); Map<String, Object> cartItemData = new HashMap<>(); for (ShoppingCartItem cartLine : shoppingCart) { int cartLineIndex = shoppingCart.getItemIndex(cartLine); cartItemData.put("displayItemQty_" + cartLineIndex, cartLine.getQuantity()); - cartItemData.put("displayItemPrice_" + cartLineIndex, org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(cartLine.getDisplayPrice(), isoCode, locale)); + cartItemData.put("displayItemPrice_" + cartLineIndex, + org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(cartLine.getDisplayPrice(), isoCode, locale)); cartItemData.put("displayItemSubTotal_" + cartLineIndex, cartLine.getDisplayItemSubTotal()); - cartItemData.put("displayItemSubTotalCurrencyFormatted_" + cartLineIndex, org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(cartLine.getDisplayItemSubTotal(), isoCode, locale)); - cartItemData.put("displayItemAdjustment_" + cartLineIndex, org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(cartLine.getOtherAdjustments(), isoCode, locale)); + cartItemData.put("displayItemSubTotalCurrencyFormatted_" + cartLineIndex, + org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(cartLine.getDisplayItemSubTotal(), isoCode, locale)); + cartItemData.put("displayItemAdjustment_" + cartLineIndex, + org.apache.ofbiz.base.util.UtilFormatOut.formatCurrency(cartLine.getOtherAdjustments(), isoCode, locale)); } result.put("cartItemData", cartItemData); } return result; } - public static Map<String, Object>getShoppingCartItemIndex(DispatchContext dctx, Map<String, Object> context) { + public static Map<String, Object> getShoppingCartItemIndex(DispatchContext dctx, Map<String, Object> context) { Map<String, Object> result = ServiceUtil.returnSuccess(); ShoppingCart shoppingCart = (ShoppingCart) context.get("shoppingCart"); String productId = (String) context.get("productId"); @@ -1162,7 +1198,7 @@ public class ShoppingCartServices { return result; } - public static Map<String, Object>resetShipGroupItems(DispatchContext dctx, Map<String, Object> context) { + public static Map<String, Object> resetShipGroupItems(DispatchContext dctx, Map<String, Object> context) { Map<String, Object> result = ServiceUtil.returnSuccess(); ShoppingCart cart = (ShoppingCart) context.get("shoppingCart"); for (ShoppingCartItem item : cart) { @@ -1172,7 +1208,7 @@ public class ShoppingCartServices { return result; } - public static Map<String, Object>prepareVendorShipGroups(DispatchContext dctx, Map<String, Object> context) { + public static Map<String, Object> prepareVendorShipGroups(DispatchContext dctx, Map<String, Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); ShoppingCart cart = (ShoppingCart) context.get("shoppingCart"); @@ -1195,7 +1231,8 @@ public class ShoppingCartServices { } int index = 0; try { - vendorProduct = EntityQuery.use(delegator).from("VendorProduct").where("productId", productId, "productStoreGroupId", "_NA_").queryFirst(); + vendorProduct = EntityQuery.use(delegator).from("VendorProduct").where("productId", productId, "productStoreGroupId", "_NA_") + .queryFirst(); } catch (GenericEntityException e) { Debug.logError(e.toString(), MODULE); } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/WebShoppingCart.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/WebShoppingCart.java index b640217..f22c36e 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/WebShoppingCart.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/WebShoppingCart.java @@ -39,19 +39,19 @@ import org.apache.ofbiz.webapp.website.WebSiteWorker; @SuppressWarnings("serial") public class WebShoppingCart extends ShoppingCart { public WebShoppingCart(HttpServletRequest request, Locale locale, String currencyUom) { - // for purchase orders, bill to customer partyId must be set - otherwise, no way to know who we're purchasing for. supplierPartyId is furnished - // by order manager for PO entry. + // for purchase orders, bill to customer partyId must be set - otherwise, no way to know who we're purchasing for. + // supplierPartyId is furnished by order manager for PO entry. // TODO: refactor constructor and the getCartObject method which calls them to multiple constructors for different types of orders super((Delegator) request.getAttribute("delegator"), ProductStoreWorker.getProductStoreId(request), - WebSiteWorker.getWebSiteId(request), (locale != null ? locale : ProductStoreWorker.getStoreLocale(request)), - (currencyUom != null ? currencyUom : ProductStoreWorker.getStoreCurrencyUomId(request)), - request.getParameter("billToCustomerPartyId"), - (request.getParameter("supplierPartyId") != null ? request.getParameter("supplierPartyId") : request.getParameter("billFromVendorPartyId"))); + WebSiteWorker.getWebSiteId(request), (locale != null ? locale : ProductStoreWorker.getStoreLocale(request)), (currencyUom != null + ? currencyUom : ProductStoreWorker.getStoreCurrencyUomId(request)), request.getParameter("billToCustomerPartyId"), ( + request.getParameter("supplierPartyId") != null ? request.getParameter("supplierPartyId") + : request.getParameter("billFromVendorPartyId"))); HttpSession session = request.getSession(true); - this.userLogin = (GenericValue) session.getAttribute("userLogin"); - this.autoUserLogin = (GenericValue) session.getAttribute("autoUserLogin"); - this.orderPartyId = (String) session.getAttribute("orderPartyId"); + this.setUserLogin((GenericValue) session.getAttribute("userLogin")); + this.setAutoUserLogin((GenericValue) session.getAttribute("autoUserLogin")); + this.setOrderPartyId((String) session.getAttribute("orderPartyId")); } public WebShoppingCart(HttpServletRequest request) { diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java index cd59c13..e342199 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java @@ -23,7 +23,6 @@ import java.math.MathContext; import java.math.RoundingMode; import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -120,8 +119,8 @@ public final class ProductPromoWorker { "manualOnly"))) { // manual only promotions are not automatically evaluated (they must be explicitly selected by the user) if (Debug.verboseOn()) { - Debug.logVerbose("Skipping promotion with id [" + productStorePromoAppl.getString("productPromoId") + "] because it is " + - "applied to the store with ID " + productStoreId + " as a manual only promotion.", MODULE); + Debug.logVerbose("Skipping promotion with id [" + productStorePromoAppl.getString("productPromoId") + "] because it is " + + "applied to the store with ID " + productStoreId + " as a manual only promotion.", MODULE); } continue; } @@ -141,13 +140,17 @@ public final class ProductPromoWorker { GenericValue productPromoCond = productPromoConds.next(); // evaluate the party related conditions; so we don't show the promo if it doesn't apply. - if ("PPIP_PARTY_ID".equals(productPromoCond.getString("inputParamEnumId")) || "PPC_PARTY_ID".equals(productPromoCond.getString("customMethodId"))) { + if ("PPIP_PARTY_ID".equals(productPromoCond.getString("inputParamEnumId")) + || "PPC_PARTY_ID".equals(productPromoCond.getString("customMethodId"))) { condResult = checkCondition(productPromoCond, cart, delegator, dispatcher, nowTimestamp); - } else if ("PPIP_PARTY_GRP_MEM".equals(productPromoCond.getString("inputParamEnumId")) || "PPC_PARTY_GRP_MEM".equals(productPromoCond.getString("customMethodId"))) { + } else if ("PPIP_PARTY_GRP_MEM".equals(productPromoCond.getString("inputParamEnumId")) + || "PPC_PARTY_GRP_MEM".equals(productPromoCond.getString("customMethodId"))) { condResult = checkCondition(productPromoCond, cart, delegator, dispatcher, nowTimestamp); - } else if ("PPIP_PARTY_CLASS".equals(productPromoCond.getString("inputParamEnumId")) || "PPC_PARTY_CLASS".equals(productPromoCond.getString("customMethodId"))) { + } else if ("PPIP_PARTY_CLASS".equals(productPromoCond.getString("inputParamEnumId")) + || "PPC_PARTY_CLASS".equals(productPromoCond.getString("customMethodId"))) { condResult = checkCondition(productPromoCond, cart, delegator, dispatcher, nowTimestamp); - } else if ("PPIP_ROLE_TYPE".equals(productPromoCond.getString("inputParamEnumId")) || "PPC_ROLE_TYPE".equals(productPromoCond.getString("customMethodId"))) { + } else if ("PPIP_ROLE_TYPE".equals(productPromoCond.getString("inputParamEnumId")) + || "PPC_ROLE_TYPE".equals(productPromoCond.getString("customMethodId"))) { condResult = checkCondition(productPromoCond, cart, delegator, dispatcher, nowTimestamp); } } @@ -191,8 +194,8 @@ public final class ProductPromoWorker { "manualOnly"))) { // manual only promotions are not automatically evaluated (they must be explicitly selected by the user) if (Debug.verboseOn()) { - Debug.logVerbose("Skipping promotion with id [" + productStorePromoAppl.getString("productPromoId") + "] because it is " + - "applied to the store with ID " + productStoreId + " as a manual only promotion.", MODULE); + Debug.logVerbose("Skipping promotion with id [" + productStorePromoAppl.getString("productPromoId") + "] because it is " + + "applied to the store with ID " + productStoreId + " as a manual only promotion.", MODULE); } continue; } @@ -243,8 +246,8 @@ public final class ProductPromoWorker { if ("Y".equals(prodCatalogPromoAppl.getString("manualOnly"))) { // manual only promotions are not automatically evaluated (they must be explicitly selected by the user) if (Debug.verboseOn()) { - Debug.logVerbose("Skipping promotion with id [" + prodCatalogPromoAppl.getString("productPromoId") + "] because it is " + - "applied to the store with ID " + productStoreId + " as a manual only promotion.", MODULE); + Debug.logVerbose("Skipping promotion with id [" + prodCatalogPromoAppl.getString("productPromoId") + "] because it is " + + "applied to the store with ID " + productStoreId + " as a manual only promotion.", MODULE); } continue; } @@ -447,8 +450,8 @@ public final class ProductPromoWorker { cartChanged = false; numberOfIterations++; if (numberOfIterations > maxIterations) { - Debug.logError("ERROR: While calculating promotions the promotion rules where run more than " + maxIterations + " times, so the" + - " calculation has been ended. This should generally never happen unless you have bad rule definitions.", MODULE); + Debug.logError("ERROR: While calculating promotions the promotion rules where run more than " + maxIterations + " times, so the" + + " calculation has been ended. This should generally never happen unless you have bad rule definitions.", MODULE); break; } @@ -461,7 +464,8 @@ public final class ProductPromoWorker { Long candidateUseLimit = getProductPromoUseLimit(productPromo, partyId, delegator); Long useLimit = candidateUseLimit; if (Debug.verboseOn()) { - Debug.logVerbose("Running promotion [" + productPromoId + "], useLimit=" + useLimit + ", # of rules=" + productPromoRules.size(), MODULE); + Debug.logVerbose("Running promotion [" + productPromoId + "], useLimit=" + useLimit + ", # of rules=" + + productPromoRules.size(), MODULE); } boolean requireCode = "Y".equals(productPromo.getString("requireCode")); @@ -482,17 +486,18 @@ public final class ProductPromoWorker { // get all promo codes entered, do a query with an IN condition to see if any of those are related EntityCondition codeCondition = EntityCondition.makeCondition(EntityCondition.makeCondition("productPromoId", EntityOperator.EQUALS, productPromoId), EntityOperator.AND, EntityCondition.makeCondition( - "productPromoCodeId", + "productPromoCodeId", EntityOperator.IN, enteredCodes)); // may want to sort by something else to decide which code to use if there is more than one candidate - List<GenericValue> productPromoCodeList = - EntityQuery.use(delegator).from("ProductPromoCode").where(codeCondition).orderBy("productPromoCodeId").queryList(); + List<GenericValue> productPromoCodeList = EntityQuery.use(delegator).from("ProductPromoCode").where(codeCondition) + .orderBy("productPromoCodeId").queryList(); Iterator<GenericValue> productPromoCodeIter = productPromoCodeList.iterator(); // support multiple promo codes for a single promo, ie if we run into a use limit for one code see if we can find // another for this promo // check the use limit before each pass so if the promo use limit has been hit we don't keep on trying for the // promo code use limit, if there is one of course - while ((useLimit == null || useLimit > cart.getProductPromoUseCount(productPromoId)) && productPromoCodeIter.hasNext()) { + while ((useLimit == null || useLimit > cart.getProductPromoUseCount(productPromoId)) + && productPromoCodeIter.hasNext()) { GenericValue productPromoCode = productPromoCodeIter.next(); String productPromoCodeId = productPromoCode.getString("productPromoCodeId"); Long codeUseLimit = getProductPromoCodeUseLimit(productPromoCode, partyId, delegator); @@ -502,10 +507,10 @@ public final class ProductPromoWorker { } if (cart.getProductPromoUseCount(productPromoId) > maxUseLimit) { - Debug.logError("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.", MODULE); + Debug.logError("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.", MODULE); break; } } @@ -707,7 +712,8 @@ public final class ProductPromoWorker { } } - public static String makeAutoDescription(GenericValue productPromo, Delegator delegator, Locale locale, LocalDispatcher dispatcher) throws GenericEntityException { + public static String makeAutoDescription(GenericValue productPromo, Delegator delegator, Locale locale, LocalDispatcher dispatcher) + throws GenericEntityException { if (productPromo == null) { return ""; } @@ -742,7 +748,8 @@ public final class ProductPromoWorker { Map<String, Object> messageContext = UtilMisc.<String, Object>toMap("condValue", condValue, "equalityOperator", equalityOperator, "quantityOperator", quantityOperator); - if ("PPIP_PARTY_CLASS".equalsIgnoreCase(productPromoCond.getString("inputParamEnumId")) || "PPC_PARTY_CLASS".equalsIgnoreCase(productPromoCond.getString("customMethodId"))) { + if ("PPIP_PARTY_CLASS".equalsIgnoreCase(productPromoCond.getString("inputParamEnumId")) + || "PPC_PARTY_CLASS".equalsIgnoreCase(productPromoCond.getString("customMethodId"))) { GenericValue partyClassificationGroup = EntityQuery.use(delegator).from("PartyClassificationGroup").where( "partyClassificationGroupId", condValue).cache(true).queryOne(); if (partyClassificationGroup != null && UtilValidate.isNotEmpty(partyClassificationGroup.getString("description"))) { @@ -864,18 +871,17 @@ public final class ProductPromoWorker { if (UtilValidate.isNotEmpty(partyClassificationsExcluded)) { Map<String, Object> messageContext = UtilMisc.<String, Object>toMap("partyClassificationsExcluded", partyClassificationsExcluded); - String msgProp = UtilProperties.getMessage("ProductPromoUiLabels", "ProductPromoCondition.PPIP_PARTY_CLASS.NOT_APPLIED", messageContext - , locale); + String msgProp = UtilProperties.getMessage("ProductPromoUiLabels", "ProductPromoCondition.PPIP_PARTY_CLASS.NOT_APPLIED", messageContext, + locale); promoDescBuf.append("\n" + msgProp); } return promoDescBuf.toString(); } - private 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 { + private 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"); @@ -959,10 +965,9 @@ public final class ProductPromoWorker { } 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."); + 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."); } } @@ -981,8 +986,8 @@ public final class ProductPromoWorker { return usageInfoMap; } - private static Map<ShoppingCartItem, BigDecimal> prepareDeltaProductUsageInfoMap(Map<ShoppingCartItem, BigDecimal> oldMap, Map<ShoppingCartItem - , BigDecimal> newMap) { + private static Map<ShoppingCartItem, BigDecimal> prepareDeltaProductUsageInfoMap(Map<ShoppingCartItem, BigDecimal> oldMap, + Map<ShoppingCartItem, BigDecimal> newMap) { Map<ShoppingCartItem, BigDecimal> deltaUsageInfoMap = new HashMap<>(newMap); for (Entry<ShoppingCartItem, BigDecimal> entry : oldMap.entrySet()) { @@ -1048,7 +1053,8 @@ public final class ProductPromoWorker { try { condResult = dispatcher.runSync(serviceName, serviceCtx); } catch (GenericServiceException e) { - Debug.logWarning("Failed to execute productPromoCond service " + serviceName + " for promo " + productPromoCond.getPkShortValueString() + " throw " + e.toString(), MODULE); + Debug.logWarning("Failed to execute productPromoCond service " + serviceName + " for promo " + productPromoCond.getPkShortValueString() + + " throw " + e.toString(), MODULE); return false; } compareBase = (Integer) condResult.get("compareBase"); @@ -1084,7 +1090,7 @@ public final class ProductPromoWorker { } public static boolean checkConditionsForItem(GenericValue productPromoActionOrCond, ShoppingCart cart, ShoppingCartItem cartItem, - Delegator delegator, LocalDispatcher dispatcher, Timestamp nowTimestamp) throws GenericEntityException { + Delegator delegator, LocalDispatcher dispatcher, Timestamp nowTimestamp) throws GenericEntityException { GenericValue productPromoRule = productPromoActionOrCond.getRelatedOne("ProductPromoRule", true); List<GenericValue> productPromoConds = EntityQuery.use(delegator).from("ProductPromoCond").where("productPromoId", productPromoRule.get( @@ -1151,7 +1157,8 @@ public final class ProductPromoWorker { return res; } - public static int checkConditionPartyHierarchy(Delegator delegator, Timestamp nowTimestamp, String groupPartyId, String partyId) throws GenericEntityException { + public static int checkConditionPartyHierarchy(Delegator delegator, Timestamp nowTimestamp, String groupPartyId, String partyId) + throws GenericEntityException { List<GenericValue> partyRelationshipList = EntityQuery.use(delegator).from("PartyRelationship").where("partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP").cache(true).filterByDate(nowTimestamp).queryList(); for (GenericValue genericValue : partyRelationshipList) { @@ -1379,7 +1386,8 @@ public final class ProductPromoWorker { return null; } - public static Set<String> getPromoRuleCondProductIds(GenericValue productPromoCond, Delegator delegator, Timestamp nowTimestamp) throws GenericEntityException { + public static Set<String> getPromoRuleCondProductIds(GenericValue productPromoCond, Delegator delegator, Timestamp nowTimestamp) + throws GenericEntityException { // get a cached list for the whole promo and filter it as needed, this for better efficiency in caching List<GenericValue> productPromoCategoriesAll = EntityQuery.use(delegator).from("ProductPromoCategory").where("productPromoId", productPromoCond.get("productPromoId")).cache(true).queryList(); @@ -1399,7 +1407,8 @@ public final class ProductPromoWorker { return productIds; } - public static Set<String> getPromoRuleActionProductIds(GenericValue productPromoAction, Delegator delegator, Timestamp nowTimestamp) throws GenericEntityException { + public static Set<String> getPromoRuleActionProductIds(GenericValue productPromoAction, Delegator delegator, Timestamp nowTimestamp) + throws GenericEntityException { // get a cached list for the whole promo and filter it as needed, this for better efficiency in caching List<GenericValue> productPromoCategoriesAll = EntityQuery.use(delegator).from("ProductPromoCategory").where("productPromoId", productPromoAction.get("productPromoId")).cache(true).queryList(); @@ -1442,7 +1451,8 @@ public final class ProductPromoWorker { } public static void makeProductPromoCondActionIdSets(String productPromoId, Set<String> productIdsCond, Set<String> productIdsAction, - Delegator delegator, Timestamp nowTimestamp, boolean filterOldProducts) throws GenericEntityException { + Delegator delegator, Timestamp nowTimestamp, boolean filterOldProducts) + throws GenericEntityException { if (nowTimestamp == null) { nowTimestamp = UtilDateTime.nowTimestamp(); } @@ -1513,7 +1523,8 @@ public final class ProductPromoWorker { } private static void handleProductPromoCategories(Set<String> productIds, List<GenericValue> productPromoCategories, - String productPromoApplEnumId, Delegator delegator, Timestamp nowTimestamp) throws GenericEntityException { + String productPromoApplEnumId, Delegator delegator, Timestamp nowTimestamp) + throws GenericEntityException { boolean include = !"PPPA_EXCLUDE".equals(productPromoApplEnumId); Set<String> productCategoryIds = new HashSet<>(); Map<String, List<Set<String>>> productCategoryGroupSetListMap = new HashMap<>(); @@ -1607,7 +1618,8 @@ public final class ProductPromoWorker { } } - private static void handleProductPromoProducts(Set<String> productIds, List<GenericValue> productPromoProducts, String productPromoApplEnumId) throws GenericEntityException { + private static void handleProductPromoProducts(Set<String> productIds, List<GenericValue> productPromoProducts, String productPromoApplEnumId) + throws GenericEntityException { boolean include = !"PPPA_EXCLUDE".equals(productPromoApplEnumId); for (GenericValue productPromoProduct : productPromoProducts) { if (productPromoApplEnumId.equals(productPromoProduct.getString("productPromoApplEnumId"))) { diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/shipping/ShippingEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/shipping/ShippingEvents.java index 160d949..7d50d24 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/shipping/ShippingEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/shipping/ShippingEvents.java @@ -61,7 +61,8 @@ import org.apache.ofbiz.service.ServiceUtil; public class ShippingEvents { private static final String MODULE = ShippingEvents.class.getName(); - private static final List<String> fieldNameGeoIds = UtilMisc.toList("countryGeoId", "countyGeoId", "stateProvinceGeoId", "municipalityGeoId", "postalCodeGeoId"); + private static final List<String> FIELD_NAME_GEO_IDS = UtilMisc.toList("countryGeoId", "countyGeoId", "stateProvinceGeoId", "municipalityGeoId", + "postalCodeGeoId"); public static String getShipEstimate(HttpServletRequest request, HttpServletResponse response) { ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("shoppingCart"); @@ -105,8 +106,10 @@ public class ShippingEvents { String productStoreShipMethId = cart.getProductStoreShipMethId(groupNo); return getShipGroupEstimate(dispatcher, delegator, cart.getOrderType(), shipmentMethodTypeId, carrierPartyId, null, - cart.getShippingContactMechId(groupNo), cart.getProductStoreId(), cart.getSupplierPartyId(groupNo), cart.getShippableItemInfo(groupNo), - cart.getShippableWeight(groupNo), cart.getShippableQuantity(groupNo), cart.getShippableTotal(groupNo), cart.getPartyId(), productStoreShipMethId); + cart.getShippingContactMechId(groupNo), cart.getProductStoreId(), cart.getSupplierPartyId(groupNo), + cart.getShippableItemInfo(groupNo), + cart.getShippableWeight(groupNo), cart.getShippableQuantity(groupNo), cart.getShippableTotal(groupNo), cart.getPartyId(), + productStoreShipMethId); } public static Map<String, Object> getShipEstimate(LocalDispatcher dispatcher, Delegator delegator, OrderReadHelper orh, String shipGroupSeqId) { @@ -132,27 +135,32 @@ public class ShippingEvents { String partyId = null; GenericValue partyObject = orh.getPlacingParty(); if (partyObject != null) { - partyId = partyObject.getString("partyId"); + partyId = partyObject.getString("partyId"); } return getShipGroupEstimate(dispatcher, delegator, orh.getOrderTypeId(), shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId, - contactMechId, orh.getProductStoreId(), supplierPartyId, orh.getShippableItemInfo(shipGroupSeqId), orh.getShippableWeight(shipGroupSeqId), + contactMechId, orh.getProductStoreId(), supplierPartyId, orh.getShippableItemInfo(shipGroupSeqId), + orh.getShippableWeight(shipGroupSeqId), orh.getShippableQuantity(shipGroupSeqId), orh.getShippableTotal(shipGroupSeqId), partyId, null); } // version with no support for using the supplier's address as the origin public static Map<String, Object> getShipGroupEstimate(LocalDispatcher dispatcher, Delegator delegator, String orderTypeId, - String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String shippingContactMechId, - String productStoreId, List<Map<String, Object>> itemInfo, BigDecimal shippableWeight, BigDecimal shippableQuantity, - BigDecimal shippableTotal, String partyId, String productStoreShipMethId) { + String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, + String shippingContactMechId, + String productStoreId, List<Map<String, Object>> itemInfo, BigDecimal shippableWeight, + BigDecimal shippableQuantity, + BigDecimal shippableTotal, String partyId, String productStoreShipMethId) { return getShipGroupEstimate(dispatcher, delegator, orderTypeId, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId, shippingContactMechId, productStoreId, null, itemInfo, shippableWeight, shippableQuantity, shippableTotal, partyId, productStoreShipMethId); } public static Map<String, Object> getShipGroupEstimate(LocalDispatcher dispatcher, Delegator delegator, String orderTypeId, - String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String shippingContactMechId, - String productStoreId, String supplierPartyId, List<Map<String, Object>> itemInfo, BigDecimal shippableWeight, BigDecimal shippableQuantity, - BigDecimal shippableTotal, String partyId, String productStoreShipMethId) { + String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, + String shippingContactMechId, + String productStoreId, String supplierPartyId, List<Map<String, Object>> itemInfo, + BigDecimal shippableWeight, BigDecimal shippableQuantity, + BigDecimal shippableTotal, String partyId, String productStoreShipMethId) { return getShipGroupEstimate(dispatcher, delegator, orderTypeId, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId, shippingContactMechId, productStoreId, supplierPartyId, itemInfo, shippableWeight, shippableQuantity, @@ -160,9 +168,12 @@ public class ShippingEvents { } public static Map<String, Object> getShipGroupEstimate(LocalDispatcher dispatcher, Delegator delegator, String orderTypeId, - String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String shippingContactMechId, - String productStoreId, String supplierPartyId, List<Map<String, Object>> itemInfo, BigDecimal shippableWeight, BigDecimal shippableQuantity, - BigDecimal shippableTotal, String partyId, String productStoreShipMethId, BigDecimal totalAllowance) { + String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, + String shippingContactMechId, + String productStoreId, String supplierPartyId, List<Map<String, Object>> itemInfo, + BigDecimal shippableWeight, BigDecimal shippableQuantity, + BigDecimal shippableTotal, String partyId, String productStoreShipMethId, + BigDecimal totalAllowance) { String standardMessage = "A problem occurred calculating shipping. Fees will be calculated offline."; List<String> errorMessageList = new LinkedList<>(); @@ -189,7 +200,8 @@ public class ShippingEvents { try { GenericValue originAddress = getShippingOriginContactMech(delegator, supplierPartyId); if (originAddress == null) { - return ServiceUtil.returnError("Cannot find the origin shipping address (SHIP_ORIG_LOCATION) for the supplier with ID ["+supplierPartyId+"]. Will not be able to calculate drop shipment estimate."); + return ServiceUtil.returnError("Cannot find the origin shipping address (SHIP_ORIG_LOCATION) for the supplier with ID [" + + supplierPartyId + "]. Will not be able to calculate drop shipment estimate."); } shippingOriginContactMechId = originAddress.getString("contactMechId"); } catch (GeneralException e) { @@ -260,17 +272,19 @@ public class ShippingEvents { // Calculate the allowance price(Already included in Product's default/list price) // using shippingAllowance percent and deduct it from Actual Shipping Cost. - if (BigDecimal.ZERO.compareTo(shippingTotal) < 0 && UtilValidate.isNotEmpty(totalAllowance) && BigDecimal.ZERO.compareTo(totalAllowance) < 0) { - BigDecimal shippingAllowancePercent = storeShipMethod.getBigDecimal("allowancePercent") != null ? storeShipMethod.getBigDecimal("allowancePercent") : BigDecimal.ZERO; + if (BigDecimal.ZERO.compareTo(shippingTotal) < 0 && UtilValidate.isNotEmpty(totalAllowance) + && BigDecimal.ZERO.compareTo(totalAllowance) < 0) { + BigDecimal shippingAllowancePercent = storeShipMethod.getBigDecimal("allowancePercent") != null ? storeShipMethod.getBigDecimal( + "allowancePercent") : BigDecimal.ZERO; totalAllowance = totalAllowance.multiply(shippingAllowancePercent.divide(BigDecimal.valueOf(100))); shippingTotal = shippingTotal.subtract(totalAllowance); } - // Check if minimum price is set for any Shipping Option, if yes, + // Check if minimum price is set for any Shipping Option, if yes, // compare it with total shipping and use greater of the two. BigDecimal minimumPrice = storeShipMethod.getBigDecimal("minimumPrice"); if (UtilValidate.isNotEmpty(minimumPrice) && shippingTotal.compareTo(minimumPrice) < 0) { - shippingTotal = minimumPrice; + shippingTotal = minimumPrice; } // return the totals @@ -279,7 +293,8 @@ public class ShippingEvents { return responseResult; } - public static BigDecimal getGenericShipEstimate(LocalDispatcher dispatcher, GenericValue storeShipMeth, Map<String, ? extends Object>context) throws GeneralException { + public static BigDecimal getGenericShipEstimate(LocalDispatcher dispatcher, GenericValue storeShipMeth, Map<String, ? extends Object> context) + throws GeneralException { // invoke the generic estimate service next -- append to estimate amount Map<String, Object> genericEstimate = null; BigDecimal genericShipAmt = null; @@ -299,6 +314,7 @@ public class ShippingEvents { } return genericShipAmt; } + public static String getShipmentCustomMethod(Delegator delegator, String shipmentCustomMethodId) { String serviceName = null; GenericValue customMethod = null; @@ -313,7 +329,8 @@ public class ShippingEvents { return serviceName; } - public static BigDecimal getExternalShipEstimate(LocalDispatcher dispatcher, GenericValue storeShipMeth, Map<String, Object> context) throws GeneralException { + public static BigDecimal getExternalShipEstimate(LocalDispatcher dispatcher, GenericValue storeShipMeth, Map<String, Object> context) + throws GeneralException { String shipmentCustomMethodId = storeShipMeth.getString("shipmentCustomMethodId"); Delegator delegator = dispatcher.getDelegator(); String serviceName = ""; @@ -330,8 +347,9 @@ public class ShippingEvents { //If all estimates are not turned off, check for the individual one if ("true".equals(doEstimates)) { String dothisEstimate = EntityUtilProperties.getPropertyValue("shipment", "shipment.doratecheck." + serviceName, "true", delegator); - if ("false".equals(dothisEstimate)) - serviceName = null; + if ("false".equals(dothisEstimate)) { + serviceName = null; + } } else { //Rate checks inhibited serviceName = null; @@ -349,8 +367,10 @@ public class ShippingEvents { // invoke the service Map<String, Object> serviceResp = null; try { - Debug.logInfo("Service : " + serviceName + " / shipmentGatewayConfigId : " + shipmentGatewayConfigId + " / configProps : " + configProps + " -- " + context, MODULE); - // because we don't want to blow up too big or rollback the transaction when this happens, always have it run in its own transaction... + Debug.logInfo("Service : " + serviceName + " / shipmentGatewayConfigId : " + shipmentGatewayConfigId + " / configProps : " + + configProps + " -- " + context, MODULE); + // because we don't want to blow up too big or rollback the transaction when this happens, always have it run in its own + // transaction... serviceResp = dispatcher.runSync(serviceName, context, 0, true); } catch (GenericServiceException e) { Debug.logError(e, "Shipment Service Error", MODULE); @@ -363,7 +383,8 @@ public class ShippingEvents { } else if (ServiceUtil.isFailure(serviceResp)) { String errMsg = "Failure getting external shipment cost estimate: " + ServiceUtil.getErrorMessage(serviceResp); Debug.logError(errMsg, MODULE); - // should not throw an Exception here, otherwise getShipGroupEstimate would return an error, causing all sorts of services like add or update order item to abort + // should not throw an Exception here, otherwise getShipGroupEstimate would return an error, causing all sorts of services like + // add or update order item to abort } else { externalShipAmt = (BigDecimal) serviceResp.get("shippingEstimateAmount"); } @@ -379,28 +400,31 @@ public class ShippingEvents { List<EntityCondition> conditions = UtilMisc.toList( EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, supplierPartyId), EntityCondition.makeCondition("contactMechTypeId", EntityOperator.EQUALS, "POSTAL_ADDRESS"), - EntityCondition.makeCondition("contactMechPurposeTypeId", EntityOperator.IN, UtilMisc.toList("SHIP_ORIG_LOCATION", "GENERAL_LOCATION")), + EntityCondition.makeCondition("contactMechPurposeTypeId", EntityOperator.IN, UtilMisc.toList("SHIP_ORIG_LOCATION", + "GENERAL_LOCATION")), EntityUtil.getFilterByDateExpr("contactFromDate", "contactThruDate"), EntityUtil.getFilterByDateExpr("purposeFromDate", "purposeThruDate")); EntityConditionList<EntityCondition> ecl = EntityCondition.makeCondition(conditions, EntityOperator.AND); - List<GenericValue> addresses = delegator.findList("PartyContactWithPurpose", ecl, null, UtilMisc.toList("contactMechPurposeTypeId DESC"), null, false); + List<GenericValue> addresses = delegator.findList("PartyContactWithPurpose", ecl, null, UtilMisc.toList("contactMechPurposeTypeId DESC"), + null, false); GenericValue generalAddress = null; GenericValue originAddress = null; for (GenericValue address : addresses) { - if ("GENERAL_LOCATION".equals(address.get("contactMechPurposeTypeId"))) + if ("GENERAL_LOCATION".equals(address.get("contactMechPurposeTypeId"))) { generalAddress = address; - else if ("SHIP_ORIG_LOCATION".equals(address.get("contactMechPurposeTypeId"))) + } else if ("SHIP_ORIG_LOCATION".equals(address.get("contactMechPurposeTypeId"))) { originAddress = address; + } } return originAddress != null ? originAddress : generalAddress; } public static GenericValue getShippingOriginContactMechFromFacility(Delegator delegator, String facilityId) throws GeneralException { - GenericValue address = ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, UtilMisc.toList("SHIP_ORIG_LOCATION")); - if (address != null) return address; - return ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, UtilMisc.toList("GENERAL_LOCATION")); + GenericValue address = ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, UtilMisc.toList("SHIP_ORIG_LOCATION")); + if (address != null) return address; + return ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, UtilMisc.toList("GENERAL_LOCATION")); } private static List<String> getGeoIdFromPostalContactMech(Delegator delegator, GenericValue address) { @@ -418,7 +442,7 @@ public class ShippingEvents { } if (addressGV != null) { GenericValue finalAddressGV = addressGV; - geoIds = fieldNameGeoIds.stream() + geoIds = FIELD_NAME_GEO_IDS.stream() .filter(key -> finalAddressGV.get(key) != null) .map(key -> finalAddressGV.getString(key)) .collect(Collectors.toList()); @@ -428,7 +452,8 @@ public class ShippingEvents { } public static List<GenericValue> getShipmentTimeEstimates(Delegator delegator, String shipmentMethodTypeId, - String partyId, String roleTypeId, GenericValue shippingAddress, GenericValue originAddress) { + String partyId, String roleTypeId, GenericValue shippingAddress, + GenericValue originAddress) { //Retrieve origin Geo List<String> geoIdFroms = getGeoIdFromPostalContactMech(delegator, originAddress); //Retrieve destination Geo @@ -438,7 +463,7 @@ public class ShippingEvents { public static List<GenericValue> getShipmentTimeEstimates(Delegator delegator, String shipmentMethodTypeId, - String partyId, String roleTypeId, List<String> geoIdFroms, List<String> geoIdTos) { + String partyId, String roleTypeId, List<String> geoIdFroms, List<String> geoIdTos) { List<GenericValue> shippingTimeEstimates = new LinkedList<>(); if ("NO_SHIPPING".equals(shipmentMethodTypeId)) { @@ -497,8 +522,9 @@ public class ShippingEvents { /** * Return the {@link GenericValue} ShipmentTimeEstimate matching the carrier shipment method + * * @param storeCarrierShipMethod ShipmentMethod used for estimation - * @param shippingTimeEstimates available configured estimation + * @param shippingTimeEstimates available configured estimation * @return */ public static GenericValue getShippingTimeEstimate(GenericValue storeCarrierShipMethod, List<GenericValue> shippingTimeEstimates) { @@ -516,15 +542,18 @@ public class ShippingEvents { /** * Return the number of days estimated for shipping + * * @param dispatcher * @param storeCarrierShipMethod ShipmentMethod used for estimation - * @param shippingTimeEstimates available configured estimation + * @param shippingTimeEstimates available configured estimation * @return */ - public static Double getShippingTimeEstimateInDay(LocalDispatcher dispatcher, GenericValue storeCarrierShipMethod, List<GenericValue> shippingTimeEstimates) { + public static Double getShippingTimeEstimateInDay(LocalDispatcher dispatcher, GenericValue storeCarrierShipMethod, + List<GenericValue> shippingTimeEstimates) { GenericValue shippingTimeEstimate = getShippingTimeEstimate(storeCarrierShipMethod, shippingTimeEstimates); if (shippingTimeEstimate == null) return null; - BigDecimal leadTimeConverted = UomWorker.convertUom(shippingTimeEstimate.getBigDecimal("leadTime"), shippingTimeEstimate.getString("leadTimeUomId"), "TF_day", dispatcher); + BigDecimal leadTimeConverted = UomWorker.convertUom(shippingTimeEstimate.getBigDecimal("leadTime"), + shippingTimeEstimate.getString("leadTimeUomId"), "TF_day", dispatcher); return leadTimeConverted != null ? leadTimeConverted.setScale(2, RoundingMode.UP).doubleValue() : null; } } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java index 7142f40..ea26c00 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListEvents.java @@ -63,9 +63,9 @@ import org.apache.ofbiz.webapp.website.WebSiteWorker; */ public class ShoppingListEvents { + private static final String PERSISTANT_LIST_NAME = "auto-save"; private static final String MODULE = ShoppingListEvents.class.getName(); private static final String RES_ERROR = "OrderErrorUiLabels"; - public static final String PERSISTANT_LIST_NAME = "auto-save"; public static String addBulkFromCart(HttpServletRequest request, HttpServletResponse response) { Delegator delegator = (Delegator) request.getAttribute("delegator"); @@ -81,7 +81,8 @@ public class ShoppingListEvents { } try { - shoppingListId = addBulkFromCart(delegator, dispatcher, cart, userLogin, shoppingListId, shoppingListTypeId, selectedCartItems, true, true); + shoppingListId = addBulkFromCart(delegator, dispatcher, cart, userLogin, shoppingListId, shoppingListTypeId, selectedCartItems, true, + true); } catch (IllegalArgumentException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; @@ -91,7 +92,9 @@ public class ShoppingListEvents { return "success"; } - public static String addBulkFromCart(Delegator delegator, LocalDispatcher dispatcher, ShoppingCart cart, GenericValue userLogin, String shoppingListId, String shoppingListTypeId, String[] items, boolean allowPromo, boolean append) throws IllegalArgumentException { + public static String addBulkFromCart(Delegator delegator, LocalDispatcher dispatcher, ShoppingCart cart, GenericValue userLogin, + String shoppingListId, String shoppingListTypeId, String[] items, boolean allowPromo, boolean append) + throws IllegalArgumentException { String errMsg = null; if (items == null || items.length == 0) { @@ -103,8 +106,8 @@ public class ShoppingListEvents { // create a new shopping list Map<String, Object> newListResult = null; try { - newListResult = dispatcher.runSync("createShoppingList", UtilMisc.<String, Object>toMap("userLogin", userLogin, - "productStoreId", cart.getProductStoreId(), "partyId", cart.getOrderPartyId(), + newListResult = dispatcher.runSync("createShoppingList", UtilMisc.<String, Object>toMap("userLogin", userLogin, + "productStoreId", cart.getProductStoreId(), "partyId", cart.getOrderPartyId(), "shoppingListTypeId", shoppingListTypeId, "currencyUom", cart.getCurrency()), 90, true); if (ServiceUtil.isError(newListResult)) { @@ -146,10 +149,13 @@ public class ShoppingListEvents { if (cartIdInt != null) { ShoppingCartItem item = cart.findCartItem(cartIdInt); if (allowPromo || !item.getIsPromo()) { - Debug.logInfo("Adding cart item to shopping list [" + shoppingListId + "], allowPromo=" + allowPromo + ", item.getIsPromo()=" + item.getIsPromo() + ", item.getProductId()=" + item.getProductId() + ", item.getQuantity()=" + item.getQuantity(), MODULE); + Debug.logInfo("Adding cart item to shopping list [" + shoppingListId + "], allowPromo=" + allowPromo + ", item.getIsPromo()=" + + item.getIsPromo() + ", item.getProductId()=" + item.getProductId() + ", item.getQuantity()=" + item.getQuantity(), + MODULE); Map<String, Object> serviceResult = null; try { - Map<String, Object> ctx = UtilMisc.<String, Object>toMap("userLogin", userLogin, "shoppingListId", shoppingListId, "productId", item.getProductId(), "quantity", item.getQuantity()); + Map<String, Object> ctx = UtilMisc.<String, Object>toMap("userLogin", userLogin, "shoppingListId", shoppingListId, + "productId", item.getProductId(), "quantity", item.getQuantity()); ctx.put("reservStart", item.getReservStart()); ctx.put("reservLength", item.getReservLength()); ctx.put("reservPersons", item.getReservPersons()); @@ -195,7 +201,9 @@ public class ShoppingListEvents { return "success"; } - public static String addListToCart(Delegator delegator, LocalDispatcher dispatcher, ShoppingCart cart, String prodCatalogId, String shoppingListId, boolean includeChild, boolean setAsListItem, boolean append) throws java.lang.IllegalArgumentException { + public static String addListToCart(Delegator delegator, LocalDispatcher dispatcher, ShoppingCart cart, String prodCatalogId, + String shoppingListId, boolean includeChild, boolean setAsListItem, boolean append) + throws java.lang.IllegalArgumentException { String errMsg = null; // no list; no add @@ -271,21 +279,27 @@ public class ShoppingListEvents { } // check if we have existing survey responses to append - if (shoppingListSurveyInfo.containsKey(listId + "." + itemId) && UtilValidate.isNotEmpty(shoppingListSurveyInfo.get(listId + "." + itemId))) { + if (shoppingListSurveyInfo.containsKey(listId + "." + itemId) && UtilValidate.isNotEmpty(shoppingListSurveyInfo.get(listId + "." + + itemId))) { attributes.put("surveyResponses", shoppingListSurveyInfo.get(listId + "." + itemId)); } ProductConfigWrapper configWrapper = null; if (UtilValidate.isNotEmpty(configId)) { - configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, productId, cart.getProductStoreId(), prodCatalogId, cart.getWebSiteId(), cart.getCurrency(), cart.getLocale(), cart.getAutoUserLogin()); + configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, productId, + cart.getProductStoreId(), prodCatalogId, cart.getWebSiteId(), cart.getCurrency(), cart.getLocale(), + cart.getAutoUserLogin()); } // TODO: add code to check for survey response requirement - // i cannot get the addOrDecrease function to accept a null reservStart field: i get a null pointer exception a null constant works.... + // i cannot get the addOrDecrease function to accept a null reservStart field: i get a null pointer exception a null constant works + // .... if (reservStart == null) { - cart.addOrIncreaseItem(productId, null, quantity, null, null, null, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher); + cart.addOrIncreaseItem(productId, null, quantity, null, null, null, null, null, null, attributes, prodCatalogId, configWrapper, + null, null, null, dispatcher); } else { - cart.addOrIncreaseItem(productId, null, quantity, reservStart, reservLength, reservPersons, null, null, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher); + cart.addOrIncreaseItem(productId, null, quantity, reservStart, reservLength, reservPersons, null, null, null, null, null, + attributes, prodCatalogId, configWrapper, null, null, null, dispatcher); } Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productId", productId); errMsg = UtilProperties.getMessage(RES_ERROR, "shoppinglistevents.added_product_to_cart", messageMap, cart.getLocale()); @@ -343,7 +357,7 @@ public class ShoppingListEvents { return "error"; } } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage(RES_ERROR, "shoppingListEvents.error_calling_update", locale) + ": " + e.toString(); + String errMsg = UtilProperties.getMessage(RES_ERROR, "shoppingListEvents.error_calling_update", locale) + ": " + e.toString(); request.setAttribute("_ERROR_MESSAGE_", errMsg); String errorMsg = "Error calling the updateShoppingListItem in handleShoppingListItemVariant: " + e.toString(); Debug.logError(e, errorMsg, MODULE); @@ -355,7 +369,8 @@ public class ShoppingListEvents { /** * Finds or creates a specialized (auto-save) shopping list used to record shopping bag contents between user visits. */ - public static String getAutoSaveListId(Delegator delegator, LocalDispatcher dispatcher, String partyId, GenericValue userLogin, String productStoreId) throws GenericEntityException, GenericServiceException { + public static String getAutoSaveListId(Delegator delegator, LocalDispatcher dispatcher, String partyId, GenericValue userLogin, + String productStoreId) throws GenericEntityException, GenericServiceException { if (partyId == null && userLogin != null) { partyId = userLogin.getString("partyId"); } @@ -364,7 +379,8 @@ public class ShoppingListEvents { GenericValue list = null; // TODO: add sorting, just in case there are multiple... if (partyId != null) { - Map<String, Object> findMap = UtilMisc.<String, Object>toMap("partyId", partyId, "productStoreId", productStoreId, "shoppingListTypeId", "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME); + Map<String, Object> findMap = UtilMisc.<String, Object>toMap("partyId", partyId, "productStoreId", productStoreId, "shoppingListTypeId", + "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME); List<GenericValue> existingLists = EntityQuery.use(delegator).from("ShoppingList").where(findMap).queryList(); Debug.logInfo("Finding existing auto-save shopping list with: \nfindMap: " + findMap + "\nlists: " + existingLists, MODULE); @@ -374,7 +390,8 @@ public class ShoppingListEvents { } } if (list == null && dispatcher != null) { - Map<String, Object> listFields = UtilMisc.<String, Object>toMap("userLogin", userLogin, "productStoreId", productStoreId, "shoppingListTypeId", "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME); + Map<String, Object> listFields = UtilMisc.<String, Object>toMap("userLogin", userLogin, "productStoreId", productStoreId, + "shoppingListTypeId", "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME); Map<String, Object> newListResult = dispatcher.runSync("createShoppingList", listFields, 90, true); if (ServiceUtil.isError(newListResult)) { String errorMessage = ServiceUtil.getErrorMessage(newListResult); @@ -619,7 +636,7 @@ public class ShoppingListEvents { /** * Create the guest cookies for a shopping list */ - public static String createGuestShoppingListCookies (HttpServletRequest request, HttpServletResponse response) { + public static String createGuestShoppingListCookies(HttpServletRequest request, HttpServletResponse response) { Delegator delegator = (Delegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); HttpSession session = request.getSession(true); @@ -642,7 +659,7 @@ public class ShoppingListEvents { // find shopping list ID if (cookies != null) { - for (Cookie cookie: cookies) { + for (Cookie cookie : cookies) { if (cookie.getName().equals(guestShoppingUserName)) { autoSaveListId = cookie.getValue(); break; @@ -651,10 +668,11 @@ public class ShoppingListEvents { } // clear the auto-save info - if (userLogin!= null && ProductStoreWorker.autoSaveCart(delegator, productStoreId)) { + if (userLogin != null && ProductStoreWorker.autoSaveCart(delegator, productStoreId)) { if (UtilValidate.isEmpty(autoSaveListId)) { try { - Map<String, Object> listFields = UtilMisc.<String, Object>toMap("userLogin", userLogin, "productStoreId", productStoreId, "shoppingListTypeId", "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME); + Map<String, Object> listFields = UtilMisc.<String, Object>toMap("userLogin", userLogin, "productStoreId", productStoreId, + "shoppingListTypeId", "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME); Map<String, Object> newListResult = dispatcher.runSync("createShoppingList", listFields, 90, true); if (ServiceUtil.isError(newListResult)) { String errorMessage = ServiceUtil.getErrorMessage(newListResult); @@ -689,7 +707,7 @@ public class ShoppingListEvents { /** * Clear the guest cookies for a shopping list */ - public static String clearGuestShoppingListCookies (HttpServletRequest request, HttpServletResponse response) { + public static String clearGuestShoppingListCookies(HttpServletRequest request, HttpServletResponse response) { Properties systemProps = System.getProperties(); String guestShoppingUserName = "GuestShoppingListId_" + systemProps.getProperty("user.name").replace(" ", "_"); Cookie guestShoppingListCookie = new Cookie(guestShoppingUserName, null); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java index fe553e7..f195f1a 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java @@ -214,7 +214,8 @@ public class ShoppingListServices { Debug.logError(e2, "[Delegator] Could not rollback transaction: " + e2.toString(), MODULE); } - String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderErrorWhileCreatingNewShoppingListBasedAutomaticReorder", UtilMisc.toMap("errorString", e.toString()), locale); + String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderErrorWhileCreatingNewShoppingListBasedAutomaticReorder", UtilMisc.toMap( + "errorString", e.toString()), locale); Debug.logError(e, errMsg, MODULE); return ServiceUtil.returnError(errMsg); } finally { @@ -271,7 +272,8 @@ public class ShoppingListServices { orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); if (orderHeader == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToLocateOrder", UtilMisc.toMap("orderId", orderId), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToLocateOrder", UtilMisc.toMap("orderId", orderId), + locale)); } String productStoreId = orderHeader.getString("productStoreId"); @@ -321,7 +323,8 @@ public class ShoppingListServices { orh = new OrderReadHelper(orderHeader); } catch (IllegalArgumentException e) { Debug.logError(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToLoadOrderReadHelper", UtilMisc.toMap("orderId", orderId), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToLoadOrderReadHelper", UtilMisc.toMap("orderId", + orderId), locale)); } List<GenericValue> orderItems = orh.getOrderItems(); @@ -330,7 +333,8 @@ public class ShoppingListServices { if (UtilValidate.isNotEmpty(productId)) { Map<String, Object> ctx = UtilMisc.<String, Object>toMap("userLogin", userLogin, "shoppingListId", shoppingListId, "productId", orderItem.get("productId"), "quantity", orderItem.get("quantity")); - if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", ProductWorker.getProductTypeId(delegator, productId), "parentTypeId", "AGGREGATED")) { + if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", ProductWorker.getProductTypeId(delegator, + productId), "parentTypeId", "AGGREGATED")) { try { GenericValue instanceProduct = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); String configId = instanceProduct.getString("configId"); @@ -349,7 +353,8 @@ public class ShoppingListServices { Debug.logError(e, MODULE); } if (serviceResult == null || ServiceUtil.isError(serviceResult)) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToAddItemToShoppingList", UtilMisc.toMap("shoppingListId", shoppingListId), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToAddItemToShoppingList", UtilMisc.toMap( + "shoppingListId", shoppingListId), locale)); } } } @@ -381,7 +386,8 @@ public class ShoppingListServices { } if (slUpResp == null || ServiceUtil.isError(slUpResp)) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToUpdateShoppingListInformation", UtilMisc.toMap("shoppingListId", shoppingListId), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToUpdateShoppingListInformation", + UtilMisc.toMap("shoppingListId", shoppingListId), locale)); } } @@ -397,7 +403,8 @@ public class ShoppingListServices { Debug.logError(e2, "[Delegator] Could not rollback transaction: " + e2.toString(), MODULE); } - String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderErrorWhileCreatingNewShoppingListBasedOnOrder", UtilMisc.toMap("errorString", e.toString()), locale); + String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderErrorWhileCreatingNewShoppingListBasedOnOrder", UtilMisc.toMap("errorString", + e.toString()), locale); Debug.logError(e, errMsg, MODULE); return ServiceUtil.returnError(errMsg); } finally { @@ -409,23 +416,26 @@ public class ShoppingListServices { } } } + /** * Create a new shoppingCart form a shoppingList - * @param dispatcher the local dispatcher + * + * @param dispatcher the local dispatcher * @param shoppingList a GenericValue object of the shopping list - * @param locale the locale in use + * @param locale the locale in use * @return returns a new shopping cart form a shopping list */ public static ShoppingCart makeShoppingListCart(LocalDispatcher dispatcher, GenericValue shoppingList, Locale locale) { - return makeShoppingListCart(null, dispatcher, shoppingList, locale); } + return makeShoppingListCart(null, dispatcher, shoppingList, locale); + } /** * Add a shoppinglist to an existing shoppingcart * - * @param listCart the shopping cart list - * @param dispatcher the local dispatcher + * @param listCart the shopping cart list + * @param dispatcher the local dispatcher * @param shoppingList a GenericValue object of the shopping list - * @param locale the locale in use + * @param locale the locale in use * @return the modified shopping cart adding the shopping list elements */ public static ShoppingCart makeShoppingListCart(ShoppingCart listCart, LocalDispatcher dispatcher, GenericValue shoppingList, Locale locale) { @@ -485,8 +495,8 @@ public class ShoppingListServices { if (UtilValidate.isNotEmpty(productId) && quantity != null) { if (UtilValidate.isNotEmpty(configId)) { configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, productId, - listCart.getProductStoreId(), null, listCart.getWebSiteId(), listCart.getCurrency(), listCart.getLocale(), - listCart.getAutoUserLogin()); + listCart.getProductStoreId(), null, listCart.getWebSiteId(), listCart.getCurrency(), listCart.getLocale(), + listCart.getAutoUserLogin()); } // list items are noted in the shopping cart String listId = shoppingListItem.getString("shoppingListId"); @@ -494,7 +504,8 @@ public class ShoppingListServices { Map<String, Object> attributes = UtilMisc.<String, Object>toMap("shoppingListId", listId, "shoppingListItemSeqId", itemId); try { - listCart.addOrIncreaseItem(productId, null, quantity, reservStart, reservLength, reservPersons, null, null, null, null, null, attributes, null, configWrapper, null, null, null, dispatcher); + listCart.addOrIncreaseItem(productId, null, quantity, reservStart, reservLength, reservPersons, null, null, null, null, + null, attributes, null, configWrapper, null, null, null, dispatcher); } catch (CartItemModifyException e) { Debug.logError(e, "Unable to add product to List Cart - " + productId, MODULE); } catch (ItemNotFoundException e) { @@ -537,12 +548,11 @@ public class ShoppingListServices { } /** - * * Given an orderId, this service will look through all its OrderItems and for each shoppingListItemId * and shoppingListItemSeqId, update the quantity purchased in the ShoppingListItem entity. Used for * tracking how many of shopping list items are purchased. This service is mounted as a seca on storeOrder. * - * @param ctx - The DispatchContext that this service is operating in + * @param ctx - The DispatchContext that this service is operating in * @param context - Map containing the input parameters * @return Map with the result of the service, the output parameters */ @@ -556,7 +566,8 @@ public class ShoppingListServices { String shoppingListId = orderItem.getString("shoppingListId"); String shoppingListItemSeqId = orderItem.getString("shoppingListItemSeqId"); if (UtilValidate.isNotEmpty(shoppingListId)) { - GenericValue shoppingListItem = EntityQuery.use(delegator).from("ShoppingListItem").where("shoppingListId", shoppingListId, "shoppingListItemSeqId", shoppingListItemSeqId).queryOne(); + GenericValue shoppingListItem = EntityQuery.use(delegator).from("ShoppingListItem").where("shoppingListId", shoppingListId, + "shoppingListItemSeqId", shoppingListItemSeqId).queryOne(); if (shoppingListItem != null) { BigDecimal quantityPurchased = shoppingListItem.getBigDecimal("quantityPurchased"); BigDecimal orderQuantity = orderItem.getBigDecimal("quantity"); @@ -624,7 +635,8 @@ public class ShoppingListServices { } } try { - result = dispatcher.runSync("removeShoppingList", UtilMisc.toMap("shoppingListId", sl.getString("shoppingListId"), "userLogin", userLogin)); + result = dispatcher.runSync("removeShoppingList", UtilMisc.toMap("shoppingListId", sl.getString("shoppingListId"), + "userLogin", userLogin)); if (ServiceUtil.isError(result)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java index 8cb29c4..0c447e2 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java @@ -115,7 +115,7 @@ public class OrderTestServices { } if (productsList.size() == 0) { return ServiceUtil.returnError(UtilProperties.getMessage("OrderUiLabels", - "OrderCreateTestSalesOrderSingleError", + "OrderCreateTestSalesOrderSingleError", UtilMisc.toMap("productCategoryId", productCategoryId), locale)); } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java b/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java index 229e75f..a071181 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/test/SalesOrderTest.java @@ -26,7 +26,6 @@ import java.util.Map; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilMisc; import org.apache.ofbiz.entity.GenericValue; -import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.service.ServiceUtil; import org.apache.ofbiz.service.testtools.OFBizTestCase; @@ -43,13 +42,16 @@ public class SalesOrderTest extends OFBizTestCase { } public void testCreateSalesOrder() throws Exception { - Map<String, Object> ctx = UtilMisc.<String, Object>toMap("partyId", "DemoCustomer", "orderTypeId", "SALES_ORDER", "currencyUom", "USD", "productStoreId", "9000"); + Map<String, Object> ctx = UtilMisc.<String, Object>toMap("partyId", "DemoCustomer", "orderTypeId", "SALES_ORDER", "currencyUom", "USD", + "productStoreId", "9000"); List<GenericValue> orderPaymentInfo = new LinkedList<>(); - GenericValue orderContactMech = delegator.makeValue("OrderContactMech", UtilMisc.toMap("contactMechId", "9015", "contactMechPurposeTypeId", "BILLING_LOCATION")); + GenericValue orderContactMech = delegator.makeValue("OrderContactMech", UtilMisc.toMap("contactMechId", "9015", "contactMechPurposeTypeId", + "BILLING_LOCATION")); orderPaymentInfo.add(orderContactMech); - GenericValue orderPaymentPreference = delegator.makeValue("OrderPaymentPreference", UtilMisc.toMap("paymentMethodId", "9015", "paymentMethodTypeId", "CREDIT_CARD", + GenericValue orderPaymentPreference = delegator.makeValue("OrderPaymentPreference", UtilMisc.toMap("paymentMethodId", "9015", + "paymentMethodTypeId", "CREDIT_CARD", "statusId", "PAYMENT_NOT_AUTH", "overflowFlag", "N", "maxAmount", new BigDecimal("49.26"))); orderPaymentInfo.add(orderPaymentPreference); ctx.put("orderPaymentInfo", orderPaymentInfo); @@ -58,18 +60,21 @@ public class SalesOrderTest extends OFBizTestCase { orderContactMech.set("contactMechPurposeTypeId", "SHIPPING_LOCATION"); orderItemShipGroupInfo.add(orderContactMech); - GenericValue orderItemShipGroup = delegator.makeValue("OrderItemShipGroup", UtilMisc.toMap("carrierPartyId", "UPS", "contactMechId", "9015", "isGift", "N", - "shipGroupSeqId", "00001", "shipmentMethodTypeId", "NEXT_DAY")); + GenericValue orderItemShipGroup = delegator.makeValue("OrderItemShipGroup", UtilMisc.toMap("carrierPartyId", "UPS", "contactMechId", "9015", + "isGift", "N", "shipGroupSeqId", "00001", "shipmentMethodTypeId", "NEXT_DAY")); orderItemShipGroupInfo.add(orderItemShipGroup); - GenericValue orderItemShipGroupAssoc = delegator.makeValue("OrderItemShipGroupAssoc", UtilMisc.toMap("orderItemSeqId", "00001", "quantity", BigDecimal.ONE, "shipGroupSeqId", "00001")); + GenericValue orderItemShipGroupAssoc = delegator.makeValue("OrderItemShipGroupAssoc", UtilMisc.toMap("orderItemSeqId", "00001", "quantity", + BigDecimal.ONE, "shipGroupSeqId", "00001")); orderItemShipGroupInfo.add(orderItemShipGroupAssoc); GenericValue orderAdjustment = null; - orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SHIPPING_CHARGES", "shipGroupSeqId", "00001", "amount", new BigDecimal("12.45"))); + orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SHIPPING_CHARGES", "shipGroupSeqId", + "00001", "amount", new BigDecimal("12.45"))); orderItemShipGroupInfo.add(orderAdjustment); - orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SALES_TAX", "orderItemSeqId", "00001", "overrideGlAccountId", "224153", + orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SALES_TAX", "orderItemSeqId", "00001", + "overrideGlAccountId", "224153", "primaryGeoId", "UT", "shipGroupSeqId", "00001", "sourcePercentage", BigDecimal.valueOf(4.7))); orderAdjustment.set("taxAuthGeoId", "UT"); orderAdjustment.set("taxAuthPartyId", "UT_TAXMAN"); @@ -78,7 +83,8 @@ public class SalesOrderTest extends OFBizTestCase { orderAdjustment.set("comments", "Utah State Sales Tax"); orderItemShipGroupInfo.add(orderAdjustment); - orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SALES_TAX", "orderItemSeqId", "00001", "overrideGlAccountId", "224153", + orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SALES_TAX", "orderItemSeqId", "00001", + "overrideGlAccountId", "224153", "primaryGeoId", "UT-UTAH", "shipGroupSeqId", "00001", "sourcePercentage", BigDecimal.valueOf(0.1))); orderAdjustment.set("taxAuthGeoId", "UT-UTAH"); orderAdjustment.set("taxAuthPartyId", "UT_UTAH_TAXMAN"); @@ -87,7 +93,8 @@ public class SalesOrderTest extends OFBizTestCase { orderAdjustment.set("comments", "Utah County, Utah Sales Tax"); orderItemShipGroupInfo.add(orderAdjustment); - orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SALES_TAX", "orderItemSeqId", "00001", "overrideGlAccountId", "224000", + orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "SALES_TAX", "orderItemSeqId", "00001", + "overrideGlAccountId", "224000", "primaryGeoId", "_NA_", "shipGroupSeqId", "00001", "sourcePercentage", BigDecimal.valueOf(1))); orderAdjustment.set("taxAuthGeoId", "_NA_"); orderAdjustment.set("taxAuthPartyId", "_NA_"); @@ -99,12 +106,14 @@ public class SalesOrderTest extends OFBizTestCase { ctx.put("orderItemShipGroupInfo", orderItemShipGroupInfo); List<GenericValue> orderAdjustments = new LinkedList<>(); - orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT", "productPromoActionSeqId", "01", "productPromoId", "9011", "productPromoRuleId", "01", "amount", BigDecimal.valueOf(-3.84))); + orderAdjustment = delegator.makeValue("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT", + "productPromoActionSeqId", "01", "productPromoId", "9011", "productPromoRuleId", "01", "amount", BigDecimal.valueOf(-3.84))); orderAdjustments.add(orderAdjustment); ctx.put("orderAdjustments", orderAdjustments); List<GenericValue> orderItems = new LinkedList<>(); - GenericValue orderItem = delegator.makeValue("OrderItem", UtilMisc.toMap("orderItemSeqId", "00001", "orderItemTypeId", "PRODUCT_ORDER_ITEM", "prodCatalogId", "DemoCatalog", "productId", "GZ-2644", "quantity", BigDecimal.ONE, "selectedAmount", BigDecimal.ZERO)); + GenericValue orderItem = delegator.makeValue("OrderItem", UtilMisc.toMap("orderItemSeqId", "00001", "orderItemTypeId", "PRODUCT_ORDER_ITEM", + "prodCatalogId", "DemoCatalog", "productId", "GZ-2644", "quantity", BigDecimal.ONE, "selectedAmount", BigDecimal.ZERO)); orderItem.set("isPromo", "N"); orderItem.set("isModifiedPrice", "N"); orderItem.set("unitPrice", new BigDecimal("38.4")); @@ -112,7 +121,8 @@ public class SalesOrderTest extends OFBizTestCase { orderItem.set("statusId", "ITEM_CREATED"); orderItems.add(orderItem); - orderItem = delegator.makeValue("OrderItem", UtilMisc.toMap("orderItemSeqId", "00002", "orderItemTypeId", "PRODUCT_ORDER_ITEM", "prodCatalogId", "DemoCatalog", "productId", "GZ-1006-1", "quantity", BigDecimal.ONE, "selectedAmount", BigDecimal.ZERO)); + orderItem = delegator.makeValue("OrderItem", UtilMisc.toMap("orderItemSeqId", "00002", "orderItemTypeId", "PRODUCT_ORDER_ITEM", + "prodCatalogId", "DemoCatalog", "productId", "GZ-1006-1", "quantity", BigDecimal.ONE, "selectedAmount", BigDecimal.ZERO)); orderItem.set("isPromo", "N"); orderItem.set("isModifiedPrice", "N"); orderItem.set("unitPrice", new BigDecimal("1.99")); @@ -125,9 +135,9 @@ public class SalesOrderTest extends OFBizTestCase { List<GenericValue> orderTerms = new LinkedList<>(); ctx.put("orderTerms", orderTerms); - GenericValue OrderContactMech = delegator.makeValue("OrderContactMech"); - OrderContactMech.set("contactMechPurposeTypeId", "SHIPPING_LOCATION"); - OrderContactMech.set("contactMechId", "10000"); + GenericValue orderContactMec = delegator.makeValue("OrderContactMech"); + orderContactMec.set("contactMechPurposeTypeId", "SHIPPING_LOCATION"); + orderContactMec.set("contactMechId", "10000"); ctx.put("placingCustomerPartyId", "DemoCustomer"); ctx.put("endUserCustomerPartyId", "DemoCustomer"); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java index 1906bc0..0af2d35 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java @@ -56,10 +56,10 @@ import org.apache.ofbiz.service.ServiceUtil; public class ZipSalesServices { private static final String MODULE = ZipSalesServices.class.getName(); - public static final String dataFile = "org/apache/ofbiz/order/thirdparty/zipsales/ZipSalesTaxTables.xml"; - public static final String flatTable = "FlatTaxTable"; - public static final String ruleTable = "FreightRuleTable"; private static final String RES_ERROR = "OrderErrorUiLabels"; + private static final String DATA_FILE = "org/apache/ofbiz/order/thirdparty/zipsales/ZipSalesTaxTables.xml"; + private static final String FLAT_TABLE = "FlatTaxTable"; + private static final String RULE_TABLE = "FreightRuleTable"; // date formatting private static final String DATE_PATTERN = "yyyyMMdd"; @@ -84,7 +84,7 @@ public class ZipSalesServices { // load the data file DataFile tdf = null; try { - tdf = DataFile.makeDataFile(UtilURL.fromResource(dataFile), flatTable); + tdf = DataFile.makeDataFile(UtilURL.fromResource(DATA_FILE), FLAT_TABLE); } catch (DataFileException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToReadZipSalesDataFile", locale)); @@ -93,7 +93,8 @@ public class ZipSalesServices { // locate the file to be imported URL tUrl = UtilURL.fromResource(taxFileLocation); if (tUrl == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToLocateTaxFileAtLocation", UtilMisc.toMap("taxFileLocation", taxFileLocation), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToLocateTaxFileAtLocation", UtilMisc.toMap( + "taxFileLocation", taxFileLocation), locale)); } RecordIterator tri = null; @@ -146,14 +147,15 @@ public class ZipSalesServices { } // console log - Debug.logInfo(newValue.get("zipCode") + "/" + newValue.get("stateCode") + "/" + newValue.get("city") + "/" + newValue.get("county") + "/" + newValue.get("fromDate"), MODULE); + Debug.logInfo(newValue.get("zipCode") + "/" + newValue.get("stateCode") + "/" + newValue.get("city") + "/" + + newValue.get("county") + "/" + newValue.get("fromDate"), MODULE); } } // load the data file DataFile rdf = null; try { - rdf = DataFile.makeDataFile(UtilURL.fromResource(dataFile), ruleTable); + rdf = DataFile.makeDataFile(UtilURL.fromResource(DATA_FILE), RULE_TABLE); } catch (DataFileException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToReadZipSalesDataFile", locale)); @@ -162,7 +164,8 @@ public class ZipSalesServices { // locate the file to be imported URL rUrl = UtilURL.fromResource(ruleFileLocation); if (rUrl == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToLocateRuleFileFromLocation", UtilMisc.toMap("ruleFileLocation", ruleFileLocation), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToLocateRuleFileFromLocation", UtilMisc.toMap( + "ruleFileLocation", ruleFileLocation), locale)); } RecordIterator rri = null; @@ -202,7 +205,8 @@ public class ZipSalesServices { } // console log - Debug.logInfo(newValue.get("stateCode") + "/" + newValue.get("city") + "/" + newValue.get("county") + "/" + newValue.get("fromDate"), MODULE); + Debug.logInfo(newValue.get("stateCode") + "/" + newValue.get("city") + "/" + newValue.get("county") + "/" + newValue.get( + "fromDate"), MODULE); } } } @@ -262,7 +266,8 @@ public class ZipSalesServices { return result; } - private static List<GenericValue>getItemTaxList(Delegator delegator, GenericValue item, String zipCode, String city, BigDecimal itemAmount, BigDecimal shippingAmount, boolean isUseTax) throws GeneralException { + private static List<GenericValue> getItemTaxList(Delegator delegator, GenericValue item, String zipCode, String city, BigDecimal itemAmount, + BigDecimal shippingAmount, boolean isUseTax) throws GeneralException { List<GenericValue> adjustments = new LinkedList<>(); // check the item for tax status @@ -272,7 +277,8 @@ public class ZipSalesServices { } // lookup the records - List<GenericValue> zipLookup = EntityQuery.use(delegator).from("ZipSalesTaxLookup").where("zipCode", zipCode).orderBy("-fromDate").queryList(); + List<GenericValue> zipLookup = + EntityQuery.use(delegator).from("ZipSalesTaxLookup").where("zipCode", zipCode).orderBy("-fromDate").queryList(); if (UtilValidate.isEmpty(zipLookup)) { throw new GeneralException("The zip code entered is not valid."); } @@ -381,71 +387,72 @@ public class ZipSalesServices { char[] conditions = condition.toCharArray(); for (int i = 0; i < conditions.length; i++) { switch (conditions[i]) { - case 'A' : + case 'A': // SHIPPING CHARGE SEPARATELY STATED ON INVOICE qualify = true; // OFBiz does this by default break; - case 'B' : + case 'B': // SHIPPING CHARGE SEPARATED ON INVOICE FROM HANDLING OR SIMILAR CHARGES qualify = false; // we do not support this currently break; - case 'C' : + case 'C': // ITEM NOT SOLD FOR GUARANTEED SHIPPED PRICE qualify = false; // we don't support this currently break; - case 'D' : + case 'D': // SHIPPING CHARGE IS COST ONLY qualify = false; // we assume a handling charge is included break; - case 'E' : + case 'E': // SHIPPED DIRECTLY TO PURCHASER qualify = true; // this is true, unless gifts do not count? break; - case 'F' : + case 'F': // SHIPPED VIA COMMON CARRIER qualify = true; // best guess default break; - case 'G' : + case 'G': // SHIPPED VIA CONTRACT CARRIER qualify = false; // best guess default break; - case 'H' : + case 'H': // SHIPPED VIA VENDOR EQUIPMENT qualify = false; // best guess default break; - case 'I' : + case 'I': // SHIPPED F.O.B. ORIGIN qualify = false; // no clue break; - case 'J' : + case 'J': // SHIPPED F.O.B. DESTINATION qualify = false; // no clue break; - case 'K' : + case 'K': // F.O.B. IS PURCHASERS OPTION qualify = false; // no clue break; - case 'L' : + case 'L': // SHIPPING ORIGINATES OR TERMINATES IN DIFFERENT STATES qualify = true; // not determined at order time, no way to know break; - case 'M' : + case 'M': // PROOF OF VENDOR ACTING AS SHIPPING AGENT FOR PURCHASER qualify = false; // no clue break; - case 'N' : + case 'N': // SHIPPED FROM VENDOR LOCATION qualify = true; // sure why not break; - case 'O' : + case 'O': // SHIPPING IS BY PURCHASER OPTION qualify = false; // most online stores require shipping break; - case 'P' : + case 'P': // CREDIT ALLOWED FOR SHIPPING CHARGE PAID BY PURCHASER TO CARRIER qualify = false; // best guess default break; - default: break; + default: + break; } } } @@ -477,7 +484,8 @@ public class ZipSalesServices { BigDecimal taxRate = comboTaxRate; BigDecimal taxCalc = taxableAmount.multiply(taxRate); - adjustments.add(delegator.makeValue("OrderAdjustment", UtilMisc.toMap("amount", taxCalc, "orderAdjustmentTypeId", "SALES_TAX", "comments", taxRate, "description", "Sales Tax (" + stateCode + ")"))); + adjustments.add(delegator.makeValue("OrderAdjustment", UtilMisc.toMap("amount", taxCalc, "orderAdjustmentTypeId", "SALES_TAX", "comments", + taxRate, "description", "Sales Tax (" + stateCode + ")"))); return adjustments; } diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java index f43741b..e3f31b2 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java @@ -908,9 +908,9 @@ public class CommunicationEventServices { Address[] addressesBCC = wrapper.getBcc(); String messageId = wrapper.getMessageId().replaceAll("[<>]", ""); - String aboutThisEmail = "message [" + messageId + "] from [" + - ((addressesFrom == null || addressesFrom[0] == null) ? "not found" : addressesFrom[0].toString()) + "] to [" + - ((addressesTo == null || addressesTo[0] == null) ? "not found" : addressesTo[0].toString()) + "]"; + String aboutThisEmail = "message [" + messageId + "] from [" + + ((addressesFrom == null || addressesFrom[0] == null) ? "not found" : addressesFrom[0].toString()) + "] to [" + + ((addressesTo == null || addressesTo[0] == null) ? "not found" : addressesTo[0].toString()) + "]"; if (Debug.verboseOn()) { Debug.logVerbose("Processing Incoming Email " + aboutThisEmail, MODULE); diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java b/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java index 04c4026..78905d0 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java @@ -140,11 +140,11 @@ public class PartyContentWrapper implements ContentWrapper { String candidateFieldName = ModelUtil.dbNameToVarName(partyContentTypeId); String cacheKey; if (contentId != null) { - cacheKey = contentId + CACHE_KEY_SEPARATOR + locale + CACHE_KEY_SEPARATOR + mimeTypeId + - CACHE_KEY_SEPARATOR + party.get("partyId"); + cacheKey = contentId + CACHE_KEY_SEPARATOR + locale + CACHE_KEY_SEPARATOR + mimeTypeId + + CACHE_KEY_SEPARATOR + party.get("partyId"); } else { - cacheKey = partyContentTypeId + CACHE_KEY_SEPARATOR + locale + CACHE_KEY_SEPARATOR + mimeTypeId + - CACHE_KEY_SEPARATOR + party.get("partyId"); + cacheKey = partyContentTypeId + CACHE_KEY_SEPARATOR + locale + CACHE_KEY_SEPARATOR + mimeTypeId + + CACHE_KEY_SEPARATOR + party.get("partyId"); } try { diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlDirective.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlDirective.java index 8e74952..81df359 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlDirective.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlDirective.java @@ -42,7 +42,7 @@ import freemarker.template.utility.DeepUnwrap; */ public class CatalogUrlDirective implements TemplateDirectiveModel { - public final static String MODULE = CatalogUrlDirective.class.getName(); + private static final String MODULE = CatalogUrlDirective.class.getName(); @Override public void execute(Environment env, @SuppressWarnings("rawtypes") Map args, TemplateModel[] loopVars, diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java index 20ab211..122ec05 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlFilter.java @@ -49,9 +49,9 @@ import org.apache.ofbiz.webapp.WebAppUtil; public class CatalogUrlFilter implements Filter { - public final static String MODULE = CatalogUrlFilter.class.getName(); - public static final String PRODUCT_REQUEST = "product"; - public static final String CATEGORY_REQUEST = "category"; + private static final String MODULE = CatalogUrlFilter.class.getName(); + private static final String PRODUCT_REQUEST = "product"; + private static final String CATEGORY_REQUEST = "category"; private static String defaultLocaleString; private static String redirectUrl; diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlSeoFilter.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlSeoFilter.java index 3da8f5d..8c0378f 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlSeoFilter.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlSeoFilter.java @@ -35,7 +35,7 @@ import org.apache.ofbiz.product.category.ftl.CatalogUrlSeoTransform; public class CatalogUrlSeoFilter extends CatalogUrlFilter { - public final static String MODULE = CatalogUrlSeoFilter.class.getName(); + private static final String MODULE = CatalogUrlSeoFilter.class.getName(); protected String defaultLocaleString = null; protected String redirectUrl = null; diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java index cebc785..20f89a6 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryServices.java @@ -74,7 +74,7 @@ public class CategoryServices { } catch (GenericEntityException e) { Debug.logError(e, "Problem reading product categories: " + e.getMessage(), MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "categoryservices.problems_reading_category_entity", + "categoryservices.problems_reading_category_entity", UtilMisc.toMap("errMessage", e.getMessage()), locale)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -228,8 +228,8 @@ public class CategoryServices { boolean activeOnly = (context.get("activeOnly") == null || (Boolean) context.get("activeOnly")); // checkViewAllow defaults to false, must be set to true and pass the prodCatalogId to enable - boolean checkViewAllow = (prodCatalogId != null && context.get("checkViewAllow") != null && - (Boolean) context.get("checkViewAllow")); + boolean checkViewAllow = (prodCatalogId != null && context.get("checkViewAllow") != null + && (Boolean) context.get("checkViewAllow")); String viewProductCategoryId = null; if (checkViewAllow) { diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java index 23bf1e4..24f0982 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java @@ -43,7 +43,7 @@ import org.apache.ofbiz.entity.util.EntityUtil; import org.apache.ofbiz.entity.util.EntityQuery; public class SeoContentUrlFilter implements Filter { - public final static String MODULE = SeoContentUrlFilter.class.getName(); + private static final String MODULE = SeoContentUrlFilter.class.getName(); protected static final String defaultLocaleString = null; protected static final String redirectUrl = null; private FilterConfig config; diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogAltUrlTransform.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogAltUrlTransform.java index caac165..10af247 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogAltUrlTransform.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogAltUrlTransform.java @@ -49,7 +49,7 @@ import freemarker.template.TemplateModelException; import freemarker.template.TemplateTransformModel; public class OfbizCatalogAltUrlTransform implements TemplateTransformModel { - public final static String MODULE = OfbizCatalogUrlTransform.class.getName(); + private static final String MODULE = OfbizCatalogUrlTransform.class.getName(); public String getStringArg(Map<?, ?> args, String key) { Object o = args.get(key); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogUrlTransform.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogUrlTransform.java index aabc789..4e225b3 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogUrlTransform.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/OfbizCatalogUrlTransform.java @@ -34,7 +34,7 @@ import freemarker.template.TemplateModelException; import freemarker.template.TemplateTransformModel; public class OfbizCatalogUrlTransform implements TemplateTransformModel { - public final static String MODULE = OfbizCatalogUrlTransform.class.getName(); + private static final String MODULE = OfbizCatalogUrlTransform.class.getName(); public String getStringArg(Map<?, ?> args, String key) { Object o = args.get(key); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java index 8b3e353..fae4c23 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java @@ -535,9 +535,9 @@ public class ProductConfigWrapper implements Serializable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ConfigItem that = (ConfigItem) o; - return Objects.equals(getConfigItem(), that.getConfigItem()) && - Objects.equals(getConfigItemAssoc(), that.getConfigItemAssoc()) && - Objects.equals(getOptions(), that.getOptions()); + return Objects.equals(getConfigItem(), that.getConfigItem()) + && Objects.equals(getConfigItemAssoc(), that.getConfigItemAssoc()) + && Objects.equals(getOptions(), that.getOptions()); } @Override diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java index 45be196..141f876 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryServices.java @@ -59,9 +59,9 @@ import com.ibm.icu.util.Calendar; */ public class InventoryServices { - public final static String MODULE = InventoryServices.class.getName(); + private static final String MODULE = InventoryServices.class.getName(); private static final String RESOURCE = "ProductUiLabels"; - public static final MathContext GEN_ROUNDING = new MathContext(10); + private static final MathContext GEN_ROUNDING = new MathContext(10); public static Map<String, Object> prepareInventoryTransfer(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryWorker.java b/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryWorker.java index 4ba36b2..910a7fb 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/inventory/InventoryWorker.java @@ -39,7 +39,7 @@ import org.apache.ofbiz.entity.util.EntityQuery; public final class InventoryWorker { - public final static String MODULE = InventoryWorker.class.getName(); + private static final String MODULE = InventoryWorker.class.getName(); private InventoryWorker() { } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java index 068144b..cae0bca 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java @@ -141,7 +141,7 @@ public class PriceServices { // if currencyUomId is null get from properties file, if nothing there assume USD (USD: American Dollar) for now String currencyDefaultUomId = (String) context.get("currencyUomId"); - String currencyUomIdTo = (String) context.get("currencyUomIdTo"); + String currencyUomIdTo = (String) context.get("currencyUomIdTo"); if (UtilValidate.isEmpty(currencyDefaultUomId)) { if (productStore != null && UtilValidate.isNotEmpty(productStore.getString("defaultCurrencyUomId"))) { currencyDefaultUomId = productStore.getString("defaultCurrencyUomId"); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java index 258c625..d528d05 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductEvents.java @@ -1139,7 +1139,7 @@ public class ProductEvents { * in fields where BigDecimal display. Blank meaning null, vs. 0 which means 0 * @param bigDecimalString * @return a BigDecimal for the parsed value - * @throws GeneralException + * @throws GeneralException */ public static BigDecimal parseBigDecimalFromParameter(String bigDecimalString, HttpServletRequest request) throws GeneralException { Locale locale = UtilHttp.getLocale(request); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java index 84321e7..7b47f48 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java @@ -219,8 +219,8 @@ public class ProductServices { // check to see if introductionDate hasn't passed yet if (productTo.get("introductionDate") != null && nowTimestamp.before(productTo.getTimestamp("introductionDate"))) { if (Debug.verboseOn()) { - String excMsg = "Tried to view the Product " + productTo.getString("productName") + - " (productId: " + productTo.getString("productId") + ") as a variant. This product has not yet been made available for sale, so not adding for view."; + String excMsg = "Tried to view the Product " + productTo.getString("productName") + + " (productId: " + productTo.getString("productId") + ") as a variant. This product has not yet been made available for sale, so not adding for view."; Debug.logVerbose(excMsg, MODULE); } @@ -230,8 +230,8 @@ public class ProductServices { // check to see if salesDiscontinuationDate has passed if (productTo.get("salesDiscontinuationDate") != null && nowTimestamp.after(productTo.getTimestamp("salesDiscontinuationDate"))) { if (Debug.verboseOn()) { - String excMsg = "Tried to view the Product " + productTo.getString("productName") + - " (productId: " + productTo.getString("productId") + ") as a variant. This product is no longer available for sale, so not adding for view."; + String excMsg = "Tried to view the Product " + productTo.getString("productName") + + " (productId: " + productTo.getString("productId") + ") as a variant. This product is no longer available for sale, so not adding for view."; Debug.logVerbose(excMsg, MODULE); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/promo/PromoServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/promo/PromoServices.java index 16a5c8b..77ac894 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/promo/PromoServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/promo/PromoServices.java @@ -55,9 +55,9 @@ import org.apache.ofbiz.service.ServiceUtil; */ public class PromoServices { - public final static String MODULE = PromoServices.class.getName(); + private static final String MODULE = PromoServices.class.getName(); private static final String RESOURCE = "ProductUiLabels"; - private final static char[] smartChars = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', + private static final char[] smartChars = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', '8', '9' }; public static Map<String, Object> createProductPromoCodeSet(DispatchContext dctx, Map<String, ? extends Object> context) { diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreEvents.java b/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreEvents.java index 6551e13..b56c8fd 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreEvents.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreEvents.java @@ -67,7 +67,7 @@ public class ProductStoreEvents { Map<String, String> dataAttrMap = new HashMap<>(); dataAttrMap.put("onClick", onclickFunction + "('" + productStoreGroupId + "')"); - String hrefStr = "EditProductStoreGroupAndAssoc"; + String hrefStr = "EditProductStoreGroupAndAssoc"; dataAttrMap.put("href", hrefStr); dataMap.put("attr", dataAttrMap); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/subscription/SubscriptionServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/subscription/SubscriptionServices.java index 04d8afb..3a6d6fd 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/subscription/SubscriptionServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/subscription/SubscriptionServices.java @@ -54,7 +54,7 @@ public class SubscriptionServices { private static final String MODULE = SubscriptionServices.class.getName(); private static final String RESOURCE = "ProductUiLabels"; private static final String RES_ERROR = "ProductErrorUiLabels"; - private static final String RES_ORDERError = "OrderErrorUiLabels"; + private static final String RES_ORDER_ERROR = "OrderErrorUiLabels"; public static Map<String, Object> processExtendSubscription(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); @@ -261,13 +261,13 @@ public class SubscriptionServices { String partyId = (String) orderRole.get("partyId"); subContext.put("partyId", partyId); } else { - return ServiceUtil.returnFailure(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnFailure(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderErrorCannotGetOrderRoleEntity", UtilMisc.toMap("itemMsgInfo", orderId), locale)); } orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); if (orderHeader == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDERError, + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER_ERROR, "OrderErrorNoValidOrderHeaderFoundForOrderId", UtilMisc.toMap("orderId", orderId), locale)); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java index 8c66ead..47b24a0 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java @@ -425,8 +425,8 @@ public class PackingSession implements java.io.Serializable { public BigDecimal getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, int packageSeq) { BigDecimal total = BigDecimal.ZERO; for (PackingSessionLine line: this.getLines()) { - if (orderId.equals(line.getOrderId()) && orderItemSeqId.equals(line.getOrderItemSeqId()) && - shipGroupSeqId.equals(line.getShipGroupSeqId()) && productId.equals(line.getProductId())) { + if (orderId.equals(line.getOrderId()) && orderItemSeqId.equals(line.getOrderItemSeqId()) + && shipGroupSeqId.equals(line.getShipGroupSeqId()) && productId.equals(line.getProductId())) { if (inventoryItemId == null || inventoryItemId.equals(line.getInventoryItemId())) { if (packageSeq == -1 || packageSeq == line.getPackageSeq()) { total = total.add(line.getQuantity()); diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java index c9b453b..718982e 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java @@ -76,8 +76,8 @@ public class ShipmentServices { productStoreShipMeth = EntityQuery.use(delegator).from("ProductStoreShipmentMeth").where("productStoreShipMethId", productStoreShipMethId).queryOne(); } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "ProductStoreShipmentMethodCannotRetrieve", - UtilMisc.toMap("productStoreShipMethId", productStoreShipMethId, + "ProductStoreShipmentMethodCannotRetrieve", + UtilMisc.toMap("productStoreShipMethId", productStoreShipMethId, "errorString", e.toString()), locale)); } @@ -152,7 +152,7 @@ public class ShipmentServices { } catch (GenericEntityException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "ProductShipmentCostEstimateRemoveError", + "ProductShipmentCostEstimateRemoveError", UtilMisc.toMap("errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); @@ -183,8 +183,8 @@ public class ShipmentServices { } } else { result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); - result.put(ModelService.ERROR_MESSAGE, "Max " + breakTypeString + - " must not be less than Min " + breakTypeString + "."); + result.put(ModelService.ERROR_MESSAGE, "Max " + breakTypeString + + " must not be less than Min " + breakTypeString + "."); return false; } } @@ -364,7 +364,7 @@ public class ShipmentServices { if (estimateList.size() < 1) { return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, "ProductShipmentCostEstimateCannotFoundForCarrier", - UtilMisc.toMap("carrierPartyId", carrierPartyId, + UtilMisc.toMap("carrierPartyId", carrierPartyId, "shipmentMethodTypeId", shipmentMethodTypeId), locale)); } @@ -883,7 +883,7 @@ public class ShipmentServices { GenericValue shipmentRouteSeg = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (shipmentRouteSeg == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "ProductShipmentRouteSegmentNotFound", + "ProductShipmentRouteSegmentNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } @@ -1059,8 +1059,8 @@ public class ShipmentServices { } if (productStoreEmail == null) { return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, - "ProductProductStoreEmailSettingsNotValid", - UtilMisc.toMap("productStoreId", orderHeader.get("productStoreId"), + "ProductProductStoreEmailSettingsNotValid", + UtilMisc.toMap("productStoreId", orderHeader.get("productStoreId"), "emailType", "PRDS_ODR_SHIP_COMPLT"), localePar)); } // the override screenUri @@ -1130,19 +1130,19 @@ public class ShipmentServices { GenericValue primaryOrderHeader = shipment.getRelatedOne("PrimaryOrderHeader", false); if (primaryOrderHeader == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "ProductShipmentPrimaryOrderHeaderNotFound", + "ProductShipmentPrimaryOrderHeaderNotFound", UtilMisc.toMap("shipmentId", shipmentId), locale)); } String productStoreId = primaryOrderHeader.getString("productStoreId"); if (UtilValidate.isEmpty(productStoreId)) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "ProductShipmentPrimaryOrderHeaderProductStoreNotFound", + "ProductShipmentPrimaryOrderHeaderProductStoreNotFound", UtilMisc.toMap("productStoreId", productStoreId, "shipmentId", shipmentId), locale)); } GenericValue primaryOrderItemShipGroup = shipment.getRelatedOne("PrimaryOrderItemShipGroup", false); if (primaryOrderItemShipGroup == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "ProductShipmentPrimaryOrderHeaderItemShipGroupNotFound", + "ProductShipmentPrimaryOrderHeaderItemShipGroupNotFound", UtilMisc.toMap("shipmentId", shipmentId), locale)); } String shipmentMethodTypeId = primaryOrderItemShipGroup.getString("shipmentMethodTypeId"); @@ -1157,7 +1157,7 @@ public class ShipmentServices { shipmentGatewayConfig.put("configProps", productStoreShipmentMeth.getString("configProps")); } else { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "ProductStoreShipmentMethodNotFound", + "ProductStoreShipmentMethodNotFound", UtilMisc.toMap("shipmentId", shipmentId), locale)); } } catch (GenericEntityException gee) { diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java index 5e61b1b..afbf9b5 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/dhl/DhlServices.java @@ -77,9 +77,9 @@ import org.xml.sax.SAXException; */ public class DhlServices { - public final static String MODULE = DhlServices.class.getName(); - public final static String shipmentPropertiesFile = "shipment.properties"; - public final static String DHL_WEIGHT_UOM_ID = "WT_lb"; // weight Uom used by DHL + private static final String MODULE = DhlServices.class.getName(); + public static final String shipmentPropertiesFile = "shipment.properties"; + public static final String DHL_WEIGHT_UOM_ID = "WT_lb"; // weight Uom used by DHL private static final String RES_ERROR = "ProductUiLabels"; /** @@ -281,7 +281,7 @@ public class DhlServices { String uceErrMsg = "Error sending DHL request for DHL Service Rate: " + e.toString(); Debug.logError(e, uceErrMsg, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentDhlShipmentTemplateSendingError", + "FacilityShipmentDhlShipmentTemplateSendingError", UtilMisc.toMap("errorString", e.toString()), locale)); } @@ -293,7 +293,7 @@ public class DhlServices { String excErrMsg = "Error parsing the RatingServiceResponse: " + e2.toString(); Debug.logError(e2, excErrMsg, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexShipmentTemplateParsingError", + "FacilityShipmentFedexShipmentTemplateParsingError", UtilMisc.toMap("errorString", e2.toString()), locale)); } } @@ -406,7 +406,7 @@ public class DhlServices { String ioeErrMsg = "Error writing the AccessRequest XML Document to a String: " + e.toString(); Debug.logError(e, ioeErrMsg, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentDhlErrorAccessRequestXmlToString", + "FacilityShipmentDhlErrorAccessRequestXmlToString", UtilMisc.toMap("errorString", e.toString()), locale)); } // send the request @@ -418,7 +418,7 @@ public class DhlServices { String uceErrMsg = "Error sending DHL request for DHL Register Account: " + e.toString(); Debug.logError(e, uceErrMsg, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentDhlErrorSendingRequestRegisterAccount", + "FacilityShipmentDhlErrorSendingRequestRegisterAccount", UtilMisc.toMap("errorString", e.toString()), locale)); } @@ -431,7 +431,7 @@ public class DhlServices { String excErrMsg = "Error parsing the RegisterAccountServiceSelectionResponse: " + e2.toString(); Debug.logError(e2, excErrMsg, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentDhlErrorParsingRegisterAccountResponse", + "FacilityShipmentDhlErrorParsingRegisterAccountResponse", UtilMisc.toMap("errorString", e2.toString()), locale)); } @@ -491,21 +491,21 @@ public class DhlServices { GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (shipmentRouteSegment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "ProductShipmentRouteSegmentNotFound", + "ProductShipmentRouteSegmentNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } if (!"DHL".equals(shipmentRouteSegment.getString("carrierPartyId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentDhlNotRouteSegmentCarrier", + "FacilityShipmentDhlNotRouteSegmentCarrier", UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale)); } // add ShipmentRouteSegment carrierServiceStatusId, check before all DHL services if (UtilValidate.isNotEmpty(shipmentRouteSegment.getString("carrierServiceStatusId")) && !"SHRSCS_NOT_STARTED".equals(shipmentRouteSegment.getString("carrierServiceStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentDhlRouteSegmentStatusNotStarted", - UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId, + "FacilityShipmentDhlRouteSegmentStatusNotStarted", + UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId, "shipmentRouteSegmentStatus", shipmentRouteSegment.getString("carrierServiceStatusId")), locale)); } @@ -513,13 +513,13 @@ public class DhlServices { GenericValue originPostalAddress = shipmentRouteSegment.getRelatedOne("OriginPostalAddress", false); if (originPostalAddress == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentOriginPostalAddressNotFound", + "FacilityShipmentRouteSegmentOriginPostalAddressNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } GenericValue originTelecomNumber = shipmentRouteSegment.getRelatedOne("OriginTelecomNumber", false); if (originTelecomNumber == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentOriginTelecomNumberNotFound", + "FacilityShipmentRouteSegmentOriginTelecomNumberNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } String originPhoneNumber = originTelecomNumber.getString("areaCode") + originTelecomNumber.getString("contactNumber"); @@ -534,7 +534,7 @@ public class DhlServices { GenericValue originCountryGeo = originPostalAddress.getRelatedOne("CountryGeo", false); if (originCountryGeo == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentOriginCountryGeoNotFound", + "FacilityShipmentRouteSegmentOriginCountryGeoNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } @@ -542,7 +542,7 @@ public class DhlServices { GenericValue destPostalAddress = shipmentRouteSegment.getRelatedOne("DestPostalAddress", false); if (destPostalAddress == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentDestPostalAddressNotFound", + "FacilityShipmentRouteSegmentDestPostalAddressNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } @@ -572,14 +572,14 @@ public class DhlServices { GenericValue destCountryGeo = destPostalAddress.getRelatedOne("CountryGeo", false); if (destCountryGeo == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentDestCountryGeoNotFound", + "FacilityShipmentRouteSegmentDestCountryGeoNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } List<GenericValue> shipmentPackageRouteSegs = shipmentRouteSegment.getRelated("ShipmentPackageRouteSeg", null, UtilMisc.toList("+shipmentPackageSeqId"), false); if (UtilValidate.isEmpty(shipmentPackageRouteSegs)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentPackageRouteSegsNotFound", + "FacilityShipmentPackageRouteSegsNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } if (shipmentPackageRouteSegs.size() != 1) { @@ -669,7 +669,7 @@ public class DhlServices { .queryOne(); if (carrierShipmentMethod == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentDhlNoCarrierShipmentMethod", + "FacilityShipmentDhlNoCarrierShipmentMethod", UtilMisc.toMap("carrierPartyId", "DHL", "shipmentMethodTypeId", shipmentMethodTypeId), locale)); } dhlShipmentDetailCode = carrierShipmentMethod.getString("carrierServiceCode"); @@ -692,7 +692,7 @@ public class DhlServices { } else if (!("PNG".equals(labelImagePreference) || "GIF".equals(labelImagePreference))) { Debug.logError("Illegal shipment.dhl.label.image.format: " + labelImagePreference, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentDhlUnknownLabelImageFormat", + "FacilityShipmentDhlUnknownLabelImageFormat", UtilMisc.toMap("labelImagePreference", labelImagePreference), locale)); } @@ -754,7 +754,7 @@ public class DhlServices { String uceErrMsg = "Error sending DHL request for DHL Service Rate: " + e.toString(); Debug.logError(e, uceErrMsg, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexRateTemplateSendingError", + "FacilityShipmentFedexRateTemplateSendingError", UtilMisc.toMap("errorString", e.toString()), locale)); } // pass to handler method @@ -762,7 +762,7 @@ public class DhlServices { } catch (GenericEntityException | GenericServiceException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexRateTemplateReadingError", + "FacilityShipmentFedexRateTemplateReadingError", UtilMisc.toMap("errorString", e.toString()), locale)); } } @@ -795,8 +795,8 @@ public class DhlServices { if (encodedImageString == null) { Debug.logError("Cannot find response DHL shipment label. Rate response document is: " + rateResponseString, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentDhlShipmentLabelError", - UtilMisc.toMap("shipmentPackageRouteSeg", shipmentPackageRouteSeg, + "FacilityShipmentDhlShipmentLabelError", + UtilMisc.toMap("shipmentPackageRouteSeg", shipmentPackageRouteSeg, "rateResponseString", rateResponseString), locale)); } @@ -862,7 +862,7 @@ public class DhlServices { UtilMisc.toMap("errorCode", errorCode, "errorDescription", errorDescription), locale)); if (UtilValidate.isNotEmpty(errorSource)) { errorMessageBuf.append(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentDhlErrorMessageElement", + "FacilityShipmentDhlErrorMessageElement", UtilMisc.toMap("errorSource", errorSource), locale)); } errorList.add(errorMessageBuf.toString()); diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/fedex/FedexServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/fedex/FedexServices.java index fb6599f..61fd8c6 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/fedex/FedexServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/fedex/FedexServices.java @@ -77,8 +77,8 @@ import org.xml.sax.SAXException; */ public class FedexServices { - public final static String MODULE = FedexServices.class.getName(); - public final static String shipmentPropertiesFile = "shipment.properties"; + private static final String MODULE = FedexServices.class.getName(); + public static final String shipmentPropertiesFile = "shipment.properties"; private static final String RES_ERROR = "ProductUiLabels"; /** @@ -91,7 +91,7 @@ public class FedexServices { * @return XML string response from FedEx * @throws FedexConnectException */ - public static String sendFedexRequest(String xmlString, Delegator delegator, String shipmentGatewayConfigId, + public static String sendFedexRequest(String xmlString, Delegator delegator, String shipmentGatewayConfigId, String resource, Locale locale) throws FedexConnectException { String url = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "connectUrl", resource, "shipment.fedex.connect.url"); if (UtilValidate.isEmpty(url)) { @@ -160,7 +160,7 @@ public class FedexServices { String meterNumber = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessMeterNumber", resource, "shipment.fedex.access.meterNumber"); if (UtilValidate.isNotEmpty(meterNumber)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexMeterNumberAlreadyExists", + "FacilityShipmentFedexMeterNumberAlreadyExists", UtilMisc.toMap("meterNumber", meterNumber), locale)); } } @@ -193,7 +193,7 @@ public class FedexServices { String errorMessage = "Party with partyId " + companyPartyId + " does not exist"; Debug.logError(errorMessage, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexCompanyPartyDoesNotExists", + "FacilityShipmentFedexCompanyPartyDoesNotExists", UtilMisc.toMap("companyPartyId", companyPartyId), locale)); } @@ -203,7 +203,7 @@ public class FedexServices { String errorMessage = "Party with partyId " + companyPartyId + " has no name"; Debug.logError(errorMessage, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexCompanyPartyHasNoName", + "FacilityShipmentFedexCompanyPartyHasNoName", UtilMisc.toMap("companyPartyId", companyPartyId), locale)); } @@ -241,7 +241,7 @@ public class FedexServices { String errorMessage = "Party with partyId " + companyPartyId + " does not have a current, fully populated postal address"; Debug.logError(errorMessage, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexCompanyPartyHasNotPostalAddress", + "FacilityShipmentFedexCompanyPartyHasNotPostalAddress", UtilMisc.toMap("companyPartyId", companyPartyId), locale)); } GenericValue countryGeo = EntityQuery.use(delegator).from("Geo").where("geoId", postalAddress.getString("countryGeoId")).cache().queryOne(); @@ -267,7 +267,7 @@ public class FedexServices { String errorMessage = "Party with partyId " + companyPartyId + " does not have a current, fully populated primary phone number"; Debug.logError(errorMessage, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexCompanyPartyHasNotPrimaryPhoneNumber", + "FacilityShipmentFedexCompanyPartyHasNotPrimaryPhoneNumber", UtilMisc.toMap("companyPartyId", companyPartyId), locale)); } phoneNumber = phoneNumberValue.getString("areaCode") + phoneNumberValue.getString("contactNumber"); @@ -562,7 +562,7 @@ public class FedexServices { if (UtilValidate.isEmpty(originPostalAddress.getString("stateProvinceGeoId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentRouteSegmentOriginStateProvinceGeoIdRequired", - UtilMisc.toMap("contactMechId", originPostalAddress.getString("contactMechId"), + UtilMisc.toMap("contactMechId", originPostalAddress.getString("contactMechId"), "shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } GenericValue stateProvinceGeo = EntityQuery.use(delegator).from("Geo").where("geoId", originPostalAddress.getString("stateProvinceGeoId")).cache().queryOne(); @@ -626,7 +626,7 @@ public class FedexServices { GenericValue destinationCountryGeo = destinationPostalAddress.getRelatedOne("CountryGeo", false); if (UtilValidate.isEmpty(destinationCountryGeo)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentDestCountryGeoNotFound", + "FacilityShipmentRouteSegmentDestCountryGeoNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } String destinationAddressCountryCode = destinationCountryGeo.getString("geoCode"); @@ -636,8 +636,8 @@ public class FedexServices { if ("CA".equals(destinationAddressCountryCode) || "US".equals(destinationAddressCountryCode)) { if (UtilValidate.isEmpty(destinationPostalAddress.getString("stateProvinceGeoId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentDestStateProvinceGeoIdNotFound", - UtilMisc.toMap("contactMechId", destinationPostalAddress.getString("contactMechId"), + "FacilityShipmentRouteSegmentDestStateProvinceGeoIdNotFound", + UtilMisc.toMap("contactMechId", destinationPostalAddress.getString("contactMechId"), "shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } GenericValue stateProvinceGeo = EntityQuery.use(delegator).from("Geo").where("geoId", destinationPostalAddress.getString("stateProvinceGeoId")).cache().queryOne(); @@ -648,7 +648,7 @@ public class FedexServices { GenericValue destinationTelecomNumber = shipmentRouteSegment.getRelatedOne("DestTelecomNumber", false); if (UtilValidate.isEmpty(destinationTelecomNumber)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentDestTelecomNumberNotFound", + "FacilityShipmentRouteSegmentDestTelecomNumberNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } String destinationContactPhoneNumber = destinationTelecomNumber.getString("areaCode") + destinationTelecomNumber.getString("contactNumber"); @@ -663,7 +663,7 @@ public class FedexServices { String destinationPartyId = shipment.getString("partyIdTo"); if (UtilValidate.isEmpty(destinationPartyId)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexPartyToRequired", + "FacilityShipmentFedexPartyToRequired", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } GenericValue partyTo = EntityQuery.use(delegator).from("Party").where("partyId", destinationPartyId).queryOne(); @@ -671,7 +671,7 @@ public class FedexServices { String destinationContactName = PartyHelper.getPartyName(partyTo, false); if (UtilValidate.isEmpty(destinationContactName)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexPartyToHasNoName", + "FacilityShipmentFedexPartyToHasNoName", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } @@ -684,18 +684,18 @@ public class FedexServices { if (UtilValidate.isNotEmpty(homeDeliveryType)) { if (!("DATECERTAIN".equals(homeDeliveryType) || "EVENING".equals(homeDeliveryType) || "APPOINTMENT".equals(homeDeliveryType))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexHomeDeliveryTypeInvalid", + "FacilityShipmentFedexHomeDeliveryTypeInvalid", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } } homeDeliveryDate = shipmentRouteSegment.getTimestamp("homeDeliveryDate"); if (UtilValidate.isEmpty(homeDeliveryDate)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexHomeDeliveryDateRequired", + "FacilityShipmentFedexHomeDeliveryDateRequired", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } else if (homeDeliveryDate.before(UtilDateTime.nowTimestamp())) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexHomeDeliveryDateBeforeCurrentDate", + "FacilityShipmentFedexHomeDeliveryDateBeforeCurrentDate", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } } @@ -792,8 +792,8 @@ public class FedexServices { packaging = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "defaultPackagingType", resource, "shipment.fedex.default.packagingType"); if (UtilValidate.isEmpty(packaging)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexPackingTypeNotConfigured", - UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), + "FacilityShipmentFedexPackingTypeNotConfigured", + UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), "shipmentId", shipmentId), locale)); } Debug.logWarning("Package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipment " + shipmentId + " has no packaging type set - defaulting to " + packaging, MODULE); @@ -805,12 +805,12 @@ public class FedexServices { GenericValue carrierShipmentBoxType = EntityQuery.use(delegator).from("CarrierShipmentBoxType").where("partyId", "FEDEX", "shipmentBoxTypeId", packaging).queryOne(); if (UtilValidate.isEmpty(carrierShipmentBoxType)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexPackingTypeInvalid", + "FacilityShipmentFedexPackingTypeInvalid", UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), "shipmentId", shipmentId), locale)); } else if (UtilValidate.isEmpty(carrierShipmentBoxType.getString("packagingTypeCode"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexPackingTypeMissing", + "FacilityShipmentFedexPackingTypeMissing", UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), "shipmentId", shipmentId), locale)); } @@ -897,7 +897,7 @@ public class FedexServices { Map<String, Object> results = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", packageWeightUomId, "uomIdTo", weightUomId, "originalValue", packageWeight)); if (ServiceUtil.isError(results) || (results.get("convertedValue") == null)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexWeightOfPackageCannotBeConverted", + "FacilityShipmentFedexWeightOfPackageCannotBeConverted", UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), "shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale)); } else { @@ -908,7 +908,7 @@ public class FedexServices { BigDecimal weight = hasBillingWeight ? billingWeight : packageWeight; if (weight == null || weight.compareTo(BigDecimal.ZERO) < 0) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexWeightOfPackageNotAvailable", + "FacilityShipmentFedexWeightOfPackageNotAvailable", UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), "shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale)); } @@ -953,7 +953,7 @@ public class FedexServices { String errorMessage = "Error sending Fedex request for FDXShipRequest: "; Debug.logError(e, errorMessage, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexShipmentTemplateSendingError", + "FacilityShipmentFedexShipmentTemplateSendingError", UtilMisc.toMap("errorString", e.toString()), locale)); } @@ -963,7 +963,7 @@ public class FedexServices { } catch (GenericEntityException | GenericServiceException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexShipmentTemplateServiceError", + "FacilityShipmentFedexShipmentTemplateServiceError", UtilMisc.toMap("errorString", e.toString()), locale)); } } @@ -1012,7 +1012,7 @@ public class FedexServices { if (UtilValidate.isEmpty(encodedImageString)) { Debug.logError("Cannot find FDXShipReply label. FDXShipReply document is: " + fDXShipReplyString, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentFedexShipmentTemplateLabelNotFound", + "FacilityShipmentFedexShipmentTemplateLabelNotFound", UtilMisc.toMap("shipmentPackageRouteSeg", shipmentPackageRouteSeg, "fDXShipReplyString", fDXShipReplyString), locale)); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java index 7fe51ab..85930e3 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/ups/UpsServices.java @@ -183,8 +183,8 @@ public class UpsServices { GenericValue destTelecomNumber = shipmentRouteSegment.getRelatedOne("DestTelecomNumber", false); if (destTelecomNumber == null) { - String missingErrMsg = "DestTelecomNumber not found for ShipmentRouteSegment with shipmentId " + shipmentId + " and " + - "shipmentRouteSegmentId " + shipmentRouteSegmentId; + String missingErrMsg = "DestTelecomNumber not found for ShipmentRouteSegment with shipmentId " + shipmentId + " and " + + "shipmentRouteSegmentId " + shipmentRouteSegmentId; Debug.logError(missingErrMsg, MODULE); // for now we won't require the dest phone number, but is it required? } @@ -272,8 +272,8 @@ public class UpsServices { BigDecimal codSurchargePackageAmount = null; if (allowCOD) { - codSurchargeAmount = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "codSurchargeAmount", resource, "shipment" + - ".ups.cod.surcharge.amount", ""); + codSurchargeAmount = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "codSurchargeAmount", resource, "shipment" + + ".ups.cod.surcharge.amount", ""); if (UtilValidate.isEmpty(codSurchargeAmount)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsSurchargeAmountIsNotConfigurated", locale)); @@ -284,13 +284,13 @@ public class UpsServices { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsSurchargeCurrencyIsNotConfigurated", locale)); } - String codSurchargeApplyToPackages = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "codSurchargeApplyToPackage" - , resource, "shipment.ups.cod.surcharge.applyToPackages", ""); + String codSurchargeApplyToPackages = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, + "codSurchargeApplyToPackage", resource, "shipment.ups.cod.surcharge.applyToPackages", ""); if (UtilValidate.isEmpty(codSurchargeApplyToPackages)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsApplyToPackagesIsNotConfigured", locale)); } - codFundsCode = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "codFundsCode", resource, "shipment.ups.cod" + - ".codFundsCode", ""); + codFundsCode = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "codFundsCode", resource, "shipment.ups.cod" + + ".codFundsCode", ""); if (UtilValidate.isEmpty(codFundsCode)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsCodFundsCodeIsNotConfigured", locale)); } @@ -360,13 +360,13 @@ public class UpsServices { "Goods for Shipment " + shipment.get("shipmentId") + " from " + ordersDescription, shipmentConfirmRequestDoc); // Child of Shipment: Shipper - String shipperNumber = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "shipperNumber", resource, "shipment.ups" + - ".shipper.number", ""); + String shipperNumber = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "shipperNumber", resource, "shipment.ups" + + ".shipper.number", ""); Element shipperElement = UtilXml.addChildElement(shipmentElement, "Shipper", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(shipperElement, "Name", UtilValidate.isNotEmpty(originPostalAddress.getString("toName")) ? - originPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(shipperElement, "AttentionName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) ? - originPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipperElement, "Name", UtilValidate.isNotEmpty(originPostalAddress.getString("toName")) + ? originPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipperElement, "AttentionName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) + ? originPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(shipperElement, "PhoneNumber", originPhoneNumber, shipmentConfirmRequestDoc); UtilXml.addChildElementValue(shipperElement, "ShipperNumber", shipperNumber, shipmentConfirmRequestDoc); @@ -386,10 +386,10 @@ public class UpsServices { // Child of Shipment: ShipTo Element shipToElement = UtilXml.addChildElement(shipmentElement, "ShipTo", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(shipToElement, "CompanyName", UtilValidate.isNotEmpty(destPostalAddress.getString("toName")) ? - destPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(shipToElement, "AttentionName", UtilValidate.isNotEmpty(destPostalAddress.getString("attnName")) ? - destPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipToElement, "CompanyName", UtilValidate.isNotEmpty(destPostalAddress.getString("toName")) + ? destPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipToElement, "AttentionName", UtilValidate.isNotEmpty(destPostalAddress.getString("attnName")) + ? destPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); if (UtilValidate.isNotEmpty(destPhoneNumber)) { UtilXml.addChildElementValue(shipToElement, "PhoneNumber", destPhoneNumber, shipmentConfirmRequestDoc); } @@ -429,10 +429,10 @@ public class UpsServices { // Child of Shipment: SoldTo Element soldToElement = UtilXml.addChildElement(shipmentElement, "SoldTo", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(soldToElement, "CompanyName", UtilValidate.isNotEmpty(destPostalAddress.getString("toName")) ? - destPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(soldToElement, "AttentionName", UtilValidate.isNotEmpty(destPostalAddress.getString("attnName")) ? - destPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(soldToElement, "CompanyName", UtilValidate.isNotEmpty(destPostalAddress.getString("toName")) + ? destPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(soldToElement, "AttentionName", UtilValidate.isNotEmpty(destPostalAddress.getString("attnName")) + ? destPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); if (UtilValidate.isNotEmpty(destPhoneNumber)) { UtilXml.addChildElementValue(soldToElement, "PhoneNumber", destPhoneNumber, shipmentConfirmRequestDoc); } @@ -1163,8 +1163,8 @@ public class UpsServices { try { shipmentPackageRouteSeg.set("packageServiceCost", new BigDecimal(packageServiceOptionsMonetaryValue)); } catch (NumberFormatException e) { - String excErrMsg = "Error parsing the packageServiceOptionsMonetaryValue [" + packageServiceOptionsMonetaryValue + "] for " + - "Package [" + shipmentPackageRouteSeg.getString("shipmentPackageSeqId") + "]: " + e.toString(); + String excErrMsg = "Error parsing the packageServiceOptionsMonetaryValue [" + packageServiceOptionsMonetaryValue + "] for " + + "Package [" + shipmentPackageRouteSeg.getString("shipmentPackageSeqId") + "]: " + e.toString(); Debug.logError(e, excErrMsg, MODULE); errorList.add(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsErrorParsingServiceOptionsMonetaryValue", UtilMisc.toMap("serviceOptionsMonetaryValue", serviceOptionsMonetaryValue, "errorString", e.toString()), locale)); @@ -1202,8 +1202,8 @@ public class UpsServices { fileOut.flush(); } catch (IOException e) { Debug.logInfo(e, - "Could not save UPS IntlSign LabelImage GIF file: [[[" + packageLabelInternationalSignatureGraphicImageString + "]]] " + - "to file: " + outFileName, MODULE); + "Could not save UPS IntlSign LabelImage GIF file: [[[" + packageLabelInternationalSignatureGraphicImageString + "]]] " + + "to file: " + outFileName, MODULE); } } if (packageLabelHTMLImageStringDecoded != null) { @@ -1311,8 +1311,8 @@ public class UpsServices { } // add ShipmentRouteSegment carrierServiceStatusId, check before all UPS services - if (!"SHRSCS_CONFIRMED".equals(shipmentRouteSegment.getString("carrierServiceStatusId")) && - !"SHRSCS_ACCEPTED".equals(shipmentRouteSegment.getString("carrierServiceStatusId"))) { + if (!"SHRSCS_CONFIRMED".equals(shipmentRouteSegment.getString("carrierServiceStatusId")) + && !"SHRSCS_ACCEPTED".equals(shipmentRouteSegment.getString("carrierServiceStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsRouteSegmentStatusMustBeConfirmedOrAccepted", UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId, "shipmentRouteSegmentStatus", shipmentRouteSegment.getString("carrierServiceStatusId")), locale)); @@ -1874,10 +1874,10 @@ public class UpsServices { Element accessRequestElement = accessRequestDocument.getDocumentElement(); String accessLicenseNumber = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessLicenseNumber", serviceConfigProps, "shipment.ups.access.license.number", ""); - String userId = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessUserId", serviceConfigProps, "shipment.ups.access" + - ".user.id", ""); - String password = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessPassword", serviceConfigProps, "shipment.ups" + - ".access.password", ""); + String userId = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessUserId", serviceConfigProps, "shipment.ups.access" + + ".user.id", ""); + String password = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessPassword", serviceConfigProps, "shipment.ups" + + ".access.password", ""); UtilXml.addChildElementValue(accessRequestElement, "AccessLicenseNumber", accessLicenseNumber, accessRequestDocument); UtilXml.addChildElementValue(accessRequestElement, "UserId", userId, accessRequestDocument); UtilXml.addChildElementValue(accessRequestElement, "Password", password, accessRequestDocument); @@ -1961,8 +1961,8 @@ public class UpsServices { } conStr = conStr + upsService; - String timeOutStr = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "connectTimeout", resource, "shipment.ups.connect" + - ".timeout", "60"); + String timeOutStr = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "connectTimeout", resource, "shipment.ups.connect" + + ".timeout", "60"); int timeout = 60; try { timeout = Integer.parseInt(timeOutStr); @@ -2024,8 +2024,8 @@ public class UpsServices { } // grab the pickup type; if none is defined we will assume daily pickup - String pickupType = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "shipperPickupType", serviceConfigProps, "shipment" + - ".ups.shipper.pickup.type", "01"); + String pickupType = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "shipperPickupType", serviceConfigProps, "shipment" + + ".ups.shipper.pickup.type", "01"); // if we're drop shipping from a supplier, then the address is given to us GenericValue shipFromAddress = (GenericValue) context.get("shipFromAddress"); @@ -2124,16 +2124,16 @@ public class UpsServices { } // package info - String maxWeightStr = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "maxEstimateWeight", serviceConfigProps, "shipment" + - ".ups.max.estimate.weight", "99"); + String maxWeightStr = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "maxEstimateWeight", serviceConfigProps, "shipment" + + ".ups.max.estimate.weight", "99"); BigDecimal maxWeight; try { maxWeight = new BigDecimal(maxWeightStr); } catch (NumberFormatException e) { maxWeight = new BigDecimal("99"); } - String minWeightStr = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "minEstimateWeight", serviceConfigProps, "shipment" + - ".ups.min.estimate.weight", ".1"); + String minWeightStr = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "minEstimateWeight", serviceConfigProps, "shipment" + + ".ups.min.estimate.weight", ".1"); BigDecimal minWeight; try { minWeight = new BigDecimal(minWeightStr); @@ -2428,8 +2428,8 @@ public class UpsServices { GenericValue destTelecomNumber = shipmentRouteSegment.getRelatedOne("DestTelecomNumber", false); if (destTelecomNumber == null) { - String missingErrMsg = "DestTelecomNumber not found for ShipmentRouteSegment with shipmentId " + shipmentId + " and " + - "shipmentRouteSegmentId " + shipmentRouteSegmentId; + String missingErrMsg = "DestTelecomNumber not found for ShipmentRouteSegment with shipmentId " + shipmentId + " and " + + "shipmentRouteSegmentId " + shipmentRouteSegmentId; Debug.logError(missingErrMsg, MODULE); } String destPhoneNumber = null; @@ -2508,13 +2508,13 @@ public class UpsServices { UtilXml.addChildElementValue(returnServiceElement, "Code", String.valueOf(RET_SERVICE_CODE), shipmentConfirmRequestDoc); // Child of Shipment: Shipper - String shipperNumber = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "shipperNumber", resource, "shipment.ups" + - ".shipper.number", ""); + String shipperNumber = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "shipperNumber", resource, "shipment.ups" + + ".shipper.number", ""); Element shipperElement = UtilXml.addChildElement(shipmentElement, "Shipper", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(shipperElement, "Name", UtilValidate.isNotEmpty(originPostalAddress.getString("toName")) ? - originPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(shipperElement, "AttentionName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) ? - originPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipperElement, "Name", UtilValidate.isNotEmpty(originPostalAddress.getString("toName")) + ? originPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipperElement, "AttentionName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) + ? originPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(shipperElement, "PhoneNumber", originPhoneNumber, shipmentConfirmRequestDoc); UtilXml.addChildElementValue(shipperElement, "ShipperNumber", shipperNumber, shipmentConfirmRequestDoc); @@ -2532,10 +2532,10 @@ public class UpsServices { // Child of Shipment: ShipTo Element shipToElement = UtilXml.addChildElement(shipmentElement, "ShipTo", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(shipToElement, "CompanyName", UtilValidate.isNotEmpty(destPostalAddress.getString("toName")) ? - destPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(shipToElement, "AttentionName", UtilValidate.isNotEmpty(destPostalAddress.getString("attnName")) ? - destPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipToElement, "CompanyName", UtilValidate.isNotEmpty(destPostalAddress.getString("toName")) + ? destPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipToElement, "AttentionName", UtilValidate.isNotEmpty(destPostalAddress.getString("attnName")) + ? destPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); if (UtilValidate.isNotEmpty(destPhoneNumber)) { UtilXml.addChildElementValue(shipToElement, "PhoneNumber", destPhoneNumber, shipmentConfirmRequestDoc); } @@ -2556,10 +2556,10 @@ public class UpsServices { // Child of Shipment: ShipFrom Element shipFromElement = UtilXml.addChildElement(shipmentElement, "ShipFrom", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(shipFromElement, "CompanyName", UtilValidate.isNotEmpty(originPostalAddress.getString("toName")) ? - originPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(shipFromElement, "AttentionName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) ? - originPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipFromElement, "CompanyName", UtilValidate.isNotEmpty(originPostalAddress.getString("toName")) + ? originPostalAddress.getString("toName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(shipFromElement, "AttentionName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) + ? originPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(shipFromElement, "PhoneNumber", originPhoneNumber, shipmentConfirmRequestDoc); Element shipFromAddressElement = UtilXml.addChildElement(shipFromElement, "Address", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(shipFromAddressElement, "AddressLine1", originPostalAddress.getString("address1"), @@ -2605,8 +2605,8 @@ public class UpsServices { Element emailMessageElement = UtilXml.addChildElement(labelDeliveryElement, "EMailMessage", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(emailMessageElement, "EMailAddress", recipientEmail, shipmentConfirmRequestDoc); UtilXml.addChildElementValue(emailMessageElement, "FromEMailAddress", senderEmail, shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(emailMessageElement, "FromName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) ? - originPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(emailMessageElement, "FromName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) + ? originPostalAddress.getString("attnName") : "", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(emailMessageElement, "Memo", defaultReturnLabelMemo, shipmentConfirmRequestDoc); UtilXml.addChildElementValue(emailMessageElement, "Subject", defaultReturnLabelSubject, shipmentConfirmRequestDoc); @@ -2618,8 +2618,8 @@ public class UpsServices { Element packageWeightElement = UtilXml.addChildElement(packageElement, "PackageWeight", shipmentConfirmRequestDoc); Element packageWeightUnitOfMeasurementElement = UtilXml.addChildElement(packageElement, "UnitOfMeasurement", shipmentConfirmRequestDoc); UtilXml.addChildElementValue(packageWeightUnitOfMeasurementElement, "Code", "LBS", shipmentConfirmRequestDoc); - UtilXml.addChildElementValue(packageWeightElement, "Weight", EntityUtilProperties.getPropertyValue("shipment", "shipment.default.weight" + - ".value", delegator), shipmentConfirmRequestDoc); + UtilXml.addChildElementValue(packageWeightElement, "Weight", EntityUtilProperties.getPropertyValue("shipment", "shipment.default.weight" + + ".value", delegator), shipmentConfirmRequestDoc); String shipmentConfirmRequestString = null; try { @@ -2846,8 +2846,8 @@ public class UpsServices { GenericValue destTelecomNumber = shipmentRouteSegment.getRelatedOne("DestTelecomNumber", false); if (destTelecomNumber == null) { - String missingErrMsg = "DestTelecomNumber not found for ShipmentRouteSegment with shipmentId " + shipmentId + " and " + - "shipmentRouteSegmentId " + shipmentRouteSegmentId; + String missingErrMsg = "DestTelecomNumber not found for ShipmentRouteSegment with shipmentId " + shipmentId + " and " + + "shipmentRouteSegmentId " + shipmentRouteSegmentId; Debug.logError(missingErrMsg, MODULE); // for now we won't require the dest phone number, but is it required? } @@ -2870,8 +2870,8 @@ public class UpsServices { } // grab the pickup type; if none is defined we will assume daily pickup - String pickupType = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "shipperPickupType", resource, "shipment.ups" + - ".shipper.pickup.type", "01"); + String pickupType = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "shipperPickupType", resource, "shipment.ups" + + ".shipper.pickup.type", "01"); // grab the customer classification; if none is defined we will assume daily pickup String customerClassification = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "customerClassification", resource, @@ -2905,13 +2905,13 @@ public class UpsServices { // shipment info Element shipmentElement = UtilXml.addChildElement(rateRequestElement, "Shipment", rateRequestDoc); Element shipperElement = UtilXml.addChildElement(shipmentElement, "Shipper", rateRequestDoc); - UtilXml.addChildElementValue(shipperElement, "Name", UtilValidate.isNotEmpty(originPostalAddress.getString("toName")) ? - originPostalAddress.getString("toName") : "", rateRequestDoc); - UtilXml.addChildElementValue(shipperElement, "AttentionName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) ? - originPostalAddress.getString("attnName") : "", rateRequestDoc); + UtilXml.addChildElementValue(shipperElement, "Name", UtilValidate.isNotEmpty(originPostalAddress.getString("toName")) + ? originPostalAddress.getString("toName") : "", rateRequestDoc); + UtilXml.addChildElementValue(shipperElement, "AttentionName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) + ? originPostalAddress.getString("attnName") : "", rateRequestDoc); UtilXml.addChildElementValue(shipperElement, "PhoneNumber", originPhoneNumber, rateRequestDoc); - UtilXml.addChildElementValue(shipperElement, "ShipperNumber", EntityUtilProperties.getPropertyValue("shipment", "shipment.ups.shipper" + - ".number", delegator), rateRequestDoc); + UtilXml.addChildElementValue(shipperElement, "ShipperNumber", EntityUtilProperties.getPropertyValue("shipment", "shipment.ups.shipper" + + ".number", delegator), rateRequestDoc); Element shipperAddressElement = UtilXml.addChildElement(shipperElement, "Address", rateRequestDoc); UtilXml.addChildElementValue(shipperAddressElement, "AddressLine1", originPostalAddress.getString("address1"), rateRequestDoc); @@ -2927,10 +2927,10 @@ public class UpsServices { // Child of Shipment: ShipTo Element shipToElement = UtilXml.addChildElement(shipmentElement, "ShipTo", rateRequestDoc); - UtilXml.addChildElementValue(shipToElement, "CompanyName", UtilValidate.isNotEmpty(destPostalAddress.getString("toName")) ? - destPostalAddress.getString("toName") : "", rateRequestDoc); - UtilXml.addChildElementValue(shipToElement, "AttentionName", UtilValidate.isNotEmpty(destPostalAddress.getString("attnName")) ? - destPostalAddress.getString("attnName") : "", rateRequestDoc); + UtilXml.addChildElementValue(shipToElement, "CompanyName", UtilValidate.isNotEmpty(destPostalAddress.getString("toName")) + ? destPostalAddress.getString("toName") : "", rateRequestDoc); + UtilXml.addChildElementValue(shipToElement, "AttentionName", UtilValidate.isNotEmpty(destPostalAddress.getString("attnName")) + ? destPostalAddress.getString("attnName") : "", rateRequestDoc); if (UtilValidate.isNotEmpty(destPhoneNumber)) { UtilXml.addChildElementValue(shipToElement, "PhoneNumber", destPhoneNumber, rateRequestDoc); } @@ -2951,10 +2951,10 @@ public class UpsServices { // Child of Shipment: ShipFrom Element shipFromElement = UtilXml.addChildElement(shipmentElement, "ShipFrom", rateRequestDoc); - UtilXml.addChildElementValue(shipFromElement, "CompanyName", UtilValidate.isNotEmpty(originPostalAddress.getString("toName")) ? - originPostalAddress.getString("toName") : "", rateRequestDoc); - UtilXml.addChildElementValue(shipFromElement, "AttentionName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) ? - originPostalAddress.getString("attnName") : "", rateRequestDoc); + UtilXml.addChildElementValue(shipFromElement, "CompanyName", UtilValidate.isNotEmpty(originPostalAddress.getString("toName")) + ? originPostalAddress.getString("toName") : "", rateRequestDoc); + UtilXml.addChildElementValue(shipFromElement, "AttentionName", UtilValidate.isNotEmpty(originPostalAddress.getString("attnName")) + ? originPostalAddress.getString("attnName") : "", rateRequestDoc); UtilXml.addChildElementValue(shipFromElement, "PhoneNumber", originPhoneNumber, rateRequestDoc); Element shipFromAddressElement = UtilXml.addChildElement(shipFromElement, "Address", rateRequestDoc); UtilXml.addChildElementValue(shipFromAddressElement, "AddressLine1", originPostalAddress.getString("address1"), rateRequestDoc); @@ -3011,9 +3011,9 @@ public class UpsServices { rateRequestDoc); UtilXml.addChildElementValue(dimensionsElement, "Height", UtilValidate.isNotEmpty(boxHeight) ? "" + boxHeight.intValue() : "", rateRequestDoc); - } else if - (UtilValidate.isNotEmpty(shipmentPackage.get("boxLength")) && UtilValidate.isNotEmpty(shipmentPackage.get("boxWidth")) && - UtilValidate.isNotEmpty(shipmentPackage.get("boxHeight"))) { + } else if (UtilValidate.isNotEmpty(shipmentPackage.get("boxLength")) + && UtilValidate.isNotEmpty(shipmentPackage.get("boxWidth")) + && UtilValidate.isNotEmpty(shipmentPackage.get("boxHeight"))) { Element dimensionsElement = UtilXml.addChildElement(packageElement, "Dimensions", rateRequestDoc); Element unitOfMeasurementElement = UtilXml.addChildElement(dimensionsElement, "UnitOfMeasurement", rateRequestDoc); UtilXml.addChildElementValue(unitOfMeasurementElement, "Code", ModelService.IN_PARAM, rateRequestDoc); diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java index d1b6f92..1b5c888 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/thirdparty/usps/UspsServices.java @@ -73,8 +73,8 @@ import org.w3c.dom.Element; */ public class UspsServices { - public final static String MODULE = UspsServices.class.getName(); - public final static String RES_ERROR = "ProductUiLabels"; + private static final String MODULE = UspsServices.class.getName(); + private static final String RES_ERROR = "ProductUiLabels"; private static List<String> domesticCountries = new LinkedList<>(); // Countries treated as domestic for rate enquiries @@ -577,7 +577,7 @@ public class UspsServices { Element respErrorElement = UtilXml.firstChildElement(respAddressElement, "Error"); if (respErrorElement != null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsAddressValidationIncompleteResponse", + "FacilityShipmentUspsAddressValidationIncompleteResponse", UtilMisc.toMap("errorString", UtilXml.childElementValue(respErrorElement, "Description")), locale)); } @@ -651,7 +651,7 @@ public class UspsServices { } catch (UspsRequestException e) { Debug.logInfo(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsCityStateLookupSendingError", + "FacilityShipmentUspsCityStateLookupSendingError", UtilMisc.toMap("errorString", e.getMessage()), locale)); } @@ -664,7 +664,7 @@ public class UspsServices { Element respErrorElement = UtilXml.firstChildElement(respAddressElement, "Error"); if (respErrorElement != null) { return ServiceUtil.returnFailure(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsCityStateLookupResponseError", + "FacilityShipmentUspsCityStateLookupResponseError", UtilMisc.toMap("errorString", UtilXml.childElementValue(respErrorElement, "Description")), locale)); } @@ -748,7 +748,7 @@ public class UspsServices { Locale locale = (Locale) context.get("locale"); if (!type.matches("PriorityMail|StandardB")) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsUnsupporteServiceType", + "FacilityShipmentUspsUnsupporteServiceType", UtilMisc.toMap("serviceType", type), locale)); } @@ -765,7 +765,7 @@ public class UspsServices { } catch (UspsRequestException e) { Debug.logInfo(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsServiceStandardSendingError", + "FacilityShipmentUspsServiceStandardSendingError", UtilMisc.toMap("serviceType", type, "errorString", e.getMessage()), locale)); } @@ -774,7 +774,7 @@ public class UspsServices { String days = UtilXml.childElementValue(responseDocument.getDocumentElement(), "Days"); if (UtilValidate.isEmpty(days)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsServiceStandardResponseIncompleteDaysElement", + "FacilityShipmentUspsServiceStandardResponseIncompleteDaysElement", UtilMisc.toMap("serviceType", type), locale)); } result.put("days", days); @@ -834,7 +834,7 @@ public class UspsServices { String shipmentGatewayConfigId = (String) context.get("shipmentGatewayConfigId"); String resource = (String) context.get("configProps"); Locale locale = (Locale) context.get("locale"); - + Document requestDocument = createUspsRequestDocument("RateRequest", true, delegator, shipmentGatewayConfigId, resource); Element packageElement = UtilXml.addChildElement(requestDocument.getDocumentElement(), "Package", requestDocument); @@ -870,7 +870,7 @@ public class UspsServices { } catch (UspsRequestException e) { Debug.logInfo(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsRateDomesticSendingError", + "FacilityShipmentUspsRateDomesticSendingError", UtilMisc.toMap("errorString", e.getMessage()), locale)); } @@ -883,7 +883,7 @@ public class UspsServices { Element respErrorElement = UtilXml.firstChildElement(respPackageElement, "Error"); if (respErrorElement != null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsRateDomesticResponseError", + "FacilityShipmentUspsRateDomesticResponseError", UtilMisc.toMap("errorString", UtilXml.childElementValue(respErrorElement, "Description")), locale)); } @@ -939,14 +939,14 @@ public class UspsServices { GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (shipmentRouteSegment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "ProductShipmentRouteSegmentNotFound", + "ProductShipmentRouteSegmentNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } // ensure the carrier is USPS if (!"USPS".equals(shipmentRouteSegment.getString("carrierPartyId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsNotRouteSegmentCarrier", + "FacilityShipmentUspsNotRouteSegmentCarrier", UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale)); } @@ -954,18 +954,18 @@ public class UspsServices { GenericValue originAddress = shipmentRouteSegment.getRelatedOne("OriginPostalAddress", false); if (originAddress == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentOriginPostalAddressNotFound", + "FacilityShipmentRouteSegmentOriginPostalAddressNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } if (!"USA".equals(originAddress.getString("countryGeoId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa", + "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } String originZip = originAddress.getString("postalCode"); if (UtilValidate.isEmpty(originZip)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsRouteSegmentOriginZipCodeMissing", + "FacilityShipmentUspsRouteSegmentOriginZipCodeMissing", UtilMisc.toMap("contactMechId", originAddress.getString("contactMechId")), locale)); } @@ -973,18 +973,18 @@ public class UspsServices { GenericValue destinationAddress = shipmentRouteSegment.getRelatedOne("DestPostalAddress", false); if (destinationAddress == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentDestPostalAddressNotFound", + "FacilityShipmentRouteSegmentDestPostalAddressNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } if (!"USA".equals(destinationAddress.getString("countryGeoId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa", + "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } String destinationZip = destinationAddress.getString("postalCode"); if (UtilValidate.isEmpty(destinationZip)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsRouteSegmentDestinationZipCodeMissing", + "FacilityShipmentUspsRouteSegmentDestinationZipCodeMissing", UtilMisc.toMap("contactMechId", destinationAddress.getString("contactMechId")), locale)); } @@ -995,13 +995,13 @@ public class UspsServices { GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod").where("partyId", partyId, "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentMethodTypeId).queryOne(); if (carrierShipmentMethod == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsNoCarrierShipmentMethod", + "FacilityShipmentUspsNoCarrierShipmentMethod", UtilMisc.toMap("carrierPartyId", partyId, "shipmentMethodTypeId", shipmentMethodTypeId), locale)); } String serviceType = carrierShipmentMethod.getString("carrierServiceCode"); if (UtilValidate.isEmpty(serviceType)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsNoCarrierServiceCodeFound", + "FacilityShipmentUspsNoCarrierServiceCodeFound", UtilMisc.toMap("carrierPartyId", partyId, "shipmentMethodTypeId", shipmentMethodTypeId), locale)); } @@ -1009,7 +1009,7 @@ public class UspsServices { List<GenericValue> shipmentPackageRouteSegList = shipmentRouteSegment.getRelated("ShipmentPackageRouteSeg", null, UtilMisc.toList("+shipmentPackageSeqId"), false); if (UtilValidate.isEmpty(shipmentPackageRouteSegList)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentPackageRouteSegsNotFound", + "FacilityShipmentPackageRouteSegsNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } @@ -1039,8 +1039,8 @@ public class UspsServices { String weightStr = shipmentPackage.getString("weight"); if (UtilValidate.isEmpty(weightStr)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsWeightNotFound", - UtilMisc.toMap("shipmentId", shipmentPackage.getString("shipmentId"), + "FacilityShipmentUspsWeightNotFound", + UtilMisc.toMap("shipmentId", shipmentPackage.getString("shipmentId"), "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId")), locale)); } @@ -1065,7 +1065,7 @@ public class UspsServices { } } catch (GenericServiceException ex) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsWeightConversionError", + "FacilityShipmentUspsWeightConversionError", UtilMisc.toMap("errorString", ex.getMessage()), locale)); } @@ -1073,8 +1073,8 @@ public class UspsServices { weight = weight.multiply((BigDecimal) result.get("convertedValue")); } else { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsWeightUnsupported", - UtilMisc.toMap("weightUomId", weightUomId, "shipmentId", shipmentPackage.getString("shipmentId"), + "FacilityShipmentUspsWeightUnsupported", + UtilMisc.toMap("weightUomId", weightUomId, "shipmentId", shipmentPackage.getString("shipmentId"), "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), "weightUom", "WT_lb"), locale)); } @@ -1097,8 +1097,8 @@ public class UspsServices { carrierShipmentBoxType = carrierShipmentBoxTypes.get(0); } - if (carrierShipmentBoxType != null && - UtilValidate.isNotEmpty(carrierShipmentBoxType.getString("packagingTypeCode"))) { + if (carrierShipmentBoxType != null + && UtilValidate.isNotEmpty(carrierShipmentBoxType.getString("packagingTypeCode"))) { UtilXml.addChildElementValue(packageElement, "Container", carrierShipmentBoxType.getString("packagingTypeCode"), requestDocument); } else { @@ -1124,7 +1124,7 @@ public class UspsServices { } catch (UspsRequestException e) { Debug.logInfo(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsRateDomesticSendingError", + "FacilityShipmentUspsRateDomesticSendingError", UtilMisc.toMap("errorString", e.getMessage()), locale)); } @@ -1137,7 +1137,7 @@ public class UspsServices { Element respErrorElement = UtilXml.firstChildElement(respPackageElement, "Error"); if (respErrorElement != null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsRateDomesticResponseError", + "FacilityShipmentUspsRateDomesticResponseError", UtilMisc.toMap("errorString", UtilXml.childElementValue(respErrorElement, "Description")), locale)); } @@ -1243,14 +1243,14 @@ public class UspsServices { GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (shipmentRouteSegment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "ProductShipmentRouteSegmentNotFound", + "ProductShipmentRouteSegmentNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } // ensure the carrier is USPS if (!"USPS".equals(shipmentRouteSegment.getString("carrierPartyId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsNotRouteSegmentCarrier", + "FacilityShipmentUspsNotRouteSegmentCarrier", UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale)); } @@ -1258,12 +1258,12 @@ public class UspsServices { GenericValue originAddress = shipmentRouteSegment.getRelatedOne("OriginPostalAddress", false); if (originAddress == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentOriginPostalAddressNotFound", + "FacilityShipmentRouteSegmentOriginPostalAddressNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } if (!"USA".equals(originAddress.getString("countryGeoId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa", + "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } @@ -1271,12 +1271,12 @@ public class UspsServices { GenericValue destinationAddress = shipmentRouteSegment.getRelatedOne("DestPostalAddress", false); if (destinationAddress == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentRouteSegmentDestPostalAddressNotFound", + "FacilityShipmentRouteSegmentDestPostalAddressNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } if (!"USA".equals(destinationAddress.getString("countryGeoId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa", + "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } @@ -1287,7 +1287,7 @@ public class UspsServices { GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod").where("partyId", partyId, "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentMethodTypeId).queryOne(); if (carrierShipmentMethod == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsNoCarrierShipmentMethod", + "FacilityShipmentUspsNoCarrierShipmentMethod", UtilMisc.toMap("carrierPartyId", partyId, "shipmentMethodTypeId", shipmentMethodTypeId), locale)); } String serviceType = carrierShipmentMethod.getString("carrierServiceCode"); @@ -1300,7 +1300,7 @@ public class UspsServices { List<GenericValue> shipmentPackageRouteSegList = shipmentRouteSegment.getRelated("ShipmentPackageRouteSeg", null, UtilMisc.toList("+shipmentPackageSeqId"), false); if (UtilValidate.isEmpty(shipmentPackageRouteSegList)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentPackageRouteSegsNotFound", + "FacilityShipmentPackageRouteSegsNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } @@ -1347,7 +1347,7 @@ public class UspsServices { String weightStr = shipmentPackage.getString("weight"); if (UtilValidate.isEmpty(weightStr)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsWeightNotFound", + "FacilityShipmentUspsWeightNotFound", UtilMisc.toMap("shipmentId", shipmentPackage.getString("shipmentId"), "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId")), locale)); } @@ -1369,8 +1369,8 @@ public class UspsServices { GenericValue uomConversion = EntityQuery.use(delegator).from("UomConversion").where("uomId", weightUomId, "uomIdTo", "WT_oz").queryOne(); if (uomConversion == null || UtilValidate.isEmpty(uomConversion.getString("conversionFactor"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsWeightUnsupported", - UtilMisc.toMap("weightUomId", weightUomId, "shipmentId", shipmentPackage.getString("shipmentId"), + "FacilityShipmentUspsWeightUnsupported", + UtilMisc.toMap("weightUomId", weightUomId, "shipmentId", shipmentPackage.getString("shipmentId"), "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), "weightUom", "WT_oz"), locale)); } @@ -1390,7 +1390,7 @@ public class UspsServices { } catch (UspsRequestException e) { Debug.logInfo(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsDeliveryConfirmationSendingError", + "FacilityShipmentUspsDeliveryConfirmationSendingError", UtilMisc.toMap("errorString", e.getMessage()), locale)); } Element responseElement = responseDocument.getDocumentElement(); @@ -1398,9 +1398,9 @@ public class UspsServices { Element respErrorElement = UtilXml.firstChildElement(responseElement, "Error"); if (respErrorElement != null) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsDeliveryConfirmationResponseError", - UtilMisc.toMap("shipmentId", shipmentPackage.getString("shipmentId"), - "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), + "FacilityShipmentUspsDeliveryConfirmationResponseError", + UtilMisc.toMap("shipmentId", shipmentPackage.getString("shipmentId"), + "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"), "errorString", UtilXml.childElementValue(respErrorElement, "Description")), locale)); } @@ -1422,7 +1422,7 @@ public class UspsServices { } catch (GenericEntityException gee) { Debug.logInfo(gee, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsDeliveryConfirmationReadingError", + "FacilityShipmentUspsDeliveryConfirmationReadingError", UtilMisc.toMap("errorString", gee.getMessage()), locale)); } @@ -1446,9 +1446,9 @@ public class UspsServices { for (GenericValue shipmentPackageRouteSeg: shipmentPackageRouteSegList) { byte[] labelImageBytes = shipmentPackageRouteSeg.getBytes("labelImage"); - String outFileName = "UspsLabelImage" + shipmentRouteSegment.getString("shipmentId") + "_" + - shipmentRouteSegment.getString("shipmentRouteSegmentId") + "_" + - shipmentPackageRouteSeg.getString("shipmentPackageSeqId") + ".gif"; + String outFileName = "UspsLabelImage" + shipmentRouteSegment.getString("shipmentId") + "_" + + shipmentRouteSegment.getString("shipmentRouteSegmentId") + "_" + + shipmentPackageRouteSeg.getString("shipmentPackageSeqId") + ".gif"; try (FileOutputStream fileOut = new FileOutputStream(outFileName)) { fileOut.write(labelImageBytes); @@ -1636,7 +1636,7 @@ public class UspsServices { } catch (UspsRequestException e) { Debug.logInfo(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, - "FacilityShipmentUspsPriorityMailLabelSendingError", + "FacilityShipmentUspsPriorityMailLabelSendingError", UtilMisc.toMap("errorString", e.getMessage()), locale)); } Element responseElement = responseDocument.getDocumentElement(); @@ -1668,10 +1668,10 @@ public class UspsServices { private static Document createUspsRequestDocument(String rootElement, boolean passwordRequired, Delegator delegator, String shipmentGatewayConfigId, String resource) { Document requestDocument = UtilXml.makeEmptyXmlDocument(rootElement); Element requestElement = requestDocument.getDocumentElement(); - requestElement.setAttribute("USERID", getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, + requestElement.setAttribute("USERID", getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessUserId", resource, "shipment.usps.access.userid", "")); if (passwordRequired) { - requestElement.setAttribute("PASSWORD", getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, + requestElement.setAttribute("PASSWORD", getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessPassword", resource, "shipment.usps.access.password", "")); } return requestDocument; @@ -1788,7 +1788,7 @@ public class UspsServices { return returnValue; } - private static String getShipmentGatewayConfigValue(Delegator delegator, String shipmentGatewayConfigId, String shipmentGatewayConfigParameterName, + private static String getShipmentGatewayConfigValue(Delegator delegator, String shipmentGatewayConfigId, String shipmentGatewayConfigParameterName, String resource, String parameterName, String defaultValue) { String returnValue = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, shipmentGatewayConfigParameterName, resource, parameterName); if (UtilValidate.isEmpty(returnValue)) { diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java index 9940e49..f1d6359 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java @@ -235,11 +235,11 @@ public class WorkEffortContentWrapper implements ContentWrapper { String candidateFieldName = ModelUtil.dbNameToVarName(workEffortContentTypeId); String cacheKey; if (contentId != null) { - cacheKey = contentId + CACHE_KEY_SEPARATOR + locale + CACHE_KEY_SEPARATOR + mimeTypeId + - CACHE_KEY_SEPARATOR + workEffort.get("workEffortId"); + cacheKey = contentId + CACHE_KEY_SEPARATOR + locale + CACHE_KEY_SEPARATOR + mimeTypeId + + CACHE_KEY_SEPARATOR + workEffort.get("workEffortId"); } else { - cacheKey = workEffortContentTypeId + CACHE_KEY_SEPARATOR + locale + CACHE_KEY_SEPARATOR + mimeTypeId + - CACHE_KEY_SEPARATOR + workEffort.get("workEffortId"); + cacheKey = workEffortContentTypeId + CACHE_KEY_SEPARATOR + locale + CACHE_KEY_SEPARATOR + mimeTypeId + + CACHE_KEY_SEPARATOR + workEffort.get("workEffortId"); } try { diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java index 479cb73..0bfa025 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java @@ -718,8 +718,8 @@ public class ICalConverter { workEffortId = (String) context.get("workEffortId"); } if (!workEffortId.equals(context.get("workEffortId"))) { - Debug.logWarning("Spoof attempt: received calendar workEffortId " + workEffortId + - " on URL workEffortId " + context.get("workEffortId"), MODULE); + Debug.logWarning("Spoof attempt: received calendar workEffortId " + workEffortId + + " on URL workEffortId " + context.get("workEffortId"), MODULE); return ICalWorker.createForbiddenResponse(null); } Delegator delegator = (Delegator) context.get("delegator"); @@ -762,8 +762,8 @@ public class ICalConverter { replaceProperty(component.getProperties(), toXProperty(workEffortIdXPropName, workEffortId)); responseProps = storeWorkEffort(component, context); } else { - Debug.logWarning("Spoof attempt: unrelated workEffortId " + workEffortId + - " on URL workEffortId " + context.get("workEffortId"), MODULE); + Debug.logWarning("Spoof attempt: unrelated workEffortId " + workEffortId + + " on URL workEffortId " + context.get("workEffortId"), MODULE); responseProps = ICalWorker.createForbiddenResponse(null); } } else if (hasCreatePermission) { diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java index 8613d79..8bf4641 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalWorker.java @@ -310,8 +310,8 @@ public final class ICalWorker { private static void writeResponse(ResponseProperties responseProps, HttpServletRequest request, HttpServletResponse response, ServletContext context) throws IOException { if (Debug.verboseOn()) { - Debug.logVerbose("Returning response: code = " + responseProps.statusCode + - ", message = " + responseProps.statusMessage, MODULE); + Debug.logVerbose("Returning response: code = " + responseProps.statusCode + + ", message = " + responseProps.statusMessage, MODULE); } response.setStatus(responseProps.statusCode); if (responseProps.statusCode == HttpServletResponse.SC_UNAUTHORIZED) { |
Free forum by Nabble | Edit this page |