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 5f021ce Improved: Corrected line is longer than 150 characters checkstyle issues in applications component. (OFBIZ-11921) Also fixed some other extra space and naming related checkstyle issues observed. Thanks Jacques for review. 5f021ce is described below commit 5f021ce06b3ae593fb06f627a60168be01702c6a Author: Suraj Khurana <[hidden email]> AuthorDate: Fri Sep 4 12:24:14 2020 +0530 Improved: Corrected line is longer than 150 characters checkstyle issues in applications component. (OFBIZ-11921) Also fixed some other extra space and naming related checkstyle issues observed. Thanks Jacques for review. --- .../ofbiz/accounting/invoice/InvoiceServices.java | 4 +- .../ofbiz/accounting/invoice/InvoiceWorker.java | 33 +++++---- .../accounting/payment/BillingAccountWorker.java | 23 +++--- .../payment/GiftCertificateServices.java | 17 +++-- .../accounting/payment/PaymentMethodServices.java | 27 ++++--- .../ofbiz/accounting/payment/PaymentWorker.java | 20 ++++-- .../ofbiz/accounting/tax/TaxAuthorityServices.java | 5 +- .../accounting/thirdparty/eway/EwayServices.java | 13 ++-- .../thirdparty/gosoftware/RitaServices.java | 3 +- .../thirdparty/sagepay/SagePayServices.java | 9 ++- .../thirdparty/valuelink/ValueLinkServices.java | 8 ++- .../ofbiz/accounting/util/UtilAccounting.java | 7 +- .../ofbiz/content/ContentManagementEvents.java | 8 ++- .../ofbiz/content/ContentManagementServices.java | 3 +- .../ofbiz/content/ContentManagementWorker.java | 24 ++++--- .../ofbiz/content/cms/ContentJsonEvents.java | 3 +- .../ofbiz/content/compdoc/CompDocServices.java | 27 ++++--- .../ofbiz/content/content/ContentEvents.java | 6 +- .../ofbiz/content/content/ContentKeywordIndex.java | 24 ++++--- .../ofbiz/content/content/ContentMapFacade.java | 8 +-- .../content/content/ContentPermissionServices.java | 13 ++-- .../ofbiz/content/content/ContentSearch.java | 21 +++--- .../content/content/ContentServicesComplex.java | 17 +++-- .../content/content/UploadContentAndImage.java | 27 ++++--- .../org/apache/ofbiz/content/data/DataEvents.java | 18 +++-- .../apache/ofbiz/content/data/DataServices.java | 3 +- .../org/apache/ofbiz/content/ftp/FtpServices.java | 28 +++++--- .../apache/ofbiz/content/layout/LayoutEvents.java | 24 ++++--- .../ofbiz/content/output/OutputServices.java | 3 +- .../content/view/SimpleContentViewHandler.java | 19 +++-- .../webapp/ftl/CheckPermissionTransform.java | 9 ++- .../webapp/ftl/EditRenderSubContentTransform.java | 3 +- .../webapp/ftl/RenderSubContentTransform.java | 11 +-- .../apache/ofbiz/manufacturing/bom/BOMHelper.java | 3 +- .../apache/ofbiz/manufacturing/bom/BOMNode.java | 40 +++++++++-- .../ofbiz/manufacturing/bom/BOMServices.java | 46 ++++++++---- .../apache/ofbiz/manufacturing/bom/BOMTree.java | 56 +++++++++++---- .../jobshopmgt/ProductionRunHelper.java | 14 ++-- .../jobshopmgt/ProductionRunServices.java | 48 ++++++++----- .../mrp/InventoryEventPlannedServices.java | 3 +- .../ofbiz/manufacturing/mrp/ProposedOrder.java | 52 ++++++++------ .../manufacturing/routing/RoutingServices.java | 3 +- .../manufacturing/techdata/TechDataServices.java | 51 +++++++++----- .../org/apache/ofbiz/order/OrderManagerEvents.java | 18 +++-- .../ofbiz/order/order/OrderChangeHelper.java | 18 +++-- .../org/apache/ofbiz/order/order/OrderEvents.java | 6 +- .../apache/ofbiz/order/order/OrderReadHelper.java | 10 +-- .../ofbiz/order/order/OrderReturnServices.java | 3 +- .../apache/ofbiz/order/order/OrderServices.java | 25 ++++--- .../apache/ofbiz/order/quote/QuoteServices.java | 9 ++- .../ofbiz/order/shoppingcart/CheckOutEvents.java | 7 +- .../ofbiz/order/shoppingcart/CheckOutHelper.java | 14 ++-- .../ofbiz/order/shoppingcart/ShoppingCart.java | 17 +++-- .../ofbiz/order/shoppingcart/ShoppingCartItem.java | 18 +++-- .../shoppingcart/product/ProductDisplayWorker.java | 14 ++-- .../shoppingcart/product/ProductPromoWorker.java | 6 +- .../org/apache/ofbiz/order/task/TaskEvents.java | 9 ++- .../thirdparty/paypal/ExpressCheckoutEvents.java | 6 +- .../apache/ofbiz/party/contact/ContactHelper.java | 3 +- .../ofbiz/party/contact/ContactMechServices.java | 31 +++++--- .../ofbiz/party/contact/ContactMechWorker.java | 64 +++++++++++------ .../party/party/PartyRelationshipServices.java | 13 ++-- .../apache/ofbiz/party/party/PartyServices.java | 11 ++- .../ofbiz/product/catalog/CatalogWorker.java | 6 +- .../ofbiz/product/category/CatalogUrlServlet.java | 3 +- .../ofbiz/product/category/CategoryWorker.java | 55 +++++++++------ .../category/ftl/OfbizCatalogAltUrlTransform.java | 33 +++++++-- .../ofbiz/product/feature/ParametricSearch.java | 23 +++--- .../product/feature/ProductFeatureServices.java | 41 ++++++----- .../ofbiz/product/imagemanagement/CropImage.java | 14 ++-- .../product/imagemanagement/ReplaceImage.java | 33 ++++++--- .../ofbiz/product/imagemanagement/RotateImage.java | 16 +++-- .../apache/ofbiz/product/product/KeywordIndex.java | 31 +++++--- .../product/ProductPromoContentWrapper.java | 12 ++-- .../product/product/ProductSearchSession.java | 14 ++-- .../ofbiz/product/product/VariantEvents.java | 18 +++-- .../ofbiz/product/store/ProductStoreEvents.java | 9 ++- .../ofbiz/product/store/ProductStoreWorker.java | 81 ++++++++++++++------- .../product/subscription/SubscriptionServices.java | 40 +++++++---- .../product/supplier/SupplierProductServices.java | 8 ++- .../ofbiz/shipment/packing/PackingServices.java | 21 +++--- .../ofbiz/shipment/packing/PackingSessionLine.java | 3 +- .../ofbiz/shipment/shipment/ShipmentEvents.java | 13 ++-- .../ofbiz/shipment/shipment/ShipmentServices.java | 82 ++++++++++++++-------- .../ofbiz/shipment/shipment/ShipmentWorker.java | 24 ++++--- .../ofbiz/shipment/thirdparty/ups/UpsServices.java | 73 +++++++++++-------- .../weightPackage/WeightPackageServices.java | 40 +++++++---- .../ofbiz/workeffort/workeffort/ICalWorker.java | 10 +-- .../workeffort/WorkEffortKeywordIndex.java | 24 ++++--- .../workeffort/workeffort/WorkEffortWorker.java | 12 ++-- 90 files changed, 1180 insertions(+), 645 deletions(-) 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 e2eb95e..0c1d937 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 @@ -3741,8 +3741,8 @@ public class InvoiceServices { } if (isSalesInvoice && !invoice.get("partyIdFrom").equals(organizationPartyId)) { newErrMsgs.add("Line number " + rec.getRecordNumber() + ": A sales type invoice should have the partyId 'from' being " - + "the organizationPartyId(=" + organizationPartyId + ")! however is " + invoice.get("partyIdFrom") + "! invoice: " - + currentInvoiceId); + + "the organizationPartyId(=" + organizationPartyId + ")! however is " + invoice.get("partyIdFrom") + + "! invoice: " + currentInvoiceId); } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java index 1472b6a..ef5c2c7 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceWorker.java @@ -130,7 +130,8 @@ public final class InvoiceWorker { * @return the item description * @throws GenericEntityException */ - public static String getInvoiceItemDescription(LocalDispatcher dispatcher, GenericValue invoiceItem, Locale locale) throws GenericEntityException { + public static String getInvoiceItemDescription(LocalDispatcher dispatcher, GenericValue invoiceItem, Locale locale) + throws GenericEntityException { Delegator delegator = invoiceItem.getDelegator(); String description = invoiceItem.getString("description"); if (UtilValidate.isEmpty(description)) { @@ -196,7 +197,7 @@ public final class InvoiceWorker { * @param invoice GenericValue object of the Invoice * @return the invoice total as BigDecimal */ - public static BigDecimal getInvoiceTotal(GenericValue invoice) { + public static BigDecimal getInvoiceTotal(GenericValue invoice) { return getInvoiceTotal(invoice, Boolean.TRUE); } @@ -208,7 +209,7 @@ public final class InvoiceWorker { * false: if required convert the actual currency into the system currency. * @return Return the total amount of the invoice */ - public static BigDecimal getInvoiceTotal(GenericValue invoice, Boolean actualCurrency) { + public static BigDecimal getInvoiceTotal(GenericValue invoice, Boolean actualCurrency) { BigDecimal invoiceTotal = BigDecimal.ZERO; BigDecimal invoiceTaxTotal = InvoiceWorker.getInvoiceTaxTotal(invoice); @@ -296,7 +297,8 @@ public final class InvoiceWorker { // remaining code is the old method, which we leave here for compatibility purposes List<GenericValue> sendFromRoles = null; try { - sendFromRoles = invoice.getRelated("InvoiceRole", UtilMisc.toMap("roleTypeId", "BILL_FROM_VENDOR"), UtilMisc.toList("-datetimePerformed"), false); + sendFromRoles = invoice.getRelated("InvoiceRole", UtilMisc.toMap("roleTypeId", "BILL_FROM_VENDOR"), + UtilMisc.toList("-datetimePerformed"), false); } catch (GenericEntityException e) { Debug.logError(e, "Trouble getting InvoiceRole list", MODULE); } @@ -440,7 +442,8 @@ public final class InvoiceWorker { * @return the invoice total as BigDecimal */ public static BigDecimal getInvoiceNotApplied(Delegator delegator, String invoiceId, Boolean actualCurrency) { - return InvoiceWorker.getInvoiceTotal(delegator, invoiceId, actualCurrency).subtract(getInvoiceApplied(delegator, invoiceId, UtilDateTime.nowTimestamp(), actualCurrency)); + return InvoiceWorker.getInvoiceTotal(delegator, invoiceId, actualCurrency).subtract(getInvoiceApplied(delegator, + invoiceId, UtilDateTime.nowTimestamp(), actualCurrency)); } public static BigDecimal getInvoiceNotApplied(Delegator delegator, String invoiceId) { return InvoiceWorker.getInvoiceTotal(delegator, invoiceId).subtract(getInvoiceApplied(delegator, invoiceId)); @@ -608,7 +611,8 @@ public final class InvoiceWorker { GenericValue acctgTransEntry = (acctgTransEntries.get(0)).getRelated("AcctgTransEntry", null, null, false).get(0); BigDecimal origAmount = acctgTransEntry.getBigDecimal("origAmount"); if (origAmount.compareTo(BigDecimal.ZERO) == 1) { - conversionRate = acctgTransEntry.getBigDecimal("amount").divide(acctgTransEntry.getBigDecimal("origAmount"), new MathContext(100)).setScale(DECIMALS, ROUNDING); + conversionRate = acctgTransEntry.getBigDecimal("amount").divide(acctgTransEntry.getBigDecimal("origAmount"), + new MathContext(100)).setScale(DECIMALS, ROUNDING); } } // check if a payment is applied and use the currency conversion from there @@ -618,7 +622,8 @@ public final class InvoiceWorker { GenericValue payment = paymentAppl.getRelatedOne("Payment", false); if (UtilValidate.isNotEmpty(payment.getBigDecimal("actualCurrencyAmount"))) { if (UtilValidate.isEmpty(conversionRate)) { - conversionRate = payment.getBigDecimal("amount").divide(payment.getBigDecimal("actualCurrencyAmount"), new MathContext(100)).setScale(DECIMALS, ROUNDING); + conversionRate = payment.getBigDecimal("amount").divide(payment.getBigDecimal("actualCurrencyAmount"), + new MathContext(100)).setScale(DECIMALS, ROUNDING); } else { conversionRate = conversionRate.add(payment.getBigDecimal("amount").divide(payment.getBigDecimal("actualCurrencyAmount"), new MathContext(100))).divide(new BigDecimal("2"), new MathContext(100)).setScale(DECIMALS, ROUNDING); @@ -628,7 +633,8 @@ public final class InvoiceWorker { } // use the dated conversion entity if (UtilValidate.isEmpty(conversionRate)) { - GenericValue rate = EntityQuery.use(delegator).from("UomConversionDated").where("uomIdTo", invoice.get("currencyUomId"), "uomId", otherCurrencyUomId).filterByDate(invoice.getTimestamp("invoiceDate")).queryFirst(); + GenericValue rate = EntityQuery.use(delegator).from("UomConversionDated").where("uomIdTo", invoice.get("currencyUomId"), + "uomId", otherCurrencyUomId).filterByDate(invoice.getTimestamp("invoiceDate")).queryFirst(); if (rate != null) { conversionRate = BigDecimal.ONE.divide(rate.getBigDecimal("conversionFactor"), new MathContext(100)).setScale(DECIMALS, ROUNDING); } else { @@ -693,13 +699,15 @@ public final class InvoiceWorker { } if (UtilValidate.isNotEmpty(invoiceItems)) { invoiceItems = EntityUtil.orderBy(invoiceItems, UtilMisc.toList("taxAuthGeoId", "taxAuthPartyId")); - // get the list of all distinct taxAuthGeoId and taxAuthPartyId. It is for getting the number of taxAuthGeoId and taxAuthPartyId in invoiceItems. + // get the list of all distinct taxAuthGeoId and taxAuthPartyId. It is for getting the number of + // taxAuthGeoId and taxAuthPartyId in invoiceItems. List<String> distinctTaxAuthGeoIdList = EntityUtil.getFieldListFromEntityList(invoiceItems, "taxAuthGeoId", true); List<String> distinctTaxAuthPartyIdList = EntityUtil.getFieldListFromEntityList(invoiceItems, "taxAuthPartyId", true); for (String taxAuthGeoId : distinctTaxAuthGeoIdList) { for (String taxAuthPartyId : distinctTaxAuthPartyIdList) { //get all records for invoices filtered by taxAuthGeoId and taxAurhPartyId - List<GenericValue> invoiceItemsByTaxAuthGeoAndPartyIds = EntityUtil.filterByAnd(invoiceItems, UtilMisc.toMap("taxAuthGeoId", taxAuthGeoId, "taxAuthPartyId", taxAuthPartyId)); + List<GenericValue> invoiceItemsByTaxAuthGeoAndPartyIds = EntityUtil.filterByAnd(invoiceItems, + UtilMisc.toMap("taxAuthGeoId", taxAuthGeoId, "taxAuthPartyId", taxAuthPartyId)); if (UtilValidate.isNotEmpty(invoiceItemsByTaxAuthGeoAndPartyIds)) { BigDecimal totalAmount = BigDecimal.ZERO; //Now for each invoiceItem record get and add amount. @@ -711,7 +719,8 @@ public final class InvoiceWorker { totalAmount = totalAmount.add(amount).setScale(TAX_DECIMALS, TAX_ROUNDING); } totalAmount = totalAmount.setScale(TAX_DECIMALS, TAX_ROUNDING); - taxByTaxAuthGeoAndPartyList.add(UtilMisc.<String, Object>toMap("taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", taxAuthGeoId, "totalAmount", totalAmount)); + taxByTaxAuthGeoAndPartyList.add(UtilMisc.<String, Object>toMap("taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", + taxAuthGeoId, "totalAmount", totalAmount)); taxGrandTotal = taxGrandTotal.add(totalAmount); } } @@ -730,7 +739,7 @@ public final class InvoiceWorker { * @return A Map containing the each taxAuthPartyId as a key and a Set of taxAuthGeoIds for that taxAuthPartyId as the values. Note this method * will not account for tax lines that do not contain a taxAuthPartyId */ - public static Map<String, Set<String>> getInvoiceTaxAuthPartyAndGeos (GenericValue invoice) { + public static Map<String, Set<String>> getInvoiceTaxAuthPartyAndGeos(GenericValue invoice) { Map<String, Set<String>> result = new HashMap<>(); if (invoice == null) { diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java index 6286ae8..07021b5 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/BillingAccountWorker.java @@ -59,13 +59,16 @@ public final class BillingAccountWorker { protected BillingAccountWorker() { } - public static List<Map<String, Object>> makePartyBillingAccountList(GenericValue userLogin, String currencyUomId, String partyId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException { + public static List<Map<String, Object>> makePartyBillingAccountList(GenericValue userLogin, String currencyUomId, String partyId, + Delegator delegator, LocalDispatcher dispatcher) throws GeneralException { List<Map<String, Object>> billingAccountList = new LinkedList<>(); - Map<String, Object> agentResult = dispatcher.runSync("getRelatedParties", UtilMisc.<String, Object>toMap("userLogin", userLogin, "partyIdFrom", partyId, - "roleTypeIdFrom", "AGENT", "roleTypeIdTo", "CUSTOMER", "partyRelationshipTypeId", "AGENT", "includeFromToSwitched", "Y")); + Map<String, Object> agentResult = dispatcher.runSync("getRelatedParties", UtilMisc.<String, Object>toMap("userLogin", userLogin, + "partyIdFrom", partyId, "roleTypeIdFrom", "AGENT", "roleTypeIdTo", "CUSTOMER", "partyRelationshipTypeId", "AGENT", + "includeFromToSwitched", "Y")); if (ServiceUtil.isError(agentResult)) { - throw new GeneralException("Error while finding party BillingAccounts when getting Customers that this party is an agent of: " + ServiceUtil.getErrorMessage(agentResult)); + throw new GeneralException("Error while finding party BillingAccounts when getting Customers that this party is an agent of: " + + ServiceUtil.getErrorMessage(agentResult)); } List<String> relatedPartyIdList = UtilGenerics.cast(agentResult.get("relatedPartyIdList")); @@ -113,7 +116,8 @@ public final class BillingAccountWorker { } /** - * Returns the amount which could be charged to a billing account, which is defined as the accountLimit minus account balance and minus the balance of outstanding orders + * Returns the amount which could be charged to a billing account, which is defined as the accountLimit minus account balance and minus + * the balance of outstanding orders * When trying to figure out how much of a billing account can be used to pay for an outstanding order, use this method * @param billingAccount GenericValue object of the billing account * @return returns the amount which could be charged to a billing account @@ -122,7 +126,8 @@ public final class BillingAccountWorker { public static BigDecimal getBillingAccountAvailableBalance(GenericValue billingAccount) throws GenericEntityException { if ((billingAccount != null) && (billingAccount.get("accountLimit") != null)) { BigDecimal accountLimit = billingAccount.getBigDecimal("accountLimit"); - BigDecimal availableBalance = accountLimit.subtract(OrderReadHelper.getBillingAccountBalance(billingAccount)).setScale(DECIMALS, ROUNDING); + BigDecimal availableBalance = accountLimit.subtract(OrderReadHelper.getBillingAccountBalance(billingAccount)) + .setScale(DECIMALS, ROUNDING); return availableBalance; } Debug.logWarning("Available balance requested for null billing account, returning zero", MODULE); @@ -135,7 +140,8 @@ public final class BillingAccountWorker { } /** - * Calculates the net balance of a billing account, which is sum of all amounts applied to invoices minus sum of all amounts applied from payments. + * Calculates the net balance of a billing account, which is sum of all amounts applied to invoices minus sum of all amounts + * applied from payments. * When charging or capturing an invoice to a billing account, use this method * @param delegator the delegator * @param billingAccountId the billing account id @@ -146,7 +152,8 @@ public final class BillingAccountWorker { BigDecimal balance = ZERO; // search through all PaymentApplications and add the amount that was applied to invoice and subtract the amount applied from payments - List<GenericValue> paymentAppls = EntityQuery.use(delegator).from("PaymentApplication").where("billingAccountId", billingAccountId).queryList(); + List<GenericValue> paymentAppls = EntityQuery.use(delegator).from("PaymentApplication").where("billingAccountId", + billingAccountId).queryList(); for (GenericValue paymentAppl : paymentAppls) { BigDecimal amountApplied = paymentAppl.getBigDecimal("amountApplied"); GenericValue invoice = paymentAppl.getRelatedOne("Invoice", false); 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 0032a12..1a566ab 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 @@ -127,7 +127,8 @@ public class GiftCertificateServices { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(acctResult)); } if (acctResult.get("finAccountId") != null) { - finAccountId = cardNumber = (String) acctResult.get("finAccountId"); + cardNumber = (String) acctResult.get("finAccountId"); + finAccountId = cardNumber; } if (acctResult.get("finAccountCode") != null) { cardNumber = (String) acctResult.get("finAccountCode"); @@ -482,7 +483,8 @@ public class GiftCertificateServices { OrderReadHelper orh = new OrderReadHelper(delegator, orderId); String productStoreId = orh.getProductStoreId(); try { - // if the store requires pin codes, then validate pin code against card number, and the gift certificate's finAccountId is the gift card's card number + // if the store requires pin codes, then validate pin code against card number, and the gift certificate's finAccountId is the + // gift card's card number // otherwise, the gift card's card number is an ecrypted string, which must be decoded to find the FinAccount GenericValue giftCertSettings = EntityQuery.use(delegator).from("ProductStoreFinActSetting") .where("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.getGiftCertFinAccountTypeId()) @@ -523,7 +525,8 @@ public class GiftCertificateServices { UtilMisc.toMap("thruDate", finAccount.getTimestamp("thruDate")), locale)); } - // check the amount to authorize against the available balance of fin account, which includes active authorizations as well as transactions + // check the amount to authorize against the available balance of fin account, which includes active authorizations as well as + // transactions BigDecimal availableBalance = finAccount.getBigDecimal("availableBalance"); Boolean processResult = null; String refNum = null; @@ -880,7 +883,8 @@ public class GiftCertificateServices { GenericValue productStoreEmail = null; String emailType = "PRDS_GC_PURCHASE"; try { - productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", emailType).queryOne(); + productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, + "emailType", emailType).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get product store email setting for gift card purchase", MODULE); } @@ -1108,7 +1112,8 @@ public class GiftCertificateServices { GenericValue productStoreEmail = null; String emailType = "PRDS_GC_RELOAD"; try { - productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", emailType).queryOne(); + productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", + emailType).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get product store email setting for gift card purchase", MODULE); } @@ -1376,7 +1381,7 @@ public class GiftCertificateServices { } if (ServiceUtil.isError(payResult)) { throw new GeneralException(ServiceUtil.getErrorMessage(payResult)); - } + } paymentId = (String) payResult.get("paymentId"); 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 33fe65a..c2b5171 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 @@ -89,7 +89,8 @@ public class PaymentMethodServices { // <b>security check</b>: userLogin partyId must equal paymentMethod partyId, or must have PAY_INFO_DELETE permission if (paymentMethod.get("partyId") == null || !paymentMethod.getString("partyId").equals(userLogin.getString("partyId"))) { - if (!security.hasEntityPermission("PAY_INFO", "_DELETE", userLogin) && !security.hasEntityPermission("ACCOUNTING", "_DELETE", userLogin)) { + if (!security.hasEntityPermission("PAY_INFO", "_DELETE", userLogin) + && !security.hasEntityPermission("ACCOUNTING", "_DELETE", userLogin)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "AccountingPaymentMethodNoPermissionToDelete", locale)); } @@ -227,7 +228,8 @@ public class PaymentMethodServices { if (tempVal == null) { // no value found, create a new one newPartyContactMechPurpose = delegator.makeValue("PartyContactMechPurpose", - UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId, "fromDate", now)); + UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", + contactMechPurposeTypeId, "fromDate", now)); } } @@ -264,7 +266,8 @@ public class PaymentMethodServices { Timestamp now = UtilDateTime.nowTimestamp(); - String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_UPDATE", "ACCOUNTING", "_UPDATE"); + String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_UPDATE", + "ACCOUNTING", "_UPDATE"); if (!result.isEmpty()) { return result; @@ -292,7 +295,8 @@ public class PaymentMethodServices { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingCreditCardUpdateWithPaymentMethodId", locale) + paymentMethodId); } - if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin) && !security.hasEntityPermission("ACCOUNTING", "_UPDATE", userLogin)) { + 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, "paymentMethodId", paymentMethodId), locale)); @@ -407,7 +411,8 @@ public class PaymentMethodServices { if (tempVal == null) { // no value found, create a new one newPartyContactMechPurpose = delegator.makeValue("PartyContactMechPurpose", - UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId, "fromDate", now)); + UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", + contactMechPurposeTypeId, "fromDate", now)); } } @@ -585,7 +590,8 @@ public class PaymentMethodServices { "AccountingGiftCardCannotBeUpdated", UtilMisc.toMap("errorString", paymentMethodId), locale)); } - if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin) && !security.hasEntityPermission("ACCOUNTING", "_UPDATE", userLogin)) { + if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin) + && !security.hasEntityPermission("ACCOUNTING", "_UPDATE", userLogin)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "AccountingGiftCardPartyNotAuthorized", UtilMisc.toMap("partyId", partyId, "paymentMethodId", paymentMethodId), locale)); @@ -823,7 +829,8 @@ public class PaymentMethodServices { "AccountingEftAccountCannotBeUpdated", UtilMisc.toMap("errorString", paymentMethodId), locale)); } - if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin) && !security.hasEntityPermission("ACCOUNTING", "_UPDATE", userLogin)) { + if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin) + && !security.hasEntityPermission("ACCOUNTING", "_UPDATE", userLogin)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "AccountingEftAccountCannotBeUpdated", UtilMisc.toMap("partyId", partyId, "paymentMethodId", paymentMethodId), locale)); @@ -1002,7 +1009,8 @@ public class PaymentMethodServices { delegator.storeAll(toBeStored); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "AccountingCheckNotAdded", UtilMisc.toMap("errorString", e.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "AccountingCheckNotAdded", + UtilMisc.toMap("errorString", e.getMessage()), locale)); } result.put("paymentMethodId", newPm.getString("paymentMethodId")); @@ -1050,7 +1058,8 @@ public class PaymentMethodServices { "AccountingCheckAccountCannotBeUpdated", UtilMisc.toMap("errorString", paymentMethodId), locale)); } - if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin) && !security.hasEntityPermission("ACCOUNTING", "_UPDATE", userLogin)) { + if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin) + && !security.hasEntityPermission("ACCOUNTING", "_UPDATE", userLogin)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "AccountingCheckAccountCannotBeUpdated", UtilMisc.toMap("partyId", partyId, "paymentMethodId", paymentMethodId), locale)); 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 209a1fd..6748c65 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 @@ -179,7 +179,7 @@ public final class PaymentWorker { curContactMechId = UtilFormatOut.checkNull(tryEntity ? giftCard.getString("contactMechId") : request.getParameter("contactMechId")); } else if (eftAccount != null) { curContactMechId = UtilFormatOut.checkNull(tryEntity ? eftAccount.getString("contactMechId") : request.getParameter("contactMechId")); - } else if (checkAccount != null) { + } else if (checkAccount != null) { curContactMechId = UtilFormatOut.checkNull(tryEntity ? checkAccount.getString("contactMechId") : request.getParameter("contactMechId")); } if (curContactMechId != null) { @@ -206,7 +206,8 @@ public final class PaymentWorker { GenericValue postalAddress = null; if (purpose != null) { try { - postalAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", purpose.getString("contactMechId")).queryOne(); + postalAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", + purpose.getString("contactMechId")).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Trouble getting PostalAddress record for contactMechId: " + purpose.getString("contactMechId"), MODULE); } @@ -274,10 +275,12 @@ public final class PaymentWorker { appliedAmount = paymentApplication.getBigDecimal("amountApplied"); if (paymentApplication.get("paymentId") != null) { GenericValue payment = paymentApplication.getRelatedOne("Payment", false); - if (paymentApplication.get("invoiceId") != null && payment.get("actualCurrencyAmount") != null && payment.get("actualCurrencyUomId") != null) { + if (paymentApplication.get("invoiceId") != null && payment.get("actualCurrencyAmount") != null + && payment.get("actualCurrencyUomId") != null) { GenericValue invoice = paymentApplication.getRelatedOne("Invoice", false); if (payment.getString("actualCurrencyUomId").equals(invoice.getString("currencyUomId"))) { - appliedAmount = appliedAmount.multiply(payment.getBigDecimal("amount")).divide(payment.getBigDecimal("actualCurrencyAmount"), new MathContext(100)); + appliedAmount = appliedAmount.multiply(payment.getBigDecimal("amount")) + .divide(payment.getBigDecimal("actualCurrencyAmount"), new MathContext(100)); } } } @@ -310,15 +313,18 @@ public final class PaymentWorker { EntityCondition.makeCondition("paymentId", EntityOperator.EQUALS, payment.getString("paymentId")), EntityCondition.makeCondition("toPaymentId", EntityOperator.EQUALS, payment.getString("paymentId"))); EntityCondition partyCond = EntityCondition.makeCondition(cond, EntityOperator.OR); - paymentApplications = payment.getDelegator().findList("PaymentApplication", partyCond, null, UtilMisc.toList("invoiceId", "billingAccountId"), null, false); + paymentApplications = payment.getDelegator().findList("PaymentApplication", partyCond, null, + UtilMisc.toList("invoiceId", "billingAccountId"), null, false); if (UtilValidate.isNotEmpty(paymentApplications)) { for (GenericValue paymentApplication : paymentApplications) { BigDecimal amountApplied = paymentApplication.getBigDecimal("amountApplied"); // check currency invoice and if different convert amount applied for display - if (actual.equals(Boolean.FALSE) && paymentApplication.get("invoiceId") != null && payment.get("actualCurrencyAmount") != null && payment.get("actualCurrencyUomId") != null) { + if (actual.equals(Boolean.FALSE) && paymentApplication.get("invoiceId") != null && payment.get("actualCurrencyAmount") != null + && payment.get("actualCurrencyUomId") != null) { GenericValue invoice = paymentApplication.getRelatedOne("Invoice", false); if (payment.getString("actualCurrencyUomId").equals(invoice.getString("currencyUomId"))) { - amountApplied = amountApplied.multiply(payment.getBigDecimal("amount")).divide(payment.getBigDecimal("actualCurrencyAmount"), new MathContext(100)); + amountApplied = amountApplied.multiply(payment.getBigDecimal("amount")) + .divide(payment.getBigDecimal("actualCurrencyAmount"), new MathContext(100)); } } paymentApplied = paymentApplied.add(amountApplied).setScale(DECIMALS, ROUNDING_MODE); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java index cc92b6d..1cfd26f 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/tax/TaxAuthorityServices.java @@ -575,9 +575,8 @@ public class TaxAuthorityServices { handlePartyTaxExempt(taxAdjValue, billToPartyIdSet, taxAuthGeoId, taxAuthPartyId, taxAmount, nowTimestamp, delegator); } else { - Debug.logInfo( - "NOTE: A tax calculation was done without a billToPartyId or taxAuthGeoId, so no tax exemptions or tax IDs considered; billToPartyId=[" - + billToPartyId + "] taxAuthGeoId=[" + taxAuthGeoId + "]", MODULE); + Debug.logInfo("NOTE: A tax calculation was done without a billToPartyId or taxAuthGeoId, so no tax exemptions or tax IDs " + + "considered; billToPartyId=[" + billToPartyId + "] taxAuthGeoId=[" + taxAuthGeoId + "]", MODULE); } if (discountedSalesTax.compareTo(BigDecimal.ZERO) < 0) { GenericValue taxAdjValueNegative = delegator.makeValue("OrderAdjustment"); 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 6aba66a..bce59eb 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 @@ -76,7 +76,8 @@ public class EwayServices { // billing address if (address != null) { - String street = address.getString("address1") + ((UtilValidate.isNotEmpty(address.getString("address2"))) ? " " + address.getString("address2") : ""); + String street = address.getString("address1") + ((UtilValidate.isNotEmpty(address.getString("address2"))) ? " " + + address.getString("address2") : ""); req.setCustomerAddress(street); req.setCustomerPostcode(address.getString("postalCode")); req.setCustomerBillingCountry(address.getString("countryGeoId")); @@ -86,7 +87,7 @@ public class EwayServices { GatewayConnector con = new GatewayConnector(); GatewayResponse reply; try { - reply = con.sendRequest(req); + reply = con.sendRequest(req); } catch (Exception e) { return ServiceUtil.returnError(e.getMessage()); } @@ -151,7 +152,7 @@ public class EwayServices { GatewayConnector con = new GatewayConnector(); GatewayResponse reply; try { - reply = con.sendRequest(req); + reply = con.sendRequest(req); } catch (Exception e) { return ServiceUtil.returnError(e.getMessage()); } @@ -212,7 +213,7 @@ public class EwayServices { GatewayConnector con = new GatewayConnector(); GatewayResponse reply; try { - reply = con.sendRequest(req); + reply = con.sendRequest(req); } catch (Exception e) { return ServiceUtil.returnError(e.getMessage()); } @@ -238,8 +239,8 @@ public class EwayServices { Boolean cvn = "Y".equalsIgnoreCase(getPaymentGatewayConfigValue(delegator, pgcId, "enableCvn", cfgStr, "payment.eway.enableCvn")); // the request mode - int requestMode = refund ? GatewayRequest.REQUEST_METHOD_REFUND : beagle - ? GatewayRequest.REQUEST_METHOD_BEAGLE : cvn ? GatewayRequest.REQUEST_METHOD_CVN : 0; + int requestMode = refund ? GatewayRequest.REQUEST_METHOD_REFUND : beagle ? GatewayRequest.REQUEST_METHOD_BEAGLE : cvn + ? GatewayRequest.REQUEST_METHOD_CVN : 0; // create the request object GatewayRequest req = new GatewayRequest(requestMode); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java index ec6d58e..a6ae527 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java @@ -377,7 +377,8 @@ public class RitaServices { GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference"); GenericValue creditCard = (GenericValue) context.get("creditCard"); if (creditCard == null) { - creditCard = EntityQuery.use(delegator).from("CreditCard").where("paymentMethodId", orderPaymentPreference.getString("paymentMethodId")).queryOne(); + creditCard = EntityQuery.use(delegator).from("CreditCard").where("paymentMethodId", orderPaymentPreference.getString("paymentMethodId")) + .queryOne(); } if (creditCard != null) { List<String> expDateList = StringUtil.split(creditCard.getString("expireDate"), "/"); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/sagepay/SagePayServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/sagepay/SagePayServices.java index ac9950f..bdbf54a 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/sagepay/SagePayServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/sagepay/SagePayServices.java @@ -360,15 +360,18 @@ public class SagePayServices { } catch (UnsupportedEncodingException uee) { //exception in encoding parameters in httpPost Debug.logError(uee, "Error occurred in encoding parameters for HttpPost (" + uee.getMessage() + ")", MODULE); - resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorEncodingParameters", UtilMisc.toMap("errorString", uee.getMessage()), locale)); + resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorEncodingParameters", + UtilMisc.toMap("errorString", uee.getMessage()), locale)); } catch (ClientProtocolException cpe) { //from httpClient execute Debug.logError(cpe, "Error occurred in HttpClient execute(" + cpe.getMessage() + ")", MODULE); - resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecute", UtilMisc.toMap("errorString", cpe.getMessage()), locale)); + resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecute", + UtilMisc.toMap("errorString", cpe.getMessage()), locale)); } catch (IOException ioe) { //from httpClient execute or getResponsedata Debug.logError(ioe, "Error occurred in HttpClient execute or getting response (" + ioe.getMessage() + ")", MODULE); - resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecuteOrGettingResponse", UtilMisc.toMap("errorString", ioe.getMessage()), locale)); + resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecuteOrGettingResponse", + UtilMisc.toMap("errorString", ioe.getMessage()), locale)); } return resultMap; } 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 cf8ac52..1bf44d7 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 @@ -755,7 +755,7 @@ public class ValueLinkServices { String paymentConfig = (String) context.get("paymentConfig"); String currency = (String) context.get("currency"); String orderId = (String) context.get("orderId"); - BigDecimal amount = (BigDecimal) context.get("processAmount"); + BigDecimal amount = (BigDecimal) context.get("processAmount"); // make sure we have a currency if (currency == null) { @@ -1188,7 +1188,8 @@ public class ValueLinkServices { GenericValue productStoreEmail = null; String emailType = "PRDS_GC_PURCHASE"; try { - productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", emailType).queryOne(); + productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, + "emailType", emailType).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get product store email setting for gift card purchase", MODULE); } @@ -1431,7 +1432,8 @@ public class ValueLinkServices { GenericValue productStoreEmail = null; String emailType = "PRDS_GC_RELOAD"; try { - productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", emailType).queryOne(); + productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", + emailType).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get product store email setting for gift card purchase", 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 89ab9d8..cb1137f 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 @@ -179,8 +179,8 @@ public final class UtilAccounting { String parentClassId = glAccountClass.getString("parentClassId"); // otherwise, we have to go to the grandparent (recurse) - return !(parentClassId == null) - && (parentClassId.equals(parentGlAccountClassId) || isAccountClassClass(glAccountClass.getRelatedOne("ParentGlAccountClass", true), parentGlAccountClassId)); + return !(parentClassId == null) && (parentClassId.equals(parentGlAccountClassId) + || isAccountClassClass(glAccountClass.getRelatedOne("ParentGlAccountClass", true), parentGlAccountClassId)); } /** @@ -314,7 +314,8 @@ public final class UtilAccounting { EntityCondition.makeCondition("acctgTransTypeId", "OUTGOING_PAYMENT"), EntityCondition.makeCondition("paymentId", paymentApplication.getString("paymentId"))); EntityCondition whereCondition = EntityCondition.makeCondition(andConditions, EntityJoinOperator.AND); - GenericValue amounts = EntityQuery.use(delegator).select("origAmount", "amount").from("AcctgTransAndEntries").where(whereCondition).queryFirst(); + GenericValue amounts = EntityQuery.use(delegator).select("origAmount", "amount").from("AcctgTransAndEntries") + .where(whereCondition).queryFirst(); if (amounts == null) { return exchangeRate; } 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 80489fc..cbe2532 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 @@ -72,7 +72,8 @@ public class ContentManagementEvents { List<Map<String, Object>> valueList = null; try { allPublishPointList = ContentManagementWorker.getAllPublishPoints(delegator, webSiteId); - permittedPublishPointList = ContentManagementWorker.getPermittedPublishPoints(delegator, allPublishPointList, userLogin, security, "_ADMIN", null, null); + permittedPublishPointList = ContentManagementWorker.getPermittedPublishPoints(delegator, allPublishPointList, userLogin, + security, "_ADMIN", null, null); valueList = ContentManagementWorker.getStaticValues(delegator, parentPlaceholderId, permittedPublishPointList); } catch (GeneralException e) { Debug.logError(e.getMessage(), MODULE); @@ -86,7 +87,7 @@ public class ContentManagementEvents { for (String[] pubArr : permittedPublishPointList) { String pubContentId = pubArr[0]; String pubValue = (String) map.get(pubContentId); - String paramName = Integer.toString(counter) + "_" + pubContentId; + String paramName = Integer.toString(counter) + "_" + pubContentId; String paramValue = (String) paramMap.get(paramName); Map<String, Object> serviceIn = new HashMap<>(); serviceIn.put("userLogin", userLogin); @@ -189,7 +190,8 @@ public class ContentManagementEvents { try { // TODO: this needs to be given author userLogin EntityQuery.use(delegator).from("UserLogin").where("userLoginId", authorId).cache().queryOne(); - origPublishedLinkList = ContentManagementWorker.getPublishedLinks(delegator, targContentId, webSiteId, userLogin, security, permittedAction, permittedOperations, roles); + origPublishedLinkList = ContentManagementWorker.getPublishedLinks(delegator, targContentId, webSiteId, userLogin, security, + permittedAction, permittedOperations, roles); } catch (GeneralException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java index 8c74a75..1bf8704 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementServices.java @@ -1213,7 +1213,8 @@ public class ContentManagementServices { return retVal; } - public static Map<String, Object> initContentChildCounts(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException { + public static Map<String, Object> initContentChildCounts(DispatchContext dctx, Map<String, ? extends Object> context) + throws GenericServiceException { Map<String, Object> result = new HashMap<>(); Locale locale = (Locale) context.get("locale"); GenericValue content = (GenericValue) context.get("content"); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementWorker.java index fe012d5..472d396 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementWorker.java @@ -406,9 +406,9 @@ public final class ContentManagementWorker { public static GenericValue getWebSitePublishPoint(Delegator delegator, String contentId, boolean ignoreCache) throws GenericEntityException { GenericValue webSitePublishPoint = null; - if (!ignoreCache) + if (!ignoreCache) { webSitePublishPoint = cachedWebSitePublishPoints.get(contentId); - + } if (webSitePublishPoint == null) { webSitePublishPoint = EntityQuery.use(delegator).from("WebSitePublishPoint").where("contentId", contentId).queryOne(); // If no webSitePublishPoint exists, still try to look for parent by making a dummy value @@ -456,7 +456,8 @@ public final class ContentManagementWorker { return contentIdTo; } - public static GenericValue getStaticValue(Delegator delegator, String parentPlaceholderId, String webSitePublishPointId, boolean ignoreCache) throws GenericEntityException { + public static GenericValue getStaticValue(Delegator delegator, String parentPlaceholderId, String webSitePublishPointId, boolean ignoreCache) + throws GenericEntityException { GenericValue webSitePublishPoint = null; if (!ignoreCache) { Map<String, Object> subStaticValueMap = cachedStaticValues.get(parentPlaceholderId); @@ -470,7 +471,8 @@ public final class ContentManagementWorker { } public static List<Object[]> getPublishedLinks(Delegator delegator, String targContentId, String rootPubId, GenericValue userLogin, - Security security, String permittedAction, String permittedOperations, String passedRoles) throws GeneralException { + Security security, String permittedAction, String permittedOperations, String passedRoles) + throws GeneralException { // Set up one map with all the top-level publish points (to which only one sub point can be attached to) // and another map (publishPointMapAll) that points to one of the top-level points. List<GenericValue> allPublishPointList = getAllPublishPoints(delegator, rootPubId); @@ -568,8 +570,9 @@ public final class ContentManagementWorker { // TODO check if we want statusId to be filled/used, else this should be removed String statusId = null; String entityAction = permittedAction; - if (entityAction == null) + if (entityAction == null) { entityAction = "_ADMIN"; + } List<String> passedPurposes = UtilMisc.<String>toList("ARTICLE"); List<String> roles = StringUtil.split(passedRoles, "|"); List<String> targetOperationList = new LinkedList<>(); @@ -627,9 +630,9 @@ public final class ContentManagementWorker { public static int updateStatsTopDown(Delegator delegator, String contentId, List<String> typeList) throws GenericEntityException { int subLeafCount = 0; GenericValue thisContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); - if (thisContent == null) + if (thisContent == null) { throw new RuntimeException("No entity found for id=" + contentId); - + } List<EntityCondition> conditionMain = new ArrayList<>(); conditionMain.add(EntityCondition.makeCondition("contentIdTo", contentId)); if (!typeList.isEmpty()) { @@ -643,8 +646,9 @@ public final class ContentManagementWorker { } // If no children, count this as a leaf - if (subLeafCount == 0) + if (subLeafCount == 0) { subLeafCount = 1; + } thisContent.put("childBranchCount", (long) contentAssocs.size()); thisContent.put("childLeafCount", (long) subLeafCount); thisContent.store(); @@ -655,9 +659,9 @@ public final class ContentManagementWorker { public static void updateStatsBottomUp(Delegator delegator, String contentId, List<String> typeList, int branchChangeAmount, int leafChangeAmount) throws GenericEntityException { GenericValue thisContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); - if (thisContent == null) + if (thisContent == null) { throw new RuntimeException("No entity found for id=" + contentId); - + } List<GenericValue> contentAssocs = EntityQuery.use(delegator).from("ContentAssoc") .where(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList), EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId)) diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java index 84593db..5b000a6 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java @@ -99,7 +99,8 @@ public class ContentJsonEvents { contentAssocTypeId, "fromDate", fromDate) .queryOne(); if (oldAssoc == null) { - throw new GenericEntityNotFoundException("Could not find ContentAssoc by primary key [contentIdTo: $contentIdTo, contentId: $contentIdFrom, contentAssocTypeId: $contentAssocTypeId, fromDate: $fromDate]"); + throw new GenericEntityNotFoundException("Could not find ContentAssoc by primary key [contentIdTo: $contentIdTo, contentId: " + + "$contentIdFrom, contentAssocTypeId: $contentAssocTypeId, fromDate: $fromDate]"); } GenericValue newAssoc = (GenericValue) oldAssoc.clone(); 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 0d13d4e..6e569d0 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 @@ -115,7 +115,8 @@ public class CompDocServices { Map<String, Object> persistRevResult = dispatcher.runSync("persistContentRevisionAndItem", contentRevisionMap); if (ServiceUtil.isError(persistRevResult)) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentContentCreatingError", UtilMisc.toMap("serviceName", "persistContentRevisionAndItem"), locale), null, null, persistRevResult); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentContentCreatingError", + UtilMisc.toMap("serviceName", "persistContentRevisionAndItem"), locale), null, null, persistRevResult); } result.putAll(persistRevResult); @@ -198,16 +199,19 @@ public class CompDocServices { if (survey != null) { acroFormContentId = survey.getString("acroFormContentId"); if (UtilValidate.isNotEmpty(acroFormContentId)) { - // TODO: is something supposed to be done here? + // TODO: is something supposed to be done here? Adding loginfo to avoid checkstyle + Debug.logInfo("AcroFormContentId:" + acroFormContentId, MODULE); } } } if (surveyResponse != null) { if (UtilValidate.isEmpty(acroFormContentId)) { // Create AcroForm PDF - Map<String, Object> survey2PdfResults = dispatcher.runSync("buildPdfFromSurveyResponse", UtilMisc.toMap("surveyResponseId", surveyId)); + Map<String, Object> survey2PdfResults = dispatcher.runSync("buildPdfFromSurveyResponse", + UtilMisc.toMap("surveyResponseId", surveyId)); if (ServiceUtil.isError(survey2PdfResults)) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentSurveyErrorBuildingPDF", locale), null, null, survey2PdfResults); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentSurveyErrorBuildingPDF", locale), + null, null, survey2PdfResults); } ByteBuffer outByteBuffer = (ByteBuffer) survey2PdfResults.get("outByteBuffer"); @@ -215,9 +219,11 @@ public class CompDocServices { reader = new PdfReader(inputByteArray); } 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"); @@ -319,7 +325,8 @@ public class CompDocServices { if (survey != null) { acroFormContentId = survey.getString("acroFormContentId"); if (UtilValidate.isNotEmpty(acroFormContentId)) { - // TODO: is something supposed to be done here? + // TODO: is something supposed to be done here? Adding loginfo to avoid checkstyle + Debug.logInfo("AcroFormContentId:" + acroFormContentId, MODULE); } } } @@ -327,9 +334,11 @@ public class CompDocServices { if (surveyResponse != null) { if (UtilValidate.isEmpty(acroFormContentId)) { // Create AcroForm PDF - Map<String, Object> survey2PdfResults = dispatcher.runSync("buildPdfFromSurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId)); + Map<String, Object> survey2PdfResults = dispatcher.runSync("buildPdfFromSurveyResponse", + UtilMisc.toMap("surveyResponseId", surveyResponseId)); if (ServiceUtil.isError(survey2PdfResults)) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentSurveyErrorBuildingPDF", locale), null, null, survey2PdfResults); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentSurveyErrorBuildingPDF", locale), null, + null, survey2PdfResults); } ByteBuffer outByteBuffer = (ByteBuffer) survey2PdfResults.get("outByteBuffer"); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentEvents.java index 74a8c99..85b6dd6 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentEvents.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentEvents.java @@ -118,13 +118,15 @@ public class ContentEvents { if (errConts == 0) { Map<String, String> messageMap = UtilMisc.toMap("numConts", Integer.toString(numConts)); - errMsg = UtilProperties.getMessage(RESOURCE, "contentevents.keyword_creation_complete_for_contents", messageMap, UtilHttp.getLocale(request)); + errMsg = UtilProperties.getMessage(RESOURCE, "contentevents.keyword_creation_complete_for_contents", messageMap, + UtilHttp.getLocale(request)); request.setAttribute("_EVENT_MESSAGE_", errMsg); return "success"; } else { Map<String, String> messageMap = UtilMisc.toMap("numConts", Integer.toString(numConts)); messageMap.put("errConts", Integer.toString(errConts)); - errMsg = UtilProperties.getMessage(RESOURCE, "contentevents.keyword_creation_complete_for_contents_with_errors", messageMap, UtilHttp.getLocale(request)); + errMsg = UtilProperties.getMessage(RESOURCE, "contentevents.keyword_creation_complete_for_contents_with_errors", + messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java index 750e379..576d323 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentKeywordIndex.java @@ -103,7 +103,8 @@ public class ContentKeywordIndex { } // DataResourceRole - List<GenericValue> dataResourceRoles = EntityQuery.use(delegator).from("DataResourceRole").where("dataResourceId", content.get("dataResourceId")).queryList(); + List<GenericValue> dataResourceRoles = EntityQuery.use(delegator).from("DataResourceRole").where("dataResourceId", + content.get("dataResourceId")).queryList(); for (GenericValue dataResourceRole: dataResourceRoles) { GenericValue party = EntityQuery.use(delegator).from("PartyNameView").where("partyId", dataResourceRole.get("partyId")).queryOne(); if (party != null) { @@ -129,9 +130,11 @@ public class ContentKeywordIndex { } // ProductCategory - List<GenericValue> productCategoryContentList = EntityQuery.use(delegator).from("ProductCategoryContent").where("contentId", contentId).queryList(); + List<GenericValue> productCategoryContentList = EntityQuery.use(delegator).from("ProductCategoryContent") + .where("contentId", contentId).queryList(); for (GenericValue productCategoryContent: productCategoryContentList) { - GenericValue productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryContent.getString("productCategoryId")).queryOne(); + GenericValue productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", + productCategoryContent.getString("productCategoryId")).queryOne(); if (productCategory != null) { addWeightedKeywordSourceString(productCategory, "categoryName", strings); addWeightedKeywordSourceString(productCategory, "description", strings); @@ -166,7 +169,8 @@ public class ContentKeywordIndex { // WorkEffortContent List<GenericValue> workEffortContents = EntityQuery.use(delegator).from("WorkEffortContent").where("contentId", contentId).queryList(); for (GenericValue workEffortContent: workEffortContents) { - GenericValue workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", workEffortContent.get("workEffortId")).queryOne(); + GenericValue workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", + workEffortContent.get("workEffortId")).queryOne(); if (workEffort != null) { addWeightedKeywordSourceString(workEffort, "workEffortName", strings); } @@ -190,13 +194,15 @@ public class ContentKeywordIndex { int keywordMaxLength = EntityUtilProperties.getPropertyAsInteger("contentsearch", "content.keyword.max.length", 0); for (Map.Entry<String, Long> entry: keywords.entrySet()) { if (entry.getKey().length() <= keywordMaxLength) { - GenericValue contentKeyword = delegator.makeValue("ContentKeyword", UtilMisc.toMap("contentId", content.getString("contentId"), "keyword", entry.getKey(), "relevancyWeight", entry.getValue())); + GenericValue contentKeyword = delegator.makeValue("ContentKeyword", UtilMisc.toMap("contentId", + content.getString("contentId"), "keyword", entry.getKey(), "relevancyWeight", entry.getValue())); toBeStored.add(contentKeyword); } } if (!toBeStored.isEmpty()) { if (Debug.verboseOn()) { - Debug.logVerbose("[ContentKeywordIndex.indexKeywords] Storing " + toBeStored.size() + " keywords for contentId " + content.getString("contentId"), MODULE); + Debug.logVerbose("[ContentKeywordIndex.indexKeywords] Storing " + toBeStored.size() + " keywords for contentId " + + content.getString("contentId"), MODULE); } if ("true".equals(EntityUtilProperties.getPropertyValue("contentsearch", "index.delete.on_index", "false", delegator))) { @@ -208,10 +214,12 @@ public class ContentKeywordIndex { } } - public static void addWeightedDataResourceString(GenericValue drView, int weight, List<String> strings, Delegator delegator, GenericValue content) { + public static void addWeightedDataResourceString(GenericValue drView, int weight, List<String> strings, Delegator delegator, + GenericValue content) { Map<String, Object> drContext = UtilMisc.<String, Object>toMap("content", content); try { - String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, drView.getString("dataResourceId"), drContext, null, null, false); + String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, drView.getString("dataResourceId"), + drContext, null, null, false); for (int i = 0; i < weight; i++) { strings.add(contentText); } diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java index 1edbb4d..1d24efd 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentMapFacade.java @@ -486,8 +486,8 @@ public class ContentMapFacade implements Map<Object, Object> { } class SubContent extends AbstractInfo { - private String sortOrder="-fromDate"; - private String statusFilter= ""; + private String sortOrder = "-fromDate"; + private String statusFilter = ""; @Override public Object get(Object key) { if (!(key instanceof String)) { @@ -527,14 +527,14 @@ public class ContentMapFacade implements Map<Object, Object> { Debug.logWarning("sortOrder parameters must be a string", MODULE); return; } - this.sortOrder=(String) obj; + this.sortOrder = (String) obj; } public void setStatusFilter(Object obj) { if (!(obj instanceof String)) { Debug.logWarning("statusFilter parameters must be a string", MODULE); return; } - this.statusFilter=(String) obj; + this.statusFilter = (String) obj; } } 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 10a0bbb..85767d3 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 @@ -143,7 +143,8 @@ public class ContentPermissionServices { passedPurposes.addAll(purposesFromString); } - EntityPermissionChecker.StdAuxiliaryValueGetter auxGetter = new EntityPermissionChecker.StdAuxiliaryValueGetter("ContentPurpose", "contentPurposeTypeId", "contentId"); + EntityPermissionChecker.StdAuxiliaryValueGetter auxGetter = new EntityPermissionChecker + .StdAuxiliaryValueGetter("ContentPurpose", "contentPurposeTypeId", "contentId"); // Sometimes permissions need to be checked before an entity is created, so // there needs to be a method for setting a purpose list auxGetter.setList(passedPurposes); @@ -156,10 +157,13 @@ public class ContentPermissionServices { } targetOperations.addAll(operationsFromString); } - EntityPermissionChecker.StdPermissionConditionGetter permCondGetter = new EntityPermissionChecker.StdPermissionConditionGetter("ContentPurposeOperation", "contentOperationId", "roleTypeId", "statusId", "contentPurposeTypeId", "privilegeEnumId"); + EntityPermissionChecker.StdPermissionConditionGetter permCondGetter = new EntityPermissionChecker + .StdPermissionConditionGetter("ContentPurposeOperation", "contentOperationId", "roleTypeId", + "statusId", "contentPurposeTypeId", "privilegeEnumId"); permCondGetter.setOperationList(targetOperations); - EntityPermissionChecker.StdRelatedRoleGetter roleGetter = new EntityPermissionChecker.StdRelatedRoleGetter("Content", "roleTypeId", "contentId", "partyId", "ownerContentId", "ContentRole"); + EntityPermissionChecker.StdRelatedRoleGetter roleGetter = new EntityPermissionChecker.StdRelatedRoleGetter("Content", + "roleTypeId", "contentId", "partyId", "ownerContentId", "ContentRole"); List<String> passedRoles = UtilGenerics.cast(context.get("roleTypeList")); if (passedRoles == null) passedRoles = new LinkedList<>(); String roleTypeString = (String) context.get("roleTypeString"); @@ -201,7 +205,8 @@ public class ContentPermissionServices { } } try { - boolean check = EntityPermissionChecker.checkPermissionMethod(delegator, partyId, "Content", entityIds, auxGetter, roleGetter, permCondGetter); + boolean check = EntityPermissionChecker.checkPermissionMethod(delegator, partyId, "Content", + entityIds, auxGetter, roleGetter, permCondGetter); if (check) { results.put("permissionStatus", "granted"); } else { 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 b75b971..8358abf 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 @@ -248,7 +248,8 @@ public class ContentSearch { boolean doingBothAndOr = (keywordFixedOrSetAndList.size() > 1) || (!keywordFixedOrSetAndList.isEmpty() && !andKeywordFixedSet.isEmpty()); - Debug.logInfo("Finished initial setup of keywords, doingBothAndOr=" + doingBothAndOr + ", andKeywordFixedSet=" + andKeywordFixedSet + "\n keywordFixedOrSetAndList=" + keywordFixedOrSetAndList, MODULE); + Debug.logInfo("Finished initial setup of keywords, doingBothAndOr=" + doingBothAndOr + ", andKeywordFixedSet=" + + andKeywordFixedSet + "\n keywordFixedOrSetAndList=" + keywordFixedOrSetAndList, MODULE); ComplexAlias relevancyComplexAlias = new ComplexAlias("+"); if (!andKeywordFixedSet.isEmpty()) { @@ -419,7 +420,8 @@ public class ContentSearch { this.totalResults = total; } - Debug.logInfo("Got search values, numRetreived=" + numRetreived + ", totalResults=" + totalResults + ", maxResults=" + maxResults + ", resultOffset=" + resultOffset + ", duplicatesFound(in the current results)=" + duplicatesFound, MODULE); + Debug.logInfo("Got search values, numRetreived=" + numRetreived + ", totalResults=" + totalResults + ", maxResults=" + maxResults + + ", resultOffset=" + resultOffset + ", duplicatesFound(in the current results)=" + duplicatesFound, MODULE); } catch (GenericEntityException e) { Debug.logError(e, "Error getting results from the content search query", MODULE); @@ -748,7 +750,8 @@ public class ContentSearch { StringBuilder ppBuf = new StringBuilder(); ppBuf.append(UtilProperties.getMessage(RESOURCE, "ContentKeywords", locale)).append(": \""); ppBuf.append(this.keywordsString).append("\", ").append(UtilProperties.getMessage(RESOURCE, "ContentKeywordWhere", locale)).append(" "); - ppBuf.append(isAnd ? UtilProperties.getMessage(RESOURCE, "ContentKeywordAllWordsMatch", locale) : UtilProperties.getMessage(RESOURCE, "ContentKeywordAnyWordMatches", locale)); + ppBuf.append(isAnd ? UtilProperties.getMessage(RESOURCE, "ContentKeywordAllWordsMatch", locale) + : UtilProperties.getMessage(RESOURCE, "ContentKeywordAnyWordMatches", locale)); return ppBuf.toString(); } @@ -810,9 +813,9 @@ public class ContentSearch { EntityConditionList<EntityExpr> dateConditions = null; EntityExpr dateCondition = null; if (fromDate != null && thruDate != null) { - dateConditions = EntityCondition.makeCondition(UtilMisc.toList( - EntityCondition.makeCondition("lastModifiedDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate), - EntityCondition.makeCondition("lastModifiedDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate)), EntityOperator.AND); + dateConditions = EntityCondition.makeCondition(UtilMisc.toList( + EntityCondition.makeCondition("lastModifiedDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate), + EntityCondition.makeCondition("lastModifiedDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate)), EntityOperator.AND); } if (fromDate != null) { dateCondition = EntityCondition.makeCondition("lastModifiedDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate); @@ -835,7 +838,8 @@ public class ContentSearch { contentSearchContext.entityConditionList.add(conditions); // add in contentSearchConstraint, don't worry about the contentSearchResultId or constraintSeqId, those will be fill in later - contentSearchContext.contentSearchConstraintList.add(contentSearchContext.getDelegator().makeValue("ContentSearchConstraint", UtilMisc.toMap("constraintName", CONSTRAINT_NAME, "infoString", "fromDate : " + fromDate + " thruDate : " + thruDate))); + contentSearchContext.contentSearchConstraintList.add(contentSearchContext.getDelegator().makeValue("ContentSearchConstraint", + UtilMisc.toMap("constraintName", CONSTRAINT_NAME, "infoString", "fromDate : " + fromDate + " thruDate : " + thruDate))); } /** pretty print for log messages and even UI stuff */ @@ -843,7 +847,8 @@ public class ContentSearch { public String prettyPrintConstraint(Delegator delegator, boolean detailed, Locale locale) { StringBuilder ppBuf = new StringBuilder(); ppBuf.append(UtilProperties.getMessage(RESOURCE, "ContentLastModified", locale)).append(": \""); - ppBuf.append(fromDate).append("-").append(thruDate).append("\", ").append(UtilProperties.getMessage(RESOURCE, "ContentLastModified", locale)).append(" "); + ppBuf.append(fromDate).append("-").append(thruDate).append("\", ").append(UtilProperties.getMessage(RESOURCE, "ContentLastModified", + locale)).append(" "); return ppBuf.toString(); } 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 e497961..6e63339 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 @@ -74,11 +74,13 @@ public class ContentServicesComplex { String contentId = (String) context.get("contentId"); String direction = (String) context.get("direction"); String mapKey = (String) context.get("mapKey"); - Map<String, Object> results = getAssocAndContentAndDataResourceMethod(delegator, contentId, mapKey, direction, fromDate, thruDate, fromDateStr, thruDateStr, assocTypes, contentTypes); + Map<String, Object> results = getAssocAndContentAndDataResourceMethod(delegator, contentId, mapKey, direction, fromDate, thruDate, + fromDateStr, thruDateStr, assocTypes, contentTypes); return results; } - public static Map<String, Object> getAssocAndContentAndDataResourceMethod(Delegator delegator, String contentId, String mapKey, String direction, Timestamp fromDate, Timestamp thruDate, String fromDateStr, String thruDateStr, List<String> assocTypes, List<String> contentTypes) { + public static Map<String, Object> getAssocAndContentAndDataResourceMethod(Delegator delegator, String contentId, String mapKey, String direction, + Timestamp fromDate, Timestamp thruDate, String fromDateStr, String thruDateStr, List<String> assocTypes, List<String> contentTypes) { List<EntityCondition> exprList = new LinkedList<>(); EntityExpr joinExpr = null; String viewName = null; @@ -186,15 +188,17 @@ public class ContentServicesComplex { Boolean nullThruDatesOnly = (Boolean) context.get("nullThruDatesOnly"); Map<String, Object> results = null; try { - results = getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, mapKey, direction, fromDate, fromDateStr, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId, null); + results = getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, mapKey, direction, fromDate, fromDateStr, assocTypes, + contentTypes, nullThruDatesOnly, contentAssocPredicateId, null); } catch (GenericEntityException | MiniLangException e) { return ServiceUtil.returnError(e.getMessage()); } return results; } - public static Map<String, Object> getAssocAndContentAndDataResourceCacheMethod(Delegator delegator, String contentId, String mapKey, String direction, - Timestamp fromDate, String fromDateStr, List<String> assocTypes, List<String> contentTypes, Boolean nullThruDatesOnly, String contentAssocPredicateId, String orderBy) throws GenericEntityException, MiniLangException { + public static Map<String, Object> getAssocAndContentAndDataResourceCacheMethod(Delegator delegator, String contentId, String mapKey, String + direction, Timestamp fromDate, String fromDateStr, List<String> assocTypes, List<String> contentTypes, Boolean nullThruDatesOnly, + String contentAssocPredicateId, String orderBy) throws GenericEntityException, MiniLangException { EntityExpr joinExpr = null; String viewName = null; String contentFieldName = null; @@ -264,8 +268,9 @@ public class ContentServicesComplex { SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocOut", contentAssoc, contentAssocDataResourceView, new LinkedList<>(), locale); String dataResourceId = content.getString("dataResourceId"); - if (UtilValidate.isNotEmpty(dataResourceId)) + if (UtilValidate.isNotEmpty(dataResourceId)) { dataResource = content.getRelatedOne("DataResource", true); + } if (dataResource != null) { SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "dataResourceOut", dataResource, contentAssocDataResourceView, new LinkedList<>(), locale); 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 bff098d..c8ae808 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 @@ -404,7 +404,7 @@ public class UploadContentAndImage { for (int i = 0; i < rowCount; i++) { String suffix = "_o_" + i; if (i == 0) { - suffix = ""; + suffix = ""; } String returnMsg = processContentUpload(passedParams, suffix, request); if ("error".equals(returnMsg)) { @@ -432,7 +432,8 @@ public class UploadContentAndImage { return "success"; } - public static String processContentUpload(Map<String, Object> passedParams, String suffix, HttpServletRequest request) throws GenericServiceException { + public static String processContentUpload(Map<String, Object> passedParams, String suffix, HttpServletRequest request) + throws GenericServiceException { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); Delegator delegator = (Delegator) request.getAttribute("delegator"); HttpSession session = request.getSession(); @@ -443,14 +444,14 @@ public class UploadContentAndImage { if (UtilValidate.isEmpty(contentPurposeString)) { contentPurposeString = (String) passedParams.get("contentPurposeString"); } - List<String> contentPurposeList = StringUtil.split(contentPurposeString,"|"); + List<String> contentPurposeList = StringUtil.split(contentPurposeString, "|"); ftlContext.put("contentPurposeList", contentPurposeList); String targetOperationString = (String) passedParams.get("targetOperationString" + suffix); if (UtilValidate.isEmpty(targetOperationString)) { targetOperationString = (String) passedParams.get("targetOperationString"); } - List<String> targetOperationList = StringUtil.split(targetOperationString,"|"); + List<String> targetOperationList = StringUtil.split(targetOperationString, "|"); ftlContext.put("targetOperationList", targetOperationList); ftlContext.put("userLogin", userLogin); @@ -490,16 +491,22 @@ public class UploadContentAndImage { List<Object> errorMessages = new LinkedList<>(); Locale loc = Locale.getDefault(); try { - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentIn", ftlContext2, ftlContext3, errorMessages, loc); - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentOut", ftlContext3, ftlContext, errorMessages, loc); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "contentIn", ftlContext2, ftlContext3, errorMessages, loc); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "contentOut", ftlContext3, ftlContext, errorMessages, loc); ftlContext3 = new HashMap<>(); - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "dataResourceIn", ftlContext2, ftlContext3, errorMessages, loc); - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "dataResourceOut", ftlContext3, ftlContext, errorMessages, loc); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "dataResourceIn", ftlContext2, ftlContext3, errorMessages, loc); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "dataResourceOut", ftlContext3, ftlContext, errorMessages, loc); ftlContext3 = new HashMap<>(); - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocIn", ftlContext2, ftlContext3, errorMessages, loc); - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocOut", ftlContext3, ftlContext, errorMessages, loc); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "contentAssocIn", ftlContext2, ftlContext3, errorMessages, loc); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "contentAssocOut", ftlContext3, ftlContext, errorMessages, loc); } catch (MiniLangException e) { throw new GenericServiceException(e.getMessage()); } 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 bf95263..23fb069 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 @@ -80,7 +80,8 @@ public class DataEvents { } // get the permission service required for streaming data; default is always the genericContentPermission - String permissionService = EntityUtilProperties.getPropertyValue("content", "stream.permission.service", "genericContentPermission", delegator); + String permissionService = EntityUtilProperties.getPropertyValue("content", "stream.permission.service", + "genericContentPermission", delegator); // This is counterintuitive but it works, for OFBIZ-11840 // It could be improved by checking for possible events associated with svg @@ -143,7 +144,8 @@ public class DataEvents { // not public check security if (!"Y".equalsIgnoreCase(isPublic)) { // do security check - Map<String, ? extends Object> permSvcCtx = UtilMisc.toMap("userLogin", userLogin, "locale", locale, "mainAction", "VIEW", "contentId", contentId); + Map<String, ? extends Object> permSvcCtx = UtilMisc.toMap("userLogin", userLogin, "locale", locale, "mainAction", + "VIEW", "contentId", contentId); Map<String, Object> permSvcResp; try { permSvcResp = dispatcher.runSync(permissionService, permSvcCtx); @@ -217,7 +219,8 @@ public class DataEvents { } catch (IOException e) { Debug.logError(e, "Unable to write content to browser", MODULE); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); - // this must be handled with a special error string because the output stream has been already used and we will not be able to return the error page; + // this must be handled with a special error string because the output stream has been already used and we will not be able + // to return the error page; // the "io-error" should be associated to a response of type "none" return "io-error"; } @@ -233,7 +236,8 @@ public class DataEvents { /** * Streams ImageDataResource data to the output. - * <p>Superseded by {@link org.apache.ofbiz.content.data.DataEvents#serveObjectData(HttpServletRequest, HttpServletResponse) DataEvents#serveObjectData}</p> + * <p>Superseded by {@link org.apache.ofbiz.content.data.DataEvents#serveObjectData(HttpServletRequest, HttpServletResponse) + * DataEvents#serveObjectData}</p> */ @Deprecated public static String serveImage(HttpServletRequest request, HttpServletResponse response) { @@ -272,7 +276,8 @@ public class DataEvents { "dataResourceId", dataResourceId) .queryCount(); if (contentAndRoleCount == 0) { - String errorMsg = "You do not have permission to download the Data Resource with ID [" + dataResourceId + "], ie you are not associated with it."; + String errorMsg = "You do not have permission to download the Data Resource with ID [" + dataResourceId + + "], ie you are not associated with it."; Debug.logError(errorMsg, MODULE); request.setAttribute("_ERROR_MESSAGE_", errorMsg); return "error"; @@ -292,7 +297,8 @@ public class DataEvents { response.setContentType(mimeType); } OutputStream os = response.getOutputStream(); - Map<String, Object> resourceData = DataResourceWorker.getDataResourceStream(dataResource, "", application.getInitParameter("webSiteId"), UtilHttp.getLocale(request), application.getRealPath("/"), false); + Map<String, Object> resourceData = DataResourceWorker.getDataResourceStream(dataResource, "", + application.getInitParameter("webSiteId"), UtilHttp.getLocale(request), application.getRealPath("/"), false); os.write(IOUtils.toByteArray((InputStream) resourceData.get("stream"))); os.flush(); } catch (GeneralException | IOException e) { diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java index 60688ff..cb37a37 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java @@ -217,7 +217,8 @@ public class DataServices { // obtain a reference to the file File file = null; if (UtilValidate.isEmpty(objectInfo)) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentUnableObtainReferenceToFile", UtilMisc.toMap("objectInfo", ""), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentUnableObtainReferenceToFile", + UtilMisc.toMap("objectInfo", ""), locale)); } if (UtilValidate.isEmpty(dataResourceTypeId) || "LOCAL_FILE".equals(dataResourceTypeId) || "LOCAL_FILE_BIN".equals(dataResourceTypeId)) { file = new File(objectInfo); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/ftp/FtpServices.java b/applications/content/src/main/java/org/apache/ofbiz/content/ftp/FtpServices.java index 5746a5f..f250dac 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/ftp/FtpServices.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/ftp/FtpServices.java @@ -72,8 +72,10 @@ public class FtpServices { String contactMechId = (String) context.get("contactMechId"); String contentId = (String) context.get("contentId"); String communicationEventId = (String) context.get("communicationEventId"); - boolean forceTransferControlSuccess = EntityUtilProperties.propertyValueEqualsIgnoreCase("ftp", "ftp.force.transfer.control", "Y", delegator); - boolean ftpNotificationEnabled = EntityUtilProperties.propertyValueEqualsIgnoreCase("ftp", "ftp.notifications.enabled", "Y", delegator); + boolean forceTransferControlSuccess = EntityUtilProperties.propertyValueEqualsIgnoreCase("ftp", + "ftp.force.transfer.control", "Y", delegator); + boolean ftpNotificationEnabled = EntityUtilProperties.propertyValueEqualsIgnoreCase("ftp", + "ftp.notifications.enabled", "Y", delegator); if (!ftpNotificationEnabled) return ServiceUtil.returnSuccess(); @@ -95,7 +97,8 @@ public class FtpServices { //Validate content GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne(); if (null == content) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentNoContentFound", + UtilMisc.toMap("contentId", contentId), locale)); } //ftp redirection @@ -113,9 +116,9 @@ public class FtpServices { } String hostname = ftpAddress.getString("hostname"); - if (UtilValidate.isEmpty(hostname)) + if (UtilValidate.isEmpty(hostname)) { return ServiceUtil.returnError("Ftp destination server is null"); - else if (hostname.indexOf("://") == -1) { + } else if (hostname.indexOf("://") == -1) { return ServiceUtil.returnError("No protocol defined in ftp destination address"); } @@ -132,8 +135,9 @@ public class FtpServices { String username = ftpAddress.getString("username"); String password = ftpAddress.getString("ftpPassword"); - if (Debug.infoOn()) + if (Debug.infoOn()) { Debug.logInfo("connecting to: " + username + "@" + ftpAddress.getString("hostname") + ":" + port, MODULE); + } ftpClient.connect(hostname, username, password, port, defaultTimeout); boolean binary = "Y".equalsIgnoreCase(ftpAddress.getString("binaryTransfer")); ftpClient.setBinaryTransfer(binary); @@ -148,16 +152,17 @@ public class FtpServices { } String path = ftpAddress.getString("filePath"); - if (Debug.infoOn()) - Debug.logInfo("storing local file remotely as: " + (UtilValidate.isNotEmpty(path) ? path + "/" : "") + content.getString("contentName"), MODULE); - + if (Debug.infoOn()) { + Debug.logInfo("storing local file remotely as: " + (UtilValidate.isNotEmpty(path) ? path + "/" : "") + + content.getString("contentName"), MODULE); + } String fileName = content.getString("contentName"); String remoteFileName = fileName; boolean zipFile = "Y".equalsIgnoreCase(ftpAddress.getString("zipFile")); if (zipFile) { //Create zip file from content input stream ByteArrayInputStream zipStream = FileUtil.zipFileStream(contentStream, fileName); - remoteFileName = fileName + (fileName.endsWith("zip")?"":".zip"); + remoteFileName = fileName + (fileName.endsWith("zip") ? "" : ".zip"); ftpClient.copy(path, remoteFileName, zipStream); zipStream.close(); @@ -188,8 +193,9 @@ public class FtpServices { if (fileNames == null || !fileNames.contains(remoteFileName)) { return ServiceUtil.returnError("DataResource " + content.getString("dataResourceId") + " return an empty stream"); } - if (Debug.infoOn()) + if (Debug.infoOn()) { Debug.logInfo(" Ok the file " + content.getString("contentName") + " is present", MODULE); + } } } catch (GeneralException | IOException e) { return ServiceUtil.returnError(e.getMessage()); 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 44584e0..9652ce0 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 @@ -90,9 +90,12 @@ public class LayoutEvents { context.put("locale", locale); try { - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentIn", formInput, context, errorMessages, locale); - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "dataResourceIn", formInput, context, errorMessages, locale); - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocIn", formInput, context, errorMessages, locale); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "contentIn", formInput, context, errorMessages, locale); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "dataResourceIn", formInput, context, errorMessages, locale); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", + "contentAssocIn", formInput, context, errorMessages, locale); } catch (MiniLangException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; @@ -420,7 +423,8 @@ public class LayoutEvents { locale = Locale.getDefault(); } try { - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocIn", view, serviceIn, errorMessages, locale); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocIn", + view, serviceIn, errorMessages, locale); } catch (IllegalArgumentException | MiniLangException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; @@ -429,9 +433,10 @@ public class LayoutEvents { String mapKey = (String) view.get("caMapKey"); Timestamp fromDate = (Timestamp) view.get("caFromDate"); Timestamp thruDate = (Timestamp) view.get("caThruDate"); - if (Debug.verboseOn()) + if (Debug.verboseOn()) { 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); @@ -488,9 +493,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"; 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 92aa39b..5cf2e8b 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 @@ -273,7 +273,8 @@ public class OutputServices { } catch (IOException | TemplateException | GeneralException | SAXException | ParserConfigurationException e) { Debug.logError(e, "Error rendering [" + contentType + "]: " + e.toString(), MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentRenderingError", UtilMisc.toMap("contentType", contentType, "errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentRenderingError", + UtilMisc.toMap("contentType", contentType, "errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/view/SimpleContentViewHandler.java b/applications/content/src/main/java/org/apache/ofbiz/content/view/SimpleContentViewHandler.java index b8a7227..8b697f0 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/view/SimpleContentViewHandler.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/view/SimpleContentViewHandler.java @@ -63,11 +63,12 @@ public class SimpleContentViewHandler extends AbstractViewHandler { https = (String) context.getAttribute("https"); } /** - * @see org.apache.ofbiz.webapp.view.ViewHandler#render(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + * @see org.apache.ofbiz.webapp.view.ViewHandler#render(java.lang.String, java.lang.String, java.lang.String, java.lang.String, + * java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @Override - public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException { - + public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, + HttpServletResponse response) throws ViewHandlerException { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); @@ -131,7 +132,8 @@ public class SimpleContentViewHandler extends AbstractViewHandler { Debug.logVerbose("contentRevisionItem:" + contentRevisionItem, MODULE); } if (Debug.verboseOn()) { - Debug.logVerbose("contentId=" + rootContentId + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId, MODULE); + Debug.logVerbose("contentId=" + rootContentId + ", contentRevisionSeqId=" + contentRevisionSeqId + + ", itemContentId=" + contentId, MODULE); } if (Debug.verboseOn()) { Debug.logVerbose("dataResourceId:" + dataResourceId, MODULE); @@ -139,7 +141,8 @@ public class SimpleContentViewHandler extends AbstractViewHandler { } } if (UtilValidate.isNotEmpty(dataResourceId)) { - GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne(); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", + dataResourceId).cache().queryOne(); // DEJ20080717: why are we rendering the DataResource directly instead of rendering the content? ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir); ByteArrayInputStream bais = new ByteArrayInputStream(byteBuffer.array()); @@ -167,12 +170,14 @@ public class SimpleContentViewHandler extends AbstractViewHandler { isPublic = "N"; } // get the permission service required for streaming data; default is always the genericContentPermission - String permissionService = EntityUtilProperties.getPropertyValue("content", "stream.permission.service", "genericContentPermission", delegator); + String permissionService = EntityUtilProperties.getPropertyValue("content", "stream.permission.service", + "genericContentPermission", delegator); // not public check security if (!"Y".equalsIgnoreCase(isPublic)) { // do security check - Map<String, ? extends Object> permSvcCtx = UtilMisc.toMap("userLogin", userLogin, "locale", locale, "mainAction", "VIEW", "contentId", contentId); + Map<String, ? extends Object> permSvcCtx = UtilMisc.toMap("userLogin", userLogin, "locale", locale, "mainAction", + "VIEW", "contentId", contentId); Map<String, Object> permSvcResp; try { permSvcResp = dispatcher.runSync(permissionService, permSvcCtx); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/CheckPermissionTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/CheckPermissionTransform.java index 8c9562b..58e179f 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/CheckPermissionTransform.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/CheckPermissionTransform.java @@ -53,7 +53,8 @@ public class CheckPermissionTransform implements TemplateTransformModel { private static final String MODULE = CheckPermissionTransform.class.getName(); - static final String[] SAVE_KEY_NAMES = {"globalNodeTrail", "nodeTrail", "mode", "purposeTypeId", "statusId", "entityOperation", "targetOperation" }; + static final String[] SAVE_KEY_NAMES = {"globalNodeTrail", "nodeTrail", "mode", "purposeTypeId", "statusId", "entityOperation", + "targetOperation" }; /** * @deprecated use FreeMarkerWorker.getWrappedObject() @@ -114,7 +115,8 @@ public class CheckPermissionTransform implements TemplateTransformModel { GenericValue currentContent = null; String contentAssocPredicateId = (String) templateCtx.get("contentAssocPredicateId"); String strNullThruDatesOnly = (String) templateCtx.get("nullThruDatesOnly"); - Boolean nullThruDatesOnly = (strNullThruDatesOnly != null && "true".equalsIgnoreCase(strNullThruDatesOnly)) ? Boolean.TRUE : Boolean.FALSE; + Boolean nullThruDatesOnly = (strNullThruDatesOnly != null && "true".equalsIgnoreCase(strNullThruDatesOnly)) + ? Boolean.TRUE : Boolean.FALSE; GenericValue val = null; try { val = ContentWorker.getCurrentContent(delegator, trail, userLogin, templateCtx, nullThruDatesOnly, contentAssocPredicateId); @@ -158,7 +160,8 @@ public class CheckPermissionTransform implements TemplateTransformModel { List<String> roleList = new LinkedList<>(); String privilegeEnumId = (String) currentContent.get("privilegeEnumId"); - Map<String, Object> results = EntityPermissionChecker.checkPermission(currentContent, statusList, userLogin, purposeList, targetOperationList, roleList, delegator, security, entityOperation, privilegeEnumId, quickCheckContentId); + Map<String, Object> results = EntityPermissionChecker.checkPermission(currentContent, statusList, userLogin, purposeList, + targetOperationList, roleList, delegator, security, entityOperation, privilegeEnumId, quickCheckContentId); boolean isError = ModelService.RESPOND_ERROR.equals(results.get(ModelService.RESPONSE_MESSAGE)); if (isError) { diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java index 0a45d14..d92500f 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java @@ -114,7 +114,8 @@ public class EditRenderSubContentTransform implements TemplateTransformModel { Timestamp fromDate = UtilDateTime.nowTimestamp(); if (subContentDataResourceViewTemp == null) { try { - subContentDataResourceViewTemp = ContentWorker.getSubContent(delegator, contentId, mapKey, subContentId, userLogin, assocTypes, fromDate); + subContentDataResourceViewTemp = ContentWorker.getSubContent(delegator, contentId, mapKey, subContentId, userLogin, + assocTypes, fromDate); } catch (IOException e) { Debug.logError(e, "Error getting sub-content", MODULE); throw new RuntimeException(e.getMessage()); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java index 3bc14cc..89dae7e 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java @@ -53,9 +53,11 @@ public class RenderSubContentTransform implements TemplateTransformModel { /** * @deprecated use FreeMarkerWorker.getArg() - * <p>Does a conditional search to return a value for a parameter with the passed name. Looks first to see if it was passed as an argument to the transform. + * <p>Does a conditional search to return a value for a parameter with the passed name. Looks first to see if it was + * passed as an argument to the transform. * Secondly, it looks to see if it is passed as a parameter in the template context object.</p> - * <p>Note that this is different from the getArg method of EditRenderDataResourceTransform, which checks the request object instead of the template context + * <p>Note that this is different from the getArg method of EditRenderDataResourceTransform, which checks the request object + * instead of the template context * object.</p> */ @Deprecated @@ -94,7 +96,8 @@ public class RenderSubContentTransform implements TemplateTransformModel { List<String> assocTypes = UtilMisc.toList("SUB_CONTENT"); Timestamp fromDate = UtilDateTime.nowTimestamp(); try { - subContentDataResourceViewTemp = ContentWorker.getSubContent(delegator, contentId, mapKey, subContentId, userLogin, assocTypes, fromDate); + subContentDataResourceViewTemp = ContentWorker.getSubContent(delegator, contentId, mapKey, subContentId, userLogin, + assocTypes, fromDate); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } @@ -139,8 +142,6 @@ public class RenderSubContentTransform implements TemplateTransformModel { Map<String, Object> templateRoot = FreeMarkerWorker.createEnvironmentMap(env); templateRoot.put("context", templateContext); - if (subContentDataResourceView != null) { - } try { if (subContentId != null) { ContentWorker.renderContentAsText(dispatcher, subContentId, out, templateRoot, locale, mimeTypeId, null, null, false); diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java index ed9fd35..9df1278 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMHelper.java @@ -156,7 +156,8 @@ public final class BOMHelper { "shipGroupSeqId", shipmentPlan.get("shipGroupSeqId")) .cache().queryList(); if (UtilValidate.isNotEmpty(productionRuns)) { - Debug.logError("Production Run for order item (" + orderItem.getString("orderId") + "/" + orderItem.getString("orderItemSeqId") + ") not created.", MODULE); + Debug.logError("Production Run for order item (" + orderItem.getString("orderId") + "/" + + orderItem.getString("orderItemSeqId") + ") not created.", MODULE); continue; } Map<String, Object> result = dispatcher.runSync("createProductionRunsForOrder", UtilMisc.<String, Object>toMap("quantity", 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 bf902df..a67f3d8 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 @@ -445,8 +445,8 @@ public class BOMNode { } if (serviceName != null) { Map<String, Object> resultContext = null; - Map<String, Object> arguments = UtilMisc.<String, Object>toMap("neededQuantity", quantity.multiply(quantityMultiplier), "amount", tree != null - ? tree.getRootAmount() : BigDecimal.ZERO); + Map<String, Object> arguments = UtilMisc.<String, Object>toMap("neededQuantity", quantity.multiply(quantityMultiplier), + "amount", tree != null ? tree.getRootAmount() : BigDecimal.ZERO); BigDecimal width = null; if (getProduct().get("productWidth") != null) { width = getProduct().getBigDecimal("productWidth"); @@ -542,7 +542,25 @@ public class BOMNode { } } - public Map<String, Object> createManufacturingOrder(String facilityId, Date date, String workEffortName, String description, String routingId, String orderId, String orderItemSeqId, String shipGroupSeqId, String shipmentId, boolean useSubstitute, boolean ignoreSupplierProducts) throws GenericEntityException { + /** + * Create manufacturing order map. + * @param facilityId the facility id + * @param date the date + * @param workEffortName the work effort name + * @param description the description + * @param routingId the routing id + * @param orderId the order id + * @param orderItemSeqId the order item seq id + * @param shipGroupSeqId the ship group seq id + * @param shipmentId the shipment id + * @param useSubstitute the use substitute + * @param ignoreSupplierProducts the ignore supplier products + * @return the map + * @throws GenericEntityException the generic entity exception + */ + public Map<String, Object> createManufacturingOrder(String facilityId, Date date, String workEffortName, String description, String routingId, + String orderId, String orderItemSeqId, String shipGroupSeqId, String shipmentId, boolean useSubstitute, boolean ignoreSupplierProducts) + throws GenericEntityException { String productionRunId = null; Timestamp endDate = null; if (isManufactured(ignoreSupplierProducts)) { @@ -552,7 +570,8 @@ public class BOMNode { for (BOMNode childrenNode : childrenNodes) { oneChildNode = childrenNode; if (oneChildNode != null) { - Map<String, Object> tmpResult = oneChildNode.createManufacturingOrder(facilityId, date, null, null, null, null, null, shipGroupSeqId, shipmentId, false, false); + Map<String, Object> tmpResult = oneChildNode.createManufacturingOrder(facilityId, date, null, null, null, + null, null, shipGroupSeqId, shipmentId, false, false); String childProductionRunId = (String) tmpResult.get("productionRunId"); Timestamp childEndDate = (Timestamp) tmpResult.get("endDate"); if (maxEndDate == null) { @@ -615,7 +634,8 @@ public class BOMNode { try { if (productionRunId != null) { if (orderId != null && orderItemSeqId != null) { - delegator.create("WorkOrderItemFulfillment", UtilMisc.toMap("workEffortId", productionRunId, "orderId", orderId, "orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId)); + delegator.create("WorkOrderItemFulfillment", UtilMisc.toMap("workEffortId", productionRunId, + "orderId", orderId, "orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId)); } for (String childProductionRun : childProductionRuns) { delegator.create("WorkEffortAssoc", UtilMisc.toMap("workEffortIdFrom", childProductionRun, @@ -629,6 +649,13 @@ public class BOMNode { return UtilMisc.toMap("productionRunId", productionRunId, "endDate", endDate); } + /** + * Gets start date. + * @param facilityId the facility id + * @param requiredBydate the required bydate + * @param allNodes the all nodes + * @return the start date + */ public Timestamp getStartDate(String facilityId, Timestamp requiredBydate, boolean allNodes) { Timestamp minStartDate = requiredBydate; if ("WIP".equals(getProduct().getString("productTypeId")) || allNodes) { @@ -689,7 +716,8 @@ 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 + * 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 */ 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 595034d..225c31c 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 @@ -88,7 +88,8 @@ public class BOMServices { bomTypes.add(bomTypesValue.getString("productAssocTypeId")); } } catch (GenericEntityException gee) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorRunningMaxDethAlgorithm", UtilMisc.toMap("errorString", gee.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorRunningMaxDethAlgorithm", + UtilMisc.toMap("errorString", gee.getMessage()), locale)); } } else { bomTypes.add(bomType); @@ -104,7 +105,8 @@ public class BOMServices { } } } catch (GenericEntityException gee) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorRunningMaxDethAlgorithm", UtilMisc.toMap("errorString", gee.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorRunningMaxDethAlgorithm", + UtilMisc.toMap("errorString", gee.getMessage()), locale)); } result.put("depth", (long) maxDepth); @@ -152,7 +154,8 @@ public class BOMServices { int virtualMaxDepth = 0; for (GenericValue oneVirtualProductAssoc : virtualProducts) { int virtualDepth = 0; - GenericValue virtualProduct = EntityQuery.use(delegator).from("Product").where("productId", oneVirtualProductAssoc.getString("productId")).queryOne(); + GenericValue virtualProduct = EntityQuery.use(delegator).from("Product").where("productId", + oneVirtualProductAssoc.getString("productId")).queryOne(); if (virtualProduct.get("billOfMaterialLevel") != null) { virtualDepth = virtualProduct.getLong("billOfMaterialLevel").intValue(); } else { @@ -168,7 +171,8 @@ public class BOMServices { product.set("billOfMaterialLevel", llc); product.store(); if (alsoComponents) { - Map<String, Object> treeResult = dispatcher.runSync("getBOMTree", UtilMisc.toMap("productId", productId, "bomType", "MANUF_COMPONENT")); + Map<String, Object> treeResult = dispatcher.runSync("getBOMTree", UtilMisc.toMap("productId", productId, + "bomType", "MANUF_COMPONENT")); if (ServiceUtil.isError(treeResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(treeResult)); } @@ -193,7 +197,8 @@ public class BOMServices { "productAssocTypeId", "PRODUCT_VARIANT") .filterByDate().queryList(); for (GenericValue oneVariantProductAssoc : variantProducts) { - GenericValue variantProduct = EntityQuery.use(delegator).from("Product").where("productId", oneVariantProductAssoc.getString("productId")).queryOne(); + GenericValue variantProduct = EntityQuery.use(delegator).from("Product").where("productId", oneVariantProductAssoc + .getString("productId")).queryOne(); variantProduct.set("billOfMaterialLevel", llc); variantProduct.store(); } @@ -231,11 +236,13 @@ public class BOMServices { for (GenericValue product : products) { try { - Map<String, Object> depthResult = dispatcher.runSync("updateLowLevelCode", UtilMisc.<String, Object>toMap("productIdTo", product.getString("productId"), "alsoComponents", Boolean.FALSE, "alsoVariants", Boolean.FALSE)); + Map<String, Object> depthResult = dispatcher.runSync("updateLowLevelCode", UtilMisc.<String, Object>toMap("productIdTo", + product.getString("productId"), "alsoComponents", Boolean.FALSE, "alsoVariants", Boolean.FALSE)); if (ServiceUtil.isError(depthResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(depthResult)); } - Debug.logInfo("Product [" + product.getString("productId") + "] Low Level Code [" + depthResult.get("lowLevelCode") + "]", MODULE); + Debug.logInfo("Product [" + product.getString("productId") + "] Low Level Code [" + depthResult.get("lowLevelCode") + + "]", MODULE); } catch (GenericServiceException exc) { Debug.logWarning(exc.getMessage(), MODULE); } @@ -273,7 +280,8 @@ public class BOMServices { try { duplicatedProductAssoc = BOMHelper.searchDuplicatedAncestor(productId, productIdKey, bomType, fromDate, delegator, dispatcher, userLogin); } catch (GenericEntityException gee) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorRunningDuplicatedAncestorSearch", UtilMisc.toMap("errorString", gee.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorRunningDuplicatedAncestorSearch", + UtilMisc.toMap("errorString", gee.getMessage()), locale)); } result.put("duplicatedProductAssoc", duplicatedProductAssoc); return result; @@ -320,7 +328,8 @@ public class BOMServices { try { tree = new BOMTree(productId, bomType, fromDate, type, delegator, dispatcher, userLogin); } catch (GenericEntityException gee) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorCreatingBillOfMaterialsTree", UtilMisc.toMap("errorString", gee.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorCreatingBillOfMaterialsTree", + UtilMisc.toMap("errorString", gee.getMessage()), locale)); } if (quantity != null) { tree.setRootQuantity(quantity); @@ -385,7 +394,8 @@ public class BOMServices { tree.print(components, excludeWIPs); if (!components.isEmpty()) components.remove(0); } catch (GenericEntityException gee) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorCreatingBillOfMaterialsTree", UtilMisc.toMap("errorString", gee.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorCreatingBillOfMaterialsTree", + UtilMisc.toMap("errorString", gee.getMessage()), locale)); } // // Product routing @@ -468,7 +478,8 @@ public class BOMServices { tree.setRootAmount(amount); tree.print(components); } catch (GenericEntityException gee) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorCreatingBillOfMaterialsTree", UtilMisc.toMap("errorString", gee.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorCreatingBillOfMaterialsTree", + UtilMisc.toMap("errorString", gee.getMessage()), locale)); } for (BOMNode oneComponent : components) { if (!oneComponent.isManufactured()) { @@ -524,7 +535,8 @@ public class BOMServices { OrderReadHelper orderReadHelper = (OrderReadHelper) orderReadHelpers.get(orderShipment.getString("orderId")); if (orderReadHelper != null) { Map<String, Object> orderShipmentReadMap = UtilMisc.toMap("orderShipment", orderShipment, "orderReadHelper", orderReadHelper); - String partyId = (orderReadHelper.getPlacingParty() != null ? orderReadHelper.getPlacingParty().getString("partyId") : null); // FIXME: is it the customer? + String partyId = (orderReadHelper.getPlacingParty() != null ? orderReadHelper.getPlacingParty().getString("partyId") : null); + // FIXME: is it the customer? if (partyId != null) { if (!partyOrderShipments.containsKey(partyId)) { List<Map<String, Object>> orderShipmentReadMapList = new LinkedList<>(); @@ -601,7 +613,8 @@ public class BOMServices { try { boxType = EntityQuery.use(delegator).from("ShipmentBoxType").where("shipmentBoxTypeId", boxTypeId).queryOne(); } catch (GenericEntityException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingPackageConfiguratorError", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingPackageConfiguratorError", + locale)); } boxTypes.put(boxTypeId, boxType); List<Map<String, Object>> box = new LinkedList<>(); @@ -708,7 +721,9 @@ public class BOMServices { // If needed, create the package if (shipmentPackageSeqId == null) { try { - Map<String, Object> serviceResult = dispatcher.runSync("createShipmentPackage", UtilMisc.<String, Object>toMap("shipmentId", orderShipment.getString("shipmentId"), "shipmentBoxTypeId", boxTypeId, "userLogin", userLogin)); + Map<String, Object> serviceResult = dispatcher.runSync("createShipmentPackage", + UtilMisc.<String, Object>toMap("shipmentId", orderShipment.getString("shipmentId"), "shipmentBoxTypeId", + boxTypeId, "userLogin", userLogin)); if (ServiceUtil.isError(serviceResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); } @@ -792,7 +807,8 @@ public class BOMServices { tree.setRootQuantity(quantity); tree.getProductsInPackages(components); } catch (GenericEntityException gee) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorCreatingBillOfMaterialsTree", UtilMisc.toMap("errorString", gee.getMessage()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingBomErrorCreatingBillOfMaterialsTree", + UtilMisc.toMap("errorString", gee.getMessage()), locale)); } result.put("productsInPackages", components); diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java index 033ec13..128f3a3 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/bom/BOMTree.java @@ -45,15 +45,15 @@ public class BOMTree { public static final int EXPLOSION_MANUFACTURING = 2; public static final int IMPLOSION = 3; - protected LocalDispatcher dispatcher = null; - protected Delegator delegator = null; + private LocalDispatcher dispatcher = null; + private Delegator delegator = null; - BOMNode root; - BigDecimal rootQuantity; - BigDecimal rootAmount; - Date inDate; - String bomTypeId; - GenericValue inputProduct; + private BOMNode root; + private BigDecimal rootQuantity; + private BigDecimal rootAmount; + private Date inDate; + private String bomTypeId; + private GenericValue inputProduct; /** Creates a new instance of BOMTree by reading downward * the productId's bill of materials (explosion). @@ -65,7 +65,8 @@ public class BOMTree { * @param delegator The delegator used. * @throws GenericEntityException If a db problem occurs. */ - public BOMTree(String productId, String bomTypeId, Date inDate, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException { + public BOMTree(String productId, String bomTypeId, Date inDate, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) + throws GenericEntityException { this(productId, bomTypeId, inDate, EXPLOSION, delegator, dispatcher, userLogin); } @@ -83,7 +84,8 @@ public class BOMTree { * @param delegator The delegator used. * @throws GenericEntityException If a db problem occurs. */ - public BOMTree(String productId, String bomTypeId, Date inDate, int type, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException { + public BOMTree(String productId, String bomTypeId, Date inDate, int type, Delegator delegator, LocalDispatcher dispatcher, GenericValue + userLogin) throws GenericEntityException { // If the parameters are not valid, return. if (productId == null || bomTypeId == null || delegator == null || dispatcher == null) return; // If the date is null, set it to today. @@ -121,7 +123,8 @@ public class BOMTree { // the bill of materials of its virtual product (if the current // product is variant). if (!hasBom(product, inDate)) { - List<GenericValue> virtualProducts = product.getRelated("AssocProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT"), null, false); + List<GenericValue> virtualProducts = product.getRelated("AssocProductAssoc", UtilMisc.toMap("productAssocTypeId", + "PRODUCT_VARIANT"), null, false); virtualProducts = EntityUtil.filterByDate(virtualProducts, inDate); GenericValue virtualProduct = EntityUtil.getFirst(virtualProducts); if (virtualProduct != null) { @@ -130,7 +133,8 @@ public class BOMTree { productIdForRules = virtualProduct.getString("productId"); manufacturedAsProduct = manufacturedAsProduct(virtualProduct.getString("productId"), inDate); product = EntityQuery.use(delegator).from("Product") - .where("productId", (manufacturedAsProduct != null ? manufacturedAsProduct.getString("productIdTo") : virtualProduct.get("productId"))) + .where("productId", (manufacturedAsProduct != null ? manufacturedAsProduct.getString("productIdTo") + : virtualProduct.get("productId"))) .queryOne(); } } @@ -154,6 +158,10 @@ public class BOMTree { rootAmount = BigDecimal.ZERO; } + /** + * Gets input product. + * @return the input product + */ public GenericValue getInputProduct() { return inputProduct; } @@ -166,7 +174,8 @@ public class BOMTree { } private boolean hasBom(GenericValue product, Date inDate) throws GenericEntityException { - List<GenericValue> children = product.getRelated("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", bomTypeId), null, false); + List<GenericValue> children = product.getRelated("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", bomTypeId), + null, false); children = EntityUtil.filterByDate(children, inDate); return UtilValidate.isNotEmpty(children); } @@ -252,6 +261,12 @@ public class BOMTree { print(arr, initialDepth, true); } + /** + * Print. + * @param arr the arr + * @param initialDepth the initial depth + * @param excludeWIPs the exclude wi ps + */ public void print(List<BOMNode> arr, int initialDepth, boolean excludeWIPs) { if (root != null) { root.print(arr, getRootQuantity(), initialDepth, excludeWIPs); @@ -267,6 +282,11 @@ public class BOMTree { print(arr, 0, false); } + /** + * Print. + * @param arr the arr + * @param excludeWIPs the exclude wi ps + */ public void print(List<BOMNode> arr, boolean excludeWIPs) { print(arr, 0, excludeWIPs); } @@ -312,7 +332,8 @@ public class BOMTree { * @return returns the work effort id * @throws GenericEntityException If a db problem occurs. */ - public String createManufacturingOrders(String facilityId, Date date, String workEffortName, String description, String routingId, String orderId, String orderItemSeqId, String shipGroupSeqId, String shipmentId, GenericValue userLogin) throws GenericEntityException { + public String createManufacturingOrders(String facilityId, Date date, String workEffortName, String description, String routingId, + String orderId, String orderItemSeqId, String shipGroupSeqId, String shipmentId, GenericValue userLogin) throws GenericEntityException { String workEffortId = null; if (root != null) { if (UtilValidate.isEmpty(facilityId)) { @@ -332,12 +353,17 @@ public class BOMTree { facilityId = shipment.getString("originFacilityId"); } } - Map<String, Object> tmpMap = root.createManufacturingOrder(facilityId, date, workEffortName, description, routingId, orderId, orderItemSeqId, shipGroupSeqId, shipmentId, true, true); + Map<String, Object> tmpMap = root.createManufacturingOrder(facilityId, date, workEffortName, description, routingId, orderId, + orderItemSeqId, shipGroupSeqId, shipmentId, true, true); workEffortId = (String) tmpMap.get("productionRunId"); } return workEffortId; } + /** + * Gets products in packages. + * @param arr the arr + */ public void getProductsInPackages(List<BOMNode> arr) { if (root != null) { root.getProductsInPackages(arr, getRootQuantity(), 0, false); diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java index 962a013..8720bbc 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java @@ -56,11 +56,14 @@ public final class ProductionRunHelper { if (productionRunId != null) { GenericValue productionRun = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", productionRunId).queryOne(); if (productionRun != null) { - List<GenericValue> productionRunProducts = productionRun.getRelated("WorkEffortGoodStandard", UtilMisc.toMap("workEffortGoodStdTypeId", "PRUN_PROD_DELIV"), null, false); + List<GenericValue> productionRunProducts = productionRun.getRelated("WorkEffortGoodStandard", + UtilMisc.toMap("workEffortGoodStdTypeId", "PRUN_PROD_DELIV"), null, false); GenericValue productionRunProduct = EntityUtil.getFirst(productionRunProducts); GenericValue productProduced = productionRunProduct.getRelatedOne("Product", true); - List<GenericValue> productionRunComponents = productionRun.getRelated("WorkEffortGoodStandard", UtilMisc.toMap("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED"), null, false); - List<GenericValue> productionRunRoutingTasks = productionRun.getRelated("FromWorkEffortAssoc", UtilMisc.toMap("workEffortTypeId", "PROD_ORDER_TASK"), null, false); + List<GenericValue> productionRunComponents = productionRun.getRelated("WorkEffortGoodStandard", + UtilMisc.toMap("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED"), null, false); + List<GenericValue> productionRunRoutingTasks = productionRun.getRelated("FromWorkEffortAssoc", + UtilMisc.toMap("workEffortTypeId", "PROD_ORDER_TASK"), null, false); result.put("productionRunProduct", productionRunProduct); result.put("productProduced", productProduced); result.put("productionRunComponents", productionRunComponents); @@ -82,7 +85,8 @@ public final class ProductionRunHelper { return (UtilValidate.isNotEmpty(tasks)); } - public static void getLinkedProductionRuns(Delegator delegator, LocalDispatcher dispatcher, String productionRunId, List<ProductionRun> productionRuns) throws GenericEntityException { + public static void getLinkedProductionRuns(Delegator delegator, LocalDispatcher dispatcher, String productionRunId, + List<ProductionRun> productionRuns) throws GenericEntityException { productionRuns.add(new ProductionRun(productionRunId, delegator, dispatcher)); List<GenericValue> linkedWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAssoc") .where("workEffortIdTo", productionRunId, @@ -93,7 +97,7 @@ public final class ProductionRunHelper { } } - public static String getRootProductionRun(Delegator delegator, String productionRunId) throws GenericEntityException { + public static String getRootProductionRun(Delegator delegator, String productionRunId) throws GenericEntityException { GenericValue linkedWorkEffort = EntityQuery.use(delegator).from("WorkEffortAssoc") .where("workEffortIdFrom", productionRunId, "workEffortAssocTypeId", "WORK_EFF_PRECEDENCY") .queryFirst(); 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 5720c60..a18c266 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 @@ -264,8 +264,8 @@ public class ProductionRunServices { if (workEffortName == null) { String prdName = UtilValidate.isNotEmpty(product.getString("productName")) ? product.getString("productName") : product.getString( "productId"); - String wefName = UtilValidate.isNotEmpty(routing.getString("workEffortName")) ? routing.getString("workEffortName") : - routing.getString("workEffortId"); + String wefName = UtilValidate.isNotEmpty(routing.getString("workEffortName")) ? routing.getString("workEffortName") + : routing.getString("workEffortId"); workEffortName = prdName + "-" + wefName; } @@ -387,7 +387,8 @@ public class ProductionRunServices { // The components variable contains a list of BOMNodes: // each node represents a product (component). GenericValue productBom = node.getProductAssoc(); - if ((productBom.getString("routingWorkEffortId") == null && first) || (productBom.getString("routingWorkEffortId") != null && productBom.getString("routingWorkEffortId").equals(routingTask.getString("workEffortId")))) { + if ((productBom.getString("routingWorkEffortId") == null && first) || (productBom.getString("routingWorkEffortId") != null + && productBom.getString("routingWorkEffortId").equals(routingTask.getString("workEffortId")))) { serviceContext.clear(); serviceContext.put("workEffortId", productionRunTaskId); // Here we get the ProductAssoc record from the BOMNode @@ -483,7 +484,8 @@ public class ProductionRunServices { /** * Make a copy of the cost calc entities that were defined on the template routing task to the new production run task. */ - private static void cloneWorkEffortCostCalcs(DispatchContext dctx, GenericValue userLogin, String routingTaskId, String productionRunTaskId) throws GeneralException { + private static void cloneWorkEffortCostCalcs(DispatchContext dctx, GenericValue userLogin, String routingTaskId, String productionRunTaskId) + throws GeneralException { List<GenericValue> workEffortCostCalcs = null; try { workEffortCostCalcs = EntityUtil.filterByDate( @@ -663,7 +665,8 @@ public class ProductionRunServices { } // PRUN_CREATED or PRUN_SCHEDULED --> PRUN_DOC_PRINTED - if (("PRUN_CREATED".equals(currentStatusId) || "PRUN_SCHEDULED".equals(currentStatusId)) && (statusId == null || "PRUN_DOC_PRINTED".equals(statusId))) { + if (("PRUN_CREATED".equals(currentStatusId) || "PRUN_SCHEDULED".equals(currentStatusId)) && (statusId == null + || "PRUN_DOC_PRINTED".equals(statusId))) { // change only the production run (header) status to PRUN_DOC_PRINTED Map<String, Object> serviceContext = new HashMap<>(); serviceContext.clear(); @@ -869,7 +872,8 @@ public class ProductionRunServices { // PRUN_CREATED or PRUN_SCHEDULED or PRUN_DOC_PRINTED --> PRUN_RUNNING // this should be called only when the first task is started - if (("PRUN_CREATED".equals(currentStatusId) || "PRUN_SCHEDULED".equals(currentStatusId) || "PRUN_DOC_PRINTED".equals(currentStatusId)) && (statusId == null || "PRUN_RUNNING".equals(statusId))) { + if (("PRUN_CREATED".equals(currentStatusId) || "PRUN_SCHEDULED".equals(currentStatusId) || "PRUN_DOC_PRINTED".equals(currentStatusId)) + && (statusId == null || "PRUN_RUNNING".equals(statusId))) { // change the production run task status to PRUN_RUNNING // if necessary change the production run (header) status to PRUN_RUNNING if (!allPrecTaskCompletedOrRunning) { @@ -1154,7 +1158,8 @@ public class ProductionRunServices { } result.put("totalCost", totalCost); } catch (GenericEntityException | GenericServiceException exc) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunUnableToFindCosts", locale) + " " + workEffortId + " " + exc.getMessage()); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunUnableToFindCosts", locale) + + " " + workEffortId + " " + exc.getMessage()); } return result; } @@ -1370,8 +1375,9 @@ public class ProductionRunServices { List<GenericValue> pRRoutingTasks = productionRun.getProductionRunRoutingTasks(); boolean first = true; for (GenericValue routingTask : pRRoutingTasks) { - if (priority.equals(routingTask.get("priority")) && !routingTaskId.equals(routingTask.get("workEffortId"))) + if (priority.equals(routingTask.get("priority")) && !routingTaskId.equals(routingTask.get("workEffortId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingRoutingTaskSeqIdAlreadyExist", locale)); + } if (routingTaskId.equals(routingTask.get("workEffortId"))) { routingTask.set("estimatedSetupMillis", ((BigDecimal) context.get("estimatedSetupMillis")).doubleValue()); routingTask.set("estimatedMilliSeconds", ((BigDecimal) context.get("estimatedMilliSeconds")).doubleValue()); @@ -1580,13 +1586,13 @@ public class ProductionRunServices { Timestamp estimatedCompletionDate = (Timestamp) context.get("estimatedCompletionDate"); Double estimatedSetupMillis = null; - if (context.get("estimatedSetupMillis") != null) + if (context.get("estimatedSetupMillis") != null) { estimatedSetupMillis = ((BigDecimal) context.get("estimatedSetupMillis")).doubleValue(); - + } Double estimatedMilliSeconds = null; - if (context.get("estimatedMilliSeconds") != null) + if (context.get("estimatedMilliSeconds") != null) { estimatedMilliSeconds = ((BigDecimal) context.get("estimatedMilliSeconds")).doubleValue(); - + } // The production run is loaded ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); BigDecimal pRQuantity = productionRun.getQuantity(); @@ -2550,10 +2556,12 @@ public class ProductionRunServices { try { serviceResult = dispatcher.runSync("createProductionRunsForProductBom", serviceContext); if (ServiceUtil.isError(serviceResult)) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunNotCreated", locale) + ": " + ServiceUtil.getErrorMessage(serviceResult)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunNotCreated", locale) + + ": " + ServiceUtil.getErrorMessage(serviceResult)); } } catch (GenericServiceException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunNotCreated", locale) + ": " + e.getMessage()); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunNotCreated", locale) + + ": " + e.getMessage()); } if (ServiceUtil.isError(serviceResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); @@ -3025,7 +3033,9 @@ public class ProductionRunServices { .cache().queryList(); } if (UtilValidate.isNotEmpty(existingProductionRuns)) { - Debug.logWarning("Production Run for order item [" + orderItemOrShipGroupAssoc.getString("orderId") + "/" + orderItemOrShipGroupAssoc.getString("orderItemSeqId") + "] and ship group [" + shipGroupSeqId + "] already exists.", MODULE); + Debug.logWarning("Production Run for order item [" + orderItemOrShipGroupAssoc.getString("orderId") + "/" + + orderItemOrShipGroupAssoc.getString("orderItemSeqId") + "] and ship group [" + shipGroupSeqId + "] already exists.", + MODULE); continue; } } catch (GenericEntityException gee) { @@ -3486,8 +3496,8 @@ public class ProductionRunServices { List<Map<String, Object>> components = UtilGenerics.cast(serviceResult.get("componentsMap")); if (UtilValidate.isEmpty(components)) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, - "ManufacturingProductionRunCannotDecomposingInventoryItemNoComponentsFound", UtilMisc.toMap("productId", inventoryItem.getString( - "productId")), locale)); + "ManufacturingProductionRunCannotDecomposingInventoryItemNoComponentsFound", UtilMisc.toMap("productId", + inventoryItem.getString("productId")), locale)); } for (Map<String, Object> component : components) { // get the component's standard cost @@ -3658,8 +3668,8 @@ public class ProductionRunServices { if (remainingQty.compareTo(quantityNotAvailableRem) >= 0) { remainingQty = remainingQty.subtract(quantityNotAvailableRem); currentDateMap.put("remainingQty", remainingQty); - GenericValue orderItemShipGrpInvRes = EntityQuery.use(delegator).from("OrderItemShipGrpInvRes"). - where("orderId", genericResult.get("orderId"), + GenericValue orderItemShipGrpInvRes = EntityQuery.use(delegator).from("OrderItemShipGrpInvRes") + .where("orderId", genericResult.get("orderId"), "shipGroupSeqId", genericResult.get("shipGroupSeqId"), "orderItemSeqId", genericResult.get("orderItemSeqId"), "inventoryItemId", genericResult.get("inventoryItemId")) diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java index 89c2299..f8b08a8 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java @@ -57,7 +57,8 @@ public class InventoryEventPlannedServices { createOrUpdateMrpEvent(parameters, quantity, (String) context.get("facilityId"), (String) context.get("eventName"), false, delegator); } catch (GenericEntityException e) { Debug.logError(e, "Error : findOne(\"MrpEvent\", parameters =)" + parameters, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCreateOrUpdateEvent", UtilMisc.toMap("parameters", parameters), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCreateOrUpdateEvent", + UtilMisc.toMap("parameters", parameters), locale)); } return ServiceUtil.returnSuccess(); } 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 18c9c52..4e655fc 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 @@ -52,18 +52,19 @@ public class ProposedOrder { private static final String MODULE = ProposedOrder.class.getName(); private static final String RESOURCE = "ManufacturingUiLabels"; - protected GenericValue product; - protected boolean isBuilt; - protected String productId; - protected String facilityId; - protected String manufacturingFacilityId; - protected String mrpName; - protected Timestamp requiredByDate; - protected Timestamp requirementStartDate; - protected BigDecimal quantity; + private GenericValue product; + private boolean isBuilt; + private String productId; + private String facilityId; + private String manufacturingFacilityId; + private String mrpName; + private Timestamp requiredByDate; + private Timestamp requirementStartDate; + private BigDecimal quantity; - public ProposedOrder(GenericValue product, String facilityId, String manufacturingFacilityId, boolean isBuilt, Timestamp requiredByDate, BigDecimal quantity) { + public ProposedOrder(GenericValue product, String facilityId, String manufacturingFacilityId, boolean isBuilt, Timestamp requiredByDate, + BigDecimal quantity) { this.product = product; this.productId = product.getString("productId"); this.facilityId = facilityId; @@ -105,7 +106,8 @@ public class ProposedOrder { * <li>else null.</li> * </ul> **/ - public Map<String, Object> calculateStartDate(int daysToShip, GenericValue routing, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) { + public Map<String, Object> calculateStartDate(int daysToShip, GenericValue routing, Delegator delegator, LocalDispatcher dispatcher, + GenericValue userLogin) { Map<String, Object> result = null; Timestamp endDate = (Timestamp) requiredByDate.clone(); Timestamp startDate = endDate; @@ -118,8 +120,8 @@ public class ProposedOrder { "ignoreDefaultRouting", "Y", "userLogin", userLogin); Map<String, Object> routingOutMap = dispatcher.runSync("getProductRouting", routingInMap); if (ServiceUtil.isError(routingOutMap)) { - String errorMessage = ServiceUtil.getErrorMessage(routingOutMap); - Debug.logError(errorMessage, MODULE); + String errorMessage = ServiceUtil.getErrorMessage(routingOutMap); + Debug.logError(errorMessage, MODULE); } routing = (GenericValue) routingOutMap.get("routing"); listRoutingTaskAssoc = UtilGenerics.cast(routingOutMap.get("tasks")); @@ -128,7 +130,8 @@ public class ProposedOrder { BOMTree tree = null; List<BOMNode> components = new LinkedList<>(); try { - tree = new BOMTree(product.getString("productId"), "MANUF_COMPONENT", requiredByDate, BOMTree.EXPLOSION_SINGLE_LEVEL, delegator, dispatcher, userLogin); + tree = new BOMTree(product.getString("productId"), "MANUF_COMPONENT", requiredByDate, + BOMTree.EXPLOSION_SINGLE_LEVEL, delegator, dispatcher, userLogin); tree.setRootQuantity(quantity); tree.print(components, true); if (!components.isEmpty()) components.remove(0); @@ -137,7 +140,8 @@ public class ProposedOrder { tree = null; } if (tree != null && tree.getRoot() != null && tree.getRoot().getProduct() != null) { - routingInMap = UtilMisc.toMap("productId", tree.getRoot().getProduct().getString("productId"), "userLogin", userLogin); + routingInMap = UtilMisc.toMap("productId", tree.getRoot().getProduct().getString("productId"), + "userLogin", userLogin); routingOutMap = dispatcher.runSync("getProductRouting", routingInMap); if (ServiceUtil.isError(routingOutMap)) { String errorMessage = ServiceUtil.getErrorMessage(routingOutMap); @@ -192,13 +196,14 @@ public class ProposedOrder { } } else { // routing is null - Debug.logError("No routing found for product = "+ product.getString("productId"), MODULE); + Debug.logError("No routing found for product = " + product.getString("productId"), MODULE); } } else { // the product is purchased // TODO: REVIEW this code try { - GenericValue techDataCalendar = product.getDelegator().findOne("TechDataCalendar", UtilMisc.toMap("calendarId", "SUPPLIER"), true); + GenericValue techDataCalendar = product.getDelegator().findOne("TechDataCalendar", UtilMisc.toMap("calendarId", + "SUPPLIER"), true); startDate = TechDataServices.addBackward(techDataCalendar, endDate, timeToShip); } catch (GenericEntityException e) { Debug.logError(e, "Error : reading SUPPLIER TechDataCalendar: " + e.getMessage(), MODULE); @@ -214,7 +219,7 @@ public class ProposedOrder { * Read the first ProductFacility.reorderQuantity and calculate the quantity : if (quantity < reorderQuantity) quantity = reorderQuantity; **/ // FIXME: facilityId - public void calculateQuantityToSupply(BigDecimal reorderQuantity, BigDecimal minimumStock, ListIterator<GenericValue> listIterIEP) { + public void calculateQuantityToSupply(BigDecimal reorderQuantity, BigDecimal minimumStock, ListIterator<GenericValue> listIterIEP) { // TODO : use a better algorithm using Order management cost et Product Stock cost to calculate the re-order quantity // the variable listIterIEP will be used for that if (quantity.compareTo(reorderQuantity) < 0) { @@ -238,7 +243,8 @@ public class ProposedOrder { if (isBuilt) { try { List<BOMNode> bom = new LinkedList<>(); - BOMTree tree = new BOMTree(productId, "MANUF_COMPONENT", null, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin); + BOMTree tree = new BOMTree(productId, "MANUF_COMPONENT", null, BOMTree.EXPLOSION_MANUFACTURING, delegator, + dispatcher, userLogin); tree.setRootQuantity(quantity); tree.print(bom); requirementStartDate = tree.getRoot().getStartDate(manufacturingFacilityId, requiredByDate, true); @@ -248,11 +254,11 @@ public class ProposedOrder { } parameters.put("productId", productId); parameters.put("statusId", "REQ_PROPOSED"); - parameters.put("facilityId", (isBuilt? manufacturingFacilityId: facilityId)); + parameters.put("facilityId", (isBuilt ? manufacturingFacilityId : facilityId)); parameters.put("requiredByDate", requiredByDate); parameters.put("requirementStartDate", requirementStartDate); parameters.put("quantity", quantity); - parameters.put("requirementTypeId", (isBuilt? "INTERNAL_REQUIREMENT" : "PRODUCT_REQUIREMENT")); + parameters.put("requirementTypeId", (isBuilt ? "INTERNAL_REQUIREMENT" : "PRODUCT_REQUIREMENT")); if (mrpName != null) { parameters.put("description", "MRP_" + mrpName); } else { @@ -272,6 +278,10 @@ public class ProposedOrder { } } + /** + * Sets mrp name. + * @param mrpName the mrp name + */ public void setMrpName(String mrpName) { this.mrpName = mrpName; } diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/routing/RoutingServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/routing/RoutingServices.java index 0a948bb..768c54b 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/routing/RoutingServices.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/routing/RoutingServices.java @@ -70,7 +70,8 @@ public class RoutingServices { try { task = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", taskId).queryOne(); } catch (GenericEntityException gee) { - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingRoutingErrorFindingTask", UtilMisc.toMap("taskId", taskId), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingRoutingErrorFindingTask", + UtilMisc.toMap("taskId", taskId), locale)); } // FIXME: the ProductionRun.getEstimatedTaskTime(...) method will be removed and // its logic will be implemented inside this method. diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/techdata/TechDataServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/techdata/TechDataServices.java index c30b4fd..a6cf805 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/techdata/TechDataServices.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/techdata/TechDataServices.java @@ -57,7 +57,8 @@ public class TechDataServices { * Used to retrieve some RoutingTasks (WorkEffort) selected by Name or MachineGroup ordered by Name * @param ctx the dispatch context * @param context a map containing workEffortName (routingTaskName) and fixedAssetId (MachineGroup or ANY) - * @return result a map containing lookupResult (list of RoutingTask <=> workEffortId with currentStatusId = "ROU_ACTIVE" and workEffortTypeId = "ROU_TASK" + * @return result a map containing lookupResult (list of RoutingTask <=> workEffortId with currentStatusId = + * "ROU_ACTIVE" and workEffortTypeId = "ROU_TASK" */ public static Map<String, Object> lookupRoutingTask(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); @@ -85,7 +86,8 @@ public class TechDataServices { .queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingTechDataWorkEffortNotExist", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingTechDataWorkEffortNotExist", + UtilMisc.toMap("errorString", e.toString()), locale)); } if (listRoutingTask == null) { listRoutingTask = new LinkedList<>(); @@ -127,7 +129,8 @@ public class TechDataServices { .queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, MODULE); - return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingTechDataWorkEffortAssocNotExist", UtilMisc.toMap("errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingTechDataWorkEffortAssocNotExist", + UtilMisc.toMap("errorString", e.toString()), locale)); } if (listRoutingTaskAssoc != null) { @@ -136,23 +139,31 @@ public class TechDataServices { || !workEffortIdTo.equals(routingTaskAssoc.getString("workEffortIdTo")) || !workEffortAssocTypeId.equals(routingTaskAssoc.getString("workEffortAssocTypeId")) || !sequenceNum.equals(routingTaskAssoc.getLong("sequenceNum"))) { - if (routingTaskAssoc.getTimestamp("thruDate") == null && routingTaskAssoc.getTimestamp("fromDate") == null) + if (routingTaskAssoc.getTimestamp("thruDate") == null && routingTaskAssoc.getTimestamp("fromDate") == null) { sequenceNumNotOk = "Y"; - else if (routingTaskAssoc.getTimestamp("thruDate") == null) { + } else if (routingTaskAssoc.getTimestamp("thruDate") == null) { if (thruDate == null) sequenceNumNotOk = "Y"; - else if (thruDate.after(routingTaskAssoc.getTimestamp("fromDate"))) sequenceNumNotOk = "Y"; + else if (thruDate.after(routingTaskAssoc.getTimestamp("fromDate"))) { + sequenceNumNotOk = "Y"; + } } else if (routingTaskAssoc.getTimestamp("fromDate") == null) { if (fromDate == null) sequenceNumNotOk = "Y"; - else if (fromDate.before(routingTaskAssoc.getTimestamp("thruDate"))) sequenceNumNotOk = "Y"; - } else if (fromDate == null && thruDate == null) sequenceNumNotOk = "Y"; - else if (thruDate == null) { + else if (fromDate.before(routingTaskAssoc.getTimestamp("thruDate"))) { + sequenceNumNotOk = "Y"; + } + } else if (fromDate == null && thruDate == null) { + sequenceNumNotOk = "Y"; + } else if (thruDate == null) { if (fromDate.before(routingTaskAssoc.getTimestamp("thruDate"))) sequenceNumNotOk = "Y"; } else if (fromDate == null) { if (thruDate.after(routingTaskAssoc.getTimestamp("fromDate"))) sequenceNumNotOk = "Y"; } else if (routingTaskAssoc.getTimestamp("fromDate").before(thruDate) && fromDate.before(routingTaskAssoc.getTimestamp( - "thruDate"))) + "thruDate"))) { sequenceNumNotOk = "Y"; - } else if (createProcess) sequenceNumNotOk = "Y"; + } + } else if (createProcess) { + sequenceNumNotOk = "Y"; + } } } result.put("sequenceNumNotOk", sequenceNumNotOk); @@ -277,7 +288,8 @@ public class TechDataServices { if (moveDay != 0) return 0; Time startTime = (Time) position.get("startTime"); Double capacity = (Double) position.get("capacity"); - Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateFrom).getTime() + startTime.getTime() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET)); + Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateFrom).getTime() + startTime.getTime() + + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET)); if (dateFrom.before(startAvailablePeriod)) return 0; Timestamp endAvailablePeriod = new Timestamp(startAvailablePeriod.getTime() + capacity.longValue()); if (dateFrom.after(endAvailablePeriod)) return 0; @@ -307,7 +319,8 @@ public class TechDataServices { Time startTime = (Time) position.get("startTime"); int moveDay = (Integer) position.get("moveDay"); dateTo = (moveDay == 0) ? dateFrom : UtilDateTime.getDayStart(dateFrom, moveDay); - Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateTo).getTime() + startTime.getTime() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET)); + Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateTo).getTime() + startTime.getTime() + + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET)); if (dateTo.before(startAvailablePeriod)) { dateTo = startAvailablePeriod; } else { @@ -355,7 +368,8 @@ public class TechDataServices { /** Used to find the last day in the TechDataCalendarWeek where capacity != 0, ending at dayEnd, dayEnd included. * @param techDataCalendarWeek The TechDataCalendarWeek cover * @param dayEnd - * @return a map with the capacity (Double) available, the startTime and moveDay (int): the number of day it's necessary to move to have capacity available + * @return a map with the capacity (Double) available, the startTime and moveDay (int): the number of day it's + * necessary to move to have capacity available */ public static Map<String, Object> dayEndCapacityAvailable(GenericValue techDataCalendarWeek, int dayEnd) { Map<String, Object> result = new HashMap<>(); @@ -426,7 +440,8 @@ public class TechDataServices { if (moveDay != 0) return 0; Time startTime = (Time) position.get("startTime"); Double capacity = (Double) position.get("capacity"); - Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateFrom).getTime() + startTime.getTime() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET)); + Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateFrom).getTime() + startTime.getTime() + + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET)); if (dateFrom.before(startAvailablePeriod)) return 0; Timestamp endAvailablePeriod = new Timestamp(startAvailablePeriod.getTime() + capacity.longValue()); if (dateFrom.after(endAvailablePeriod)) return 0; @@ -457,7 +472,8 @@ public class TechDataServices { int moveDay = (Integer) position.get("moveDay"); Double capacity = (Double) position.get("capacity"); dateTo = (moveDay == 0) ? dateFrom : UtilDateTime.getDayEnd(dateFrom, (long) moveDay); - Timestamp endAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateTo).getTime() + startTime.getTime() + capacity.longValue() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET)); + Timestamp endAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateTo).getTime() + startTime.getTime() + capacity.longValue() + + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET)); if (dateTo.after(endAvailablePeriod)) { dateTo = endAvailablePeriod; } else { @@ -468,7 +484,8 @@ public class TechDataServices { moveDay = (Integer) position.get("moveDay"); capacity = (Double) position.get("capacity"); if (moveDay != 0) dateTo = UtilDateTime.getDayStart(dateTo, moveDay); - dateTo.setTime(dateTo.getTime() + startTime.getTime() + capacity.longValue() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET)); + dateTo.setTime(dateTo.getTime() + startTime.getTime() + capacity.longValue() + cDateTrav.get(Calendar.ZONE_OFFSET) + + cDateTrav.get(Calendar.DST_OFFSET)); } result.put("dateTo", dateTo); result.put("previousCapacity", position.get("capacity")); 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 995a8fd..468766b 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 @@ -71,7 +71,8 @@ public class OrderManagerEvents { GenericValue placingCustomer = null; try { paymentPrefs = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId", orderId).queryList(); - placingCustomer = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "roleTypeId", "PLACING_CUSTOMER").queryFirst(); + placingCustomer = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "roleTypeId", + "PLACING_CUSTOMER").queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, "Problems looking up order payment preferences", MODULE); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, "OrderErrorProcessingOfflinePayments", locale)); @@ -88,7 +89,8 @@ public class OrderManagerEvents { // create a payment record Map<String, Object> results = null; try { - results = dispatcher.runSync("createPaymentFromPreference", UtilMisc.toMap("orderPaymentPreferenceId", ppref.get("orderPaymentPreferenceId"), + results = dispatcher.runSync("createPaymentFromPreference", UtilMisc.toMap("orderPaymentPreferenceId", + ppref.get("orderPaymentPreferenceId"), "paymentFromId", placingCustomer.getString("partyId"), "comments", "Payment received offline and manually entered.")); if (ServiceUtil.isError(results)) { String errorMessage = ServiceUtil.getErrorMessage(results); @@ -107,7 +109,8 @@ public class OrderManagerEvents { delegator.storeAll(toBeStored); } catch (GenericEntityException e) { Debug.logError(e, "Problems storing payment information", MODULE); - request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, "OrderProblemStoringReceivedPaymentInformation", locale)); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, + "OrderProblemStoringReceivedPaymentInformation", locale)); return "error"; } @@ -147,7 +150,8 @@ public class OrderManagerEvents { List<GenericValue> paymentMethodTypes = null; try { - paymentMethodTypes = EntityQuery.use(delegator).from("PaymentMethodType").where(EntityCondition.makeCondition("paymentMethodTypeId", EntityOperator.NOT_EQUAL, "EXT_OFFLINE")).queryList(); + paymentMethodTypes = EntityQuery.use(delegator).from("PaymentMethodType").where(EntityCondition.makeCondition("paymentMethodTypeId", + EntityOperator.NOT_EQUAL, "EXT_OFFLINE")).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Problems getting payment types", MODULE); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, "OrderProblemsWithPaymentTypeLookup", locale)); @@ -233,7 +237,8 @@ public class OrderManagerEvents { if (paymentTypeAmount.compareTo(BigDecimal.ZERO) > 0) { // create the OrderPaymentPreference // TODO: this should be done with a service - Map<String, String> prefFields = UtilMisc.<String, String> toMap("orderPaymentPreferenceId", delegator.getNextSeqId("OrderPaymentPreference")); + Map<String, String> prefFields = UtilMisc.<String, String>toMap("orderPaymentPreferenceId", + delegator.getNextSeqId("OrderPaymentPreference")); GenericValue paymentPreference = delegator.makeValue("OrderPaymentPreference", prefFields); paymentPreference.set("paymentMethodTypeId", paymentMethodType.getString("paymentMethodTypeId")); paymentPreference.set("maxAmount", paymentTypeAmount); @@ -247,7 +252,8 @@ public class OrderManagerEvents { try { if (UtilValidate.isEmpty(paymentReference)) { // get the old order preference to copy the reference number and set it as paymentRefNumber for the payment - GenericValue currentPref = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId", orderId).queryFirst(); + GenericValue currentPref = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId", + orderId).queryFirst(); if (currentPref != null) { paymentReference = (String) currentPref.get("manualRefNum"); paymentPreference.set("manualRefNum", paymentReference); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java index 74846ce..b45d561 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderChangeHelper.java @@ -135,7 +135,8 @@ public final class OrderChangeHelper { return true; } - public static void orderStatusChanges(LocalDispatcher dispatcher, GenericValue userLogin, String orderId, String orderStatus, String fromItemStatus, String toItemStatus, String digitalItemStatus) throws GenericServiceException { + public static void orderStatusChanges(LocalDispatcher dispatcher, GenericValue userLogin, String orderId, String orderStatus, + String fromItemStatus, String toItemStatus, String digitalItemStatus) throws GenericServiceException { // set the status on the order header Map<String, Object> statusFields = UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", orderStatus, "userLogin", userLogin); Map<String, Object> statusResult = dispatcher.runSync("changeOrderStatus", statusFields); @@ -194,7 +195,8 @@ public final class OrderChangeHelper { String isDigital = productType.getString("isDigital"); if (isDigital != null && "Y".equalsIgnoreCase(isDigital)) { // update the status - Map<String, Object> digitalStatusFields = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "statusId", digitalItemStatus, "userLogin", userLogin); + Map<String, Object> digitalStatusFields = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", + orderItemSeqId, "statusId", digitalItemStatus, "userLogin", userLogin); Map<String, Object> digitalStatusChange = dispatcher.runSync("changeOrderItemStatus", digitalStatusFields); if (ServiceUtil.isError(digitalStatusChange)) { String errorMessage = ServiceUtil.getErrorMessage(digitalStatusChange); @@ -207,7 +209,8 @@ public final class OrderChangeHelper { String orderItemType = orderItem.getString("orderItemTypeId"); if (!"PRODUCT_ORDER_ITEM".equals(orderItemType)) { // non-product items don't ship; treat as a digital item - Map<String, Object> digitalStatusFields = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "statusId", digitalItemStatus, "userLogin", userLogin); + Map<String, Object> digitalStatusFields = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", + orderItemSeqId, "statusId", digitalItemStatus, "userLogin", userLogin); Map<String, Object> digitalStatusChange = dispatcher.runSync("changeOrderItemStatus", digitalStatusFields); if (ServiceUtil.isError(digitalStatusChange)) { String errorMessage = ServiceUtil.getErrorMessage(digitalStatusChange); @@ -222,7 +225,8 @@ public final class OrderChangeHelper { } } - public static void cancelInventoryReservations(LocalDispatcher dispatcher, GenericValue userLogin, String orderId) throws GenericServiceException { + public static void cancelInventoryReservations(LocalDispatcher dispatcher, GenericValue userLogin, String orderId) + throws GenericServiceException { // cancel the inventory reservations Map<String, Object> cancelInvFields = UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", userLogin); Map<String, Object> cancelInvResult = dispatcher.runSync("cancelOrderInventoryReservation", cancelInvFields); @@ -233,7 +237,8 @@ public final class OrderChangeHelper { } } - public static void releasePaymentAuthorizations(LocalDispatcher dispatcher, GenericValue userLogin, String orderId) throws GenericServiceException { + public static void releasePaymentAuthorizations(LocalDispatcher dispatcher, GenericValue userLogin, String orderId) + throws GenericServiceException { Map<String, Object> releaseFields = UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", userLogin); Map<String, Object> releaseResult = dispatcher.runSync("releaseOrderPayments", releaseFields); if (ServiceUtil.isError(releaseResult)) { @@ -265,7 +270,8 @@ public final class OrderChangeHelper { if (UtilValidate.isEmpty(payments)) { // only do this one time; if we have payment already for this pref ignore. Map<String, Object> results = dispatcher.runSync("createPaymentFromPreference", - UtilMisc.<String, Object>toMap("userLogin", userLogin, "orderPaymentPreferenceId", opp.getString("orderPaymentPreferenceId"), + UtilMisc.<String, Object>toMap("userLogin", userLogin, "orderPaymentPreferenceId", + opp.getString("orderPaymentPreferenceId"), "paymentRefNum", UtilDateTime.nowTimestamp().toString(), "paymentFromId", partyId)); if (ServiceUtil.isError(results)) { String errorMessage = ServiceUtil.getErrorMessage(results); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java index b7f932e..6a594ba 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderEvents.java @@ -67,7 +67,8 @@ public class OrderEvents { .queryFirst(); if (orderRoleAndProductContentInfo == null) { - request.setAttribute("_ERROR_MESSAGE_", "No record of purchase for digital download found (dataResourceId=[" + dataResourceId + "])."); + request.setAttribute("_ERROR_MESSAGE_", "No record of purchase for digital download found (dataResourceId=[" + + dataResourceId + "])."); return "error"; } @@ -79,7 +80,8 @@ public class OrderEvents { } OutputStream os = response.getOutputStream(); GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne(); - Map<String, Object> resourceData = DataResourceWorker.getDataResourceStream(dataResource, "", application.getInitParameter("webSiteId"), UtilHttp.getLocale(request), application.getRealPath("/"), false); + Map<String, Object> resourceData = DataResourceWorker.getDataResourceStream(dataResource, "", application.getInitParameter("webSiteId"), + UtilHttp.getLocale(request), application.getRealPath("/"), false); os.write(IOUtils.toByteArray((InputStream) resourceData.get("stream"))); os.flush(); } catch (GeneralException | IOException e) { 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 1d75f50..cdbb1bd 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 @@ -3328,7 +3328,8 @@ public class OrderReadHelper { * @return the order item statuses */ public static List<GenericValue> getOrderItemStatuses(GenericValue orderItem, List<GenericValue> orderStatuses) { - List<EntityExpr> contraints1 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, orderItem.get("orderItemSeqId"))); + List<EntityExpr> contraints1 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, + orderItem.get("orderItemSeqId"))); List<EntityExpr> contraints2 = UtilMisc.toList(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, null)); contraints2.add(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, DataModelConstants.SEQ_ID_NA)); contraints2.add(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, "")); @@ -3710,7 +3711,7 @@ public class OrderReadHelper { EntityUtil.filterByAnd(orderItemAttributes, UtilMisc.toMap("orderItemSeqId", orderItemSeqId, "attrName", attributeName))); } - return orderItemAttribute != null ? orderItemAttribute.getString("attrValue"): null; + return orderItemAttribute != null ? orderItemAttribute.getString("attrValue") : null; } /** @@ -3764,7 +3765,7 @@ public class OrderReadHelper { orderAttribute = orderAttributeMap.get(attributeName); } } - return orderAttribute != null ? orderAttribute.getString("attrValue"): null; + return orderAttribute != null ? orderAttribute.getString("attrValue") : null; } /** @@ -3998,7 +3999,8 @@ public class OrderReadHelper { EntityCondition.makeCondition("quantityAccepted", EntityOperator.GREATER_THAN, BigDecimal.ZERO), EntityCondition.makeCondition("orderItemSeqId", orderItem.getString("orderItemSeqId")))); Delegator delegator = orderItem.getDelegator(); - List<GenericValue> shipmentReceipts = EntityQuery.use(delegator).select("quantityAccepted", "quantityRejected").from("ShipmentReceiptAndItem").where(cond).queryList(); + List<GenericValue> shipmentReceipts = EntityQuery.use(delegator).select("quantityAccepted", "quantityRejected") + .from("ShipmentReceiptAndItem").where(cond).queryList(); for (GenericValue shipmentReceipt : shipmentReceipts) { if (shipmentReceipt.getBigDecimal("quantityAccepted") != null) { totalReceived = totalReceived.add(shipmentReceipt.getBigDecimal("quantityAccepted")); 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 4527aae..a143ab8 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 @@ -350,7 +350,8 @@ public class OrderReturnServices { if (returnItemResponse != null) { String replacementOrderId = returnItemResponse.getString("replacementOrderId"); Map<String, Object> svcCtx = UtilMisc.<String, Object>toMap("orderId", replacementOrderId, "userLogin", userLogin); - GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", replacementOrderId).queryOne(); + GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", + replacementOrderId).queryOne(); if ("ORDER_HOLD".equals(orderHeader.getString("statusId"))) { try { Map<String, Object> result = dispatcher.runSync("cancelOrderItem", svcCtx); 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 3cebfe5..0ba45c3 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 @@ -1436,8 +1436,8 @@ public class OrderServices { } } - if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), - "parentTypeId", "MARKETING_PKG_AUTO")) { + 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<>(); @@ -1734,7 +1734,7 @@ public class OrderServices { String facilityId = orderHeader.getString("originFacilityId"); if (facilityId != null) { GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, - UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); + UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); if (facilityContactMech != null) { try { shippingAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", @@ -1750,7 +1750,7 @@ public class OrderServices { // 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); + + "the origin facility [" + orderHeader.getString("originFacilityId") + "]", MODULE); continue; } @@ -1894,7 +1894,7 @@ public class OrderServices { } Map<String, Object> shippingEstMap = ShippingEvents.getShipEstimate(dispatcher, delegator, orh, shipGroupSeqId); - BigDecimal shippingTotal = null; + BigDecimal shippingTotal; if (UtilValidate.isEmpty(orh.getValidOrderItems(shipGroupSeqId))) { shippingTotal = ZERO; Debug.logInfo("No valid order items found - " + shippingTotal, MODULE); @@ -5222,7 +5222,9 @@ public class OrderServices { coh.createOrder(userLogin); } else { // if there are no items to drop ship, then clear out the supplier partyId - Debug.logWarning("No drop ship items found for order [" + shipGroup.getString("orderId") + "] and ship group [" + shipGroup.getString("shipGroupSeqId") + "] and supplier party [" + shipGroup.getString("supplierPartyId") + "]. Supplier party information will be cleared for this ship group", MODULE); + Debug.logWarning("No drop ship items found for order [" + shipGroup.getString("orderId") + "] and ship group [" + + shipGroup.getString("shipGroupSeqId") + "] and supplier party [" + shipGroup.getString("supplierPartyId") + + "]. Supplier party information will be cleared for this ship group", MODULE); shipGroup.set("supplierPartyId", null); shipGroup.store(); @@ -5231,7 +5233,7 @@ public class OrderServices { } } } catch (GenericEntityException exc) { - // TODO: imporve error handling + // TODO: improve error handling return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "OrderOrderCreatingDropShipmentsError", UtilMisc.toMap("orderId", orderId, "errorString", exc.getMessage()), @@ -5747,7 +5749,7 @@ public class OrderServices { Locale locale = (Locale) context.get("locale"); try { GenericValue orderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", - orderPaymentPreferenceId).queryOne(); + orderPaymentPreferenceId).queryOne(); String orderId = orderPaymentPreference.getString("orderId"); String statusUserLogin = orderPaymentPreference.getString("createdByUserLogin"); GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); @@ -5830,7 +5832,8 @@ public class OrderServices { } else if ("TF_yr".equals(subscription.getString("canclAutmExtTimeUomId"))) { field = Calendar.YEAR; } else { - Debug.logWarning("Don't know anything about canclAutmExtTimeUomId [" + subscription.getString("canclAutmExtTimeUomId") + "], defaulting to month", MODULE); + Debug.logWarning("Don't know anything about canclAutmExtTimeUomId [" + subscription.getString("canclAutmExtTimeUomId") + + "], defaulting to month", MODULE); } endDate.add(field, Integer.parseInt(subscription.getString("canclAutmExtTime"))); @@ -6184,8 +6187,8 @@ public class OrderServices { } //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); 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 0bd116f..414fd8e 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 @@ -76,9 +76,11 @@ public class QuoteServices { GenericValue productStoreEmail = null; try { - productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", quote.get("productStoreId"), "emailType", emailType).queryOne(); + productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", + quote.get("productStoreId"), "emailType", emailType).queryOne(); } catch (GenericEntityException e) { - Debug.logError(e, "Problem getting the ProductStoreEmailSetting for productStoreId=" + quote.get("productStoreId") + " and emailType=" + emailType, MODULE); + Debug.logError(e, "Problem getting the ProductStoreEmailSetting for productStoreId=" + quote.get("productStoreId") + + " and emailType=" + emailType, MODULE); } if (productStoreEmail == null) { return ServiceUtil.returnFailure(UtilProperties.getMessage(RES_PRODUCT, @@ -169,7 +171,8 @@ public class QuoteServices { Map<String, Object> result = new HashMap<>(); try { - Map<String, Object> quoteIn = UtilMisc.toMap("quoteTypeId", quoteTypeId, "partyId", partyId, "issueDate", issueDate, "statusId", statusId, "currencyUomId", currencyUomId); + Map<String, Object> quoteIn = UtilMisc.toMap("quoteTypeId", quoteTypeId, "partyId", partyId, "issueDate", issueDate, + "statusId", statusId, "currencyUomId", currencyUomId); quoteIn.put("productStoreId", productStoreId); quoteIn.put("salesChannelEnumId", salesChannelEnumId); quoteIn.put("productStoreId", productStoreId); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java index 50266d5..e56fef6 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java @@ -331,8 +331,8 @@ public class CheckOutEvents { amount = new BigDecimal(amountStr); } catch (NumberFormatException e) { Debug.logError(e, MODULE); - errMsg = UtilProperties.getMessage(RES_ERROR, "checkevents.invalid_amount_set_for_payment_method", - (cart != null ? cart.getLocale() : Locale.getDefault())); + errMsg = UtilProperties.getMessage(RES_ERROR, "checkevents.invalid_amount_set_for_payment_method", (cart != null + ? cart.getLocale() : Locale.getDefault())); request.setAttribute("_ERROR_MESSAGE_", errMsg); return null; } @@ -398,7 +398,8 @@ public class CheckOutEvents { if (UtilValidate.isNotEmpty(taxAuthPartyGeoIds)) { try { Map<String, Object> createCustomerTaxAuthInfoResult = dispatcher.runSync("createCustomerTaxAuthInfo", - UtilMisc.toMap("partyId", cart.getPartyId(), "taxAuthPartyGeoIds", taxAuthPartyGeoIds, "partyTaxId", partyTaxId, "isExempt", isExempt)); + UtilMisc.toMap("partyId", cart.getPartyId(), "taxAuthPartyGeoIds", taxAuthPartyGeoIds, "partyTaxId", + partyTaxId, "isExempt", isExempt)); ServiceUtil.getMessages(request, createCustomerTaxAuthInfoResult, null); if (ServiceUtil.isError(createCustomerTaxAuthInfoResult)) { String errorMessage = ServiceUtil.getErrorMessage(createCustomerTaxAuthInfoResult); 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 38056f7..12edfb4 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 @@ -77,9 +77,9 @@ public class CheckOutHelper { private static final int DECIMALS = UtilNumber.getBigDecimalScale("order.decimals"); private static final RoundingMode ROUNDING = UtilNumber.getRoundingMode("order.rounding"); - protected LocalDispatcher dispatcher = null; - protected Delegator delegator = null; - protected ShoppingCart cart = null; + private LocalDispatcher dispatcher = null; + private Delegator delegator = null; + private ShoppingCart cart = null; public CheckOutHelper(LocalDispatcher dispatcher, Delegator delegator, ShoppingCart cart) { this.delegator = delegator; @@ -87,6 +87,11 @@ public class CheckOutHelper { this.cart = cart; } + /** + * Sets check out shipping address. + * @param shippingContactMechId the shipping contact mech id + * @return the check out shipping address + */ public Map<String, Object> setCheckOutShippingAddress(String shippingContactMechId) { List<String> errorMessages = new ArrayList<>(); Map<String, Object> result; @@ -242,7 +247,8 @@ public class CheckOutHelper { * @param billingAccountId the billing account id * @return the check out payment */ - public Map<String, Object> setCheckOutPayment(Map<String, Map<String, Object>> selectedPaymentMethods, List<String> singleUsePayments, String billingAccountId) { + public Map<String, Object> setCheckOutPayment(Map<String, Map<String, Object>> selectedPaymentMethods, List<String> singleUsePayments, + String billingAccountId) { List<String> errorMessages = new ArrayList<>(); Map<String, Object> result; String errMsg = null; 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 4b32127..1df8a22 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 @@ -926,7 +926,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } /** Ensure item total quantity */ - public void ensureItemsQuantity(List<ShoppingCartItem> cartItems, LocalDispatcher dispatcher, BigDecimal quantity) throws CartItemModifyException { + public void ensureItemsQuantity(List<ShoppingCartItem> cartItems, LocalDispatcher dispatcher, BigDecimal quantity) + throws CartItemModifyException { for (ShoppingCartItem item : cartItems) { if (item.getQuantity() != quantity) { item.setQuantity(quantity, dispatcher, this); @@ -935,7 +936,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } /** Ensure item total quantity */ - public BigDecimal ensureItemsTotalQuantity(List<ShoppingCartItem> cartItems, LocalDispatcher dispatcher, BigDecimal quantity) throws CartItemModifyException { + 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... BigDecimal quantityToKeep = quantity; @@ -950,7 +952,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { quantityRemoved = quantityRemoved.add(item.getQuantity()); this.removeCartItem(item, dispatcher); } else { - // there is some to keep, so reduce quantity to quantityToKeep, at this point we know we'll take up all of the rest of the quantityToKeep + // there is some to keep, so reduce quantity to quantityToKeep, at this point we know we'll take up all of the + // rest of the quantityToKeep quantityRemoved = quantityRemoved.add(item.getQuantity().subtract(quantityToKeep)); item.setQuantity(quantityToKeep, dispatcher, this); quantityToKeep = BigDecimal.ZERO; @@ -1067,7 +1070,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { /** Remove an item from the cart object. */ public void removeCartItem(int index, LocalDispatcher dispatcher) throws CartItemModifyException { if (isReadOnlyCart()) { - throw new CartItemModifyException("Cart items cannot be changed"); + throw new CartItemModifyException("Cart items cannot be changed"); } if (index < 0) { return; @@ -1295,7 +1298,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { String checkResult = ProductPromoWorker.checkCanUsePromoCode(promoCode, partyId, this.getDelegator(), locale); if (checkResult != null) { promoCodeIter.remove(); - Debug.logWarning(UtilProperties.getMessage(RES_ERROR, "OrderOnUserChangePromoCodeWasRemovedBecause", UtilMisc.toMap("checkResult", checkResult), locale), MODULE); + Debug.logWarning(UtilProperties.getMessage(RES_ERROR, "OrderOnUserChangePromoCodeWasRemovedBecause", + UtilMisc.toMap("checkResult", checkResult), locale), MODULE); } } @@ -2034,7 +2038,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } /** adds a payment method/payment method type */ - public CartPaymentInfo addPaymentAmount(String id, BigDecimal amount, String refNum, String authCode, boolean isSingleUse, boolean isPresent, boolean replace) { + public CartPaymentInfo addPaymentAmount(String id, BigDecimal amount, String refNum, String authCode, boolean isSingleUse, + boolean isPresent, boolean replace) { CartPaymentInfo inf = this.getPaymentInfo(id, refNum, authCode, amount, replace); if (isSalesOrder()) { GenericValue billingAddress = inf.getBillingAddress(this.getDelegator()); 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 56ea6e7..734abc9 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 @@ -840,7 +840,8 @@ public class ShoppingCartItem implements java.io.Serializable { throws CartItemModifyException { Delegator delegator = cart.getDelegator(); - ShoppingCartItem newItem = new ShoppingCartItem(delegator, itemType, itemDescription, productCategoryId, basePrice, attributes, prodCatalogId, cart.getLocale(), itemGroup); + ShoppingCartItem newItem = new ShoppingCartItem(delegator, itemType, itemDescription, productCategoryId, basePrice, attributes, + prodCatalogId, cart.getLocale(), itemGroup); // add to cart before setting quantity so that we can get order total, etc if (cartLocation == null) { @@ -867,7 +868,8 @@ public class ShoppingCartItem implements java.io.Serializable { /** * returns "OK" when the product can be booked or returns a string with the dates the related fixed Asset is not available */ - public static String checkAvailability(String productId, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, ShoppingCart cart) { + public static String checkAvailability(String productId, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, + ShoppingCart cart) { Delegator delegator = cart.getDelegator(); // find related fixedAsset List<GenericValue> selFixedAssetProduct = null; @@ -905,7 +907,8 @@ public class ShoppingCartItem implements java.io.Serializable { } // see if this fixed asset has a calendar, when no create one and attach to fixed asset - // DEJ20050725 this isn't being used anywhere, commenting out for now and not assigning from the getRelatedOne: GenericValue techDataCalendar = null; + // DEJ20050725 this isn't being used anywhere, commenting out for now and not assigning from the getRelatedOne: + // GenericValue techDataCalendar = null; GenericValue techDataCalendar = null; try { techDataCalendar = fixedAsset.getRelatedOne("TechDataCalendar", false); @@ -1335,7 +1338,8 @@ public class ShoppingCartItem implements java.io.Serializable { } if (priceResult.get("specialPromoPrice") != null) { - this.setSpecialPromoPrice(((BigDecimal) priceResult.get("specialPromoPrice")).divide(pieces, decimals, RoundingMode.HALF_UP)); + this.setSpecialPromoPrice(((BigDecimal) priceResult.get("specialPromoPrice")).divide(pieces, decimals, + RoundingMode.HALF_UP)); } } else { if (priceResult.get("listPrice") != null) { @@ -1357,7 +1361,8 @@ public class ShoppingCartItem implements java.io.Serializable { // If product is configurable, the price is taken from the configWrapper. if (configWrapper != null) { - // TODO: for configurable products need to do something to make them VAT aware... for now base and display prices are the same + // TODO: for configurable products need to do something to make them VAT aware... + // for now base and display prices are the same this.setBasePrice(configWrapper.getTotalPrice()); // Check if price display with taxes GenericValue productStore = ProductStoreWorker.getProductStore(cart.getProductStoreId(), delegator); @@ -2782,7 +2787,8 @@ public class ShoppingCartItem implements java.io.Serializable { return attrs; } - /** Add an adjustment to the order item; don't worry about setting the orderId, orderItemSeqId or orderAdjustmentId; they will be set when the order is created */ + /** Add an adjustment to the order item; don't worry about setting the orderId, orderItemSeqId or orderAdjustmentId; + * they will be set when the order is created */ public int addAdjustment(GenericValue adjustment) { itemAdjustments.add(adjustment); return itemAdjustments.indexOf(adjustment); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java index 9f276ef..7a463b9 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java @@ -75,9 +75,11 @@ public final class ProductDisplayWorker { while (cartiter != null && cartiter.hasNext()) { ShoppingCartItem item = cartiter.next(); // since ProductAssoc records have a fromDate and thruDate, we can filter by now so that only assocs in the date range are included - List<GenericValue> complementProducts = EntityQuery.use(delegator).from("ProductAssoc").where("productId", item.getProductId(), "productAssocTypeId", "PRODUCT_COMPLEMENT").cache(true).filterByDate().queryList(); + List<GenericValue> complementProducts = EntityQuery.use(delegator).from("ProductAssoc").where("productId", item.getProductId(), + "productAssocTypeId", "PRODUCT_COMPLEMENT").cache(true).filterByDate().queryList(); - List<GenericValue> productsCategories = EntityQuery.use(delegator).from("ProductCategoryMember").where("productId", item.getProductId()).cache(true).filterByDate().queryList(); + List<GenericValue> productsCategories = EntityQuery.use(delegator).from("ProductCategoryMember").where("productId", + item.getProductId()).cache(true).filterByDate().queryList(); if (productsCategories != null) { for (GenericValue productsCategoryMember : productsCategories) { GenericValue productsCategory = productsCategoryMember.getRelatedOne("ProductCategory", true); @@ -132,7 +134,7 @@ public final class ProductDisplayWorker { // randomly remove products while there are more than 3 while (cartAssocs.size() > 3) { - int toRemove = (int) (Math.random() * cartAssocs.size()); + int toRemove = (int) (Math.random() * cartAssocs.size()); cartAssocs.remove(toRemove); } } catch (GenericEntityException e) { @@ -160,7 +162,8 @@ public final class ProductDisplayWorker { try { Map<String, GenericValue> products = UtilGenerics.cast(httpRequest.getSession().getAttribute("_QUICK_REORDER_PRODUCTS_")); - Map<String, BigDecimal> productQuantities = UtilGenerics.cast(httpRequest.getSession().getAttribute("_QUICK_REORDER_PRODUCT_QUANTITIES_")); + Map<String, BigDecimal> productQuantities = + UtilGenerics.cast(httpRequest.getSession().getAttribute("_QUICK_REORDER_PRODUCT_QUANTITIES_")); Map<String, Integer> productOccurances = UtilGenerics.cast(httpRequest.getSession().getAttribute("_QUICK_REORDER_PRODUCT_OCCURANCES_")); if (products == null || productQuantities == null || productOccurances == null) { @@ -170,7 +173,8 @@ public final class ProductDisplayWorker { productOccurances = new HashMap<>(); // get all order role entities for user by customer role type : PLACING_CUSTOMER - List<GenericValue> orderRoles = EntityQuery.use(delegator).from("OrderRole").where("partyId", userLogin.get("partyId"), "roleTypeId", "PLACING_CUSTOMER").queryList(); + List<GenericValue> orderRoles = EntityQuery.use(delegator).from("OrderRole").where("partyId", userLogin.get("partyId"), + "roleTypeId", "PLACING_CUSTOMER").queryList(); Iterator<GenericValue> ordersIter = UtilMisc.toIterator(orderRoles); while (ordersIter != null && ordersIter.hasNext()) { 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 072a0bc..c5df099 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 @@ -1636,9 +1636,9 @@ public final class ProductPromoWorker { } public static class ActionResultInfo { - public boolean ranAction = false; - public BigDecimal totalDiscountAmount = BigDecimal.ZERO; - public BigDecimal quantityLeftInAction = BigDecimal.ZERO; + private boolean ranAction = false; + private BigDecimal totalDiscountAmount = BigDecimal.ZERO; + private BigDecimal quantityLeftInAction = BigDecimal.ZERO; } @SuppressWarnings("serial") diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java index 9273e01..e0731e7 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskEvents.java @@ -79,7 +79,8 @@ public class TaskEvents { return "error"; } } catch (GenericServiceException e) { - request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, "OrderProblemsInvokingTheCompleteAssignmentService", locale)); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, + "OrderProblemsInvokingTheCompleteAssignmentService", locale)); return "error"; } @@ -97,7 +98,8 @@ public class TaskEvents { eh.invoke(new Event("service", "", "wfAcceptRoleAssignment", true), null, request, response); } catch (EventHandlerException e) { Debug.logError(e, "Invocation error", MODULE); - request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, "OrderFailedToInvokeTheWfAcceptRoleAssignmentService", locale)); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, + "OrderFailedToInvokeTheWfAcceptRoleAssignmentService", locale)); return "error"; } return "success"; @@ -116,7 +118,8 @@ public class TaskEvents { eh.invoke(new Event("service", "", "wfAcceptRoleAssignment", true), null, request, response); } catch (EventHandlerException e) { Debug.logError(e, "Invocation error", MODULE); - request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, "OrderFailedToInvokeTheWfDelegateAndAcceptAssignmentService", locale)); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, + "OrderFailedToInvokeTheWfDelegateAndAcceptAssignmentService", locale)); return "error"; } return "success"; diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java b/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java index fe9e5b3..ed20dfa 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java @@ -101,7 +101,8 @@ public class ExpressCheckoutEvents { } if (paymentGatewayConfigId != null) { try { - payPalGatewayConfig = EntityQuery.use(delegator).from("PaymentGatewayPayPal").where("paymentGatewayConfigId", paymentGatewayConfigId).cache().queryOne(); + payPalGatewayConfig = EntityQuery.use(delegator).from("PaymentGatewayPayPal").where("paymentGatewayConfigId", + paymentGatewayConfigId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, MODULE); } @@ -176,7 +177,8 @@ public class ExpressCheckoutEvents { return "success"; } - public static Map<String, Object> doExpressCheckout(String productStoreId, String orderId, GenericValue paymentPref, GenericValue userLogin, Delegator delegator, LocalDispatcher dispatcher) { + public static Map<String, Object> doExpressCheckout(String productStoreId, String orderId, GenericValue paymentPref, + GenericValue userLogin, Delegator delegator, LocalDispatcher dispatcher) { CheckoutType checkoutType = determineCheckoutType(delegator, productStoreId); if (!checkoutType.equals(CheckoutType.NONE)) { String serviceName = null; diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactHelper.java b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactHelper.java index ccab8aa..20a0fe3 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactHelper.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactHelper.java @@ -50,7 +50,8 @@ public class ContactHelper { return getContactMech(party, contactMechPurposeTypeId, null, includeOld); } - public static Collection<GenericValue> getContactMech(GenericValue party, String contactMechPurposeTypeId, String contactMechTypeId, boolean includeOld) { + public static Collection<GenericValue> getContactMech(GenericValue party, String contactMechPurposeTypeId, String + contactMechTypeId, boolean includeOld) { if (party == null) { return null; } diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java index 27d1a1a..1803e67 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java @@ -93,12 +93,14 @@ public class ContactMechServices { "contactmechservices.could_not_create_contact_info_id_generation_failure", locale)); } - GenericValue tempContactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId", newCmId, "contactMechTypeId", contactMechTypeId)); + GenericValue tempContactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId", newCmId, + "contactMechTypeId", contactMechTypeId)); toBeStored.add(tempContactMech); if (!"_NA_".equals(partyId)) { toBeStored.add(delegator.makeValue("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", newCmId, - "fromDate", now, "roleTypeId", context.get("roleTypeId"), "allowSolicitation", context.get("allowSolicitation"), "extension", context.get("extension")))); + "fromDate", now, "roleTypeId", context.get("roleTypeId"), "allowSolicitation", context.get("allowSolicitation"), + "extension", context.get("extension")))); } if ("POSTAL_ADDRESS".equals(contactMechTypeId)) { @@ -226,7 +228,8 @@ public class ContactMechServices { newPartyContactMech.set("thruDate", null); try { - Iterator<GenericValue> partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose", null, null, false)); + Iterator<GenericValue> partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose", + null, null, false)); while (partyContactMechPurposes != null && partyContactMechPurposes.hasNext()) { GenericValue tempVal = GenericValue.create(partyContactMechPurposes.next()); @@ -354,7 +357,8 @@ public class ContactMechServices { "contactmechservices.could_not_create_contact_info_id_generation_failure", locale)); } - GenericValue tempContactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId", newCmId, "contactMechTypeId", contactMechTypeId)); + GenericValue tempContactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId", newCmId, + "contactMechTypeId", contactMechTypeId)); toBeStored.add(tempContactMech); // don't create a PartyContactMech if there is no party; we define no party as sending _NA_ as partyId @@ -525,7 +529,8 @@ public class ContactMechServices { newPartyContactMech.set("thruDate", null); try { - Iterator<GenericValue> partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose", null, null, false)); + Iterator<GenericValue> partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose", + null, null, false)); while (partyContactMechPurposes != null && partyContactMechPurposes.hasNext()) { GenericValue tempVal = GenericValue.create(partyContactMechPurposes.next()); @@ -599,11 +604,13 @@ public class ContactMechServices { "contactmechservices.could_not_create_contact_info_id_generation_failure", locale)); } - GenericValue tempContactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId", newCmId, "contactMechTypeId", contactMechTypeId)); + GenericValue tempContactMech = delegator.makeValue("ContactMech", UtilMisc.toMap("contactMechId", newCmId, + "contactMechTypeId", contactMechTypeId)); toBeStored.add(tempContactMech); toBeStored.add(delegator.makeValue("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", newCmId, - "fromDate", now, "roleTypeId", context.get("roleTypeId"), "allowSolicitation", context.get("allowSolicitation"), "extension", context.get("extension")))); + "fromDate", now, "roleTypeId", context.get("roleTypeId"), "allowSolicitation", context.get("allowSolicitation"), + "extension", context.get("extension")))); toBeStored.add(delegator.makeValue("TelecomNumber", UtilMisc.toMap("contactMechId", newCmId, "countryCode", context.get("countryCode"), "areaCode", context.get("areaCode"), "contactNumber", context.get("contactNumber")))); @@ -730,7 +737,8 @@ public class ContactMechServices { newPartyContactMech.set("thruDate", null); try { - Iterator<GenericValue> partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose", null, null, false)); + Iterator<GenericValue> partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose", + null, null, false)); while (partyContactMechPurposes != null && partyContactMechPurposes.hasNext()) { GenericValue tempVal = GenericValue.create(partyContactMechPurposes.next()); @@ -926,9 +934,10 @@ public class ContactMechServices { String contactMechId = contactMech.getString("contactMechId"); // create a new party contact mech for the partyIdTo - Map<String, Object> serviceResults = dispatcher.runSync("createPartyContactMech", UtilMisc.<String, Object>toMap("partyId", partyIdTo, "userLogin", userLogin, - "contactMechId", contactMechId, "contactMechTypeId", contactMech.getString("contactMechTypeId"), "fromDate", UtilDateTime.nowTimestamp(), - "allowSolicitation", partyContactMech.getString("allowSolicitation"), "extension", partyContactMech.getString("extension"))); + Map<String, Object> serviceResults = dispatcher.runSync("createPartyContactMech", UtilMisc.<String, Object>toMap("partyId", + partyIdTo, "userLogin", userLogin, "contactMechId", contactMechId, "contactMechTypeId", + contactMech.getString("contactMechTypeId"), "fromDate", UtilDateTime.nowTimestamp(), "allowSolicitation", + partyContactMech.getString("allowSolicitation"), "extension", partyContactMech.getString("extension"))); if (ServiceUtil.isError(serviceResults)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResults)); } diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java index 9eb4849..cff44f5 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java @@ -92,13 +92,15 @@ public class ContactMechWorker { } public static List<Map<String, Object>> getPartyContactMechValueMaps(Delegator delegator, String partyId, boolean showOld) { - return getPartyContactMechValueMaps(delegator, partyId, showOld, null); + return getPartyContactMechValueMaps(delegator, partyId, showOld, null); } - public static List<Map<String, Object>> getPartyContactMechValueMaps(Delegator delegator, String partyId, boolean showOld, String contactMechTypeId) { + public static List<Map<String, Object>> getPartyContactMechValueMaps(Delegator delegator, String partyId, boolean showOld, + String contactMechTypeId) { Timestamp date = showOld? null: UtilDateTime.nowTimestamp(); return getPartyContactMechValueMaps(delegator, partyId, date, contactMechTypeId); } - public static List<Map<String, Object>> getPartyContactMechValueMaps(Delegator delegator, String partyId, Timestamp date, String contactMechTypeId) { + public static List<Map<String, Object>> getPartyContactMechValueMaps(Delegator delegator, String partyId, Timestamp date, + String contactMechTypeId) { List<Map<String, Object>> partyContactMechValueMaps = new ArrayList<>(); List<GenericValue> allPartyContactMechs = null; @@ -146,7 +148,8 @@ public class ContactMechWorker { partyContactMechValueMap.put("partyContactMech", delegator.makeValidValue("PartyContactMech", fields)); ContactMechWorker.insertRelatedContactElement(delegator, partyContactMechValueMap, fields); - List<GenericValue> partyContactMechPurposes = EntityUtil.filterByAnd(allPartyContactMechPurposes, UtilMisc.toMap("contactMechId", partyContactMech.getString("contactMechId"))); + List<GenericValue> partyContactMechPurposes = EntityUtil.filterByAnd(allPartyContactMechPurposes, UtilMisc.toMap("contactMechId", + partyContactMech.getString("contactMechId"))); partyContactMechValueMap.put("partyContactMechPurposes", partyContactMechPurposes); } @@ -156,11 +159,13 @@ public class ContactMechWorker { public static List<Map<String, Object>> getFacilityContactMechValueMaps(Delegator delegator, String facilityId, boolean showOld) { return getFacilityContactMechValueMaps(delegator, facilityId, showOld, null); } - public static List<Map<String, Object>> getFacilityContactMechValueMaps(Delegator delegator, String facilityId, boolean showOld, String contactMechTypeId) { + public static List<Map<String, Object>> getFacilityContactMechValueMaps(Delegator delegator, String facilityId, boolean showOld, + String contactMechTypeId) { Timestamp date = showOld? UtilDateTime.nowTimestamp(): null; return getFacilityContactMechValueMaps(delegator, facilityId, date, contactMechTypeId); } - public static List<Map<String, Object>> getFacilityContactMechValueMaps(Delegator delegator, String facilityId, Timestamp date, String contactMechTypeId) { + public static List<Map<String, Object>> getFacilityContactMechValueMaps(Delegator delegator, String facilityId, Timestamp date, + String contactMechTypeId) { List<Map<String, Object>> facilityContactMechValueMaps = new ArrayList<>(); List<GenericValue> allFacilityContactMechs = null; @@ -188,7 +193,8 @@ public class ContactMechWorker { EntityCondition.makeCondition("contactMechId", EntityOperator.IN, contactMechIds)); List<GenericValue> allFacilityContactMechPurposes = null; try { - allFacilityContactMechPurposes = EntityQuery.use(delegator).from("FacilityContactMechPurpose").where(conditionList).filterByDate(date).cache().queryList(); + allFacilityContactMechPurposes = EntityQuery.use(delegator).from("FacilityContactMechPurpose").where(conditionList) + .filterByDate(date).cache().queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, MODULE); } @@ -203,7 +209,8 @@ public class ContactMechWorker { facilityContactMechValueMap.put("facilityContactMech", delegator.makeValidValue("FacilityContactMech", fields)); ContactMechWorker.insertRelatedContactElement(delegator, facilityContactMechValueMap, fields); - List<GenericValue> facilityContactMechPurposes = EntityUtil.filterByAnd(allFacilityContactMechPurposes, UtilMisc.toMap("contactMechId", facilityContactMech.getString("contactMechId"))); + List<GenericValue> facilityContactMechPurposes = EntityUtil.filterByAnd(allFacilityContactMechPurposes, + UtilMisc.toMap("contactMechId", facilityContactMech.getString("contactMechId"))); facilityContactMechValueMap.put("facilityContactMechPurposes", facilityContactMechPurposes); } @@ -215,11 +222,13 @@ public class ContactMechWorker { } public static Collection<Map<String, GenericValue>> getWorkEffortContactMechValueMaps(Delegator delegator, String workEffortId) { - Collection<Map<String, GenericValue>> workEffortContactMechValueMaps = getEntityContactMechValueMaps(delegator, "WorkEffort", workEffortId, UtilDateTime.nowTimestamp()); + Collection<Map<String, GenericValue>> workEffortContactMechValueMaps = getEntityContactMechValueMaps(delegator, "WorkEffort", + workEffortId, UtilDateTime.nowTimestamp()); return UtilValidate.isNotEmpty(workEffortContactMechValueMaps) ? workEffortContactMechValueMaps : null; } - private static List<Map<String, GenericValue>> getEntityContactMechValueMaps(Delegator delegator, String entityName, String entityId, Timestamp date) { + private static List<Map<String, GenericValue>> getEntityContactMechValueMaps(Delegator delegator, String entityName, String entityId, + Timestamp date) { List<Map<String, GenericValue>> entityContactMechValueMaps = new LinkedList<>(); String downCaseEntityName = ModelUtil.lowerFirstChar(entityName); @@ -329,7 +338,8 @@ public class ContactMechWorker { Collection<GenericValue> partyContactMechPurposes = null; try { - partyContactMechPurposes = EntityUtil.filterByDate(partyContactMech.getRelated("PartyContactMechPurpose", null, null, false), true); + partyContactMechPurposes = EntityUtil.filterByDate(partyContactMech.getRelated("PartyContactMechPurpose", null, + null, false), true); } catch (GenericEntityException e) { Debug.logWarning(e, MODULE); } @@ -354,7 +364,8 @@ public class ContactMechWorker { target.put("contactMechTypeId", contactMechTypeId); try { - GenericValue contactMechType = EntityQuery.use(delegator).from("ContactMechType").where("contactMechTypeId", contactMechTypeId).queryOne(); + GenericValue contactMechType = EntityQuery.use(delegator).from("ContactMechType").where("contactMechTypeId", + contactMechTypeId).queryOne(); if (contactMechType != null) { target.put("contactMechType", contactMechType); @@ -600,7 +611,8 @@ public class ContactMechWorker { Collection<GenericValue> facilityContactMechPurposes = null; try { - facilityContactMechPurposes = EntityUtil.filterByDate(facilityContactMech.getRelated("FacilityContactMechPurpose", null, null, false), true); + facilityContactMechPurposes = EntityUtil.filterByDate(facilityContactMech.getRelated("FacilityContactMechPurpose", + null, null, false), true); } catch (GenericEntityException e) { Debug.logWarning(e, MODULE); } @@ -625,7 +637,8 @@ public class ContactMechWorker { target.put("contactMechTypeId", contactMechTypeId); try { - GenericValue contactMechType = EntityQuery.use(delegator).from("ContactMechType").where("contactMechTypeId", contactMechTypeId).queryOne(); + GenericValue contactMechType = EntityQuery.use(delegator).from("ContactMechType").where("contactMechTypeId", + contactMechTypeId).queryOne(); if (contactMechType != null) { target.put("contactMechType", contactMechType); @@ -761,7 +774,8 @@ public class ContactMechWorker { } catch (GenericEntityException e) { Debug.logWarning(e, MODULE); } - if (contactMech != null && "POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId")) && !contactMech.getString("contactMechId").equals(curContactMechId)) { + if (contactMech != null && "POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId")) && !contactMech.getString("contactMechId") + .equals(curContactMechId)) { Map<String, Object> postalAddressInfo = new HashMap<>(); postalAddressInfos.add(postalAddressInfo); @@ -776,7 +790,8 @@ public class ContactMechWorker { } try { - List<GenericValue> partyContactMechPurposes = EntityUtil.filterByDate(partyContactMech.getRelated("PartyContactMechPurpose", null, null, false), true); + List<GenericValue> partyContactMechPurposes = EntityUtil.filterByDate(partyContactMech.getRelated("PartyContactMechPurpose", + null, null, false), true); postalAddressInfo.put("partyContactMechPurposes", partyContactMechPurposes); } catch (GenericEntityException e) { Debug.logWarning(e, MODULE); @@ -815,7 +830,8 @@ public class ContactMechWorker { Collection<GenericValue> curPartyContactMechPurposes = null; try { - curPartyContactMechPurposes = EntityUtil.filterByDate(curPartyContactMech.getRelated("PartyContactMechPurpose", null, null, false), true); + curPartyContactMechPurposes = EntityUtil.filterByDate(curPartyContactMech.getRelated("PartyContactMechPurpose", + null, null, false), true); } catch (GenericEntityException e) { Debug.logWarning(e, MODULE); } @@ -968,14 +984,16 @@ public class ContactMechWorker { // no postalCodeGeoId, see if there is a Geo record matching the countryGeoId and postalCode fields if (UtilValidate.isNotEmpty(postalAddress.getString("countryGeoId")) && UtilValidate.isNotEmpty(postalAddress.getString("postalCode"))) { // first try the shortcut with the geoId convention for "{countryGeoId}-{postalCode}" - GenericValue geo = EntityQuery.use(delegator).from("Geo").where("geoId", postalAddress.getString("countryGeoId") + "-" + postalAddress.getString("postalCode")).cache().queryOne(); + GenericValue geo = EntityQuery.use(delegator).from("Geo").where("geoId", postalAddress.getString("countryGeoId") + "-" + + postalAddress.getString("postalCode")).cache().queryOne(); if (geo != null) { // save the value to the database for quicker future reference if (postalAddress.isMutable()) { postalAddress.set("postalCodeGeoId", geo.getString("geoId")); postalAddress.store(); } else { - GenericValue mutablePostalAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", postalAddress.getString("contactMechId")).queryOne(); + GenericValue mutablePostalAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", + postalAddress.getString("contactMechId")).queryOne(); mutablePostalAddress.set("postalCodeGeoId", geo.getString("geoId")); mutablePostalAddress.store(); } @@ -985,16 +1003,16 @@ public class ContactMechWorker { // no shortcut, try the longcut to see if there is something with a geoCode associated to the countryGeoId GenericValue geoAssocAndGeoTo = EntityQuery.use(delegator).from("GeoAssocAndGeoTo") - .where("geoIdFrom", postalAddress.getString("countryGeoId"), "geoCode", postalAddress.getString("postalCode"), "geoAssocTypeId", "REGIONS") - .cache(true) - .queryFirst(); + .where("geoIdFrom", postalAddress.getString("countryGeoId"), "geoCode", postalAddress.getString("postalCode"), + "geoAssocTypeId", "REGIONS").cache(true).queryFirst(); if (geoAssocAndGeoTo != null) { // save the value to the database for quicker future reference if (postalAddress.isMutable()) { postalAddress.set("postalCodeGeoId", geoAssocAndGeoTo.getString("geoId")); postalAddress.store(); } else { - GenericValue mutablePostalAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", postalAddress.getString("contactMechId")).queryOne(); + GenericValue mutablePostalAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", + postalAddress.getString("contactMechId")).queryOne(); mutablePostalAddress.set("postalCodeGeoId", geoAssocAndGeoTo.getString("geoId")); mutablePostalAddress.store(); } diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyRelationshipServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyRelationshipServices.java index 23a0b47..71fa985 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyRelationshipServices.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyRelationshipServices.java @@ -79,7 +79,7 @@ public class PartyRelationshipServices { partyToRole.create(); } - GenericValue partyFromRole= null; + GenericValue partyFromRole = null; partyFromRole = EntityQuery.use(delegator).from("PartyRole").where("partyId", partyIdFrom, "roleTypeId", roleTypeIdFrom).queryOne(); if (partyFromRole == null) { partyFromRole = delegator.makeValue("PartyRole", UtilMisc.toMap("partyId", partyIdFrom, "roleTypeId", roleTypeIdFrom)); @@ -87,15 +87,14 @@ public class PartyRelationshipServices { } // Check if there is already a partyRelationship of that type with another party from the side indicated - String sideChecked = partyIdFrom.equals(partyId)? "partyIdFrom" : "partyIdTo"; + String sideChecked = partyIdFrom.equals(partyId) ? "partyIdFrom" : "partyIdTo"; // We consider the last one (in time) as sole active (we try to maintain a unique relationship and keep changes history) GenericValue oldPartyRelationShip = EntityQuery.use(delegator).from("PartyRelationship") - .where(sideChecked, partyId, "roleTypeIdFrom", roleTypeIdFrom, "roleTypeIdTo", roleTypeIdTo, "partyRelationshipTypeId", partyRelationshipTypeId) - .filterByDate() - .queryFirst(); + .where(sideChecked, partyId, "roleTypeIdFrom", roleTypeIdFrom, "roleTypeIdTo", roleTypeIdTo, "partyRelationshipTypeId", + partyRelationshipTypeId).filterByDate().queryFirst(); if (oldPartyRelationShip != null) { - oldPartyRelationShip.setFields(UtilMisc.toMap("thruDate", UtilDateTime.nowTimestamp())); // Current becomes inactive - oldPartyRelationShip.store(); + oldPartyRelationShip.setFields(UtilMisc.toMap("thruDate", UtilDateTime.nowTimestamp())); // Current becomes inactive + oldPartyRelationShip.store(); } try { Map<String, Object> resultMap = dispatcher.runSync("createPartyRelationship", context); // Create new one diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java index b6bcedb..6aad675 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java @@ -1296,9 +1296,7 @@ public class PartyServices { String inventoryItemId = (String) context.get("inventoryItemId"); String serialNumber = (String) context.get("serialNumber"); String softIdentifier = (String) context.get("softIdentifier"); - if (UtilValidate.isNotEmpty(inventoryItemId) - || UtilValidate.isNotEmpty(serialNumber) - || UtilValidate.isNotEmpty(softIdentifier)) { + if (UtilValidate.isNotEmpty(inventoryItemId) || UtilValidate.isNotEmpty(serialNumber) || UtilValidate.isNotEmpty(softIdentifier)) { // add role to view dynamicView.addMemberEntity("II", "InventoryItem"); dynamicView.addAlias("II", "ownerPartyId"); @@ -1707,7 +1705,7 @@ public class PartyServices { // PartyClassificationGroup Fields // ---- - List<String> partyClassificationGroupIds = (List) context.get("partyClassificationGroupId"); + List<String> partyClassificationGroupIds = UtilGenerics.cast(context.get("partyClassificationGroupId")); if (UtilValidate.isNotEmpty(partyClassificationGroupIds)) { // add PartyClassification to view dynamicView.addMemberEntity("PC", "PartyClassification"); @@ -2272,7 +2270,7 @@ public class PartyServices { String searchAllIdContext = (String) context.get("searchAllId"); boolean searchPartyFirst = UtilValidate.isNotEmpty(searchPartyFirstContext) && "N".equals(searchPartyFirstContext) ? false : true; - boolean searchAllId = UtilValidate.isNotEmpty(searchAllIdContext)&& "Y".equals(searchAllIdContext) ? true : false; + boolean searchAllId = UtilValidate.isNotEmpty(searchAllIdContext) && "Y".equals(searchAllIdContext) ? true : false; GenericValue party = null; List<GenericValue> partiesFound = null; @@ -2574,7 +2572,8 @@ public class PartyServices { lastCountryGeoId = (String) postalAddress.get("countryGeoId"); } - Map<String, Object> telecomNumber = UtilMisc.toMap("userLogin", (Object) userLogin); // casting is here necessary for some compiler versions + Map<String, Object> telecomNumber = UtilMisc.toMap("userLogin", (Object) userLogin); + // casting is here necessary for some compiler versions boolean telecomNumberChanged = false; if ("TELECOM_NUMBER".equals(currentContactMechTypeId)) { diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/catalog/CatalogWorker.java b/applications/product/src/main/java/org/apache/ofbiz/product/catalog/CatalogWorker.java index 27c06f0..384e4ae 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/catalog/CatalogWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/catalog/CatalogWorker.java @@ -92,7 +92,8 @@ public final class CatalogWorker { public static List<GenericValue> getStoreCatalogs(Delegator delegator, String productStoreId) { try { - return EntityQuery.use(delegator).from("ProductStoreCatalog").where("productStoreId", productStoreId).orderBy("sequenceNum", "prodCatalogId").cache(true).filterByDate().queryList(); + return EntityQuery.use(delegator).from("ProductStoreCatalog").where("productStoreId", productStoreId) + .orderBy("sequenceNum", "prodCatalogId").cache(true).filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Error looking up store catalogs for store with id " + productStoreId, MODULE); } @@ -116,7 +117,8 @@ public final class CatalogWorker { } try { - return EntityQuery.use(delegator).from("ProdCatalogRole").where("partyId", partyId, "roleTypeId", "CUSTOMER").orderBy("sequenceNum", "prodCatalogId").cache(true).filterByDate().queryList(); + return EntityQuery.use(delegator).from("ProdCatalogRole").where("partyId", partyId, "roleTypeId", "CUSTOMER") + .orderBy("sequenceNum", "prodCatalogId").cache(true).filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Error looking up ProdCatalog Roles for party with id " + partyId, MODULE); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlServlet.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlServlet.java index 2ac3b82..f609df8 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlServlet.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/CatalogUrlServlet.java @@ -175,7 +175,8 @@ public class CatalogUrlServlet extends HttpServlet { return urlBuilder.toString(); } - public static String makeCatalogUrl(String contextPath, List<String> crumb, String productId, String currentCategoryId, String previousCategoryId) { + public static String makeCatalogUrl(String contextPath, List<String> crumb, String productId, String currentCategoryId, + String previousCategoryId) { StringBuilder urlBuilder = new StringBuilder(); urlBuilder.append(contextPath); if (urlBuilder.length() == 0 || urlBuilder.charAt(urlBuilder.length() - 1) != '/') { diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java index 51a8489..1f4f342 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryWorker.java @@ -66,14 +66,17 @@ public final class CategoryWorker { // if no parameter, try from session if (topCatName == null) { topCatName = (String) httpRequest.getSession().getAttribute("CATALOG_TOP_CATEGORY"); - if (topCatName != null) + if (topCatName != null) { fromSession = true; + } } // if nothing else, just use a default top category name - if (topCatName == null) + if (topCatName == null) { topCatName = defaultTopCategory; - if (topCatName == null) + } + if (topCatName == null) { topCatName = "CATALOG1"; + } if (!fromSession) { if (Debug.infoOn()) { @@ -109,8 +112,9 @@ public final class CategoryWorker { requestId = UtilFormatOut.checkNull((String) requestParameters.get("catalog_id"), (String) requestParameters.get("CATALOG_ID"), (String) requestParameters.get("category_id"), (String) requestParameters.get("CATEGORY_ID")); - if ("".equals(requestId)) + if ("".equals(requestId)) { return; + } if (Debug.infoOn()) { Debug.logInfo("[CategoryWorker.getRelatedCategories] RequestID: " + requestId, MODULE); } @@ -124,24 +128,26 @@ public final class CategoryWorker { public static void getRelatedCategories(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty) { List<GenericValue> categories = getRelatedCategoriesRet(request, attributeName, parentId, limitView, excludeEmpty); - if (!categories.isEmpty()) request.setAttribute(attributeName, categories); + if (!categories.isEmpty()) request.setAttribute(attributeName, categories); } public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView) { return getRelatedCategoriesRet(request, attributeName, parentId, limitView, false); } - public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty) { + public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, + boolean excludeEmpty) { return getRelatedCategoriesRet(request, attributeName, parentId, limitView, excludeEmpty, false); } - public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty, boolean recursive) { - Delegator delegator = (Delegator) request.getAttribute("delegator"); - - return getRelatedCategoriesRet(delegator, attributeName, parentId, limitView, excludeEmpty, recursive); + public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, + boolean excludeEmpty, boolean recursive) { + Delegator delegator = (Delegator) request.getAttribute("delegator"); + return getRelatedCategoriesRet(delegator, attributeName, parentId, limitView, excludeEmpty, recursive); } - public static List<GenericValue> getRelatedCategoriesRet(Delegator delegator, String attributeName, String parentId, boolean limitView, boolean excludeEmpty, boolean recursive) { + public static List<GenericValue> getRelatedCategoriesRet(Delegator delegator, String attributeName, String parentId, boolean limitView, + boolean excludeEmpty, boolean recursive) { List<GenericValue> categories = new LinkedList<>(); if (Debug.verboseOn()) { @@ -151,7 +157,8 @@ public final class CategoryWorker { List<GenericValue> rollups = null; try { - rollups = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", parentId).orderBy("sequenceNum").cache(true).queryList(); + rollups = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", parentId) + .orderBy("sequenceNum").cache(true).queryList(); if (limitView) { rollups = EntityUtil.filterByDate(rollups, true); } @@ -172,13 +179,15 @@ public final class CategoryWorker { if (!isCategoryEmpty(cv)) { categories.add(cv); if (recursive) { - categories.addAll(getRelatedCategoriesRet(delegator, attributeName, cv.getString("productCategoryId"), limitView, excludeEmpty, recursive)); + categories.addAll(getRelatedCategoriesRet(delegator, attributeName, cv.getString("productCategoryId"), + limitView, excludeEmpty, recursive)); } } } else { categories.add(cv); if (recursive) { - categories.addAll(getRelatedCategoriesRet(delegator, attributeName, cv.getString("productCategoryId"), limitView, excludeEmpty, recursive)); + categories.addAll(getRelatedCategoriesRet(delegator, attributeName, cv.getString("productCategoryId"), + limitView, excludeEmpty, recursive)); } } } @@ -209,7 +218,8 @@ public final class CategoryWorker { Delegator delegator = category.getDelegator(); long count = 0; try { - count = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", category.getString("productCategoryId")).queryCount(); + count = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", + category.getString("productCategoryId")).queryCount(); } catch (GenericEntityException e) { Debug.logError(e, MODULE); } @@ -221,7 +231,8 @@ public final class CategoryWorker { Delegator delegator = category.getDelegator(); long count = 0; try { - count = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", category.getString("productCategoryId")).queryCount(); + count = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", + category.getString("productCategoryId")).queryCount(); } catch (GenericEntityException e) { Debug.logError(e, MODULE); } @@ -359,11 +370,13 @@ public final class CategoryWorker { } } - public static List<GenericValue> filterProductsInCategory(Delegator delegator, List<GenericValue> valueObjects, String productCategoryId) throws GenericEntityException { + public static List<GenericValue> filterProductsInCategory(Delegator delegator, List<GenericValue> valueObjects, String productCategoryId) + throws GenericEntityException { return filterProductsInCategory(delegator, valueObjects, productCategoryId, "productId"); } - public static List<GenericValue> filterProductsInCategory(Delegator delegator, List<GenericValue> valueObjects, String productCategoryId, String productIdFieldName) throws GenericEntityException { + public static List<GenericValue> filterProductsInCategory(Delegator delegator, List<GenericValue> valueObjects, String productCategoryId, + String productIdFieldName) throws GenericEntityException { List<GenericValue> newList = new LinkedList<>(); if (productCategoryId == null) return newList; @@ -378,7 +391,8 @@ public final class CategoryWorker { return newList; } - public static void getCategoryContentWrappers(Map<String, CategoryContentWrapper> catContentWrappers, List<GenericValue> categoryList, HttpServletRequest request) throws GenericEntityException { + public static void getCategoryContentWrappers(Map<String, CategoryContentWrapper> catContentWrappers, List<GenericValue> categoryList, + HttpServletRequest request) throws GenericEntityException { if (catContentWrappers == null || categoryList == null) { return; } @@ -421,7 +435,8 @@ public final class CategoryWorker { List<EntityCondition> rolllupConds = new LinkedList<>(); rolllupConds.add(EntityCondition.makeCondition("productCategoryId", parentProductCategoryId)); rolllupConds.add(EntityUtil.getFilterByDateExpr()); - List<GenericValue> productCategoryRollups = EntityQuery.use(delegator).from("ProductCategoryRollup").where(rolllupConds).orderBy("sequenceNum").cache(true).queryList(); + List<GenericValue> productCategoryRollups = EntityQuery.use(delegator).from("ProductCategoryRollup").where(rolllupConds) + .orderBy("sequenceNum").cache(true).queryList(); if (UtilValidate.isNotEmpty(productCategoryRollups)) { // add only categories that belong to the top category to trail for (GenericValue productCategoryRollup : productCategoryRollups) { 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 10af247..89eb5c1 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 @@ -51,6 +51,12 @@ import freemarker.template.TemplateTransformModel; public class OfbizCatalogAltUrlTransform implements TemplateTransformModel { private static final String MODULE = OfbizCatalogUrlTransform.class.getName(); + /** + * Gets string arg. + * @param args the args + * @param key the key + * @return the string arg + */ public String getStringArg(Map<?, ?> args, String key) { Object o = args.get(key); if (o instanceof SimpleScalar) { @@ -65,6 +71,13 @@ public class OfbizCatalogAltUrlTransform implements TemplateTransformModel { return null; } + /** + * Check arg boolean. + * @param args the args + * @param key the key + * @param defaultValue the default value + * @return the boolean + */ public boolean checkArg(Map<?, ?> args, String key, boolean defaultValue) { if (!args.containsKey(key)) { return defaultValue; @@ -117,7 +130,8 @@ public class OfbizCatalogAltUrlTransform implements TemplateTransformModel { if (UtilValidate.isNotEmpty(productId)) { url = CatalogUrlFilter.makeProductUrl(request, previousCategoryId, productCategoryId, productId); } else { - url = CatalogUrlFilter.makeCategoryUrl(request, previousCategoryId, productCategoryId, productId, viewSize, viewIndex, viewSort, searchString); + url = CatalogUrlFilter.makeCategoryUrl(request, previousCategoryId, productCategoryId, productId, viewSize, + viewIndex, viewSort, searchString); } // make the link if (fullPath) { @@ -132,18 +146,23 @@ public class OfbizCatalogAltUrlTransform implements TemplateTransformModel { Locale locale = (Locale) args.get("locale"); if (UtilValidate.isNotEmpty(productId)) { GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); - ProductContentWrapper wrapper = new ProductContentWrapper(dispatcher, product, locale, EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", delegator)); - url = CatalogUrlFilter.makeProductUrl(wrapper, null, ((StringModel) prefix).getAsString(), previousCategoryId, productCategoryId, productId); + ProductContentWrapper wrapper = new ProductContentWrapper(dispatcher, product, locale, + EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", delegator)); + url = CatalogUrlFilter.makeProductUrl(wrapper, null, ((StringModel) prefix).getAsString(), previousCategoryId, + productCategoryId, productId); } else { - GenericValue productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).queryOne(); - CategoryContentWrapper wrapper = new CategoryContentWrapper(dispatcher, productCategory, locale, EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", delegator)); - url = CatalogUrlFilter.makeCategoryUrl(delegator, wrapper, null, ((StringModel) prefix).getAsString(), previousCategoryId, productCategoryId, productId, viewSize, viewIndex, viewSort, searchString); + GenericValue productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", + productCategoryId).queryOne(); + CategoryContentWrapper wrapper = new CategoryContentWrapper(dispatcher, productCategory, locale, EntityUtilProperties + .getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", delegator)); + url = CatalogUrlFilter.makeCategoryUrl(delegator, wrapper, null, ((StringModel) prefix).getAsString(), previousCategoryId, + productCategoryId, productId, viewSize, viewIndex, viewSort, searchString); } out.write(url); } else { out.write(buf.toString()); } - } catch (TemplateModelException |GenericEntityException | WebAppConfigurationException e) { + } catch (TemplateModelException | GenericEntityException | WebAppConfigurationException e) { throw new IOException(e.getMessage()); } } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/feature/ParametricSearch.java b/applications/product/src/main/java/org/apache/ofbiz/product/feature/ParametricSearch.java index 07aa314..7d6f20a 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/feature/ParametricSearch.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/feature/ParametricSearch.java @@ -60,11 +60,13 @@ public class ParametricSearch { public static Map<String, List<GenericValue>> makeCategoryFeatureLists(String productCategoryId, Delegator delegator, int perTypeMaxSize) { Map<String, Map<String, GenericValue>> productFeaturesByTypeMap = new HashMap<>(); try { - List<GenericValue> productFeatureCategoryAppls = EntityQuery.use(delegator).from("ProductFeatureCategoryAppl").where("productCategoryId", productCategoryId).cache(true).queryList(); + List<GenericValue> productFeatureCategoryAppls = EntityQuery.use(delegator).from("ProductFeatureCategoryAppl").where("productCategoryId", + productCategoryId).cache(true).queryList(); productFeatureCategoryAppls = EntityUtil.filterByDate(productFeatureCategoryAppls, true); if (productFeatureCategoryAppls != null) { for (GenericValue productFeatureCategoryAppl: productFeatureCategoryAppls) { - List<GenericValue> productFeatures = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureCategoryId", productFeatureCategoryAppl.get("productFeatureCategoryId")).cache(true).queryList(); + List<GenericValue> productFeatures = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureCategoryId", + productFeatureCategoryAppl.get("productFeatureCategoryId")).cache(true).queryList(); for (GenericValue productFeature: productFeatures) { String productFeatureTypeId = productFeature.getString("productFeatureTypeId"); Map<String, GenericValue> featuresByType = productFeaturesByTypeMap.get(productFeatureTypeId); @@ -83,13 +85,16 @@ public class ParametricSearch { } try { - List<GenericValue> productFeatureCatGrpAppls = EntityQuery.use(delegator).from("ProductFeatureCatGrpAppl").where("productCategoryId", productCategoryId).cache(true).queryList(); + List<GenericValue> productFeatureCatGrpAppls = EntityQuery.use(delegator).from("ProductFeatureCatGrpAppl").where("productCategoryId", + productCategoryId).cache(true).queryList(); productFeatureCatGrpAppls = EntityUtil.filterByDate(productFeatureCatGrpAppls, true); if (productFeatureCatGrpAppls != null) { for (GenericValue productFeatureCatGrpAppl: productFeatureCatGrpAppls) { - List<GenericValue> productFeatureGroupAppls = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId", productFeatureCatGrpAppl.get("productFeatureGroupId")).cache(true).queryList(); + List<GenericValue> productFeatureGroupAppls = EntityQuery.use(delegator).from("ProductFeatureGroupAppl") + .where("productFeatureGroupId", productFeatureCatGrpAppl.get("productFeatureGroupId")).cache(true).queryList(); for (GenericValue productFeatureGroupAppl: productFeatureGroupAppls) { - GenericValue productFeature = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureId", productFeatureGroupAppl.get("productFeatureId")).cache().queryOne(); + GenericValue productFeature = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureId", + productFeatureGroupAppl.get("productFeatureId")).cache().queryOne(); String productFeatureTypeId = productFeature.getString("productFeatureTypeId"); Map<String, GenericValue> featuresByType = productFeaturesByTypeMap.get(productFeatureTypeId); @@ -152,7 +157,8 @@ public class ParametricSearch { return makeFeatureIdByTypeMap(parameters); } - /** Handles parameters coming in prefixed with "pft_" where the text in the key following the prefix is a productFeatureTypeId and the value is a productFeatureId; meant to be used with drop-downs and such */ + /** Handles parameters coming in prefixed with "pft_" where the text in the key following the prefix is a + * productFeatureTypeId and the value is a productFeatureId; meant to be used with drop-downs and such */ public static Map<String, String> makeFeatureIdByTypeMap(Map<String, Object> parameters) { Map<String, String> featureIdByType = new HashMap<>(); if (parameters == null) return featureIdByType; @@ -172,7 +178,8 @@ public class ParametricSearch { return featureIdByType; } - /** Handles parameters coming in prefixed with "SEARCH_FEAT" where the parameter value is a productFeatureId; meant to be used with text entry boxes or check-boxes and such */ + /** Handles parameters coming in prefixed with "SEARCH_FEAT" where the parameter value is a productFeatureId; + * meant to be used with text entry boxes or check-boxes and such */ public static List<String> makeFeatureIdListFromPrefixed(Map<String, Object> parameters) { List<String> featureIdList = new LinkedList<>(); if (parameters == null) return featureIdList; @@ -224,7 +231,7 @@ public class ParametricSearch { if (parameterName.startsWith("SEARCH_PROD_FEAT_CAT")) { String productFeatureCategoryId = (String) entry.getValue(); if (UtilValidate.isNotEmpty(productFeatureCategoryId)) { - prodFeatureCategoryIdList.add(productFeatureCategoryId); + prodFeatureCategoryIdList.add(productFeatureCategoryId); } } } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/feature/ProductFeatureServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/feature/ProductFeatureServices.java index 4dd3222..44e905d 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/feature/ProductFeatureServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/feature/ProductFeatureServices.java @@ -54,8 +54,10 @@ public class ProductFeatureServices { /* * Parameters: productFeatureCategoryId, productFeatureGroupId, productId, productFeatureApplTypeId - * Result: productFeaturesByType, a Map of all product features from productFeatureCategoryId, group by productFeatureType -> List of productFeatures - * If the parameter were productFeatureCategoryId, the results are from ProductFeatures. If productFeatureCategoryId were null and there were a productFeatureGroupId, + * Result: productFeaturesByType, a Map of all product features from productFeatureCategoryId, group by productFeatureType -> + * List of productFeatures + * If the parameter were productFeatureCategoryId, the results are from ProductFeatures. If productFeatureCategoryId were null + * and there were a productFeatureGroupId, * the results are from ProductFeatureGroupAndAppl. Otherwise, if there is a productId, the results are from ProductFeatureAndAppl. * The optional productFeatureApplTypeId causes results to be filtered by this parameter--only used in conjunction with productId. */ @@ -92,10 +94,12 @@ public class ProductFeatureServices { try { // get all product features in this feature category - List<GenericValue> allFeatures = EntityQuery.use(delegator).from(entityToSearch).where(fieldToSearch, valueToSearch).orderBy(orderBy).queryList(); + List<GenericValue> allFeatures = EntityQuery.use(delegator).from(entityToSearch).where(fieldToSearch, valueToSearch) + .orderBy(orderBy).queryList(); - if ("ProductFeatureAndAppl".equals(entityToSearch) && productFeatureApplTypeId != null) + if ("ProductFeatureAndAppl".equals(entityToSearch) && productFeatureApplTypeId != null) { allFeatures = EntityUtil.filterByAnd(allFeatures, UtilMisc.toMap("productFeatureApplTypeId", productFeatureApplTypeId)); + } List<String> featureTypes = new LinkedList<>(); Map<String, List<GenericValue>> featuresByType = new LinkedHashMap<>(); @@ -140,7 +144,8 @@ public class ProductFeatureServices { * see if it has every single feature in the list of productFeatureAppls as a STANDARD_FEATURE. If so, then * it qualifies and add it to the list of existingVariantProductIds. */ - List<GenericValue> productAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList(); + List<GenericValue> productAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", + "PRODUCT_VARIANT").filterByDate().queryList(); for (GenericValue productAssoc: productAssocs) { //for each associated product, if it has all standard features, display it's productId @@ -150,15 +155,13 @@ public class ProductFeatureServices { "productFeatureId", productFeatureAndAppl, "productFeatureApplTypeId", "STANDARD_FEATURE"); - List<GenericValue> standardProductFeatureAndAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where(findByMap).filterByDate().queryList(); + List<GenericValue> standardProductFeatureAndAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where(findByMap) + .filterByDate().queryList(); if (UtilValidate.isEmpty(standardProductFeatureAndAppls)) { hasAllFeatures = false; break; - } else { - } } - if (hasAllFeatures) { // add to list of existing variants: productId=productAssoc.productIdTo existingVariantProductIds.add(productAssoc.getString("productIdTo")); @@ -170,13 +173,14 @@ public class ProductFeatureServices { Debug.logError(ex, ex.getMessage(), MODULE); return ServiceUtil.returnError(ex.getMessage()); } - return results; + return results; } /* * Parameter: productId (of the parent product which has SELECTABLE features) * Result: featureCombinations, a List of Maps containing, for each possible variant of the productid: - * {defaultVariantProductId: id of this variant; curProductFeatureAndAppls: features applied to this variant; existingVariantProductIds: List of productIds which are already variants with these features } + * {defaultVariantProductId: id of this variant; curProductFeatureAndAppls: features applied to this variant; + * existingVariantProductIds: List of productIds which are already variants with these features } */ public static Map<String, Object> getVariantCombinations(DispatchContext dctx, Map<String, ? extends Object> context) { Map<String, Object> results; @@ -241,10 +245,12 @@ public class ProductFeatureServices { Map<String, Object> newCombination = new HashMap<>(); // .clone() is important, or you'll keep adding to the same List for all the variants // have to cast twice: once from get() and once from clone() - List<GenericValue> newFeatures = UtilMisc.makeListWritable(UtilGenerics.cast(combination.get("curProductFeatureAndAppls"))); + List<GenericValue> newFeatures = UtilMisc.makeListWritable(UtilGenerics.cast(combination + .get("curProductFeatureAndAppls"))); List<String> newFeatureIds = UtilMisc.makeListWritable(UtilGenerics.cast(combination.get("curProductFeatureIds"))); if (currentFeature.getString("idCode") != null) { - newCombination.put("defaultVariantProductId", combination.get("defaultVariantProductId") + currentFeature.getString("idCode")); + newCombination.put("defaultVariantProductId", combination.get("defaultVariantProductId") + + currentFeature.getString("idCode")); } else { newCombination.put("defaultVariantProductId", combination.get("defaultVariantProductId")); } @@ -270,7 +276,8 @@ public class ProductFeatureServices { for (Map<String, Object> combination: oldCombinations) { // Verify if the default code is already used, if so add a numeric suffix if (defaultVariantProductIds.contains(combination.get("defaultVariantProductId"))) { - combination.put("defaultVariantProductId", combination.get("defaultVariantProductId") + "-" + (defaultCodeCounter < 10 ? "0" + defaultCodeCounter : "" + defaultCodeCounter)); + combination.put("defaultVariantProductId", combination.get("defaultVariantProductId") + "-" + (defaultCodeCounter < 10 ? "0" + + defaultCodeCounter : "" + defaultCodeCounter)); defaultCodeCounter++; } defaultVariantProductIds.add((String) combination.get("defaultVariantProductId")); @@ -322,9 +329,11 @@ public class ProductFeatureServices { // find variants for each member product of the category try { - result = dispatcher.runSync("getProductVariant", UtilMisc.toMap("productId", memberProduct.getString("productId"), "selectedFeatures", featuresByType)); + result = dispatcher.runSync("getProductVariant", UtilMisc.toMap("productId", memberProduct.getString("productId"), + "selectedFeatures", featuresByType)); } catch (GenericServiceException ex) { - Debug.logError("Cannot get product variants for " + memberProduct.getString("productId") + " due to error: " + ex.getMessage(), MODULE); + Debug.logError("Cannot get product variants for " + memberProduct.getString("productId") + " due to error: " + + ex.getMessage(), MODULE); return ServiceUtil.returnError(ex.getMessage()); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/CropImage.java b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/CropImage.java index 68df917..419b74d 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/CropImage.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/CropImage.java @@ -54,7 +54,8 @@ public class CropImage { Delegator delegator = dispatcher.getDelegator(); Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - String nameOfThumb = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.nameofthumbnail", delegator), context); + String nameOfThumb = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", + "image.management.nameofthumbnail", delegator), context); String productId = (String) context.get("productId"); String imageName = (String) context.get("imageName"); @@ -97,8 +98,10 @@ public class CropImage { String filenameToUse = (String) contentResult.get("contentId") + ".jpg"; String filenameTouseThumb = (String) contentResult.get("contentId") + nameOfThumb + ".jpg"; - String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.path", delegator), context); - String imageServerUrl = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.url", delegator), context); + String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", + "image.management.path", delegator), context); + String imageServerUrl = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", + "image.management.url", delegator), context); BufferedImage bufImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + imageName)); int x = Integer.parseInt(imageX); @@ -114,7 +117,8 @@ public class CropImage { double imgWidth = bufNewImg.getWidth(); Map<String, Object> resultResize = ImageManagementServices.resizeImageThumbnail(bufNewImg, imgHeight, imgWidth); - ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + "/" + productId + "/" + filenameTouseThumb)); + ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + + "/" + productId + "/" + filenameTouseThumb)); String imageUrlResource = imageServerUrl + "/" + productId + "/" + filenameToUse; String imageUrlThumb = imageServerUrl + "/" + productId + "/" + filenameTouseThumb; @@ -146,7 +150,7 @@ public class CropImage { productContentCtx.put("contentId", contentId); productContentCtx.put("statusId", "IM_PENDING"); try { - Map<String, Object> serviceResult= dispatcher.runSync("createProductContent", productContentCtx); + Map<String, Object> serviceResult = dispatcher.runSync("createProductContent", productContentCtx); if (ServiceUtil.isError(serviceResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ReplaceImage.java b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ReplaceImage.java index 4fbbc3a..12a68bd 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ReplaceImage.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/ReplaceImage.java @@ -53,7 +53,8 @@ public class ReplaceImage { Delegator delegator = dctx.getDelegator(); Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.path", delegator), context); + String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", + "image.management.path", delegator), context); String productId = (String) context.get("productId"); String contentIdExist = (String) context.get("contentIdExist"); String contentIdReplace = (String) context.get("contentIdReplace"); @@ -68,7 +69,7 @@ public class ReplaceImage { return ServiceUtil.returnError(errMsg); } } else { - String errMsg = UtilProperties.getMessage(RES_ERROR, "ProductPleaseChooseImageToReplace", locale); + String errMsg = UtilProperties.getMessage(RES_ERROR, "ProductPleaseChooseImageToReplace", locale); Debug.logError(errMsg, MODULE); return ServiceUtil.returnError(errMsg); } @@ -82,28 +83,38 @@ public class ReplaceImage { BufferedImage bufImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceNameReplace)); ImageIO.write(bufImg, "jpg", new File(imageServerPath + "/" + productId + "/" + dataResourceNameExist)); - List<GenericValue> contentAssocReplaceList = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", contentIdReplace, "contentAssocTypeId", "IMAGE_THUMBNAIL").queryList(); + List<GenericValue> contentAssocReplaceList = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", + contentIdReplace, "contentAssocTypeId", "IMAGE_THUMBNAIL").queryList(); if (!contentAssocReplaceList.isEmpty()) { for (int i = 0; i < contentAssocReplaceList.size(); i++) { GenericValue contentAssocReplace = contentAssocReplaceList.get(i); - GenericValue dataResourceAssocReplace = EntityQuery.use(delegator).from("ContentDataResourceView").where("contentId", contentAssocReplace.get("contentIdTo")).queryFirst(); + GenericValue dataResourceAssocReplace = EntityQuery.use(delegator).from("ContentDataResourceView") + .where("contentId", contentAssocReplace.get("contentIdTo")).queryFirst(); - GenericValue contentAssocExist = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", contentIdExist, "contentAssocTypeId", "IMAGE_THUMBNAIL", "mapKey", contentAssocReplace.get("mapKey")).queryFirst(); + GenericValue contentAssocExist = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", + contentIdExist, "contentAssocTypeId", "IMAGE_THUMBNAIL", "mapKey", contentAssocReplace.get("mapKey")).queryFirst(); - GenericValue dataResourceAssocExist = EntityQuery.use(delegator).from("ContentDataResourceView").where("contentId", contentAssocExist.get("contentIdTo")).queryFirst(); + GenericValue dataResourceAssocExist = EntityQuery.use(delegator).from("ContentDataResourceView") + .where("contentId", contentAssocExist.get("contentIdTo")).queryFirst(); if (UtilValidate.isNotEmpty(dataResourceAssocExist)) { - BufferedImage bufImgAssocReplace = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceAssocReplace.get("drDataResourceName"))); - ImageIO.write(bufImgAssocReplace, "jpg", new File(imageServerPath + "/" + productId + "/" + dataResourceAssocExist.get("drDataResourceName"))); + BufferedImage bufImgAssocReplace = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + + dataResourceAssocReplace.get("drDataResourceName"))); + ImageIO.write(bufImgAssocReplace, "jpg", new File(imageServerPath + "/" + productId + "/" + + dataResourceAssocExist.get("drDataResourceName"))); } else { - BufferedImage bufImgAssocReplace = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceAssocReplace.get("drDataResourceName"))); - ImageIO.write(bufImgAssocReplace, "jpg", new File(imageServerPath + "/" + productId + "/" + dataResourceNameExist.substring(0, dataResourceNameExist.length() - 4) + "-" + contentAssocReplace.get("mapKey") + ".jpg")); + BufferedImage bufImgAssocReplace = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + + dataResourceAssocReplace.get("drDataResourceName"))); + ImageIO.write(bufImgAssocReplace, "jpg", new File(imageServerPath + "/" + productId + "/" + + dataResourceNameExist.substring(0, dataResourceNameExist.length() - 4) + "-" + contentAssocReplace.get("mapKey") + + ".jpg")); } } } - GenericValue productContent = EntityQuery.use(delegator).from("ProductContent").where("productId", productId, "contentId", contentIdReplace, "productContentTypeId", "IMAGE").queryFirst(); + GenericValue productContent = EntityQuery.use(delegator).from("ProductContent").where("productId", productId, "contentId", + contentIdReplace, "productContentTypeId", "IMAGE").queryFirst(); if (productContent != null) { Map<String, Object> productContentCtx = new HashMap<>(); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/RotateImage.java b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/RotateImage.java index b5c03bd..bc3cbb1 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/RotateImage.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/imagemanagement/RotateImage.java @@ -51,11 +51,12 @@ public class RotateImage { public static Map<String, Object> imageRotate(DispatchContext dctx, Map<String, ? extends Object> context) throws IOException { - Locale locale = (Locale) context.get("locale"); + Locale locale = (Locale) context.get("locale"); LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); GenericValue userLogin = (GenericValue) context.get("userLogin"); - String nameOfThumb = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.nameofthumbnail", delegator), context); + String nameOfThumb = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", + "image.management.nameofthumbnail", delegator), context); String productId = (String) context.get("productId"); String imageName = (String) context.get("imageName"); @@ -95,8 +96,10 @@ public class RotateImage { String filenameToUse = (String) contentResult.get("contentId") + ".jpg"; String filenameTouseThumb = (String) contentResult.get("contentId") + nameOfThumb + ".jpg"; - String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.path", delegator), context); - String imageServerUrl = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.url", delegator), context); + String imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", + "image.management.path", delegator), context); + String imageServerUrl = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", + "image.management.url", delegator), context); BufferedImage bufImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + imageName)); int bufImgType; @@ -111,7 +114,7 @@ public class RotateImage { BufferedImage bufNewImg = new BufferedImage(w, h, bufImgType); Graphics2D g = bufNewImg.createGraphics(); g.rotate(Math.toRadians(Double.parseDouble(angle)), w / 2.0, h / 2.0); - g.drawImage(bufImg,0,0, null); + g.drawImage(bufImg, 0, 0, null); g.dispose(); String mimeType = imageName.substring(imageName.lastIndexOf('.') + 1); @@ -121,7 +124,8 @@ public class RotateImage { double imgWidth = bufNewImg.getWidth(); Map<String, Object> resultResize = ImageManagementServices.resizeImageThumbnail(bufNewImg, imgHeight, imgWidth); - ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + "/" + productId + "/" + filenameTouseThumb)); + ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + "/" + + productId + "/" + filenameTouseThumb)); String imageUrlResource = imageServerUrl + "/" + productId + "/" + filenameToUse; String imageUrlThumb = imageServerUrl + "/" + productId + "/" + filenameTouseThumb; diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java index 7ac8c90..dab74a7 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/KeywordIndex.java @@ -66,7 +66,8 @@ public class KeywordIndex { if ("N".equals(product.getString("autoCreateKeywords"))) { return; } - if ("Y".equals(product.getString("isVariant")) && "true".equals(EntityUtilProperties.getPropertyValue("prodsearch", "index.ignore.variants", delegator))) { + if ("Y".equals(product.getString("isVariant")) && "true".equals(EntityUtilProperties.getPropertyValue("prodsearch", + "index.ignore.variants", delegator))) { return; } Timestamp salesDiscontinuationDate = product.getTimestamp("salesDiscontinuationDate"); @@ -118,10 +119,11 @@ public class KeywordIndex { // ProductFeatureAppl if (!"0".equals(EntityUtilProperties.getPropertyValue("prodsearch", "index.weight.ProductFeatureAndAppl.description", "0", delegator)) - || !"0".equals(EntityUtilProperties.getPropertyValue("prodsearch", "index.weight.ProductFeatureAndAppl.abbrev", "0", delegator)) - || !"0".equals(EntityUtilProperties.getPropertyValue("prodsearch", "index.weight.ProductFeatureAndAppl.idCode", "0", delegator))) { + || !"0".equals(EntityUtilProperties.getPropertyValue("prodsearch", "index.weight.ProductFeatureAndAppl.abbrev", "0", delegator)) + || !"0".equals(EntityUtilProperties.getPropertyValue("prodsearch", "index.weight.ProductFeatureAndAppl.idCode", "0", delegator))) { // get strings from attributes and features - List<GenericValue> productFeatureAndAppls = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId).queryList(); + List<GenericValue> productFeatureAndAppls = EntityQuery.use(delegator).from("ProductFeatureAndAppl") + .where("productId", productId).queryList(); for (GenericValue productFeatureAndAppl: productFeatureAndAppls) { addWeightedKeywordSourceString(productFeatureAndAppl, "description", strings); addWeightedKeywordSourceString(productFeatureAndAppl, "abbrev", strings); @@ -150,7 +152,8 @@ public class KeywordIndex { // Variant Product IDs if ("Y".equals(product.getString("isVirtual"))) { if (!"0".equals(EntityUtilProperties.getPropertyValue("prodsearch", "index.weight.Variant.Product.productId", "0", delegator))) { - List<GenericValue> variantProductAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList(); + List<GenericValue> variantProductAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, + "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList(); for (GenericValue variantProductAssoc: variantProductAssocs) { int weight = 1; try { @@ -175,11 +178,13 @@ public class KeywordIndex { Debug.logWarning("Could not parse weight number: " + e.toString(), MODULE); } - List<GenericValue> productContentAndInfos = EntityQuery.use(delegator).from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", productContentTypeId).queryList(); + List<GenericValue> productContentAndInfos = EntityQuery.use(delegator).from("ProductContentAndInfo").where("productId", productId, + "productContentTypeId", productContentTypeId).queryList(); for (GenericValue productContentAndInfo: productContentAndInfos) { addWeightedDataResourceString(productContentAndInfo, weight, strings, delegator, product); - List<GenericValue> alternateViews = productContentAndInfo.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"), false); + List<GenericValue> alternateViews = productContentAndInfo.getRelated("ContentAssocDataResourceViewTo", + UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"), false); alternateViews = EntityUtil.filterByDate(alternateViews, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true); for (GenericValue thisView: alternateViews) { addWeightedDataResourceString(thisView, weight, strings, delegator, product); @@ -197,13 +202,15 @@ public class KeywordIndex { int keywordMaxLength = EntityUtilProperties.getPropertyAsInteger("prodsearch", "product.keyword.max.length", 0); for (Map.Entry<String, Long> entry: keywords.entrySet()) { if (entry.getKey().length() <= keywordMaxLength) { - GenericValue productKeyword = delegator.makeValue("ProductKeyword", UtilMisc.toMap("productId", product.getString("productId"), "keyword", entry.getKey(), "keywordTypeId", "KWT_KEYWORD", "relevancyWeight", entry.getValue())); + GenericValue productKeyword = delegator.makeValue("ProductKeyword", UtilMisc.toMap("productId", product.getString("productId"), + "keyword", entry.getKey(), "keywordTypeId", "KWT_KEYWORD", "relevancyWeight", entry.getValue())); toBeStored.add(productKeyword); } } if (!toBeStored.isEmpty()) { if (Debug.verboseOn()) { - Debug.logVerbose("[KeywordIndex.indexKeywords] Storing " + toBeStored.size() + " keywords for productId " + product.getString("productId"), MODULE); + Debug.logVerbose("[KeywordIndex.indexKeywords] Storing " + toBeStored.size() + " keywords for productId " + + product.getString("productId"), MODULE); } if ("true".equals(EntityUtilProperties.getPropertyValue("prodsearch", "index.delete.on_index", "false", delegator))) { @@ -215,10 +222,12 @@ public class KeywordIndex { } } - public static void addWeightedDataResourceString(GenericValue drView, int weight, List<String> strings, Delegator delegator, GenericValue product) { + public static void addWeightedDataResourceString(GenericValue drView, int weight, List<String> strings, Delegator delegator, + GenericValue product) { Map<String, Object> drContext = UtilMisc.<String, Object>toMap("product", product); try { - String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, drView.getString("dataResourceId"), drContext, null, null, false); + String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, drView.getString("dataResourceId"), drContext, + null, null, false); for (int i = 0; i < weight; i++) { strings.add(contentText); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductPromoContentWrapper.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductPromoContentWrapper.java index 228bc7c..83f818a 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductPromoContentWrapper.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductPromoContentWrapper.java @@ -59,7 +59,8 @@ public class ProductPromoContentWrapper implements ContentWrapper { private static final String MODULE = ProductPromoContentWrapper.class.getName(); public static final String SEPARATOR = "::"; // cache key separator - private static final UtilCache<String, String> PRODUCT_PROMO_CONTENT_CACHE = UtilCache.createUtilCache("product.promo.content.rendered", true); + private static final UtilCache<String, String> PRODUCT_PROMO_CONTENT_CACHE = + UtilCache.createUtilCache("product.promo.content.rendered", true); public static ProductPromoContentWrapper makeProductPromoContentWrapper(GenericValue productPromo, HttpServletRequest request) { return new ProductPromoContentWrapper(productPromo, request); @@ -81,7 +82,8 @@ public class ProductPromoContentWrapper implements ContentWrapper { this.dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); this.productPromo = productPromo; this.locale = UtilHttp.getLocale(request); - this.mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", (Delegator) request.getAttribute("delegator")); + this.mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", + (Delegator) request.getAttribute("delegator")); } @Override @@ -176,7 +178,8 @@ public class ProductPromoContentWrapper implements ContentWrapper { exprs.add(EntityCondition.makeCondition("productPromoId", EntityOperator.EQUALS, productPromoId)); exprs.add(EntityCondition.makeCondition("productPromoContentTypeId", EntityOperator.EQUALS, productPromoContentTypeId)); - List<GenericValue> productPromoContentList = EntityQuery.use(delegator).from("ProductPromoContent").where(EntityCondition.makeCondition(exprs, EntityOperator.AND)).orderBy("-fromDate").cache(cache).queryList(); + List<GenericValue> productPromoContentList = EntityQuery.use(delegator).from("ProductPromoContent").where(EntityCondition + .makeCondition(exprs, EntityOperator.AND)).orderBy("-fromDate").cache(cache).queryList(); GenericValue productPromoContent = null; if (UtilValidate.isNotEmpty(productPromoContentList)) { productPromoContent = EntityUtil.getFirst(EntityUtil.filterByDate(productPromoContentList)); @@ -187,7 +190,8 @@ public class ProductPromoContentWrapper implements ContentWrapper { Map<String, Object> inContext = new HashMap<>(); inContext.put("productPromo", productPromo); inContext.put("productPromoContent", productPromoContent); - ContentWorker.renderContentAsText(dispatcher, productPromoContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, partyId, roleTypeId, cache); + ContentWorker.renderContentAsText(dispatcher, productPromoContent.getString("contentId"), outWriter, + inContext, locale, mimeTypeId, partyId, roleTypeId, cache); return; } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java index baba193..57603eb 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java @@ -680,7 +680,8 @@ public class ProductSearchSession { String searchOperator = (String) parameters.get("SEARCH_OPERATOR" + kwNum); // defaults to true/Y, ie anything but N is true/Y boolean anyPrefixSuffix = !"N".equals(parameters.get("SEARCH_ANYPRESUF" + kwNum)); - searchAddConstraint(new ProductSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, "AND".equals(searchOperator)), session); + searchAddConstraint(new ProductSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, + "AND".equals(searchOperator)), session); constraintsChanged = true; } } @@ -693,7 +694,8 @@ public class ProductSearchSession { String paramNameExt = parameterName.substring("SEARCH_FEAT".length()); String searchCategoryExc = (String) parameters.get("SEARCH_FEAT_EXC" + paramNameExt); Boolean exclude = UtilValidate.isEmpty(searchCategoryExc) ? null : !"N".equals(searchCategoryExc); - //Debug.logInfo("parameterName=" + parameterName + ", paramNameExt=" + paramNameExt + ", searchCategoryExc=" + searchCategoryExc + ", exclude=" + exclude, MODULE); + //Debug.logInfo("parameterName=" + parameterName + ", paramNameExt=" + paramNameExt + ", searchCategoryExc=" + // + searchCategoryExc + ", exclude=" + exclude, MODULE); searchAddConstraint(new ProductSearch.FeatureConstraint(productFeatureId, exclude), session); constraintsChanged = true; } @@ -783,14 +785,16 @@ public class ProductSearchSession { try { listPriceLow = new BigDecimal((String) parameters.get("LIST_PRICE_LOW")); } catch (NumberFormatException e) { - Debug.logError("Error parsing LIST_PRICE_LOW parameter [" + (String) parameters.get("LIST_PRICE_LOW") + "]: " + e.toString(), MODULE); + Debug.logError("Error parsing LIST_PRICE_LOW parameter [" + (String) parameters.get("LIST_PRICE_LOW") + "]: " + + e.toString(), MODULE); } } if (UtilValidate.isNotEmpty(parameters.get("LIST_PRICE_HIGH"))) { try { listPriceHigh = new BigDecimal((String) parameters.get("LIST_PRICE_HIGH")); } catch (NumberFormatException e) { - Debug.logError("Error parsing LIST_PRICE_HIGH parameter [" + (String) parameters.get("LIST_PRICE_HIGH") + "]: " + e.toString(), MODULE); + Debug.logError("Error parsing LIST_PRICE_HIGH parameter [" + (String) parameters.get("LIST_PRICE_HIGH") + "]: " + + e.toString(), MODULE); } } searchAddConstraint(new ProductSearch.ListPriceRangeConstraint(listPriceLow, listPriceHigh, listPriceCurrency), session); @@ -846,7 +850,7 @@ public class ProductSearchSession { } if (UtilValidate.isNotEmpty(parameters.get("SEARCH_GOOD_IDENTIFICATION_TYPE")) - || UtilValidate.isNotEmpty(parameters.get("SEARCH_GOOD_IDENTIFICATION_VALUE"))) { + || UtilValidate.isNotEmpty(parameters.get("SEARCH_GOOD_IDENTIFICATION_VALUE"))) { String include = (String) parameters.get("SEARCH_GOOD_IDENTIFICATION_INCL"); if (UtilValidate.isEmpty(include)) { include = "Y"; diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/VariantEvents.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/VariantEvents.java index c736566..1f90a10 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/VariantEvents.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/VariantEvents.java @@ -64,7 +64,8 @@ public class VariantEvents { } if (UtilValidate.isEmpty(variantProductId)) { - errMsg = UtilProperties.getMessage(RESOURCE, "variantevents.variantProductId_required_but_missing_enter_an_id", UtilHttp.getLocale(request)); + errMsg = UtilProperties.getMessage(RESOURCE, "variantevents.variantProductId_required_but_missing_enter_an_id", + UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } @@ -125,13 +126,15 @@ public class VariantEvents { String productFeatureId = request.getParameter("feature_" + i); if (productFeatureId == null) { Map<String, String> messageMap = UtilMisc.toMap("i", Integer.toString(i)); - errMsg = UtilProperties.getMessage(RESOURCE, "variantevents.productFeatureId_for_feature_type_number_not_found", messageMap, UtilHttp.getLocale(request)); + errMsg = UtilProperties.getMessage(RESOURCE, "variantevents.productFeatureId_for_feature_type_number_not_found", + messageMap, UtilHttp.getLocale(request)); TransactionUtil.rollback(beganTransacton, errMsg, null); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } - GenericValue productFeature = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureId", productFeatureId).queryOne(); + GenericValue productFeature = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureId", + productFeatureId).queryOne(); GenericValue productFeatureAppl = delegator.makeValue("ProductFeatureAppl", UtilMisc.toMap("productId", variantProductId, "productFeatureId", productFeatureId, @@ -148,7 +151,8 @@ public class VariantEvents { TransactionUtil.commit(beganTransacton); } catch (GenericEntityException e) { Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString()); - errMsg = UtilProperties.getMessage(RESOURCE, "variantevents.entity_error_quick_add_variant_data", messageMap, UtilHttp.getLocale(request)); + errMsg = UtilProperties.getMessage(RESOURCE, "variantevents.entity_error_quick_add_variant_data", messageMap, + UtilHttp.getLocale(request)); TransactionUtil.rollback(beganTransacton, errMsg, null); Debug.logError(e, "Entity error creating quick add variant data", MODULE); request.setAttribute("_ERROR_MESSAGE_", errMsg); @@ -157,13 +161,15 @@ public class VariantEvents { } catch (GenericTransactionException e) { Debug.logError(e, "Transaction error creating quick add variant data", MODULE); Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString()); - errMsg = UtilProperties.getMessage(RESOURCE, "variantevents.transaction_error_quick_add_variant_data", messageMap, UtilHttp.getLocale(request)); + errMsg = UtilProperties.getMessage(RESOURCE, "variantevents.transaction_error_quick_add_variant_data", messageMap, + UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } Map<String, String> messageMap = UtilMisc.toMap("variantProductId", variantProductId); - String sucMsg = UtilProperties.getMessage(RESOURCE, "variantevents.successfully_created_variant_product_with_id", messageMap, UtilHttp.getLocale(request)); + String sucMsg = UtilProperties.getMessage(RESOURCE, "variantevents.successfully_created_variant_product_with_id", messageMap, + UtilHttp.getLocale(request)); request.setAttribute("_EVENT_MESSAGE_", sucMsg); return "success"; } 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 b56c8fd..2188f55 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 @@ -49,16 +49,19 @@ public class ProductStoreEvents { List<String> sortList = org.apache.ofbiz.base.util.UtilMisc.toList("sequenceNum"); try { - GenericValue productStoreGroup = EntityQuery.use(delegator).from("ProductStoreGroup").where("productStoreGroupId", parentGroupId).cache(true).queryOne(); + GenericValue productStoreGroup = EntityQuery.use(delegator).from("ProductStoreGroup").where("productStoreGroupId", + parentGroupId).cache(true).queryOne(); if (productStoreGroup != null) { - children = EntityQuery.use(delegator).from("ProductStoreGroupRollupAndChild").where("parentGroupId", parentGroupId).cache(true).filterByDate().queryList(); + children = EntityQuery.use(delegator).from("ProductStoreGroupRollupAndChild").where("parentGroupId", + parentGroupId).cache(true).filterByDate().queryList(); if (UtilValidate.isNotEmpty(children)) { for (GenericValue child : children) { String productStoreGroupId = child.getString("productStoreGroupId"); Map<Object, Object> josonMap = new HashMap<>(); List<GenericValue> childList = null; // Get the child list of chosen category - childList = EntityQuery.use(delegator).from("ProductStoreGroupRollupAndChild").where("parentGroupId", productStoreGroupId).cache(true).filterByDate().queryList(); + childList = EntityQuery.use(delegator).from("ProductStoreGroupRollupAndChild").where("parentGroupId", + productStoreGroupId).cache(true).filterByDate().queryList(); if (UtilValidate.isNotEmpty(childList)) { josonMap.put("state", "closed"); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreWorker.java b/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreWorker.java index 8165910..c6ab823 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreWorker.java @@ -160,14 +160,18 @@ public final class ProductStoreWorker { return payToPartyId; } - public static String getProductStorePaymentProperties(ServletRequest request, String paymentMethodTypeId, String paymentServiceTypeEnumId, boolean anyServiceType) { + public static String getProductStorePaymentProperties(ServletRequest request, String paymentMethodTypeId, String paymentServiceTypeEnumId, + boolean anyServiceType) { Delegator delegator = (Delegator) request.getAttribute("delegator"); String productStoreId = ProductStoreWorker.getProductStoreId(request); - return ProductStoreWorker.getProductStorePaymentProperties(delegator, productStoreId, paymentMethodTypeId, paymentServiceTypeEnumId, anyServiceType); + return ProductStoreWorker.getProductStorePaymentProperties(delegator, productStoreId, paymentMethodTypeId, paymentServiceTypeEnumId, + anyServiceType); } - public static String getProductStorePaymentProperties(Delegator delegator, String productStoreId, String paymentMethodTypeId, String paymentServiceTypeEnumId, boolean anyServiceType) { - GenericValue setting = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStoreId, paymentMethodTypeId, paymentServiceTypeEnumId, anyServiceType); + public static String getProductStorePaymentProperties(Delegator delegator, String productStoreId, String paymentMethodTypeId, + String paymentServiceTypeEnumId, boolean anyServiceType) { + GenericValue setting = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStoreId, paymentMethodTypeId, + paymentServiceTypeEnumId, anyServiceType); String payProps = "payment.properties"; if (setting != null && setting.get("paymentPropertiesPath") != null) { @@ -176,10 +180,12 @@ public final class ProductStoreWorker { return payProps; } - public static GenericValue getProductStorePaymentSetting(Delegator delegator, String productStoreId, String paymentMethodTypeId, String paymentServiceTypeEnumId, boolean anyServiceType) { + public static GenericValue getProductStorePaymentSetting(Delegator delegator, String productStoreId, String paymentMethodTypeId, + String paymentServiceTypeEnumId, boolean anyServiceType) { GenericValue storePayment = null; try { - storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId, "paymentServiceTypeEnumId", paymentServiceTypeEnumId).cache().queryOne(); + storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId, + "paymentMethodTypeId", paymentMethodTypeId, "paymentServiceTypeEnumId", paymentServiceTypeEnumId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Problems looking up store payment settings", MODULE); } @@ -187,7 +193,8 @@ public final class ProductStoreWorker { if (anyServiceType) { if (storePayment == null) { try { - storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId).queryFirst(); + storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId, + "paymentMethodTypeId", paymentMethodTypeId).queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, "Problems looking up store payment settings", MODULE); } @@ -227,16 +234,19 @@ public final class ProductStoreWorker { String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId) { // TODO: selecting the first record is a far from optimal solution but, since the productStoreShipmentMethod // is currently used to get the service name to get the online estimate, this should not be a huge deal for now. - return EntityUtil.getFirst(getProductStoreShipmentMethods(delegator, productStoreId, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId)); + return EntityUtil.getFirst(getProductStoreShipmentMethods(delegator, productStoreId, shipmentMethodTypeId, carrierPartyId, + carrierRoleTypeId)); } - public static List<GenericValue> getAvailableStoreShippingMethods(Delegator delegator, String productStoreId, GenericValue shippingAddress, List<BigDecimal> itemSizes, Map<String, BigDecimal> featureIdMap, BigDecimal weight, BigDecimal orderTotal) { + public static List<GenericValue> getAvailableStoreShippingMethods(Delegator delegator, String productStoreId, GenericValue shippingAddress, + List<BigDecimal> itemSizes, Map<String, BigDecimal> featureIdMap, BigDecimal weight, BigDecimal orderTotal) { if (featureIdMap == null) { featureIdMap = new HashMap<>(); } List<GenericValue> shippingMethods = null; try { - shippingMethods = EntityQuery.use(delegator).from("ProductStoreShipmentMethView").where("productStoreId", productStoreId).orderBy("sequenceNumber").cache(true).queryList(); + shippingMethods = EntityQuery.use(delegator).from("ProductStoreShipmentMethView").where("productStoreId", + productStoreId).orderBy("sequenceNumber").cache(true).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductStore shipping methods", MODULE); return null; @@ -378,7 +388,8 @@ public final class ProductStoreWorker { if (UtilValidate.isNotEmpty(includeFeatures)) { List<GenericValue> includedFeatures = null; try { - includedFeatures = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId", includeFeatures).cache(true).queryList(); + includedFeatures = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId", + includeFeatures).cache(true).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + includeFeatures, MODULE); } @@ -399,7 +410,8 @@ public final class ProductStoreWorker { if (UtilValidate.isNotEmpty(excludeFeatures)) { List<GenericValue> excludedFeatures = null; try { - excludedFeatures = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId", excludeFeatures).cache(true).queryList(); + excludedFeatures = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId", + excludeFeatures).cache(true).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + excludeFeatures, MODULE); } @@ -437,7 +449,8 @@ public final class ProductStoreWorker { return getRandomSurveyWrapper(productStore.getDelegator(), productStore.getString("productStoreId"), groupName, partyId, passThruFields); } - public static ProductStoreSurveyWrapper getRandomSurveyWrapper(Delegator delegator, String productStoreId, String groupName, String partyId, Map<String, Object> passThruFields) { + public static ProductStoreSurveyWrapper getRandomSurveyWrapper(Delegator delegator, String productStoreId, String groupName, String + partyId, Map<String, Object> passThruFields) { List<GenericValue> randomSurveys = getSurveys(delegator, productStoreId, groupName, null, "RANDOM_POLL", null); if (UtilValidate.isNotEmpty(randomSurveys)) { Random rand = new Random(); @@ -453,15 +466,18 @@ public final class ProductStoreWorker { return getSurveys(delegator, productStoreId, null, productId, surveyApplTypeId, null); } - public static List<GenericValue> getProductSurveys(Delegator delegator, String productStoreId, String productId, String surveyApplTypeId, String parentProductId) { + public static List<GenericValue> getProductSurveys(Delegator delegator, String productStoreId, String productId, String surveyApplTypeId, + String parentProductId) { return getSurveys(delegator, productStoreId, null, productId, surveyApplTypeId, parentProductId); } - public static List<GenericValue> getSurveys(Delegator delegator, String productStoreId, String groupName, String productId, String surveyApplTypeId, String parentProductId) { + public static List<GenericValue> getSurveys(Delegator delegator, String productStoreId, String groupName, String productId, String + surveyApplTypeId, String parentProductId) { List<GenericValue> surveys = new LinkedList<>(); List<GenericValue> storeSurveys = null; try { - storeSurveys = EntityQuery.use(delegator).from("ProductStoreSurveyAppl").where("productStoreId", productStoreId, "surveyApplTypeId", surveyApplTypeId).orderBy("sequenceNum").cache(true).queryList(); + storeSurveys = EntityQuery.use(delegator).from("ProductStoreSurveyAppl").where("productStoreId", productStoreId, "surveyApplTypeId", + surveyApplTypeId).orderBy("sequenceNum").cache(true).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductStoreSurveyAppl for store : " + productStoreId, MODULE); return surveys; @@ -475,7 +491,7 @@ public final class ProductStoreWorker { storeSurveys = EntityUtil.filterByAnd(storeSurveys, UtilMisc.toMap("groupName", groupName)); } - Debug.logInfo("getSurvey for product " + productId, MODULE); + Debug.logInfo("getSurvey for product " + productId, MODULE); // limit by product if (UtilValidate.isNotEmpty(productId) && UtilValidate.isNotEmpty(storeSurveys)) { for (GenericValue surveyAppl: storeSurveys) { @@ -507,7 +523,8 @@ public final class ProductStoreWorker { } else if (surveyAppl.get("productCategoryId") != null) { List<GenericValue> categoryMembers = null; try { - categoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", surveyAppl.get("productCategoryId")).cache(true).queryList(); + categoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", + surveyAppl.get("productCategoryId")).cache(true).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductCategoryMember records for survey application : " + surveyAppl, MODULE); } @@ -516,7 +533,8 @@ public final class ProductStoreWorker { if (productId != null && productId.equals(member.getString("productId"))) { surveys.add(surveyAppl); break; - } else if ((virtualProductId != null) && (virtualProductId.equals(member.getString("productId")))) { // similarly, check if virtual productId is in category + } else if ((virtualProductId != null) && (virtualProductId.equals(member.getString("productId")))) { + // similarly, check if virtual productId is in category surveys.add(surveyAppl); break; } @@ -581,7 +599,8 @@ public final class ProductStoreWorker { * @param wantRequired If true then inventory required must be true for the result to be true, if false must be false; if null don't care * @param wantAvailable If true then inventory avilable must be true for the result to be true, if false must be false; if null don't care */ - public static boolean isStoreInventoryRequiredAndAvailable(ServletRequest request, GenericValue product, BigDecimal quantity, Boolean wantRequired, Boolean wantAvailable) { + public static boolean isStoreInventoryRequiredAndAvailable(ServletRequest request, GenericValue product, BigDecimal quantity, Boolean + wantRequired, Boolean wantAvailable) { GenericValue productStore = getProductStore(request); if (productStore == null) { Debug.logWarning("No ProductStore found, return false for inventory check", MODULE); @@ -600,7 +619,9 @@ public final class ProductStoreWorker { try { Boolean requiredOkay = null; if (wantRequired != null) { - Map<String, Object> invReqResult = dispatcher.runSync("isStoreInventoryRequired", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "productStore", productStore)); + Map<String, Object> invReqResult = dispatcher.runSync("isStoreInventoryRequired", + UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, + "productStore", productStore)); if (ServiceUtil.isError(invReqResult)) { Debug.logError("Error calling isStoreInventoryRequired service, result is: " + invReqResult, MODULE); return false; @@ -610,7 +631,9 @@ public final class ProductStoreWorker { Boolean availableOkay = null; if (wantAvailable != null) { - Map<String, Object> invAvailResult = dispatcher.runSync("isStoreInventoryAvailable", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "productStore", productStore, "quantity", quantity)); + Map<String, Object> invAvailResult = dispatcher.runSync("isStoreInventoryAvailable", + UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, + "productStore", productStore, "quantity", quantity)); if (ServiceUtil.isError(invAvailResult)) { Debug.logError("Error calling isStoreInventoryAvailable service, result is: " + invAvailResult, MODULE); return false; @@ -641,7 +664,8 @@ public final class ProductStoreWorker { } /** check inventory availability for the given catalog, product, quantity, etc */ - public static boolean isStoreInventoryAvailable(String productStoreId, ProductConfigWrapper productConfig, BigDecimal quantity, Delegator delegator, LocalDispatcher dispatcher) { + public static boolean isStoreInventoryAvailable(String productStoreId, ProductConfigWrapper productConfig, BigDecimal quantity, + Delegator delegator, LocalDispatcher dispatcher) { GenericValue productStore = getProductStore(productStoreId, delegator); if (productStore == null) { @@ -653,7 +677,8 @@ public final class ProductStoreWorker { if ("N".equals(productStore.getString("checkInventory"))) { // note: if not set, defaults to yes, check inventory if (Debug.verboseOn()) { - Debug.logVerbose("ProductStore with id " + productStoreId + ", is set to NOT check inventory, returning true for inventory available check", MODULE); + Debug.logVerbose("ProductStore with id " + productStoreId + + ", is set to NOT check inventory, returning true for inventory available check", MODULE); } return true; } @@ -663,7 +688,8 @@ public final class ProductStoreWorker { String 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); return false; } @@ -682,8 +708,9 @@ public final class ProductStoreWorker { if (UtilValidate.isNotEmpty(productFacilities)) { for (GenericValue pfValue: productFacilities) { - isInventoryAvailable = ProductWorker.isProductInventoryAvailableByFacility(productConfig, pfValue.getString("facilityId"), quantity, dispatcher); - if (isInventoryAvailable == true) { + isInventoryAvailable = ProductWorker.isProductInventoryAvailableByFacility(productConfig, + pfValue.getString("facilityId"), quantity, dispatcher); + if (isInventoryAvailable) { return isInventoryAvailable; } } 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 6a495b2..01a7f91 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 @@ -80,7 +80,8 @@ public class SubscriptionServices { subscriptionFindMap.put("inventoryItemId", inventoryItemId); } List<GenericValue> subscriptionList = EntityQuery.use(delegator).from("Subscription").where(subscriptionFindMap).queryList(); - // DEJ20070718 DON'T filter by date, we want to consider all subscriptions: List listFiltered = EntityUtil.filterByDate(subscriptionList, true); + // DEJ20070718 DON'T filter by date, we want to consider all subscriptions: List listFiltered + // = EntityUtil.filterByDate(subscriptionList, true); List<GenericValue> listOrdered = EntityUtil.orderBy(subscriptionList, UtilMisc.toList("-fromDate")); if (!listOrdered.isEmpty()) { lastSubscription = listOrdered.get(0); @@ -139,7 +140,8 @@ public class SubscriptionServices { Map<String, Object> result = ServiceUtil.returnSuccess(); try { if (lastSubscription != null && !alwaysCreateNewRecord) { - Map<String, Object> updateSubscriptionMap = dctx.getModelService("updateSubscription").makeValid(newSubscription, ModelService.IN_PARAM); + Map<String, Object> updateSubscriptionMap = dctx.getModelService("updateSubscription") + .makeValid(newSubscription, ModelService.IN_PARAM); updateSubscriptionMap.put("userLogin", EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne()); Map<String, Object> updateSubscriptionResult = dispatcher.runSync("updateSubscription", updateSubscriptionMap); @@ -164,7 +166,8 @@ public class SubscriptionServices { null, null, createPartyRoleResult); } } - Map<String, Object> createSubscriptionMap = dctx.getModelService("createSubscription").makeValid(newSubscription, ModelService.IN_PARAM); + Map<String, Object> createSubscriptionMap = dctx.getModelService("createSubscription") + .makeValid(newSubscription, ModelService.IN_PARAM); createSubscriptionMap.put("userLogin", EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne()); Map<String, Object> createSubscriptionResult = dispatcher.runSync("createSubscription", createSubscriptionMap); @@ -182,7 +185,8 @@ public class SubscriptionServices { return result; } - public static Map<String, Object> processExtendSubscriptionByProduct(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException { + public static Map<String, Object> processExtendSubscriptionByProduct(DispatchContext dctx, Map<String, ? extends Object> context) + throws GenericServiceException { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); String productId = (String) context.get("productId"); @@ -244,7 +248,8 @@ public class SubscriptionServices { return ServiceUtil.returnSuccess(); } - public static Map<String, Object> processExtendSubscriptionByOrder(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException { + public static Map<String, Object> processExtendSubscriptionByOrder(DispatchContext dctx, Map<String, ? extends Object> context) + throws GenericServiceException { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); Map<String, Object> subContext = UtilMisc.makeMapWritable(context); @@ -255,7 +260,8 @@ public class SubscriptionServices { GenericValue orderHeader = null; try { - List<GenericValue> orderRoleList = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER").queryList(); + List<GenericValue> orderRoleList = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, + "roleTypeId", "END_USER_CUSTOMER").queryList(); if (!orderRoleList.isEmpty()) { GenericValue orderRole = orderRoleList.get(0); String partyId = (String) orderRole.get("partyId"); @@ -280,7 +286,8 @@ public class SubscriptionServices { if (UtilValidate.isEmpty(productId)) { continue; } - List<GenericValue> productSubscriptionResourceListFiltered = EntityQuery.use(delegator).from("ProductSubscriptionResource").where("productId", productId).cache(true).filterByDate().queryList(); + List<GenericValue> productSubscriptionResourceListFiltered = EntityQuery.use(delegator).from("ProductSubscriptionResource") + .where("productId", productId).cache(true).filterByDate().queryList(); if (!productSubscriptionResourceListFiltered.isEmpty()) { subContext.put("subscriptionTypeId", "PRODUCT_SUBSCR"); subContext.put("productId", productId); @@ -288,7 +295,8 @@ public class SubscriptionServices { subContext.put("orderItemSeqId", orderItem.get("orderItemSeqId")); subContext.put("inventoryItemId", orderItem.get("fromInventoryItemId")); subContext.put("quantity", qty.intValue()); - Map<String, Object> ctx = dctx.getModelService("processExtendSubscriptionByProduct").makeValid(subContext, ModelService.IN_PARAM); + Map<String, Object> ctx = dctx.getModelService("processExtendSubscriptionByProduct").makeValid(subContext, + ModelService.IN_PARAM); Map<String, Object> thisResult = dispatcher.runSync("processExtendSubscriptionByProduct", ctx); if (ServiceUtil.isError(thisResult)) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, @@ -308,7 +316,7 @@ public class SubscriptionServices { public static Map<String, Object> runServiceOnSubscriptionExpiry(DispatchContext dctx, Map<String, ? extends Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); - Locale locale =(Locale) context.get("locale"); + Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); Map<String, Object> result = new HashMap<>(); Map<String, Object> expiryMap = new HashMap<>(); @@ -335,7 +343,8 @@ public class SubscriptionServices { int field = Calendar.MONTH; String subscriptionResourceId = subscription.getString("subscriptionResourceId"); GenericValue subscriptionResource = null; - subscriptionResource = EntityQuery.use(delegator).from("SubscriptionResource").where("subscriptionResourceId", subscriptionResourceId).queryOne(); + subscriptionResource = EntityQuery.use(delegator).from("SubscriptionResource").where("subscriptionResourceId", + subscriptionResourceId).queryOne(); subscriptionId = subscription.getString("subscriptionId"); gracePeriodOnExpiry = subscription.getString("gracePeriodOnExpiry"); gracePeriodOnExpiryUomId = subscription.getString("gracePeriodOnExpiryUomId"); @@ -352,7 +361,8 @@ public class SubscriptionServices { } else if ("TF_yr".equals(gracePeriodOnExpiryUomId)) { field = Calendar.YEAR; } else { - Debug.logWarning("Don't know anything about gracePeriodOnExpiryUomId [" + gracePeriodOnExpiryUomId + "], defaulting to month", MODULE); + Debug.logWarning("Don't know anything about gracePeriodOnExpiryUomId [" + gracePeriodOnExpiryUomId + + "], defaulting to month", MODULE); } endDateSubscription.add(field, Integer.parseInt(gracePeriodOnExpiry)); } @@ -374,7 +384,8 @@ public class SubscriptionServices { } if (result != null && subscriptionId != null) { - Debug.logInfo("Service mentioned in serviceNameOnExpiry called with result: " + ServiceUtil.makeSuccessMessage(result, "", "", "", ""), MODULE); + Debug.logInfo("Service mentioned in serviceNameOnExpiry called with result: " + + ServiceUtil.makeSuccessMessage(result, "", "", "", ""), MODULE); } else if (result == null && subscriptionId != null) { Debug.logError("Subscription couldn't be expired for subscriptionId: " + subscriptionId, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "ProductSubscriptionCouldntBeExpired", @@ -394,9 +405,8 @@ public class SubscriptionServices { return result; } - public static Map<String, Object> runSubscriptionExpired( - DispatchContext dctx, Map<String, ? extends Object> context) { - Locale locale = (Locale) context.get("locale"); + public static Map<String, Object> runSubscriptionExpired(DispatchContext dctx, Map<String, ? extends Object> context) { + Locale locale = (Locale) context.get("locale"); String subscriptionId = (String) context.get("subscriptionId"); Map<String, Object> result = new HashMap<>(); if (subscriptionId != null) { diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java index c5270e7..2851893 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/supplier/SupplierProductServices.java @@ -61,7 +61,7 @@ public class SupplierProductServices { String productId = (String) context.get("productId"); String partyId = (String) context.get("partyId"); String currencyUomId = (String) context.get("currencyUomId"); - BigDecimal quantity =(BigDecimal) context.get("quantity"); + BigDecimal quantity = (BigDecimal) context.get("quantity"); String canDropShip = (String) context.get("canDropShip"); String agreementId = (String) context.get("agreementId"); @@ -74,7 +74,8 @@ public class SupplierProductServices { } List<GenericValue> supplierProducts = product.getRelated("SupplierProduct", null, null, true); - // if there were no related SupplierProduct entities and the item is a variant, then get the SupplierProducts of the virtual parent product + // if there were no related SupplierProduct entities and the item is a variant, then get the SupplierProducts of the + // virtual parent product if (supplierProducts.isEmpty() && product.getString("isVariant") != null && "Y".equals(product.getString("isVariant"))) { String virtualProductId = ProductWorker.getVariantVirtualId(product); GenericValue virtualProduct = EntityQuery.use(delegator).from("Product").where("productId", virtualProductId).cache().queryOne(); @@ -102,7 +103,8 @@ public class SupplierProductServices { // filter the list down by the minimumOrderQuantity if one is provided if (quantity != null) { //minimumOrderQuantity - supplierProducts = EntityUtil.filterByCondition(supplierProducts, EntityCondition.makeCondition("minimumOrderQuantity", EntityOperator.LESS_THAN_EQUAL_TO, quantity)); + supplierProducts = EntityUtil.filterByCondition(supplierProducts, EntityCondition.makeCondition("minimumOrderQuantity", + EntityOperator.LESS_THAN_EQUAL_TO, quantity)); } // filter the list down by the canDropShip if one is provided diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingServices.java index 5b31a1b..abe7860 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingServices.java @@ -57,10 +57,12 @@ public class PackingServices { quantity = BigDecimal.ONE; } - Debug.logInfo("OrderId [" + orderId + "] ship group [" + shipGroupSeqId + "] Pack input [" + productId + "] @ [" + quantity + "] packageSeq [" + packageSeq + "] weight [" + weight +"]", MODULE); + Debug.logInfo("OrderId [" + orderId + "] ship group [" + shipGroupSeqId + "] Pack input [" + productId + "] @ [" + + quantity + "] packageSeq [" + packageSeq + "] weight [" + weight + "]", MODULE); if (weight == null) { - Debug.logWarning("OrderId [" + orderId + "] ship group [" + shipGroupSeqId + "] product [" + productId + "] being packed without a weight, assuming 0", MODULE); + Debug.logWarning("OrderId [" + orderId + "] ship group [" + shipGroupSeqId + "] product [" + productId + + "] being packed without a weight, assuming 0", MODULE); weight = BigDecimal.ZERO; } @@ -130,7 +132,8 @@ public class PackingServices { String qtyStr = qtyInfo.get(rowKey); String wgtStr = wgtInfo.get(rowKey); - Debug.logInfo("Item: " + orderItemSeqId + " / Product: " + prdStr + " / Quantity: " + qtyStr + " / Package: " + pkgStr + " / Weight: " + wgtStr, MODULE); + Debug.logInfo("Item: " + orderItemSeqId + " / Product: " + prdStr + " / Quantity: " + qtyStr + " / Package: " + + pkgStr + " / Weight: " + wgtStr, MODULE); // array place holders String[] quantities; @@ -142,7 +145,7 @@ public class PackingServices { // this is a multi-box update packages = pkgStr.split(","); } else { - packages = new String[] { pkgStr }; + packages = new String[] {pkgStr }; } // check to make sure there is at least one package @@ -162,12 +165,12 @@ public class PackingServices { "ProductPackBulkPackagesAndQuantitiesDoNotMatch", locale)); } } else { - quantities = new String[] { qtyStr }; + quantities = new String[] {qtyStr }; } // process the weight array if (UtilValidate.isEmpty(wgtStr)) wgtStr = "0"; - weights = new String[] { wgtStr }; + weights = new String[] {wgtStr }; for (int p = 0; p < packages.length; p++) { BigDecimal quantity; @@ -194,7 +197,8 @@ public class PackingServices { } } for (int numPackage = 0; numPackage < numPackages; numPackage++) { - session.addOrIncreaseLine(orderId, orderItemSeqId, shipGroupSeqId, prdStr, quantity, packageSeq + numPackage, weightSeq, updateQuantity); + session.addOrIncreaseLine(orderId, orderItemSeqId, shipGroupSeqId, prdStr, quantity, packageSeq + + numPackage, weightSeq, updateQuantity); } } catch (GeneralException e) { Debug.logError(e, MODULE); @@ -265,7 +269,8 @@ public class PackingServices { String productStoreId = (String) context.get("productStoreId"); BigDecimal shippableWeight = setSessionPackageWeights(session, packageWeights); - BigDecimal estimatedShipCost = session.getShipmentCostEstimate(shippingContactMechId, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId, productStoreId, null, null, shippableWeight, null); + BigDecimal estimatedShipCost = session.getShipmentCostEstimate(shippingContactMechId, shipmentMethodTypeId, carrierPartyId, + carrierRoleTypeId, productStoreId, null, null, shippableWeight, null); session.setAdditionalShippingCharge(estimatedShipCost); session.setWeightUomId(weightUomId); diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSessionLine.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSessionLine.java index d222809..07ce872 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSessionLine.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSessionLine.java @@ -51,7 +51,8 @@ public class PackingSessionLine implements java.io.Serializable { private String weightPackageSeqId = null; private int packageSeq = 0; - public PackingSessionLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, BigDecimal quantity, BigDecimal weight, int packageSeq) { + public PackingSessionLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, + BigDecimal quantity, BigDecimal weight, int packageSeq) { this.orderId = orderId; this.orderItemSeqId = orderItemSeqId; this.shipGroupSeqId = shipGroupSeqId; diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentEvents.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentEvents.java index ac94746..473ce19 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentEvents.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentEvents.java @@ -53,7 +53,8 @@ public class ShipmentEvents { GenericValue shipmentPackageRouteSeg = null; try { - shipmentPackageRouteSeg = EntityQuery.use(delegator).from("ShipmentPackageRouteSeg").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentPackageSeqId", shipmentPackageSeqId).queryOne(); + shipmentPackageRouteSeg = EntityQuery.use(delegator).from("ShipmentPackageRouteSeg").where("shipmentId", shipmentId, + "shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentPackageSeqId", shipmentPackageSeqId).queryOne(); } catch (GenericEntityException e) { String errorMsg = "Error looking up ShipmentPackageRouteSeg: " + e.toString(); Debug.logError(e, errorMsg, MODULE); @@ -62,17 +63,21 @@ public class ShipmentEvents { } if (shipmentPackageRouteSeg == null) { - request.setAttribute("_ERROR_MESSAGE_", "Could not find ShipmentPackageRouteSeg where shipmentId=[" + shipmentId + "], shipmentRouteSegmentId=[" + shipmentRouteSegmentId + "], shipmentPackageSeqId=[" + shipmentPackageSeqId + "]"); + request.setAttribute("_ERROR_MESSAGE_", "Could not find ShipmentPackageRouteSeg where shipmentId=[" + shipmentId + + "], shipmentRouteSegmentId=[" + shipmentRouteSegmentId + "], shipmentPackageSeqId=[" + shipmentPackageSeqId + "]"); return "error"; } byte[] bytes = shipmentPackageRouteSeg.getBytes("labelImage"); if (bytes == null || bytes.length == 0) { - request.setAttribute("_ERROR_MESSAGE_", "The ShipmentPackageRouteSeg was found where shipmentId=[" + shipmentId + "], shipmentRouteSegmentId=[" + shipmentRouteSegmentId + "], shipmentPackageSeqId=[" + shipmentPackageSeqId + "], but there was no labelImage on the value."); + request.setAttribute("_ERROR_MESSAGE_", "The ShipmentPackageRouteSeg was found where shipmentId=[" + shipmentId + + "], shipmentRouteSegmentId=[" + shipmentRouteSegmentId + "], shipmentPackageSeqId=[" + shipmentPackageSeqId + + "], but there was no labelImage on the value."); return "error"; } - // TODO: record the image format somehow to make this block nicer. Right now we're just trying GIF first as a default, then if it doesn't work, trying PNG. + // TODO: record the image format somehow to make this block nicer. Right now we're just trying GIF first as a default, + // then if it doesn't work, trying PNG. // It would be nice to store the actual type of the image alongside the image data. try { UtilHttp.streamContentToBrowser(response, bytes, "image/gif"); 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 fa3456f..cc752ee 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 @@ -73,7 +73,8 @@ public class ShipmentServices { GenericValue productStoreShipMeth = null; try { - productStoreShipMeth = EntityQuery.use(delegator).from("ProductStoreShipmentMeth").where("productStoreShipMethId", productStoreShipMethId).queryOne(); + productStoreShipMeth = EntityQuery.use(delegator).from("ProductStoreShipmentMeth").where("productStoreShipMethId", + productStoreShipMethId).queryOne(); } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ProductStoreShipmentMethodCannotRetrieve", @@ -158,8 +159,8 @@ public class ShipmentServices { return ServiceUtil.returnSuccess(); } - private static boolean applyQuantityBreak(Map<String, ? extends Object> context, Map<String, Object> result, List<GenericValue> storeAll, Delegator delegator, - GenericValue estimate, String prefix, String breakType, String breakTypeString) { + private static boolean applyQuantityBreak(Map<String, ? extends Object> context, Map<String, Object> result, List<GenericValue> storeAll, + Delegator delegator, GenericValue estimate, String prefix, String breakType, String breakTypeString) { BigDecimal min = (BigDecimal) context.get(prefix + "min"); BigDecimal max = (BigDecimal) context.get(prefix + "max"); if (min != null || max != null) { @@ -187,10 +188,9 @@ public class ShipmentServices { + " must not be less than Min " + breakTypeString + "."); return false; } - } - else { + } else { result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); - result.put(ModelService.ERROR_MESSAGE, breakTypeString+" Span Requires BOTH Fields."); + result.put(ModelService.ERROR_MESSAGE, breakTypeString + " Span Requires BOTH Fields."); return false; } } @@ -238,7 +238,8 @@ public class ShipmentServices { if (UtilValidate.isNotEmpty(productStoreShipMethId)) { // if the productStoreShipMethId field is passed, then also get estimates that have the field set - List<EntityCondition> condList = UtilMisc.toList(EntityCondition.makeCondition("productStoreShipMethId", EntityOperator.EQUALS, productStoreShipMethId), estFieldsCond); + List<EntityCondition> condList = UtilMisc.toList(EntityCondition.makeCondition("productStoreShipMethId", + EntityOperator.EQUALS, productStoreShipMethId), estFieldsCond); estFieldsCond = EntityCondition.makeCondition(condList, EntityOperator.AND); } @@ -255,7 +256,8 @@ public class ShipmentServices { } if (estimates == null || estimates.size() < 1) { if (initialEstimateAmt.compareTo(BigDecimal.ZERO) == 0) { - Debug.logWarning("No shipping estimates found; the shipping amount returned is 0! Condition used was: " + estFieldsCond + "; Using the passed context: " + context, MODULE); + Debug.logWarning("No shipping estimates found; the shipping amount returned is 0! Condition used was: " + + estFieldsCond + "; Using the passed context: " + context, MODULE); } Map<String, Object> respNow = ServiceUtil.returnSuccess(); @@ -336,7 +338,8 @@ public class ShipmentServices { BigDecimal max = BigDecimal.ONE.movePointLeft(4); min = qv.getBigDecimal("fromQuantity"); max = qv.getBigDecimal("thruQuantity"); - if (shippableQuantity.compareTo(min) >= 0 && (max.compareTo(BigDecimal.ZERO) == 0 || shippableQuantity.compareTo(max) <= 0)) { + if (shippableQuantity.compareTo(min) >= 0 && (max.compareTo(BigDecimal.ZERO) == 0 + || shippableQuantity.compareTo(max) <= 0)) { qtyValid = true; } } @@ -679,7 +682,8 @@ public class ShipmentServices { String shipmentId = pkgInfo.getString("shipmentId"); // locate the shipment package - GenericValue shipmentPackage = EntityQuery.use(delegator).from("ShipmentPackage").where("shipmentId", shipmentId, "shipmentPackageSeqId", packageSeqId).queryOne(); + GenericValue shipmentPackage = EntityQuery.use(delegator).from("ShipmentPackage").where("shipmentId", shipmentId, + "shipmentPackageSeqId", packageSeqId).queryOne(); if (shipmentPackage != null) { if ("00001".equals(packageSeqId)) { // only need to do this for the first package @@ -741,7 +745,7 @@ public class ShipmentServices { pkgRtSeg.set("trackingCode", pkgInfo.get("trackingNumber")); pkgRtSeg.set("boxNumber", pkgInfo.get("shipmentPackageSeqId")); pkgRtSeg.set("packageServiceCost", pkgInfo.get("packageTotal")); - delegator.store(pkgRtSeg); + delegator.store(pkgRtSeg); shipmentMap.put(shipmentId, pkgInfo.getString("voidIndicator")); } } @@ -776,7 +780,8 @@ public class ShipmentServices { // remove the shipment info Map<String, Object> clearResp = null; try { - clearResp = dispatcher.runSync("clearShipmentStaging", UtilMisc.<String, Object>toMap("shipmentId", shipmentId, "userLogin", userLogin)); + clearResp = dispatcher.runSync("clearShipmentStaging", UtilMisc.<String, Object>toMap("shipmentId", shipmentId, + "userLogin", userLogin)); } catch (GenericServiceException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(e.getMessage()); @@ -820,16 +825,19 @@ public class ShipmentServices { List<GenericValue> shipmentReceipts = EntityQuery.use(delegator).from("ShipmentReceipt").where("shipmentId", shipmentId).queryList(); if (shipmentReceipts.isEmpty()) return ServiceUtil.returnSuccess(); - // If there are shipment receipts, the shipment must have been shipped, so set the shipment status to PURCH_SHIP_SHIPPED if it's only PURCH_SHIP_CREATED + // If there are shipment receipts, the shipment must have been shipped, so set the shipment status to + // PURCH_SHIP_SHIPPED if it's only PURCH_SHIP_CREATED GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); if ((!UtilValidate.isEmpty(shipment)) && "PURCH_SHIP_CREATED".equals(shipment.getString("statusId"))) { - Map<String, Object> updateShipmentMap = dispatcher.runSync("updateShipment", UtilMisc.<String, Object>toMap("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED", "userLogin", userLogin)); + Map<String, Object> updateShipmentMap = dispatcher.runSync("updateShipment", + UtilMisc.<String, Object>toMap("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED", "userLogin", userLogin)); if (ServiceUtil.isError(updateShipmentMap)) { return updateShipmentMap; } } - List<GenericValue> shipmentAndItems = EntityQuery.use(delegator).from("ShipmentAndItem").where("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED").queryList(); + List<GenericValue> shipmentAndItems = EntityQuery.use(delegator).from("ShipmentAndItem").where("shipmentId", + shipmentId, "statusId", "PURCH_SHIP_SHIPPED").queryList(); if (shipmentAndItems.isEmpty()) { return ServiceUtil.returnSuccess(); } @@ -858,7 +866,8 @@ public class ShipmentServices { } // now update the shipment - Map<String, Object> serviceResult = dispatcher.runSync("updateShipment", UtilMisc.<String, Object>toMap("shipmentId", shipmentId, "statusId", "PURCH_SHIP_RECEIVED", "userLogin", userLogin)); + Map<String, Object> serviceResult = dispatcher.runSync("updateShipment", UtilMisc.<String, Object>toMap("shipmentId", + shipmentId, "statusId", "PURCH_SHIP_RECEIVED", "userLogin", userLogin)); if (ServiceUtil.isError(serviceResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult)); } @@ -880,7 +889,8 @@ public class ShipmentServices { Map<String, Object> results = ServiceUtil.returnSuccess(); try { - GenericValue shipmentRouteSeg = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); + GenericValue shipmentRouteSeg = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, + "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (shipmentRouteSeg == null) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ProductShipmentRouteSegmentNotFound", @@ -888,8 +898,10 @@ public class ShipmentServices { "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } - Map<String, Object> params = UtilMisc.<String, Object>toMap("shipmentId", shipmentId, "carrierPartyId", shipmentRouteSeg.getString("carrierPartyId"), "shipmentMethodTypeId", shipmentRouteSeg.getString("shipmentMethodTypeId"), - "originFacilityId", shipmentRouteSeg.getString("originFacilityId"), "originContactMechId", shipmentRouteSeg.getString("originContactMechId"), + Map<String, Object> params = UtilMisc.<String, Object>toMap("shipmentId", shipmentId, "carrierPartyId", + shipmentRouteSeg.getString("carrierPartyId"), "shipmentMethodTypeId", shipmentRouteSeg.getString("shipmentMethodTypeId"), + "originFacilityId", shipmentRouteSeg.getString("originFacilityId"), "originContactMechId", + shipmentRouteSeg.getString("originContactMechId"), "originTelecomNumberId", shipmentRouteSeg.getString("originTelecomNumberId")); params.put("destFacilityId", shipmentRouteSeg.getString("destFacilityId")); params.put("destContactMechId", shipmentRouteSeg.getString("destContactMechId")); @@ -900,7 +912,7 @@ public class ShipmentServices { Map<String, Object> tmpResult = dispatcher.runSync("createShipmentRouteSegment", params); if (ServiceUtil.isError(tmpResult)) { - return ServiceUtil.returnError(ServiceUtil.getErrorMessage(tmpResult)); + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(tmpResult)); } else { results.put("newShipmentRouteSegmentId", tmpResult.get("shipmentRouteSegmentId")); return results; @@ -937,7 +949,8 @@ public class ShipmentServices { // TODO: This may not need to be done asynchronously. The reason it's done that way right now is that calling it synchronously means that // if we can't confirm a single shipment, then all shipment route segments in a multi-form are rolled back. try { - Map<String, Object> input = UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId, "userLogin", userLogin); + Map<String, Object> input = UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId, + "userLogin", userLogin); // for DHL, we just need to confirm the shipment to get the label. Other carriers may have more elaborate requirements. if ("DHL".equals(carrierPartyId)) { dispatcher.runAsync("dhlShipmentConfirm", input); @@ -983,20 +996,23 @@ public class ShipmentServices { return ServiceUtil.returnError(errorMessage); } - shipmentPackage = EntityQuery.use(delegator).from("ShipmentPackage").where("shipmentId", shipmentId, "shipmentPackageSeqId", shipmentPackageSeqId).queryOne(); + shipmentPackage = EntityQuery.use(delegator).from("ShipmentPackage").where("shipmentId", shipmentId, "shipmentPackageSeqId", + shipmentPackageSeqId).queryOne(); if (UtilValidate.isEmpty(shipmentPackage)) { String errorMessage = UtilProperties.getMessage(RESOURCE, "ProductShipmentPackageNotFound", context, locale); Debug.logError(errorMessage, MODULE); return ServiceUtil.returnError(errorMessage); } - List<GenericValue> packageContents = EntityQuery.use(delegator).from("PackedQtyVsOrderItemQuantity").where("shipmentId", shipmentId, "shipmentPackageSeqId", shipmentPackageSeqId).queryList(); + List<GenericValue> packageContents = EntityQuery.use(delegator).from("PackedQtyVsOrderItemQuantity").where("shipmentId", shipmentId, + "shipmentPackageSeqId", shipmentPackageSeqId).queryList(); for (GenericValue packageContent: packageContents) { String orderId = packageContent.getString("orderId"); String orderItemSeqId = packageContent.getString("orderItemSeqId"); // Get the value of the orderItem by calling the getOrderItemInvoicedAmountAndQuantity service - Map<String, Object> getOrderItemValueResult = dispatcher.runSync("getOrderItemInvoicedAmountAndQuantity", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "userLogin", userLogin, "locale", locale)); + Map<String, Object> getOrderItemValueResult = dispatcher.runSync("getOrderItemInvoicedAmountAndQuantity", + UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "userLogin", userLogin, "locale", locale)); if (ServiceUtil.isError(getOrderItemValueResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(getOrderItemValueResult)); } @@ -1005,14 +1021,16 @@ public class ShipmentServices { // How much of the invoiced quantity does the issued quantity represent? BigDecimal issuedQuantity = packageContent.getBigDecimal("issuedQuantity"); - BigDecimal proportionOfInvoicedQuantity = invoicedQuantity.signum() == 0 ? ZERO : issuedQuantity.divide(invoicedQuantity, 10, ROUNDING); + BigDecimal proportionOfInvoicedQuantity = invoicedQuantity.signum() == 0 ? ZERO : issuedQuantity.divide(invoicedQuantity, + 10, ROUNDING); // Prorate the orderItem's invoiced amount by that proportion BigDecimal packageContentValue = proportionOfInvoicedQuantity.multiply(invoicedAmount).setScale(DECIMALS, ROUNDING); // Convert the value to the shipment currency, if necessary GenericValue orderHeader = packageContent.getRelatedOne("OrderHeader", false); - Map<String, Object> convertUomResult = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", orderHeader.getString("currencyUom"), "uomIdTo", currencyUomId, "originalValue", packageContentValue)); + Map<String, Object> convertUomResult = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", + orderHeader.getString("currencyUom"), "uomIdTo", currencyUomId, "originalValue", packageContentValue)); if (ServiceUtil.isError(convertUomResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(convertUomResult)); } @@ -1053,9 +1071,11 @@ public class ShipmentServices { } GenericValue productStoreEmail = null; try { - productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", orderHeader.get("productStoreId"), "emailType", "PRDS_ODR_SHIP_COMPLT").queryOne(); + productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", + orderHeader.get("productStoreId"), "emailType", "PRDS_ODR_SHIP_COMPLT").queryOne(); } catch (GenericEntityException e) { - Debug.logError(e, "Problem getting the ProductStoreEmailSetting for productStoreId =" + orderHeader.get("productStoreId") + " and emailType = PRDS_ODR_SHIP_COMPLT", MODULE); + Debug.logError(e, "Problem getting the ProductStoreEmailSetting for productStoreId =" + orderHeader.get("productStoreId") + + " and emailType = PRDS_ODR_SHIP_COMPLT", MODULE); } if (productStoreEmail == null) { return ServiceUtil.returnFailure(UtilProperties.getMessage(RESOURCE, @@ -1089,7 +1109,8 @@ public class ShipmentServices { locale = Locale.getDefault(); } - Map<String, Object> bodyParameters = UtilMisc.<String, Object>toMap("partyId", partyId, "shipmentId", shipmentId, "orderId", shipment.getString("primaryOrderId"), "userLogin", userLogin, "locale", locale); + Map<String, Object> bodyParameters = UtilMisc.<String, Object>toMap("partyId", partyId, "shipmentId", shipmentId, "orderId", + shipment.getString("primaryOrderId"), "userLogin", userLogin, "locale", locale); sendMap.put("bodyParameters", bodyParameters); sendMap.put("userLogin", userLogin); @@ -1115,7 +1136,8 @@ public class ShipmentServices { // check for errors if (sendResp != null && ServiceUtil.isError(sendResp)) { sendResp.put("emailType", "PRDS_ODR_SHIP_COMPLT"); - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderProblemSendingEmail", localePar), null, null, sendResp); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderProblemSendingEmail", localePar), + null, null, sendResp); } return sendResp; } diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentWorker.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentWorker.java index d89d00c..1b855c6 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentWorker.java @@ -50,8 +50,10 @@ public final class ShipmentWorker { private ShipmentWorker() { } /* - * Returns the value of a given ShipmentPackageContent record. Calculated by working out the total value (from the OrderItems) of all ItemIssuances - * for the ShipmentItem then dividing that by the total quantity issued for the same to get an average item value then multiplying that by the package + * Returns the value of a given ShipmentPackageContent record. Calculated by working out the total value (from the OrderItems) of all + * ItemIssuances + * for the ShipmentItem then dividing that by the total quantity issued for the same to get an average item value then multiplying that by + * the package * content quantity. * Note: No rounding of the calculation is performed so you will need to round it to the accuracy that you require */ @@ -108,7 +110,8 @@ public final class ShipmentWorker { return value; } - public static List<Map<String, BigDecimal>> getPackageSplit(DispatchContext dctx, List<Map<String, Object>> shippableItemInfo, BigDecimal maxWeight) { + public static List<Map<String, BigDecimal>> getPackageSplit(DispatchContext dctx, List<Map<String, Object>> shippableItemInfo, + BigDecimal maxWeight) { // create the package list w/ the first package List<Map<String, BigDecimal>> packages = new LinkedList<>(); @@ -163,7 +166,8 @@ public final class ShipmentWorker { return packages; } - public static BigDecimal calcPackageWeight(DispatchContext dctx, Map<String, BigDecimal> packageMap, List<Map<String, Object>> shippableItemInfo, BigDecimal additionalWeight) { + public static BigDecimal calcPackageWeight(DispatchContext dctx, Map<String, BigDecimal> packageMap, List<Map<String, Object>> shippableItemInfo, + BigDecimal additionalWeight) { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); @@ -179,7 +183,8 @@ public final class ShipmentWorker { String weightUomId = (String) productInfo.get("weightUomId"); - Debug.logInfo("Product Id : " + productId + " Product Weight : " + String.valueOf(productWeight) + " Product UomId : " + weightUomId + " assuming " + defaultWeightUomId + " if null. Quantity : " + String.valueOf(quantity), MODULE); + Debug.logInfo("Product Id : " + productId + " Product Weight : " + String.valueOf(productWeight) + " Product UomId : " + + weightUomId + " assuming " + defaultWeightUomId + " if null. Quantity : " + String.valueOf(quantity), MODULE); if (UtilValidate.isEmpty(weightUomId)) { weightUomId = defaultWeightUomId; @@ -188,7 +193,8 @@ public final class ShipmentWorker { // attempt a conversion to pounds Map<String, Object> result = new HashMap<>(); try { - result = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", weightUomId, "uomIdTo", "WT_lb", "originalValue", productWeight)); + result = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", weightUomId, "uomIdTo", "WT_lb", + "originalValue", productWeight)); if (ServiceUtil.isError(result)) { Debug.logError(ServiceUtil.getErrorMessage(result), MODULE); return totalWeight; @@ -196,10 +202,12 @@ public final class ShipmentWorker { } catch (GenericServiceException ex) { Debug.logError(ex, MODULE); } - if (result.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_SUCCESS) && UtilValidate.isNotEmpty(result.get("convertedValue"))) { + if (result.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_SUCCESS) + && UtilValidate.isNotEmpty(result.get("convertedValue"))) { productWeight = (BigDecimal) result.get("convertedValue"); } else { - Debug.logError("Unsupported weightUom [" + weightUomId + "] for calcPackageWeight running productId " + productId + ", could not find a conversion factor to WT_lb", MODULE); + Debug.logError("Unsupported weightUom [" + weightUomId + "] for calcPackageWeight running productId " + + productId + ", could not find a conversion factor to WT_lb", MODULE); } } 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 5dff537..42b6a2c 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 @@ -142,7 +142,8 @@ public class UpsServices { } // add ShipmentRouteSegment carrierServiceStatusId, check before all UPS services - if (UtilValidate.isNotEmpty(shipmentRouteSegment.getString("carrierServiceStatusId")) && !"SHRSCS_NOT_STARTED".equals(shipmentRouteSegment.getString("carrierServiceStatusId"))) { + if (UtilValidate.isNotEmpty(shipmentRouteSegment.getString("carrierServiceStatusId")) + && !"SHRSCS_NOT_STARTED".equals(shipmentRouteSegment.getString("carrierServiceStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsRouteSegmentStatusNotStarted", UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId, "shipmentRouteSegmentStatus", shipmentRouteSegment.getString("carrierServiceStatusId")), locale)); @@ -161,7 +162,8 @@ public class UpsServices { } String originPhoneNumber = originTelecomNumber.getString("areaCode") + originTelecomNumber.getString("contactNumber"); // don't put on country code if not specified or is the US country code (UPS wants it this way) - if (UtilValidate.isNotEmpty(originTelecomNumber.getString("countryCode")) && !"001".equals(originTelecomNumber.getString("countryCode"))) { + if (UtilValidate.isNotEmpty(originTelecomNumber.getString("countryCode")) + && !"001".equals(originTelecomNumber.getString("countryCode"))) { originPhoneNumber = originTelecomNumber.getString("countryCode") + originPhoneNumber; } originPhoneNumber = StringUtil.replaceString(originPhoneNumber, "-", ""); @@ -191,7 +193,8 @@ public class UpsServices { if (destTelecomNumber != null) { destPhoneNumber = destTelecomNumber.getString("areaCode") + destTelecomNumber.getString("contactNumber"); // don't put on country code if not specified or is the US country code (UPS wants it this way) - if (UtilValidate.isNotEmpty(destTelecomNumber.getString("countryCode")) && !"001".equals(destTelecomNumber.getString("countryCode"))) { + if (UtilValidate.isNotEmpty(destTelecomNumber.getString("countryCode")) + && !"001".equals(destTelecomNumber.getString("countryCode"))) { destPhoneNumber = destTelecomNumber.getString("countryCode") + destPhoneNumber; } destPhoneNumber = StringUtil.replaceString(destPhoneNumber, "-", ""); @@ -277,8 +280,8 @@ public class UpsServices { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsSurchargeAmountIsNotConfigurated", locale)); } - codSurchargeCurrencyUomId = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "codSurchargeCurrencyUomId", resource - , "shipment.ups.cod.surcharge.currencyUomId", ""); + codSurchargeCurrencyUomId = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "codSurchargeCurrencyUomId", + resource, "shipment.ups.cod.surcharge.currencyUomId", ""); if (UtilValidate.isEmpty(codSurchargeCurrencyUomId)) { return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "FacilityShipmentUpsSurchargeCurrencyIsNotConfigurated", locale)); @@ -308,10 +311,12 @@ public class UpsServices { } if (UtilValidate.isEmpty(destTelecomNumber)) { - Debug.logInfo("Voice notification service will not be requested for COD shipmentId " + shipmentId + ", shipmentRouteSegmentId " + shipmentRouteSegmentId + " - missing destination phone number", MODULE); + Debug.logInfo("Voice notification service will not be requested for COD shipmentId " + shipmentId + ", shipmentRouteSegmentId " + + shipmentRouteSegmentId + " - missing destination phone number", MODULE); } if (UtilValidate.isEmpty(shipmentRouteSegment.get("homeDeliveryType"))) { - Debug.logInfo("Voice notification service will not be requested for COD shipmentId " + shipmentId + ", shipmentRouteSegmentId " + shipmentRouteSegmentId + " - destination address is not residential", MODULE); + Debug.logInfo("Voice notification service will not be requested for COD shipmentId " + shipmentId + ", shipmentRouteSegmentId " + + shipmentRouteSegmentId + " - destination address is not residential", MODULE); } } @@ -638,9 +643,9 @@ public class UpsServices { UtilXml.addChildElementValue(codAmountElement, "CurrencyCode", currencyCode, shipmentConfirmRequestDoc); // Get the value of the package by going back to the orderItems - Map<String, Object> getPackageValueResult = dispatcher.runSync("getShipmentPackageValueFromOrders", UtilMisc.toMap("shipmentId" - , shipmentId, "shipmentPackageSeqId", shipmentPackage.get("shipmentPackageSeqId"), "currencyUomId", currencyCode, "userLogin", - userLogin, "locale", locale)); + Map<String, Object> getPackageValueResult = dispatcher.runSync("getShipmentPackageValueFromOrders", UtilMisc.toMap("shipmentId", + shipmentId, "shipmentPackageSeqId", shipmentPackage.get("shipmentPackageSeqId"), "currencyUomId", currencyCode, + "userLogin", userLogin, "locale", locale)); if (ServiceUtil.isError(getPackageValueResult)) return getPackageValueResult; BigDecimal packageValue = (BigDecimal) getPackageValueResult.get("packageValue"); @@ -654,7 +659,8 @@ public class UpsServices { // Add the amount of the surcharge for the package, if the surcharge should be on all packages or the first and this is the // first package - if (codSurchargeApplyToAllPackages || codSurchargeSplitBetweenPackages || (codSurchargeApplyToFirstPackage && shipmentPackageRouteSegIter.previousIndex() <= 0)) { + if (codSurchargeApplyToAllPackages || codSurchargeSplitBetweenPackages || (codSurchargeApplyToFirstPackage + && shipmentPackageRouteSegIter.previousIndex() <= 0)) { packageValue = packageValue.add(codSurchargePackageAmount); } @@ -1024,7 +1030,8 @@ public class UpsServices { public static Map<String, Object> handleUpsShipmentAcceptResponse(Document shipmentAcceptResponseDocument, GenericValue shipmentRouteSegment, List<GenericValue> shipmentPackageRouteSegs, Delegator delegator, String shipmentGatewayConfigId, String resource, - Map<String, ? extends Object> context, Locale locale) throws GenericEntityException { + Map<String, ? extends Object> context, Locale locale) + throws GenericEntityException { boolean shipmentUpsSaveCertificationInfo = "true".equals(getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "saveCertInfo", resource, "shipment.ups.save.certification.info", "true")); String shipmentUpsSaveCertificationPath = FlexibleStringExpander.expandString(getShipmentGatewayConfigValue(delegator, @@ -1191,7 +1198,8 @@ public class UpsServices { fileOut.flush(); } catch (IOException e) { Debug.logInfo(e, - "Could not save UPS LabelImage GIF file: [[[" + packageLabelGraphicImageString + "]]] to file: " + outFileName, MODULE); + "Could not save UPS LabelImage GIF file: [[[" + packageLabelGraphicImageString + "]]] to file: " + + outFileName, MODULE); } } if (labelInternationalSignatureGraphicImageBytes != null) { @@ -1201,20 +1209,20 @@ 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) { String outFileName = shipmentUpsSaveCertificationPath + "/UpsShipmentLabelHTMLImage" + shipmentRouteSegment.getString( - "shipmentId") + "_" + shipmentRouteSegment.getString("shipmentRouteSegmentId") + "_" + shipmentPackageRouteSeg.getString("shipmentPackageSeqId") + ".html"; + "shipmentId") + "_" + shipmentRouteSegment.getString("shipmentRouteSegmentId") + "_" + + shipmentPackageRouteSeg.getString("shipmentPackageSeqId") + ".html"; try (FileOutputStream fileOut = new FileOutputStream(outFileName)) { fileOut.write(packageLabelHTMLImageStringDecoded.getBytes(StandardCharsets.UTF_8)); fileOut.flush(); } catch (IOException e) { - Debug.logInfo(e, - "Could not save UPS LabelImage HTML file: [[[" + packageLabelHTMLImageStringDecoded + "]]] to file: " + outFileName, - MODULE); + Debug.logInfo(e, "Could not save UPS LabelImage HTML file: [[[" + packageLabelHTMLImageStringDecoded + "]]] to file: " + + outFileName, MODULE); } } } @@ -1241,7 +1249,8 @@ public class UpsServices { shipmentRouteSegment.set("upsHighValueReport", fileStringDecoded); shipmentRouteSegment.store(); String outFileName = - shipmentUpsSaveCertificationPath + "/HighValueReport" + shipmentRouteSegment.getString("shipmentId") + "_" + shipmentRouteSegment.getString("shipmentRouteSegmentId") + ".html"; + shipmentUpsSaveCertificationPath + "/HighValueReport" + shipmentRouteSegment.getString("shipmentId") + + "_" + shipmentRouteSegment.getString("shipmentRouteSegmentId") + ".html"; try (FileOutputStream fileOut = new FileOutputStream(outFileName)) { fileOut.write(fileStringDecoded.getBytes(StandardCharsets.UTF_8)); fileOut.flush(); @@ -1618,7 +1627,7 @@ public class UpsServices { } public static Map<String, Object> handleUpsTrackShipmentResponse(Document trackResponseDocument, GenericValue shipmentRouteSegment, - List<GenericValue> shipmentPackageRouteSegs, Locale locale) throws GenericEntityException { + List<GenericValue> shipmentPackageRouteSegs, Locale locale) throws GenericEntityException { // process TrackResponse, update data as needed Element trackResponseElement = trackResponseDocument.getDocumentElement(); @@ -1796,7 +1805,8 @@ public class UpsServices { String productId = i.next(); Map<String, Object> productInfo = ShipmentWorker.getProductItemInfo(shippableItemInfo, productId); if (productInfo.get("inShippingBox") != null && "Y".equalsIgnoreCase((String) productInfo.get("inShippingBox")) - && productInfo.get("shippingDepth") != null && productInfo.get("shippingWidth") != null && productInfo.get("shippingHeight") != null) { + && productInfo.get("shippingDepth") != null && productInfo.get("shippingWidth") != null + && productInfo.get("shippingHeight") != null) { Element dimensionsElement = UtilXml.addChildElement(packageElement, "Dimensions", requestDoc); UtilXml.addChildElementValue(dimensionsElement, "Length", productInfo.get("shippingDepth").toString(), requestDoc); UtilXml.addChildElementValue(dimensionsElement, "Width", productInfo.get("shippingWidth").toString(), requestDoc); @@ -2405,7 +2415,8 @@ public class UpsServices { } String originPhoneNumber = originTelecomNumber.getString("areaCode") + originTelecomNumber.getString("contactNumber"); // don't put on country code if not specified or is the US country code (UPS wants it this way) - if (UtilValidate.isNotEmpty(originTelecomNumber.getString("countryCode")) && !"001".equals(originTelecomNumber.getString("countryCode"))) { + if (UtilValidate.isNotEmpty(originTelecomNumber.getString("countryCode")) + && !"001".equals(originTelecomNumber.getString("countryCode"))) { originPhoneNumber = originTelecomNumber.getString("countryCode") + originPhoneNumber; } originPhoneNumber = StringUtil.replaceString(originPhoneNumber, "-", ""); @@ -2434,7 +2445,8 @@ public class UpsServices { if (destTelecomNumber != null) { destPhoneNumber = destTelecomNumber.getString("areaCode") + destTelecomNumber.getString("contactNumber"); // don't put on country code if not specified or is the US country code (UPS wants it this way) - if (UtilValidate.isNotEmpty(destTelecomNumber.getString("countryCode")) && !"001".equals(destTelecomNumber.getString("countryCode"))) { + if (UtilValidate.isNotEmpty(destTelecomNumber.getString("countryCode")) + && !"001".equals(destTelecomNumber.getString("countryCode"))) { destPhoneNumber = destTelecomNumber.getString("countryCode") + destPhoneNumber; } destPhoneNumber = StringUtil.replaceString(destPhoneNumber, "-", ""); @@ -2469,8 +2481,8 @@ public class UpsServices { recipientEmail = (String) destEmail.get("emailAddress"); } String senderEmail = null; - Map<String, Object> originEmail = dispatcher.runSync("getPartyEmail", UtilMisc.toMap("partyId", shipment.get("partyIdFrom"), "userLogin" - , userLogin)); + Map<String, Object> originEmail = dispatcher.runSync("getPartyEmail", UtilMisc.toMap("partyId", shipment.get("partyIdFrom"), + "userLogin", userLogin)); if (ServiceUtil.isError(originEmail)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(originEmail)); } @@ -2823,7 +2835,8 @@ public class UpsServices { } String originPhoneNumber = originTelecomNumber.getString("areaCode") + originTelecomNumber.getString("contactNumber"); // don't put on country code if not specified or is the US country code (UPS wants it this way) - if (UtilValidate.isNotEmpty(originTelecomNumber.getString("countryCode")) && !"001".equals(originTelecomNumber.getString("countryCode"))) { + if (UtilValidate.isNotEmpty(originTelecomNumber.getString("countryCode")) + && !"001".equals(originTelecomNumber.getString("countryCode"))) { originPhoneNumber = originTelecomNumber.getString("countryCode") + originPhoneNumber; } originPhoneNumber = StringUtil.replaceString(originPhoneNumber, "-", ""); @@ -2853,7 +2866,8 @@ public class UpsServices { if (destTelecomNumber != null) { destPhoneNumber = destTelecomNumber.getString("areaCode") + destTelecomNumber.getString("contactNumber"); // don't put on country code if not specified or is the US country code (UPS wants it this way) - if (UtilValidate.isNotEmpty(destTelecomNumber.getString("countryCode")) && !"001".equals(destTelecomNumber.getString("countryCode"))) { + if (UtilValidate.isNotEmpty(destTelecomNumber.getString("countryCode")) + && !"001".equals(destTelecomNumber.getString("countryCode"))) { destPhoneNumber = destTelecomNumber.getString("countryCode") + destPhoneNumber; } destPhoneNumber = StringUtil.replaceString(destPhoneNumber, "-", ""); @@ -3107,7 +3121,8 @@ public class UpsServices { Map<String, Object> thisUpsRateCodeMap = new HashMap<>(); carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod") .where("shipmentMethodTypeId", productStoreShipmentMethod.getString("shipmentMethodTypeId"), "partyId", - productStoreShipmentMethod.getString("partyId"), "roleTypeId", productStoreShipmentMethod.getString("roleTypeId")) + productStoreShipmentMethod.getString("partyId"), "roleTypeId", + productStoreShipmentMethod.getString("roleTypeId")) .queryOne(); String serviceCode = carrierShipmentMethod.getString("carrierServiceCode"); for (String thisServiceCode : upsRateCodeMap.keySet()) { diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageServices.java index dc06a39..e647936 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageServices.java @@ -49,11 +49,16 @@ public class WeightPackageServices { String shipmentBoxTypeId = (String) context.get("shipmentBoxTypeId"); // User can either enter all the dimensions or shipment box type, but not both - if (UtilValidate.isNotEmpty(packageLength) || UtilValidate.isNotEmpty(packageWidth) || UtilValidate.isNotEmpty(packageHeight)) { // Check if user entered any dimensions + if (UtilValidate.isNotEmpty(packageLength) || UtilValidate.isNotEmpty(packageWidth) || UtilValidate.isNotEmpty(packageHeight)) { + // Check if user entered any dimensions if (UtilValidate.isNotEmpty(shipmentBoxTypeId)) { // check also if user entered shipment box type - return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorEnteredBothDimensionAndPackageInputBoxField", locale)); - } else if (!(UtilValidate.isNotEmpty(packageLength) && UtilValidate.isNotEmpty(packageWidth) && UtilValidate.isNotEmpty(packageHeight))) { // check if user does not enter all the dimensions - return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNotEnteredAllFieldsInDimension", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", + "ProductErrorEnteredBothDimensionAndPackageInputBoxField", locale)); + } else if (!(UtilValidate.isNotEmpty(packageLength) && UtilValidate.isNotEmpty(packageWidth) + && UtilValidate.isNotEmpty(packageHeight))) { + // check if user does not enter all the dimensions + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", + "ProductErrorNotEnteredAllFieldsInDimension", locale)); } } // Check package weight, it must be greater than ZERO @@ -62,7 +67,8 @@ public class WeightPackageServices { } try { // Checked no of packages, it should not be greater than ordered quantity - List<GenericValue> orderItems = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId, "statusId", "ITEM_APPROVED").queryList(); + List<GenericValue> orderItems = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId, + "statusId", "ITEM_APPROVED").queryList(); BigDecimal orderedItemQty = BigDecimal.ZERO; for (GenericValue orderItem : orderItems) { orderedItemQty = orderedItemQty.add(orderItem.getBigDecimal("quantity")); @@ -71,7 +77,8 @@ public class WeightPackageServices { if ((orderedItemQty.intValue() - packageQuantity) > 0) { weightPackageSession.createWeightPackageLine(orderId, packageWeight, packageLength, packageWidth, packageHeight, shipmentBoxTypeId); } else { - return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNumberOfPackageCannotBeGreaterThanTheNumberOfOrderedQuantity", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", + "ProductErrorNumberOfPackageCannotBeGreaterThanTheNumberOfOrderedQuantity", locale)); } } catch (GeneralException e) { return ServiceUtil.returnError(e.getMessage()); @@ -91,19 +98,24 @@ public class WeightPackageServices { Integer weightPackageSeqId = (Integer) context.get("weightPackageSeqId"); // User can either enter all the dimensions or shipment box type, but not both - if (UtilValidate.isNotEmpty(packageLength) || UtilValidate.isNotEmpty(packageWidth) || UtilValidate.isNotEmpty(packageHeight)) { // Check if user entered any dimensions + if (UtilValidate.isNotEmpty(packageLength) || UtilValidate.isNotEmpty(packageWidth) || UtilValidate.isNotEmpty(packageHeight)) { + // Check if user entered any dimensions if (UtilValidate.isNotEmpty(shipmentBoxTypeId)) { // check also if user entered shipment box type weightPackageSession.setDimensionAndShipmentBoxType(weightPackageSeqId); - return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorEnteredBothDimensionAndPackageInputBoxField", locale)); - } else if (!(UtilValidate.isNotEmpty(packageLength) && UtilValidate.isNotEmpty(packageWidth) && UtilValidate.isNotEmpty(packageHeight))) { // check if user does not enter all the dimensions + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", + "ProductErrorEnteredBothDimensionAndPackageInputBoxField", locale)); + } else if (!(UtilValidate.isNotEmpty(packageLength) && UtilValidate.isNotEmpty(packageWidth) + && UtilValidate.isNotEmpty(packageHeight))) { // check if user does not enter all the dimensions weightPackageSession.setDimensionAndShipmentBoxType(weightPackageSeqId); - return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNotEnteredAllFieldsInDimension", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", + "ProductErrorNotEnteredAllFieldsInDimension", locale)); } } // Check package weight, it must be greater than ZERO if (UtilValidate.isEmpty(packageWeight) || packageWeight.compareTo(BigDecimal.ZERO) <= 0) { - return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorPackageWeightCannotBeNullOrZero", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", + "ProductErrorPackageWeightCannotBeNullOrZero", locale)); } weightPackageSession.setPackageWeight(packageWeight, weightPackageSeqId); @@ -156,7 +168,8 @@ public class WeightPackageServices { } else if ("success".equals(result)) { response.put("shipmentId", shipmentId); } else { - response = ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoItemsCurrentlySetToBeShippedCannotComplete", locale)); + response = ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", + "ProductErrorNoItemsCurrentlySetToBeShippedCannotComplete", locale)); } } catch (GeneralException e) { return ServiceUtil.returnError(e.getMessage(), e.getMessageList()); @@ -178,7 +191,8 @@ public class WeightPackageServices { if (weightPackageSession.completeShipment(orderId, getActualShippingQuoteFromUps)) { response.put("shipmentId", shipmentId); } else { - response = ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorNoItemsCurrentlySetToBeShippedCannotComplete", locale)); + response = ServiceUtil.returnError(UtilProperties.getMessage("ProductErrorUiLabels", + "ProductErrorNoItemsCurrentlySetToBeShippedCannotComplete", locale)); } } catch (GeneralException e) { return ServiceUtil.returnError(e.getMessage(), e.getMessageList()); 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 b4304a2..e0a5a28 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 @@ -64,8 +64,8 @@ public final class ICalWorker { private ICalWorker() { } public static final class ResponseProperties { - public final int statusCode; - public final String statusMessage; + private final int statusCode; + private final String statusMessage; public ResponseProperties(int statusCode, String statusMessage) { this.statusCode = statusCode; this.statusMessage = statusMessage; @@ -182,7 +182,8 @@ public final class ICalWorker { } if ("getlastmodified".equals(propElement.getNodeName())) { Date lastModified = getLastModifiedDate(request); - Element lmElement = helper.createElementSetValue("D:getlastmodified", WebDavUtil.formatDate(WebDavUtil.getRFC1123DateFormat(), lastModified)); + Element lmElement = helper.createElementSetValue("D:getlastmodified", + WebDavUtil.formatDate(WebDavUtil.getRFC1123DateFormat(), lastModified)); supportedProps.add(lmElement); continue; } @@ -305,7 +306,8 @@ public final class ICalWorker { } } - private static void writeResponse(ResponseProperties responseProps, HttpServletRequest request, HttpServletResponse response, ServletContext context) throws IOException { + 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); diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java index c2436e0..f612930 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortKeywordIndex.java @@ -73,7 +73,8 @@ public class WorkEffortKeywordIndex { addWeightedKeywordSourceString(workEffort, "currentStatusId", strings); if (!"0".equals(EntityUtilProperties.getPropertyValue("workeffort", "index.weight.WorkEffortNoteAndData.noteInfo", "1", delegator))) { - List<GenericValue> workEffortNotes = EntityQuery.use(delegator).from("WorkEffortNoteAndData").where("workEffortId", workEffortId).queryList(); + List<GenericValue> workEffortNotes = EntityQuery.use(delegator).from("WorkEffortNoteAndData") + .where("workEffortId", workEffortId).queryList(); for (GenericValue workEffortNote : workEffortNotes) { addWeightedKeywordSourceString(workEffortNote, "noteInfo", strings); } @@ -81,7 +82,8 @@ public class WorkEffortKeywordIndex { //WorkEffortAttribute if (!"0".equals(EntityUtilProperties.getPropertyValue("workeffort", "index.weight.WorkEffortAttribute.attrName", "1", delegator)) || !"0".equals(EntityUtilProperties.getPropertyValue("workeffort", "index.weight.WorkEffortAttribute.attrValue", "1", delegator))) { - List<GenericValue> workEffortAttributes = EntityQuery.use(delegator).from("WorkEffortAttribute").where("workEffortId", workEffortId).queryList(); + List<GenericValue> workEffortAttributes = EntityQuery.use(delegator).from("WorkEffortAttribute") + .where("workEffortId", workEffortId).queryList(); for (GenericValue workEffortAttribute : workEffortAttributes) { addWeightedKeywordSourceString(workEffortAttribute, "attrName", strings); addWeightedKeywordSourceString(workEffortAttribute, "attrValue", strings); @@ -97,10 +99,12 @@ public class WorkEffortKeywordIndex { Debug.logWarning("Could not parse weight number: " + e.toString(), MODULE); } - List<GenericValue> workEffortContentAndInfos = EntityQuery.use(delegator).from("WorkEffortContentAndInfo").where("workEffortId", workEffortId, "workEffortContentTypeId", workEffortContentTypeId).queryList(); + List<GenericValue> workEffortContentAndInfos = EntityQuery.use(delegator).from("WorkEffortContentAndInfo").where("workEffortId", + workEffortId, "workEffortContentTypeId", workEffortContentTypeId).queryList(); for (GenericValue workEffortContentAndInfo: workEffortContentAndInfos) { addWeightedDataResourceString(workEffortContentAndInfo, weight, strings, delegator, workEffort); - List<GenericValue> alternateViews = workEffortContentAndInfo.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"), false); + List<GenericValue> alternateViews = workEffortContentAndInfo.getRelated("ContentAssocDataResourceViewTo", + UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"), false); alternateViews = EntityUtil.filterByDate(alternateViews, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true); for (GenericValue thisView: alternateViews) { addWeightedDataResourceString(thisView, weight, strings, delegator, workEffort); @@ -115,23 +119,27 @@ public class WorkEffortKeywordIndex { List<GenericValue> toBeStored = new LinkedList<>(); for (Map.Entry<String, Long> entry: keywords.entrySet()) { if (entry.getKey().length() < 60) { // ignore very long strings, cannot be stored anyway - GenericValue workEffortKeyword = delegator.makeValue("WorkEffortKeyword", UtilMisc.toMap("workEffortId", workEffort.getString("workEffortId"), "keyword", entry.getKey(), "relevancyWeight", entry.getValue())); + GenericValue workEffortKeyword = delegator.makeValue("WorkEffortKeyword", UtilMisc.toMap("workEffortId", + workEffort.getString("workEffortId"), "keyword", entry.getKey(), "relevancyWeight", entry.getValue())); toBeStored.add(workEffortKeyword); } } if (!toBeStored.isEmpty()) { if (Debug.verboseOn()) { - Debug.logVerbose("WorkEffortKeywordIndex indexKeywords Storing " + toBeStored.size() + " keywords for workEffortId " + workEffort.getString("workEffortId"), MODULE); + Debug.logVerbose("WorkEffortKeywordIndex indexKeywords Storing " + toBeStored.size() + " keywords for workEffortId " + + workEffort.getString("workEffortId"), MODULE); } delegator.storeAll(toBeStored); } } - public static void addWeightedDataResourceString(GenericValue dataResource, int weight, List<String> strings, Delegator delegator, GenericValue workEffort) { + public static void addWeightedDataResourceString(GenericValue dataResource, int weight, List<String> strings, Delegator delegator, + GenericValue workEffort) { Map<String, Object> workEffortCtx = UtilMisc.<String, Object>toMap("workEffort", workEffort); try { - String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, dataResource.getString("dataResourceId"), workEffortCtx, null, null, false); + String contentText = DataResourceWorker.renderDataResourceAsText(null, delegator, dataResource.getString("dataResourceId"), + workEffortCtx, null, null, false); for (int i = 0; i < weight; i++) { strings.add(contentText); } diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortWorker.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortWorker.java index bb3505e..2251140 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortWorker.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortWorker.java @@ -43,7 +43,8 @@ public final class WorkEffortWorker { return getLowestLevelWorkEfforts(delegator, workEffortId, workEffortAssocTypeId, "workEffortIdFrom", "workEffortIdTo"); } - public static List<GenericValue> getLowestLevelWorkEfforts(Delegator delegator, String workEffortId, String workEffortAssocTypeId, String left, String right) { + public static List<GenericValue> getLowestLevelWorkEfforts(Delegator delegator, String workEffortId, String workEffortAssocTypeId, + String left, String right) { if (left == null) { left = "workEffortIdFrom"; } @@ -53,13 +54,16 @@ public final class WorkEffortWorker { List<GenericValue> workEfforts = new LinkedList<>(); try { - List<GenericValue> childWEAssocsLevelFirst = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, workEffortId, "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList(); + List<GenericValue> childWEAssocsLevelFirst = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, workEffortId, + "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList(); for (GenericValue childWEAssocLevelFirst : childWEAssocsLevelFirst) { - List<GenericValue> childWEAssocsLevelNext = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, childWEAssocLevelFirst.get(right), "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList(); + List<GenericValue> childWEAssocsLevelNext = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, + childWEAssocLevelFirst.get(right), "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList(); while (UtilValidate.isNotEmpty(childWEAssocsLevelNext)) { List<GenericValue> tempWorkEffortList = new LinkedList<>(); for (GenericValue childWEAssocLevelNext : childWEAssocsLevelNext) { - List<GenericValue> childWEAssocsLevelNth = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, childWEAssocLevelNext.get(right), "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList(); + List<GenericValue> childWEAssocsLevelNth = EntityQuery.use(delegator).from("WorkEffortAssoc").where(left, + childWEAssocLevelNext.get(right), "workEffortAssocTypeId", workEffortAssocTypeId).cache(true).queryList(); if (UtilValidate.isNotEmpty(childWEAssocsLevelNth)) { tempWorkEffortList.addAll(childWEAssocsLevelNth); } |
Free forum by Nabble | Edit this page |