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 d74742d Improved: Make data members of class as private and added accessor methods for the same, also corrected occurences of the same in applications component. (OFBIZ-11963) Also made some related checkstyle code enhancements. Thanks jacques for finalizing Javadoc pattern during this effort. d74742d is described below commit d74742d730a25cc9a77a6138e63677336acd73d1 Author: Suraj Khurana <[hidden email]> AuthorDate: Sat Aug 22 13:00:17 2020 +0530 Improved: Make data members of class as private and added accessor methods for the same, also corrected occurences of the same in applications component. (OFBIZ-11963) Also made some related checkstyle code enhancements. Thanks jacques for finalizing Javadoc pattern during this effort. --- .../accounting/payment/PaymentGatewayServices.java | 12 +- .../thirdparty/clearcommerce/CCServicesTest.java | 24 +- .../accounting/thirdparty/gosoftware/RitaApi.java | 44 +- .../thirdparty/valuelink/ValueLinkApi.java | 76 ++- .../thirdparty/valuelink/ValueLinkServices.java | 12 +- .../ofbiz/content/content/ContentMapFacade.java | 28 +- .../ofbiz/content/content/ContentSearch.java | 120 +++-- .../content/content/ContentSearchSession.java | 41 +- .../ofbiz/content/content/ContentWorker.java | 163 ++++--- .../ofbiz/content/content/PermissionRecorder.java | 176 +++++-- .../apache/ofbiz/content/survey/SurveyWrapper.java | 114 ++++- .../apache/ofbiz/manufacturing/bom/BOMNode.java | 95 +++- .../manufacturing/jobshopmgt/ProductionRun.java | 75 +-- .../ofbiz/marketing/report/ReportHelper.java | 3 +- .../ofbiz/order/order/OrderContentWrapper.java | 49 +- .../apache/ofbiz/order/order/OrderListState.java | 122 ++++- .../apache/ofbiz/order/order/OrderServices.java | 25 +- .../ofbiz/order/shoppingcart/ShoppingCart.java | 537 ++++++++++++++++++--- .../order/shoppingcart/ShoppingCartHelper.java | 159 ++++-- .../shoppingcart/product/ProductPromoWorker.java | 16 +- .../org/apache/ofbiz/order/task/TaskWorker.java | 23 +- .../apache/ofbiz/order/test/OrderTestServices.java | 3 +- .../ofbiz/party/contact/ContactMechServices.java | 2 +- .../ofbiz/party/content/PartyContentWrapper.java | 53 +- .../apache/ofbiz/party/party/PartyServices.java | 42 +- .../config/ProductConfigItemContentWrapper.java | 75 ++- .../ofbiz/product/config/ProductConfigWorker.java | 67 +-- .../ofbiz/product/config/ProductConfigWrapper.java | 210 ++++++-- .../product/product/ProductContentWrapper.java | 55 ++- .../product/ProductPromoContentWrapper.java | 50 +- .../ofbiz/product/product/ProductSearch.java | 82 ++-- .../product/product/ProductSearchSession.java | 6 - .../ofbiz/product/product/ProductServices.java | 8 +- .../ofbiz/product/product/ProductWorker.java | 2 +- .../product/store/ProductStoreSurveyWrapper.java | 36 +- .../product/subscription/SubscriptionServices.java | 2 +- .../ofbiz/shipment/packing/PackingSession.java | 14 +- .../ofbiz/shipment/packing/PackingSessionLine.java | 148 +++++- .../apache/ofbiz/shipment/test/IssuanceTest.java | 4 +- .../ofbiz/shipment/verify/VerifyPickSession.java | 66 ++- .../weightPackage/WeightPackageSession.java | 167 +++++-- .../weightPackage/WeightPackageSessionLine.java | 98 +++- .../content/WorkEffortContentWrapper.java | 99 +++- .../ofbiz/workeffort/workeffort/ICalConverter.java | 16 +- .../workeffort/workeffort/ICalRecurConverter.java | 37 +- .../workeffort/workeffort/WorkEffortSearch.java | 182 ++++--- .../workeffort/WorkEffortSearchSession.java | 31 +- 47 files changed, 2587 insertions(+), 882 deletions(-) diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java index 8126447..6c8fcc7 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java @@ -981,7 +981,7 @@ public class PaymentGatewayServices { releaseResult.put("orderPaymentPreference", paymentPref); releaseResult.put("userLogin", userLogin); Map<String, Object> resCtx = model.makeValid(releaseResult, ModelService.IN_PARAM); - releaseResRes = dispatcher.runSync(model.name, resCtx); + releaseResRes = dispatcher.runSync(model.getName(), resCtx); } catch (GenericServiceException e) { Debug.logError(e, "Trouble processing the release results", MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER, @@ -1815,12 +1815,12 @@ public class PaymentGatewayServices { Map<String, Object> context = model.makeValid(result, ModelService.IN_PARAM); // in case we rollback make sure this service gets called - dispatcher.addRollbackService(model.name, context, true); + dispatcher.addRollbackService(model.getName(), context, true); // invoke the service Map<String, Object> resResp; try { - resResp = dispatcher.runSync(model.name, context); + resResp = dispatcher.runSync(model.getName(), context); } catch (GenericServiceException e) { Debug.logError(e, MODULE); throw e; @@ -2455,7 +2455,7 @@ public class PaymentGatewayServices { if (actualRefundAmount != null && actualRefundAmount.compareTo(processAmount) != 0) { refundResCtx.put("refundAmount", refundResponse.get("refundAmount")); } - refundResRes = dispatcher.runSync(model.name, refundResCtx); + refundResRes = dispatcher.runSync(model.getName(), refundResCtx); if (ServiceUtil.isError(refundResRes)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(refundResRes)); } @@ -3211,7 +3211,7 @@ public class PaymentGatewayServices { response.put("orderPaymentPreference", paymentPref); response.put("userLogin", userLogin); Map<String, Object> resCtx = model.makeValid(response, ModelService.IN_PARAM); - responseRes = dispatcher.runSync(model.name, resCtx); + responseRes = dispatcher.runSync(model.getName(), resCtx); } catch (GenericServiceException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, @@ -3512,7 +3512,7 @@ public class PaymentGatewayServices { /** * Fail/bad expire date when year is even processor */ - public static Map<String, Object>badExpireEvenProcessor(DispatchContext dctx, Map<String, ? extends Object> context) { + public static Map<String, Object> badExpireEvenProcessor(DispatchContext dctx, Map<String, ? extends Object> context) { GenericValue creditCard = (GenericValue) context.get("creditCard"); String expireDate = creditCard.getString("expireDate"); String lastNumberStr = expireDate.substring(expireDate.length() - 1); diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java index caf1f00..49f283f 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java @@ -36,14 +36,14 @@ public class CCServicesTest extends OFBizTestCase { private static final String MODULE = CCServicesTest.class.getName(); // test data - protected GenericValue emailAddr = null; - protected String orderId = null; - protected GenericValue creditCard = null; - protected GenericValue billingAddress = null; - protected GenericValue shippingAddress = null; - protected Map<String, Object> pbOrder = null; - protected BigDecimal creditAmount = null; - protected String configFile = null; + private GenericValue emailAddr = null; + private String orderId = null; + private GenericValue creditCard = null; + private GenericValue billingAddress = null; + private GenericValue shippingAddress = null; + private Map<String, Object> pbOrder = null; + private BigDecimal creditAmount = null; + private String configFile = null; public CCServicesTest(String name) { super(name); @@ -75,7 +75,7 @@ public class CCServicesTest extends OFBizTestCase { "TotalNumberPayments", "4"); } - /* + /** * Check the authorisation */ public void testAuth() throws Exception { @@ -109,7 +109,7 @@ public class CCServicesTest extends OFBizTestCase { } - /* + /** * Check the credit action: to deduct a certain amount of a credit card. */ public void testCredit() throws Exception { @@ -140,7 +140,7 @@ public class CCServicesTest extends OFBizTestCase { } - /* + /** * Test Purchase subscription */ public void testPurchaseSubscription() throws Exception { @@ -196,7 +196,7 @@ public class CCServicesTest extends OFBizTestCase { */ } - /* + /** * Test Query subscription transaction status */ public void testCCReport() throws Exception { diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java index 9f953e6..6ba7fb3 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/gosoftware/RitaApi.java @@ -31,9 +31,9 @@ import org.apache.ofbiz.base.util.ObjectType; public class RitaApi { private static final String MODULE = RitaApi.class.getName(); - public static final String xschema = "x-schema:..\\dtd\\stnd.xdr"; - public static final String rootElement = "XML_FILE"; - public static final String reqElement = "XML_REQUEST"; + public static final String XSCHEMA = "x-schema:..\\dtd\\stnd.xdr"; + public static final String ROOT_ELEMENT = "XML_FILE"; + public static final String REQ_ELEMENT = "XML_REQUEST"; // request fields public static final String FUNCTION_TYPE = "FUNCTION_TYPE"; @@ -76,11 +76,11 @@ public class RitaApi { public static final String ORIG_TRANS_AMOUNT = "ORIG_TRANS_AMOUNT"; // IN/OUT validation array - private static final String[] validOut = {TERMINATION_STATUS, INTRN_SEQ_NUM, RESULT, RESULT_CODE, RESPONSE_TEXT, + private static final String[] VALID_OUT = {TERMINATION_STATUS, INTRN_SEQ_NUM, RESULT, RESULT_CODE, RESPONSE_TEXT, AUTH_CODE, AVS_CODE, CVV2_CODE, REFERENCE, TRANS_DATE, TRANS_TIME, ORIG_TRANS_AMOUNT }; - private static final String[] validIn = {FUNCTION_TYPE, PAYMENT_TYPE, USER_ID, USER_PW, COMMAND, CLIENT_ID, + private static final String[] VALID_IN = {FUNCTION_TYPE, PAYMENT_TYPE, USER_ID, USER_PW, COMMAND, CLIENT_ID, ACCT_NUM, EXP_MONTH, EXP_YEAR, TRANS_AMOUNT, CARDHOLDER, TRACK_DATA, INVOICE, PRESENT_FLAG, CUSTOMER_STREET, CUSTOMER_ZIP, CVV2, TAX_AMOUNT, PURCHASE_ID, FORCE_FLAG, ORIG_TRANS_AMOUNT, ORIG_SEQ_NUM }; @@ -90,11 +90,11 @@ public class RitaApi { protected static final int MODE_IN = 10; // instance variables - protected Map<String, String> document = null; - protected String host = null; - protected boolean ssl = false; - protected int port = 0; - protected int mode = 0; + private Map<String, String> document = null; + private String host = null; + private boolean ssl = false; + private int port = 0; + private int mode = 0; public RitaApi(Map<String, String> document) { this.document = new HashMap<>(); @@ -114,6 +114,11 @@ public class RitaApi { this.ssl = ssl; } + /** + * Set. + * @param name the name + * @param value the value + */ public void set(String name, Object value) { if (!checkIn(name)) { throw new IllegalArgumentException("Field [" + name + "] is not a valid IN parameter"); @@ -136,6 +141,11 @@ public class RitaApi { document.put(name, objString); } + /** + * Get string. + * @param name the name + * @return the string + */ public String get(String name) { if (!checkOut(name)) { throw new IllegalArgumentException("Field [" + name + "] is not a valid OUT parameter"); @@ -159,10 +169,20 @@ public class RitaApi { return buf.toString(); } + /** + * Gets document. + * @return the document + */ public Map<String, String> getDocument() { return this.document; } + /** + * Send rita api. + * @return the rita api + * @throws IOException the io exception + * @throws GeneralException the general exception + */ public RitaApi send() throws IOException, GeneralException { if (host == null || port == 0) { throw new GeneralException("TCP transaction not supported without valid host/port configuration"); @@ -205,7 +225,7 @@ public class RitaApi { } private static boolean checkIn(String name) { - for (String element : validOut) { + for (String element : VALID_OUT) { if (name.equals(element)) { return false; } @@ -214,7 +234,7 @@ public class RitaApi { } private static boolean checkOut(String name) { - for (String element : validIn) { + for (String element : VALID_IN) { if (name.equals(element)) { return false; } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java index f042f80..4ceb665 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java @@ -80,14 +80,14 @@ public class ValueLinkApi { private static Map<String, Object> objectCache = new HashMap<>(); // instance variables - protected Delegator delegator = null; - protected Properties props = null; - protected SecretKey kek = null; - protected SecretKey mwk = null; - protected String merchantId = null; - protected String terminalId = null; - protected Long mwkIndex = null; - protected boolean debug = false; + private Delegator delegator = null; + private Properties props = null; + private SecretKey kek = null; + private SecretKey mwk = null; + private String merchantId = null; + private String terminalId = null; + private Long mwkIndex = null; + private boolean debug = false; protected ValueLinkApi() { } protected ValueLinkApi(Delegator delegator, Properties props) { @@ -126,7 +126,7 @@ public class ValueLinkApi { throw new RuntimeException("Runtime problems with ValueLinkApi; unable to create instance"); } if (reload) { - synchronized(ValueLinkApi.class) { + synchronized (ValueLinkApi.class) { api = (ValueLinkApi) objectCache.get(merchantId); if (api == null) { api = new ValueLinkApi(delegator, props); @@ -358,7 +358,8 @@ public class ValueLinkApi { // private key (full) byte[] privateBytes = privateKey.getEncoded(); String privateHex = StringUtil.toHexString(privateBytes); - buf.append("======== Begin Private Key (Full @ ").append(privateBytes.length).append(" / ").append(privateHex.length()).append(") ========\n"); + buf.append("======== Begin Private Key (Full @ ").append(privateBytes.length).append(" / ").append(privateHex.length()) + .append(") ========\n"); buf.append(privateHex).append("\n"); buf.append("======== End Private Key ========\n\n"); } @@ -558,7 +559,7 @@ public class ValueLinkApi { */ public byte[] generateMwk(SecretKey mwkdes3) { // zeros for checksum - byte[] zeros = { 0, 0, 0, 0, 0, 0, 0, 0 }; + byte[] zeros = {0, 0, 0, 0, 0, 0, 0, 0 }; // 8 bytes random data byte[] random = new byte[8]; @@ -625,7 +626,7 @@ public class ValueLinkApi { */ public Long getWorkingKeyIndex() { if (this.mwkIndex == null) { - synchronized(this) { + synchronized (this) { if (this.mwkIndex == null) { this.mwkIndex = this.getGenericValue().getLong("workingKeyIndex"); } @@ -664,6 +665,11 @@ public class ValueLinkApi { return amountBd.movePointLeft(2); } + /** + * Gets currency. + * @param currency the currency + * @return the currency + */ public String getCurrency(String currency) { return "840"; // todo make this multi-currency } @@ -736,7 +742,7 @@ public class ValueLinkApi { this.mwkIndex = null; } - // using the prime and generator provided by valuelink; create a parameter object + /** using the prime and generator provided by valuelink; create a parameter object */ protected DHParameterSpec getDHParameterSpec() { String primeHex = (String) props.get("payment.valuelink.prime"); String genString = (String) props.get("payment.valuelink.generator"); @@ -752,7 +758,7 @@ public class ValueLinkApi { return dhParamSpec; } - // actual kek encryption/decryption code + /** actual kek encryption/decryption code */ protected byte[] cryptoViaKek(byte[] content, int mode) { // open a cipher using the kek for transport Cipher cipher = this.getCipher(this.getKekKey(), mode); @@ -765,7 +771,7 @@ public class ValueLinkApi { return dec; } - // return a cipher for a key - DESede/CBC/NoPadding IV = 0 + /** return a cipher for a key - DESede/CBC/NoPadding IV = 0 */ protected Cipher getCipher(SecretKey key, int mode) { byte[] zeros = {0, 0, 0, 0, 0, 0, 0, 0 }; IvParameterSpec iv = new IvParameterSpec(zeros); @@ -790,6 +796,11 @@ public class ValueLinkApi { return mwkCipher; } + /** + * Get pin check sum byte [ ]. + * @param pinBytes the pin bytes + * @return the byte [ ] + */ protected byte[] getPinCheckSum(byte[] pinBytes) { byte[] checkSum = new byte[1]; checkSum[0] = 0; @@ -799,6 +810,11 @@ public class ValueLinkApi { return checkSum; } + /** + * Get random bytes byte [ ]. + * @param length the length + * @return the byte [ ] + */ protected byte[] getRandomBytes(int length) { Random rand = new SecureRandom(); byte[] randomBytes = new byte[length]; @@ -806,6 +822,10 @@ public class ValueLinkApi { return randomBytes; } + /** + * Gets mwk key. + * @return the mwk key + */ protected SecretKey getMwkKey() { if (mwk == null) { mwk = this.getDesEdeKey(getByteRange(getMwk(), 8, 24)); @@ -819,6 +839,10 @@ public class ValueLinkApi { return mwk; } + /** + * Gets kek key. + * @return the kek key + */ protected SecretKey getKekKey() { if (kek == null) { kek = this.getDesEdeKey(getKek()); @@ -832,6 +856,11 @@ public class ValueLinkApi { return kek; } + /** + * Gets des ede key. + * @param rawKey the raw key + * @return the des ede key + */ protected SecretKey getDesEdeKey(byte[] rawKey) { SecretKeyFactory skf = null; try { @@ -865,18 +894,35 @@ public class ValueLinkApi { } } + /** + * Get mwk byte [ ]. + * @return the byte [ ] + */ protected byte[] getMwk() { return StringUtil.fromHexString(this.getGenericValue().getString("workingKey")); } + /** + * Get kek byte [ ]. + * @return the byte [ ] + */ protected byte[] getKek() { return StringUtil.fromHexString(this.getGenericValue().getString("exchangeKey")); } + /** + * Get private key bytes byte [ ]. + * @return the byte [ ] + */ protected byte[] getPrivateKeyBytes() { return StringUtil.fromHexString(this.getGenericValue().getString("privateKey")); } + /** + * Parse response map. + * @param response the response + * @return the map + */ protected Map<String, Object> parseResponse(String response) { if (debug) { Debug.logInfo("Raw Response : " + response, MODULE); 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 b13ee13..008779a 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 @@ -358,7 +358,7 @@ public class ValueLinkServices { Map<String, Object> result = ServiceUtil.returnSuccess(UtilProperties.getMessage(RESOURCE, "AccountingValueLinkPinDisabled", locale)); - result.put("processResult","00".equals(responseCode)); + result.put("processResult", "00".equals(responseCode)); result.put("responseCode", responseCode); result.put("balance", vl.getAmount((String) response.get("currbal"))); result.put("expireDate", response.get("expiredate")); @@ -417,7 +417,7 @@ public class ValueLinkServices { String responseCode = (String) response.get("responsecode"); Map<String, Object> result = ServiceUtil.returnSuccess(); - result.put("processResult","00".equals(responseCode)); + result.put("processResult", "00".equals(responseCode)); result.put("responseCode", responseCode); result.put("authCode", response.get("authcode")); result.put("previousAmount", vl.getAmount((String) response.get("prevbal"))); @@ -480,7 +480,7 @@ public class ValueLinkServices { String responseCode = (String) response.get("responsecode"); Map<String, Object> result = ServiceUtil.returnSuccess(); - result.put("processResult","00".equals(responseCode)); + result.put("processResult", "00".equals(responseCode)); result.put("responseCode", responseCode); result.put("authCode", response.get("authcode")); result.put("previousAmount", vl.getAmount((String) response.get("prevbal"))); @@ -534,7 +534,7 @@ public class ValueLinkServices { String responseCode = (String) response.get("responsecode"); Map<String, Object> result = ServiceUtil.returnSuccess(); - result.put("processResult","00".equals(responseCode)); + result.put("processResult", "00".equals(responseCode)); result.put("responseCode", responseCode); result.put("balance", vl.getAmount((String) response.get("currbal"))); result.put("expireDate", response.get("expiredate")); @@ -645,7 +645,7 @@ public class ValueLinkServices { String responseCode = (String) response.get("responsecode"); Map<String, Object> result = ServiceUtil.returnSuccess(); - result.put("processResult","00".equals(responseCode)); + result.put("processResult", "00".equals(responseCode)); result.put("responseCode", responseCode); result.put("authCode", response.get("authcode")); result.put("previousAmount", vl.getAmount((String) response.get("prevbal"))); @@ -1171,7 +1171,7 @@ public class ValueLinkServices { Debug.logError(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "AccountingGiftCertificateNumberCannotStoreFulfillmentInfo", - UtilMisc.toMap("errorString", e.toString() ), locale)); + UtilMisc.toMap("errorString", e.toString()), locale)); } if (failure) { 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 a5a29a4..5cfcfcd 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 @@ -64,17 +64,17 @@ public class ContentMapFacade implements Map<Object, Object> { mapKeySet.add("render"); } - protected final LocalDispatcher dispatcher; - protected final Delegator delegator; - protected final String contentId; - protected final GenericValue value; - protected final Map<String, Object> context; - protected final Locale locale; - protected final String mimeType; - protected final boolean cache; - protected boolean allowRender = true; - protected boolean isDecorated = false; - protected ContentMapFacade decoratedContent = null; + private final LocalDispatcher dispatcher; + private final Delegator delegator; + private final String contentId; + private final GenericValue value; + private final Map<String, Object> context; + private final Locale locale; + private final String mimeType; + private final boolean cache; + private boolean allowRender = true; + private boolean isDecorated = false; + private ContentMapFacade decoratedContent = null; // internal objects private String sortOrder = "-fromDate"; @@ -200,7 +200,7 @@ 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; this.subContent.setSortOrder(obj); } @@ -209,7 +209,7 @@ public class ContentMapFacade implements Map<Object, Object> { Debug.logWarning("mapKeyFilter parameters must be a string", MODULE); return; } - this.mapKeyFilter=(String) obj; + this.mapKeyFilter = (String) obj; } public void setStatusFilter(Object obj) { @@ -217,7 +217,7 @@ public class ContentMapFacade implements Map<Object, Object> { Debug.logWarning("statusFilter parameters must be a string", MODULE); return; } - this.statusFilter=(String) obj; + this.statusFilter = (String) obj; this.subContent.setStatusFilter(obj); } 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 43fc746..0fc9da1 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 @@ -111,25 +111,28 @@ public class ContentSearch { } } + /** + * The type Content search context. + */ public static class ContentSearchContext { - public int index = 1; - public List<EntityCondition> entityConditionList = new LinkedList<>(); - public List<String> orderByList = new LinkedList<>(); - public Set<String> fieldsToSelect = UtilMisc.toSet("contentId"); - public DynamicViewEntity dynamicViewEntity = new DynamicViewEntity(); - public boolean contentIdGroupBy = false; - public boolean includedKeywordSearch = false; - public Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); - public List<Set<String>> keywordFixedOrSetAndList = new LinkedList<>(); - public Set<String> orKeywordFixedSet = new HashSet<>(); - public Set<String> andKeywordFixedSet = new HashSet<>(); - public List<GenericValue> contentSearchConstraintList = new LinkedList<>(); - public ResultSortOrder resultSortOrder = null; - public Integer resultOffset = null; - public Integer maxResults = null; - protected Delegator delegator = null; - protected String visitId = null; - protected Integer totalResults = null; + private int index = 1; + private List<EntityCondition> entityConditionList = new LinkedList<>(); + private List<String> orderByList = new LinkedList<>(); + private Set<String> fieldsToSelect = UtilMisc.toSet("contentId"); + private DynamicViewEntity dynamicViewEntity = new DynamicViewEntity(); + private boolean contentIdGroupBy = false; + private boolean includedKeywordSearch = false; + private Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); + private List<Set<String>> keywordFixedOrSetAndList = new LinkedList<>(); + private Set<String> orKeywordFixedSet = new HashSet<>(); + private Set<String> andKeywordFixedSet = new HashSet<>(); + private List<GenericValue> contentSearchConstraintList = new LinkedList<>(); + private ResultSortOrder resultSortOrder = null; + private Integer resultOffset = null; + private Integer maxResults = null; + private Delegator delegator = null; + private String visitId = null; + private Integer totalResults = null; public ContentSearchContext(Delegator delegator, String visitId) { this.delegator = delegator; @@ -137,10 +140,18 @@ public class ContentSearch { dynamicViewEntity.addMemberEntity("CNT", "Content"); } + /** + * Gets delegator. + * @return the delegator + */ public Delegator getDelegator() { return this.delegator; } + /** + * Add content search constraints. + * @param contentSearchConstraintList the content search constraint list + */ public void addContentSearchConstraints(List<? extends ContentSearchConstraint> contentSearchConstraintList) { // Go through the constraints and add them in for (ContentSearchConstraint constraint: contentSearchConstraintList) { @@ -148,22 +159,42 @@ public class ContentSearch { } } + /** + * Sets result sort order. + * @param resultSortOrder the result sort order + */ public void setResultSortOrder(ResultSortOrder resultSortOrder) { this.resultSortOrder = resultSortOrder; } + /** + * Sets result offset. + * @param resultOffset the result offset + */ public void setResultOffset(Integer resultOffset) { this.resultOffset = resultOffset; } + /** + * Sets max results. + * @param maxResults the max results + */ public void setMaxResults(Integer maxResults) { this.maxResults = maxResults; } + /** + * Gets total results. + * @return the total results + */ public Integer getTotalResults() { return this.totalResults; } + /** + * Do search array list. + * @return the array list + */ public ArrayList<String> doSearch() { long startMillis = System.currentTimeMillis(); @@ -445,10 +476,10 @@ public class ContentSearch { @SuppressWarnings("serial") public static class ContentAssocConstraint extends ContentSearchConstraint { - public static final String constraintName = "ContentAssoc"; - protected String contentId; - protected String contentAssocTypeId; - protected boolean includeSubContents; + public static final String CONSTRAINT_NAME = "ContentAssoc"; + private String contentId; + private String contentAssocTypeId; + private boolean includeSubContents; public ContentAssocConstraint(String contentId, String contentAssocTypeId, boolean includeSubContents) { this.contentId = contentId; @@ -519,7 +550,7 @@ public class ContentSearch { // 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", constraintName, "infoString", this.contentId + "," + this.contentAssocTypeId))); + contentSearchContext.contentSearchConstraintList.add(contentSearchContext.getDelegator().makeValue("ContentSearchConstraint", UtilMisc.toMap("constraintName", CONSTRAINT_NAME, "infoString", this.contentId + "," + this.contentAssocTypeId))); } @@ -607,12 +638,12 @@ public class ContentSearch { @SuppressWarnings("serial") public static class KeywordConstraint extends ContentSearchConstraint { - public static final String constraintName = "Keyword"; - protected String keywordsString; - protected boolean anyPrefix; - protected boolean anySuffix; - protected boolean isAnd; - protected boolean removeStems; + public static final String CONSTRAINT_NAME = "Keyword"; + private String keywordsString; + private boolean anyPrefix; + private boolean anySuffix; + private boolean isAnd; + private boolean removeStems; public KeywordConstraint(String keywordsString, boolean anyPrefix, boolean anySuffix, Boolean removeStems, boolean isAnd) { this.keywordsString = keywordsString; @@ -675,7 +706,7 @@ public class ContentSearch { } // add in contentSearchConstraint, don't worry about the contentSearchResultId or constraintSeqId, those will be fill in later - Map<String, String> valueMap = UtilMisc.toMap("constraintName", constraintName, "infoString", this.keywordsString); + Map<String, String> valueMap = UtilMisc.toMap("constraintName", CONSTRAINT_NAME, "infoString", this.keywordsString); valueMap.put("anyPrefix", this.anyPrefix ? "Y" : "N"); valueMap.put("anySuffix", this.anySuffix ? "Y" : "N"); valueMap.put("isAnd", this.isAnd ? "Y" : "N"); @@ -735,9 +766,9 @@ public class ContentSearch { @SuppressWarnings("serial") public static class LastUpdatedRangeConstraint extends ContentSearchConstraint { - public static final String constraintName = "LastUpdatedRange"; - protected Timestamp fromDate; - protected Timestamp thruDate; + public static final String CONSTRAINT_NAME = "LastUpdatedRange"; + private Timestamp fromDate; + private Timestamp thruDate; public LastUpdatedRangeConstraint(Timestamp fromDate, Timestamp thruDate) { this.fromDate = fromDate != null ? (Timestamp) fromDate.clone() : null; @@ -749,24 +780,25 @@ public class ContentSearch { contentSearchContext.dynamicViewEntity.addAlias("CNT", "lastModifiedDate", "lastModifiedDate", null, null, null, null); EntityConditionList<EntityExpr> dateConditions = null; - EntityExpr dateCondition=null; - if (fromDate !=null && thruDate!=null) { - dateConditions= EntityCondition.makeCondition(UtilMisc.toList( + 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); - } if (fromDate !=null) { - dateCondition=EntityCondition.makeCondition("lastModifiedDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate); + } + if (fromDate != null) { + dateCondition = EntityCondition.makeCondition("lastModifiedDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate); } else if (thruDate != null) { dateCondition = EntityCondition.makeCondition("lastModifiedDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate); } EntityConditionList<? extends EntityCondition> conditions = null; - if (fromDate !=null && thruDate!=null) { - conditions=EntityCondition.makeCondition(UtilMisc.toList( + if (fromDate != null && thruDate != null) { + conditions = EntityCondition.makeCondition(UtilMisc.toList( dateConditions, EntityCondition.makeCondition("lastModifiedDate", EntityOperator.EQUALS, null)), EntityOperator.OR); } else { - conditions=EntityCondition.makeCondition(UtilMisc.toList( + conditions = EntityCondition.makeCondition(UtilMisc.toList( dateCondition, EntityCondition.makeCondition("lastModifiedDate", EntityOperator.EQUALS, null)), EntityOperator.OR); @@ -775,7 +807,7 @@ 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", constraintName, "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 */ @@ -874,8 +906,8 @@ public class ContentSearch { @SuppressWarnings("serial") public static class SortContentField extends ResultSortOrder { - protected String fieldName; - protected boolean ascending; + private String fieldName; + private boolean ascending; /** Some good field names to try might include: * [contentName] diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearchSession.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearchSession.java index 6e26aac..4e1087a 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearchSession.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearchSession.java @@ -43,11 +43,11 @@ public class ContentSearchSession { @SuppressWarnings("serial") public static class ContentSearchOptions implements java.io.Serializable { - protected List<ContentSearchConstraint> constraintList = null; - protected ResultSortOrder resultSortOrder = null; - protected Integer viewIndex = null; - protected Integer viewSize = null; - protected boolean changed = false; + private List<ContentSearchConstraint> constraintList = null; + private ResultSortOrder resultSortOrder = null; + private Integer viewIndex = null; + private Integer viewSize = null; + private boolean changed = false; public ContentSearchOptions() { } /** Basic copy constructor */ @@ -59,6 +59,10 @@ public class ContentSearchSession { this.changed = contentSearchOptions.changed; } + /** + * Gets constraint list. + * @return the constraint list + */ public List<ContentSearchConstraint> getConstraintList() { return this.constraintList; } @@ -76,6 +80,10 @@ public class ContentSearchSession { } } + /** + * Gets result sort order. + * @return the result sort order + */ public ResultSortOrder getResultSortOrder() { if (this.resultSortOrder == null) { this.resultSortOrder = new SortKeywordRelevancy(); @@ -99,6 +107,9 @@ public class ContentSearchSession { contentSearchOptions.resultSortOrder = null; } + /** + * Clear view info. + */ public void clearViewInfo() { this.viewIndex = null; this.viewSize = null; @@ -129,6 +140,13 @@ public class ContentSearchSession { this.viewSize = viewSize; } + /** + * Search get constraint strings list. + * @param detailed the detailed + * @param delegator the delegator + * @param locale the locale + * @return the list + */ public List<String> searchGetConstraintStrings(boolean detailed, Delegator delegator, Locale locale) { List<ContentSearchConstraint> contentSearchConstraintList = this.getConstraintList(); List<String> constraintStrings = new LinkedList<>(); @@ -186,18 +204,18 @@ public class ContentSearchSession { // add a Content Assoc Type to the search if (UtilValidate.isNotEmpty(parameters.get("SEARCH_CONTENT_ID"))) { - String contentId=(String) parameters.get("SEARCH_CONTENT_ID"); - String contentAssocTypeId=(String) parameters.get("contentAssocTypeId"); - boolean includeAllSubContents =!"N".equalsIgnoreCase((String) parameters.get("SEARCH_SUB_CONTENTS")); + String contentId = (String) parameters.get("SEARCH_CONTENT_ID"); + String contentAssocTypeId = (String) parameters.get("contentAssocTypeId"); + boolean includeAllSubContents = !"N".equalsIgnoreCase((String) parameters.get("SEARCH_SUB_CONTENTS")); searchAddConstraint(new ContentSearch.ContentAssocConstraint(contentId, contentAssocTypeId, includeAllSubContents), session); constraintsChanged = true; } // add a Content fromDate thruDate to the search if (UtilValidate.isNotEmpty(parameters.get("fromDate")) || UtilValidate.isNotEmpty(parameters.get("thruDate"))) { - Timestamp fromDate =null; + Timestamp fromDate = null; if (UtilValidate.isNotEmpty(parameters.get("fromDate"))) { - fromDate=Timestamp.valueOf((String) parameters.get("fromDate")); + fromDate = Timestamp.valueOf((String) parameters.get("fromDate")); } Timestamp thruDate = null; @@ -214,7 +232,8 @@ public class ContentSearchSession { String searchOperator = (String) parameters.get("SEARCH_OPERATOR"); // defaults to true/Y, ie anything but N is true/Y boolean anyPrefixSuffix = !"N".equals(parameters.get("SEARCH_ANYPRESUF")); - searchAddConstraint(new ContentSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, "AND".equals(searchOperator)), session); + searchAddConstraint(new ContentSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, + "AND".equals(searchOperator)), session); constraintsChanged = true; } // set the sort order diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java index 965b166..b66e1f4 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java @@ -83,7 +83,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor } @Override - public GenericValue getCurrentContentExt(Delegator delegator, List<Map<String, ? extends Object>> trail, GenericValue userLogin, Map<String, Object> ctx, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GeneralException { + public GenericValue getCurrentContentExt(Delegator delegator, List<Map<String, ? extends Object>> trail, GenericValue userLogin, + Map<String, Object> ctx, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GeneralException { return getCurrentContent(delegator, trail, userLogin, ctx, nullThruDatesOnly, contentAssocPredicateId); } @@ -94,29 +95,34 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor // new rendering methods @Override - public void renderContentAsTextExt(LocalDispatcher dispatcher, String contentId, Appendable out, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { + public void renderContentAsTextExt(LocalDispatcher dispatcher, String contentId, Appendable out, Map<String, Object> templateContext, + Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { renderContentAsText(dispatcher, contentId, out, templateContext, locale, mimeTypeId, null, null, cache); } @Override - public void renderSubContentAsTextExt(LocalDispatcher dispatcher, String contentId, Appendable out, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { + public void renderSubContentAsTextExt(LocalDispatcher dispatcher, String contentId, Appendable out, String mapKey, Map<String, Object> + templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { renderSubContentAsText(dispatcher, contentId, out, mapKey, templateContext, locale, mimeTypeId, cache); } @Override - public String renderSubContentAsTextExt(LocalDispatcher dispatcher, String contentId, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { + public String renderSubContentAsTextExt(LocalDispatcher dispatcher, String contentId, String mapKey, Map<String, Object> templateContext, Locale + locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { return renderSubContentAsText(dispatcher, contentId, mapKey, templateContext, locale, mimeTypeId, cache); } @Override - public String renderContentAsTextExt(LocalDispatcher dispatcher, String contentId, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { + public String renderContentAsTextExt(LocalDispatcher dispatcher, String contentId, Map<String, Object> templateContext, Locale locale, + String mimeTypeId, boolean cache) throws GeneralException, IOException { return renderContentAsText(dispatcher, contentId, templateContext, locale, mimeTypeId, cache); } // ------------------------------------- // Content rendering methods // ------------------------------------- - public static GenericValue findContentForRendering(Delegator delegator, String contentId, Locale locale, String partyId, String roleTypeId, boolean cache) throws GeneralException, IOException { + public static GenericValue findContentForRendering(Delegator delegator, String contentId, Locale locale, String partyId, String roleTypeId, + boolean cache) throws GeneralException, IOException { if (UtilValidate.isEmpty(contentId)) { Debug.logError("No content ID found.", MODULE); return null; @@ -164,14 +170,16 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor if (partyId != null && roleTypeId != null) { List<GenericValue> alternateViews = null; try { - alternateViews = content.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_ROLE"), UtilMisc.toList("-caFromDate"), true); + alternateViews = content.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_ROLE"), + UtilMisc.toList("-caFromDate"), true); } catch (GenericEntityException e) { Debug.logError(e, "Error finding alternate content: " + e.toString(), MODULE); } alternateViews = EntityUtil.filterByDate(alternateViews, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true); for (GenericValue thisView : alternateViews) { - GenericValue altContentRole = EntityUtil.getFirst(EntityUtil.filterByDate(thisView.getRelated("ContentRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", roleTypeId), null, true))); + GenericValue altContentRole = EntityUtil.getFirst(EntityUtil.filterByDate(thisView.getRelated("ContentRole", + UtilMisc.toMap("partyId", partyId, "roleTypeId", roleTypeId), null, true))); GenericValue altContent = null; if (UtilValidate.isNotEmpty(altContentRole)) { altContent = altContentRole.getRelatedOne("Content", true); @@ -279,7 +287,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor } if (UtilValidate.isNotEmpty(webAnalytics)) { - DataResourceWorker.renderDataResourceAsText(dispatcher, delegator, dataResourceId, out, templateContext, locale, mimeTypeId, cache, webAnalytics); + DataResourceWorker.renderDataResourceAsText(dispatcher, delegator, dataResourceId, out, templateContext, locale, mimeTypeId, + cache, webAnalytics); } else { DataResourceWorker.renderDataResourceAsText(dispatcher, dataResourceId, out, templateContext, locale, mimeTypeId, cache); } @@ -304,8 +313,10 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor // This part is using an xml file as the input data and an ftl or xsl file to present it. if (UtilValidate.isNotEmpty(mimeType)) { if (mimeType.toLowerCase().indexOf("xml") >= 0) { - GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne(); - GenericValue templateDataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", templateDataResourceId).cache().queryOne(); + GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache() + .queryOne(); + GenericValue templateDataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", + templateDataResourceId).cache().queryOne(); if ("FTL".equals(templateDataResource.getString("dataTemplateTypeId"))) { StringReader sr = new StringReader(textData); try { @@ -315,7 +326,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor throw new GeneralException(e.getMessage()); } } else { - templateContext.put("docFile", DataResourceWorker.getContentFile(dataResource.getString("dataResourceTypeId"), dataResource.getString("objectInfo"), (String) templateContext.get("contextRoot")).getAbsoluteFile().toString()); + templateContext.put("docFile", DataResourceWorker.getContentFile(dataResource.getString("dataResourceTypeId"), + dataResource.getString("objectInfo"), (String) templateContext.get("contextRoot")).getAbsoluteFile().toString()); } } else { // must be text @@ -354,7 +366,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor } public static String renderContentAsText(LocalDispatcher dispatcher, String contentId, Appendable out, Map<String, Object> templateContext, - Locale locale, String mimeTypeId, String partyId, String roleTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException { + Locale locale, String mimeTypeId, String partyId, String roleTypeId, boolean cache, List<GenericValue> webAnalytics) + throws GeneralException, IOException { Delegator delegator = dispatcher.getDelegator(); GenericValue content = ContentWorker.findContentForRendering(delegator, contentId, locale, partyId, roleTypeId, cache); ContentWorker.renderContentAsText(dispatcher, content, out, templateContext, locale, mimeTypeId, cache, webAnalytics); @@ -368,21 +381,21 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor ContentWorker.renderContentAsText(dispatcher, content, out, templateContext, locale, mimeTypeId, cache, null); } - public static String renderSubContentAsText(LocalDispatcher dispatcher, String contentId, String mapKey, Map<String, Object> templateContext, Locale locale, - String mimeTypeId, boolean cache) throws GeneralException, IOException { + public static String renderSubContentAsText(LocalDispatcher dispatcher, String contentId, String mapKey, Map<String, Object> templateContext, + Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { Writer writer = new StringWriter(); renderSubContentAsText(dispatcher, contentId, writer, mapKey, templateContext, locale, mimeTypeId, cache); return writer.toString(); } - public static void renderSubContentAsText(LocalDispatcher dispatcher, String contentId, Appendable out, String mapKey, Map<String, Object> templateContext, - Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { + public static void renderSubContentAsText(LocalDispatcher dispatcher, String contentId, Appendable out, String mapKey, Map<String, Object> + templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { Delegator delegator = dispatcher.getDelegator(); // find the sub-content with matching mapKey List<EntityCondition> exprs = UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId)); if (UtilValidate.isNotEmpty(mapKey)) { - exprs.add(EntityCondition.makeCondition("mapKey", EntityOperator.EQUALS, mapKey)); + exprs.add(EntityCondition.makeCondition("mapKey", EntityOperator.EQUALS, mapKey)); } GenericValue subContent = EntityQuery.use(delegator).from("ContentAssoc") @@ -409,7 +422,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor List<GenericValue> alternateViews = null; try { - alternateViews = view.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"), true); + alternateViews = view.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), + UtilMisc.toList("-caFromDate"), true); } catch (GenericEntityException e) { Debug.logError(e, "Error finding alternate locale content: " + e.toString(), MODULE); return view; @@ -468,7 +482,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return contentAssocDataResourceViewFrom; } - public static void traverse(Delegator delegator, GenericValue content, Timestamp fromDate, Timestamp thruDate, Map<String, Object> whenMap, int depthIdx, Map<String, Object> masterNode, String contentAssocTypeId, List<GenericValue> pickList, String direction) { + public static void traverse(Delegator delegator, GenericValue content, Timestamp fromDate, Timestamp thruDate, Map<String, Object> whenMap, + int depthIdx, Map<String, Object> masterNode, String contentAssocTypeId, List<GenericValue> pickList, String direction) { String contentTypeId = null; String contentId = null; try { @@ -547,7 +562,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor boolean isFollow = checkWhen(assocContext, (String) whenMap.get("followWhen"), true); if (isFollow) { GenericValue thisContent = assocValue.getRelatedOne(assocRelation, false); - traverse(delegator, thisContent, fromDate, thruDate, whenMap, depthIdx + 1, thisNode, contentAssocTypeId, pickList, relatedDirection); + traverse(delegator, thisContent, fromDate, thruDate, whenMap, depthIdx + 1, thisNode, contentAssocTypeId, pickList, + relatedDirection); } } } @@ -558,7 +574,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor public static boolean traverseSubContent(Map<String, Object> ctx) { boolean inProgress = false; - List<Map <String, Object>> nodeTrail = UtilGenerics.cast(ctx.get("nodeTrail")); + List<Map<String, Object>> nodeTrail = UtilGenerics.cast(ctx.get("nodeTrail")); ContentWorker.traceNodeTrail("11", nodeTrail); int sz = nodeTrail.size(); if (sz == 0) { @@ -571,7 +587,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return false; } - List<Map <String, Object>> kids = UtilGenerics.cast(currentNode.get("kids")); + List<Map<String, Object>> kids = UtilGenerics.cast(currentNode.get("kids")); if (UtilValidate.isNotEmpty(kids)) { int idx = 0; while (idx < kids.size()) { @@ -678,8 +694,9 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor List<GenericValue> topicValueList = content.getRelated("FromContentAssoc", null, null, true); for (GenericValue topicValue : topicValueList) { String contentAssocPredicateId = (String) topicValue.get("contentAssocPredicateId"); - if (contentAssocPredicateId != null && "topifies".equals(contentAssocPredicateId)) + if (contentAssocPredicateId != null && "topifies".equals(contentAssocPredicateId)) { topics.add(topicValue.get("contentIdTo")); + } } } catch (GenericEntityException e) { Debug.logError("Entity Error:" + e.getMessage(), null); @@ -708,7 +725,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor Boolean nullThruDatesOnly = Boolean.TRUE; Map<String, Object> results = null; try { - results = ContentServicesComplex.getAssocAndContentAndDataResourceCacheMethod(delegator, parentContentId, mapKey, direction, null, null, assocTypeList, contentTypeList, nullThruDatesOnly, contentAssocPredicateId, null); + results = ContentServicesComplex.getAssocAndContentAndDataResourceCacheMethod(delegator, parentContentId, mapKey, direction, null, null, + assocTypeList, contentTypeList, nullThruDatesOnly, contentAssocPredicateId, null); } catch (GenericEntityException | MiniLangException e) { throw new RuntimeException(e.getMessage()); } @@ -735,7 +753,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor * @param context A <code>Map</code> containing initial variables * @param whenStr A <code>String</code> condition expression * @param defaultReturn A <code>boolean</code> default return value - * @return A <code>boolan</code> result of evaluation + * @return A <code>boolean</code> result of evaluation */ public static boolean checkWhen(Map<String, Object> context, String whenStr, boolean defaultReturn) { boolean isWhen = defaultReturn; @@ -760,7 +778,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return isWhen; } - public static List<GenericValue> getAssociatedContent(GenericValue currentContent, String linkDir, List<String> assocTypes, List<String> contentTypes, String fromDate, String thruDate) throws GenericEntityException { + public static List<GenericValue> getAssociatedContent(GenericValue currentContent, String linkDir, List<String> assocTypes, + List<String> contentTypes, String fromDate, String thruDate) throws GenericEntityException { Delegator delegator = currentContent.getDelegator(); List<GenericValue> assocList = getAssociations(currentContent, linkDir, assocTypes, fromDate, thruDate); if (UtilValidate.isEmpty(assocList)) { @@ -798,7 +817,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return contentList; } - public static List<GenericValue> getAssociatedContentView(GenericValue currentContent, String linkDir, List<String> assocTypes, List<String> contentTypes, String fromDate, String thruDate) throws GenericEntityException { + public static List<GenericValue> getAssociatedContentView(GenericValue currentContent, String linkDir, List<String> assocTypes, + List<String> contentTypes, String fromDate, String thruDate) throws GenericEntityException { List<EntityExpr> exprListAnd = new LinkedList<>(); String origContentId = (String) currentContent.get("contentId"); @@ -833,7 +853,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return EntityQuery.use(delegator).from(contentAssocViewName).where(exprListAnd).queryList(); } - public static List<GenericValue> getAssociations(GenericValue currentContent, String linkDir, List<String> assocTypes, String strFromDate, String strThruDate) throws GenericEntityException { + public static List<GenericValue> getAssociations(GenericValue currentContent, String linkDir, List<String> assocTypes, String strFromDate, + String strThruDate) throws GenericEntityException { Delegator delegator = currentContent.getDelegator(); String origContentId = (String) currentContent.get("contentId"); Timestamp fromDate = null; @@ -848,7 +869,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return assocs; } - public static List<GenericValue> getContentAssocsWithId(Delegator delegator, String contentId, Timestamp fromDate, Timestamp thruDate, String direction, List<String> assocTypes) throws GenericEntityException { + public static List<GenericValue> getContentAssocsWithId(Delegator delegator, String contentId, Timestamp fromDate, Timestamp thruDate, + String direction, List<String> assocTypes) throws GenericEntityException { List<EntityCondition> exprList = new LinkedList<>(); EntityExpr joinExpr = null; if (direction != null && "From".equalsIgnoreCase(direction)) { @@ -893,15 +915,17 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor public static void getContentTypeAncestry(Delegator delegator, String contentTypeId, List<String> contentTypes) throws GenericEntityException { contentTypes.add(contentTypeId); GenericValue contentTypeValue = EntityQuery.use(delegator).from("ContentType").where("contentTypeId", contentTypeId).queryOne(); - if (contentTypeValue == null) + if (contentTypeValue == null) { return; + } String parentTypeId = (String) contentTypeValue.get("parentTypeId"); if (parentTypeId != null) { getContentTypeAncestry(delegator, parentTypeId, contentTypes); } } - public static void getContentAncestry(Delegator delegator, String contentId, String contentAssocTypeId, String direction, List<GenericValue> contentAncestorList) throws GenericEntityException { + public static void getContentAncestry(Delegator delegator, String contentId, String contentAssocTypeId, String direction, + List<GenericValue> contentAncestorList) throws GenericEntityException { String contentIdField = null; String contentIdOtherField = null; if (direction != null && "to".equalsIgnoreCase(direction)) { @@ -934,7 +958,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor } } - public static void getContentAncestryAll(Delegator delegator, String contentId, String passedContentTypeId, String direction, List<String> contentAncestorList) { + public static void getContentAncestryAll(Delegator delegator, String contentId, String passedContentTypeId, String direction, + List<String> contentAncestorList) { String contentIdField = null; String contentIdOtherField = null; if (direction != null && "to".equalsIgnoreCase(direction)) { @@ -960,8 +985,9 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor GenericValue contentTo = EntityQuery.use(delegator).from("Content").where("contentId", contentIdOther).cache().queryOne(); String contentTypeId = contentTo.getString("contentTypeId"); - if (contentTypeId != null && contentTypeId.equals(passedContentTypeId)) + if (contentTypeId != null && contentTypeId.equals(passedContentTypeId)) { contentAncestorList.add(contentIdOther); + } } } } @@ -983,14 +1009,16 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return nodeTrail; } - public static String getContentAncestryNodeTrailCsv(Delegator delegator, String contentId, String contentAssocTypeId, String direction) throws GenericEntityException { + public static String getContentAncestryNodeTrailCsv(Delegator delegator, String contentId, String contentAssocTypeId, String direction) + throws GenericEntityException { List<GenericValue> contentAncestorList = new LinkedList<>(); getContentAncestry(delegator, contentId, contentAssocTypeId, direction, contentAncestorList); String csv = StringUtil.join(contentAncestorList, ","); return csv; } - public static void getContentAncestryValues(Delegator delegator, String contentId, String contentAssocTypeId, String direction, List<GenericValue> contentAncestorList) throws GenericEntityException { + public static void getContentAncestryValues(Delegator delegator, String contentId, String contentAssocTypeId, String direction, + List<GenericValue> contentAncestorList) throws GenericEntityException { String contentIdField = null; String contentIdOtherField = null; if (direction != null && "to".equalsIgnoreCase(direction)) { @@ -1066,7 +1094,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return permResults; } - public static GenericValue getSubContent(Delegator delegator, String contentId, String mapKey, String subContentId, GenericValue userLogin, List<String> assocTypes, Timestamp fromDate) throws IOException { + public static GenericValue getSubContent(Delegator delegator, String contentId, String mapKey, String subContentId, GenericValue userLogin, + List<String> assocTypes, Timestamp fromDate) throws IOException { GenericValue view = null; try { if (subContentId == null) { @@ -1074,9 +1103,11 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor throw new GenericEntityException("contentId and subContentId are null."); } Map<String, Object> results = null; - results = ContentServicesComplex.getAssocAndContentAndDataResourceMethod(delegator, contentId, mapKey, "To", fromDate, null, null, null, assocTypes, null); + results = ContentServicesComplex.getAssocAndContentAndDataResourceMethod(delegator, contentId, mapKey, "To", fromDate, null, null, + null, assocTypes, null); List<GenericValue> entityList = UtilGenerics.cast(results.get("entityList")); if (UtilValidate.isEmpty(entityList)) { + return view; //throw new IOException("No subcontent found."); } else { view = entityList.get(0); @@ -1094,7 +1125,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return view; } - public static GenericValue getSubContentCache(Delegator delegator, String contentId, String mapKey, String subContentId, GenericValue userLogin, List<String> assocTypes, Timestamp fromDate, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException { + public static GenericValue getSubContentCache(Delegator delegator, String contentId, String mapKey, String subContentId, GenericValue userLogin, + List<String> assocTypes, Timestamp fromDate, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException { GenericValue view = null; if (UtilValidate.isEmpty(subContentId)) { view = getSubContentCache(delegator, contentId, mapKey, userLogin, assocTypes, fromDate, nullThruDatesOnly, contentAssocPredicateId); @@ -1104,7 +1136,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return view; } - public static GenericValue getSubContentCache(Delegator delegator, String contentId, String mapKey, GenericValue userLogin, List<String> assocTypes, Timestamp fromDate, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException { + public static GenericValue getSubContentCache(Delegator delegator, String contentId, String mapKey, GenericValue userLogin, + List<String> assocTypes, Timestamp fromDate, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException { GenericValue view = null; if (contentId == null) { Debug.logError("ContentId is null", MODULE); @@ -1113,9 +1146,13 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor Map<String, Object> results = null; List<String> contentTypes = null; try { - // NOTE DEJ20060610: Changed "From" to "To" because it makes the most sense for sub-content renderings using a root-contentId and mapKey to determine the sub-contentId to have the ContentAssoc go from the root to the sub, ie try to determine the contentIdTo from the contentId and mapKey - // This shouldn't be changed from "To" to "From", but if desired could be parameterized to make this selectable in higher up calling methods - results = ContentServicesComplex.getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, mapKey, "To", fromDate, null, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId, null); + // NOTE DEJ20060610: Changed "From" to "To" because it makes the most sense for sub-content renderings using a root-contentId and mapKey + // to determine the sub-contentId to have the ContentAssoc go from the root to the sub, ie try to determine the contentIdTo from the + // contentId and mapKey + // This shouldn't be changed from "To" to "From", but if desired could be parameterized to make this selectable in higher up calling + // methods + results = ContentServicesComplex.getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, mapKey, "To", fromDate, null, + assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId, null); } catch (MiniLangException e) { throw new RuntimeException(e.getMessage()); } @@ -1134,7 +1171,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor .cache().queryFirst(); } - public static GenericValue getCurrentContent(Delegator delegator, List<Map<String, ? extends Object>> trail, GenericValue userLogin, Map<String, Object> ctx, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GeneralException { + public static GenericValue getCurrentContent(Delegator delegator, List<Map<String, ? extends Object>> trail, GenericValue userLogin, + Map<String, Object> ctx, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GeneralException { String contentId = (String) ctx.get("contentId"); String subContentId = (String) ctx.get("subContentId"); String mapKey = (String) ctx.get("mapKey"); @@ -1151,10 +1189,12 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor int sz = passedGlobalNodeTrail.size(); if (sz > 0) { Map<String, Object> nd = passedGlobalNodeTrail.get(sz - 1); - if (nd != null) + if (nd != null) { currentContent = (GenericValue) nd.get("value"); - if (currentContent != null) + } + if (currentContent != null) { viewContentId = (String) currentContent.get("contentId"); + } } if (UtilValidate.isNotEmpty(subContentId)) { @@ -1172,7 +1212,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor } if (UtilValidate.isNotEmpty(contentId) || UtilValidate.isNotEmpty(subContentId)) { try { - currentContent = ContentWorker.getSubContentCache(delegator, contentId, mapKey, subContentId, userLogin, assocTypes, fromDate, nullThruDatesOnly, contentAssocPredicateId); + currentContent = ContentWorker.getSubContentCache(delegator, contentId, mapKey, subContentId, userLogin, assocTypes, fromDate, + nullThruDatesOnly, contentAssocPredicateId); Map<String, Object> node = ContentWorker.makeNode(currentContent); passedGlobalNodeTrail.add(node); } catch (GenericEntityException e) { @@ -1203,7 +1244,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return content; } - public static Map<String, Object> buildPickContext(Delegator delegator, String contentAssocTypeId, String assocContentId, String direction, GenericValue thisContent) throws GenericEntityException { + public static Map<String, Object> buildPickContext(Delegator delegator, String contentAssocTypeId, String assocContentId, String direction, + GenericValue thisContent) throws GenericEntityException { Map<String, Object> ctx = new HashMap<>(); ctx.put("contentAssocTypeId", contentAssocTypeId); ctx.put("contentId", assocContentId); @@ -1213,8 +1255,9 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor } else { ctx.put("contentIdTo", assocContentId); } - if (thisContent == null) + if (thisContent == null) { thisContent = EntityQuery.use(delegator).from("Content").where("contentId", assocContentId).cache().queryOne(); + } ctx.put("content", thisContent); List<Object> purposes = getPurposes(thisContent); ctx.put("purposes", purposes); @@ -1229,7 +1272,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return ctx; } - public static void checkConditions(Delegator delegator, Map<String, Object> trailNode, Map<String, Object> contentAssoc, Map<String, Object> whenMap) { + public static void checkConditions(Delegator delegator, Map<String, Object> trailNode, Map<String, Object> contentAssoc, + Map<String, Object> whenMap) { Map<String, Object> context = new HashMap<>(); GenericValue content = (GenericValue) trailNode.get("value"); if (content != null) { @@ -1252,7 +1296,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor contentAssoc = delegator.makeValue("ContentAssoc"); try { // TODO: locale needs to be gotten correctly - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocIn", content, contentAssoc, new LinkedList<>(), Locale.getDefault()); + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocIn", + content, contentAssoc, new LinkedList<>(), Locale.getDefault()); context.put("contentAssocTypeId", contentAssoc.get("contentAssocTypeId")); context.put("contentAssocPredicateId", contentAssoc.get("contentAssocPredicateId")); context.put("mapKey", contentAssoc.get("mapKey")); @@ -1300,7 +1345,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor if (UtilValidate.isEmpty(targetOperationList)) { targetOperationList = new LinkedList<>(); if (UtilValidate.isEmpty(md)) { - md ="_CREATE"; + md = "_CREATE"; } targetOperationList.add("CONTENT" + md); } @@ -1351,7 +1396,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor return errorMessage; } - public static List<GenericValue> getContentAssocViewList(Delegator delegator, String contentIdTo, String contentId, String contentAssocTypeId, String statusId, String privilegeEnumId) throws GenericEntityException { + public static List<GenericValue> getContentAssocViewList(Delegator delegator, String contentIdTo, String contentId, String contentAssocTypeId, + String statusId, String privilegeEnumId) throws GenericEntityException { List<EntityExpr> exprListAnd = new LinkedList<>(); if (UtilValidate.isNotEmpty(contentIdTo)) { @@ -1385,7 +1431,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor .queryList(); } - public static GenericValue getContentAssocViewFrom(Delegator delegator, String contentIdTo, String contentId, String contentAssocTypeId, String statusId, String privilegeEnumId) throws GenericEntityException { + public static GenericValue getContentAssocViewFrom(Delegator delegator, String contentIdTo, String contentId, String contentAssocTypeId, + String statusId, String privilegeEnumId) throws GenericEntityException { List<GenericValue> filteredList = getContentAssocViewList(delegator, contentIdTo, contentId, contentAssocTypeId, statusId, privilegeEnumId); GenericValue val = null; @@ -1516,7 +1563,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor * @param dataResourceId part of primary key of view. To be used if view is null. * @param parentContentId primary key of parent content. To be used if parentContent is null; */ - public static String determineMimeType(Delegator delegator, GenericValue view, GenericValue parentContent, String contentId, String dataResourceId, String parentContentId) throws GenericEntityException { + public static String determineMimeType(Delegator delegator, GenericValue view, GenericValue parentContent, String contentId, + String dataResourceId, String parentContentId) throws GenericEntityException { String mimeTypeId = null; if (view != null) { @@ -1529,7 +1577,8 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor if (UtilValidate.isEmpty(mimeTypeId)) { if (UtilValidate.isNotEmpty(contentId) && UtilValidate.isNotEmpty(dataResourceId)) { - view = EntityQuery.use(delegator).from("SubContentDataResourceView").where("contentId", contentId, "drDataResourceId", dataResourceId).queryOne(); + view = EntityQuery.use(delegator).from("SubContentDataResourceView").where("contentId", contentId, "drDataResourceId", + dataResourceId).queryOne(); if (view != null) { mimeTypeId = view.getString("mimeTypeId"); String drMimeTypeId = view.getString("drMimeTypeId"); @@ -1559,7 +1608,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor public static String logMap(String lbl, Map<String, Object> map, int indentLevel) { StringBuilder indent = new StringBuilder(); - for (int i = 0; i<indentLevel; i++) { + for (int i = 0; i < indentLevel; i++) { indent.append(' '); } return logMap(new StringBuilder(), lbl, map, indent).toString(); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/content/PermissionRecorder.java b/applications/content/src/main/java/org/apache/ofbiz/content/content/PermissionRecorder.java index 3bdbe1c..cbcbf6e 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/content/PermissionRecorder.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/content/PermissionRecorder.java @@ -31,23 +31,23 @@ import org.apache.ofbiz.entity.GenericValue; /** * PermissionRecorder Class - * + * <p> * Services for granting operation permissions on Content entities in a data-driven manner. */ public class PermissionRecorder { - protected boolean isOn = false; - protected GenericValue userLogin; - protected List<Map<String, Object>> permCheckResults = new LinkedList<>(); - protected boolean entityPermCheckResult = false; - protected String currentContentId = ""; - protected Map<String, Object> currentContentMap; - protected String privilegeEnumId; - protected int currentCheckMode; - protected GenericValue[] contentPurposeOperations; - protected String[] statusTargets; - protected String[] targetOperations; + private boolean isOn = false; + private GenericValue userLogin; + private List<Map<String, Object>> permCheckResults = new LinkedList<>(); + private boolean entityPermCheckResult = false; + private String currentContentId = ""; + private Map<String, Object> currentContentMap; + private String privilegeEnumId; + private int currentCheckMode; + private GenericValue[] contentPurposeOperations; + private String[] statusTargets; + private String[] targetOperations; private static final String MODULE = PermissionRecorder.class.getName(); @@ -58,68 +58,124 @@ public class PermissionRecorder { isOn = UtilProperties.propertyValueEqualsIgnoreCase("content", "permissionRecorderOn", "true"); } - public void setCheckMode(int val) { - currentCheckMode = val; - } - + /** + * Gets check mode. + * @return the check mode + */ public int getCheckMode() { return currentCheckMode; } + /** + * Sets check mode. + * @param val the val + */ + public void setCheckMode(int val) { + currentCheckMode = val; + } + + /** + * Is on boolean. + * @return the boolean + */ public boolean isOn() { return isOn; } + /** + * Sets on. + * @param b the b + */ public void setOn(boolean b) { isOn = b; } - public void setUserLogin(GenericValue user) { - userLogin = user; - } - + /** + * Gets user login. + * @return the user login + */ public GenericValue getUserLogin() { return userLogin; } + /** + * Sets user login. + * @param user the user + */ + public void setUserLogin(GenericValue user) { + userLogin = user; + } + + /** + * Gets entity perm check result. + * @return the entity perm check result + */ public boolean getEntityPermCheckResult() { return entityPermCheckResult; } + /** + * Sets entity perm check result. + * @param b the b + */ public void setEntityPermCheckResult(boolean b) { entityPermCheckResult = b; } + /** + * Get content purpose operations generic value [ ]. + * @return the generic value [ ] + */ public GenericValue[] getContentPurposeOperations() { - return contentPurposeOperations != null ? contentPurposeOperations.clone() : null; + return contentPurposeOperations != null ? contentPurposeOperations.clone() : null; } + /** + * Sets content purpose operations. + * @param opList the op list + */ public void setContentPurposeOperations(List<GenericValue> opList) { - contentPurposeOperations = opList.toArray(new GenericValue[opList.size()]); - } - - public void setPrivilegeEnumId(String id) { - privilegeEnumId = id; + contentPurposeOperations = opList.toArray(new GenericValue[opList.size()]); } + /** + * Gets privilege enum id. + * @return the privilege enum id + */ public String getPrivilegeEnumId() { return privilegeEnumId; } + /** + * Sets privilege enum id. + * @param id the id + */ + public void setPrivilegeEnumId(String id) { + privilegeEnumId = id; + } + + /** + * Get status targets string [ ]. + * @return the string [ ] + */ public String[] getStatusTargets() { - return statusTargets != null ? statusTargets.clone() : null; + return statusTargets != null ? statusTargets.clone() : null; } + /** + * Sets status targets. + * @param opList the op list + */ public void setStatusTargets(List<String> opList) { - statusTargets = opList.toArray(new String[opList.size()]); + statusTargets = opList.toArray(new String[opList.size()]); } public String[] getTargetOperations() { - return targetOperations != null ? targetOperations.clone() : null; + return targetOperations != null ? targetOperations.clone() : null; } public void setTargetOperations(List<String> opList) { - targetOperations = opList.toArray(new String[opList.size()]); + targetOperations = opList.toArray(new String[opList.size()]); } public void setCurrentContentId(String id) { @@ -132,29 +188,53 @@ public class PermissionRecorder { currentContentId = id; } + /** + * Gets current content id. + * @return the current content id + */ public String getCurrentContentId() { return currentContentId; } + /** + * Sets roles. + * @param roles the roles + */ public void setRoles(List<String> roles) { if (currentContentMap != null) { - if (roles != null) + if (roles != null) { currentContentMap.put("roles", roles.toArray()); - else + } else { currentContentMap.put("roles", null); + } } } + /** + * Sets purposes. + * @param purposes the purposes + */ public void setPurposes(List<String> purposes) { if (currentContentMap != null) { - if (purposes != null) + if (purposes != null) { currentContentMap.put("purposes", purposes.toArray()); - else + } else { currentContentMap.put("purposes", null); + } } } - public void startMatchGroup(List<String> targetOperations, List<String> purposes, List<String> roles, List<String> targStatusList, String targPrivilegeEnumId, String contentId) { + /** + * Start match group. + * @param targetOperations the target operations + * @param purposes the purposes + * @param roles the roles + * @param targStatusList the targ status list + * @param targPrivilegeEnumId the targ privilege enum id + * @param contentId the content id + */ + public void startMatchGroup(List<String> targetOperations, List<String> purposes, List<String> roles, List<String> targStatusList, + String targPrivilegeEnumId, String contentId) { currentContentMap = new HashMap<>(); permCheckResults.add(currentContentMap); String s = null; @@ -194,6 +274,10 @@ public class PermissionRecorder { checkResultList.add(map); } + /** + * To html string. + * @return the string + */ public String toHtml() { StringBuilder sb = new StringBuilder(); sb.append("<style type=\"text/css\">"); @@ -226,6 +310,11 @@ public class PermissionRecorder { return sb.toString(); } + /** + * Render current content map html string. + * @param cMap the c map + * @return the string + */ public String renderCurrentContentMapHtml(Map<String, Object> cMap) { StringBuilder sb = new StringBuilder(); List<Map<String, Object>> resultList = UtilGenerics.cast(cMap.get("checkResultList")); @@ -236,7 +325,12 @@ public class PermissionRecorder { return sb.toString(); } - + /** + * Render result row html string. + * @param rMap the r map + * @param currentContentResultMap the current content result map + * @return the string + */ public String renderResultRowHtml(Map<String, Object> rMap, Map<String, Object> currentContentResultMap) { StringBuilder sb = new StringBuilder(); @@ -253,10 +347,11 @@ public class PermissionRecorder { for (String opField : opFields) { sb.append("<td class=\"target\">"); s = (String) currentContentResultMap.get(opField); - if (s != null) + if (s != null) { str = s; - else + } else { str = " "; + } sb.append(str); sb.append("</td>"); } @@ -274,15 +369,16 @@ public class PermissionRecorder { for (String opField : opFields) { Boolean bool = (Boolean) rMap.get(opField + "Cond"); String cls = (bool) ? "pass" : "fail"; - if (!bool) + if (!bool) { isPass = false; + } sb.append("<td class=\"" + cls + "\">"); s = (String) rMap.get(opField); sb.append(s); sb.append("</td>"); } String passFailCls = (isPass) ? "pass" : "fail"; - sb.append("<td class=\"" + passFailCls +"\">" + passFailCls.toUpperCase(Locale.getDefault()) + "</td>"); + sb.append("<td class=\"" + passFailCls + "\">" + passFailCls.toUpperCase(Locale.getDefault()) + "</td>"); sb.append("</tr>"); return sb.toString(); diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/survey/SurveyWrapper.java b/applications/content/src/main/java/org/apache/ofbiz/content/survey/SurveyWrapper.java index acc482c..314e095 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/survey/SurveyWrapper.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/survey/SurveyWrapper.java @@ -62,18 +62,43 @@ public class SurveyWrapper { private static final String MODULE = SurveyWrapper.class.getName(); - protected Delegator delegator = null; - protected String responseId = null; - protected String partyId = null; - protected String surveyId = null; - protected Map<String, Object> templateContext = null; - protected Map<String, Object> passThru = null; - protected Map<String, Object> defaultValues = null; - protected boolean edit = false; + private Delegator delegator = null; + private String responseId = null; + private String partyId = null; + private String surveyId = null; + private Map<String, Object> templateContext = null; + private Map<String, Object> passThru = null; + private Map<String, Object> defaultValues = null; + private boolean edit = false; protected SurveyWrapper() { } - public SurveyWrapper(Delegator delegator, String responseId, String partyId, String surveyId, Map<String, Object> passThru, Map<String, Object> defaultValues) { + /** + * Sets delegator. + * @param delegator the delegator + */ + public void setDelegator(Delegator delegator) { + this.delegator = delegator; + } + + /** + * Sets party id. + * @param partyId the party id + */ + public void setPartyId(String partyId) { + this.partyId = partyId; + } + + /** + * Sets survey id. + * @param surveyId the survey id + */ + public void setSurveyId(String surveyId) { + this.surveyId = surveyId; + } + + public SurveyWrapper(Delegator delegator, String responseId, String partyId, String surveyId, Map<String, Object> passThru, + Map<String, Object> defaultValues) { this.delegator = delegator; this.responseId = responseId; this.partyId = partyId; @@ -91,6 +116,9 @@ public class SurveyWrapper { this(delegator, null, null, surveyId, null); } + /** + * Check parameters. + */ protected void checkParameters() { if (delegator == null || surveyId == null) { throw new IllegalArgumentException("Missing one or more required parameters (delegator, surveyId)"); @@ -217,8 +245,11 @@ public class SurveyWrapper { } } - // returns the FTL Template object - // Note: the template will not be cached + /** + * Gets template. + * @param templateUrl the template url + * @return the template + */ protected Template getTemplate(URL templateUrl) { Configuration config = FreeMarkerWorker.getDefaultOfbizConfig(); @@ -232,11 +263,15 @@ public class SurveyWrapper { return template; } + /** + * Sets edit. + * @param edit the edit + */ public void setEdit(boolean edit) { this.edit = edit; } - // returns the GenericValue object for the current Survey + /** returns the GenericValue object for the current Survey */ public GenericValue getSurvey() { GenericValue survey = null; try { @@ -247,6 +282,10 @@ public class SurveyWrapper { return survey; } + /** + * Gets survey name. + * @return the survey name + */ public String getSurveyName() { GenericValue survey = this.getSurvey(); if (survey != null) { @@ -255,7 +294,10 @@ public class SurveyWrapper { return ""; } - // true if we can update this survey + /** + * Can update boolean. + * @return the boolean + */ public boolean canUpdate() { if (this.edit) { return true; @@ -265,6 +307,10 @@ public class SurveyWrapper { return !(!"Y".equals(survey.getString("allowMultiple")) && !"Y".equals(survey.getString("allowUpdate"))); } + /** + * Can respond boolean. + * @return the boolean + */ public boolean canRespond() { String responseId = this.getThisResponseId(); if (responseId == null) { @@ -274,7 +320,7 @@ public class SurveyWrapper { return "Y".equals(survey.getString("allowMultiple")); } - // returns a list of SurveyQuestions (in order by sequence number) for the current Survey + /** returns a list of SurveyQuestions (in order by sequence number) for the current Survey */ public List<GenericValue> getSurveyQuestionAndAppls() { List<GenericValue> questions = new LinkedList<>(); @@ -290,7 +336,7 @@ public class SurveyWrapper { return questions; } - // returns the most current SurveyResponse ID for a survey; null if no party is found + /** returns the most current SurveyResponse ID for a survey; null if no party is found */ protected String getThisResponseId() { if (responseId != null) { return responseId; @@ -322,10 +368,19 @@ public class SurveyWrapper { return responseId; } + /** + * Sets this response id. + * @param responseId the response id + */ protected void setThisResponseId(String responseId) { this.responseId = responseId; } + /** + * Gets number responses. + * @return the number responses + * @throws SurveyWrapperException the survey wrapper exception + */ public long getNumberResponses() throws SurveyWrapperException { long responses = 0; try { @@ -336,6 +391,12 @@ public class SurveyWrapper { return responses; } + /** + * Gets survey responses. + * @param question the question + * @return the survey responses + * @throws SurveyWrapperException the survey wrapper exception + */ public List<GenericValue> getSurveyResponses(GenericValue question) throws SurveyWrapperException { List<GenericValue> responses = null; try { @@ -346,7 +407,7 @@ public class SurveyWrapper { return responses; } - // returns a Map of answers keyed on SurveyQuestion ID from the most current SurveyResponse ID + /** returns a Map of answers keyed on SurveyQuestion ID from the most current SurveyResponse ID */ public Map<String, Object> getResponseAnswers(String responseId) throws SurveyWrapperException { Map<String, Object> answerMap = new HashMap<>(); @@ -388,6 +449,14 @@ public class SurveyWrapper { return answerMap; } + /** + * Gets question responses. + * @param question the question + * @param startIndex the start index + * @param number the number + * @return the question responses + * @throws SurveyWrapperException the survey wrapper exception + */ public List<GenericValue> getQuestionResponses(GenericValue question, int startIndex, int number) throws SurveyWrapperException { List<GenericValue> resp = null; boolean beganTransaction = false; @@ -423,6 +492,12 @@ public class SurveyWrapper { return resp; } + /** + * Gets results. + * @param questions the questions + * @return the results + * @throws SurveyWrapperException the survey wrapper exception + */ public Map<String, Object> getResults(List<GenericValue> questions) throws SurveyWrapperException { Map<String, Object> questionResults = new HashMap<>(); if (questions != null) { @@ -436,7 +511,12 @@ public class SurveyWrapper { return questionResults; } - // returns a map of question reqsults + /** + * Gets result info. + * @param question the question + * @return the result info + * @throws SurveyWrapperException the survey wrapper exception + */ public Map<String, Object> getResultInfo(GenericValue question) throws SurveyWrapperException { Map<String, Object> resultMap = new HashMap<>(); 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 cd2ebdd..79f8122 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 @@ -48,9 +48,9 @@ import org.apache.ofbiz.service.ServiceUtil; public class BOMNode { private static final String MODULE = BOMNode.class.getName(); - protected LocalDispatcher dispatcher = null; - protected Delegator delegator = null; - protected GenericValue userLogin = null; + private LocalDispatcher dispatcher = null; + private Delegator delegator = null; + private GenericValue userLogin = null; private BOMTree tree; // the tree to which this node belongs private BOMNode parentNode; // the parent node (null if it's not present) @@ -89,6 +89,14 @@ public class BOMNode { this(EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(), dispatcher, userLogin); } + /** + * Load children. + * @param partBomTypeId the part bom type id + * @param inDate the in date + * @param productFeatures the product features + * @param type the type + * @throws GenericEntityException the generic entity exception + */ protected void loadChildren(String partBomTypeId, Date inDate, List<GenericValue> productFeatures, int type) throws GenericEntityException { if (product == null) { throw new GenericEntityException("product is null"); @@ -123,13 +131,14 @@ public class BOMNode { switch (type) { case BOMTree.EXPLOSION: oneChildNode.loadChildren(partBomTypeId, inDate, productFeatures, BOMTree.EXPLOSION); - break; + break; case BOMTree.EXPLOSION_MANUFACTURING: - // for manufacturing trees, do not look through and create production runs for children unless there is no warehouse stocking of this node item + // for manufacturing trees, do not look through and create production runs for children unless there is no warehouse + // stocking of this node item if (!oneChildNode.isWarehouseManaged(null)) { // FIXME: we will need to pass a facilityId here oneChildNode.loadChildren(partBomTypeId, inDate, productFeatures, type); } - break; + break; } } childrenNodes.add(oneChildNode); @@ -264,10 +273,10 @@ public class BOMNode { if (newNode.equals(oneChildNode)) { // If no substitution has been done (no valid rule applied), // we try to set the default (first) node-substitution - if (UtilValidate.isNotEmpty(genericNodeRules)) { + // if (UtilValidate.isNotEmpty(genericNodeRules)) { // FIXME //... - } + // } // ----------------------------------------------------------- // We try to apply directly the selected features if (newNode.equals(oneChildNode)) { @@ -319,6 +328,13 @@ public class BOMNode { return newNode; } + /** + * Load parents. + * @param partBomTypeId the part bom type id + * @param inDate the in date + * @param productFeatures the product features + * @throws GenericEntityException the generic entity exception + */ protected void loadParents(String partBomTypeId, Date inDate, List<GenericValue> productFeatures) throws GenericEntityException { if (product == null) { throw new GenericEntityException("product is null"); @@ -365,6 +381,10 @@ public class BOMNode { return parentNode; } + /** + * Gets root node. + * @return the root node + */ public BOMNode getRootNode() { return (parentNode != null ? getParentNode() : this); } @@ -375,7 +395,7 @@ public class BOMNode { this.parentNode = parentNode; } // ------------------------------------ - // Method used for TEST and DEBUG purposes + /** Method used for TEST and DEBUG purposes */ public void print(StringBuffer sb, BigDecimal quantity, int depth) { for (int i = 0; i < depth; i++) { sb.append("<b> * </b>"); @@ -402,6 +422,13 @@ public class BOMNode { } } + /** + * Print. + * @param arr the arr + * @param quantity the quantity + * @param depth the depth + * @param excludeWIPs the exclude wi ps + */ public void print(List<BOMNode> arr, BigDecimal quantity, int depth, boolean excludeWIPs) { // Now we set the depth and quantity of the current node // in this breakdown. @@ -418,7 +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"); @@ -460,6 +488,13 @@ public class BOMNode { } } + /** + * Gets products in packages. + * @param arr the arr + * @param quantity the quantity + * @param depth the depth + * @param excludeWIPs the exclude wi ps + */ public void getProductsInPackages(List<BOMNode> arr, BigDecimal quantity, int depth, boolean excludeWIPs) { // Now we set the depth and quantity of the current node // in this breakdown. @@ -483,6 +518,10 @@ public class BOMNode { } } + /** + * Sum quantity. + * @param nodes the nodes + */ public void sumQuantity(Map<String, BOMNode> nodes) { // First of all, we try to fetch a node with the same partId BOMNode sameNode = nodes.get(product.getString("productId")); @@ -630,7 +669,8 @@ public class BOMNode { if (UtilValidate.isEmpty(facilityId)) { pfs = getSubstitutedNode().getProduct().getRelated("ProductFacility", null, null, true); } else { - pfs = getSubstitutedNode().getProduct().getRelated("ProductFacility", UtilMisc.toMap("facilityId", facilityId), null, true); + pfs = getSubstitutedNode().getProduct().getRelated("ProductFacility", + UtilMisc.toMap("facilityId", facilityId), null, true); } } } @@ -645,7 +685,7 @@ public class BOMNode { } catch (GenericEntityException gee) { Debug.logError("Problem in BOMNode.isWarehouseManaged()", MODULE); } - return isWarehouseManaged; + return isWarehouseManaged; } /** @@ -656,7 +696,8 @@ public class BOMNode { public boolean isManufactured(boolean ignoreSupplierProducts) { List<GenericValue> supplierProducts = null; try { - supplierProducts = product.getRelated("SupplierProduct", UtilMisc.toMap("supplierPrefOrderId", "10_MAIN_SUPPL"), UtilMisc.toList("minimumOrderQuantity"), false); + supplierProducts = product.getRelated("SupplierProduct", UtilMisc.toMap("supplierPrefOrderId", "10_MAIN_SUPPL"), + UtilMisc.toList("minimumOrderQuantity"), false); } catch (GenericEntityException gee) { Debug.logError("Problem in BOMNode.isManufactured()", MODULE); } @@ -672,10 +713,18 @@ public class BOMNode { return isManufactured(false); } + /** + * Is virtual boolean. + * @return the boolean + */ public boolean isVirtual() { return (product.get("isVirtual") != null ? "Y".equals(product.get("isVirtual")) : false); } + /** + * Is configured. + * @param arr the arr + */ public void isConfigured(List<BOMNode> arr) { // First of all we visit the current node. if (isVirtual()) { @@ -698,6 +747,10 @@ public class BOMNode { return quantity; } + /** + * Sets quantity. + * @param quantity the quantity + */ public void setQuantity(BigDecimal quantity) { this.quantity = quantity; } @@ -710,6 +763,10 @@ public class BOMNode { return depth; } + /** + * Gets product. + * @return the product + */ public GenericValue getProduct() { return product; } @@ -728,6 +785,10 @@ public class BOMNode { this.substitutedNode = substitutedNode; } + /** + * Gets root product for rules. + * @return the root product for rules + */ public String getRootProductForRules() { return getParentNode().getProductForRules(); } @@ -827,10 +888,18 @@ public class BOMNode { this.productAssoc = productAssoc; } + /** + * Sets tree. + * @param tree the tree + */ public void setTree(BOMTree tree) { this.tree = tree; } + /** + * Gets tree. + * @return the tree + */ public BOMTree getTree() { return tree; } diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java index c79d021..57dbe20 100644 --- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java +++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRun.java @@ -49,19 +49,19 @@ public class ProductionRun { private static final String MODULE = ProductionRun.class.getName(); private static final String RESOURCE = "ManufacturingUiLabels"; - protected GenericValue productionRun; // WorkEffort (PROD_ORDER_HEADER) - protected GenericValue productionRunProduct; // WorkEffortGoodStandard (type: PRUN_PROD_DELIV) - protected GenericValue productProduced; // Product (from WorkEffortGoodStandard of type: PRUN_PROD_DELIV) - protected BigDecimal quantity; // the estimatedQuantity + private GenericValue productionRun; // WorkEffort (PROD_ORDER_HEADER) + private GenericValue productionRunProduct; // WorkEffortGoodStandard (type: PRUN_PROD_DELIV) + private GenericValue productProduced; // Product (from WorkEffortGoodStandard of type: PRUN_PROD_DELIV) + private BigDecimal quantity; // the estimatedQuantity - protected Timestamp estimatedStartDate; - protected Timestamp estimatedCompletionDate; - protected String productionRunName; - protected String description; - protected GenericValue currentStatus; - protected List<GenericValue> productionRunComponents; - protected List<GenericValue> productionRunRoutingTasks; - protected LocalDispatcher dispatcher; + private Timestamp estimatedStartDate; + private Timestamp estimatedCompletionDate; + private String productionRunName; + private String description; + private GenericValue currentStatus; + private List<GenericValue> productionRunComponents; + private List<GenericValue> productionRunRoutingTasks; + private LocalDispatcher dispatcher; /** * indicate if quantity or estimatedStartDate has been modified and @@ -81,7 +81,8 @@ public class ProductionRun { if (workEffort != null) { // If this is a task, get the parent production run if (workEffort.getString("workEffortTypeId") != null && "PROD_ORDER_TASK".equals(workEffort.getString("workEffortTypeId"))) { - workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", workEffort.getString("workEffortParentId")).queryOne(); + workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", + workEffort.getString("workEffortParentId")).queryOne(); } } this.productionRun = workEffort; @@ -167,7 +168,8 @@ public class ProductionRun { if (exist()) { if (productProduced == null) { try { - 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); this.productionRunProduct = EntityUtil.getFirst(productionRunProducts); quantity = productionRunProduct.getBigDecimal("estimatedQuantity"); productProduced = productionRunProduct.getRelatedOne("Product", true); @@ -186,10 +188,9 @@ public class ProductionRun { **/ public BigDecimal getQuantity() { if (exist()) { - if (quantity == null) getProductProduced(); + if (quantity == null) getProductProduced(); return quantity; - } - else return null; + } else return null; } /** * set the quantity property and recalculated the productComponent quantity. @@ -197,14 +198,16 @@ public class ProductionRun { **/ public void setQuantity(BigDecimal newQuantity) { if (quantity == null) getProductProduced(); - BigDecimal previousQuantity = quantity, componentQuantity; + BigDecimal previousQuantity = quantity; + BigDecimal componentQuantity; this.quantity = newQuantity; this.quantityIsUpdated = true; this.updateCompletionDate = true; if (productionRunComponents == null) getProductionRunComponents(); for (GenericValue component : productionRunComponents) { componentQuantity = component.getBigDecimal("estimatedQuantity"); - component.set("estimatedQuantity", componentQuantity.divide(previousQuantity, 10, RoundingMode.HALF_UP).multiply(newQuantity).doubleValue()); + component.set("estimatedQuantity", componentQuantity.divide(previousQuantity, 10, RoundingMode.HALF_UP).multiply(newQuantity) + .doubleValue()); } } /** @@ -212,7 +215,7 @@ public class ProductionRun { * @return the estimatedStartDate property **/ public Timestamp getEstimatedStartDate() { - return (exist()? this.estimatedStartDate: null); + return (exist() ? this.estimatedStartDate : null); } /** * set the estimatedStartDate property. @@ -232,8 +235,7 @@ public class ProductionRun { this.estimatedCompletionDate = recalculateEstimatedCompletionDate(); } return this.estimatedCompletionDate; - } - else return null; + } else return null; } /** * set the estimatedCompletionDate property without any control or calculation. @@ -255,7 +257,7 @@ public class ProductionRun { if (exist()) { getProductionRunRoutingTasks(); if (quantity == null) getQuantity(); - Timestamp endDate=null; + Timestamp endDate = null; for (GenericValue routingTask : productionRunRoutingTasks) { if (priority.compareTo(routingTask.getLong("priority")) <= 0) { // Calculate the estimatedCompletionDate @@ -287,7 +289,12 @@ public class ProductionRun { if (exist()) return this.productionRunName; else return null; } - public void setProductionRunName(String name) { + + /** + * Sets production run name. + * @param name the name + */ + public void setProductionRunName(String name) { this.productionRunName = name; } /** @@ -298,6 +305,11 @@ public class ProductionRun { if (exist()) return productionRun.getString("description"); else return null; } + + /** + * Sets description. + * @param description the description + */ public void setDescription(String description) { this.description = description; } @@ -325,7 +337,7 @@ public class ProductionRun { public List<GenericValue> getProductionRunComponents() { if (exist()) { if (productionRunComponents == null) { - if (productionRunRoutingTasks == null) this.getProductionRunRoutingTasks(); + if (productionRunRoutingTasks == null) this.getProductionRunRoutingTasks(); if (productionRunRoutingTasks != null) { try { productionRunComponents = new LinkedList<>(); @@ -352,7 +364,8 @@ public class ProductionRun { if (exist()) { if (productionRunRoutingTasks == null) { try { - productionRunRoutingTasks = productionRun.getRelated("ChildWorkEffort", UtilMisc.toMap("workEffortTypeId", "PROD_ORDER_TASK"), UtilMisc.toList("priority"), false); + productionRunRoutingTasks = productionRun.getRelated("ChildWorkEffort", + UtilMisc.toMap("workEffortTypeId", "PROD_ORDER_TASK"), UtilMisc.toList("priority"), false); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), MODULE); } @@ -370,7 +383,8 @@ public class ProductionRun { if (exist()) { if (productionRunRoutingTasks == null) { try { - productionRunRoutingTasks = productionRun.getRelated("ChildWorkEffort", UtilMisc.toMap("workEffortTypeId", "PROD_ORDER_TASK"), UtilMisc.toList("priority"), false); + productionRunRoutingTasks = productionRun.getRelated("ChildWorkEffort", + UtilMisc.toMap("workEffortTypeId", "PROD_ORDER_TASK"), UtilMisc.toList("priority"), false); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), MODULE); } @@ -419,7 +433,8 @@ public class ProductionRun { serviceName = genericService.getString("customMethodName"); // call the service // and put the value in totalTaskTime - Map<String, Object> estimateCalcServiceMap = UtilMisc.<String, Object>toMap("workEffort", task, "quantity", quantity, "productId", productId, "routingId", routingId); + Map<String, Object> estimateCalcServiceMap = UtilMisc.<String, Object>toMap("workEffort", task, "quantity", quantity, "productId", + productId, "routingId", routingId); Map<String, Object> serviceContext = UtilMisc.<String, Object>toMap("arguments", estimateCalcServiceMap); Map<String, Object> serviceResult = dispatcher.runSync(serviceName, serviceContext); if (ServiceUtil.isError(serviceResult)) { @@ -436,6 +451,10 @@ public class ProductionRun { return (long) totalTaskTime; } + /** + * Is update completion date boolean. + * @return the boolean + */ public boolean isUpdateCompletionDate() { return updateCompletionDate; } diff --git a/applications/marketing/src/main/java/org/apache/ofbiz/marketing/report/ReportHelper.java b/applications/marketing/src/main/java/org/apache/ofbiz/marketing/report/ReportHelper.java index 29823f9..ea93902 100644 --- a/applications/marketing/src/main/java/org/apache/ofbiz/marketing/report/ReportHelper.java +++ b/applications/marketing/src/main/java/org/apache/ofbiz/marketing/report/ReportHelper.java @@ -1,3 +1,4 @@ + /******************************************************************************* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -69,7 +70,7 @@ public final class ReportHelper { reportValue.put("orderAmount", orderValue.getDouble("grandTotal")); } if ((orderValue.getLong("orderId") == null) || (visit.getLong("visitId") == null) - || (visit.getLong("visitId").intValue() == 0)) { + || (visit.getLong("visitId").intValue() == 0)) { reportValue.put("conversionRate", (double) 0); } else { reportValue.put("conversionRate", orderValue.getLong("orderId").doubleValue() / visit.getLong("visitId").doubleValue()); diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java index 54495d3..21cd1a9 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderContentWrapper.java @@ -49,18 +49,19 @@ import org.apache.ofbiz.service.LocalDispatcher; public class OrderContentWrapper implements ContentWrapper { private static final String MODULE = OrderContentWrapper.class.getName(); - public static final String SEPARATOR = "::"; // cache key separator + private static final String SEPARATOR = "::"; // cache key separator - private static final UtilCache<String, String> orderContentCache = UtilCache.createUtilCache("order.content", true); // use soft reference to free up memory if needed + private static final UtilCache<String, String> ORDER_CONTENT_CACHE = UtilCache.createUtilCache("order.content", true); + // use soft reference to free up memory if needed public static OrderContentWrapper makeOrderContentWrapper(GenericValue order, HttpServletRequest request) { return new OrderContentWrapper(order, request); } - protected LocalDispatcher dispatcher; - protected GenericValue order; - protected Locale locale; - protected String mimeTypeId; + private LocalDispatcher dispatcher; + private GenericValue order; + private Locale locale; + private String mimeTypeId; public OrderContentWrapper(LocalDispatcher dispatcher, GenericValue order, Locale locale, String mimeTypeId) { this.dispatcher = dispatcher; @@ -73,35 +74,41 @@ public class OrderContentWrapper implements ContentWrapper { this.dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); this.order = order; 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 public StringUtil.StringWrapper get(String orderContentTypeId, String encoderType) { - return StringUtil.makeStringWrapper(getOrderContentAsText(order, orderContentTypeId, locale, mimeTypeId, order.getDelegator(), dispatcher, encoderType)); + return StringUtil.makeStringWrapper(getOrderContentAsText(order, orderContentTypeId, locale, mimeTypeId, order.getDelegator(), dispatcher, + encoderType)); } public static String getOrderContentAsText(GenericValue order, String orderContentTypeId, HttpServletRequest request, String encoderType) { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); String mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", order.getDelegator()); - return getOrderContentAsText(order, orderContentTypeId, UtilHttp.getLocale(request), mimeTypeId, order.getDelegator(), dispatcher, encoderType); + return getOrderContentAsText(order, orderContentTypeId, UtilHttp.getLocale(request), mimeTypeId, order.getDelegator(), dispatcher, + encoderType); } - public static String getOrderContentAsText(GenericValue order, String orderContentTypeId, Locale locale, LocalDispatcher dispatcher, String encoderType) { + public static String getOrderContentAsText(GenericValue order, String orderContentTypeId, Locale locale, LocalDispatcher dispatcher, + String encoderType) { return getOrderContentAsText(order, orderContentTypeId, locale, null, null, dispatcher, encoderType); } - public static String getOrderContentAsText(GenericValue order, String orderContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, String encoderType) { + public static String getOrderContentAsText(GenericValue order, String orderContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, + LocalDispatcher dispatcher, String encoderType) { /* caching: there is one cache created, "order.content" Each order's content is cached with a key of * contentTypeId::locale::mimeType::orderId::orderItemSeqId, or whatever the SEPARATOR is defined above to be. */ UtilCodec.SimpleEncoder encoder = UtilCodec.getEncoder(encoderType); - String orderItemSeqId = ("OrderItem".equals(order.getEntityName())? order.getString("orderItemSeqId"): "_NA_"); + String orderItemSeqId = ("OrderItem".equals(order.getEntityName()) ? order.getString("orderItemSeqId") : "_NA_"); - String cacheKey = orderContentTypeId + SEPARATOR + locale + SEPARATOR + mimeTypeId + SEPARATOR + order.get("orderId") + SEPARATOR + orderItemSeqId + SEPARATOR + encoderType + SEPARATOR + delegator; + String cacheKey = orderContentTypeId + SEPARATOR + locale + SEPARATOR + mimeTypeId + SEPARATOR + order.get("orderId") + SEPARATOR + + orderItemSeqId + SEPARATOR + encoderType + SEPARATOR + delegator; try { - String cachedValue = orderContentCache.get(cacheKey); + String cachedValue = ORDER_CONTENT_CACHE.get(cacheKey); if (cachedValue != null) { return cachedValue; } @@ -110,7 +117,7 @@ public class OrderContentWrapper implements ContentWrapper { getOrderContentAsText(null, null, order, orderContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter, false); String outString = outWriter.toString(); outString = encoder.sanitize(outString, null); - orderContentCache.put(cacheKey, outString); + ORDER_CONTENT_CACHE.put(cacheKey, outString); return outString; } catch (GeneralException | IOException e) { @@ -119,16 +126,19 @@ public class OrderContentWrapper implements ContentWrapper { } } - public static void getOrderContentAsText(String orderId, String orderItemSeqId, GenericValue order, String orderContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { + public static void getOrderContentAsText(String orderId, String orderItemSeqId, GenericValue order, String orderContentTypeId, Locale locale, + String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { getOrderContentAsText(orderId, orderItemSeqId, order, orderContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter, true); } - public static void getOrderContentAsText(String orderId, String orderItemSeqId, GenericValue order, String orderContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, boolean cache) throws GeneralException, IOException { + public static void getOrderContentAsText(String orderId, String orderItemSeqId, GenericValue order, String orderContentTypeId, Locale locale, + String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, boolean cache) + throws GeneralException, IOException { if (orderId == null && order != null) { orderId = order.getString("orderId"); } if (orderItemSeqId == null && order != null) { - orderItemSeqId = ("OrderItem".equals(order.getEntityName())? order.getString("orderItemSeqId"): "_NA_"); + orderItemSeqId = ("OrderItem".equals(order.getEntityName())? order.getString("orderItemSeqId") : "_NA_"); } if (delegator == null && order != null) { @@ -150,7 +160,8 @@ public class OrderContentWrapper implements ContentWrapper { Map<String, Object> inContext = new HashMap<>(); inContext.put("order", order); inContext.put("orderContent", orderContent); - ContentWorker.renderContentAsText(dispatcher, orderContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache); + ContentWorker.renderContentAsText(dispatcher, orderContent.getString("contentId"), outWriter, inContext, locale, + mimeTypeId, null, null, cache); } } } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderListState.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderListState.java index 71991e0..be01017 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderListState.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderListState.java @@ -159,7 +159,8 @@ public class OrderListState implements Serializable { viewSize = Integer.parseInt(viewSizeParam); viewIndex = Integer.parseInt(viewIndexParam); } catch (NumberFormatException e) { - Debug.logWarning("Values of " + VIEW_SIZE_PARAM + " ["+viewSizeParam+"] and " + VIEW_INDEX_PARAM + " ["+viewIndexParam+"] must both be Integers. Not paginating order list.", MODULE); + Debug.logWarning("Values of " + VIEW_SIZE_PARAM + " [" + viewSizeParam + "] and " + VIEW_INDEX_PARAM + " [" + viewIndexParam + + "] must both be Integers. Not paginating order list.", MODULE); } } @@ -190,22 +191,80 @@ public class OrderListState implements Serializable { } viewIndex = 0; } + //============== Get and Set methods =================// + /** + * Gets order status state. + * @return the order status state + */ + public Map<String, String> getOrderStatusState() { + return orderStatusState; + } + /** + * Gets order type state. + * @return the order type state + */ + public Map<String, String> getOrderTypeState() { + return orderTypeState; + } - //============== Get and Set methods =================// + /** + * Gets filter state. + * @return the filter state + */ + public Map<String, String> getorderFilterState() { + return orderFilterState; + } + /** + * Sets status. + * @param param the param + * @param b the b + */ + public void setStatus(String param, boolean b) { + orderStatusState.put(param, (b ? "Y" : "N")); + } - public Map<String, String> getOrderStatusState() { return orderStatusState; } - public Map<String, String> getOrderTypeState() { return orderTypeState; } - public Map<String, String> getorderFilterState() { return orderFilterState; } + /** + * Sets type. + * @param param the param + * @param b the b + */ + public void setType(String param, boolean b) { + orderTypeState.put(param, (b ? "Y" : "N")); + } - public void setStatus(String param, boolean b) { orderStatusState.put(param, (b ? "Y" : "N")); } - public void setType(String param, boolean b) { orderTypeState.put(param, (b ? "Y" : "N")); } + /** + * Has status boolean. + * @param param the param + * @return the boolean + */ + public boolean hasStatus(String param) { + return ("Y".equals(orderStatusState.get(param))); + } - public boolean hasStatus(String param) { return ("Y".equals(orderStatusState.get(param))); } - public boolean hasType(String param) { return ("Y".equals(orderTypeState.get(param))); } - public boolean hasFilter(String param) { return ("Y".equals(orderFilterState.get(param))); } + /** + * Has type boolean. + * @param param the param + * @return the boolean + */ + public boolean hasType(String param) { + return ("Y".equals(orderTypeState.get(param))); + } + /** + * Has filter boolean. + * @param param the param + * @return the boolean + */ + public boolean hasFilter(String param) { + return ("Y".equals(orderFilterState.get(param))); + } + + /** + * Has all status boolean. + * @return the boolean + */ public boolean hasAllStatus() { for (String string : orderStatusState.values()) { if (!"Y".equals(string)) { @@ -215,12 +274,45 @@ public class OrderListState implements Serializable { return true; } - public int getViewSize() { return viewSize; } - public int getViewIndex() { return viewIndex; } - public int getSize() { return orderListSize; } + /** + * Gets view size. + * @return the view size + */ + public int getViewSize() { + return viewSize; + } + + /** + * Gets view index. + * @return the view index + */ + public int getViewIndex() { + return viewIndex; + } - public boolean hasPrevious() { return (viewIndex > 0); } - public boolean hasNext() { return (viewIndex < getSize() / viewSize); } + /** + * Gets size. + * @return the size + */ + public int getSize() { + return orderListSize; + } + + /** + * Has previous boolean. + * @return the boolean + */ + public boolean hasPrevious() { + return (viewIndex > 0); + } + + /** + * Has next boolean. + * @return the boolean + */ + public boolean hasNext() { + return (viewIndex < getSize() / viewSize); + } /** * Get the OrderHeaders corresponding to the state. 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 60235d2..955405e 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 @@ -169,7 +169,7 @@ public class OrderServices { UtilMisc.toMap("roleTypeIdFrom", "SALES_REP", "roleTypeIdTo", "CUSTOMER", "partyIdTo", partyId), null, false)); } catch (GenericEntityException ex) { Debug.logError("Could not determine if " + partyId + " is a customer of user " + userLogin.getString("userLoginId") - + " due to " + ex.getMessage(), MODULE); + + " due to " + ex.getMessage(), MODULE); } if ((repsCustomers != null) && (repsCustomers.size() > 0) && (security.hasEntityPermission("ORDERMGR", "_ROLE_" + action, userLogin))) { @@ -1333,7 +1333,7 @@ public class OrderServices { // If the product is a marketing package auto, attempt to create enough packages to bring ATP back to 0, won't // necessarily create enough to cover this order. if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), - "parentTypeId", "MARKETING_PKG_AUTO")) { + "parentTypeId", "MARKETING_PKG_AUTO")) { // do something tricky here: run as the "system" user // that can actually create and run a production run GenericValue permUserLogin = @@ -1427,7 +1427,7 @@ public class OrderServices { String invErrMsg = "The product "; invErrMsg += getProductName(product, orderItem); invErrMsg += " with ID " + orderItem.getString("productId") + " is no longer in stock. Please try " - + "reducing the quantity or removing the product from this order."; + + "reducing the quantity or removing the product from this order."; resErrorMessages.add(invErrMsg); } } @@ -2046,8 +2046,8 @@ public class OrderServices { } } } catch (GenericEntityException e) { - String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderDatabaseErrorCheckingIfWeShouldChangeOrderHeaderStatusToApproved" - , UtilMisc.toMap("errorString", e.toString()), locale); + String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderDatabaseErrorCheckingIfWeShouldChangeOrderHeaderStatusToApproved", + UtilMisc.toMap("errorString", e.toString()), locale); Debug.logError(e, errMsg, MODULE); return ServiceUtil.returnError(errMsg); } @@ -2077,7 +2077,7 @@ public class OrderServices { // now set the new order status if (newStatus != null && !newStatus.equals(orderHeaderStatusId)) { Map<String, Object> serviceContext = UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", newStatus, "userLogin", - userLogin); + userLogin); Map<String, Object> newSttsResult = null; try { newSttsResult = dispatcher.runSync("changeOrderStatus", serviceContext); @@ -2283,14 +2283,14 @@ public class OrderServices { if ("ITEM_COMPLETED".equals(itemStatus) && "SALES_ORDER".equals(orh.getOrderTypeId())) { //If partial item shipped then release remaining inventory of SO item and marked SO item as completed. Map<String, Object> cancelOrderItemInvResCtx = UtilMisc.toMap("orderId", orderId, "orderItemSeqId", - orderItem.getString("orderItemSeqId"), "shipGroupSeqId", + orderItem.getString("orderItemSeqId"), "shipGroupSeqId", shipGroupSeqId, "cancelQuantity", thisCancelQty, "userLogin", userLogin); try { dispatcher.runSyncIgnore("cancelOrderItemInvResQty", cancelOrderItemInvResCtx); } catch (GenericServiceException e) { Debug.logError(e, MODULE); return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderUnableToUpdateInventoryReservations", - UtilMisc.toMap("itemMsgInfo", itemMsgInfo), locale)); + UtilMisc.toMap("itemMsgInfo", itemMsgInfo), locale)); } } // all items are cancelled -- mark the item as cancelled @@ -3375,8 +3375,8 @@ public class OrderServices { Map<String, Object> invoiceResult = null; try { GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); - Map<String, Object> invoiceContext = UtilMisc.<String, Object>toMap("orderId", orderId, "billItems", itemsToInvoice, "userLogin" - , permUserLogin); + Map<String, Object> invoiceContext = UtilMisc.<String, Object>toMap("orderId", orderId, "billItems", itemsToInvoice, "userLogin", + permUserLogin); invoiceResult = dispatcher.runSync("createInvoiceForOrder", invoiceContext); if (ServiceUtil.isError(invoiceResult)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(invoiceResult)); @@ -7097,7 +7097,7 @@ public class OrderServices { exprs.add(EntityCondition.makeCondition("orderItemSeqId", orderItemSeqId)); } else { exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_IN, UtilMisc.toList("ALLOC_PLAN_ITEM_CMPL", - "ALLOC_PLAN_ITEM_CNCL"))); + "ALLOC_PLAN_ITEM_CNCL"))); } List<GenericValue> allocationPlanItems = EntityQuery.use(delegator).from("AllocationPlanItem").where(exprs).queryList(); @@ -7172,7 +7172,8 @@ public class OrderServices { BigDecimal quantityChanged = orderItemChange.getBigDecimal("quantity"); if (quantityChanged.compareTo(BigDecimal.ZERO) < 0) { GenericValue allocationPlanItem = EntityQuery.use(delegator).from("AllocationPlanItem").where("orderId", orderId, - "orderItemSeqId", orderItemSeqId, "statusId", "ALLOC_PLAN_ITEM_CRTD", "productId", orderItem.getString("productId")).queryFirst(); + "orderItemSeqId", orderItemSeqId, "statusId", "ALLOC_PLAN_ITEM_CRTD", "productId", orderItem.getString("productId")) + .queryFirst(); if (allocationPlanItem != null) { BigDecimal revisedQuantity = orderItem.getBigDecimal("quantity"); BigDecimal allocatedQuantity = allocationPlanItem.getBigDecimal("allocatedQuantity"); 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 2c4ea2f..3005257 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 @@ -409,7 +409,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { public void setOrderName(String orderName) { this.orderName = orderName; } - + /** get order name */ public String getOrderName() { return orderName; } @@ -483,14 +483,25 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } // uh oh, not good, should always be passed in on init, we can't really do // anything without it, so throw an exception - throw new IllegalStateException( - "The Currency UOM is not set in the shopping cart, this is not a valid state, it should always be passed in when the cart is created."); + throw new IllegalStateException("The Currency UOM is not set in the shopping cart, this is not a valid state," + + "it should always be passed in when the cart is created."); } + /** + * Gets cart created time. + * @return the cart created time + */ public Timestamp getCartCreatedTime() { return this.cartCreatedTs != null ? (Timestamp) this.cartCreatedTs.clone() : null; } + /** + * Gets supplier product. + * @param productId the product id + * @param quantity the quantity + * @param dispatcher the dispatcher + * @return the supplier product + */ public GenericValue getSupplierProduct(String productId, BigDecimal quantity, LocalDispatcher dispatcher) { GenericValue supplierProduct = null; Map<String, Object> params = UtilMisc.<String, Object>toMap("productId", productId, @@ -508,7 +519,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { if ((productSuppliers != null) && (productSuppliers.size() > 0)) { supplierProduct = productSuppliers.get(0); } - } catch (GenericServiceException e) { + } catch (GenericServiceException e) { Debug.logWarning(UtilProperties.getMessage(RES_ERROR, "OrderRunServiceGetSuppliersForProductError", locale) + e.getMessage(), MODULE); } return supplierProduct; @@ -522,36 +533,45 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * @return the new/increased item index * @throws CartItemModifyException */ - public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, - Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, String prodCatalogId, - ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException { + public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, + BigDecimal reservPersons, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, + Map<String, Object> attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, + String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException { - return addOrIncreaseItem(productId, selectedAmount, quantity, reservStart, reservLength, reservPersons, null, null, shipBeforeDate, shipAfterDate, features, attributes, prodCatalogId, - configWrapper, itemType, itemGroupNumber, parentProductId, dispatcher); + return addOrIncreaseItem(productId, selectedAmount, quantity, reservStart, reservLength, reservPersons, null, null, shipBeforeDate, + shipAfterDate, features, attributes, prodCatalogId, configWrapper, itemType, itemGroupNumber, parentProductId, dispatcher); } /** add rental (with accommodation) item to cart */ - public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, - String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, - String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException { - return addOrIncreaseItem(productId, selectedAmount, quantity, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, features, attributes, null, prodCatalogId, configWrapper, itemType, itemGroupNumber, parentProductId, dispatcher); + public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, + BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, + Map<String, GenericValue> features, Map<String, Object> attributes, String prodCatalogId, ProductConfigWrapper configWrapper, + String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) + throws CartItemModifyException, ItemNotFoundException { + return addOrIncreaseItem(productId, selectedAmount, quantity, reservStart, reservLength, reservPersons, accommodationMapId, + accommodationSpotId, shipBeforeDate, shipAfterDate, features, attributes, null, prodCatalogId, configWrapper, itemType, + itemGroupNumber, parentProductId, dispatcher); } /** add rental (with accommodation) item to cart and order item attributes*/ // TODO change method signature, this one is really scary, above are not bad too :/ ! - public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, - String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, - Map<String, String> orderItemAttributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, - String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException { - return addOrIncreaseItem(productId, selectedAmount, quantity, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, null, features, attributes, orderItemAttributes, prodCatalogId, configWrapper, itemType, itemGroupNumber, parentProductId, dispatcher); + public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, + BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, + Map<String, GenericValue> features, Map<String, Object> attributes, Map<String, String> orderItemAttributes, String prodCatalogId, + ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) + throws CartItemModifyException, ItemNotFoundException { + return addOrIncreaseItem(productId, selectedAmount, quantity, reservStart, reservLength, reservPersons, accommodationMapId, + accommodationSpotId, shipBeforeDate, shipAfterDate, null, features, attributes, orderItemAttributes, prodCatalogId, configWrapper, + itemType, itemGroupNumber, parentProductId, dispatcher); } /** add rental (with accommodation) item to cart and order item attributes*/ // TODO change method signature, this one is really scary, above are not bad too :/ ! - public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, - String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, Timestamp reserveAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, - Map<String, String> orderItemAttributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, - String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException { + public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, + BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, + Timestamp reserveAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, Map<String, String> orderItemAttributes, + String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, + LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException { if (isReadOnlyCart()) { throw new CartItemModifyException("Cart items cannot be changed"); } @@ -567,7 +587,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { ShoppingCartItem sci = cartLines.get(i); - if (sci.equals(productId, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, features, attributes, orderItemAttributes, prodCatalogId, selectedAmount, configWrapper, itemType, itemGroup, false)) { + if (sci.equals(productId, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, features, attributes, + orderItemAttributes, prodCatalogId, selectedAmount, configWrapper, itemType, itemGroup, false)) { BigDecimal newQuantity = sci.getQuantity().add(quantity); try { BigDecimal minQuantity = getMinimumOrderQuantity(getDelegator(), sci.getBasePrice(), productId); @@ -627,8 +648,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { Debug.logError(e, MODULE); } item = ShoppingCartItem.makeItem(0, productId, selectedAmount, quantity, null, - reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, reserveAfterDate, - features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, + reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, + reserveAfterDate, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, this, Boolean.TRUE, Boolean.TRUE, parentProductId, Boolean.FALSE, Boolean.FALSE); } // add order item attributes @@ -649,7 +670,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { public int addNonProductItem(String itemType, String description, String categoryId, BigDecimal price, BigDecimal quantity, Map<String, Object> attributes, String prodCatalogId, String itemGroupNumber, LocalDispatcher dispatcher) throws CartItemModifyException { ShoppingCart.ShoppingCartItemGroup itemGroup = this.getItemGroupByNumber(itemGroupNumber); - return this.addItem(0, ShoppingCartItem.makeItem(0, itemType, description, categoryId, price, null, quantity, attributes, prodCatalogId, itemGroup, dispatcher, this, Boolean.TRUE)); + return this.addItem(0, ShoppingCartItem.makeItem(0, itemType, description, categoryId, price, null, quantity, attributes, + prodCatalogId, itemGroup, dispatcher, this, Boolean.TRUE)); } /** Add an item to the shopping cart. */ @@ -688,9 +710,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * Add an item to the shopping cart. */ public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, HashMap<String, GenericValue> features, - HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, - Boolean triggerExternalOps, - Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException { + HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, + Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(productId, amount, quantity, unitPrice, features, attributes, prodCatalogId, itemType, dispatcher, triggerExternalOps, triggerPriceRules, Boolean.FALSE, Boolean.FALSE); } @@ -699,8 +720,9 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * Add an (rental)item to the shopping cart. */ public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, - BigDecimal reservLength, BigDecimal reservPersons, HashMap<String, GenericValue> features, HashMap<String, Object> attributes, - String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException { + BigDecimal reservLength, BigDecimal reservPersons, HashMap<String, GenericValue> features, HashMap<String, Object> attributes, + String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) + throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, Boolean.FALSE, Boolean.FALSE)); @@ -710,9 +732,9 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * Add an (rental)item to the shopping cart. */ public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, - BigDecimal reservLength, BigDecimal reservPersons, HashMap<String, GenericValue> features, HashMap<String, Object> attributes, - String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, - Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { + BigDecimal reservLength, BigDecimal reservPersons, HashMap<String, GenericValue> features, HashMap<String, Object> attributes, + String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, + Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks)); @@ -722,9 +744,10 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * Add an (rental/aggregated)item to the shopping cart. */ public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, - BigDecimal reservLength, BigDecimal reservPersons, HashMap<String, GenericValue> features, HashMap<String, Object> attributes, - String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, - Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { + BigDecimal reservLength, BigDecimal reservPersons, HashMap<String, GenericValue> features, HashMap<String, Object> attributes, + String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, + Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) + throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, null, null, features, attributes, prodCatalogId, configWrapper, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks)); @@ -734,8 +757,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * Add an accommodation(rental)item to the shopping cart. */ public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, - BigDecimal reservLength, BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, - HashMap<String, GenericValue> features, HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, + BigDecimal reservLength, BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, + HashMap<String, GenericValue> features, HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, @@ -746,8 +769,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * Add an accommodation(rental)item to the shopping cart. */ public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, - BigDecimal reservLength, BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, - HashMap<String, GenericValue> features, HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, + BigDecimal reservLength, BigDecimal reservPersons, String accommodationMapId, String accommodationSpotId, + HashMap<String, GenericValue> features, HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, @@ -758,10 +781,10 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * Add an accommodation(rental/aggregated)item to the shopping cart. */ public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, Timestamp reservStart, - BigDecimal reservLength, BigDecimal reservPersonsDbl, String accommodationMapId, String accommodationSpotId, - HashMap<String, GenericValue> features, HashMap<String, Object> attributes, String prodCatalogId, - ProductConfigWrapper configWrapper, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, - Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, + BigDecimal reservLength, BigDecimal reservPersonsDbl, String accommodationMapId, String accommodationSpotId, + HashMap<String, GenericValue> features, HashMap<String, Object> attributes, String prodCatalogId, + ProductConfigWrapper configWrapper, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, + Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersonsDbl, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, configWrapper, itemType, null, dispatcher, this, @@ -772,8 +795,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * Add an item to the shopping cart. */ public int addItemToEnd(String productId, BigDecimal amount, BigDecimal quantity, BigDecimal unitPrice, HashMap<String, GenericValue> features, - HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, - Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { + HashMap<String, Object> attributes, String prodCatalogId, String itemType, LocalDispatcher dispatcher, Boolean triggerExternalOps, + Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException { return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, null, null, null, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks)); } @@ -819,7 +842,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return itemsToReturn; } - /** Get all ShoppingCartItems from the cart object with the given productCategoryId and optional groupNumber to limit it to a specific item group */ + /** Get all ShoppingCartItems from the cart object with the given productCategoryId and + * optional groupNumber to limit it to a specific item group */ public List<ShoppingCartItem> findAllCartItemsInCategory(String productCategoryId, String groupNumber) { if (productCategoryId == null) { return this.items(); @@ -1078,6 +1102,11 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return cartLines.iterator(); } + /** + * Gets item group by number. + * @param groupNumber the group number + * @return the item group by number + */ public ShoppingCart.ShoppingCartItemGroup getItemGroupByNumber(String groupNumber) { if (UtilValidate.isEmpty(groupNumber)) { return null; @@ -1094,6 +1123,12 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return newGroup.getGroupNumber(); } + /** + * Add item group shopping cart item group. + * @param itemGroupValue the item group value + * @return the shopping cart item group + * @throws GenericEntityException the generic entity exception + */ public ShoppingCartItemGroup addItemGroup(GenericValue itemGroupValue) throws GenericEntityException { if (itemGroupValue == null) { return null; @@ -1112,6 +1147,10 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return itemGroup; } + /** + * Gets cart items in no group. + * @return the cart items in no group + */ public List<ShoppingCartItem> getCartItemsInNoGroup() { List<ShoppingCartItem> cartItemList = new LinkedList<>(); for (ShoppingCartItem cartItem : cartLines) { @@ -1122,6 +1161,11 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return cartItemList; } + /** + * Gets cart items in group. + * @param groupNumber the group number + * @return the cart items in group + */ public List<ShoppingCartItem> getCartItemsInGroup(String groupNumber) { List<ShoppingCartItem> cartItemList = new LinkedList<>(); ShoppingCart.ShoppingCartItemGroup itemGroup = this.getItemGroupByNumber(groupNumber); @@ -1165,6 +1209,12 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return this.userLogin; } + /** + * Sets user login. + * @param userLogin the user login + * @param dispatcher the dispatcher + * @throws CartItemModifyException the cart item modify exception + */ public void setUserLogin(GenericValue userLogin, LocalDispatcher dispatcher) throws CartItemModifyException { this.userLogin = userLogin; this.handleNewUser(dispatcher); @@ -1364,49 +1414,98 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { this.setShipAfterDate(0, shipAfterDate); } + /** + * Sets default ship before date. + * @param defaultShipBeforeDate the default ship before date + */ public void setDefaultShipBeforeDate(Timestamp defaultShipBeforeDate) { this.defaultShipBeforeDate = defaultShipBeforeDate != null ? (Timestamp) defaultShipBeforeDate.clone() : null; } + /** + * Gets default ship before date. + * @return the default ship before date + */ public Timestamp getDefaultShipBeforeDate() { return this.defaultShipBeforeDate != null ? (Timestamp) this.defaultShipBeforeDate.clone() : null; } + /** + * Sets default ship after date. + * @param defaultShipAfterDate the default ship after date + */ public void setDefaultShipAfterDate(Timestamp defaultShipAfterDate) { this.defaultShipAfterDate = defaultShipAfterDate != null ? (Timestamp) defaultShipAfterDate.clone() : null; } + /** + * Sets cancel back order date. + * @param cancelBackOrderDate the cancel back order date + */ public void setCancelBackOrderDate(Timestamp cancelBackOrderDate) { this.cancelBackOrderDate = cancelBackOrderDate != null ? (Timestamp) cancelBackOrderDate.clone() : null; } + /** + * Gets cancel back order date. + * @return the cancel back order date + */ public Timestamp getCancelBackOrderDate() { return this.cancelBackOrderDate != null ? (Timestamp) this.cancelBackOrderDate.clone() : null; } + /** + * Gets default ship after date. + * @return the default ship after date + */ public Timestamp getDefaultShipAfterDate() { return this.defaultShipAfterDate != null ? (Timestamp) this.defaultShipAfterDate.clone() : null; } + + /** + * Sets default reserve after date. + * @param defaultReserveAfterDate the default reserve after date + */ public void setDefaultReserveAfterDate(Timestamp defaultReserveAfterDate) { this.defaultReserveAfterDate = defaultReserveAfterDate != null ? (Timestamp) defaultReserveAfterDate.clone() : null; } + /** + * Gets default reserve after date. + * @return the default reserve after date + */ public Timestamp getDefaultReserveAfterDate() { return this.defaultReserveAfterDate != null ? (Timestamp) this.defaultReserveAfterDate.clone() : null; } + /** + * Gets order party id. + * @return the order party id + */ public String getOrderPartyId() { return this.orderPartyId != null ? this.orderPartyId : this.getPartyId(); } + /** + * Sets order party id. + * @param orderPartyId the order party id + */ public void setOrderPartyId(String orderPartyId) { this.orderPartyId = orderPartyId; } + /** + * Gets placing customer party id. + * @return the placing customer party id + */ public String getPlacingCustomerPartyId() { return this.placingCustomerPartyId != null ? this.placingCustomerPartyId : this.getPartyId(); } + /** + * Sets placing customer party id. + * @param placingCustomerPartyId the placing customer party id + */ public void setPlacingCustomerPartyId(String placingCustomerPartyId) { this.placingCustomerPartyId = placingCustomerPartyId; if (UtilValidate.isEmpty(this.orderPartyId)) { @@ -1414,10 +1513,18 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Gets bill to customer party id. + * @return the bill to customer party id + */ public String getBillToCustomerPartyId() { return this.billToCustomerPartyId != null ? this.billToCustomerPartyId : this.getPartyId(); } + /** + * Sets bill to customer party id. + * @param billToCustomerPartyId the bill to customer party id + */ public void setBillToCustomerPartyId(String billToCustomerPartyId) { this.billToCustomerPartyId = billToCustomerPartyId; if ((UtilValidate.isEmpty(this.orderPartyId)) && !("PURCHASE_ORDER".equals(orderType))) { @@ -1425,10 +1532,18 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Gets ship to customer party id. + * @return the ship to customer party id + */ public String getShipToCustomerPartyId() { return this.shipToCustomerPartyId != null ? this.shipToCustomerPartyId : this.getPartyId(); } + /** + * Sets ship to customer party id. + * @param shipToCustomerPartyId the ship to customer party id + */ public void setShipToCustomerPartyId(String shipToCustomerPartyId) { this.shipToCustomerPartyId = shipToCustomerPartyId; if (UtilValidate.isEmpty(this.orderPartyId)) { @@ -1436,10 +1551,18 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Gets end user customer party id. + * @return the end user customer party id + */ public String getEndUserCustomerPartyId() { return this.endUserCustomerPartyId != null ? this.endUserCustomerPartyId : this.getPartyId(); } + /** + * Sets end user customer party id. + * @param endUserCustomerPartyId the end user customer party id + */ public void setEndUserCustomerPartyId(String endUserCustomerPartyId) { this.endUserCustomerPartyId = endUserCustomerPartyId; if (UtilValidate.isEmpty(this.orderPartyId)) { @@ -1447,10 +1570,18 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Gets bill from vendor party id. + * @return the bill from vendor party id + */ public String getBillFromVendorPartyId() { return this.billFromVendorPartyId != null ? this.billFromVendorPartyId : this.getPartyId(); } + /** + * Sets bill from vendor party id. + * @param billFromVendorPartyId the bill from vendor party id + */ public void setBillFromVendorPartyId(String billFromVendorPartyId) { this.billFromVendorPartyId = billFromVendorPartyId; if ((UtilValidate.isEmpty(this.orderPartyId)) && ("PURCHASE_ORDER".equals(orderType))) { @@ -1459,10 +1590,18 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } + /** + * Gets ship from vendor party id. + * @return the ship from vendor party id + */ public String getShipFromVendorPartyId() { return this.shipFromVendorPartyId != null ? this.shipFromVendorPartyId : this.getPartyId(); } + /** + * Sets ship from vendor party id. + * @param shipFromVendorPartyId the ship from vendor party id + */ public void setShipFromVendorPartyId(String shipFromVendorPartyId) { this.shipFromVendorPartyId = shipFromVendorPartyId; if (UtilValidate.isEmpty(this.orderPartyId)) { @@ -1470,10 +1609,18 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Gets supplier agent party id. + * @return the supplier agent party id + */ public String getSupplierAgentPartyId() { return this.supplierAgentPartyId != null ? this.supplierAgentPartyId : this.getPartyId(); } + /** + * Sets supplier agent party id. + * @param supplierAgentPartyId the supplier agent party id + */ public void setSupplierAgentPartyId(String supplierAgentPartyId) { this.supplierAgentPartyId = supplierAgentPartyId; if (UtilValidate.isEmpty(this.orderPartyId)) { @@ -1481,6 +1628,10 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Gets party id. + * @return the party id + */ public String getPartyId() { String partyId = this.orderPartyId; @@ -1493,22 +1644,43 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return partyId; } + /** + * Sets auto save list id. + * @param id the id + */ public void setAutoSaveListId(String id) { this.autoSaveListId = id; } + /** + * Gets auto save list id. + * @return the auto save list id + */ public String getAutoSaveListId() { return this.autoSaveListId; } + /** + * Sets last list restore. + * @param time the time + */ public void setLastListRestore(Timestamp time) { this.lastListRestore = time != null ? (Timestamp) time.clone() : null; } + /** + * Gets last list restore. + * @return the last list restore + */ public Timestamp getLastListRestore() { return this.lastListRestore != null ? (Timestamp) this.lastListRestore.clone() : null; } + /** + * Gets party days since created. + * @param nowTimestamp the now timestamp + * @return the party days since created + */ public BigDecimal getPartyDaysSinceCreated(Timestamp nowTimestamp) { String partyId = this.getPartyId(); if (UtilValidate.isEmpty(partyId)) { @@ -1625,18 +1797,34 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return this.orderType; } + /** + * Sets channel type. + * @param channelType the channel type + */ public void setChannelType(String channelType) { this.channel = channelType; } + /** + * Gets channel type. + * @return the channel type + */ public String getChannelType() { return this.channel; } + /** + * Is purchase order boolean. + * @return the boolean + */ public boolean isPurchaseOrder() { return "PURCHASE_ORDER".equals(this.orderType); } + /** + * Is sales order boolean. + * @return the boolean + */ public boolean isSalesOrder() { return "SALES_ORDER".equals(this.orderType); } @@ -1651,34 +1839,66 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return poNumber; } + /** + * Sets default item delivery date. + * @param date the date + */ public void setDefaultItemDeliveryDate(String date) { this.defaultItemDeliveryDate = date; } + /** + * Gets default item delivery date. + * @return the default item delivery date + */ public String getDefaultItemDeliveryDate() { return this.defaultItemDeliveryDate; } + /** + * Sets default item comment. + * @param comment the comment + */ public void setDefaultItemComment(String comment) { this.defaultItemComment = comment; } + /** + * Gets default item comment. + * @return the default item comment + */ public String getDefaultItemComment() { return this.defaultItemComment; } + /** + * Sets agreement id. + * @param agreementId the agreement id + */ public void setAgreementId(String agreementId) { this.agreementId = agreementId; } + /** + * Gets agreement id. + * @return the agreement id + */ public String getAgreementId() { return this.agreementId; } + /** + * Sets quote id. + * @param quoteId the quote id + */ public void setQuoteId(String quoteId) { this.quoteId = quoteId; } + /** + * Gets quote id. + * @return the quote id + */ public String getQuoteId() { return this.quoteId; } @@ -1912,7 +2132,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { String orderId = this.getOrderId(); if (UtilValidate.isNotEmpty(orderId)) { try { - List<GenericValue> declinedPaymentMethods = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId", orderId, "statusId", "PAYMENT_DECLINED").queryList(); + List<GenericValue> declinedPaymentMethods = EntityQuery.use(delegator).from("OrderPaymentPreference") + .where("orderId", orderId, "statusId", "PAYMENT_DECLINED").queryList(); if (UtilValidate.isNotEmpty(declinedPaymentMethods)) { List<String> paymentMethodIdsToRemove = new ArrayList<>(); for (GenericValue opp : declinedPaymentMethods) { @@ -2285,11 +2506,22 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Gets item ship group estimate. + * @param idx the idx + * @return the item ship group estimate + */ public BigDecimal getItemShipGroupEstimate(int idx) { CartShipInfo csi = this.getShipInfo(idx); return csi.shipEstimate; } + /** + * Sets item ship group qty. + * @param itemIndex the item index + * @param quantity the quantity + * @param idx the idx + */ public void setItemShipGroupQty(int itemIndex, BigDecimal quantity, int idx) { ShoppingCartItem itemIdx = this.findCartItem(itemIndex); if (itemIdx != null) { @@ -2297,10 +2529,23 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Sets item ship group qty. + * @param item the item + * @param quantity the quantity + * @param idx the idx + */ public void setItemShipGroupQty(ShoppingCartItem item, BigDecimal quantity, int idx) { this.setItemShipGroupQty(item, this.getItemIndex(item), quantity, idx); } + /** + * Sets item ship group qty. + * @param item the item + * @param itemIndex the item index + * @param quantity the quantity + * @param idx the idx + */ public void setItemShipGroupQty(ShoppingCartItem item, int itemIndex, BigDecimal quantity, int idx) { if (itemIndex > -1) { CartShipInfo csi = this.getShipInfo(idx); @@ -2327,6 +2572,12 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Gets item ship group qty. + * @param item the item + * @param idx the idx + * @return the item ship group qty + */ public BigDecimal getItemShipGroupQty(ShoppingCartItem item, int idx) { if (item != null) { CartShipInfo csi = this.getShipInfo(idx); @@ -2641,6 +2892,11 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return this.getGiftMessage(0); } + /** + * Sets is gift. + * @param idx the idx + * @param isGift the is gift + */ public void setIsGift(int idx, Boolean isGift) { CartShipInfo csi = this.getShipInfo(idx); if (UtilValidate.isNotEmpty(isGift)) { @@ -2660,15 +2916,29 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Gets is gift. + * @param idx the idx + * @return the is gift + */ public String getIsGift(int idx) { CartShipInfo csi = this.getShipInfo(idx); return csi.isGift; } + /** + * Gets is gift. + * @return the is gift + */ public String getIsGift() { return this.getIsGift(0); } + /** + * Sets carrier party id. + * @param idx the idx + * @param carrierPartyId the carrier party id + */ public void setCarrierPartyId(int idx, String carrierPartyId) { CartShipInfo csi = this.getShipInfo(idx); csi.carrierPartyId = carrierPartyId; @@ -2744,44 +3014,87 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } + /** + * Sets ship group facility id. + * @param idx the idx + * @param facilityId the facility id + */ public void setShipGroupFacilityId(int idx, String facilityId) { CartShipInfo csi = this.getShipInfo(idx); csi.facilityId = facilityId; } + /** + * Gets ship group facility id. + * @param idx the idx + * @return the ship group facility id + */ public String getShipGroupFacilityId(int idx) { CartShipInfo csi = this.getShipInfo(idx); return csi.facilityId; } + /** + * Sets ship group vendor party id. + * @param idx the idx + * @param vendorPartyId the vendor party id + */ public void setShipGroupVendorPartyId(int idx, String vendorPartyId) { CartShipInfo csi = this.getShipInfo(idx); csi.vendorPartyId = vendorPartyId; } + /** + * Gets ship group vendor party id. + * @param idx the idx + * @return the ship group vendor party id + */ public String getShipGroupVendorPartyId(int idx) { CartShipInfo csi = this.getShipInfo(idx); return csi.vendorPartyId; } + /** + * Sets ship group seq id. + * @param idx the idx + * @param shipGroupSeqId the ship group seq id + */ public void setShipGroupSeqId(int idx, String shipGroupSeqId) { CartShipInfo csi = this.getShipInfo(idx); csi.shipGroupSeqId = shipGroupSeqId; } + /** + * Gets ship group seq id. + * @param idx the idx + * @return the ship group seq id + */ public String getShipGroupSeqId(int idx) { CartShipInfo csi = this.getShipInfo(idx); return csi.shipGroupSeqId; } + /** + * Sets order additional emails. + * @param orderAdditionalEmails the order additional emails + */ public void setOrderAdditionalEmails(String orderAdditionalEmails) { this.orderAdditionalEmails = orderAdditionalEmails; } + /** + * Gets order additional emails. + * @return the order additional emails + */ public String getOrderAdditionalEmails() { return orderAdditionalEmails; } + /** + * Gets shipping address. + * @param idx the idx + * @return the shipping address + */ public GenericValue getShippingAddress(int idx) { if (this.getShippingContactMechId(idx) != null) { try { @@ -2794,12 +3107,21 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return null; } + /** + * Gets origin address. + * @param idx the idx + * @return the origin address + */ public GenericValue getOriginAddress(int idx) { CartShipInfo cartShipInfo = getShipInfo(idx); if (cartShipInfo == null) return null; return cartShipInfo.getOriginAddress(this); } + /** + * Gets shipping address. + * @return the shipping address + */ public GenericValue getShippingAddress() { return this.getShippingAddress(0); } @@ -2891,7 +3213,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { // the facilityId should be set prior to triggering default options, otherwise we do not set up facility information String defaultFacilityId = getFacilityId(); if (defaultFacilityId != null) { - GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(this.getDelegator(), facilityId, UtilMisc.toList("SHIPPING_LOCATION", "PRIMARY_LOCATION")); + GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(this.getDelegator(), facilityId, + UtilMisc.toList("SHIPPING_LOCATION", "PRIMARY_LOCATION")); if (facilityContactMech != null) { this.setShippingContactMechId(0, facilityContactMech.getString("contactMechId")); } @@ -2955,7 +3278,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { /** Returns the total from the cart, including tax/shipping. */ public BigDecimal getGrandTotal() { // sales tax and shipping are not stored as adjustments but rather as part of the ship group - return this.getSubTotal().add(this.getTotalShipping()).add(this.getTotalSalesTax()).add(this.getOrderOtherAdjustmentTotal()).add(this.getOrderGlobalAdjustments()); + return this.getSubTotal().add(this.getTotalShipping()).add(this.getTotalSalesTax()).add(this.getOrderOtherAdjustmentTotal()) + .add(this.getOrderGlobalAdjustments()); } /** @@ -3069,7 +3393,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { if (payment.paymentMethodId != null) { try { // need to determine the payment method type from the payment method - GenericValue paymentMethod = this.getDelegator().findOne("PaymentMethod", UtilMisc.toMap("paymentMethodId", payment.paymentMethodId), true); + GenericValue paymentMethod = this.getDelegator().findOne("PaymentMethod", + UtilMisc.toMap("paymentMethodId", payment.paymentMethodId), true); if (paymentMethod != null) { thisPaymentMethodTypeId = paymentMethod.getString("paymentMethodTypeId"); } @@ -3088,14 +3413,26 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return total; } + /** + * Gets credit card payment preference total. + * @return the credit card payment preference total + */ public BigDecimal getCreditCardPaymentPreferenceTotal() { return getOrderPaymentPreferenceTotalByType("CREDIT_CARD"); } + /** + * Gets billing account payment preference total. + * @return the billing account payment preference total + */ public BigDecimal getBillingAccountPaymentPreferenceTotal() { return getOrderPaymentPreferenceTotalByType("EXT_BILLACT"); } + /** + * Gets gift card payment preference total. + * @return the gift card payment preference total + */ public BigDecimal getGiftCardPaymentPreferenceTotal() { return getOrderPaymentPreferenceTotalByType("GIFT_CARD"); } @@ -3118,6 +3455,10 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return contactMechIdsMap.remove(contactMechPurposeTypeId); } + /** + * Gets order contact mech ids. + * @return the order contact mech ids + */ public Map<String, String> getOrderContactMechIds() { return this.contactMechIdsMap; } @@ -3127,6 +3468,11 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return adjustments; } + /** + * Gets adjustment promo index. + * @param productPromoId the product promo id + * @return the adjustment promo index + */ public int getAdjustmentPromoIndex(String productPromoId) { if (UtilValidate.isEmpty(productPromoId)) { return -1; @@ -3141,16 +3487,26 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return -1; } - /** Add an adjustment to the order; 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; don't worry about setting the orderId, orderItemSeqId or orderAdjustmentId; + * they will be set when the order is created */ public int addAdjustment(GenericValue adjustment) { adjustments.add(adjustment); return adjustments.indexOf(adjustment); } + /** + * Remove adjustment. + * @param index the index + */ public void removeAdjustment(int index) { adjustments.remove(index); } + /** + * Gets adjustment. + * @param index the index + * @return the adjustment + */ public GenericValue getAdjustment(int index) { return adjustments.get(index); } @@ -3175,6 +3531,16 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return addOrderTerm(orderTerm); } + /** + * Add order term int. + * @param termTypeId the term type id + * @param orderItemSeqId the order item seq id + * @param termValue the term value + * @param termDays the term days + * @param textValue the text value + * @param description the description + * @return the int + */ public int addOrderTerm(String termTypeId, String orderItemSeqId, BigDecimal termValue, Long termDays, String textValue, String description) { GenericValue orderTerm = this.getDelegator().makeValue("OrderTerm"); orderTerm.put("termTypeId", termTypeId); @@ -3195,22 +3561,42 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return orderTerms.indexOf(orderTerm); } + /** + * Remove order term. + * @param index the index + */ public void removeOrderTerm(int index) { orderTerms.remove(index); } + /** + * Remove order terms. + */ public void removeOrderTerms() { orderTerms.clear(); } + /** + * Is order term set boolean. + * @return the boolean + */ public boolean isOrderTermSet() { return orderTermSet; } + /** + * Sets order term set. + * @param orderTermSet the order term set + */ public void setOrderTermSet(boolean orderTermSet) { this.orderTermSet = orderTermSet; } + /** + * Has order term boolean. + * @param termTypeId the term type id + * @return the boolean + */ public boolean hasOrderTerm(String termTypeId) { if (termTypeId == null) { return false; @@ -3223,10 +3609,18 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return false; } + /** + * Is read only cart boolean. + * @return the boolean + */ public boolean isReadOnlyCart() { return readOnlyCart; } + /** + * Sets read only cart. + * @param readOnlyCart the read only cart + */ public void setReadOnlyCart(boolean readOnlyCart) { this.readOnlyCart = readOnlyCart; } @@ -3484,14 +3878,17 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { return new HashMap<>(this.desiredAlternateGiftByAction); } /** add product promo use */ - public void addProductPromoUse(String productPromoId, String productPromoCodeId, BigDecimal totalDiscountAmount, BigDecimal quantityLeftInActions, Map<ShoppingCartItem, BigDecimal> usageInfoMap) { + public void addProductPromoUse(String productPromoId, String productPromoCodeId, BigDecimal totalDiscountAmount, BigDecimal + quantityLeftInActions, Map<ShoppingCartItem, BigDecimal> usageInfoMap) { if (UtilValidate.isNotEmpty(productPromoCodeId) && !this.productPromoCodes.contains(productPromoCodeId)) { throw new IllegalStateException("Cannot add a use to a promo code use for a code that has not been entered."); } if (Debug.verboseOn()) { - Debug.logVerbose("Used promotion [" + productPromoId + "] with code [" + productPromoCodeId + "] for total discount [" + totalDiscountAmount + "] and quantity left in actions [" + quantityLeftInActions + "]", MODULE); + Debug.logVerbose("Used promotion [" + productPromoId + "] with code [" + productPromoCodeId + "] for total discount [" + + totalDiscountAmount + "] and quantity left in actions [" + quantityLeftInActions + "]", MODULE); } - this.productPromoUseInfoList.add(new ProductPromoUseInfo(productPromoId, productPromoCodeId, totalDiscountAmount, quantityLeftInActions, usageInfoMap)); + this.productPromoUseInfoList.add(new ProductPromoUseInfo(productPromoId, productPromoCodeId, totalDiscountAmount, quantityLeftInActions, + usageInfoMap)); } /** remove product promo use */ public void removeProductPromoUse(String productPromoId) { @@ -3650,13 +4047,15 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } } - /** Adds a promotion code to the cart, checking if it is valid. If it is valid this will return null, otherwise it will return a message stating why it was not valid + /** Adds a promotion code to the cart, checking if it is valid. If it is valid this will return null, otherwise it will return a message stating + * why it was not valid * @param productPromoCodeId The promotion code to check and add * @return String that is null if valid, and added to cart, or an error message of the code was not valid and not added to the cart. */ public String addProductPromoCode(String productPromoCodeId, LocalDispatcher dispatcher) { if (this.productPromoCodes.contains(productPromoCodeId)) { - return UtilProperties.getMessage(RES_ERROR, "productpromoworker.promotion_code_already_been_entered", UtilMisc.toMap("productPromoCodeId", productPromoCodeId), locale); + return UtilProperties.getMessage(RES_ERROR, "productpromoworker.promotion_code_already_been_entered", + UtilMisc.toMap("productPromoCodeId", productPromoCodeId), locale); } if (!this.getDoPromotions()) { this.productPromoCodes.add(productPromoCodeId); @@ -4451,7 +4850,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { String storeRequirementMethodEnumId = null; if (UtilValidate.isNotEmpty(this.getProductStoreId())) { try { - GenericValue productStore = this.getDelegator().findOne("ProductStore", UtilMisc.toMap("productStoreId", this.getProductStoreId()), true); + GenericValue productStore = this.getDelegator().findOne("ProductStore", UtilMisc.toMap("productStoreId", + this.getProductStoreId()), true); facilityId = productStore.getString("inventoryFacilityId"); storeRequirementMethodEnumId = productStore.getString("requirementMethodEnumId"); } catch (GenericEntityException gee) { @@ -4765,7 +5165,6 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { /** * Gets product promo id. - * * @return the product promo id */ public String getProductPromoId() { @@ -4774,7 +5173,6 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { /** * Gets product promo code id. - * * @return the product promo code id */ public String getProductPromoCodeId() { @@ -4783,7 +5181,6 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { /** * Gets total discount amount. - * * @return the total discount amount */ public BigDecimal getTotalDiscountAmount() { @@ -4792,7 +5189,6 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { /** * Gets quantity left in actions. - * * @return the quantity left in actions */ public BigDecimal getQuantityLeftInActions() { @@ -4801,7 +5197,6 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { /** * Gets usage info map. - * * @return the usage info map */ public Map<ShoppingCartItem, BigDecimal> getUsageInfoMap() { @@ -4810,7 +5205,6 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { /** * Gets usage weight. - * * @return the usage weight */ public BigDecimal getUsageWeight() { @@ -5089,7 +5483,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { /** make Item Ship Group And Assoc */ @Deprecated - public List<GenericValue> makeItemShipGroupAndAssoc(LocalDispatcher dispatcher, Delegator delegator, ShoppingCart cart, String shipGroupSeqId, boolean newShipGroup) { + public List<GenericValue> makeItemShipGroupAndAssoc(LocalDispatcher dispatcher, Delegator delegator, ShoppingCart cart, + String shipGroupSeqId, boolean newShipGroup) { return makeItemShipGroupAndAssoc(dispatcher, delegator, cart, shipGroupSeqId); } @@ -5178,9 +5573,11 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { } if (shipTimeEstimateSize != 0) { try { - GenericValue shippingAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", this.internalContactMechId).cache().queryOne(); + GenericValue shippingAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", + this.internalContactMechId).cache().queryOne(); GenericValue originAddress = getOriginAddress(cart); - List<GenericValue> shipmentTimeEstimates = ShippingEvents.getShipmentTimeEstimates(delegator, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId, shippingAddress, originAddress); + List<GenericValue> shipmentTimeEstimates = ShippingEvents.getShipmentTimeEstimates(delegator, shipmentMethodTypeId, + carrierPartyId, carrierRoleTypeId, shippingAddress, originAddress); GenericValue carrierShipmentMethod = delegator.makeValidValue("CarrierShipmentMethod", shipGroup); carrierShipmentMethod.put("partyId", carrierPartyId); if (carrierRoleTypeId == null) carrierRoleTypeId = "CARRIER"; @@ -5306,7 +5703,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { * @param newShipBeforeDate the ship group's shipBeforeDate to be reset */ public void resetShipBeforeDateIfAfter(Timestamp newShipBeforeDate) { - if (newShipBeforeDate != null) { + if (newShipBeforeDate != null) { if ((this.shipBeforeDate == null) || (!this.shipBeforeDate.before(newShipBeforeDate))) { this.shipBeforeDate = (Timestamp) newShipBeforeDate.clone(); } @@ -5595,7 +5992,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable { opp.set("statusId", "PAYMENT_RECEIVED"); } } - Debug.logInfo("ShipGroup [" + csi.getShipGroupSeqId() +"]", MODULE); + Debug.logInfo("ShipGroup [" + csi.getShipGroupSeqId() + "]", MODULE); Debug.logInfo("Creating OrderPaymentPreference - " + opp, MODULE); values.add(opp); } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java index 484ac43..e2bb30b 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartHelper.java @@ -164,7 +164,8 @@ public class ShoppingCartHelper { try { java.sql.Timestamp.valueOf((String) context.get("itemDesiredDeliveryDate")); } catch (IllegalArgumentException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderInvalidDesiredDeliveryDateSyntaxError", this.cart.getLocale())); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderInvalidDesiredDeliveryDateSyntaxError", + this.cart.getLocale())); } } else { context.remove("itemDesiredDeliveryDate"); @@ -253,13 +254,12 @@ public class ShoppingCartHelper { int itemId = -1; try { if (productId != null) { - - itemId = cart.addOrIncreaseItem(productId, amount, quantity, reservStart, reservLength, - reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, reserveAfterDate, additionalFeaturesMap, attributes, - orderItemAttributes, catalogId, configWrapper, itemType, itemGroupNumber, pProductId, dispatcher); - + itemId = cart.addOrIncreaseItem(productId, amount, quantity, reservStart, reservLength, reservPersons, accommodationMapId, + accommodationSpotId, shipBeforeDate, shipAfterDate, reserveAfterDate, additionalFeaturesMap, attributes, + orderItemAttributes, catalogId, configWrapper, itemType, itemGroupNumber, pProductId, dispatcher); } else { - itemId = cart.addNonProductItem(itemType, itemDescription, productCategoryId, price, quantity, attributes, catalogId, itemGroupNumber, dispatcher); + itemId = cart.addNonProductItem(itemType, itemDescription, productCategoryId, price, quantity, attributes, catalogId, + itemGroupNumber, dispatcher); } // set the shopping list info @@ -289,6 +289,15 @@ public class ShoppingCartHelper { return result; } + /** + * Add to cart from order map. + * @param catalogId the catalog id + * @param orderId the order id + * @param itemIds the item ids + * @param addAll the add all + * @param itemGroupNumber the item group number + * @return the map + */ public Map<String, Object> addToCartFromOrder(String catalogId, String orderId, String[] itemIds, boolean addAll, String itemGroupNumber) { List<String> errorMsgs = new ArrayList<>(); Map<String, Object> result; @@ -341,20 +350,24 @@ public class ShoppingCartHelper { BigDecimal amount = orderItem.getBigDecimal("selectedAmount"); ProductConfigWrapper configWrapper = null; String aggregatedProdId = null; - if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", ProductWorker.getProductTypeId(delegator, productId), "parentTypeId", "AGGREGATED")) { + if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", ProductWorker.getProductTypeId(delegator, productId), + "parentTypeId", "AGGREGATED")) { try { GenericValue instanceProduct = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); String configId = instanceProduct.getString("configId"); aggregatedProdId = ProductWorker.getInstanceAggregatedId(delegator, productId); - configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, aggregatedProdId, cart.getProductStoreId(), catalogId, cart.getWebSiteId(), cart.getCurrency(), cart.getLocale(), cart.getAutoUserLogin()); + configWrapper = ProductConfigWorker.loadProductConfigWrapper(delegator, dispatcher, configId, aggregatedProdId, + cart.getProductStoreId(), catalogId, cart.getWebSiteId(), cart.getCurrency(), cart.getLocale(), + cart.getAutoUserLogin()); } catch (GenericEntityException e) { errorMsgs.add(e.getMessage()); } } try { - this.cart.addOrIncreaseItem(UtilValidate.isNotEmpty(aggregatedProdId) ? aggregatedProdId : productId, amount, orderItem.getBigDecimal("quantity"), - null, null, null, null, null, null, null, catalogId, configWrapper, orderItemTypeId, itemGroupNumber, null, dispatcher); + this.cart.addOrIncreaseItem(UtilValidate.isNotEmpty(aggregatedProdId) ? aggregatedProdId : productId, amount, + orderItem.getBigDecimal("quantity"), null, null, null, null, null, null, null, catalogId, configWrapper, + orderItemTypeId, itemGroupNumber, null, dispatcher); noItems = false; } catch (CartItemModifyException | ItemNotFoundException e) { errorMsgs.add(e.getMessage()); @@ -384,7 +397,8 @@ public class ShoppingCartHelper { * Adds all products in a category according to quantity request parameter * for each; if no parameter for a certain product in the category, or if * quantity is 0, do not add. - * If a _ign_${itemGroupNumber} is appended to the name it will be put in that group instead of the default in the request parameter in itemGroupNumber + * If a _ign_${itemGroupNumber} is appended to the name it will be put in that group instead of the default in the + * request parameter in itemGroupNumber * There are 2 options for the syntax: * - name="quantity_${productId}" value="${quantity} * - name="product_${whatever}" value="${productId}" (note: quantity is always 1) @@ -393,10 +407,12 @@ public class ShoppingCartHelper { String itemGroupNumber = (String) context.get("itemGroupNumber"); // use this prefix for the main structure such as a checkbox or a text input where name="quantity_${productId}" value="${quantity}" String keyPrefix = "quantity_"; - // use this prefix for a different structure, useful for radio buttons; can have any suffix, name="product_${whatever}" value="${productId}" and quantity is always 1 + // use this prefix for a different structure, useful for radio buttons; can have any suffix, + // name="product_${whatever}" value="${productId}" and quantity is always 1 String productQuantityKeyPrefix = "product_"; - // If a _ign_${itemGroupNumber} is appended to the name it will be put in that group instead of the default in the request parameter in itemGroupNumber + // If a _ign_${itemGroupNumber} is appended to the name it will be put in that group instead of the default in the + // request parameter in itemGroupNumber String ignSeparator = "_ign_"; // iterate through the context and find all keys that start with "quantity_" @@ -457,25 +473,30 @@ public class ShoppingCartHelper { if (!ProductWorker.isDecimalQuantityOrderAllowed(delegator, productId, cart.getProductStoreId())) { BigDecimal remainder = quantity.remainder(BigDecimal.ONE); if (remainder.compareTo(BigDecimal.ZERO) != 0) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", this.cart.getLocale())); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", + this.cart.getLocale())); } quantity = quantity.setScale(0, UtilNumber.getRoundingMode("order.rounding")); } else { - quantity = quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), UtilNumber.getRoundingMode("order.rounding")); + quantity = quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), + UtilNumber.getRoundingMode("order.rounding")); } } catch (GenericEntityException e) { Debug.logError(e.getMessage(), MODULE); quantity = BigDecimal.ONE; } if (quantity.compareTo(BigDecimal.ZERO) < 0) { - return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.quantity_not_positive_number", this.cart.getLocale())); + return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.quantity_not_positive_number", + this.cart.getLocale())); } try { if (Debug.verboseOn()) { - Debug.logVerbose("Bulk Adding to cart [" + quantity + "] of [" + productId + "] in Item Group [" + itemGroupNumber + "]", MODULE); + Debug.logVerbose("Bulk Adding to cart [" + quantity + "] of [" + productId + "] in Item Group [" + itemGroupNumber + + "]", MODULE); } - this.cart.addOrIncreaseItem(productId, null, quantity, null, null, null, null, null, null, null, catalogId, null, null, itemGroupNumberToUse, originalProductId, dispatcher); + this.cart.addOrIncreaseItem(productId, null, quantity, null, null, null, null, null, null, null, catalogId, null, null, + itemGroupNumberToUse, originalProductId, dispatcher); } catch (CartItemModifyException | ItemNotFoundException e) { return ServiceUtil.returnError(e.getMessage()); } @@ -493,8 +514,7 @@ public class ShoppingCartHelper { public Map<String, Object> addToCartBulkRequirements(String catalogId, Map<String, ? extends Object> context) { String itemGroupNumber = (String) context.get("itemGroupNumber"); // check if we are using per row submit - boolean useRowSubmit = (!context.containsKey("_useRowSubmit"))? false : - "Y".equalsIgnoreCase((String) context.get("_useRowSubmit")); + boolean useRowSubmit = (!context.containsKey("_useRowSubmit")) ? false : "Y".equalsIgnoreCase((String) context.get("_useRowSubmit")); // The number of multi form rows is retrieved int rowCount = UtilHttp.getMultiFormRowCount(context); @@ -511,8 +531,8 @@ public class ShoppingCartHelper { String quantStr = null; String requirementId = null; String thisSuffix = UtilHttp.getMultiRowDelimiter() + i; - boolean rowSelected = (!context.containsKey("_rowSubmit" + thisSuffix))? false : - "Y".equalsIgnoreCase((String) context.get("_rowSubmit" + thisSuffix)); + boolean rowSelected = (!context.containsKey("_rowSubmit" + thisSuffix)) ? false + : "Y".equalsIgnoreCase((String) context.get("_rowSubmit" + thisSuffix)); // make sure we are to process this row if (useRowSubmit && !rowSelected) { @@ -555,7 +575,8 @@ public class ShoppingCartHelper { } if (requirementAlreadyInCart) { if (Debug.warningOn()) { - Debug.logWarning(UtilProperties.getMessage(RES_ERROR, "OrderTheRequirementIsAlreadyInTheCartNotAdding", UtilMisc.toMap("requirementId", requirementId), cart.getLocale()), MODULE); + Debug.logWarning(UtilProperties.getMessage(RES_ERROR, "OrderTheRequirementIsAlreadyInTheCartNotAdding", + UtilMisc.toMap("requirementId", requirementId), cart.getLocale()), MODULE); } continue; } @@ -564,7 +585,9 @@ public class ShoppingCartHelper { if (Debug.verboseOn()) { Debug.logVerbose("Bulk Adding to cart requirement [" + quantity + "] of [" + productId + "]", MODULE); } - int index = this.cart.addOrIncreaseItem(productId, null, quantity, null, null, null, requirement.getTimestamp("requiredByDate"), null, null, null, catalogId, null, null, itemGroupNumber, null, dispatcher); + int index = this.cart.addOrIncreaseItem(productId, null, quantity, null, null, null, + requirement.getTimestamp("requiredByDate"), null, null, null, catalogId, null, null, itemGroupNumber, + null, dispatcher); ShoppingCartItem sci = this.cart.items().get(index); sci.setRequirementId(requirementId); } catch (CartItemModifyException | ItemNotFoundException e) { @@ -597,7 +620,8 @@ public class ShoppingCartHelper { Collection<GenericValue> prodCatMemberCol = null; try { - prodCatMemberCol = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", categoryId).cache(true).queryList(); + prodCatMemberCol = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", categoryId).cache(true) + .queryList(); } catch (GenericEntityException e) { Debug.logWarning(e.toString(), MODULE); Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("categoryId", categoryId); @@ -617,7 +641,6 @@ public class ShoppingCartHelper { BigDecimal totalQuantity = BigDecimal.ZERO; for (GenericValue productCategoryMember : prodCatMemberCol) { BigDecimal quantity = productCategoryMember.getBigDecimal("quantity"); - if (quantity != null && quantity.compareTo(BigDecimal.ZERO) > 0) { try { this.cart.addOrIncreaseItem(productCategoryMember.getString("productId"), @@ -672,7 +695,8 @@ public class ShoppingCartHelper { } /** Update the items in the shopping cart. */ - public Map<String, Object> modifyCart(Security security, GenericValue userLogin, Map<String, ? extends Object> context, boolean removeSelected, String[] selectedItems, Locale locale) { + public Map<String, Object> modifyCart(Security security, GenericValue userLogin, Map<String, ? extends Object> context, boolean removeSelected, + String[] selectedItems, Locale locale) { Map<String, Object> result = null; if (locale == null) { locale = this.cart.getLocale(); @@ -730,7 +754,7 @@ public class ShoppingCartHelper { } else if (parameterName.toUpperCase(Locale.getDefault()).startsWith("DESCRIPTION")) { itemDescription = quantString; // the quantString is actually the description if the field name starts with DESCRIPTION } else if (parameterName.toUpperCase(Locale.getDefault()).startsWith("COMMENT")) { - itemComment= quantString; // the quantString is actually the comment if the field name starts with COMMENT + itemComment = quantString; // the quantString is actually the comment if the field name starts with COMMENT } else if (parameterName.startsWith("reservStart")) { if (quantString.length() == 0) { // should have format: yyyy-mm-dd hh:mm:ss.fffffffff @@ -785,17 +809,20 @@ public class ShoppingCartHelper { quantity = (BigDecimal) ObjectType.simpleTypeOrObjectConvert(quantString, "BigDecimal", null, locale); //For quantity we should test if we allow to add decimal quantity for this product an productStore : // if not and if quantity is in decimal format then return error. - if (!ProductWorker.isDecimalQuantityOrderAllowed(delegator, item.getProductId(), cart.getProductStoreId()) && parameterName.startsWith("update")) { + if (!ProductWorker.isDecimalQuantityOrderAllowed(delegator, item.getProductId(), cart.getProductStoreId()) + && parameterName.startsWith("update")) { BigDecimal remainder = quantity.remainder(BigDecimal.ONE); if (remainder.compareTo(BigDecimal.ZERO) != 0) { - String errMsg = UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", this.cart.getLocale()); + String errMsg = UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", + this.cart.getLocale()); errorMsgs.add(errMsg); result = ServiceUtil.returnError(errorMsgs); return result; } quantity = quantity.setScale(0, UtilNumber.getRoundingMode("order.rounding")); } else { - quantity = quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), UtilNumber.getRoundingMode("order.rounding")); + quantity = quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), + UtilNumber.getRoundingMode("order.rounding")); } if (quantity.compareTo(BigDecimal.ZERO) < 0) { String errMsg = UtilProperties.getMessage(RES_ERROR, "cart.quantity_not_positive_number", this.cart.getLocale()); @@ -826,31 +853,36 @@ public class ShoppingCartHelper { oldPrice = item.getBasePrice(); if (UtilValidate.isNotEmpty(item.getProductId())) { - GenericValue supplierProduct = this.cart.getSupplierProduct(item.getProductId(), quantity, this.dispatcher); - + GenericValue supplierProduct = this.cart.getSupplierProduct(item.getProductId(), quantity, + this.dispatcher); if (supplierProduct == null) { if ("_NA_".equals(cart.getPartyId())) { // no supplier does not require the supplier product item.setQuantity(quantity, dispatcher, this.cart); item.setName(item.getProduct().getString("internalName")); } else { - // in this case, the user wanted to purchase a quantity which is not available (probably below minimum) - String errMsg = UtilProperties.getMessage(RES_ERROR, "cart.product_not_valid_for_supplier", this.cart.getLocale()); - errMsg = errMsg + " (" + item.getProductId() + ", " + quantity + ", " + cart.getCurrency() + ")"; + // in this case, the user wanted to purchase a quantity which is not available + // (probably below minimum) + String errMsg = UtilProperties.getMessage(RES_ERROR, "cart.product_not_valid_for_supplier", + this.cart.getLocale()); + errMsg = errMsg + " (" + item.getProductId() + ", " + quantity + ", " + cart.getCurrency() + + ")"; errorMsgs.add(errMsg); } } else { item.setSupplierProductId(supplierProduct.getString("supplierProductId")); item.setQuantity(quantity, dispatcher, this.cart); item.setBasePrice(supplierProduct.getBigDecimal("lastPrice")); - item.setName(ShoppingCartItem.getPurchaseOrderItemDescription(item.getProduct(), supplierProduct, cart.getLocale(), dispatcher)); + item.setName(ShoppingCartItem.getPurchaseOrderItemDescription(item.getProduct(), supplierProduct, + cart.getLocale(), dispatcher)); } } else { item.setQuantity(quantity, dispatcher, this.cart); } } } else { - BigDecimal minQuantity = ShoppingCart.getMinimumOrderQuantity(delegator, item.getBasePrice(), item.getProductId()); + BigDecimal minQuantity = ShoppingCart.getMinimumOrderQuantity(delegator, item.getBasePrice(), + item.getProductId()); oldQuantity = item.getQuantity(); if (oldQuantity.compareTo(quantity) != 0) { GenericValue product = item.getProduct(); @@ -991,7 +1023,7 @@ public class ShoppingCartHelper { public ShoppingCart getCartObject() { return this.cart; } - + /** get feature appl */ public GenericValue getFeatureAppl(String productId, String optionField, String featureId) { if (delegator == null) { throw new IllegalArgumentException("No delegator available to lookup ProductFeature"); @@ -1024,7 +1056,7 @@ public class ShoppingCartHelper { return productFeatureAppl; } - + /** get remove feature type id*/ public String getRemoveFeatureTypeId(String optionField) { if (optionField != null) { int featureTypeStartIndex = optionField.indexOf('^') + 1; @@ -1044,7 +1076,8 @@ public class ShoppingCartHelper { GenericValue agreement = null; if ((this.delegator == null) || (this.dispatcher == null) || (this.cart == null)) { - result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderDispatcherOrDelegatorOrCartArgumentIsNull", this.cart.getLocale())); + result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderDispatcherOrDelegatorOrCartArgumentIsNull", + this.cart.getLocale())); return result; } @@ -1057,18 +1090,22 @@ public class ShoppingCartHelper { agreement = EntityQuery.use(this.delegator).from("Agreement").where("agreementId", agreementId).cache(true).queryOne(); } catch (GenericEntityException e) { Debug.logWarning(e.toString(), MODULE); - result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderCouldNotGetAgreement", UtilMisc.toMap("agreementId", agreementId), this.cart.getLocale()) + UtilProperties.getMessage(RES_ERROR, "OrderError", this.cart.getLocale()) + e.getMessage()); + result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderCouldNotGetAgreement", + UtilMisc.toMap("agreementId", agreementId), this.cart.getLocale()) + UtilProperties.getMessage(RES_ERROR, "OrderError", + this.cart.getLocale()) + e.getMessage()); return result; } if (agreement == null) { - result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderCouldNotGetAgreement", UtilMisc.toMap("agreementId", agreementId), this.cart.getLocale())); + result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderCouldNotGetAgreement", UtilMisc.toMap("agreementId", + agreementId), this.cart.getLocale())); } else { // set the agreement id in the cart cart.setAgreementId(agreementId); try { // set the currency based on the pricing agreement - List<GenericValue> agreementItems = agreement.getRelated("AgreementItem", UtilMisc.toMap("agreementItemTypeId", "AGREEMENT_PRICING_PR"), null, false); + List<GenericValue> agreementItems = agreement.getRelated("AgreementItem", UtilMisc.toMap("agreementItemTypeId", + "AGREEMENT_PRICING_PR"), null, false); if (agreementItems.size() > 0) { GenericValue agreementItem = agreementItems.get(0); String currencyUomId = (String) agreementItem.get("currencyUomId"); @@ -1076,14 +1113,17 @@ public class ShoppingCartHelper { try { cart.setCurrency(dispatcher, currencyUomId); } catch (CartItemModifyException ex) { - result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderSetCurrencyError", this.cart.getLocale()) + ex.getMessage()); + result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderSetCurrencyError", this.cart.getLocale()) + + ex.getMessage()); return result; } } } } catch (GenericEntityException e) { Debug.logWarning(e.toString(), MODULE); - result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderCouldNotGetAgreementItemsThrough", UtilMisc.toMap("agreementId", agreementId), this.cart.getLocale()) + UtilProperties.getMessage(RES_ERROR, "OrderError", this.cart.getLocale()) + e.getMessage()); + result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderCouldNotGetAgreementItemsThrough", + UtilMisc.toMap("agreementId", agreementId), this.cart.getLocale()) + UtilProperties.getMessage(RES_ERROR, "OrderError", + this.cart.getLocale()) + e.getMessage()); return result; } @@ -1113,6 +1153,11 @@ public class ShoppingCartHelper { return result; } + /** + * Sets currency. + * @param currencyUomId the currency uom id + * @return the currency + */ public Map<String, Object> setCurrency(String currencyUomId) { Map<String, Object> result = null; @@ -1126,10 +1171,25 @@ public class ShoppingCartHelper { return result; } + /** + * Add order term map. + * @param termTypeId the term type id + * @param termValue the term value + * @param termDays the term days + * @return the map + */ public Map<String, Object> addOrderTerm(String termTypeId, BigDecimal termValue, Long termDays) { return addOrderTerm(termTypeId, termValue, termDays, null); } + /** + * Add order term map. + * @param termTypeId the term type id + * @param termValue the term value + * @param termDays the term days + * @param textValue the text value + * @return the map + */ public Map<String, Object> addOrderTerm(String termTypeId, BigDecimal termValue, Long termDays, String textValue) { Map<String, Object> result = null; this.cart.addOrderTerm(termTypeId, termValue, termDays, textValue); @@ -1137,6 +1197,11 @@ public class ShoppingCartHelper { return result; } + /** + * Remove order term map. + * @param index the index + * @return the map + */ public Map<String, Object> removeOrderTerm(int index) { Map<String, Object> result = null; this.cart.removeOrderTerm(index); 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 81a8911..d7cd8f1 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 @@ -365,7 +365,7 @@ public final class ProductPromoWorker { EntityQuery.use(delegator).from("ProductPromo").where("productPromoId", promoUse.getProductPromoId()).cache().queryOne(); GenericValue newProductPromo = (GenericValue) productPromo.clone(); if (!usesPerPromo.containsKey(promoUse.getProductPromoId())) { - usesPerPromo.put(promoUse.getProductPromoId(), 0l); + usesPerPromo.put(promoUse.getProductPromoId(), 0L); } long uses = usesPerPromo.get(promoUse.getProductPromoId()); uses = uses + 1; @@ -474,8 +474,8 @@ public final class ProductPromoWorker { Set<String> enteredCodes = cart.getProductPromoCodesEntered(); // Check whether any promotion code is applied on order. if (cart.getOrderId() != null) { - List<GenericValue> orderproductPromoCodes = EntityQuery.use(delegator).from("OrderProductPromoCode").where("orderId" - , cart.getOrderId()).queryList(); + List<GenericValue> orderproductPromoCodes = EntityQuery.use(delegator).from("OrderProductPromoCode").where("orderId", + cart.getOrderId()).queryList(); Iterator<GenericValue> orderproductPromoCodesItr = UtilMisc.toIterator(orderproductPromoCodes); while (orderproductPromoCodesItr != null && orderproductPromoCodesItr.hasNext()) { GenericValue orderproductPromoCode = orderproductPromoCodesItr.next(); @@ -1053,8 +1053,8 @@ public final class ProductPromoWorker { try { condResult = dispatcher.runSync(serviceName, serviceCtx); } catch (GenericServiceException e) { - Debug.logWarning("Failed to execute productPromoCond service " + serviceName + " for promo " + productPromoCond.getPkShortValueString() - + " throw " + e.toString(), MODULE); + Debug.logWarning("Failed to execute productPromoCond service " + serviceName + " for promo " + + productPromoCond.getPkShortValueString() + " throw " + e.toString(), MODULE); return false; } compareBase = (Integer) condResult.get("compareBase"); @@ -1090,7 +1090,8 @@ public final class ProductPromoWorker { } public static boolean checkConditionsForItem(GenericValue productPromoActionOrCond, ShoppingCart cart, ShoppingCartItem cartItem, - Delegator delegator, LocalDispatcher dispatcher, Timestamp nowTimestamp) throws GenericEntityException { + Delegator delegator, LocalDispatcher dispatcher, Timestamp nowTimestamp) + throws GenericEntityException { GenericValue productPromoRule = productPromoActionOrCond.getRelatedOne("ProductPromoRule", true); List<GenericValue> productPromoConds = EntityQuery.use(delegator).from("ProductPromoCond").where("productPromoId", productPromoRule.get( @@ -1131,7 +1132,8 @@ public final class ProductPromoWorker { BigDecimal amountOff = listPrice.subtract(basePrice); BigDecimal percentOff = amountOff.divide(listPrice, 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100L)); - if (!("PPIP_LPMUP_AMT".equals(inputParamEnumId) || "PPC_LPMUP_AMT".equals(customMethodId)) && !("PPIP_LPMUP_PER".equals(inputParamEnumId) || "PPC_LPMUP_PER".equals(customMethodId))) { + if (!("PPIP_LPMUP_AMT".equals(inputParamEnumId) || "PPC_LPMUP_AMT".equals(customMethodId)) && !("PPIP_LPMUP_PER".equals(inputParamEnumId) + || "PPC_LPMUP_PER".equals(customMethodId))) { // condition doesn't apply to individual item, always passes return true; } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskWorker.java b/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskWorker.java index caa3635..7d77f5d 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskWorker.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/task/TaskWorker.java @@ -31,7 +31,8 @@ import org.apache.ofbiz.entity.GenericValue; public final class TaskWorker { private static final String MODULE = TaskWorker.class.getName(); - private static final Map<String, String> statusMapping = UtilMisc.toMap("WF_NOT_STARTED", "Waiting", "WF_RUNNING", "Active", "WF_COMPLETE", "Complete", "WF_SUSPENDED", "Hold"); + private static final Map<String, String> STATUS_MAPPING = UtilMisc.toMap("WF_NOT_STARTED", "Waiting", "WF_RUNNING", "Active", "WF_COMPLETE", + "Complete", "WF_SUSPENDED", "Hold"); private TaskWorker() { } @@ -39,21 +40,23 @@ public final class TaskWorker { String lastName = orderTaskList.getString("customerLastName"); String firstName = orderTaskList.getString("customerFirstName"); if (lastName != null) { - String name = lastName; - if (firstName != null) - name = name + ", " + firstName; - return name; - } else { - return ""; - } + String name = lastName; + if (firstName != null) { + name = name + ", " + firstName; + } + return name; + } else { + return ""; + } } public static String getPrettyStatus(GenericValue orderTaskList) { String statusId = orderTaskList.getString("currentStatusId"); - String prettyStatus = statusMapping.get(statusId); - if (prettyStatus == null) + String prettyStatus = STATUS_MAPPING.get(statusId); + if (prettyStatus == null) { prettyStatus = "?"; + } return prettyStatus; } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java index 0c447e2..ce90bcd 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/test/OrderTestServices.java @@ -59,7 +59,8 @@ public class OrderTestServices { for (int i = 1; i <= numberOfOrdersInt; i++) { try { ModelService modelService = dctx.getModelService("createTestSalesOrderSingle"); - Map<String, Object> outputMap = dispatcher.runSync("createTestSalesOrderSingle", modelService.makeValid(context, ModelService.IN_PARAM)); + Map<String, Object> outputMap = dispatcher.runSync("createTestSalesOrderSingle", + modelService.makeValid(context, ModelService.IN_PARAM)); if (ServiceUtil.isError(outputMap)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(outputMap)); } 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 aea7203..dbb8a55 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 @@ -969,7 +969,7 @@ public class ContactMechServices { SecureRandom secureRandom = new SecureRandom(); - synchronized(ContactMechServices.class) { + synchronized (ContactMechServices.class) { while (true) { Long random = secureRandom.nextLong(); verifyHash = HashCrypt.digestHash("MD5", Long.toString(random).getBytes(StandardCharsets.UTF_8)); diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java b/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java index 78905d0..a1b5671 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/content/PartyContentWrapper.java @@ -57,12 +57,12 @@ public class PartyContentWrapper implements ContentWrapper { private static final String MODULE = PartyContentWrapper.class.getName(); public static final String CACHE_KEY_SEPARATOR = "::"; - private static final UtilCache<String, String> partyContentCache = UtilCache.createUtilCache("party.content.rendered", true); + private static final UtilCache<String, String> PARTY_CONTENT_CACHE = UtilCache.createUtilCache("party.content.rendered", true); - protected LocalDispatcher dispatcher; - protected GenericValue party; - protected Locale locale; - protected String mimeTypeId; + private LocalDispatcher dispatcher; + private GenericValue party; + private Locale locale; + private String mimeTypeId; public PartyContentWrapper(LocalDispatcher dispatcher, GenericValue party, Locale locale, String mimeTypeId) { this.dispatcher = dispatcher; @@ -75,7 +75,8 @@ public class PartyContentWrapper implements ContentWrapper { this.dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); this.party = party; 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")); } // interface implementation @@ -97,6 +98,11 @@ public class PartyContentWrapper implements ContentWrapper { } } + /** + * Gets list. + * @param contentTypeId the content type id + * @return the list + */ public List<String> getList(String contentTypeId) { try { return getPartyContentTextList(party, contentTypeId, locale, mimeTypeId, party.getDelegator(), dispatcher); @@ -118,10 +124,12 @@ public class PartyContentWrapper implements ContentWrapper { public static String getPartyContentAsText(GenericValue party, String partyContentId, HttpServletRequest request, String encoderType) { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); String mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", party.getDelegator()); - return getPartyContentAsText(party, partyContentId, null, UtilHttp.getLocale(request), mimeTypeId, party.getDelegator(), dispatcher, true, encoderType); + return getPartyContentAsText(party, partyContentId, null, UtilHttp.getLocale(request), mimeTypeId, party.getDelegator(), dispatcher, + true, encoderType); } - public static String getPartyContentAsText(GenericValue party, String partyContentId, Locale locale, LocalDispatcher dispatcher, String encoderType) { + public static String getPartyContentAsText(GenericValue party, String partyContentId, Locale locale, LocalDispatcher dispatcher, + String encoderType) { return getPartyContentAsText(party, partyContentId, null, locale, null, null, dispatcher, true, encoderType); } @@ -149,37 +157,41 @@ public class PartyContentWrapper implements ContentWrapper { try { if (useCache) { - String cachedValue = partyContentCache.get(cacheKey); + String cachedValue = PARTY_CONTENT_CACHE.get(cacheKey); if (cachedValue != null) { return cachedValue; } } Writer outWriter = new StringWriter(); - getPartyContentAsText(contentId, party.getString("partyId"), party, partyContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter, false); + getPartyContentAsText(contentId, party.getString("partyId"), party, partyContentTypeId, locale, mimeTypeId, delegator, dispatcher, + outWriter, false); String outString = outWriter.toString(); if (UtilValidate.isEmpty(outString)) { - outString = party.getModelEntity().isField(candidateFieldName) ? party.getString(candidateFieldName): ""; + outString = party.getModelEntity().isField(candidateFieldName) ? party.getString(candidateFieldName) : ""; outString = outString == null ? "" : outString; } outString = encoder.sanitize(outString, null); - if (partyContentCache != null) { - partyContentCache.put(cacheKey, outString); + if (PARTY_CONTENT_CACHE != null) { + PARTY_CONTENT_CACHE.put(cacheKey, outString); } return outString; } catch (GeneralException | IOException e) { Debug.logError(e, "Error rendering PartyContent, inserting empty String", MODULE); - String candidateOut = party.getModelEntity().isField(candidateFieldName) ? party.getString(candidateFieldName): ""; + String candidateOut = party.getModelEntity().isField(candidateFieldName) ? party.getString(candidateFieldName) : ""; return candidateOut == null ? "" : encoder.sanitize(candidateOut, null); } } - public static void getPartyContentAsText(String contentId, String partyId, GenericValue party, String partyContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { + public static void getPartyContentAsText(String contentId, String partyId, GenericValue party, String partyContentTypeId, Locale locale, + String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { getPartyContentAsText(contentId, partyId, party, partyContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter, true); } - public static void getPartyContentAsText(String contentId, String partyId, GenericValue party, String partyContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, boolean cache) throws GeneralException, IOException { + public static void getPartyContentAsText(String contentId, String partyId, GenericValue party, String partyContentTypeId, Locale locale, + String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, boolean cache) + throws GeneralException, IOException { if (partyId == null && party != null) { partyId = party.getString("partyId"); } @@ -208,7 +220,8 @@ public class PartyContentWrapper implements ContentWrapper { Map<String, Object> inContext = new HashMap<>(); inContext.put("party", party); inContext.put("partyContent", partyContent); - ContentWorker.renderContentAsText(dispatcher, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache); + ContentWorker.renderContentAsText(dispatcher, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, + null, null, cache); return; } @@ -247,7 +260,8 @@ public class PartyContentWrapper implements ContentWrapper { } } - public static List<String> getPartyContentTextList(GenericValue party, String partyContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { + public static List<String> getPartyContentTextList(GenericValue party, String partyContentTypeId, Locale locale, String mimeTypeId, + Delegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { List<GenericValue> partyContentList = EntityQuery.use(delegator).from("PartyContent") .where("partyId", party.getString("partyId"), "partyContentTypeId", partyContentTypeId) .orderBy("-fromDate") @@ -262,7 +276,8 @@ public class PartyContentWrapper implements ContentWrapper { Map<String, Object> inContext = new HashMap<>(); inContext.put("party", party); inContext.put("partyContent", partyContent); - ContentWorker.renderContentAsText(dispatcher, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false); + ContentWorker.renderContentAsText(dispatcher, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, + null, null, false); contentList.add(outWriter.toString()); } } 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 9be9e7b..7442183 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 @@ -126,7 +126,8 @@ public class PartyServices { if (statusId == null) { statusId = "PARTY_ENABLED"; } - Map<String, Object> newPartyMap = UtilMisc.toMap("partyId", partyId, "partyTypeId", "PERSON", "description", description, "createdDate", now, "lastModifiedDate", now, "statusId", statusId); + Map<String, Object> newPartyMap = UtilMisc.toMap("partyId", partyId, "partyTypeId", "PERSON", "description", description, + "createdDate", now, "lastModifiedDate", now, "statusId", statusId); String preferredCurrencyUomId = (String) context.get("preferredCurrencyUomId"); if (UtilValidate.isNotEmpty(preferredCurrencyUomId)) { newPartyMap.put("preferredCurrencyUomId", preferredCurrencyUomId); @@ -2309,24 +2310,29 @@ public class PartyServices { .where("abbreviation", rec.get("preferredCurrencyUomId"), "uomTypeId", "CURRENCY_MEASURE") .queryList(); if (UtilValidate.isNotEmpty(rec.get("preferredCurrencyUomId")) && currencyCheck.size() == 0) { - newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + "Currency code not found for: " + rec.get("preferredCurrencyUomId")); + newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + "Currency code not found for: " + + rec.get("preferredCurrencyUomId")); } if (UtilValidate.isEmpty(rec.get("roleTypeId"))) { - newErrMsgs.add("Line number " + rec.getRecordNumber() + ": Mandatory roletype is missing, possible values: CUSTOMER, SUPPLIER, EMPLOYEE and more...."); + newErrMsgs.add("Line number " + rec.getRecordNumber() + + ": Mandatory roletype is missing, possible values: CUSTOMER, SUPPLIER, EMPLOYEE and more...."); } else if (EntityQuery.use(delegator).from("RoleType").where("roleTypeId", rec.get("roleTypeId")).queryOne() == null) { newErrMsgs.add("Line number " + rec.getRecordNumber() + ": RoletypeId is not valid: " + rec.get("roleTypeId")); } if (UtilValidate.isNotEmpty(rec.get("contactMechTypeId")) && EntityQuery.use(delegator).from("ContactMechType").where("contactMechTypeId", rec.get("contactMechTypeId")).cache().queryOne() == null) { - newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + " contactMechTypeId code not found for: " + rec.get("contactMechTypeId")); + newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + + " contactMechTypeId code not found for: " + + rec.get("contactMechTypeId")); } if (UtilValidate.isNotEmpty(rec.get("contactMechPurposeTypeId")) && EntityQuery.use(delegator).from("ContactMechPurposeType").where("contactMechPurposeTypeId", rec.get("contactMechPurposeTypeId")).cache().queryOne() == null) { - newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + "contactMechPurposeTypeId code not found for: " + rec.get("contactMechPurposeTypeId")); + newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + + "contactMechPurposeTypeId code not found for: " + rec.get("contactMechPurposeTypeId")); } if (UtilValidate.isNotEmpty(rec.get("contactMechTypeId")) && "POSTAL_ADDRESS".equals(rec.get("contactMechTypeId"))) { @@ -2337,7 +2343,8 @@ public class PartyServices { .where("geoTypeId", "COUNTRY", "abbreviation", rec.get("countryGeoId")) .queryList(); if (countryCheck.size() == 0) { - newErrMsgs.add("Line number " + rec.getRecordNumber() + " partyId: " + currentPartyId + " Invalid Country code: " + rec.get("countryGeoId")); + newErrMsgs.add("Line number " + rec.getRecordNumber() + " partyId: " + currentPartyId + " Invalid Country code: " + + rec.get("countryGeoId")); } } @@ -2350,7 +2357,8 @@ public class PartyServices { .where("geoTypeId", "STATE", "abbreviation", rec.get("stateProvinceGeoId")) .queryList(); if (stateCheck.size() == 0) { - newErrMsgs.add("Line number " + rec.getRecordNumber() + " partyId: " + currentPartyId + " Invalid stateProvinceGeoId code: " + rec.get("countryGeoId")); + newErrMsgs.add("Line number " + rec.getRecordNumber() + " partyId: " + currentPartyId + + " Invalid stateProvinceGeoId code: " + rec.get("countryGeoId")); } } } @@ -2426,7 +2434,7 @@ public class PartyServices { newPartyId = (String) result.get("partyId"); Map<String, Object> partyIdentification = UtilMisc.toMap("partyId", newPartyId, - "partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId"), "userLogin", userLogin); + "partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId"), "userLogin", userLogin); result = dispatcher.runSync("createPartyIdentification", partyIdentification); if (ServiceUtil.isError(result)) { @@ -2447,7 +2455,7 @@ public class PartyServices { if (companyCheck.size() == 0) { // update party group // company does not exist so create Map<String, Object> companyPartyGroup = UtilMisc.toMap( - "partyId", newCompanyPartyId, "statusId", "PARTY_ENABLED", "userLogin", userLogin); + "partyId", newCompanyPartyId, "statusId", "PARTY_ENABLED", "userLogin", userLogin); result = dispatcher.runSync("createPartyGroup", companyPartyGroup); if (ServiceUtil.isError(result)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); @@ -2466,14 +2474,14 @@ public class PartyServices { // company exist, so create link Map<String, Object> partyRelationship = UtilMisc.toMap("partyIdTo", newPartyId, "partyIdFrom", newCompanyPartyId, - "roleTypeIdFrom", "ACCOUNT", "partyRelationshipTypeId", "EMPLOYMENT", "userLogin", userLogin); + "roleTypeIdFrom", "ACCOUNT", "partyRelationshipTypeId", "EMPLOYMENT", "userLogin", userLogin); result = dispatcher.runSync("createPartyRelationship", partyRelationship); if (ServiceUtil.isError(result)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); } } } - Debug.logInfo(" =========================================================party created id: " + newPartyId, MODULE); + Debug.logInfo(" New party created with id: " + newPartyId, MODULE); partiesCreated++; } else { errMsgs.addAll(newErrMsgs); @@ -2535,10 +2543,11 @@ public class PartyServices { Map<String, Object> partyContactMechPurpose = UtilMisc.toMap("partyId", newPartyId, "userLogin", userLogin); boolean partyContactMechPurposeChanged = false; currentContactMechPurposeTypeId = rec.get("contactMechPurposeTypeId"); - if (currentContactMechPurposeTypeId != null && ("TELECOM_NUMBER".equals(currentContactMechTypeId) || "POSTAL_ADDRESS".equals(currentContactMechTypeId) || "EMAIL_ADDRESS".equals(currentContactMechTypeId))) { + if (currentContactMechPurposeTypeId != null && ("TELECOM_NUMBER".equals(currentContactMechTypeId) + || "POSTAL_ADDRESS".equals(currentContactMechTypeId) || "EMAIL_ADDRESS".equals(currentContactMechTypeId))) { partyContactMechPurpose.put("contactMechPurposeTypeId", currentContactMechPurposeTypeId); partyContactMechPurposeChanged = (lastContactMechPurposeTypeId == null || !lastContactMechPurposeTypeId.equals(currentContactMechPurposeTypeId)) && !telecomNumberChanged && !postalAddressChanged && !emailAddressChanged; - Debug.logInfo("===================================last:" + lastContactMechPurposeTypeId + " current: " + currentContactMechPurposeTypeId + " t :" + telecomNumberChanged + " p: " + postalAddressChanged + " e: " + emailAddressChanged + " result: " + partyContactMechPurposeChanged, MODULE); + Debug.logInfo("Last:" + lastContactMechPurposeTypeId + " current: " + currentContactMechPurposeTypeId + " t :" + telecomNumberChanged + " p: " + postalAddressChanged + " e: " + emailAddressChanged + " result: " + partyContactMechPurposeChanged, MODULE); } lastContactMechPurposeTypeId = currentContactMechPurposeTypeId; @@ -2584,7 +2593,9 @@ public class PartyServices { if (currentContactMechPurposeTypeId == null) { currentContactMechPurposeTypeId = "PRIMARY_EMAIL"; } - Map<String, Object> resultMap = dispatcher.runSync("createPartyContactMech", UtilMisc.toMap("partyId", newPartyId, "contactMechId", newContactMechId, "contactMechPurposeTypeId", currentContactMechPurposeTypeId, "userLogin", userLogin)); + Map<String, Object> resultMap = dispatcher.runSync("createPartyContactMech", UtilMisc.toMap("partyId", newPartyId, + "contactMechId", newContactMechId, "contactMechPurposeTypeId", currentContactMechPurposeTypeId, "userLogin", + userLogin)); if (ServiceUtil.isError(resultMap)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result)); } @@ -2612,7 +2623,8 @@ public class PartyServices { return ServiceUtil.returnError(errMsgs); } - result = ServiceUtil.returnSuccess(UtilProperties.getMessage(RESOURCE, "PartyNewPartiesCreated", UtilMisc.toMap("partiesCreated", partiesCreated), locale)); + result = ServiceUtil.returnSuccess(UtilProperties.getMessage(RESOURCE, "PartyNewPartiesCreated", + UtilMisc.toMap("partiesCreated", partiesCreated), locale)); return result; } } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java index de30f57..f5b8f45 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigItemContentWrapper.java @@ -54,15 +54,16 @@ public class ProductConfigItemContentWrapper implements ContentWrapper { private static final String MODULE = ProductConfigItemContentWrapper.class.getName(); public static final String SEPARATOR = "::"; // cache key separator - private static final UtilCache<String, String> configItemContentCache = UtilCache.createUtilCache("configItem.content", true); // use soft reference to free up memory if needed + private static final UtilCache<String, String> CONFIG_ITEM_CONTENT_CACHE = UtilCache.createUtilCache("configItem.content", true); + // use soft reference to free up memory if needed - protected transient LocalDispatcher dispatcher; - protected String dispatcherName; - protected transient Delegator delegator; - protected String delegatorName; - protected GenericValue productConfigItem; - protected Locale locale; - protected String mimeTypeId; + private transient LocalDispatcher dispatcher; + private String dispatcherName; + private transient Delegator delegator; + private String delegatorName; + private GenericValue productConfigItem; + private Locale locale; + private String mimeTypeId; public static ProductConfigItemContentWrapper makeProductConfigItemContentWrapper(GenericValue productConfigItem, HttpServletRequest request) { @@ -91,9 +92,14 @@ public class ProductConfigItemContentWrapper implements ContentWrapper { @Override public StringWrapper get(String confItemContentTypeId, String encoderType) { - return StringUtil.makeStringWrapper(getProductConfigItemContentAsText(productConfigItem, confItemContentTypeId, locale, mimeTypeId, getDelegator(), getDispatcher(), encoderType)); + return StringUtil.makeStringWrapper(getProductConfigItemContentAsText(productConfigItem, confItemContentTypeId, locale, mimeTypeId, + getDelegator(), getDispatcher(), encoderType)); } + /** + * Gets delegator. + * @return the delegator + */ public Delegator getDelegator() { if (delegator == null) { delegator = DelegatorFactory.getDelegator(delegatorName); @@ -101,6 +107,10 @@ public class ProductConfigItemContentWrapper implements ContentWrapper { return delegator; } + /** + * Gets dispatcher. + * @return the dispatcher + */ public LocalDispatcher getDispatcher() { if (dispatcher == null) { dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, this.getDelegator()); @@ -108,47 +118,60 @@ public class ProductConfigItemContentWrapper implements ContentWrapper { return dispatcher; } - public static String getProductConfigItemContentAsText(GenericValue productConfigItem, String confItemContentTypeId, HttpServletRequest request, String encoderType) { + public static String getProductConfigItemContentAsText(GenericValue productConfigItem, String confItemContentTypeId, + HttpServletRequest request, String encoderType) { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - String mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", productConfigItem.getDelegator()); - return getProductConfigItemContentAsText(productConfigItem, confItemContentTypeId, UtilHttp.getLocale(request), mimeTypeId, productConfigItem.getDelegator(), dispatcher, encoderType); + String mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", + productConfigItem.getDelegator()); + return getProductConfigItemContentAsText(productConfigItem, confItemContentTypeId, UtilHttp.getLocale(request), mimeTypeId, + productConfigItem.getDelegator(), dispatcher, encoderType); } - public static String getProductConfigItemContentAsText(GenericValue productConfigItem, String confItemContentTypeId, Locale locale, LocalDispatcher dispatcher, String encoderType) { + public static String getProductConfigItemContentAsText(GenericValue productConfigItem, String confItemContentTypeId, Locale locale, + LocalDispatcher dispatcher, String encoderType) { return getProductConfigItemContentAsText(productConfigItem, confItemContentTypeId, locale, null, null, dispatcher, encoderType); } - public static String getProductConfigItemContentAsText(GenericValue productConfigItem, String confItemContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, String encoderType) { + public static String getProductConfigItemContentAsText(GenericValue productConfigItem, String confItemContentTypeId, Locale locale, + String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, String encoderType) { UtilCodec.SimpleEncoder encoder = UtilCodec.getEncoder(encoderType); String candidateFieldName = ModelUtil.dbNameToVarName(confItemContentTypeId); - String cacheKey = confItemContentTypeId + SEPARATOR + locale + SEPARATOR + mimeTypeId + SEPARATOR + productConfigItem.get("configItemId") + SEPARATOR + encoderType + SEPARATOR + delegator; + String cacheKey = confItemContentTypeId + SEPARATOR + locale + SEPARATOR + mimeTypeId + SEPARATOR + productConfigItem.get("configItemId") + + SEPARATOR + encoderType + SEPARATOR + delegator; try { - String cachedValue = configItemContentCache.get(cacheKey); + String cachedValue = CONFIG_ITEM_CONTENT_CACHE.get(cacheKey); if (cachedValue != null) { return cachedValue; } Writer outWriter = new StringWriter(); - getProductConfigItemContentAsText(null, productConfigItem, confItemContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter, false); + getProductConfigItemContentAsText(null, productConfigItem, confItemContentTypeId, locale, mimeTypeId, delegator, dispatcher, + outWriter, false); String outString = outWriter.toString(); if (UtilValidate.isEmpty(outString)) { - outString = productConfigItem.getModelEntity().isField(candidateFieldName) ? productConfigItem.getString(candidateFieldName): ""; + outString = productConfigItem.getModelEntity().isField(candidateFieldName) ? productConfigItem.getString(candidateFieldName) : ""; outString = outString == null ? "" : outString; } outString = encoder.sanitize(outString, null); - configItemContentCache.put(cacheKey, outString); + CONFIG_ITEM_CONTENT_CACHE.put(cacheKey, outString); return outString; } catch (GeneralException | IOException e) { Debug.logError(e, "Error rendering ProdConfItemContent, inserting empty String", MODULE); - String candidateOut = productConfigItem.getModelEntity().isField(candidateFieldName) ? productConfigItem.getString(candidateFieldName): ""; + String candidateOut = productConfigItem.getModelEntity().isField(candidateFieldName) + ? productConfigItem.getString(candidateFieldName) : ""; return candidateOut == null ? "" : encoder.sanitize(candidateOut, null); } } - public static void getProductConfigItemContentAsText(String configItemId, GenericValue productConfigItem, String confItemContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { - getProductConfigItemContentAsText(configItemId, productConfigItem, confItemContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter, true); + public static void getProductConfigItemContentAsText(String configItemId, GenericValue productConfigItem, String confItemContentTypeId, + Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) + throws GeneralException, IOException { + getProductConfigItemContentAsText(configItemId, productConfigItem, confItemContentTypeId, locale, mimeTypeId, delegator, dispatcher, + outWriter, true); } - public static void getProductConfigItemContentAsText(String configItemId, GenericValue productConfigItem, String confItemContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, boolean cache) throws GeneralException, IOException { + public static void getProductConfigItemContentAsText(String configItemId, GenericValue productConfigItem, String confItemContentTypeId, + Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, boolean cache) + throws GeneralException, IOException { if (configItemId == null && productConfigItem != null) { configItemId = productConfigItem.getString("configItemId"); } @@ -168,11 +191,13 @@ public class ProductConfigItemContentWrapper implements ContentWrapper { .filterByDate() .queryFirst(); if (productConfigItemContent != null) { - // when rendering the product config item content, always include the ProductConfigItem and ProdConfItemContent records that this comes from + // when rendering the product config item content, always include the ProductConfigItem and + // ProdConfItemContent records that this comes from Map<String, Object> inContext = new HashMap<>(); inContext.put("productConfigItem", productConfigItem); inContext.put("productConfigItemContent", productConfigItemContent); - ContentWorker.renderContentAsText(dispatcher, productConfigItemContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache); + ContentWorker.renderContentAsText(dispatcher, productConfigItemContent.getString("contentId"), outWriter, inContext, locale, + mimeTypeId, null, null, cache); return; } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java index 6f5e3b6..80149d4 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWorker.java @@ -52,7 +52,8 @@ public final class ProductConfigWorker { private ProductConfigWorker() { } - private static final UtilCache<String, ProductConfigWrapper> productConfigCache = UtilCache.createUtilCache("product.config", true); // use soft reference to free up memory if needed + private static final UtilCache<String, ProductConfigWrapper> PRODUCT_CONFIG_CACHE = UtilCache.createUtilCache("product.config", true); + // use soft reference to free up memory if needed public static ProductConfigWrapper getProductConfigWrapper(String productId, String currencyUomId, HttpServletRequest request) { ProductConfigWrapper configWrapper = null; @@ -65,15 +66,16 @@ public final class ProductConfigWorker { * productId::catalogId::webSiteId::currencyUomId, or whatever the SEPARATOR is defined above to be. */ Delegator delegator = (Delegator) request.getAttribute("delegator"); - String cacheKey = productId + SEPARATOR + productStoreId + SEPARATOR + catalogId + SEPARATOR + webSiteId + SEPARATOR + currencyUomId + SEPARATOR + delegator; - configWrapper = productConfigCache.get(cacheKey); + String cacheKey = productId + SEPARATOR + productStoreId + SEPARATOR + catalogId + SEPARATOR + webSiteId + SEPARATOR + + currencyUomId + SEPARATOR + delegator; + configWrapper = PRODUCT_CONFIG_CACHE.get(cacheKey); if (configWrapper == null) { configWrapper = new ProductConfigWrapper((Delegator) request.getAttribute("delegator"), (LocalDispatcher) request.getAttribute("dispatcher"), productId, productStoreId, catalogId, webSiteId, currencyUomId, UtilHttp.getLocale(request), autoUserLogin); - configWrapper = productConfigCache.putIfAbsentAndGet(cacheKey, new ProductConfigWrapper(configWrapper)); + configWrapper = PRODUCT_CONFIG_CACHE.putIfAbsentAndGet(cacheKey, new ProductConfigWrapper(configWrapper)); } else { configWrapper = new ProductConfigWrapper(configWrapper); } @@ -102,7 +104,7 @@ public final class ProductConfigWorker { ProductConfigWrapper.ConfigItem question = configWrapper.getQuestions().get(k); if (question.isStandard()) { int i = 0; - while (i <= (question.getOptions().size() -1)) { + while (i <= (question.getOptions().size() - 1)) { String comments = (String) combinedMap.get("comments_" + k + "_" + i); if (UtilValidate.isNotEmpty(comments)) { try { @@ -146,7 +148,8 @@ public final class ProductConfigWorker { // handle also feature tree virtual variant methods if (ProductWorker.isVirtual((Delegator) request.getAttribute("delegator"), selectedProductId)) { - if ("VV_FEATURETREE".equals(ProductWorker.getProductVirtualVariantMethod((Delegator) request.getAttribute("delegator"), selectedProductId))) { + if ("VV_FEATURETREE".equals(ProductWorker.getProductVirtualVariantMethod((Delegator) + request.getAttribute("delegator"), selectedProductId))) { // get the selected features List<String> selectedFeatures = new LinkedList<>(); String prefix = "FT" + k + "_" + cnt + "_" + variantIndex; @@ -158,21 +161,23 @@ public final class ProductConfigWorker { // check if features are selected if (UtilValidate.isEmpty(selectedFeatures)) { - Debug.logWarning("ERROR: No features selected for productId [" + selectedProductId+ "]", MODULE); + Debug.logWarning("ERROR: No features selected for productId [" + selectedProductId + "]", MODULE); } - String variantProductId = ProductWorker.getVariantFromFeatureTree(selectedProductId, selectedFeatures, (Delegator) request.getAttribute("delegator")); + String variantProductId = ProductWorker.getVariantFromFeatureTree(selectedProductId, selectedFeatures, + (Delegator) request.getAttribute("delegator")); if (UtilValidate.isNotEmpty(variantProductId)) { selectedProductId = variantProductId; } else { Debug.logWarning("ERROR: Variant product not found!", MODULE); - request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage("OrderErrorUiLabels", "cart.addToCart.incompatibilityVariantFeature", UtilHttp.getLocale(request))); - } + request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage("OrderErrorUiLabels", + "cart.addToCart.incompatibilityVariantFeature", UtilHttp.getLocale(request))); + } } } configWrapper.setSelected(k, cnt, i, selectedProductId); } - variantIndex ++; + variantIndex++; } } } @@ -218,13 +223,15 @@ public final class ProductConfigWorker { configItemId = ci.getConfigItemAssoc().getString("configItemId"); sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum"); try { - List<GenericValue> configs = EntityQuery.use(delegator).from("ProductConfigConfig").where("configItemId", configItemId, "sequenceNum", sequenceNum).queryList(); + List<GenericValue> configs = EntityQuery.use(delegator).from("ProductConfigConfig").where("configItemId", configItemId, + "sequenceNum", sequenceNum).queryList(); for (GenericValue productConfigConfig: configs) { for (ConfigOption oneOption: selectedOptions) { - String configOptionId = oneOption.configOption.getString("configOptionId"); + String configOptionId = oneOption.getConfigOption().getString("configOptionId"); if (productConfigConfig.getString("configOptionId").equals(configOptionId)) { String comments = oneOption.getComments() != null ? oneOption.getComments() : ""; - if ((UtilValidate.isEmpty(comments) && UtilValidate.isEmpty(productConfigConfig.getString("description"))) || comments.equals(productConfigConfig.getString("description"))) { + if ((UtilValidate.isEmpty(comments) && UtilValidate.isEmpty(productConfigConfig.getString("description"))) + || comments.equals(productConfigConfig.getString("description"))) { configsToCheck.add(productConfigConfig); } } @@ -241,9 +248,11 @@ public final class ProductConfigWorker { for (GenericValue productConfigConfig: configsToCheck) { String tempConfigId = productConfigConfig.getString("configId"); try { - List<GenericValue> tempResult = EntityQuery.use(delegator).from("ProductConfigConfig").where("configId", tempConfigId).queryList(); + List<GenericValue> tempResult = EntityQuery.use(delegator).from("ProductConfigConfig").where("configId", tempConfigId) + .queryList(); if (tempResult.size() == selectedOptionSize && configsToCheck.containsAll(tempResult)) { - List<GenericValue> configOptionProductOptions = EntityQuery.use(delegator).from("ConfigOptionProductOption").where("configId", tempConfigId).queryList(); + List<GenericValue> configOptionProductOptions = EntityQuery.use(delegator).from("ConfigOptionProductOption") + .where("configId", tempConfigId).queryList(); if (UtilValidate.isNotEmpty(configOptionProductOptions)) { // check for variant product equality @@ -274,7 +283,7 @@ public final class ProductConfigWorker { if (UtilValidate.isNotEmpty(componentOptions)) { optionProductOptionId = componentOptions.get(optionProductId); } - String configOptionId = anOption.configOption.getString("configOptionId"); + String configOptionId = anOption.getConfigOption().getString("configOptionId"); configItemId = ci.getConfigItemAssoc().getString("configItemId"); sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum"); @@ -295,15 +304,15 @@ public final class ProductConfigWorker { } if (match && (UtilValidate.isEmpty(configOptionProductOptions))) { - configWrapper.configId = tempConfigId; - Debug.logInfo("Existing configuration found with configId:"+ tempConfigId, MODULE); + configWrapper.setConfigId(tempConfigId); + Debug.logInfo("Existing configuration found with configId:" + tempConfigId, MODULE); return; } } } else { - configWrapper.configId = tempConfigId; - Debug.logInfo("Existing configuration found with configId:"+ tempConfigId, MODULE); + configWrapper.setConfigId(tempConfigId); + Debug.logInfo("Existing configuration found with configId:" + tempConfigId, MODULE); return; } } @@ -321,7 +330,7 @@ public final class ProductConfigWorker { Long sequenceNum = null; List<ProductConfigWrapper.ConfigOption> selectedOptions = new LinkedList<>(); List<ConfigOption> options = ci.getOptions(); - if (ci.isStandard()) { + if (ci.isStandard()) { selectedOptions.addAll(options); } else { for (ConfigOption oneOption: options) { @@ -340,9 +349,9 @@ public final class ProductConfigWorker { configItemId = ci.getConfigItemAssoc().getString("configItemId"); sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum"); for (ConfigOption oneOption: selectedOptions) { - Map<String, String> componentOptions = oneOption.componentOptions; + Map<String, String> componentOptions = oneOption.getComponentOptions(); List<GenericValue> toBeStored = new LinkedList<>(); - String configOptionId = oneOption.configOption.getString("configOptionId"); + String configOptionId = oneOption.getConfigOption().getString("configOptionId"); String description = oneOption.getComments(); GenericValue productConfigConfig = delegator.makeValue("ProductConfigConfig"); productConfigConfig.put("configId", configId); @@ -379,8 +388,8 @@ public final class ProductConfigWorker { } //save configId to configWrapper, so we can use it in shopping cart operations - configWrapper.configId = configId; - Debug.logInfo("New configId created:"+ configId, MODULE); + configWrapper.setConfigId(configId); + Debug.logInfo("New configId created:" + configId, MODULE); return; } @@ -399,10 +408,12 @@ public final class ProductConfigWorker { * @param autoUserLogin * @return ProductConfigWrapper */ - public static ProductConfigWrapper loadProductConfigWrapper(Delegator delegator, LocalDispatcher dispatcher, String configId, String productId, String productStoreId, String catalogId, String webSiteId, String currencyUomId, Locale locale, GenericValue autoUserLogin) { + public static ProductConfigWrapper loadProductConfigWrapper(Delegator delegator, LocalDispatcher dispatcher, String configId, String productId, + String productStoreId, String catalogId, String webSiteId, String currencyUomId, Locale locale, GenericValue autoUserLogin) { ProductConfigWrapper configWrapper = null; try { - configWrapper = new ProductConfigWrapper(delegator, dispatcher, productId, productStoreId, catalogId, webSiteId, currencyUomId, locale, autoUserLogin); + configWrapper = new ProductConfigWrapper(delegator, dispatcher, productId, productStoreId, catalogId, webSiteId, currencyUomId, + locale, autoUserLogin); if (UtilValidate.isNotEmpty(configId)) { configWrapper.loadConfig(delegator, configId); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java index fae4c23..5b2abc7 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/config/ProductConfigWrapper.java @@ -52,27 +52,36 @@ public class ProductConfigWrapper implements Serializable { private static final String MODULE = ProductConfigWrapper.class.getName(); - protected transient LocalDispatcher dispatcher; - protected String dispatcherName; - protected String productStoreId; - protected String catalogId; - protected String webSiteId; - protected String currencyUomId; - protected transient Delegator delegator; - protected String delegatorName = null; - protected GenericValue product = null; // the aggregated product - protected GenericValue autoUserLogin = null; - protected BigDecimal listPrice = BigDecimal.ZERO; - protected BigDecimal basePrice = BigDecimal.ZERO; - protected BigDecimal defaultPrice = BigDecimal.ZERO; - protected String configId = null; // Id of persisted ProductConfigWrapper - protected List<ConfigItem> questions = null; // ProductConfigs + private transient LocalDispatcher dispatcher; + private String dispatcherName; + private String productStoreId; + private String catalogId; + private String webSiteId; + private String currencyUomId; + private transient Delegator delegator; + private String delegatorName = null; + private GenericValue product = null; // the aggregated product + private GenericValue autoUserLogin = null; + private BigDecimal listPrice = BigDecimal.ZERO; + private BigDecimal basePrice = BigDecimal.ZERO; + private BigDecimal defaultPrice = BigDecimal.ZERO; + private String configId = null; // Id of persisted ProductConfigWrapper + private List<ConfigItem> questions = null; // ProductConfigs /** Creates a new instance of ProductConfigWrapper */ public ProductConfigWrapper() { } - public ProductConfigWrapper(Delegator delegator, LocalDispatcher dispatcher, String productId, String productStoreId, String catalogId, String webSiteId, String currencyUomId, Locale locale, GenericValue autoUserLogin) throws Exception { + /** + * Sets config id. + * @param configId the config id + */ + public void setConfigId(String configId) { + this.configId = configId; + } + + public ProductConfigWrapper(Delegator delegator, LocalDispatcher dispatcher, String productId, String productStoreId, String catalogId, + String webSiteId, String currencyUomId, Locale locale, GenericValue autoUserLogin) throws Exception { init(delegator, dispatcher, productId, productStoreId, catalogId, webSiteId, currencyUomId, locale, autoUserLogin); } @@ -96,9 +105,11 @@ public class ProductConfigWrapper implements Serializable { } } - private void init(Delegator delegator, LocalDispatcher dispatcher, String productId, String productStoreId, String catalogId, String webSiteId, String currencyUomId, Locale locale, GenericValue autoUserLogin) throws Exception { + private void init(Delegator delegator, LocalDispatcher dispatcher, String productId, String productStoreId, String catalogId, String webSiteId, + String currencyUomId, Locale locale, GenericValue autoUserLogin) throws Exception { product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); - if (product == null || !"AGGREGATED".equals(product.getString("productTypeId")) && !"AGGREGATED_SERVICE".equals(product.getString("productTypeId"))) { + if (product == null || !"AGGREGATED".equals(product.getString("productTypeId")) + && !"AGGREGATED_SERVICE".equals(product.getString("productTypeId"))) { throw new ProductConfigWrapperException("Product " + productId + " is not an AGGREGATED product."); } this.dispatcher = dispatcher; @@ -112,8 +123,8 @@ public class ProductConfigWrapper implements Serializable { this.autoUserLogin = autoUserLogin; // get the list Price, the base Price - Map<String, Object> priceContext = UtilMisc.toMap("product", product, "prodCatalogId", catalogId, "webSiteId", webSiteId, "productStoreId", productStoreId, - "currencyUomId", currencyUomId, "autoUserLogin", autoUserLogin); + Map<String, Object> priceContext = UtilMisc.toMap("product", product, "prodCatalogId", catalogId, "webSiteId", webSiteId, + "productStoreId", productStoreId, "currencyUomId", currencyUomId, "autoUserLogin", autoUserLogin); Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", priceContext); if (ServiceUtil.isError(priceMap)) { String errorMessage = ServiceUtil.getErrorMessage(priceMap); @@ -129,7 +140,8 @@ public class ProductConfigWrapper implements Serializable { } questions = new LinkedList<>(); if ("AGGREGATED".equals(product.getString("productTypeId")) || "AGGREGATED_SERVICE".equals(product.getString("productTypeId"))) { - List<GenericValue> questionsValues = EntityQuery.use(delegator).from("ProductConfig").where("productId", productId).orderBy("sequenceNum").filterByDate().queryList(); + List<GenericValue> questionsValues = EntityQuery.use(delegator).from("ProductConfig").where("productId", productId) + .orderBy("sequenceNum").filterByDate().queryList(); Set<String> itemIds = new HashSet<>(); for (GenericValue questionsValue: questionsValues) { ConfigItem oneQuestion = new ConfigItem(questionsValue); @@ -140,9 +152,11 @@ public class ProductConfigWrapper implements Serializable { itemIds.add(oneQuestion.getConfigItem().getString("configItemId")); } questions.add(oneQuestion); - List<GenericValue> configOptions = EntityQuery.use(delegator).from("ProductConfigOption").where("configItemId", oneQuestion.getConfigItemAssoc().getString("configItemId")).orderBy("sequenceNum").filterByDate().queryList(); + List<GenericValue> configOptions = EntityQuery.use(delegator).from("ProductConfigOption").where("configItemId", + oneQuestion.getConfigItemAssoc().getString("configItemId")).orderBy("sequenceNum").filterByDate().queryList(); for (GenericValue configOption: configOptions) { - ConfigOption option = new ConfigOption(delegator, dispatcher, configOption, oneQuestion, catalogId, webSiteId, currencyUomId, autoUserLogin); + ConfigOption option = new ConfigOption(delegator, dispatcher, configOption, oneQuestion, catalogId, webSiteId, + currencyUomId, autoUserLogin); oneQuestion.addOption(option); } } @@ -210,10 +224,18 @@ public class ProductConfigWrapper implements Serializable { } } + /** + * Gets config id. + * @return the config id + */ public String getConfigId() { return configId; } + /** + * Gets delegator. + * @return the delegator + */ public Delegator getDelegator() { if (delegator == null) { delegator = DelegatorFactory.getDelegator(delegatorName); @@ -221,6 +243,10 @@ public class ProductConfigWrapper implements Serializable { return delegator; } + /** + * Gets dispatcher. + * @return the dispatcher + */ public LocalDispatcher getDispatcher() { if (dispatcher == null) { dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, this.getDelegator()); @@ -401,11 +427,11 @@ public class ProductConfigWrapper implements Serializable { } public class ConfigItem implements java.io.Serializable { - GenericValue configItem = null; - GenericValue configItemAssoc = null; - ProductConfigItemContentWrapper content = null; - List<ConfigOption> options = null; - boolean first = true; + private GenericValue configItem = null; + private GenericValue configItemAssoc = null; + private ProductConfigItemContentWrapper content = null; + private List<ConfigOption> options = null; + private boolean first = true; public ConfigItem(GenericValue questionAssoc) throws Exception { configItemAssoc = questionAssoc; @@ -424,50 +450,99 @@ public class ProductConfigWrapper implements Serializable { content = ci.content; // FIXME: this should be cloned } + /** + * Sets content. + * @param locale the locale + * @param mimeTypeId the mime type id + */ public void setContent(Locale locale, String mimeTypeId) { content = new ProductConfigItemContentWrapper(dispatcher, configItem, locale, mimeTypeId); } + /** + * Gets content. + * @return the content + */ public ProductConfigItemContentWrapper getContent() { return content; } + /** + * Gets config item. + * @return the config item + */ public GenericValue getConfigItem() { return configItem; } + /** + * Gets config item assoc. + * @return the config item assoc + */ public GenericValue getConfigItemAssoc() { return configItemAssoc; } + /** + * Is standard boolean. + * @return the boolean + */ public boolean isStandard() { return "STANDARD".equals(configItemAssoc.getString("configTypeId")); } + /** + * Is single choice boolean. + * @return the boolean + */ public boolean isSingleChoice() { return "SINGLE".equals(configItem.getString("configItemTypeId")); } + /** + * Is mandatory boolean. + * @return the boolean + */ public boolean isMandatory() { return configItemAssoc.getString("isMandatory") != null && "Y".equals(configItemAssoc.getString("isMandatory")); } + /** + * Is first boolean. + * @return the boolean + */ public boolean isFirst() { return first; } + /** + * Sets first. + * @param newValue the new value + */ public void setFirst(boolean newValue) { first = newValue; } + /** + * Add option. + * @param option the option + */ public void addOption(ConfigOption option) { options.add(option); } + /** + * Gets options. + * @return the options + */ public List<ConfigOption> getOptions() { return options; } + /** + * Gets question. + * @return the question + */ public String getQuestion() { String question = ""; if (UtilValidate.isNotEmpty(configItemAssoc.getString("description"))) { @@ -552,17 +627,28 @@ public class ProductConfigWrapper implements Serializable { } + /** + * The type Config option. + */ public class ConfigOption implements java.io.Serializable { - BigDecimal optionListPrice = BigDecimal.ZERO; - BigDecimal optionPrice = BigDecimal.ZERO; - Date availabilityDate = null; - List<GenericValue> componentList = null; // lists of ProductConfigProduct - Map<String, String> componentOptions = null; - GenericValue configOption = null; - boolean selected = false; - boolean available = true; - ConfigItem parentConfigItem = null; - String comments = null; // comments for production run entered during ordering + private BigDecimal optionListPrice = BigDecimal.ZERO; + private BigDecimal optionPrice = BigDecimal.ZERO; + private Date availabilityDate = null; + private List<GenericValue> componentList = null; // lists of ProductConfigProduct + private Map<String, String> componentOptions = null; + private GenericValue configOption = null; + private boolean selected = false; + private boolean available = true; + private ConfigItem parentConfigItem = null; + private String comments = null; // comments for production run entered during ordering + + /** + * Gets config option. + * @return the config option + */ + public GenericValue getConfigOption() { + return configOption; + } public ConfigOption(Delegator delegator, LocalDispatcher dispatcher, GenericValue option, ConfigItem configItem, String catalogId, String webSiteId, String currencyUomId, GenericValue autoUserLogin) throws Exception { configOption = option; @@ -708,26 +794,50 @@ public class ProductConfigWrapper implements Serializable { return (configOption.getString("description") != null ? (String) configOption.get("description", locale) : "no description"); } + /** + * Gets id. + * @return the id + */ public String getId() { return configOption.getString("configOptionId"); } + /** + * Gets comments. + * @return the comments + */ public String getComments() { return comments; } + /** + * Sets comments. + * @param comments the comments + */ public void setComments(String comments) { this.comments = comments; } + /** + * Gets list price. + * @return the list price + */ public BigDecimal getListPrice() { return optionListPrice; } + /** + * Gets price. + * @return the price + */ public BigDecimal getPrice() { return optionPrice; } + /** + * Gets offset list price. + * @return the offset list price + */ public BigDecimal getOffsetListPrice() { ConfigOption defaultConfigOption = parentConfigItem.getDefault(); if (parentConfigItem.isSingleChoice() && UtilValidate.isNotEmpty(defaultConfigOption)) { @@ -777,26 +887,50 @@ public class ProductConfigWrapper implements Serializable { return false; } + /** + * Is selected boolean. + * @return the boolean + */ public boolean isSelected() { return selected; } + /** + * Sets selected. + * @param newValue the new value + */ public void setSelected(boolean newValue) { selected = newValue; } + /** + * Is available boolean. + * @return the boolean + */ public boolean isAvailable() { return available; } + /** + * Sets available. + * @param newValue the new value + */ public void setAvailable(boolean newValue) { available = newValue; } + /** + * Gets components. + * @return the components + */ public List<GenericValue> getComponents() { return componentList; } + /** + * Gets component options. + * @return the component options + */ public Map<String, String> getComponentOptions() { return componentOptions; } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductContentWrapper.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductContentWrapper.java index b057270..4e103ce 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductContentWrapper.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductContentWrapper.java @@ -55,16 +55,16 @@ public class ProductContentWrapper implements ContentWrapper { private static final String MODULE = ProductContentWrapper.class.getName(); public static final String SEPARATOR = "::"; // cache key separator - private static final UtilCache<String, String> productContentCache = UtilCache.createUtilCache("product.content.rendered", true); + private static final UtilCache<String, String> PRODUCT_CONTENT_CACHE = UtilCache.createUtilCache("product.content.rendered", true); public static ProductContentWrapper makeProductContentWrapper(GenericValue product, HttpServletRequest request) { return new ProductContentWrapper(product, request); } - LocalDispatcher dispatcher; - protected GenericValue product; - protected Locale locale; - protected String mimeTypeId; + private LocalDispatcher dispatcher; + private GenericValue product; + private Locale locale; + private String mimeTypeId; public ProductContentWrapper(LocalDispatcher dispatcher, GenericValue product, Locale locale, String mimeTypeId) { this.dispatcher = dispatcher; @@ -77,25 +77,30 @@ public class ProductContentWrapper implements ContentWrapper { this.dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); this.product = product; 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 public StringUtil.StringWrapper get(String productContentTypeId, String encoderType) { if (this.product == null) { - Debug.logWarning("Tried to get ProductContent for type [" + productContentTypeId + "] but the product field in the ProductContentWrapper is null", MODULE); + Debug.logWarning("Tried to get ProductContent for type [" + productContentTypeId + + "] but the product field in the ProductContentWrapper is null", MODULE); return null; } - return StringUtil.makeStringWrapper(getProductContentAsText(this.product, productContentTypeId, locale, mimeTypeId, null, null, this.product.getDelegator(), dispatcher, encoderType)); + return StringUtil.makeStringWrapper(getProductContentAsText(this.product, productContentTypeId, locale, mimeTypeId, null, + null, this.product.getDelegator(), dispatcher, encoderType)); } public static String getProductContentAsText(GenericValue product, String productContentTypeId, HttpServletRequest request, String encoderType) { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); String mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", product.getDelegator()); - return getProductContentAsText(product, productContentTypeId, UtilHttp.getLocale(request), mimeTypeId, null, null, product.getDelegator(), dispatcher, encoderType); + return getProductContentAsText(product, productContentTypeId, UtilHttp.getLocale(request), mimeTypeId, null, null, + product.getDelegator(), dispatcher, encoderType); } - public static String getProductContentAsText(GenericValue product, String productContentTypeId, Locale locale, LocalDispatcher dispatcher, String encoderType) { + public static String getProductContentAsText(GenericValue product, String productContentTypeId, Locale locale, LocalDispatcher dispatcher, + String encoderType) { return getProductContentAsText(product, productContentTypeId, locale, null, null, null, null, dispatcher, encoderType); } @@ -110,22 +115,24 @@ public class ProductContentWrapper implements ContentWrapper { /* caching: there is one cache created, "product.content" Each product's content is cached with a key of * contentTypeId::locale::mimeType::productId, or whatever the SEPARATOR is defined above to be. */ - String cacheKey = productContentTypeId + SEPARATOR + locale + SEPARATOR + mimeTypeId + SEPARATOR + product.get("productId") + SEPARATOR + encoderType + SEPARATOR + delegator; + String cacheKey = productContentTypeId + SEPARATOR + locale + SEPARATOR + mimeTypeId + SEPARATOR + product.get("productId") + SEPARATOR + + encoderType + SEPARATOR + delegator; try { - String cachedValue = productContentCache.get(cacheKey); + String cachedValue = PRODUCT_CONTENT_CACHE.get(cacheKey); if (cachedValue != null) { return cachedValue; } Writer outWriter = new StringWriter(); - getProductContentAsText(null, product, productContentTypeId, locale, mimeTypeId, partyId, roleTypeId, delegator, dispatcher, outWriter, false); + getProductContentAsText(null, product, productContentTypeId, locale, mimeTypeId, partyId, roleTypeId, delegator, dispatcher, + outWriter, false); String outString = outWriter.toString(); if (UtilValidate.isEmpty(outString)) { outString = product.getModelEntity().isField(candidateFieldName) ? product.getString(candidateFieldName) : ""; outString = outString == null ? "" : outString; } outString = encoder.sanitize(outString, null); - productContentCache.put(cacheKey, outString); + PRODUCT_CONTENT_CACHE.put(cacheKey, outString); return outString; } catch (GeneralException | IOException e) { Debug.logError(e, "Error rendering ProductContent, inserting empty String", MODULE); @@ -134,11 +141,16 @@ public class ProductContentWrapper implements ContentWrapper { } } - public static void getProductContentAsText(String productId, GenericValue product, String productContentTypeId, Locale locale, String mimeTypeId, String partyId, String roleTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { - getProductContentAsText(productId, product, productContentTypeId, locale, mimeTypeId, partyId, roleTypeId, delegator, dispatcher, outWriter, true); + public static void getProductContentAsText(String productId, GenericValue product, String productContentTypeId, Locale locale, String mimeTypeId, + String partyId, String roleTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) + throws GeneralException, IOException { + getProductContentAsText(productId, product, productContentTypeId, locale, mimeTypeId, partyId, roleTypeId, delegator, dispatcher, + outWriter, true); } - public static void getProductContentAsText(String productId, GenericValue product, String productContentTypeId, Locale locale, String mimeTypeId, String partyId, String roleTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, boolean cache) throws GeneralException, IOException { + public static void getProductContentAsText(String productId, GenericValue product, String productContentTypeId, Locale locale, String mimeTypeId, + String partyId, String roleTypeId, Delegator delegator, LocalDispatcher dispatcher, + Writer outWriter, boolean cache) throws GeneralException, IOException { if (productId == null && product != null) { productId = product.getString("productId"); } @@ -155,11 +167,13 @@ public class ProductContentWrapper implements ContentWrapper { throw new GeneralRuntimeException("Unable to find a delegator to use!"); } - List<GenericValue> productContentList = EntityQuery.use(delegator).from("ProductContent").where("productId", productId, "productContentTypeId", productContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList(); + List<GenericValue> productContentList = EntityQuery.use(delegator).from("ProductContent").where("productId", productId, + "productContentTypeId", productContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList(); if (UtilValidate.isEmpty(productContentList) && ("Y".equals(product.getString("isVariant")))) { GenericValue parent = ProductWorker.getParentProduct(productId, delegator); if (parent != null) { - productContentList = EntityQuery.use(delegator).from("ProductContent").where("productId", parent.get("productId"), "productContentTypeId", productContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList(); + productContentList = EntityQuery.use(delegator).from("ProductContent").where("productId", parent.get("productId"), + "productContentTypeId", productContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList(); } } GenericValue productContent = EntityUtil.getFirst(productContentList); @@ -168,7 +182,8 @@ public class ProductContentWrapper implements ContentWrapper { Map<String, Object> inContext = new HashMap<>(); inContext.put("product", product); inContext.put("productContent", productContent); - ContentWorker.renderContentAsText(dispatcher, productContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, partyId, roleTypeId, cache); + ContentWorker.renderContentAsText(dispatcher, productContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, + partyId, roleTypeId, cache); return; } 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 9ebaa07..228bc7c 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,16 +59,16 @@ 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> productPromoContentCache = 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); } - LocalDispatcher dispatcher; - protected GenericValue productPromo; - protected Locale locale; - protected String mimeTypeId; + private LocalDispatcher dispatcher; + private GenericValue productPromo; + private Locale locale; + private String mimeTypeId; public ProductPromoContentWrapper(LocalDispatcher dispatcher, GenericValue productPromo, Locale locale, String mimeTypeId) { this.dispatcher = dispatcher; @@ -87,13 +87,16 @@ public class ProductPromoContentWrapper implements ContentWrapper { @Override public StringUtil.StringWrapper get(String productPromoContentTypeId, String encoderType) { if (UtilValidate.isEmpty(this.productPromo)) { - Debug.logWarning("Tried to get ProductPromoContent for type [" + productPromoContentTypeId + "] but the productPromo field in the ProductPromoContentWrapper is null", MODULE); + Debug.logWarning("Tried to get ProductPromoContent for type [" + productPromoContentTypeId + + "] but the productPromo field in the ProductPromoContentWrapper is null", MODULE); return null; } - return StringUtil.makeStringWrapper(getProductPromoContentAsText(this.productPromo, productPromoContentTypeId, locale, mimeTypeId, null, null, this.productPromo.getDelegator(), dispatcher, encoderType)); + return StringUtil.makeStringWrapper(getProductPromoContentAsText(this.productPromo, productPromoContentTypeId, locale, mimeTypeId, null, + null, this.productPromo.getDelegator(), dispatcher, encoderType)); } - public static String getProductPromoContentAsText(GenericValue productPromo, String productPromoContentTypeId, HttpServletRequest request, String encoderType) { + public static String getProductPromoContentAsText(GenericValue productPromo, String productPromoContentTypeId, HttpServletRequest request, + String encoderType) { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); Delegator delegator = (Delegator) request.getAttribute("delegator"); return getProductPromoContentAsText(productPromo, productPromoContentTypeId, UtilHttp.getLocale(request), @@ -101,11 +104,13 @@ public class ProductPromoContentWrapper implements ContentWrapper { null, null, productPromo.getDelegator(), dispatcher, encoderType); } - public static String getProductContentAsText(GenericValue productPromo, String productPromoContentTypeId, Locale locale, LocalDispatcher dispatcher, String encoderType) { + public static String getProductContentAsText(GenericValue productPromo, String productPromoContentTypeId, Locale locale, LocalDispatcher + dispatcher, String encoderType) { return getProductPromoContentAsText(productPromo, productPromoContentTypeId, locale, null, null, null, null, dispatcher, encoderType); } - public static String getProductPromoContentAsText(GenericValue productPromo, String productPromoContentTypeId, Locale locale, String mimeTypeId, String partyId, String roleTypeId, Delegator delegator, LocalDispatcher dispatcher, String encoderType) { + public static String getProductPromoContentAsText(GenericValue productPromo, String productPromoContentTypeId, Locale locale, String mimeTypeId, + String partyId, String roleTypeId, Delegator delegator, LocalDispatcher dispatcher, String encoderType) { if (UtilValidate.isEmpty(productPromo)) { return null; } @@ -115,35 +120,42 @@ public class ProductPromoContentWrapper implements ContentWrapper { /* caching: there is one cache created, "product.promo.content" Each productPromo's content is cached with a key of * contentTypeId::locale::mimeType::productPromoId, or whatever the SEPARATOR is defined above to be. */ - String cacheKey = productPromoContentTypeId + SEPARATOR + locale + SEPARATOR + mimeTypeId + SEPARATOR + productPromo.get("productPromoId") + SEPARATOR + encoderType + SEPARATOR + delegator; + String cacheKey = productPromoContentTypeId + SEPARATOR + locale + SEPARATOR + mimeTypeId + SEPARATOR + productPromo.get("productPromoId") + + SEPARATOR + encoderType + SEPARATOR + delegator; try { - String cachedValue = productPromoContentCache.get(cacheKey); + String cachedValue = PRODUCT_PROMO_CONTENT_CACHE.get(cacheKey); if (cachedValue != null) { return cachedValue; } Writer outWriter = new StringWriter(); - getProductPromoContentAsText(null, productPromo, productPromoContentTypeId, locale, mimeTypeId, partyId, roleTypeId, delegator, dispatcher, outWriter, false); + getProductPromoContentAsText(null, productPromo, productPromoContentTypeId, locale, mimeTypeId, partyId, roleTypeId, + delegator, dispatcher, outWriter, false); String outString = outWriter.toString(); if (UtilValidate.isEmpty(outString)) { - outString = productPromo.getModelEntity().isField(candidateFieldName) ? productPromo.getString(candidateFieldName): ""; + outString = productPromo.getModelEntity().isField(candidateFieldName) ? productPromo.getString(candidateFieldName) : ""; outString = outString == null ? "" : outString; } outString = encoder.sanitize(outString, null); - productPromoContentCache.put(cacheKey, outString); + PRODUCT_PROMO_CONTENT_CACHE.put(cacheKey, outString); return outString; } catch (GeneralException | IOException e) { Debug.logError(e, "Error rendering ProductPromoContent, inserting empty String", MODULE); - String candidateOut = productPromo.getModelEntity().isField(candidateFieldName) ? productPromo.getString(candidateFieldName): ""; + String candidateOut = productPromo.getModelEntity().isField(candidateFieldName) ? productPromo.getString(candidateFieldName) : ""; return candidateOut == null ? "" : encoder.sanitize(candidateOut, null); } } - public static void getProductPromoContentAsText(String productPromoId, GenericValue productPromo, String productPromoContentTypeId, Locale locale, String mimeTypeId, String partyId, String roleTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { - getProductPromoContentAsText(productPromoId, productPromo, productPromoContentTypeId, locale, mimeTypeId, partyId, roleTypeId, delegator, dispatcher, outWriter, true); + public static void getProductPromoContentAsText(String productPromoId, GenericValue productPromo, String productPromoContentTypeId, + Locale locale, String mimeTypeId, String partyId, String roleTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) + throws GeneralException, IOException { + getProductPromoContentAsText(productPromoId, productPromo, productPromoContentTypeId, locale, mimeTypeId, partyId, roleTypeId, delegator, + dispatcher, outWriter, true); } - public static void getProductPromoContentAsText(String productPromoId, GenericValue productPromo, String productPromoContentTypeId, Locale locale, String mimeTypeId, String partyId, String roleTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, boolean cache) throws GeneralException, IOException { + public static void getProductPromoContentAsText(String productPromoId, GenericValue productPromo, String productPromoContentTypeId, + Locale locale, String mimeTypeId, String partyId, String roleTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, + boolean cache) throws GeneralException, IOException { if (UtilValidate.isEmpty(productPromoId) && productPromo != null) { productPromoId = productPromo.getString("productPromoId"); } diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearch.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearch.java index 8dad651..6c1a5fd 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearch.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearch.java @@ -185,10 +185,18 @@ public class ProductSearch { private Set<String> excludeFeatureGroupIds = new HashSet<>(); private Set<String> alwaysIncludeFeatureGroupIds = new HashSet<>(); + /** + * Gets entity condition list. + * @return the entity condition list + */ public List<EntityCondition> getEntityConditionList() { return entityConditionList; } + /** + * Gets dynamic view entity. + * @return the dynamic view entity + */ public DynamicViewEntity getDynamicViewEntity() { return dynamicViewEntity; } @@ -203,7 +211,6 @@ public class ProductSearch { /** * Sets keyword type ids. - * * @param keywordTypeIds the keyword type ids */ public void setKeywordTypeIds(List<String> keywordTypeIds) { @@ -214,7 +221,6 @@ public class ProductSearch { /** * Sets status id. - * * @param statusId the status id */ public void setStatusId(String statusId) { @@ -233,7 +239,6 @@ public class ProductSearch { /** * Gets delegator. - * * @return the delegator */ public Delegator getDelegator() { @@ -242,7 +247,6 @@ public class ProductSearch { /** * Add product search constraints. - * * @param productSearchConstraintList the product search constraint list */ public void addProductSearchConstraints(List<ProductSearchConstraint> productSearchConstraintList) { @@ -254,7 +258,6 @@ public class ProductSearch { /** * Sets result sort order. - * * @param resultSortOrder the result sort order */ public void setResultSortOrder(ResultSortOrder resultSortOrder) { @@ -263,7 +266,6 @@ public class ProductSearch { /** * Sets result offset. - * * @param resultOffset the result offset */ public void setResultOffset(Integer resultOffset) { @@ -1050,7 +1052,6 @@ public class ProductSearch { /** * Gets product category id. - * * @return the product category id */ public String getProductCategoryId() { @@ -1058,7 +1059,6 @@ public class ProductSearch { } /** * Is include sub categories boolean. - * * @return the boolean */ public boolean isIncludeSubCategories() { @@ -1066,7 +1066,6 @@ public class ProductSearch { } /** * Gets exclude. - * * @return the exclude */ public Boolean getExclude() { @@ -1219,7 +1218,6 @@ public class ProductSearch { /** * Gets product feature id. - * * @return the product feature id */ public String getProductFeatureId() { @@ -1228,7 +1226,6 @@ public class ProductSearch { /** * Gets exclude. - * * @return the exclude */ public Boolean getExclude() { @@ -1343,7 +1340,6 @@ public class ProductSearch { /** * Gets product feature category id. - * * @return the product feature category id */ public String getProductFeatureCategoryId() { @@ -1352,7 +1348,6 @@ public class ProductSearch { /** * Gets exclude. - * * @return the exclude */ public Boolean getExclude() { @@ -1469,7 +1464,6 @@ public class ProductSearch { /** * Gets product feature group id. - * * @return the product feature group id */ public String getProductFeatureGroupId() { @@ -1478,7 +1472,6 @@ public class ProductSearch { /** * Gets exclude. - * * @return the exclude */ public Boolean getExclude() { @@ -1716,7 +1709,6 @@ public class ProductSearch { /** * Gets keywords string. - * * @return the keywords string */ public String getKeywordsString() { @@ -1725,7 +1717,6 @@ public class ProductSearch { /** * Is any prefix boolean. - * * @return the boolean */ public boolean isAnyPrefix() { @@ -1734,7 +1725,6 @@ public class ProductSearch { /** * Is any suffix boolean. - * * @return the boolean */ public boolean isAnySuffix() { @@ -1743,7 +1733,6 @@ public class ProductSearch { /** * Is and boolean. - * * @return the boolean */ public boolean isAnd() { @@ -1956,9 +1945,9 @@ public class ProductSearch { @SuppressWarnings("serial") public static class StoreGroupPriceConstraint extends ProductSearchConstraint { public static final String CONSTRAIN_NAME = "StoreGroupPrice"; - protected String productStoreGroupId; - protected String productPriceTypeId; - protected String currencyUomId; + private String productStoreGroupId; + private String productPriceTypeId; + private String currencyUomId; public StoreGroupPriceConstraint(String productStoreGroupId, String productPriceTypeId, String currencyUomId) { this.productStoreGroupId = productStoreGroupId; @@ -2046,7 +2035,8 @@ public class ProductSearch { } /* (non-Javadoc) - * @see org.apache.ofbiz.product.product.ProductSearch.ProductSearchConstraint#prettyPrintConstraint(org.apache.ofbiz.service.LocalDispatcher, boolean, java.util.Locale) + * @see org.apache.ofbiz.product.product.ProductSearch.ProductSearchConstraint#prettyPrintConstraint( + * org.apache.ofbiz.service.LocalDispatcher, boolean, java.util.Locale) */ @Override public String prettyPrintConstraint(LocalDispatcher dispatcher, boolean detailed, Locale locale) { @@ -2064,7 +2054,6 @@ public class ProductSearch { /** * Gets low price. - * * @return the low price */ public BigDecimal getLowPrice() { @@ -2073,7 +2062,6 @@ public class ProductSearch { /** * Gets high price. - * * @return the high price */ public BigDecimal getHighPrice() { @@ -2096,26 +2084,37 @@ public class ProductSearch { productSearchContext.dynamicViewEntity.addMemberEntity(entityAlias, "ProductPrice"); productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ProductPriceTypeId", "productPriceTypeId", null, null, null, null); - productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ProductPricePurposeId", "productPricePurposeId", null, null, null, null); + productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ProductPricePurposeId", "productPricePurposeId", + null, null, null, null); productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "CurrencyUomId", "currencyUomId", null, null, null, null); - productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ProductStoreGroupId", "productStoreGroupId", null, null, null, null); + productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ProductStoreGroupId", "productStoreGroupId", null, + null, null, null); productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "FromDate", "fromDate", null, null, null, null); productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ThruDate", "thruDate", null, null, null, null); productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "Price", "price", null, null, null, null); productSearchContext.dynamicViewEntity.addViewLink("PROD", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId")); - productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "ProductPriceTypeId", EntityOperator.EQUALS, "LIST_PRICE")); - productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "ProductPricePurposeId", EntityOperator.EQUALS, "PURCHASE")); - productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "CurrencyUomId", EntityOperator.EQUALS, currencyUomId)); - productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "ProductStoreGroupId", EntityOperator.EQUALS, "_NA_")); - productSearchContext.entityConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.GREATER_THAN, productSearchContext.nowTimestamp))); - productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "FromDate", EntityOperator.LESS_THAN, productSearchContext.nowTimestamp)); + productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "ProductPriceTypeId", + EntityOperator.EQUALS, "LIST_PRICE")); + productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "ProductPricePurposeId", + EntityOperator.EQUALS, "PURCHASE")); + productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "CurrencyUomId", + EntityOperator.EQUALS, currencyUomId)); + productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "ProductStoreGroupId", + EntityOperator.EQUALS, "_NA_")); + productSearchContext.entityConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition(prefix + "ThruDate", + EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition(prefix + "ThruDate", + EntityOperator.GREATER_THAN, productSearchContext.nowTimestamp))); + productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "FromDate", + EntityOperator.LESS_THAN, productSearchContext.nowTimestamp)); if (this.lowPrice != null) { - productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "Price", EntityOperator.GREATER_THAN_EQUAL_TO, this.lowPrice)); + productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "Price", + EntityOperator.GREATER_THAN_EQUAL_TO, this.lowPrice)); } if (this.highPrice != null) { - productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "Price", EntityOperator.LESS_THAN_EQUAL_TO, this.highPrice)); + productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "Price", + EntityOperator.LESS_THAN_EQUAL_TO, this.highPrice)); } // add in productSearchConstraint, don't worry about the productSearchResultId or constraintSeqId, those will be fill in later @@ -2213,7 +2212,6 @@ public class ProductSearch { /** * Gets supplier party id. - * * @return the supplier party id */ public String getSupplierPartyId() { @@ -2329,7 +2327,8 @@ public class ProductSearch { } /* (non-Javadoc) - * @see org.apache.ofbiz.product.product.ProductSearch.ProductSearchConstraint#prettyPrintConstraint(org.apache.ofbiz.service.LocalDispatcher, boolean, java.util.Locale) + * @see org.apache.ofbiz.product.product.ProductSearch.ProductSearchConstraint#prettyPrintConstraint( + * org.apache.ofbiz.service.LocalDispatcher, boolean, java.util.Locale) */ @Override public String prettyPrintConstraint(LocalDispatcher dispatcher, boolean detailed, Locale locale) { @@ -2392,9 +2391,9 @@ public class ProductSearch { @SuppressWarnings("serial") public static class GoodIdentificationConstraint extends ProductSearchConstraint { public static final String CONSTRAIN_NAME = "GoodIdentification"; - protected String goodIdentificationTypeId; - protected String goodIdentificationValue; - protected Boolean include; + private String goodIdentificationTypeId; + private String goodIdentificationValue; + private Boolean include; public GoodIdentificationConstraint(String goodIdentificationTypeId, String goodIdentificationValue, Boolean include) { this.goodIdentificationTypeId = goodIdentificationTypeId; @@ -2635,7 +2634,6 @@ public class ProductSearch { /** * Gets field name. - * * @return the field name */ public String getFieldName() { @@ -2702,7 +2700,6 @@ public class ProductSearch { /** * Gets product price type id. - * * @return the product price type id */ public String getProductPriceTypeId() { @@ -2801,7 +2798,6 @@ public class ProductSearch { /** * Gets product feature type id. - * * @return the product feature type id */ public String getProductFeatureTypeId() { 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 faccf7d..5ae9c19 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 @@ -104,7 +104,6 @@ public class ProductSearchSession { /** * Gets constraint list. - * * @return the constraint list */ public List<ProductSearchConstraint> getConstraintList() { @@ -126,7 +125,6 @@ public class ProductSearchSession { /** * Gets result sort order. - * * @return the result sort order */ public ResultSortOrder getResultSortOrder() { @@ -270,7 +268,6 @@ public class ProductSearchSession { /** * Gets top product category id. - * * @return the top product category id */ public String getTopProductCategoryId() { @@ -284,7 +281,6 @@ public class ProductSearchSession { /** * Sets top product category id. - * * @param topProductCategoryId the top product category id */ public void setTopProductCategoryId(String topProductCategoryId) { @@ -303,7 +299,6 @@ public class ProductSearchSession { /** * Search get constraint strings list. - * * @param detailed the detailed * @param delegator the delegator * @param locale the locale @@ -331,7 +326,6 @@ public class ProductSearchSession { /** * Search get constraint strings list. - * * @param detailed the detailed * @param dispatcher the dispatcher * @param locale the locale diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java index 7b47f48..84b9f90 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java @@ -1083,7 +1083,7 @@ public class ProductServices { /* store the imageUrl version of the image, for backwards compatibility with code that does not use scaled versions */ Map<String, Object> result = addImageResource(dispatcher, delegator, context, imageUrl, productContentTypeId); - if ( ServiceUtil.isError(result)) { + if (ServiceUtil.isError(result)) { return result; } @@ -1092,7 +1092,7 @@ public class ProductServices { Map<String, String> imageUrlMap = UtilGenerics.cast(resultResize.get("imageUrlMap")); for (String sizeType : ScaleImage.sizeTypeList) { imageUrl = imageUrlMap.get(sizeType); - if ( UtilValidate.isNotEmpty(imageUrl)) { + if (UtilValidate.isNotEmpty(imageUrl)) { try { GenericValue productContentType = EntityQuery.use(delegator) .from("ProductContentType") @@ -1101,7 +1101,7 @@ public class ProductServices { .queryOne(); if (UtilValidate.isNotEmpty(productContentType)) { result = addImageResource(dispatcher, delegator, context, imageUrl, "XTRA_IMG_" + viewNumber + "_" + sizeType.toUpperCase(Locale.getDefault())); - if ( ServiceUtil.isError(result)) { + if (ServiceUtil.isError(result)) { Debug.logError(ServiceUtil.getErrorMessage(result), MODULE); return result; } @@ -1116,7 +1116,7 @@ public class ProductServices { return ServiceUtil.returnSuccess(); } - private static Map<String, Object> addImageResource( LocalDispatcher dispatcher, Delegator delegator, Map<String, ? extends Object> context, + private static Map<String, Object> addImageResource(LocalDispatcher dispatcher, Delegator delegator, Map<String, ? extends Object> context, String imageUrl, String productContentTypeId ) { GenericValue userLogin = (GenericValue) context.get("userLogin"); String productId = (String) context.get("productId"); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductWorker.java b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductWorker.java index b0964a5..f8fa945 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductWorker.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductWorker.java @@ -1234,7 +1234,7 @@ public final class ProductWorker { product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache(true).queryOne(); Boolean isMarketingPackage = EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG"); - if ( UtilValidate.isNotEmpty(isMarketingPackage) && isMarketingPackage) { + if (UtilValidate.isNotEmpty(isMarketingPackage) && isMarketingPackage) { Map<String, Object> resultOutput = new HashMap<>(); resultOutput = dispatcher.runSync("getMktgPackagesAvailable", UtilMisc.toMap("productId", productId)); Debug.logWarning("Error getting available marketing package.", MODULE); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreSurveyWrapper.java b/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreSurveyWrapper.java index f9ce5d5..aded7df 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreSurveyWrapper.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/store/ProductStoreSurveyWrapper.java @@ -32,20 +32,21 @@ public class ProductStoreSurveyWrapper extends SurveyWrapper { private static final String MODULE = ProductStoreSurveyWrapper.class.getName(); - protected GenericValue productStoreSurveyAppl = null; - protected String surveyTemplate = null; - protected String resultTemplate = null; - protected boolean callResult = false; + private GenericValue productStoreSurveyAppl = null; + private String surveyTemplate = null; + private String resultTemplate = null; + private boolean callResult = false; protected ProductStoreSurveyWrapper() { } - public ProductStoreSurveyWrapper(GenericValue productStoreSurveyAppl, String partyId, Map<String, Object> passThru, Map<String, Object> defaultValues) { + public ProductStoreSurveyWrapper(GenericValue productStoreSurveyAppl, String partyId, Map<String, Object> passThru, + Map<String, Object> defaultValues) { this.productStoreSurveyAppl = productStoreSurveyAppl; if (this.productStoreSurveyAppl != null) { - this.partyId = partyId; - this.delegator = productStoreSurveyAppl.getDelegator(); - this.surveyId = productStoreSurveyAppl.getString("surveyId"); + this.setPartyId(partyId); + this.setDelegator(productStoreSurveyAppl.getDelegator()); + this.setSurveyId(productStoreSurveyAppl.getString("surveyId")); this.surveyTemplate = productStoreSurveyAppl.getString("surveyTemplate"); this.resultTemplate = productStoreSurveyAppl.getString("resultTemplate"); } else { @@ -65,10 +66,19 @@ public class ProductStoreSurveyWrapper extends SurveyWrapper { this(productStoreSurveyAppl, partyId, passThru, null); } + /** + * Call result. + * @param b the b + */ public void callResult(boolean b) { this.callResult = b; } + /** + * Render writer. + * @return the writer + * @throws SurveyWrapperException the survey wrapper exception + */ public Writer render() throws SurveyWrapperException { if (canRespond() && !callResult) { return renderSurvey(); @@ -79,10 +89,20 @@ public class ProductStoreSurveyWrapper extends SurveyWrapper { } } + /** + * Render survey writer. + * @return the writer + * @throws SurveyWrapperException the survey wrapper exception + */ public Writer renderSurvey() throws SurveyWrapperException { return this.render(surveyTemplate); } + /** + * Render result writer. + * @return the writer + * @throws SurveyWrapperException the survey wrapper exception + */ public Writer renderResult() throws SurveyWrapperException { return this.render(resultTemplate); } 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 3a6d6fd..c46a71d 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 @@ -305,7 +305,7 @@ public class SubscriptionServices { return ServiceUtil.returnSuccess(); } - public static Map<String, Object> runServiceOnSubscriptionExpiry( DispatchContext dctx, Map<String, ? extends Object> context) { + 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"); diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java index d4c395a..c7eb7eb 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/packing/PackingSession.java @@ -296,7 +296,8 @@ public class PackingSession implements java.io.Serializable { * @param packageSeq the package seq * @return the packing session line */ - public PackingSessionLine findLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, int packageSeq) { + public PackingSessionLine findLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, + int packageSeq) { for (PackingSessionLine line: this.getLines()) { if (orderId.equals(line.getOrderId()) && orderItemSeqId.equals(line.getOrderItemSeqId()) @@ -887,15 +888,15 @@ public class PackingSession implements java.io.Serializable { */ public void clearLine(PackingSessionLine line) { this.packLines.remove(line); - BigDecimal packageWeight = this.packageWeights.get(line.packageSeq); + BigDecimal packageWeight = this.packageWeights.get(line.getPackageSeq()); if (packageWeight != null) { - packageWeight = packageWeight.subtract(line.weight); + packageWeight = packageWeight.subtract(line.getWeight()); if (packageWeight.compareTo(BigDecimal.ZERO) < 0) { packageWeight = BigDecimal.ZERO; } - this.packageWeights.put(line.packageSeq, packageWeight); + this.packageWeights.put(line.getPackageSeq(), packageWeight); } - if (line.packageSeq == packageSeq && packageSeq > 1) { + if (line.getPackageSeq() == packageSeq && packageSeq > 1) { packageSeq--; } } @@ -1525,7 +1526,6 @@ public class PackingSession implements java.io.Serializable { /** * Instantiates a new Item display. - * * @param v the v */ ItemDisplay(GenericValue v) { @@ -1548,7 +1548,6 @@ public class PackingSession implements java.io.Serializable { /** * Gets order item. - * * @return the order item */ public GenericValue getOrderItem() { @@ -1557,7 +1556,6 @@ public class PackingSession implements java.io.Serializable { /** * Gets quantity. - * * @return the quantity */ public BigDecimal getQuantity() { 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 f9c99fb..d222809 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 @@ -36,20 +36,20 @@ public class PackingSessionLine implements java.io.Serializable { private static final String MODULE = PackingSessionLine.class.getName(); - protected String orderId = null; - protected String orderItemSeqId = null; - protected String shipGroupSeqId = null; - protected String productId = null; - protected String inventoryItemId = null; - protected String shipmentItemSeqId = null; - protected BigDecimal quantity = BigDecimal.ZERO; - protected BigDecimal weight = BigDecimal.ZERO; - protected BigDecimal height = null; - protected BigDecimal width = null; - protected BigDecimal length = null; - protected String shipmentBoxTypeId = null; - protected String weightPackageSeqId = null; - protected int packageSeq = 0; + private String orderId = null; + private String orderItemSeqId = null; + private String shipGroupSeqId = null; + private String productId = null; + private String inventoryItemId = null; + private String shipmentItemSeqId = null; + private BigDecimal quantity = BigDecimal.ZERO; + private BigDecimal weight = BigDecimal.ZERO; + private BigDecimal height = null; + private BigDecimal width = null; + private BigDecimal length = null; + private String shipmentBoxTypeId = null; + 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) { this.orderId = orderId; @@ -67,102 +67,203 @@ public class PackingSessionLine implements java.io.Serializable { this.packageSeq = packageSeq; } + /** + * Gets order id. + * @return the order id + */ public String getOrderId() { return this.orderId; } + /** + * Gets order item seq id. + * @return the order item seq id + */ public String getOrderItemSeqId() { return this.orderItemSeqId; } + /** + * Gets ship group seq id. + * @return the ship group seq id + */ public String getShipGroupSeqId() { return this.shipGroupSeqId; } + /** + * Gets inventory item id. + * @return the inventory item id + */ public String getInventoryItemId() { return this.inventoryItemId; } + /** + * Gets product id. + * @return the product id + */ public String getProductId() { return this.productId; } + /** + * Gets shipment item seq id. + * @return the shipment item seq id + */ public String getShipmentItemSeqId() { return this.shipmentItemSeqId; } + /** + * Sets shipment item seq id. + * @param shipmentItemSeqId the shipment item seq id + */ public void setShipmentItemSeqId(String shipmentItemSeqId) { this.shipmentItemSeqId = shipmentItemSeqId; } + /** + * Gets quantity. + * @return the quantity + */ public BigDecimal getQuantity() { return this.quantity; } + /** + * Sets quantity. + * @param quantity the quantity + */ public void setQuantity(BigDecimal quantity) { this.quantity = quantity; } + /** + * Add quantity. + * @param quantity the quantity + */ public void addQuantity(BigDecimal quantity) { this.quantity = this.quantity.add(quantity); } + /** + * Gets weight. + * @return the weight + */ public BigDecimal getWeight() { return weight; } + /** + * Sets weight. + * @param weight the weight + */ public void setWeight(BigDecimal weight) { this.weight = weight; } + /** + * Add weight. + * @param weight the weight + */ public void addWeight(BigDecimal weight) { this.weight = this.weight.add(weight); } + /** + * Gets package seq. + * @return the package seq + */ public int getPackageSeq() { return this.packageSeq; } + /** + * Gets length. + * @return the length + */ public BigDecimal getLength() { return this.length; } + /** + * Sets length. + * @param length the length + */ public void setLength(BigDecimal length) { this.length = length; } + /** + * Gets width. + * @return the width + */ public BigDecimal getWidth() { return this.width; } + /** + * Sets width. + * @param width the width + */ public void setWidth(BigDecimal width) { this.width = width; } + /** + * Gets height. + * @return the height + */ public BigDecimal getHeight() { return this.height; } + /** + * Sets height. + * @param height the height + */ public void setHeight(BigDecimal height) { this.height = height; } + /** + * Gets shipment box type id. + * @return the shipment box type id + */ public String getShipmentBoxTypeId() { return this.shipmentBoxTypeId; } + /** + * Sets shipment box type id. + * @param shipmentBoxTypeId the shipment box type id + */ public void setShipmentBoxTypeId(String shipmentBoxTypeId) { this.shipmentBoxTypeId = shipmentBoxTypeId; } + /** + * Gets weight package seq id. + * @return the weight package seq id + */ public String getWeightPackageSeqId() { return this.weightPackageSeqId; } + /** + * Sets weight package seq id. + * @param weightPackageSeqId the weight package seq id + */ public void setWeightPackageSeqId(String weightPackageSeqId) { this.weightPackageSeqId = weightPackageSeqId; } + /** + * Is same item boolean. + * @param line the line + * @return the boolean + */ public boolean isSameItem(PackingSessionLine line) { if (this.getInventoryItemId().equals(line.getInventoryItemId())) { if (this.getOrderItemSeqId().equals(line.getOrderItemSeqId())) { @@ -176,7 +277,17 @@ public class PackingSessionLine implements java.io.Serializable { return false; } - protected void issueItemToShipment(String shipmentId, String picklistBinId, GenericValue userLogin, BigDecimal quantity, LocalDispatcher dispatcher) throws GeneralException { + /** + * Issue item to shipment. + * @param shipmentId the shipment id + * @param picklistBinId the picklist bin id + * @param userLogin the user login + * @param quantity the quantity + * @param dispatcher the dispatcher + * @throws GeneralException the general exception + */ + protected void issueItemToShipment(String shipmentId, String picklistBinId, GenericValue userLogin, BigDecimal quantity, + LocalDispatcher dispatcher) throws GeneralException { if (quantity == null) { quantity = this.getQuantity(); } @@ -239,6 +350,13 @@ public class PackingSessionLine implements java.io.Serializable { } } + /** + * Apply line to package. + * @param shipmentId the shipment id + * @param userLogin the user login + * @param dispatcher the dispatcher + * @throws GeneralException the general exception + */ protected void applyLineToPackage(String shipmentId, GenericValue userLogin, LocalDispatcher dispatcher) throws GeneralException { // assign item to package String shipmentPackageSeqId = UtilFormatOut.formatPaddedNumber(this.getPackageSeq(), 5); diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/test/IssuanceTest.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/test/IssuanceTest.java index 668180d..17d5686 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/test/IssuanceTest.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/test/IssuanceTest.java @@ -61,7 +61,7 @@ public class IssuanceTest extends OFBizTestCase { List<GenericValue> orderShipments = orderHeader.getRelated("OrderShipment", null, null, false); assertFalse("No OrderShipment for order", UtilValidate.isEmpty(orderShipments)); - assertEquals( "Incorrect number of OrderShipments for order", 1, orderShipments.size()); + assertEquals("Incorrect number of OrderShipments for order", 1, orderShipments.size()); GenericValue orderShipment = orderShipments.get(0); assertEquals(orderItemSeqId, orderShipment.getString("orderItemSeqId")); @@ -74,7 +74,7 @@ public class IssuanceTest extends OFBizTestCase { // Test the ItemIssuances are correct List<GenericValue> itemIssuances = orderHeader.getRelated("ItemIssuance", null, UtilMisc.toList("inventoryItemId"), false); assertFalse("No ItemIssuances for order", UtilValidate.isEmpty(itemIssuances)); - assertEquals( "Incorrect number of ItemIssuances for order", 2, itemIssuances.size()); + assertEquals("Incorrect number of ItemIssuances for order", 2, itemIssuances.size()); GenericValue itemIssuance = itemIssuances.get(0); assertEquals(orderItemSeqId, itemIssuance.getString("orderItemSeqId")); diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSession.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSession.java index 1af6720..38b767c 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSession.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/verify/VerifyPickSession.java @@ -42,17 +42,20 @@ import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ServiceContainer; import org.apache.ofbiz.service.ServiceUtil; +/** + * The type Verify pick session. + */ @SuppressWarnings("serial") public class VerifyPickSession implements Serializable { private static final String MODULE = VerifyPickSession.class.getName(); - protected GenericValue userLogin = null; - protected String dispatcherName = null; - protected String delegatorName = null; - protected String picklistBinId = null; - protected String facilityId = null; - protected List<VerifyPickSessionRow> pickRows = null; + private GenericValue userLogin = null; + private String dispatcherName = null; + private String delegatorName = null; + private String picklistBinId = null; + private String facilityId = null; + private List<VerifyPickSessionRow> pickRows = null; private transient Delegator _delegator = null; private transient LocalDispatcher _dispatcher = null; @@ -152,7 +155,8 @@ public class VerifyPickSession implements Serializable { } } - protected String findOrderItemSeqId(String productId, String orderId, String shipGroupSeqId, BigDecimal quantity, Locale locale) throws GeneralException { + protected String findOrderItemSeqId(String productId, String orderId, String shipGroupSeqId, BigDecimal quantity, Locale locale) + throws GeneralException { Map<String, Object> orderItemLookupMap = new HashMap<>(); orderItemLookupMap.put("orderId", orderId); @@ -188,7 +192,8 @@ public class VerifyPickSession implements Serializable { } } - protected int checkRowForAdd(GenericValue reservation, String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, BigDecimal quantity) { + protected int checkRowForAdd(GenericValue reservation, String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, + BigDecimal quantity) { // check to see if the reservation can hold the requested quantity amount String inventoryItemId = reservation.getString("inventoryItemId"); BigDecimal resQty = reservation.getBigDecimal("quantity"); @@ -211,7 +216,8 @@ public class VerifyPickSession implements Serializable { } } - protected void createVerifyPickRow(int checkCode, GenericValue res, String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String originGeoId, BigDecimal quantity, Locale locale) throws GeneralException { + protected void createVerifyPickRow(int checkCode, GenericValue res, String orderId, String orderItemSeqId, String shipGroupSeqId, + String productId, String originGeoId, BigDecimal quantity, Locale locale) throws GeneralException { // process the result; add new item if necessary switch (checkCode) { case 0: @@ -231,30 +237,59 @@ public class VerifyPickSession implements Serializable { } } + /** + * Gets user login. + * @return the user login + */ public GenericValue getUserLogin() { return this.userLogin; } + /** + * Sets facility id. + * @param facilityId the facility id + */ public void setFacilityId(String facilityId) { this.facilityId = facilityId; } + /** + * Gets facility id. + * @return the facility id + */ public String getFacilityId() { return this.facilityId; } + /** + * Sets picklist bin id. + * @param setPicklistBinId the set picklist bin id + */ public void setPicklistBinId(String setPicklistBinId) { this.picklistBinId = setPicklistBinId; } + /** + * Gets picklist bin id. + * @return the picklist bin id + */ public String getPicklistBinId() { return this.picklistBinId; } + /** + * Gets pick rows. + * @return the pick rows + */ public List<VerifyPickSessionRow> getPickRows() { return this.pickRows; } + /** + * Gets pick rows. + * @param orderId the order id + * @return the pick rows + */ public List<VerifyPickSessionRow> getPickRows(String orderId) { List<VerifyPickSessionRow> pickVerifyRows = new LinkedList<>(); for (VerifyPickSessionRow line: this.getPickRows()) { @@ -288,7 +323,8 @@ public class VerifyPickSession implements Serializable { public BigDecimal getVerifiedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId) { BigDecimal total = BigDecimal.ZERO; for (VerifyPickSessionRow pickRow : this.getPickRows(orderId)) { - if (orderItemSeqId.equals(pickRow.getOrderItemSeqId()) && shipGroupSeqId.equals(pickRow.getShipGroupSeqId()) && productId.equals(pickRow.getProductId())) { + if (orderItemSeqId.equals(pickRow.getOrderItemSeqId()) && shipGroupSeqId.equals(pickRow.getShipGroupSeqId()) + && productId.equals(pickRow.getProductId())) { if (inventoryItemId == null || inventoryItemId.equals(pickRow.getInventoryItemId())) { total = total.add(pickRow.getReadyToVerifyQty()); } @@ -297,10 +333,20 @@ public class VerifyPickSession implements Serializable { return total; } + /** + * Clear all rows. + */ public void clearAllRows() { this.pickRows.clear(); } + /** + * Complete string. + * @param orderId the order id + * @param locale the locale + * @return the string + * @throws GeneralException the general exception + */ public String complete(String orderId, Locale locale) throws GeneralException { this.checkVerifiedQty(orderId, locale); // check reserved quantity, it should be equal to verified quantity diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java index 502ec9c..5812ef4 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSession.java @@ -43,41 +43,44 @@ import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ServiceContainer; import org.apache.ofbiz.service.ServiceUtil; +/** + * The type Weight package session. + */ @SuppressWarnings("serial") public class WeightPackageSession implements Serializable { private static final String MODULE = WeightPackageSession.class.getName(); - protected GenericValue userLogin = null; - protected String dispatcherName = null; - protected String delegatorName = null; - protected String primaryOrderId = null; - protected String primaryShipGrpSeqId = null; - protected String picklistBinId = null; - protected String shipmentId = null; - protected String invoiceId = null; - protected String facilityId = null; - protected String carrierPartyId = null; - protected String dimensionUomId = null; - protected String weightUomId = null; - protected BigDecimal estimatedShipCost = null; - protected BigDecimal actualShipCost = null; - protected int weightPackageSeqId = 1; - protected List<WeightPackageSessionLine> weightPackageLines = null; - - private transient Delegator _delegator = null; - private transient LocalDispatcher _dispatcher = null; + private GenericValue userLogin = null; + private String dispatcherName = null; + private String delegatorName = null; + private String primaryOrderId = null; + private String primaryShipGrpSeqId = null; + private String picklistBinId = null; + private String shipmentId = null; + private String invoiceId = null; + private String facilityId = null; + private String carrierPartyId = null; + private String dimensionUomId = null; + private String weightUomId = null; + private BigDecimal estimatedShipCost = null; + private BigDecimal actualShipCost = null; + private int weightPackageSeqId = 1; + private List<WeightPackageSessionLine> weightPackageLines = null; + + private transient Delegator delegator = null; + private transient LocalDispatcher dispatcher = null; private static final RoundingMode ROUNDING_MODE = UtilNumber.getRoundingMode("invoice.rounding"); public WeightPackageSession() { } public WeightPackageSession(LocalDispatcher dispatcher, GenericValue userLogin, String facilityId, String picklistBinId, String orderId, String shipGrpSeqId) { - this._dispatcher = dispatcher; + this.dispatcher = dispatcher; this.dispatcherName = dispatcher.getName(); - this._delegator = _dispatcher.getDelegator(); - this.delegatorName = _delegator.getDelegatorName(); + this.delegator = dispatcher.getDelegator(); + this.delegatorName = delegator.getDelegatorName(); this.primaryOrderId = orderId; this.primaryShipGrpSeqId = shipGrpSeqId; @@ -95,18 +98,26 @@ public class WeightPackageSession implements Serializable { this(dispatcher, userLogin, null, null, null, null); } + /** + * Gets dispatcher. + * @return the dispatcher + */ public LocalDispatcher getDispatcher() { - if (_dispatcher == null) { - _dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, this.getDelegator()); + if (dispatcher == null) { + dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, this.getDelegator()); } - return _dispatcher; + return dispatcher; } + /** + * Gets delegator. + * @return the delegator + */ public Delegator getDelegator() { - if (_delegator == null) { - _delegator = DelegatorFactory.getDelegator(delegatorName); + if (delegator == null) { + delegator = DelegatorFactory.getDelegator(delegatorName); } - return _delegator; + return delegator; } public void createWeightPackageLine(String orderId, BigDecimal packageWeight, BigDecimal packageLength, BigDecimal packageWidth, BigDecimal packageHeight, String shipmentBoxTypeId) throws GeneralException { @@ -114,94 +125,187 @@ public class WeightPackageSession implements Serializable { this.weightPackageSeqId++; } + /** + * Gets weight package seq id. + * @return the weight package seq id + */ public int getWeightPackageSeqId() { return this.weightPackageSeqId; } + /** + * Gets facility id. + * @return the facility id + */ public String getFacilityId() { return this.facilityId; } + /** + * Sets facility id. + * @param facilityId the facility id + */ public void setFacilityId(String facilityId) { this.facilityId = facilityId; } + /** + * Gets primary order id. + * @return the primary order id + */ public String getPrimaryOrderId() { return this.primaryOrderId; } + /** + * Sets primary order id. + * @param primaryOrderId the primary order id + */ public void setPrimaryOrderId(String primaryOrderId) { this.primaryOrderId = primaryOrderId; } + /** + * Gets primary ship group seq id. + * @return the primary ship group seq id + */ public String getPrimaryShipGroupSeqId() { return this.primaryShipGrpSeqId; } + /** + * Sets primary ship group seq id. + * @param primaryShipGrpSeqId the primary ship grp seq id + */ public void setPrimaryShipGroupSeqId(String primaryShipGrpSeqId) { this.primaryShipGrpSeqId = primaryShipGrpSeqId; } + /** + * Sets picklist bin id. + * @param picklistBinId the picklist bin id + */ public void setPicklistBinId(String picklistBinId) { this.picklistBinId = picklistBinId; } + /** + * Gets picklist bin id. + * @return the picklist bin id + */ public String getPicklistBinId() { return this.picklistBinId; } + /** + * Sets estimated ship cost. + * @param estimatedShipCost the estimated ship cost + */ public void setEstimatedShipCost(BigDecimal estimatedShipCost) { this.estimatedShipCost = estimatedShipCost; } + /** + * Gets estimated ship cost. + * @return the estimated ship cost + */ public BigDecimal getEstimatedShipCost() { return this.estimatedShipCost; } + /** + * Sets actual ship cost. + * @param actualShipCost the actual ship cost + */ public void setActualShipCost(BigDecimal actualShipCost) { this.actualShipCost = actualShipCost; } + /** + * Gets actual ship cost. + * @return the actual ship cost + */ public BigDecimal getActualShipCost() { return this.actualShipCost; } + /** + * Gets shipment id. + * @return the shipment id + */ public String getShipmentId() { return this.shipmentId; } + /** + * Sets shipment id. + * @param shipmentId the shipment id + */ public void setShipmentId(String shipmentId) { this.shipmentId = shipmentId; } + /** + * Gets invoice id. + * @return the invoice id + */ public String getInvoiceId() { return this.invoiceId; } + /** + * Sets invoice id. + * @param invoiceId the invoice id + */ public void setInvoiceId(String invoiceId) { this.invoiceId = invoiceId; } + /** + * Gets weight uom id. + * @return the weight uom id + */ public String getWeightUomId() { return weightUomId; } + /** + * Sets weight uom id. + * @param weightUomId the weight uom id + */ public void setWeightUomId(String weightUomId) { this.weightUomId = weightUomId; } + /** + * Gets dimension uom id. + * @return the dimension uom id + */ public String getDimensionUomId() { return dimensionUomId; } + /** + * Sets carrier party id. + * @param carrierPartyId the carrier party id + */ public void setCarrierPartyId(String carrierPartyId) { this.carrierPartyId = carrierPartyId; } + /** + * Sets dimension uom id. + * @param dimensionUomId the dimension uom id + */ public void setDimensionUomId(String dimensionUomId) { this.dimensionUomId = dimensionUomId; } + /** + * Gets shippable weight. + * @param orderId the order id + * @return the shippable weight + */ public BigDecimal getShippableWeight(String orderId) { BigDecimal shippableWeight = BigDecimal.ZERO; for (WeightPackageSessionLine packedLine : this.getPackedLines(orderId)) { @@ -487,13 +591,16 @@ public class WeightPackageSession implements Serializable { } } - public BigDecimal getShipmentCostEstimate(GenericValue orderItemShipGroup, String orderId, String productStoreId, List<GenericValue> shippableItemInfo, BigDecimal shippableTotal, BigDecimal shippableWeight, BigDecimal shippableQuantity) { + public BigDecimal getShipmentCostEstimate(GenericValue orderItemShipGroup, String orderId, String productStoreId, List<GenericValue> + shippableItemInfo, BigDecimal shippableTotal, BigDecimal shippableWeight, BigDecimal shippableQuantity) { return getShipmentCostEstimate(orderItemShipGroup.getString("contactMechId"), orderItemShipGroup.getString("shipmentMethodTypeId"), orderItemShipGroup.getString("carrierPartyId"), orderItemShipGroup.getString("carrierRoleTypeId"), orderId, productStoreId, shippableItemInfo, shippableTotal, shippableWeight, shippableQuantity); } - public BigDecimal getShipmentCostEstimate(String shippingContactMechId, String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String orderId, String productStoreId, List<GenericValue> shippableItemInfo, BigDecimal shippableTotal, BigDecimal shippableWeight, BigDecimal shippableQuantity) { + public BigDecimal getShipmentCostEstimate(String shippingContactMechId, String shipmentMethodTypeId, String carrierPartyId, + String carrierRoleTypeId, String orderId, String productStoreId, List<GenericValue> shippableItemInfo, BigDecimal shippableTotal, + BigDecimal shippableWeight, BigDecimal shippableQuantity) { BigDecimal shipmentCostEstimate = BigDecimal.ZERO; Map<String, Object> shipCostEstimateResult = null; try { diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java index a0dc4ef..6ed58bf 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java +++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/weightPackage/WeightPackageSessionLine.java @@ -31,16 +31,17 @@ import org.apache.ofbiz.service.ServiceUtil; @SuppressWarnings("serial") public class WeightPackageSessionLine implements java.io.Serializable { - protected String orderId = null; - protected BigDecimal packageWeight = BigDecimal.ZERO; - protected BigDecimal packageLength = null; - protected BigDecimal packageWidth = null; - protected BigDecimal packageHeight = null; - protected String shipmentBoxTypeId = null; - protected String shipmentItemSeqId = null; - protected int weightPackageSeqId = 0; - - public WeightPackageSessionLine(String orderId, BigDecimal packageWeight, BigDecimal packageLength, BigDecimal packageWidth, BigDecimal packageHeight, String shipmentBoxTypeId, int weightPackageSeqId) throws GeneralException { + private String orderId = null; + private BigDecimal packageWeight = BigDecimal.ZERO; + private BigDecimal packageLength = null; + private BigDecimal packageWidth = null; + private BigDecimal packageHeight = null; + private String shipmentBoxTypeId = null; + private String shipmentItemSeqId = null; + private int weightPackageSeqId = 0; + + public WeightPackageSessionLine(String orderId, BigDecimal packageWeight, BigDecimal packageLength, BigDecimal packageWidth, + BigDecimal packageHeight, String shipmentBoxTypeId, int weightPackageSeqId) throws GeneralException { this.orderId = orderId; this.packageWeight = packageWeight; this.packageLength = packageLength; @@ -50,71 +51,144 @@ public class WeightPackageSessionLine implements java.io.Serializable { this.weightPackageSeqId = weightPackageSeqId; } + /** + * Gets order id. + * @return the order id + */ public String getOrderId() { return this.orderId; } + /** + * Sets order id. + * @param orderId the order id + */ public void setOrderId(String orderId) { this.orderId = orderId; } + /** + * Gets package weight. + * @return the package weight + */ public BigDecimal getPackageWeight() { return this.packageWeight; } + /** + * Sets package weight. + * @param packageWeight the package weight + */ public void setPackageWeight(BigDecimal packageWeight) { this.packageWeight = packageWeight; } + /** + * Gets package length. + * @return the package length + */ public BigDecimal getPackageLength() { return this.packageLength; } + /** + * Sets package length. + * @param packageLength the package length + */ public void setPackageLength(BigDecimal packageLength) { this.packageLength = packageLength; } + /** + * Gets package width. + * @return the package width + */ public BigDecimal getPackageWidth() { - return this.packageWidth; + return this.packageWidth; } + /** + * Sets package width. + * @param packageWidth the package width + */ public void setPackageWidth(BigDecimal packageWidth) { this.packageWidth = packageWidth; } + /** + * Gets package height. + * @return the package height + */ public BigDecimal getPackageHeight() { return this.packageHeight; } + /** + * Sets package height. + * @param packageHeight the package height + */ public void setPackageHeight(BigDecimal packageHeight) { this.packageHeight = packageHeight; } + /** + * Gets shipment box type id. + * @return the shipment box type id + */ public String getShipmentBoxTypeId() { return this.shipmentBoxTypeId; } + /** + * Sets shipment box type id. + * @param shipmentBoxTypeId the shipment box type id + */ public void setShipmentBoxTypeId(String shipmentBoxTypeId) { this.shipmentBoxTypeId = shipmentBoxTypeId; } + /** + * Gets weight package seq id. + * @return the weight package seq id + */ public int getWeightPackageSeqId() { return this.weightPackageSeqId; } + /** + * Sets weight package seq id. + * @param weightPackageSeqId the weight package seq id + */ public void setWeightPackageSeqId(int weightPackageSeqId) { this.weightPackageSeqId = weightPackageSeqId; } + /** + * Gets shipment item seq id. + * @return the shipment item seq id + */ public String getShipmentItemSeqId() { return this.shipmentItemSeqId; } + /** + * Sets shipment item seq id. + * @param shipmentItemSeqId the shipment item seq id + */ public void setShipmentItemSeqId(String shipmentItemSeqId) { this.shipmentItemSeqId = shipmentItemSeqId; } - protected void applyLineToPackage(String shipmentId, GenericValue userLogin, LocalDispatcher dispatcher, int shipPackSeqId) throws GeneralException { + /** + * Apply line to package. + * @param shipmentId the shipment id + * @param userLogin the user login + * @param dispatcher the dispatcher + * @param shipPackSeqId the ship pack seq id + * @throws GeneralException the general exception + */ + protected void applyLineToPackage(String shipmentId, GenericValue userLogin, LocalDispatcher dispatcher, int shipPackSeqId) + throws GeneralException { String shipmentPackageSeqId = UtilFormatOut.formatPaddedNumber(shipPackSeqId, 5); Map<String, Object> packageMap = new HashMap<>(); diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java index f1d6359..566fb61 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/content/WorkEffortContentWrapper.java @@ -56,12 +56,12 @@ public class WorkEffortContentWrapper implements ContentWrapper { private static final String MODULE = WorkEffortContentWrapper.class.getName(); public static final String CACHE_KEY_SEPARATOR = "::"; - private static final UtilCache<String, String> workEffortContentCache = UtilCache.createUtilCache("workeffort.content.rendered", true); + private static final UtilCache<String, String> WORK_EFFORT_CONTENT_CACHE = UtilCache.createUtilCache("workeffort.content.rendered", true); - protected LocalDispatcher dispatcher; - protected GenericValue workEffort; - protected Locale locale; - protected String mimeTypeId; + private LocalDispatcher dispatcher; + private GenericValue workEffort; + private Locale locale; + private String mimeTypeId; public WorkEffortContentWrapper(LocalDispatcher dispatcher, GenericValue workEffort, Locale locale, String mimeTypeId) { this.dispatcher = dispatcher; @@ -73,12 +73,14 @@ public class WorkEffortContentWrapper implements ContentWrapper { public WorkEffortContentWrapper(GenericValue workEffort, HttpServletRequest request) { this.workEffort = workEffort; 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")); } - // interface implementation(s) + /** interface implementation(s) */ public String get(String workEffortContentId, boolean useCache, String encoderType) { - return getWorkEffortContentAsText(workEffort, workEffortContentId, locale, mimeTypeId, workEffort.getDelegator(), dispatcher, useCache, encoderType); + return getWorkEffortContentAsText(workEffort, workEffortContentId, locale, mimeTypeId, workEffort.getDelegator(), dispatcher, useCache, + encoderType); } /** @@ -143,6 +145,11 @@ public class WorkEffortContentWrapper implements ContentWrapper { } } + /** + * Gets data resource id. + * @param contentTypeId the content type id + * @return the data resource id + */ public String getDataResourceId(String contentTypeId) { GenericValue workEffortContent = getFirstWorkEffortContentByType(null, workEffort, contentTypeId, workEffort.getDelegator(), true); if (workEffortContent != null) { @@ -170,6 +177,11 @@ public class WorkEffortContentWrapper implements ContentWrapper { return null; } + /** + * Gets list. + * @param contentTypeId the content type id + * @return the list + */ public List<String> getList(String contentTypeId) { try { return getWorkEffortContentTextList(workEffort, contentTypeId, locale, mimeTypeId, workEffort.getDelegator(), dispatcher); @@ -179,6 +191,11 @@ public class WorkEffortContentWrapper implements ContentWrapper { } } + /** + * Gets type description. + * @param contentTypeId the content type id + * @return the type description + */ public String getTypeDescription(String contentTypeId) { Delegator delegator = null; if (workEffort != null) { @@ -188,7 +205,8 @@ public class WorkEffortContentWrapper implements ContentWrapper { if (delegator != null) { GenericValue contentType = null; try { - contentType = EntityQuery.use(delegator).from("WorkEffortContentType").where("workEffortContentTypeId", contentTypeId).cache().queryOne(); + contentType = EntityQuery.use(delegator).from("WorkEffortContentType").where("workEffortContentTypeId", contentTypeId).cache() + .queryOne(); } catch (GeneralException e) { Debug.logError(e, MODULE); } @@ -201,28 +219,47 @@ public class WorkEffortContentWrapper implements ContentWrapper { return null; } + /** + * Gets content. + * @param contentId the content id + * @param useCache the use cache + * @param encoderType the encoder type + * @return the content + */ public String getContent(String contentId, boolean useCache, String encoderType) { - return getWorkEffortContentAsText(workEffort, contentId, null, locale, mimeTypeId, workEffort.getDelegator(), dispatcher, useCache, encoderType); + return getWorkEffortContentAsText(workEffort, contentId, null, locale, mimeTypeId, workEffort.getDelegator(), dispatcher, + useCache, encoderType); } + /** + * Gets content. + * @param contentId the content id + * @param encoderType the encoder type + * @return the content + */ public String getContent(String contentId, String encoderType) { return getContent(contentId, true, encoderType); } // static method helpers - public static String getWorkEffortContentAsText(GenericValue workEffort, String workEffortContentTypeId, HttpServletRequest request, String encoderType) { + public static String getWorkEffortContentAsText(GenericValue workEffort, String workEffortContentTypeId, HttpServletRequest request, + String encoderType) { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - String mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", workEffort.getDelegator()); - return getWorkEffortContentAsText(workEffort, workEffortContentTypeId, UtilHttp.getLocale(request), mimeTypeId, workEffort.getDelegator(), dispatcher, true, encoderType); + String mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", + workEffort.getDelegator()); + return getWorkEffortContentAsText(workEffort, workEffortContentTypeId, UtilHttp.getLocale(request), mimeTypeId, workEffort.getDelegator(), + dispatcher, true, encoderType); } - public static String getWorkEffortContentAsText(GenericValue workEffort, String workEffortContentTypeId, Locale locale, LocalDispatcher dispatcher, String encoderType) { + public static String getWorkEffortContentAsText(GenericValue workEffort, String workEffortContentTypeId, Locale locale, + LocalDispatcher dispatcher, String encoderType) { return getWorkEffortContentAsText(workEffort, workEffortContentTypeId, locale, null, null, dispatcher, true, encoderType); } public static String getWorkEffortContentAsText(GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, boolean useCache, String encoderType) { - return getWorkEffortContentAsText(workEffort, null, workEffortContentTypeId, locale, mimeTypeId, delegator, dispatcher, useCache, encoderType); + return getWorkEffortContentAsText(workEffort, null, workEffortContentTypeId, locale, mimeTypeId, delegator, dispatcher, useCache, + encoderType); } public static String getWorkEffortContentAsText(GenericValue workEffort, String contentId, String workEffortContentTypeId, @@ -244,22 +281,23 @@ public class WorkEffortContentWrapper implements ContentWrapper { try { if (useCache) { - String cachedValue = workEffortContentCache.get(cacheKey); + String cachedValue = WORK_EFFORT_CONTENT_CACHE.get(cacheKey); if (cachedValue != null) { return cachedValue; } } Writer outWriter = new StringWriter(); - getWorkEffortContentAsText(contentId, null, workEffort, workEffortContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter, false); + getWorkEffortContentAsText(contentId, null, workEffort, workEffortContentTypeId, locale, mimeTypeId, delegator, dispatcher, + outWriter, false); String outString = outWriter.toString(); if (UtilValidate.isEmpty(outString)) { outString = workEffort.getModelEntity().isField(candidateFieldName) ? workEffort.getString(candidateFieldName) : ""; outString = outString == null ? "" : outString; } outString = encoder.sanitize(outString, null); - if (workEffortContentCache != null) { - workEffortContentCache.put(cacheKey, outString); + if (WORK_EFFORT_CONTENT_CACHE != null) { + WORK_EFFORT_CONTENT_CACHE.put(cacheKey, outString); } return outString; } catch (GeneralException | IOException e) { @@ -269,11 +307,15 @@ public class WorkEffortContentWrapper implements ContentWrapper { } } - public static void getWorkEffortContentAsText(String contentId, String workEffortId, GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { + public static void getWorkEffortContentAsText(String contentId, String workEffortId, GenericValue workEffort, String workEffortContentTypeId, + Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, + Writer outWriter) throws GeneralException, IOException { getWorkEffortContentAsText(contentId, null, workEffort, workEffortContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter, true); } - public static void getWorkEffortContentAsText(String contentId, String workEffortId, GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, boolean cache) throws GeneralException, IOException { + public static void getWorkEffortContentAsText(String contentId, String workEffortId, GenericValue workEffort, String workEffortContentTypeId, + Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher, Writer outWriter, boolean cache) + throws GeneralException, IOException { if (workEffortId == null && workEffort != null) { workEffortId = workEffort.getString("workEffortId"); } @@ -293,7 +335,8 @@ public class WorkEffortContentWrapper implements ContentWrapper { // Honor work effort content over WorkEffort entity fields. GenericValue workEffortContent; if (contentId != null) { - workEffortContent = EntityQuery.use(delegator).from("WorkEffortContent").where("workEffortId", workEffortId, "contentId", contentId).cache(cache).queryOne(); + workEffortContent = EntityQuery.use(delegator).from("WorkEffortContent").where("workEffortId", workEffortId, "contentId", contentId) + .cache(cache).queryOne(); } else { workEffortContent = getFirstWorkEffortContentByType(workEffortId, workEffort, workEffortContentTypeId, delegator, cache); } @@ -302,7 +345,8 @@ public class WorkEffortContentWrapper implements ContentWrapper { Map<String, Object> inContext = new HashMap<>(); inContext.put("workEffort", workEffort); inContext.put("workEffortContent", workEffortContent); - ContentWorker.renderContentAsText(dispatcher, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false); + ContentWorker.renderContentAsText(dispatcher, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, + null, null, false); return; } // check for workeffort field @@ -321,7 +365,8 @@ public class WorkEffortContentWrapper implements ContentWrapper { } } } - public static List<String> getWorkEffortContentTextList(GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { + public static List<String> getWorkEffortContentTextList(GenericValue workEffort, String workEffortContentTypeId, Locale locale, + String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { List<GenericValue> partyContentList = EntityQuery.use(delegator).from("WorkEffortContent") .where("workEffortId", workEffort.getString("partyId"), "workEffortContentTypeId", workEffortContentTypeId) .orderBy("-fromDate") @@ -336,7 +381,8 @@ public class WorkEffortContentWrapper implements ContentWrapper { Map<String, Object> inContext = new HashMap<>(); inContext.put("workEffort", workEffort); inContext.put("workEffortContent", workEffortContent); - ContentWorker.renderContentAsText(dispatcher, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false); + ContentWorker.renderContentAsText(dispatcher, workEffortContent.getString("contentId"), outWriter, inContext, locale, + mimeTypeId, null, null, false); contentList.add(outWriter.toString()); } } @@ -344,7 +390,8 @@ public class WorkEffortContentWrapper implements ContentWrapper { return contentList; } - public static GenericValue getFirstWorkEffortContentByType(String workEffortId, GenericValue workEffort, String workEffortContentTypeId, Delegator delegator, boolean cache) { + public static GenericValue getFirstWorkEffortContentByType(String workEffortId, GenericValue workEffort, String workEffortContentTypeId, + Delegator delegator, boolean cache) { if (workEffortId == null && workEffort != null) { workEffortId = workEffort.getString("workEffortId"); } diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java index 6c8258d..b00646f 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalConverter.java @@ -472,12 +472,12 @@ public class ICalConverter { ModelService modelService = null; modelService = dispatcher.getDispatchContext().getModelService(serviceName); for (ModelParam modelParam: modelService.getInModelParamList()) { - if (serviceMap.containsKey(modelParam.name)) { - Object value = serviceMap.get(modelParam.name); - if (UtilValidate.isNotEmpty(modelParam.type)) { - value = ObjectType.simpleTypeOrObjectConvert(value, modelParam.type, null, null, null, true); + if (serviceMap.containsKey(modelParam.getName())) { + Object value = serviceMap.get(modelParam.getName()); + if (UtilValidate.isNotEmpty(modelParam.getType())) { + value = ObjectType.simpleTypeOrObjectConvert(value, modelParam.getType(), null, null, null, true); } - localMap.put(modelParam.name, value); + localMap.put(modelParam.getName(), value); } } } catch (GeneralException e) { @@ -496,7 +496,8 @@ public class ICalConverter { } return result; } catch (GenericServiceException e) { - String errMsg = UtilProperties.getMessage("WorkEffortUiLabels", "WorkeffortErrorWhileInvokingService", UtilMisc.toMap("serviceName", serviceName), locale); + String errMsg = UtilProperties.getMessage("WorkEffortUiLabels", "WorkeffortErrorWhileInvokingService", + UtilMisc.toMap("serviceName", serviceName), locale); Debug.logError(e, errMsg, MODULE); return ServiceUtil.returnError(errMsg + e); } @@ -849,7 +850,8 @@ public class ICalConverter { return storePartyAssignments(workEffortId, component, context); } - protected static ResponseProperties toCalendarComponent(ComponentList components, GenericValue workEffort, Map<String, Object> context) throws GenericEntityException { + protected static ResponseProperties toCalendarComponent(ComponentList components, GenericValue workEffort, Map<String, Object> context) + throws GenericEntityException { Delegator delegator = workEffort.getDelegator(); String workEffortId = workEffort.getString("workEffortId"); String workEffortUid = workEffort.getString("universalId"); diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java index 08e09af..47e4e58 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ICalRecurConverter.java @@ -61,7 +61,7 @@ import net.fortuna.ical4j.model.property.RRule; * when conversion is not possible. */ public class ICalRecurConverter implements TemporalExpressionVisitor { - protected static final WeekDay dayOfWeekArray[] = {WeekDay.SU, WeekDay.MO, WeekDay.TU, WeekDay.WE, WeekDay.TH, WeekDay.FR, WeekDay.SA}; + protected static final WeekDay DAY_OF_WEEK_ARRAY[] = {WeekDay.SU, WeekDay.MO, WeekDay.TU, WeekDay.WE, WeekDay.TH, WeekDay.FR, WeekDay.SA}; @SuppressWarnings("unchecked") public static void convert(TemporalExpression expr, PropertyList eventProps) { @@ -87,13 +87,13 @@ public class ICalRecurConverter implements TemporalExpressionVisitor { eventProps.addAll(converter.exRuleList); } - protected DtStart dateStart = null; - protected List<DateListProperty> incDateList = new LinkedList<>(); - protected List<DateListProperty> exDateList = new LinkedList<>(); - protected List<RRule> incRuleList = new LinkedList<>(); - protected List<ExRule> exRuleList = new LinkedList<>(); - protected VisitorState state = new VisitorState(); - protected Stack<VisitorState> stateStack = new Stack<>(); + private DtStart dateStart = null; + private List<DateListProperty> incDateList = new LinkedList<>(); + private List<DateListProperty> exDateList = new LinkedList<>(); + private List<RRule> incRuleList = new LinkedList<>(); + private List<ExRule> exRuleList = new LinkedList<>(); + private VisitorState state = new VisitorState(); + private Stack<VisitorState> stateStack = new Stack<>(); protected ICalRecurConverter() { } @@ -200,7 +200,7 @@ public class ICalRecurConverter implements TemporalExpressionVisitor { } @Override - public void visit(Null expr) {} + public void visit(Null expr) { } @Override public void visit(Substitution expr) { @@ -221,7 +221,7 @@ public class ICalRecurConverter implements TemporalExpressionVisitor { @Override public void visit(TemporalExpressions.DayInMonth expr) { Recur recur = new Recur(Recur.MONTHLY, 0); - recur.getDayList().add(new WeekDay(dayOfWeekArray[expr.getDayOfWeek() - 1], expr.getOccurrence())); + recur.getDayList().add(new WeekDay(DAY_OF_WEEK_ARRAY[expr.getDayOfWeek() - 1], expr.getOccurrence())); this.state.addRecur(recur); } @@ -247,13 +247,13 @@ public class ICalRecurConverter implements TemporalExpressionVisitor { int startDay = expr.getStartDay(); int endDay = expr.getEndDay(); WeekDayList dayList = new WeekDayList(); - dayList.add(dayOfWeekArray[startDay - 1]); + dayList.add(DAY_OF_WEEK_ARRAY[startDay - 1]); while (startDay != endDay) { startDay++; if (startDay > Calendar.SATURDAY) { startDay = Calendar.SUNDAY; } - dayList.add(dayOfWeekArray[startDay - 1]); + dayList.add(DAY_OF_WEEK_ARRAY[startDay - 1]); } Recur recur = new Recur(Recur.DAILY, 0); recur.getDayList().addAll(dayList); @@ -320,10 +320,15 @@ public class ICalRecurConverter implements TemporalExpressionVisitor { } protected class VisitorState { - public boolean isExcluded = false; - public boolean isIntersection = false; - public List<Recur> inclRecurList = new LinkedList<>(); - public List<Recur> exRecurList = new LinkedList<>(); + private boolean isExcluded = false; + private boolean isIntersection = false; + private List<Recur> inclRecurList = new LinkedList<>(); + private List<Recur> exRecurList = new LinkedList<>(); + + /** + * Add recur. + * @param recur the recur + */ public void addRecur(Recur recur) { if (this.isIntersection) { if (this.isExcluded) { diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java index 41e4bfa..08b0c60 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearch.java @@ -55,8 +55,6 @@ import org.apache.ofbiz.entity.util.EntityListIterator; import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.entity.util.EntityUtil; - - /** * Utilities for WorkEffort search based on various constraints including assocs, features and keywords. * @@ -133,24 +131,24 @@ public class WorkEffortSearch { } public static class WorkEffortSearchContext { - public int index = 1; - public List<EntityCondition> entityConditionList = new LinkedList<>(); - public List<String> orderByList = new LinkedList<>(); - public List<String> fieldsToSelect = UtilMisc.toList("workEffortId"); - public DynamicViewEntity dynamicViewEntity = new DynamicViewEntity(); - public boolean workEffortIdGroupBy = false; - public boolean includedKeywordSearch = false; - public Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); - public List<Set<String>> keywordFixedOrSetAndList = new LinkedList<>(); - public Set<String> orKeywordFixedSet = new HashSet<>(); - public Set<String> andKeywordFixedSet = new HashSet<>(); - public List<GenericValue> workEffortSearchConstraintList = new LinkedList<>(); - public ResultSortOrder resultSortOrder = null; - public Integer resultOffset = null; - public Integer maxResults = null; - protected Delegator delegator = null; - protected String visitId = null; - protected Integer totalResults = null; + private int index = 1; + private List<EntityCondition> entityConditionList = new LinkedList<>(); + private List<String> orderByList = new LinkedList<>(); + private List<String> fieldsToSelect = UtilMisc.toList("workEffortId"); + private DynamicViewEntity dynamicViewEntity = new DynamicViewEntity(); + private boolean workEffortIdGroupBy = false; + private boolean includedKeywordSearch = false; + private Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); + private List<Set<String>> keywordFixedOrSetAndList = new LinkedList<>(); + private Set<String> orKeywordFixedSet = new HashSet<>(); + private Set<String> andKeywordFixedSet = new HashSet<>(); + private List<GenericValue> workEffortSearchConstraintList = new LinkedList<>(); + private ResultSortOrder resultSortOrder = null; + private Integer resultOffset = null; + private Integer maxResults = null; + private Delegator delegator = null; + private String visitId = null; + private Integer totalResults = null; public WorkEffortSearchContext(Delegator delegator, String visitId) { this.delegator = delegator; @@ -158,10 +156,18 @@ public class WorkEffortSearch { dynamicViewEntity.addMemberEntity("WEFF", "WorkEffort"); } + /** + * Gets delegator. + * @return the delegator + */ public Delegator getDelegator() { return this.delegator; } + /** + * Add work effort search constraints. + * @param workEffortSearchConstraintList the work effort search constraint list + */ public void addWorkEffortSearchConstraints(List<? extends WorkEffortSearchConstraint> workEffortSearchConstraintList) { // Go through the constraints and add them in for (WorkEffortSearchConstraint constraint: workEffortSearchConstraintList) { @@ -169,22 +175,42 @@ public class WorkEffortSearch { } } + /** + * Sets result sort order. + * @param resultSortOrder the result sort order + */ public void setResultSortOrder(ResultSortOrder resultSortOrder) { this.resultSortOrder = resultSortOrder; } + /** + * Sets result offset. + * @param resultOffset the result offset + */ public void setResultOffset(Integer resultOffset) { this.resultOffset = resultOffset; } + /** + * Sets max results. + * @param maxResults the max results + */ public void setMaxResults(Integer maxResults) { this.maxResults = maxResults; } + /** + * Gets total results. + * @return the total results + */ public Integer getTotalResults() { return this.totalResults; } + /** + * Do search array list. + * @return the array list + */ public ArrayList<String> doSearch() { long startMillis = System.currentTimeMillis(); @@ -232,7 +258,8 @@ public class WorkEffortSearch { boolean doingBothAndOr = (keywordFixedOrSetAndList.size() > 1) || (keywordFixedOrSetAndList.size() > 0 && andKeywordFixedSet.size() > 0); - 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.size() > 0) { @@ -249,7 +276,8 @@ public class WorkEffortSearch { dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("workEffortId")); entityConditionList.add(EntityCondition.makeCondition(prefix + "Keyword", EntityOperator.LIKE, keyword)); - //don't add an alias for this, will be part of a complex alias: dynamicViewEntity.addAlias(entityAlias, prefix + "RelevancyWeight", "relevancyWeight", null, null, null, null); + //don't add an alias for this, will be part of a complex alias: dynamicViewEntity + // .addAlias(entityAlias, prefix + "RelevancyWeight", "relevancyWeight", null, null, null, null); relevancyComplexAlias.addComplexAliasMember(new ComplexAliasField(entityAlias, "relevancyWeight", null, null)); } @@ -327,6 +355,11 @@ public class WorkEffortSearch { return eli; } + /** + * Make work effort id list array list. + * @param eli the eli + * @return the array list + */ public ArrayList<String> makeWorkEffortIdList(EntityListIterator eli) { ArrayList<String> workEffortIds = new ArrayList<>(maxResults == null ? 100 : maxResults); if (eli == null) { @@ -402,7 +435,8 @@ public class WorkEffortSearch { 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 workEffort search query", MODULE); @@ -469,10 +503,10 @@ public class WorkEffortSearch { @SuppressWarnings("serial") public static class WorkEffortAssocConstraint extends WorkEffortSearchConstraint { - public static final String constraintName = "WorkEffortAssoc"; - protected String workEffortId; - protected String workEffortAssocTypeId; - protected boolean includeSubWorkEfforts; + public static final String CONSTRAINT_NAME = "WorkEffortAssoc"; + private String workEffortId; + private String workEffortAssocTypeId; + private boolean includeSubWorkEfforts; public WorkEffortAssocConstraint(String workEffortId, String workEffortAssocTypeId, boolean includeSubWorkEfforts) { this.workEffortId = workEffortId; @@ -485,7 +519,8 @@ public class WorkEffortSearch { Set<String> workEffortIdSet = new HashSet<>(); if (includeSubWorkEfforts) { // find all sub-categories recursively, make a Set of workEffortId - WorkEffortSearch.getAllSubWorkEffortIds(workEffortId, workEffortIdSet, workEffortSearchContext.getDelegator(), workEffortSearchContext.nowTimestamp); + WorkEffortSearch.getAllSubWorkEffortIds(workEffortId, workEffortIdSet, workEffortSearchContext.getDelegator(), + workEffortSearchContext.nowTimestamp); } else { workEffortIdSet.add(workEffortId); } @@ -504,18 +539,24 @@ public class WorkEffortSearch { workEffortSearchContext.dynamicViewEntity.addMemberEntity(entityAlias, "WorkEffortAssoc"); workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "WorkEffortIdFrom", "workEffortIdFrom", null, null, null, null); workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "WorkEffortIdTo", "workEffortIdTo", null, null, null, null); - workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "WorkEffortAssocTypeId", "workEffortAssocTypeId", null, null, null, null); + workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "WorkEffortAssocTypeId", "workEffortAssocTypeId", null, null, + null, null); workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "FromDate", "fromDate", null, null, null, null); workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ThruDate", "thruDate", null, null, null, null); - workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.TRUE, ModelKeyMap.makeKeyMapList("workEffortId", "workEffortIdFrom")); + workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.TRUE, ModelKeyMap.makeKeyMapList("workEffortId", + "workEffortIdFrom")); List<EntityExpr> assocConditionFromTo = new LinkedList<>(); assocConditionFromTo.add(EntityCondition.makeCondition(prefix + "WorkEffortIdTo", EntityOperator.IN, workEffortIdSet)); if (UtilValidate.isNotEmpty(workEffortAssocTypeId)) { - assocConditionFromTo.add(EntityCondition.makeCondition(prefix + "WorkEffortAssocTypeId", EntityOperator.EQUALS, workEffortAssocTypeId)); + assocConditionFromTo.add(EntityCondition.makeCondition(prefix + "WorkEffortAssocTypeId", EntityOperator.EQUALS, + workEffortAssocTypeId)); } - assocConditionFromTo.add(EntityCondition.makeCondition(EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.GREATER_THAN, workEffortSearchContext.nowTimestamp))); - assocConditionFromTo.add(EntityCondition.makeCondition(prefix + "FromDate", EntityOperator.LESS_THAN, workEffortSearchContext.nowTimestamp)); + assocConditionFromTo.add(EntityCondition.makeCondition(EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.EQUALS, null), + EntityOperator.OR, EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.GREATER_THAN, + workEffortSearchContext.nowTimestamp))); + assocConditionFromTo.add(EntityCondition.makeCondition(prefix + "FromDate", EntityOperator.LESS_THAN, + workEffortSearchContext.nowTimestamp)); // do workEffortId = workEffortIdTo, workEffortIdFrom IN workEffortIdSet entityAlias = "WFA" + workEffortSearchContext.index; @@ -525,25 +566,34 @@ public class WorkEffortSearch { workEffortSearchContext.dynamicViewEntity.addMemberEntity(entityAlias, "WorkEffortAssoc"); workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "WorkEffortIdFrom", "workEffortIdFrom", null, null, null, null); workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "WorkEffortIdTo", "workEffortIdTo", null, null, null, null); - workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "WorkEffortAssocTypeId", "workEffortAssocTypeId", null, null, null, null); + workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "WorkEffortAssocTypeId", "workEffortAssocTypeId", null, null, + null, null); workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "FromDate", "fromDate", null, null, null, null); workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ThruDate", "thruDate", null, null, null, null); - workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.TRUE, ModelKeyMap.makeKeyMapList("workEffortId", "workEffortIdTo")); + workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.TRUE, ModelKeyMap.makeKeyMapList("workEffortId", + "workEffortIdTo")); List<EntityExpr> assocConditionToFrom = new LinkedList<>(); assocConditionToFrom.add(EntityCondition.makeCondition(prefix + "WorkEffortIdFrom", EntityOperator.IN, workEffortIdSet)); if (UtilValidate.isNotEmpty(workEffortAssocTypeId)) { - assocConditionToFrom.add(EntityCondition.makeCondition(prefix + "WorkEffortAssocTypeId", EntityOperator.EQUALS, workEffortAssocTypeId)); + assocConditionToFrom.add(EntityCondition.makeCondition(prefix + "WorkEffortAssocTypeId", + EntityOperator.EQUALS, workEffortAssocTypeId)); } - assocConditionToFrom.add(EntityCondition.makeCondition(EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.GREATER_THAN, workEffortSearchContext.nowTimestamp))); - assocConditionToFrom.add(EntityCondition.makeCondition(prefix + "FromDate", EntityOperator.LESS_THAN, workEffortSearchContext.nowTimestamp)); + assocConditionToFrom.add(EntityCondition.makeCondition(EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.EQUALS, null), + EntityOperator.OR, EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.GREATER_THAN, + workEffortSearchContext.nowTimestamp))); + assocConditionToFrom.add(EntityCondition.makeCondition(prefix + "FromDate", EntityOperator.LESS_THAN, + workEffortSearchContext.nowTimestamp)); // now create and add the combined constraint - workEffortSearchContext.entityConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition(assocConditionFromTo, EntityOperator.AND), EntityOperator.OR, EntityCondition.makeCondition(assocConditionToFrom, EntityOperator.AND))); + workEffortSearchContext.entityConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition(assocConditionFromTo, + EntityOperator.AND), EntityOperator.OR, EntityCondition.makeCondition(assocConditionToFrom, EntityOperator.AND))); // add in workEffortSearchConstraint, don't worry about the workEffortSearchResultId or constraintSeqId, those will be fill in later - workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", this.workEffortId + "," + this.workEffortAssocTypeId, "includeSubWorkEfforts", this.includeSubWorkEfforts ? "Y" : "N"))); + workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", + UtilMisc.toMap("constraintName", CONSTRAINT_NAME, "infoString", this.workEffortId + "," + this.workEffortAssocTypeId, + "includeSubWorkEfforts", this.includeSubWorkEfforts ? "Y" : "N"))); } @@ -554,7 +604,8 @@ public class WorkEffortSearch { GenericValue workEffortAssocType = null; try { workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", this.workEffortId).cache().queryOne(); - workEffortAssocType = EntityQuery.use(delegator).from("WorkEffortAssocType").where("workEffortAssocTypeId", this.workEffortAssocTypeId).cache().queryOne(); + workEffortAssocType = EntityQuery.use(delegator).from("WorkEffortAssocType") + .where("workEffortAssocTypeId", this.workEffortAssocTypeId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error looking up WorkEffortAssocConstraint pretty print info: " + e.toString(), MODULE); } @@ -630,8 +681,8 @@ public class WorkEffortSearch { @SuppressWarnings("serial") public static class WorkEffortReviewConstraint extends WorkEffortSearchConstraint { - public static final String constraintName = "WorkEffortReview"; - protected String reviewTextString; + public static final String CONSTRAINT_NAME = "WorkEffortReview"; + private String reviewTextString; public WorkEffortReviewConstraint(String reviewTextString) { this.reviewTextString = reviewTextString; @@ -647,7 +698,7 @@ public class WorkEffortSearch { workEffortSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ReviewText", "reviewText", null, null, null, null); workEffortSearchContext.dynamicViewEntity.addViewLink("WEFF", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("workEffortId")); workEffortSearchContext.entityConditionList.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD(prefix + "ReviewText"), EntityOperator.LIKE, EntityFunction.UPPER("%" + reviewTextString + "%"))); - Map<String, String> valueMap = UtilMisc.toMap("constraintName", constraintName, "infoString", this.reviewTextString); + Map<String, String> valueMap = UtilMisc.toMap("constraintName", CONSTRAINT_NAME, "infoString", this.reviewTextString); workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", valueMap)); } @@ -694,9 +745,9 @@ public class WorkEffortSearch { @SuppressWarnings("serial") public static class PartyAssignmentConstraint extends WorkEffortSearchConstraint { - public static final String constraintName = "PartyAssignment"; - protected String partyId; - protected String roleTypeId; + public static final String CONSTRAINT_NAME = "PartyAssignment"; + private String partyId; + private String roleTypeId; public PartyAssignmentConstraint(String partyId, String roleTypeId) { this.partyId = partyId; @@ -725,7 +776,7 @@ public class WorkEffortSearch { } // add in workEffortSearchConstraint, don't worry about the workEffortSearchResultId or constraintSeqId, those will be fill in later - workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", this.partyId + "," + this.roleTypeId))); + workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", UtilMisc.toMap("constraintName", CONSTRAINT_NAME, "infoString", this.partyId + "," + this.roleTypeId))); } @Override @@ -814,8 +865,8 @@ public class WorkEffortSearch { @SuppressWarnings("serial") public static class ProductSetConstraint extends WorkEffortSearchConstraint { - public static final String constraintName = "ProductSet"; - protected Set<String> productIdSet; + public static final String CONSTRAINT_NAME = "ProductSet"; + private Set<String> productIdSet; public ProductSetConstraint(Collection<String> productIdSet) { this.productIdSet = new LinkedHashSet<>(productIdSet); @@ -849,7 +900,7 @@ public class WorkEffortSearch { } } - workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", productIdInfo.toString()))); + workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", UtilMisc.toMap("constraintName", CONSTRAINT_NAME, "infoString", productIdInfo.toString()))); } @Override @@ -912,12 +963,12 @@ public class WorkEffortSearch { @SuppressWarnings("serial") public static class KeywordConstraint extends WorkEffortSearchConstraint { - public static final String constraintName = "Keyword"; - protected String keywordsString; - protected boolean anyPrefix; - protected boolean anySuffix; - protected boolean isAnd; - protected boolean removeStems; + public static final String CONSTRAINT_NAME = "Keyword"; + private String keywordsString; + private boolean anyPrefix; + private boolean anySuffix; + private boolean isAnd; + private boolean removeStems; public KeywordConstraint(String keywordsString, boolean anyPrefix, boolean anySuffix, Boolean removeStems, boolean isAnd) { this.keywordsString = keywordsString; @@ -980,12 +1031,13 @@ public class WorkEffortSearch { } // add in workEffortSearchConstraint, don't worry about the workEffortSearchResultId or constraintSeqId, those will be fill in later - Map<String, String> valueMap = UtilMisc.toMap("constraintName", constraintName, "infoString", this.keywordsString); + Map<String, String> valueMap = UtilMisc.toMap("constraintName", CONSTRAINT_NAME, "infoString", this.keywordsString); valueMap.put("anyPrefix", this.anyPrefix ? "Y" : "N"); valueMap.put("anySuffix", this.anySuffix ? "Y" : "N"); valueMap.put("isAnd", this.isAnd ? "Y" : "N"); valueMap.put("removeStems", this.removeStems ? "Y" : "N"); - workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", valueMap)); + workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator() + .makeValue("WorkEffortSearchConstraint", valueMap)); } /** pretty print for log messages and even UI stuff */ @@ -1047,9 +1099,9 @@ public class WorkEffortSearch { @SuppressWarnings("serial") public static class LastUpdatedRangeConstraint extends WorkEffortSearchConstraint { - public static final String constraintName = "LastUpdatedRange"; - protected Timestamp fromDate; - protected Timestamp thruDate; + public static final String CONSTRAINT_NAME = "LastUpdatedRange"; + private Timestamp fromDate; + private Timestamp thruDate; public LastUpdatedRangeConstraint(Timestamp fromDate, Timestamp thruDate) { this.fromDate = fromDate; @@ -1088,7 +1140,7 @@ public class WorkEffortSearch { workEffortSearchContext.entityConditionList.add(conditions); // add in workEffortSearchConstraint, don't worry about the workEffortSearchResultId or constraintSeqId, those will be fill in later - workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", "fromDate : " + fromDate + " thruDate : " + thruDate))); + workEffortSearchContext.workEffortSearchConstraintList.add(workEffortSearchContext.getDelegator().makeValue("WorkEffortSearchConstraint", UtilMisc.toMap("constraintName", CONSTRAINT_NAME, "infoString", "fromDate : " + fromDate + " thruDate : " + thruDate))); } /** pretty print for log messages and even UI stuff */ @@ -1187,8 +1239,8 @@ public class WorkEffortSearch { @SuppressWarnings("serial") public static class SortWorkEffortField extends ResultSortOrder { - protected String fieldName; - protected boolean ascending; + private String fieldName; + private boolean ascending; /** Some good field names to try might include: * [workEffortName] diff --git a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java index 02a3ee4..37c8ff1 100644 --- a/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java +++ b/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortSearchSession.java @@ -43,11 +43,11 @@ public class WorkEffortSearchSession { @SuppressWarnings("serial") public static class WorkEffortSearchOptions implements java.io.Serializable { - protected List<WorkEffortSearchConstraint> constraintList = null; - protected ResultSortOrder resultSortOrder = null; - protected Integer viewIndex = null; - protected Integer viewSize = null; - protected boolean changed = false; + private List<WorkEffortSearchConstraint> constraintList = null; + private ResultSortOrder resultSortOrder = null; + private Integer viewIndex = null; + private Integer viewSize = null; + private boolean changed = false; public WorkEffortSearchOptions() { } /** Basic copy constructor */ @@ -59,6 +59,10 @@ public class WorkEffortSearchSession { this.changed = workEffortSearchOptions.changed; } + /** + * Gets constraint list. + * @return the constraint list + */ public List<WorkEffortSearchConstraint> getConstraintList() { return this.constraintList; } @@ -76,6 +80,10 @@ public class WorkEffortSearchSession { } } + /** + * Gets result sort order. + * @return the result sort order + */ public ResultSortOrder getResultSortOrder() { if (this.resultSortOrder == null) { this.resultSortOrder = new SortKeywordRelevancy(); @@ -99,6 +107,9 @@ public class WorkEffortSearchSession { workEffortSearchOptions.resultSortOrder = null; } + /** + * Clear view info. + */ public void clearViewInfo() { this.viewIndex = null; this.viewSize = null; @@ -129,6 +140,13 @@ public class WorkEffortSearchSession { this.viewSize = viewSize; } + /** + * Search get constraint strings list. + * @param detailed the detailed + * @param delegator the delegator + * @param locale the locale + * @return the list + */ public List<String> searchGetConstraintStrings(boolean detailed, Delegator delegator, Locale locale) { List<WorkEffortSearchConstraint> workEffortSearchConstraintList = this.getConstraintList(); List<String> constraintStrings = new LinkedList<>(); @@ -240,7 +258,8 @@ public class WorkEffortSearchSession { String searchOperator = (String) parameters.get("SEARCH_OPERATOR"); // defaults to true/Y, ie anything but N is true/Y boolean anyPrefixSuffix = !"N".equals(parameters.get("SEARCH_ANYPRESUF")); - searchAddConstraint(new WorkEffortSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, "AND".equals(searchOperator)), session); + searchAddConstraint(new WorkEffortSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, + "AND".equals(searchOperator)), session); constraintsChanged = true; } // set the sort order |
Free forum by Nabble | Edit this page |