Improved: Corrected all incorrect indentation level issues in application component, also fixed some case indentation checkstyle issues.
(OFBIZ-11922)
This commit is contained in:
@@ -38,94 +38,100 @@ import org.apache.ofbiz.service.ServiceUtil;
|
||||
|
||||
public class GlEvents {
|
||||
|
||||
private static final String MODULE = GlEvents.class.getName();
|
||||
public static String createReconcileAccount(HttpServletRequest request, HttpServletResponse response) {
|
||||
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
|
||||
final Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
|
||||
Map<String, Object> ctx = UtilHttp.getParameterMap(request);
|
||||
String acctgTransId;
|
||||
String acctgTransEntrySeqId;
|
||||
String glAccountId = null;
|
||||
String organizationPartyId = null;
|
||||
BigDecimal reconciledBalance = BigDecimal.ZERO;
|
||||
boolean isSelected;
|
||||
String debitCreditFlag;
|
||||
// The number of multi form rows is retrieved
|
||||
int rowCount = UtilHttp.getMultiFormRowCount(ctx);
|
||||
for (int i = 0; i < rowCount; i++) { //for calculating amount per glAccountId
|
||||
String suffix = UtilHttp.getMultiRowDelimiter() + i;
|
||||
isSelected = (ctx.containsKey("_rowSubmit" + suffix) && "Y".equalsIgnoreCase((String) ctx.get("_rowSubmit" + suffix)));
|
||||
if (!isSelected) {
|
||||
continue;
|
||||
}
|
||||
acctgTransId = (String) ctx.get("acctgTransId" + suffix);
|
||||
acctgTransEntrySeqId = (String) ctx.get("acctgTransEntrySeqId" + suffix);
|
||||
organizationPartyId = (String) ctx.get("organizationPartyId" + suffix);
|
||||
glAccountId = (String) ctx.get("glAccountId" + suffix);
|
||||
try {
|
||||
GenericValue acctgTransEntry = EntityQuery.use(delegator).from("AcctgTransEntry").where("acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId).queryOne();
|
||||
if (acctgTransEntry != null) {
|
||||
//calculate amount for each AcctgTransEntry according to glAccountId based on debit and credit
|
||||
debitCreditFlag = acctgTransEntry.getString("debitCreditFlag");
|
||||
if ("D".equalsIgnoreCase(debitCreditFlag)) {
|
||||
reconciledBalance = reconciledBalance.add(acctgTransEntry.getBigDecimal("amount")); //total balance per glAccountId
|
||||
} else {
|
||||
reconciledBalance = reconciledBalance.subtract(acctgTransEntry.getBigDecimal("amount")); //total balance per glAccountId
|
||||
}
|
||||
private static final String MODULE = GlEvents.class.getName();
|
||||
|
||||
public static String createReconcileAccount(HttpServletRequest request, HttpServletResponse response) {
|
||||
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
|
||||
final Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
|
||||
Map<String, Object> ctx = UtilHttp.getParameterMap(request);
|
||||
String acctgTransId;
|
||||
String acctgTransEntrySeqId;
|
||||
String glAccountId = null;
|
||||
String organizationPartyId = null;
|
||||
BigDecimal reconciledBalance = BigDecimal.ZERO;
|
||||
boolean isSelected;
|
||||
String debitCreditFlag;
|
||||
// The number of multi form rows is retrieved
|
||||
int rowCount = UtilHttp.getMultiFormRowCount(ctx);
|
||||
for (int i = 0; i < rowCount; i++) { //for calculating amount per glAccountId
|
||||
String suffix = UtilHttp.getMultiRowDelimiter() + i;
|
||||
isSelected = (ctx.containsKey("_rowSubmit" + suffix) && "Y".equalsIgnoreCase((String) ctx.get("_rowSubmit" + suffix)));
|
||||
if (!isSelected) {
|
||||
continue;
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
acctgTransId = (String) ctx.get("acctgTransId" + suffix);
|
||||
acctgTransEntrySeqId = (String) ctx.get("acctgTransEntrySeqId" + suffix);
|
||||
organizationPartyId = (String) ctx.get("organizationPartyId" + suffix);
|
||||
glAccountId = (String) ctx.get("glAccountId" + suffix);
|
||||
try {
|
||||
GenericValue acctgTransEntry = EntityQuery.use(delegator).from("AcctgTransEntry").where("acctgTransId", acctgTransId,
|
||||
"acctgTransEntrySeqId", acctgTransEntrySeqId).queryOne();
|
||||
if (acctgTransEntry != null) {
|
||||
//calculate amount for each AcctgTransEntry according to glAccountId based on debit and credit
|
||||
debitCreditFlag = acctgTransEntry.getString("debitCreditFlag");
|
||||
if ("D".equalsIgnoreCase(debitCreditFlag)) {
|
||||
reconciledBalance = reconciledBalance.add(acctgTransEntry.getBigDecimal("amount")); //total balance per glAccountId
|
||||
} else {
|
||||
reconciledBalance = reconciledBalance.subtract(acctgTransEntry.getBigDecimal("amount")); //total balance per glAccountId
|
||||
}
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
return "error";
|
||||
}
|
||||
|
||||
}
|
||||
Map<String, Object> fieldMap = UtilMisc.toMap("glReconciliationName", "Reconciliation at date " + UtilDateTime.nowTimestamp(), "glAccountId"
|
||||
, glAccountId, "organizationPartyId", organizationPartyId, "reconciledDate", UtilDateTime.nowTimestamp(), "reconciledBalance",
|
||||
reconciledBalance, "userLogin", userLogin);
|
||||
Map<String, Object> glReconResult = null;
|
||||
try {
|
||||
glReconResult = dispatcher.runSync("createGlReconciliation", fieldMap); //create GlReconciliation for the glAccountId
|
||||
if (ServiceUtil.isError(glReconResult)) {
|
||||
return "error";
|
||||
}
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
return "error";
|
||||
}
|
||||
|
||||
}
|
||||
Map<String, Object> fieldMap = UtilMisc.toMap("glReconciliationName", "Reconciliation at date " + UtilDateTime.nowTimestamp(), "glAccountId", glAccountId, "organizationPartyId", organizationPartyId, "reconciledDate", UtilDateTime.nowTimestamp(), "reconciledBalance", reconciledBalance, "userLogin", userLogin);
|
||||
Map<String, Object> glReconResult = null;
|
||||
try {
|
||||
glReconResult = dispatcher.runSync("createGlReconciliation", fieldMap); //create GlReconciliation for the glAccountId
|
||||
if (ServiceUtil.isError(glReconResult)) {
|
||||
return "error";
|
||||
}
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
return "error";
|
||||
}
|
||||
String glReconciliationId = (String) glReconResult.get("glReconciliationId");
|
||||
String reconciledAmount;
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
String suffix = UtilHttp.getMultiRowDelimiter() + i;
|
||||
isSelected = (ctx.containsKey("_rowSubmit" + suffix) && "Y".equalsIgnoreCase((String) ctx.get("_rowSubmit" + suffix)));
|
||||
if (!isSelected) {
|
||||
continue;
|
||||
}
|
||||
acctgTransId = (String) ctx.get("acctgTransId" + suffix);
|
||||
acctgTransEntrySeqId = (String) ctx.get("acctgTransEntrySeqId" + suffix);
|
||||
try {
|
||||
GenericValue acctgTransEntry = EntityQuery.use(delegator).from("AcctgTransEntry").where("acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId).queryOne();
|
||||
if (acctgTransEntry != null) {
|
||||
reconciledAmount = acctgTransEntry.getString("amount");
|
||||
acctgTransId = acctgTransEntry.getString("acctgTransId");
|
||||
acctgTransEntrySeqId = acctgTransEntry.getString("acctgTransEntrySeqId");
|
||||
Map<String, Object> glReconEntryMap = UtilMisc.toMap("glReconciliationId", glReconciliationId, "acctgTransId", acctgTransId, "acctgTransEntrySeqId", acctgTransEntrySeqId, "reconciledAmount", reconciledAmount, "userLogin", userLogin);
|
||||
Map<String, Object> glReconEntryResult = null;
|
||||
try {
|
||||
glReconEntryResult = dispatcher.runSync("createGlReconciliationEntry", glReconEntryMap);
|
||||
if (ServiceUtil.isError(glReconEntryResult)) {
|
||||
String glReconciliationId = (String) glReconResult.get("glReconciliationId");
|
||||
String reconciledAmount;
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
String suffix = UtilHttp.getMultiRowDelimiter() + i;
|
||||
isSelected = (ctx.containsKey("_rowSubmit" + suffix) && "Y".equalsIgnoreCase((String) ctx.get("_rowSubmit" + suffix)));
|
||||
if (!isSelected) {
|
||||
continue;
|
||||
}
|
||||
acctgTransId = (String) ctx.get("acctgTransId" + suffix);
|
||||
acctgTransEntrySeqId = (String) ctx.get("acctgTransEntrySeqId" + suffix);
|
||||
try {
|
||||
GenericValue acctgTransEntry = EntityQuery.use(delegator).from("AcctgTransEntry").where("acctgTransId", acctgTransId,
|
||||
"acctgTransEntrySeqId", acctgTransEntrySeqId).queryOne();
|
||||
if (acctgTransEntry != null) {
|
||||
reconciledAmount = acctgTransEntry.getString("amount");
|
||||
acctgTransId = acctgTransEntry.getString("acctgTransId");
|
||||
acctgTransEntrySeqId = acctgTransEntry.getString("acctgTransEntrySeqId");
|
||||
Map<String, Object> glReconEntryMap = UtilMisc.toMap("glReconciliationId", glReconciliationId, "acctgTransId", acctgTransId,
|
||||
"acctgTransEntrySeqId", acctgTransEntrySeqId, "reconciledAmount", reconciledAmount, "userLogin", userLogin);
|
||||
Map<String, Object> glReconEntryResult = null;
|
||||
try {
|
||||
glReconEntryResult = dispatcher.runSync("createGlReconciliationEntry", glReconEntryMap);
|
||||
if (ServiceUtil.isError(glReconEntryResult)) {
|
||||
return "error";
|
||||
}
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
return "error";
|
||||
}
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
return "error";
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
return "error";
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
return "error";
|
||||
}
|
||||
ctx.put("glReconciliationId", glReconciliationId);
|
||||
request.setAttribute("glReconciliationId", glReconciliationId);
|
||||
return "success";
|
||||
}
|
||||
ctx.put("glReconciliationId", glReconciliationId);
|
||||
request.setAttribute("glReconciliationId", glReconciliationId);
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
|
||||
+535
-413
File diff suppressed because it is too large
Load Diff
+31
-29
@@ -58,8 +58,8 @@ public final class InvoiceWorker {
|
||||
|
||||
private static final int DECIMALS = UtilNumber.getBigDecimalScale("invoice.decimals");
|
||||
private static final RoundingMode ROUNDING = UtilNumber.getRoundingMode("invoice.rounding");
|
||||
private static final int taxDecimals = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
|
||||
private static final RoundingMode taxRounding = UtilNumber.getRoundingMode("salestax.rounding");
|
||||
private static final int TAX_DECIMALS = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
|
||||
private static final RoundingMode TAX_ROUNDING = UtilNumber.getRoundingMode("salestax.rounding");
|
||||
|
||||
private InvoiceWorker() { }
|
||||
|
||||
@@ -95,7 +95,7 @@ public final class InvoiceWorker {
|
||||
}
|
||||
|
||||
if (invoice == null) {
|
||||
throw new IllegalArgumentException("The passed invoiceId [" +invoiceId + "] does not match an existing invoice");
|
||||
throw new IllegalArgumentException("The passed invoiceId [" + invoiceId + "] does not match an existing invoice");
|
||||
}
|
||||
|
||||
return getInvoiceTotal(invoice, actualCurrency);
|
||||
@@ -162,7 +162,8 @@ public final class InvoiceWorker {
|
||||
return description;
|
||||
}
|
||||
|
||||
/** Method to get the taxable invoice item types as a List of invoiceItemTypeIds. These are identified in Enumeration with enumTypeId TAXABLE_INV_ITM_TY. */
|
||||
/** Method to get the taxable invoice item types as a List of invoiceItemTypeIds.
|
||||
* These are identified in Enumeration with enumTypeId TAXABLE_INV_ITM_TY. */
|
||||
public static List<String> getTaxableInvoiceItemTypeIds(Delegator delegator) throws GenericEntityException {
|
||||
List<String> typeIds = new LinkedList<>();
|
||||
List<GenericValue> invoiceItemTaxTypes = EntityQuery.use(delegator).from("Enumeration").where("enumTypeId", "TAXABLE_INV_ITM_TY")
|
||||
@@ -217,7 +218,7 @@ public final class InvoiceWorker {
|
||||
invoiceItems = invoice.getRelated("InvoiceItem", null, null, false);
|
||||
invoiceItems = EntityUtil.filterByAnd(
|
||||
invoiceItems, UtilMisc.toList(
|
||||
EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.NOT_IN, getTaxableInvoiceItemTypeIds(invoice.getDelegator()))));
|
||||
EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.NOT_IN, getTaxableInvoiceItemTypeIds(invoice.getDelegator()))));
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Trouble getting InvoiceItem list", MODULE);
|
||||
}
|
||||
@@ -251,7 +252,8 @@ public final class InvoiceWorker {
|
||||
// remaining code is the old method, which we leave here for compatibility purposes
|
||||
List<GenericValue> billToRoles = null;
|
||||
try {
|
||||
billToRoles = invoice.getRelated("InvoiceRole", UtilMisc.toMap("roleTypeId", "BILL_TO_CUSTOMER"), UtilMisc.toList("-datetimePerformed"), false);
|
||||
billToRoles = invoice.getRelated("InvoiceRole", UtilMisc.toMap("roleTypeId", "BILL_TO_CUSTOMER"),
|
||||
UtilMisc.toList("-datetimePerformed"), false);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Trouble getting InvoiceRole list", MODULE);
|
||||
}
|
||||
@@ -330,7 +332,7 @@ public final class InvoiceWorker {
|
||||
.where("invoiceId", invoice.get("invoiceId")).queryFirst();
|
||||
if (shipmentView != null) {
|
||||
GenericValue shipment = EntityQuery.use(delegator).from("Shipment")
|
||||
.where("shipmentId", shipmentView.get("shipmentId")).queryOne();
|
||||
.where("shipmentId", shipmentView.get("shipmentId")).queryOne();
|
||||
postalAddress = shipment.getRelatedOne("DestinationPostalAddress", false);
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -372,7 +374,7 @@ public final class InvoiceWorker {
|
||||
Debug.logError("Touble getting InvoiceContactMech entity list", MODULE);
|
||||
}
|
||||
|
||||
if (UtilValidate.isEmpty(locations) && fetchPartyAddress) {
|
||||
if (UtilValidate.isEmpty(locations) && fetchPartyAddress) {
|
||||
// if no locations found get it from the PartyAndContactMech using the from and to party on the invoice
|
||||
String destinationPartyId = null;
|
||||
Timestamp now = UtilDateTime.nowTimestamp();
|
||||
@@ -391,7 +393,7 @@ public final class InvoiceWorker {
|
||||
Debug.logError("Trouble getting contact party purpose list", MODULE);
|
||||
}
|
||||
//if still not found get it from the general location
|
||||
if (UtilValidate.isEmpty(locations)) {
|
||||
if (UtilValidate.isEmpty(locations)) {
|
||||
try {
|
||||
locations = EntityQuery.use(delegator).from("PartyContactWithPurpose")
|
||||
.where("partyId", destinationPartyId, "contactMechPurposeTypeId", "GENERAL_LOCATION").queryList();
|
||||
@@ -413,7 +415,7 @@ public final class InvoiceWorker {
|
||||
Debug.logError(e, "Trouble getting Contact for contactMechId: " + locations.get(0).getString("contactMechId"), MODULE);
|
||||
}
|
||||
|
||||
if (contactMech != null && "POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId"))) {
|
||||
if (contactMech != null && "POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId"))) {
|
||||
try {
|
||||
postalAddress = contactMech.getRelatedOne("PostalAddress", false);
|
||||
return postalAddress;
|
||||
@@ -433,7 +435,7 @@ public final class InvoiceWorker {
|
||||
* @return the invoice total as BigDecimal
|
||||
*/
|
||||
public static BigDecimal getInvoiceNotApplied(Delegator delegator, String invoiceId, Boolean actualCurrency) {
|
||||
return InvoiceWorker.getInvoiceTotal(delegator, invoiceId, actualCurrency).subtract(getInvoiceApplied(delegator, invoiceId, UtilDateTime.nowTimestamp(), actualCurrency));
|
||||
return InvoiceWorker.getInvoiceTotal(delegator, invoiceId, actualCurrency).subtract(getInvoiceApplied(delegator, invoiceId, UtilDateTime.nowTimestamp(), actualCurrency));
|
||||
}
|
||||
public static BigDecimal getInvoiceNotApplied(Delegator delegator, String invoiceId) {
|
||||
return InvoiceWorker.getInvoiceTotal(delegator, invoiceId).subtract(getInvoiceApplied(delegator, invoiceId));
|
||||
@@ -580,9 +582,9 @@ public final class InvoiceWorker {
|
||||
String otherCurrencyUomId = null;
|
||||
// find the organization party currencyUomId which different from the invoice currency
|
||||
try {
|
||||
GenericValue party = EntityQuery.use(delegator).from("PartyAcctgPreference").where("partyId", invoice.get("partyIdFrom")).queryOne();
|
||||
GenericValue party = EntityQuery.use(delegator).from("PartyAcctgPreference").where("partyId", invoice.get("partyIdFrom")).queryOne();
|
||||
if (UtilValidate.isEmpty(party) || party.getString("baseCurrencyUomId").equals(invoice.getString("currencyUomId"))) {
|
||||
party = EntityQuery.use(delegator).from("PartyAcctgPreference").where("partyId", invoice.get("partyId")).queryOne();
|
||||
party = EntityQuery.use(delegator).from("PartyAcctgPreference").where("partyId", invoice.get("partyId")).queryOne();
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(party) && party.getString("baseCurrencyUomId") != null) {
|
||||
otherCurrencyUomId = party.getString("baseCurrencyUomId");
|
||||
@@ -703,9 +705,9 @@ public final class InvoiceWorker {
|
||||
if (amount == null) {
|
||||
amount = BigDecimal.ZERO;
|
||||
}
|
||||
totalAmount = totalAmount.add(amount).setScale(taxDecimals, taxRounding);
|
||||
totalAmount = totalAmount.add(amount).setScale(TAX_DECIMALS, TAX_ROUNDING);
|
||||
}
|
||||
totalAmount = totalAmount.setScale(taxDecimals, taxRounding);
|
||||
totalAmount = totalAmount.setScale(TAX_DECIMALS, TAX_ROUNDING);
|
||||
taxByTaxAuthGeoAndPartyList.add(UtilMisc.<String, Object>toMap("taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", taxAuthGeoId, "totalAmount", totalAmount));
|
||||
taxGrandTotal = taxGrandTotal.add(totalAmount);
|
||||
}
|
||||
@@ -736,7 +738,7 @@ public final class InvoiceWorker {
|
||||
Delegator delegator = invoice.getDelegator();
|
||||
invoiceTaxItems = EntityQuery.use(delegator).from("InvoiceItem")
|
||||
.where(EntityCondition.makeCondition("invoiceId", invoice.getString("invoiceId")),
|
||||
EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.IN, getTaxableInvoiceItemTypeIds(delegator))).queryList();
|
||||
EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.IN, getTaxableInvoiceItemTypeIds(delegator))).queryList();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Trouble getting InvoiceItem list", MODULE);
|
||||
return null;
|
||||
@@ -779,7 +781,7 @@ public final class InvoiceWorker {
|
||||
Debug.logError(e, "Trouble getting InvoiceItem list", MODULE);
|
||||
return null;
|
||||
}
|
||||
return getTaxTotalForInvoiceItems(invoiceTaxItems);
|
||||
return getTaxTotalForInvoiceItems(invoiceTaxItems);
|
||||
}
|
||||
|
||||
/** Returns the invoice tax total for unattributed tax items, that is items which have no taxAuthPartyId value
|
||||
@@ -787,17 +789,17 @@ public final class InvoiceWorker {
|
||||
* @return Returns the invoice tax total for unattributed tax items
|
||||
*/
|
||||
public static BigDecimal getInvoiceUnattributedTaxTotal(GenericValue invoice) {
|
||||
List<GenericValue> invoiceTaxItems = null;
|
||||
try {
|
||||
Delegator delegator = invoice.getDelegator();
|
||||
invoiceTaxItems = EntityQuery.use(delegator).from("InvoiceItem")
|
||||
.where(EntityCondition.makeCondition("invoiceId", invoice.get("invoiceId")),
|
||||
EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.IN, getTaxableInvoiceItemTypeIds(delegator)),
|
||||
EntityCondition.makeCondition("taxAuthPartyId", null)).queryList();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Trouble getting InvoiceItem list", MODULE);
|
||||
return null;
|
||||
}
|
||||
List<GenericValue> invoiceTaxItems = null;
|
||||
try {
|
||||
Delegator delegator = invoice.getDelegator();
|
||||
invoiceTaxItems = EntityQuery.use(delegator).from("InvoiceItem")
|
||||
.where(EntityCondition.makeCondition("invoiceId", invoice.get("invoiceId")),
|
||||
EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.IN, getTaxableInvoiceItemTypeIds(delegator)),
|
||||
EntityCondition.makeCondition("taxAuthPartyId", null)).queryList();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Trouble getting InvoiceItem list", MODULE);
|
||||
return null;
|
||||
}
|
||||
return getTaxTotalForInvoiceItems(invoiceTaxItems);
|
||||
}
|
||||
|
||||
@@ -820,7 +822,7 @@ public final class InvoiceWorker {
|
||||
quantity = BigDecimal.ONE;
|
||||
}
|
||||
amount = amount.multiply(quantity);
|
||||
amount = amount.setScale(taxDecimals, taxRounding);
|
||||
amount = amount.setScale(TAX_DECIMALS, TAX_ROUNDING);
|
||||
taxTotal = taxTotal.add(amount);
|
||||
}
|
||||
return taxTotal.setScale(DECIMALS, ROUNDING);
|
||||
|
||||
+9
-9
@@ -120,7 +120,7 @@ public class GiftCertificateServices {
|
||||
createAccountCtx.put("finAccountTypeId", FinAccountHelper.getGiftCertFinAccountTypeId());
|
||||
createAccountCtx.put("productStoreId", productStoreId);
|
||||
createAccountCtx.put("currencyUomId", currency);
|
||||
createAccountCtx.put("finAccountName", accountName + " for party ["+partyId+"]");
|
||||
createAccountCtx.put("finAccountName", accountName + " for party [" + partyId + "]");
|
||||
createAccountCtx.put("userLogin", userLogin);
|
||||
acctResult = dispatcher.runSync("createFinAccountForStore", createAccountCtx);
|
||||
if (ServiceUtil.isError(acctResult)) {
|
||||
@@ -460,7 +460,7 @@ public class GiftCertificateServices {
|
||||
"AccountingGiftCertificateNumberCannotProcess",
|
||||
UtilMisc.toMap("errorString", ex.getMessage()), locale));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Map<String, Object> giftCertificateAuthorize(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
@@ -496,13 +496,13 @@ public class GiftCertificateServices {
|
||||
finAccount = EntityQuery.use(delegator).from("FinAccount").where("finAccountId", finAccountId).queryOne();
|
||||
}
|
||||
} else {
|
||||
finAccount = FinAccountHelper.getFinAccountFromCode(giftCard.getString("cardNumber"), delegator);
|
||||
if (finAccount == null) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
|
||||
"AccountingGiftCertificateNumberNotFound",
|
||||
UtilMisc.toMap("finAccountId", ""), locale));
|
||||
}
|
||||
finAccountId = finAccount.getString("finAccountId");
|
||||
finAccount = FinAccountHelper.getFinAccountFromCode(giftCard.getString("cardNumber"), delegator);
|
||||
if (finAccount == null) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
|
||||
"AccountingGiftCertificateNumberNotFound",
|
||||
UtilMisc.toMap("finAccountId", ""), locale));
|
||||
}
|
||||
finAccountId = finAccount.getString("finAccountId");
|
||||
}
|
||||
} else {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
|
||||
|
||||
+20
-20
@@ -985,7 +985,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.name, resCtx);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, "Trouble processing the release results", MODULE);
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ORDER,
|
||||
@@ -1392,21 +1392,21 @@ public class PaymentGatewayServices {
|
||||
try {
|
||||
amountCaptured = (BigDecimal) ObjectType.simpleTypeOrObjectConvert(captureResult.get("captureAmount"), "BigDecimal", null, locale);
|
||||
|
||||
if (amountCaptured == null) {
|
||||
amountCaptured = (BigDecimal) captureResult.get("processAmount");
|
||||
}
|
||||
if (amountCaptured == null) {
|
||||
amountCaptured = (BigDecimal) captureResult.get("processAmount");
|
||||
}
|
||||
|
||||
amountCaptured = amountCaptured.setScale(DECIMALS, ROUNDING);
|
||||
amountCaptured = amountCaptured.setScale(DECIMALS, ROUNDING);
|
||||
|
||||
// decrease amount of next payment preference to capture
|
||||
amountToCapture = amountToCapture.subtract(amountCaptured);
|
||||
// decrease amount of next payment preference to capture
|
||||
amountToCapture = amountToCapture.subtract(amountCaptured);
|
||||
|
||||
// add the invoiceId to the result for processing, not for a replacement order
|
||||
if (!isReplacementOrder(orderHeader)) {
|
||||
captureResult.put("invoiceId", invoiceId);
|
||||
}
|
||||
// add the invoiceId to the result for processing, not for a replacement order
|
||||
if (!isReplacementOrder(orderHeader)) {
|
||||
captureResult.put("invoiceId", invoiceId);
|
||||
}
|
||||
|
||||
// process the capture's results
|
||||
// process the capture's results
|
||||
processResult(dctx, captureResult, userLogin, paymentPref, locale);
|
||||
} catch (GeneralException e) {
|
||||
Debug.logError(e, "Trouble processing the result; captureResult: " + captureResult, MODULE);
|
||||
@@ -3214,7 +3214,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.name, resCtx);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
|
||||
@@ -3244,7 +3244,7 @@ public class PaymentGatewayServices {
|
||||
}
|
||||
|
||||
// Verify Credit Card (Manually) Service
|
||||
public static Map<String, Object>verifyCreditCard(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
public static Map<String, Object> verifyCreditCard(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
String productStoreId = (String) context.get("productStoreId");
|
||||
@@ -3319,8 +3319,8 @@ public class PaymentGatewayServices {
|
||||
if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) < 0) {
|
||||
result.put("authResult", Boolean.FALSE);
|
||||
}
|
||||
result.put("customerRespMsgs", UtilMisc.toList(UtilProperties.getMessage(RESOURCE,
|
||||
"AccountingPaymentTestProcessorMinimumPurchase", locale)));
|
||||
result.put("customerRespMsgs", UtilMisc.toList(UtilProperties.getMessage(RESOURCE,
|
||||
"AccountingPaymentTestProcessorMinimumPurchase", locale)));
|
||||
if (processAmount == null) {
|
||||
result.put("authResult", null);
|
||||
}
|
||||
@@ -3349,13 +3349,13 @@ public class PaymentGatewayServices {
|
||||
if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) >= 0) {
|
||||
result.put("authResult", Boolean.TRUE);
|
||||
}
|
||||
result.put("captureResult", Boolean.TRUE);
|
||||
result.put("captureResult", Boolean.TRUE);
|
||||
if (processAmount != null && processAmount.compareTo(new BigDecimal("100.00")) < 0) {
|
||||
result.put("authResult", Boolean.FALSE);
|
||||
}
|
||||
result.put("captureResult", Boolean.FALSE);
|
||||
result.put("customerRespMsgs", UtilMisc.toList(UtilProperties.getMessage(RESOURCE,
|
||||
"AccountingPaymentTestProcessorMinimumPurchase", locale)));
|
||||
result.put("captureResult", Boolean.FALSE);
|
||||
result.put("customerRespMsgs", UtilMisc.toList(UtilProperties.getMessage(RESOURCE,
|
||||
"AccountingPaymentTestProcessorMinimumPurchase", locale)));
|
||||
if (processAmount == null) {
|
||||
result.put("authResult", null);
|
||||
}
|
||||
|
||||
+15
-14
@@ -48,8 +48,8 @@ import org.apache.ofbiz.service.ServiceUtil;
|
||||
*/
|
||||
public class PaymentMethodServices {
|
||||
|
||||
public final static String MODULE = PaymentMethodServices.class.getName();
|
||||
public final static String RESOURCE = "AccountingUiLabels";
|
||||
private static final String MODULE = PaymentMethodServices.class.getName();
|
||||
private static final String RESOURCE = "AccountingUiLabels";
|
||||
private static final String RES_ERROR = "AccountingUiLabels";
|
||||
|
||||
/**
|
||||
@@ -152,15 +152,15 @@ public class PaymentMethodServices {
|
||||
context.put("cardNumber", StringUtil.removeSpaces((String) context.get("cardNumber")));
|
||||
if (!UtilValidate.isCardMatch((String) context.get("cardType"), (String) context.get("cardNumber"))) {
|
||||
messages.add(
|
||||
UtilProperties.getMessage(RESOURCE, "AccountingCreditCardNumberInvalid",
|
||||
UtilMisc.toMap("cardType", (String) context.get("cardType"),
|
||||
"validCardType", UtilValidate.getCardType((String) context.get("cardNumber"))), locale));
|
||||
UtilProperties.getMessage(RESOURCE, "AccountingCreditCardNumberInvalid",
|
||||
UtilMisc.toMap("cardType", (String) context.get("cardType"),
|
||||
"validCardType", UtilValidate.getCardType((String) context.get("cardNumber"))), locale));
|
||||
}
|
||||
|
||||
if (!UtilValidate.isDateAfterToday((String) context.get("expireDate"))) {
|
||||
messages.add(
|
||||
UtilProperties.getMessage(RESOURCE, "AccountingCreditCardExpireDateBeforeToday",
|
||||
UtilMisc.toMap("expireDate", (String) context.get("expireDate")), locale));
|
||||
UtilProperties.getMessage(RESOURCE, "AccountingCreditCardExpireDateBeforeToday",
|
||||
UtilMisc.toMap("expireDate", (String) context.get("expireDate")), locale));
|
||||
}
|
||||
|
||||
if (messages.size() > 0) {
|
||||
@@ -323,15 +323,15 @@ public class PaymentMethodServices {
|
||||
|
||||
if (!UtilValidate.isCardMatch((String) context.get("cardType"), (String) context.get("cardNumber"))) {
|
||||
messages.add(
|
||||
UtilProperties.getMessage(RESOURCE, "AccountingCreditCardNumberInvalid",
|
||||
UtilMisc.toMap("cardType", (String) context.get("cardType"),
|
||||
"validCardType", UtilValidate.getCardType((String) context.get("cardNumber"))), locale));
|
||||
UtilProperties.getMessage(RESOURCE, "AccountingCreditCardNumberInvalid",
|
||||
UtilMisc.toMap("cardType", (String) context.get("cardType"),
|
||||
"validCardType", UtilValidate.getCardType((String) context.get("cardNumber"))), locale));
|
||||
}
|
||||
|
||||
if (!UtilValidate.isDateAfterToday((String) context.get("expireDate"))) {
|
||||
messages.add(
|
||||
UtilProperties.getMessage(RESOURCE, "AccountingCreditCardExpireDateBeforeToday",
|
||||
UtilMisc.toMap("expireDate", (String) context.get("expireDate")), locale));
|
||||
UtilProperties.getMessage(RESOURCE, "AccountingCreditCardExpireDateBeforeToday",
|
||||
UtilMisc.toMap("expireDate", (String) context.get("expireDate")), locale));
|
||||
}
|
||||
|
||||
if (messages.size() > 0) {
|
||||
@@ -921,12 +921,13 @@ public class PaymentMethodServices {
|
||||
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<String, Object> createCheckAccount(DispatchContext ctx, Map<String, ? extends Object> context) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Delegator delegator = ctx.getDelegator();
|
||||
Security security = ctx.getSecurity();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
Timestamp now = UtilDateTime.nowTimestamp();
|
||||
|
||||
String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PAY_INFO", "_CREATE", "ACCOUNTING", "_CREATE");
|
||||
|
||||
+13
-13
@@ -280,11 +280,11 @@ public class TaxAuthorityServices {
|
||||
}
|
||||
|
||||
if (orderShippingAmount != null && orderShippingAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
for (GenericValue prod : productWeight.keySet()) {
|
||||
List<GenericValue> taxList = getTaxAdjustments(delegator, prod, productStore, payToPartyId, billToPartyId,
|
||||
taxAuthoritySet, ZERO_BASE, ZERO_BASE, ZERO_BASE, orderShippingAmount, null, productWeight.get(prod));
|
||||
orderAdjustments.addAll(taxList);
|
||||
}
|
||||
for (GenericValue prod : productWeight.keySet()) {
|
||||
List<GenericValue> taxList = getTaxAdjustments(delegator, prod, productStore, payToPartyId, billToPartyId,
|
||||
taxAuthoritySet, ZERO_BASE, ZERO_BASE, ZERO_BASE, orderShippingAmount, null, productWeight.get(prod));
|
||||
orderAdjustments.addAll(taxList);
|
||||
}
|
||||
}
|
||||
if (orderPromotionsAmount != null && orderPromotionsAmount.compareTo(BigDecimal.ZERO) != 0) {
|
||||
List<GenericValue> taxList = getTaxAdjustments(delegator, null, productStore, payToPartyId, billToPartyId,
|
||||
@@ -300,7 +300,7 @@ public class TaxAuthorityServices {
|
||||
}
|
||||
|
||||
private static void getTaxAuthorities(Delegator delegator, GenericValue shippingAddress,
|
||||
Set<GenericValue> taxAuthoritySet) throws GenericEntityException {
|
||||
Set<GenericValue> taxAuthoritySet) throws GenericEntityException {
|
||||
Map<String, String> geoIdByTypeMap = new HashMap<>();
|
||||
if (shippingAddress != null) {
|
||||
if (UtilValidate.isNotEmpty(shippingAddress.getString("countryGeoId"))) {
|
||||
@@ -332,13 +332,13 @@ public class TaxAuthorityServices {
|
||||
}
|
||||
|
||||
private static List<GenericValue> getTaxAdjustments(Delegator delegator, GenericValue product,
|
||||
GenericValue productStore,
|
||||
String payToPartyId, String billToPartyId, Set<GenericValue> taxAuthoritySet,
|
||||
BigDecimal itemPrice, BigDecimal itemQuantity, BigDecimal itemAmount,
|
||||
BigDecimal shippingAmount, BigDecimal orderPromotionsAmount) {
|
||||
return getTaxAdjustments(delegator, product, productStore, payToPartyId, billToPartyId,
|
||||
taxAuthoritySet, itemPrice, itemQuantity, itemAmount, shippingAmount,
|
||||
orderPromotionsAmount, null);
|
||||
GenericValue productStore,
|
||||
String payToPartyId, String billToPartyId, Set<GenericValue> taxAuthoritySet,
|
||||
BigDecimal itemPrice, BigDecimal itemQuantity, BigDecimal itemAmount,
|
||||
BigDecimal shippingAmount, BigDecimal orderPromotionsAmount) {
|
||||
return getTaxAdjustments(delegator, product, productStore, payToPartyId, billToPartyId,
|
||||
taxAuthoritySet, itemPrice, itemQuantity, itemAmount, shippingAmount,
|
||||
orderPromotionsAmount, null);
|
||||
}
|
||||
|
||||
private static List<GenericValue> getTaxAdjustments(Delegator delegator, GenericValue product,
|
||||
|
||||
+23
-22
@@ -754,29 +754,29 @@ public class AIMPaymentServices {
|
||||
private static void processAuthCaptureTransResult(Map<String, Object> request, Map<String, Object> reply, Map<String, Object> results) {
|
||||
AuthorizeResponse ar = (AuthorizeResponse) reply.get("authorizeResponse");
|
||||
try {
|
||||
Boolean authResult = (Boolean) reply.get("authResult");
|
||||
results.put("authResult", authResult);
|
||||
results.put("authFlag", ar.getReasonCode());
|
||||
results.put("authMessage", ar.getReasonText());
|
||||
results.put("captureResult", authResult);
|
||||
results.put("captureFlag", ar.getReasonCode());
|
||||
results.put("captureMessage", ar.getReasonText());
|
||||
results.put("captureRefNum", ar.getTransactionId());
|
||||
if (authResult) { //passed
|
||||
results.put("authCode", ar.getAuthorizationCode());
|
||||
results.put("authRefNum", ar.getTransactionId());
|
||||
results.put("cvCode", ar.getCvResult());
|
||||
results.put("avsCode", ar.getAvsResult());
|
||||
if (BigDecimal.ZERO.compareTo(ar.getAmount()) == 0) {
|
||||
results.put("processAmount", getXAmount(request));
|
||||
Boolean authResult = (Boolean) reply.get("authResult");
|
||||
results.put("authResult", authResult);
|
||||
results.put("authFlag", ar.getReasonCode());
|
||||
results.put("authMessage", ar.getReasonText());
|
||||
results.put("captureResult", authResult);
|
||||
results.put("captureFlag", ar.getReasonCode());
|
||||
results.put("captureMessage", ar.getReasonText());
|
||||
results.put("captureRefNum", ar.getTransactionId());
|
||||
if (authResult) { //passed
|
||||
results.put("authCode", ar.getAuthorizationCode());
|
||||
results.put("authRefNum", ar.getTransactionId());
|
||||
results.put("cvCode", ar.getCvResult());
|
||||
results.put("avsCode", ar.getAvsResult());
|
||||
if (BigDecimal.ZERO.compareTo(ar.getAmount()) == 0) {
|
||||
results.put("processAmount", getXAmount(request));
|
||||
} else {
|
||||
results.put("processAmount", ar.getAmount());
|
||||
}
|
||||
} else {
|
||||
results.put("processAmount", ar.getAmount());
|
||||
results.put("authCode", ar.getResponseCode());
|
||||
results.put("processAmount", BigDecimal.ZERO);
|
||||
results.put("authRefNum", AuthorizeResponse.ERROR);
|
||||
}
|
||||
} else {
|
||||
results.put("authCode", ar.getResponseCode());
|
||||
results.put("processAmount", BigDecimal.ZERO);
|
||||
results.put("authRefNum", AuthorizeResponse.ERROR);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Debug.logError(ex, MODULE);
|
||||
results.put("authCode", ar.getResponseCode());
|
||||
@@ -791,7 +791,8 @@ public class AIMPaymentServices {
|
||||
String returnValue = "";
|
||||
if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) {
|
||||
try {
|
||||
GenericValue payflowPro = EntityQuery.use(delegator).from("PaymentGatewayAuthorizeNet").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne();
|
||||
GenericValue payflowPro = EntityQuery.use(delegator).from("PaymentGatewayAuthorizeNet").where("paymentGatewayConfigId",
|
||||
paymentGatewayConfigId).queryOne();
|
||||
if (payflowPro != null) {
|
||||
Object payflowProField = payflowPro.get(paymentGatewayConfigParameterName);
|
||||
if (payflowProField != null) {
|
||||
|
||||
+9
-9
@@ -598,17 +598,17 @@ public class OrbitalPaymentServices {
|
||||
|
||||
private static void printTransResult(ResponseIF response) {
|
||||
Map<String, Object> generatedResponse = new HashMap<>();
|
||||
generatedResponse.put("isGood", response.isGood());
|
||||
generatedResponse.put("isGood", response.isGood());
|
||||
generatedResponse.put("isError", response.isError());
|
||||
generatedResponse.put("isQuickResponse", response.isQuickResponse());
|
||||
generatedResponse.put("isQuickResponse", response.isQuickResponse());
|
||||
generatedResponse.put("isApproved", response.isApproved());
|
||||
generatedResponse.put("isDeclined", response.isDeclined());
|
||||
generatedResponse.put("AuthCode", response.getAuthCode());
|
||||
generatedResponse.put("TxRefNum", response.getTxRefNum());
|
||||
generatedResponse.put("ResponseCode", response.getResponseCode());
|
||||
generatedResponse.put("Status", response.getStatus());
|
||||
generatedResponse.put("Message", response.getMessage());
|
||||
generatedResponse.put("AVSCode", response.getAVSResponseCode());
|
||||
generatedResponse.put("isDeclined", response.isDeclined());
|
||||
generatedResponse.put("AuthCode", response.getAuthCode());
|
||||
generatedResponse.put("TxRefNum", response.getTxRefNum());
|
||||
generatedResponse.put("ResponseCode", response.getResponseCode());
|
||||
generatedResponse.put("Status", response.getStatus());
|
||||
generatedResponse.put("Message", response.getMessage());
|
||||
generatedResponse.put("AVSCode", response.getAVSResponseCode());
|
||||
generatedResponse.put("CVV2ResponseCode", response.getCVV2RespCode());
|
||||
|
||||
Debug.logInfo("printTransResult === " + generatedResponse.toString(), MODULE);
|
||||
|
||||
+8
-6
@@ -135,15 +135,17 @@ public class PayPalEvents {
|
||||
String imageUrl = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "imageUrl", configString, "payment.paypal.image");
|
||||
|
||||
// get the paypal account
|
||||
String payPalAccount = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "businessEmail", configString, "payment.paypal.business");
|
||||
String payPalAccount = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "businessEmail", configString, "payment.paypal" +
|
||||
".business");
|
||||
|
||||
if (UtilValidate.isEmpty(redirectUrl)
|
||||
|| UtilValidate.isEmpty(notifyUrl)
|
||||
|| UtilValidate.isEmpty(returnUrl)
|
||||
|| UtilValidate.isEmpty(imageUrl)
|
||||
|| UtilValidate.isEmpty(payPalAccount)) {
|
||||
|| UtilValidate.isEmpty(notifyUrl)
|
||||
|| UtilValidate.isEmpty(returnUrl)
|
||||
|| UtilValidate.isEmpty(imageUrl)
|
||||
|| UtilValidate.isEmpty(payPalAccount)) {
|
||||
Debug.logError("Payment properties is not configured properly, some notify URL from PayPal is not correctly defined!", MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, "payPalEvents.problemsGettingMerchantConfiguration", locale));
|
||||
request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, "payPalEvents.problemsGettingMerchantConfiguration",
|
||||
locale));
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -714,7 +714,7 @@ public class PayPalServices {
|
||||
Map<String, String> errorMessages = getErrorMessageMap(decoder);
|
||||
if (UtilValidate.isNotEmpty(errorMessages)) {
|
||||
if (errorMessages.containsKey("10417")) {
|
||||
// "The transaction cannot complete successfully, Instruct the customer to use an alternative payment method"
|
||||
// "The transaction cannot complete successfully, Instruct the customer to use an alternative payment method"
|
||||
// I've only encountered this once and there's no indication of the cause so the temporary solution is to try again
|
||||
boolean retry = context.get("_RETRY_") == null || (Boolean) context.get("_RETRY_");
|
||||
if (retry) {
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ public class SagePayPaymentServices {
|
||||
billingInfo.put("currency", currency);
|
||||
billingInfo.put("description", orderId);
|
||||
billingInfo.put("cardNumber", cardNumber);
|
||||
billingInfo.put("cardHolder", nameOnCard);
|
||||
billingInfo.put("cardHolder", nameOnCard);
|
||||
billingInfo.put("expiryDate", expireDate);
|
||||
billingInfo.put("cardType", cardType);
|
||||
billingInfo.put("cv2", securityCode);
|
||||
|
||||
+121
-42
@@ -42,8 +42,7 @@ import org.apache.ofbiz.service.DispatchContext;
|
||||
import org.apache.ofbiz.service.ModelService;
|
||||
import org.apache.ofbiz.service.ServiceUtil;
|
||||
|
||||
public class SagePayServices
|
||||
{
|
||||
public class SagePayServices {
|
||||
private static final String MODULE = SagePayServices.class.getName();
|
||||
private static final String RESOURCE = "AccountingUiLabels";
|
||||
|
||||
@@ -147,58 +146,138 @@ public class SagePayServices
|
||||
parameters.put("TxType", txType);
|
||||
parameters.put("Vendor", vendor);
|
||||
|
||||
if (vendorTxCode != null) {parameters.put("VendorTxCode", vendorTxCode); }
|
||||
if (amount != null) {parameters.put("Amount", amount); }
|
||||
if (currency != null) {parameters.put("Currency", currency); } //GBP/USD
|
||||
if (description != null) {parameters.put("Description", description); }
|
||||
if (cardHolder != null) {parameters.put("CardHolder", cardHolder); }
|
||||
if (cardNumber != null) {parameters.put("CardNumber", cardNumber); }
|
||||
if (expiryDate != null) {parameters.put("ExpiryDate", expiryDate); }
|
||||
if (cardType != null) {parameters.put("CardType", cardType); }
|
||||
if (vendorTxCode != null) {
|
||||
parameters.put("VendorTxCode", vendorTxCode);
|
||||
}
|
||||
if (amount != null) {
|
||||
parameters.put("Amount", amount);
|
||||
}
|
||||
if (currency != null) {
|
||||
parameters.put("Currency", currency);
|
||||
} //GBP/USD
|
||||
if (description != null) {
|
||||
parameters.put("Description", description);
|
||||
}
|
||||
if (cardHolder != null) {
|
||||
parameters.put("CardHolder", cardHolder);
|
||||
}
|
||||
if (cardNumber != null) {
|
||||
parameters.put("CardNumber", cardNumber);
|
||||
}
|
||||
if (cardType != null) {
|
||||
parameters.put("CardType", cardType);
|
||||
}
|
||||
if (expiryDate != null) {
|
||||
parameters.put("ExpiryDate", expiryDate);
|
||||
}
|
||||
|
||||
//start - billing details
|
||||
if (billingSurname != null) {parameters.put("BillingSurname", billingSurname); }
|
||||
if (billingFirstnames != null) {parameters.put("BillingFirstnames", billingFirstnames); }
|
||||
if (billingAddress != null) {parameters.put("BillingAddress", billingAddress); }
|
||||
if (billingAddress2 != null) {parameters.put("BillingAddress2", billingAddress2); }
|
||||
if (billingCity != null) {parameters.put("BillingCity", billingCity); }
|
||||
if (billingPostCode != null) {parameters.put("BillingPostCode", billingPostCode); }
|
||||
if (billingCountry != null) {parameters.put("BillingCountry", billingCountry); }
|
||||
if (billingState != null) {parameters.put("BillingState", billingState); }
|
||||
if (billingPhone != null) {parameters.put("BillingPhone", billingPhone); }
|
||||
if (billingSurname != null) {
|
||||
parameters.put("BillingSurname", billingSurname);
|
||||
}
|
||||
if (billingFirstnames != null) {
|
||||
parameters.put("BillingFirstnames", billingFirstnames);
|
||||
}
|
||||
if (billingAddress != null) {
|
||||
parameters.put("BillingAddress", billingAddress);
|
||||
}
|
||||
if (billingAddress2 != null) {
|
||||
parameters.put("BillingAddress2", billingAddress2);
|
||||
}
|
||||
if (billingCity != null) {
|
||||
parameters.put("BillingCity", billingCity);
|
||||
}
|
||||
if (billingPostCode != null) {
|
||||
parameters.put("BillingPostCode", billingPostCode);
|
||||
}
|
||||
if (billingCountry != null) {
|
||||
parameters.put("BillingCountry", billingCountry);
|
||||
}
|
||||
if (billingState != null) {
|
||||
parameters.put("BillingState", billingState);
|
||||
}
|
||||
if (billingPhone != null) {
|
||||
parameters.put("BillingPhone", billingPhone);
|
||||
}
|
||||
//end - billing details
|
||||
|
||||
//start - delivery details
|
||||
if (isBillingSameAsDelivery != null && isBillingSameAsDelivery) {
|
||||
if (billingSurname != null) {parameters.put("DeliverySurname", billingSurname); }
|
||||
if (billingFirstnames != null) {parameters.put("DeliveryFirstnames", billingFirstnames); }
|
||||
if (billingAddress != null) {parameters.put("DeliveryAddress", billingAddress); }
|
||||
if (billingAddress2 != null) {parameters.put("DeliveryAddress2", billingAddress2); }
|
||||
if (billingCity != null) {parameters.put("DeliveryCity", billingCity); }
|
||||
if (billingPostCode != null) {parameters.put("DeliveryPostCode", billingPostCode); }
|
||||
if (billingCountry != null) {parameters.put("DeliveryCountry", billingCountry); }
|
||||
if (billingState != null) {parameters.put("DeliveryState", billingState); }
|
||||
if (billingPhone != null) {parameters.put("DeliveryPhone", billingPhone); }
|
||||
if (billingSurname != null) {
|
||||
parameters.put("DeliverySurname", billingSurname);
|
||||
}
|
||||
if (billingFirstnames != null) {
|
||||
parameters.put("DeliveryFirstnames", billingFirstnames);
|
||||
}
|
||||
if (billingAddress != null) {
|
||||
parameters.put("DeliveryAddress", billingAddress);
|
||||
}
|
||||
if (billingAddress2 != null) {
|
||||
parameters.put("DeliveryAddress2", billingAddress2);
|
||||
}
|
||||
if (billingCity != null) {
|
||||
parameters.put("DeliveryCity", billingCity);
|
||||
}
|
||||
if (billingPostCode != null) {
|
||||
parameters.put("DeliveryPostCode", billingPostCode);
|
||||
}
|
||||
if (billingCountry != null) {
|
||||
parameters.put("DeliveryCountry", billingCountry);
|
||||
}
|
||||
if (billingState != null) {
|
||||
parameters.put("DeliveryState", billingState);
|
||||
}
|
||||
if (billingPhone != null) {
|
||||
parameters.put("DeliveryPhone", billingPhone);
|
||||
}
|
||||
} else {
|
||||
if (deliverySurname != null) {parameters.put("DeliverySurname", deliverySurname); }
|
||||
if (deliveryFirstnames != null) {parameters.put("DeliveryFirstnames", deliveryFirstnames); }
|
||||
if (deliveryAddress != null) {parameters.put("DeliveryAddress", deliveryAddress); }
|
||||
if (deliveryAddress2 != null) {parameters.put("DeliveryAddress2", deliveryAddress2); }
|
||||
if (deliveryCity != null) {parameters.put("DeliveryCity", deliveryCity); }
|
||||
if (deliveryPostCode != null) {parameters.put("DeliveryPostCode", deliveryPostCode); }
|
||||
if (deliveryCountry != null) {parameters.put("DeliveryCountry", deliveryCountry); }
|
||||
if (deliveryState != null) {parameters.put("DeliveryState", deliveryState); }
|
||||
if (deliveryPhone != null) {parameters.put("DeliveryPhone", deliveryPhone); }
|
||||
if (deliverySurname != null) {
|
||||
parameters.put("DeliverySurname", deliverySurname);
|
||||
}
|
||||
if (deliveryFirstnames != null) {
|
||||
parameters.put("DeliveryFirstnames", deliveryFirstnames);
|
||||
}
|
||||
if (deliveryAddress != null) {
|
||||
parameters.put("DeliveryAddress", deliveryAddress);
|
||||
}
|
||||
if (deliveryAddress2 != null) {
|
||||
parameters.put("DeliveryAddress2", deliveryAddress2);
|
||||
}
|
||||
if (deliveryCity != null) {
|
||||
parameters.put("DeliveryCity", deliveryCity);
|
||||
}
|
||||
if (deliveryPostCode != null) {
|
||||
parameters.put("DeliveryPostCode", deliveryPostCode);
|
||||
}
|
||||
if (deliveryCountry != null) {
|
||||
parameters.put("DeliveryCountry", deliveryCountry);
|
||||
}
|
||||
if (deliveryState != null) {
|
||||
parameters.put("DeliveryState", deliveryState);
|
||||
}
|
||||
if (deliveryPhone != null) {
|
||||
parameters.put("DeliveryPhone", deliveryPhone);
|
||||
}
|
||||
}
|
||||
//end - delivery details
|
||||
//end - required parameters
|
||||
|
||||
//start - optional parameters
|
||||
if (cv2 != null) {parameters.put("CV2", cv2); }
|
||||
if (startDate != null) {parameters.put("StartDate", startDate); }
|
||||
if (issueNumber != null) {parameters.put("IssueNumber", issueNumber); }
|
||||
if (basket != null) {parameters.put("Basket", basket); }
|
||||
if (clientIPAddress != null) {parameters.put("ClientIPAddress", clientIPAddress); }
|
||||
if (cv2 != null) {
|
||||
parameters.put("CV2", cv2);
|
||||
}
|
||||
if (startDate != null) {
|
||||
parameters.put("StartDate", startDate);
|
||||
}
|
||||
if (issueNumber != null) {
|
||||
parameters.put("IssueNumber", issueNumber);
|
||||
}
|
||||
if (basket != null) {
|
||||
parameters.put("Basket", basket);
|
||||
}
|
||||
if (clientIPAddress != null) {
|
||||
parameters.put("ClientIPAddress", clientIPAddress);
|
||||
}
|
||||
//end - optional parameters
|
||||
//end - authentication parameters
|
||||
|
||||
|
||||
+109
-43
@@ -31,6 +31,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpResponse;
|
||||
@@ -46,79 +47,144 @@ import org.apache.ofbiz.base.util.Debug;
|
||||
public final class SagePayUtil {
|
||||
|
||||
private static final String MODULE = SagePayUtil.class.getName();
|
||||
private SagePayUtil() { }
|
||||
|
||||
public static Map<String, Object> buildCardAuthorisationPaymentResponse
|
||||
(Boolean authResult, String authCode, String authFlag, BigDecimal processAmount, String authRefNum, String authAltRefNum, String authMessage) {
|
||||
private SagePayUtil() {
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildCardAuthorisationPaymentResponse(Boolean authResult,
|
||||
String authCode, String authFlag, BigDecimal processAmount, String authRefNum, String authAltRefNum, String authMessage) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (authResult != null) {result.put("authResult", authResult); }
|
||||
if (authCode != null) {result.put("authCode", authCode); }
|
||||
if (authFlag != null) {result.put("authFlag", authFlag); }
|
||||
if (processAmount != null) {result.put("processAmount", processAmount); }
|
||||
if (authRefNum != null) {result.put("authRefNum", authRefNum); }
|
||||
if (authAltRefNum != null) {result.put("authAltRefNum", authAltRefNum); }
|
||||
if (authMessage != null) {result.put("authMessage", authMessage); }
|
||||
if (authResult != null) {
|
||||
result.put("authResult", authResult);
|
||||
}
|
||||
if (authCode != null) {
|
||||
result.put("authCode", authCode);
|
||||
}
|
||||
if (authFlag != null) {
|
||||
result.put("authFlag", authFlag);
|
||||
}
|
||||
if (processAmount != null) {
|
||||
result.put("processAmount", processAmount);
|
||||
}
|
||||
if (authRefNum != null) {
|
||||
result.put("authRefNum", authRefNum);
|
||||
}
|
||||
if (authAltRefNum != null) {
|
||||
result.put("authAltRefNum", authAltRefNum);
|
||||
}
|
||||
if (authMessage != null) {
|
||||
result.put("authMessage", authMessage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildCardCapturePaymentResponse
|
||||
(Boolean captureResult, String captureCode, String captureFlag, BigDecimal captureAmount, String captureRefNum, String captureAltRefNum, String captureMessage) {
|
||||
public static Map<String, Object> buildCardCapturePaymentResponse(Boolean captureResult,
|
||||
String captureCode, String captureFlag, BigDecimal captureAmount, String captureRefNum, String captureAltRefNum, String captureMessage) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (captureResult != null) {result.put("captureResult", captureResult); }
|
||||
if (captureCode != null) {result.put("captureCode", captureCode); }
|
||||
if (captureFlag != null) {result.put("captureFlag", captureFlag); }
|
||||
if (captureAmount != null) {result.put("captureAmount", captureAmount); }
|
||||
if (captureRefNum != null) {result.put("captureRefNum", captureRefNum); }
|
||||
if (captureAltRefNum != null) {result.put("captureAltRefNum", captureAltRefNum); }
|
||||
if (captureMessage != null) {result.put("captureMessage", captureMessage); }
|
||||
if (captureResult != null) {
|
||||
result.put("captureResult", captureResult);
|
||||
}
|
||||
if (captureCode != null) {
|
||||
result.put("captureCode", captureCode);
|
||||
}
|
||||
if (captureFlag != null) {
|
||||
result.put("captureFlag", captureFlag);
|
||||
}
|
||||
if (captureAmount != null) {
|
||||
result.put("captureAmount", captureAmount);
|
||||
}
|
||||
if (captureRefNum != null) {
|
||||
result.put("captureRefNum", captureRefNum);
|
||||
}
|
||||
if (captureAltRefNum != null) {
|
||||
result.put("captureAltRefNum", captureAltRefNum);
|
||||
}
|
||||
if (captureMessage != null) {
|
||||
result.put("captureMessage", captureMessage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildCardReleasePaymentResponse
|
||||
(Boolean releaseResult, String releaseCode, BigDecimal releaseAmount, String releaseRefNum, String releaseAltRefNum, String releaseMessage) {
|
||||
public static Map<String, Object> buildCardReleasePaymentResponse(Boolean releaseResult,
|
||||
String releaseCode, BigDecimal releaseAmount, String releaseRefNum, String releaseAltRefNum, String releaseMessage) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (releaseResult != null) {result.put("releaseResult", releaseResult); }
|
||||
if (releaseCode != null) {result.put("releaseCode", releaseCode); }
|
||||
if (releaseAmount != null) {result.put("releaseAmount", releaseAmount); }
|
||||
if (releaseRefNum != null) {result.put("releaseRefNum", releaseRefNum); }
|
||||
if (releaseAltRefNum != null) {result.put("releaseAltRefNum", releaseAltRefNum); }
|
||||
if (releaseMessage != null) {result.put("releaseMessage", releaseMessage); }
|
||||
if (releaseResult != null) {
|
||||
result.put("releaseResult", releaseResult);
|
||||
}
|
||||
if (releaseCode != null) {
|
||||
result.put("releaseCode", releaseCode);
|
||||
}
|
||||
if (releaseAmount != null) {
|
||||
result.put("releaseAmount", releaseAmount);
|
||||
}
|
||||
if (releaseRefNum != null) {
|
||||
result.put("releaseRefNum", releaseRefNum);
|
||||
}
|
||||
if (releaseAltRefNum != null) {
|
||||
result.put("releaseAltRefNum", releaseAltRefNum);
|
||||
}
|
||||
if (releaseMessage != null) {
|
||||
result.put("releaseMessage", releaseMessage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildCardVoidPaymentResponse
|
||||
(Boolean refundResult, BigDecimal refundAmount, String refundRefNum, String refundAltRefNum, String refundMessage) {
|
||||
public static Map<String, Object> buildCardVoidPaymentResponse(Boolean refundResult,
|
||||
BigDecimal refundAmount, String refundRefNum, String refundAltRefNum, String refundMessage) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (refundResult != null) {result.put("refundResult", refundResult); }
|
||||
if (refundAmount != null) {result.put("refundAmount", refundAmount); }
|
||||
if (refundRefNum != null) {result.put("refundRefNum", refundRefNum); }
|
||||
if (refundAltRefNum != null) {result.put("refundAltRefNum", refundAltRefNum); }
|
||||
if (refundMessage != null) {result.put("refundMessage", refundMessage); }
|
||||
if (refundResult != null) {
|
||||
result.put("refundResult", refundResult);
|
||||
}
|
||||
if (refundAmount != null) {
|
||||
result.put("refundAmount", refundAmount);
|
||||
}
|
||||
if (refundRefNum != null) {
|
||||
result.put("refundRefNum", refundRefNum);
|
||||
}
|
||||
if (refundAltRefNum != null) {
|
||||
result.put("refundAltRefNum", refundAltRefNum);
|
||||
}
|
||||
if (refundMessage != null) {
|
||||
result.put("refundMessage", refundMessage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildCardRefundPaymentResponse
|
||||
(Boolean refundResult, String refundCode, BigDecimal refundAmount, String refundRefNum, String refundAltRefNum, String refundMessage) {
|
||||
public static Map<String, Object> buildCardRefundPaymentResponse(Boolean refundResult,
|
||||
String refundCode, BigDecimal refundAmount, String refundRefNum, String refundAltRefNum, String refundMessage) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (refundResult != null) {result.put("refundResult", refundResult); }
|
||||
if (refundCode != null) {result.put("refundCode", refundCode); }
|
||||
if (refundAmount != null) {result.put("refundAmount", refundAmount); }
|
||||
if (refundRefNum != null) {result.put("refundRefNum", refundRefNum); }
|
||||
if (refundAltRefNum != null) {result.put("refundAltRefNum", refundAltRefNum); }
|
||||
if (refundMessage != null) {result.put("refundMessage", refundMessage); }
|
||||
if (refundResult != null) {
|
||||
result.put("refundResult", refundResult);
|
||||
}
|
||||
if (refundCode != null) {
|
||||
result.put("refundCode", refundCode);
|
||||
}
|
||||
if (refundAmount != null) {
|
||||
result.put("refundAmount", refundAmount);
|
||||
}
|
||||
if (refundRefNum != null) {
|
||||
result.put("refundRefNum", refundRefNum);
|
||||
}
|
||||
if (refundAltRefNum != null) {
|
||||
result.put("refundAltRefNum", refundAltRefNum);
|
||||
}
|
||||
if (refundMessage != null) {
|
||||
result.put("refundMessage", refundMessage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds HttpHost with the given SagePayProperties.
|
||||
*
|
||||
* @param props SagePay properties
|
||||
* @throws IllegalArgumentException if neither productionHost nor testingHost found in properties.
|
||||
* @return
|
||||
* @throws IllegalArgumentException if neither productionHost nor testingHost found in properties.
|
||||
*/
|
||||
public static HttpHost getHost(Map<String, String> props) {
|
||||
String hostUrl = null;
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public class SecurePayServiceTest extends OFBizTestCase {
|
||||
orderId = "Demo1002";
|
||||
creditCard = delegator.makeValue("CreditCard", UtilMisc.toMap(
|
||||
"cardType", "CCT_VISA",
|
||||
"expireDate", "10/2011", // mm/yyyy, gets converted to mm/yy
|
||||
"expireDate", "10/2011", // mm/yyyy, gets converted to mm/yy
|
||||
"cardNumber", "4444333322221111"));
|
||||
billingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap(
|
||||
"toName", "The customer Name",
|
||||
|
||||
+1
-1
@@ -419,7 +419,7 @@ public class ValueLinkApi {
|
||||
byte[] secretKey = ka.generateSecret();
|
||||
|
||||
if (debug) {
|
||||
Debug.logInfo("Secret Key : " + StringUtil.toHexString(secretKey) + " / " + secretKey.length, MODULE);
|
||||
Debug.logInfo("Secret Key : " + StringUtil.toHexString(secretKey) + " / " + secretKey.length, MODULE);
|
||||
}
|
||||
|
||||
// generate 3DES from secret key using VL algorithm (KEK)
|
||||
|
||||
+9
-9
@@ -108,7 +108,7 @@ public class PayflowPro {
|
||||
data.put("CUSTCODE", party.getString("partyId"));
|
||||
|
||||
// transaction type
|
||||
if (comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "preAuth", configString, "payment.verisign.preAuth", "Y")) {
|
||||
if (comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "preAuth", configString, "payment.verisign.preAuth", "Y")) {
|
||||
data.put("TRXTYPE", "A");
|
||||
// only support re-auth for auth types; sale types don't do it
|
||||
if (authTrans != null) {
|
||||
@@ -147,7 +147,7 @@ public class PayflowPro {
|
||||
// gather the address info
|
||||
if (ps != null) {
|
||||
String street = ps.getString("address1") + ((UtilValidate.isNotEmpty(ps.getString("address2"))) ? " " + ps.getString("address2") : "");
|
||||
data.put("STREET"+"["+street.length()+"]", street);
|
||||
data.put("STREET" + "[" + street.length() + "]", street);
|
||||
data.put("ZIP", ps.getString("postalCode"));
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ public class PayflowPro {
|
||||
Debug.logVerbose("Sending to Verisign: " + params.toString(), MODULE);
|
||||
}
|
||||
String resp;
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
resp = pfp.submitTransaction(params.toString(), pfp.generateRequestId());
|
||||
} else {
|
||||
resp = "RESULT=0&AUTHCODE=T&PNREF=" + (new Date()).getTime() + "&RESPMSG=Testing";
|
||||
@@ -253,7 +253,7 @@ public class PayflowPro {
|
||||
Debug.logVerbose("Sending to Verisign: " + params.toString(), MODULE);
|
||||
}
|
||||
String resp;
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
resp = pfp.submitTransaction(params.toString(), pfp.generateRequestId());
|
||||
} else {
|
||||
resp = "RESULT=0&AUTHCODE=T&PNREF=" + (new Date()).getTime() + "&RESPMSG=Testing";
|
||||
@@ -335,7 +335,7 @@ public class PayflowPro {
|
||||
Debug.logVerbose("Sending to Verisign: " + params.toString(), MODULE);
|
||||
}
|
||||
String resp;
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
resp = pfp.submitTransaction(params.toString(), pfp.generateRequestId());
|
||||
} else {
|
||||
resp = "RESULT=0&AUTHCODE=T&PNREF=" + (new Date()).getTime() + "&RESPMSG=Testing";
|
||||
@@ -416,7 +416,7 @@ public class PayflowPro {
|
||||
Debug.logVerbose("Sending to Verisign: " + params.toString(), MODULE);
|
||||
}
|
||||
String resp;
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
resp = pfp.submitTransaction(params.toString(), pfp.generateRequestId());
|
||||
} else {
|
||||
resp = "RESULT=0&AUTHCODE=T&PNREF=" + (new Date()).getTime() + "&RESPMSG=Testing";
|
||||
@@ -480,7 +480,7 @@ public class PayflowPro {
|
||||
Debug.logVerbose("Sending to Verisign: " + params.toString(), MODULE);
|
||||
}
|
||||
String resp;
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
resp = pfp.submitTransaction(params.toString(), pfp.generateRequestId());
|
||||
} else {
|
||||
resp = "RESULT=0&TOKEN=" + (new Date()).getTime() + "&RESPMSG=Testing";
|
||||
@@ -583,7 +583,7 @@ public class PayflowPro {
|
||||
Debug.logVerbose("Sending to Verisign: " + params.toString(), MODULE);
|
||||
}
|
||||
String resp;
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
resp = pfp.submitTransaction(params.toString(), pfp.generateRequestId());
|
||||
} else {
|
||||
resp = "RESULT=0&PAYERID=" + (new Date()).getTime() + "&RESPMSG=Testing";
|
||||
@@ -664,7 +664,7 @@ public class PayflowPro {
|
||||
Debug.logVerbose("Sending to Verisign: " + params.toString(), MODULE);
|
||||
}
|
||||
String resp;
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) {
|
||||
resp = pfp.submitTransaction(params.toString(), pfp.generateRequestId());
|
||||
} else {
|
||||
resp = "RESULT=0&PAYERID=" + (new Date()).getTime() + "&RESPMSG=Testing";
|
||||
|
||||
+10
-10
@@ -120,16 +120,16 @@ public class ContentManagementEvents {
|
||||
}
|
||||
} else if (UtilValidate.isNotEmpty(pubValue)) {
|
||||
if ("Y".equalsIgnoreCase(pubValue)) {
|
||||
serviceIn.put("thruDate", UtilDateTime.nowTimestamp());
|
||||
Timestamp fromDate = (Timestamp) map.get(pubContentId + "FromDate");
|
||||
serviceIn.put("fromDate", fromDate);
|
||||
result = dispatcher.runSync("updateContentAssoc", serviceIn);
|
||||
if (ServiceUtil.isError(result)) {
|
||||
String errorMessage = ServiceUtil.getErrorMessage(result);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errorMessage);
|
||||
Debug.logError(errorMessage, MODULE);
|
||||
return "error";
|
||||
}
|
||||
serviceIn.put("thruDate", UtilDateTime.nowTimestamp());
|
||||
Timestamp fromDate = (Timestamp) map.get(pubContentId + "FromDate");
|
||||
serviceIn.put("fromDate", fromDate);
|
||||
result = dispatcher.runSync("updateContentAssoc", serviceIn);
|
||||
if (ServiceUtil.isError(result)) {
|
||||
String errorMessage = ServiceUtil.getErrorMessage(result);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errorMessage);
|
||||
Debug.logError(errorMessage, MODULE);
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (GenericServiceException e) {
|
||||
|
||||
+33
-33
@@ -282,7 +282,7 @@ public class ContentManagementServices {
|
||||
Map<String, Object> thisResult = dispatcher.runSync("updateContent", contentContext);
|
||||
if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentContentUpdatingError", UtilMisc.toMap("serviceName",
|
||||
"persistContentAndAssoc"), locale), null, null, thisResult);
|
||||
"persistContentAndAssoc"), locale), null, null, thisResult);
|
||||
}
|
||||
} else {
|
||||
Map<String, Object> contentContext = new HashMap<>();
|
||||
@@ -295,7 +295,7 @@ public class ContentManagementServices {
|
||||
Map<String, Object> thisResult = dispatcher.runSync("createContent", contentContext);
|
||||
if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentContentCreatingError", UtilMisc.toMap("serviceName",
|
||||
"persistContentAndAssoc"), locale), null, null, thisResult);
|
||||
"persistContentAndAssoc"), locale), null, null, thisResult);
|
||||
}
|
||||
contentId = (String) thisResult.get("contentId");
|
||||
}
|
||||
@@ -309,7 +309,7 @@ public class ContentManagementServices {
|
||||
Set<String> contentPurposeSet = new LinkedHashSet<>(contentPurposeList);
|
||||
for (String contentPurposeTypeId : contentPurposeSet) {
|
||||
GenericValue contentPurpose = delegator.makeValue("ContentPurpose", UtilMisc.toMap("contentId", contentId,
|
||||
"contentPurposeTypeId", contentPurposeTypeId));
|
||||
"contentPurposeTypeId", contentPurposeTypeId));
|
||||
contentPurpose.create();
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -830,12 +830,12 @@ public class ContentManagementServices {
|
||||
}
|
||||
EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList);
|
||||
EntityCondition conditionMain = EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("contentIdTo",
|
||||
EntityOperator.EQUALS, contentIdTo), conditionType), EntityOperator.AND);
|
||||
EntityOperator.EQUALS, contentIdTo), conditionType), EntityOperator.AND);
|
||||
try {
|
||||
List<GenericValue> listAll = EntityQuery.use(delegator).from("ContentAssoc")
|
||||
.where(conditionMain)
|
||||
.orderBy("sequenceNum", "fromDate", "createdDate")
|
||||
.filterByDate().queryList();
|
||||
.where(conditionMain)
|
||||
.orderBy("sequenceNum", "fromDate", "createdDate")
|
||||
.filterByDate().queryList();
|
||||
String contentId = (String) context.get("contentId");
|
||||
String dir = (String) context.get("dir");
|
||||
int seqNum = seqIncrement;
|
||||
@@ -994,7 +994,7 @@ public class ContentManagementServices {
|
||||
thisContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
|
||||
if (thisContent == null) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentNoContentFound", UtilMisc.toMap("contentId", contentId),
|
||||
locale));
|
||||
locale));
|
||||
}
|
||||
thisContent.set("contentTypeId", contentTypeId);
|
||||
thisContent.store();
|
||||
@@ -1035,7 +1035,7 @@ public class ContentManagementServices {
|
||||
thisContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
|
||||
if (thisContent == null) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
|
||||
"ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale));
|
||||
"ContentNoContentFound", UtilMisc.toMap("contentId", contentId), locale));
|
||||
}
|
||||
thisContent.set("contentTypeId", "OUTLINE_NODE");
|
||||
thisContent.store();
|
||||
@@ -1047,7 +1047,7 @@ public class ContentManagementServices {
|
||||
kidContent.put("contentTypeId", "PAGE_NODE");
|
||||
kidContent.store();
|
||||
List<GenericValue> kids2 = ContentWorker.getAssociatedContent(kidContent, "from", UtilMisc.toList("SUB_CONTENT"), null, null,
|
||||
null);
|
||||
null);
|
||||
for (GenericValue kidContent2 : kids2) {
|
||||
updatePageNodeChildren(kidContent2, context);
|
||||
}
|
||||
@@ -1162,11 +1162,11 @@ public class ContentManagementServices {
|
||||
String contentIdTo = (String) context.get("contentId");
|
||||
try {
|
||||
List<GenericValue> lst = EntityQuery.use(delegator).from("ContentAssocDataResourceViewFrom")
|
||||
.where("caContentIdTo", contentIdTo,
|
||||
"caContentAssocTypeId", "SUB_CONTENT",
|
||||
"caThruDate", null)
|
||||
.orderBy("caSequenceNum", "caFromDate", "createdDate")
|
||||
.queryList();
|
||||
.where("caContentIdTo", contentIdTo,
|
||||
"caContentAssocTypeId", "SUB_CONTENT",
|
||||
"caThruDate", null)
|
||||
.orderBy("caSequenceNum", "caFromDate", "createdDate")
|
||||
.queryList();
|
||||
results.put("_LIST_", lst);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
@@ -1221,7 +1221,7 @@ public class ContentManagementServices {
|
||||
GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
|
||||
if (content == null) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentNoContentFound", UtilMisc.toMap("contentId", contentId),
|
||||
locale));
|
||||
locale));
|
||||
}
|
||||
Long leafCount = (Long) content.get("childLeafCount");
|
||||
if (leafCount == null) {
|
||||
@@ -1231,7 +1231,7 @@ public class ContentManagementServices {
|
||||
int changeBranchCount = 1;
|
||||
|
||||
ContentManagementWorker.updateStatsBottomUp(delegator, contentId, UtilMisc.toList(contentAssocTypeId), changeBranchCount,
|
||||
changeLeafCount);
|
||||
changeLeafCount);
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(e.toString());
|
||||
}
|
||||
@@ -1249,7 +1249,7 @@ public class ContentManagementServices {
|
||||
GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
|
||||
if (content == null) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentNoContentFound", UtilMisc.toMap("contentId", contentId),
|
||||
locale));
|
||||
locale));
|
||||
}
|
||||
Long leafCount = (Long) content.get("childLeafCount");
|
||||
if (leafCount == null) {
|
||||
@@ -1259,7 +1259,7 @@ public class ContentManagementServices {
|
||||
int changeBranchCount = -1;
|
||||
|
||||
ContentManagementWorker.updateStatsBottomUp(delegator, contentId, UtilMisc.toList(contentAssocTypeId), changeBranchCount,
|
||||
changeLeafCount);
|
||||
changeLeafCount);
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(e.toString());
|
||||
}
|
||||
@@ -1303,10 +1303,10 @@ public class ContentManagementServices {
|
||||
GenericValue contentRole = null;
|
||||
try {
|
||||
contentRole = EntityQuery.use(delegator).from("ContentRole")
|
||||
.where("partyId", partyId, "contentId", webPubPt, "roleTypeId", roleTypeId)
|
||||
.orderBy("fromDate DESC")
|
||||
.cache().filterByDate()
|
||||
.queryFirst();
|
||||
.where("partyId", partyId, "contentId", webPubPt, "roleTypeId", roleTypeId)
|
||||
.orderBy("fromDate DESC")
|
||||
.cache().filterByDate()
|
||||
.queryFirst();
|
||||
if (contentRole != null) {
|
||||
hasExistingContentRole = true;
|
||||
}
|
||||
@@ -1386,12 +1386,12 @@ public class ContentManagementServices {
|
||||
GenericValue productContent = null;
|
||||
try {
|
||||
List<GenericValue> lst = EntityQuery.use(delegator).from("ProductContent")
|
||||
.where("productId", productId, "productContentTypeId", "ONLINE_ACCESS")
|
||||
.orderBy("purchaseFromDate", "purchaseThruDate")
|
||||
.filterByDate("purchaseFromDate", "purchaseThruDate")
|
||||
.cache().queryList();
|
||||
.where("productId", productId, "productContentTypeId", "ONLINE_ACCESS")
|
||||
.orderBy("purchaseFromDate", "purchaseThruDate")
|
||||
.filterByDate("purchaseFromDate", "purchaseThruDate")
|
||||
.cache().queryList();
|
||||
List<GenericValue> listThrusOnly = EntityUtil.filterOutByCondition(lst, EntityCondition.makeCondition("purchaseThruDate",
|
||||
EntityOperator.EQUALS, null));
|
||||
EntityOperator.EQUALS, null));
|
||||
if (listThrusOnly.size() > 0) {
|
||||
productContent = listThrusOnly.get(0);
|
||||
} else if (lst.size() > 0) {
|
||||
@@ -1437,8 +1437,8 @@ public class ContentManagementServices {
|
||||
GenericValue orderHeader = null;
|
||||
try {
|
||||
GenericValue orderRole = EntityQuery.use(delegator).from("OrderRole")
|
||||
.where("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER")
|
||||
.queryFirst();
|
||||
.where("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER")
|
||||
.queryFirst();
|
||||
if (orderRole != null) {
|
||||
String partyId = (String) orderRole.get("partyId");
|
||||
context.put("partyId", partyId);
|
||||
@@ -1460,8 +1460,8 @@ public class ContentManagementServices {
|
||||
BigDecimal qty = orderItem.getBigDecimal("quantity");
|
||||
String productId = (String) orderItem.get("productId");
|
||||
long productContentCount = EntityQuery.use(delegator).from("ProductContent")
|
||||
.where("productId", productId, "productContentTypeId", "ONLINE_ACCESS")
|
||||
.filterByDate().queryCount();
|
||||
.where("productId", productId, "productContentTypeId", "ONLINE_ACCESS")
|
||||
.filterByDate().queryCount();
|
||||
if (productContentCount > 0) {
|
||||
context.put("productId", productId);
|
||||
context.put("quantity", qty.intValue());
|
||||
@@ -1514,7 +1514,7 @@ public class ContentManagementServices {
|
||||
}
|
||||
|
||||
public static Map<String, Object> followNodeChildrenMethod(GenericValue content, LocalDispatcher dispatcher, String serviceName, Map<String,
|
||||
Object> context) throws GenericEntityException, GenericServiceException {
|
||||
Object> context) throws GenericEntityException, GenericServiceException {
|
||||
Map<String, Object> result = null;
|
||||
String contentId = content.getString("contentId");
|
||||
List<String> contentAssocTypeIdList = UtilGenerics.cast(context.get("contentAssocTypeIdList"));
|
||||
|
||||
+16
-16
@@ -303,7 +303,7 @@ public final class ContentManagementWorker {
|
||||
}
|
||||
Map<String, Object> results = null;
|
||||
results = EntityPermissionChecker.checkPermission(content, statusId, userLogin, passedPurposes, targetOperationList, roles, delegator,
|
||||
security, entityAction);
|
||||
security, entityAction);
|
||||
String permissionStatus = (String) results.get("permissionStatus");
|
||||
if (permissionStatus != null && "granted".equalsIgnoreCase(permissionStatus)) {
|
||||
String[] arr = {contentId, templateTitle};
|
||||
@@ -323,8 +323,8 @@ public final class ContentManagementWorker {
|
||||
List<GenericValue> relatedPubPts = null;
|
||||
try {
|
||||
relatedPubPts = EntityQuery.use(delegator).from("ContentAssoc")
|
||||
.where("contentIdTo", parentPubPt, "contentAssocTypeId", "SUBSITE")
|
||||
.cache().queryList();
|
||||
.where("contentIdTo", parentPubPt, "contentAssocTypeId", "SUBSITE")
|
||||
.cache().queryList();
|
||||
} catch (GenericEntityException e) {
|
||||
throw new GeneralException(e.getMessage());
|
||||
}
|
||||
@@ -451,8 +451,8 @@ public final class ContentManagementWorker {
|
||||
public static String getParentWebSitePublishPointId(Delegator delegator, String contentId) throws GenericEntityException {
|
||||
String contentIdTo = null;
|
||||
GenericValue contentAssoc = EntityQuery.use(delegator).from("ContentAssoc")
|
||||
.where("contentId", contentId, "contentAssocTypeId", "SUBSITE")
|
||||
.filterByDate().cache().queryFirst();
|
||||
.where("contentId", contentId, "contentAssocTypeId", "SUBSITE")
|
||||
.filterByDate().cache().queryFirst();
|
||||
if (contentAssoc != null) {
|
||||
contentIdTo = contentAssoc.getString("contentIdTo");
|
||||
}
|
||||
@@ -478,7 +478,7 @@ public final class ContentManagementWorker {
|
||||
// and another map (publishPointMapAll) that points to one of the top-level points.
|
||||
List<GenericValue> allPublishPointList = getAllPublishPoints(delegator, rootPubId);
|
||||
List<String[]> publishPointList = getPermittedPublishPoints(delegator, allPublishPointList, userLogin, security, permittedAction,
|
||||
permittedOperations, passedRoles);
|
||||
permittedOperations, passedRoles);
|
||||
Map<String, Object> publishPointMap = new HashMap<>();
|
||||
Map<String, Object> publishPointMapAll = new HashMap<>();
|
||||
for (String[] arr : publishPointList) {
|
||||
@@ -500,8 +500,8 @@ public final class ContentManagementWorker {
|
||||
List<GenericValue> assocValueList = null;
|
||||
try {
|
||||
assocValueList = EntityQuery.use(delegator).from("ContentAssoc")
|
||||
.where("contentId", targContentId, "contentAssocTypeId", "PUBLISH_LINK")
|
||||
.filterByDate().cache().queryList();
|
||||
.where("contentId", targContentId, "contentAssocTypeId", "PUBLISH_LINK")
|
||||
.filterByDate().cache().queryList();
|
||||
} catch (GenericEntityException e) {
|
||||
throw new GeneralException(e.getMessage());
|
||||
}
|
||||
@@ -544,7 +544,7 @@ public final class ContentManagementWorker {
|
||||
// TODO check if we want contentTypes to be filled/used, else this should be removed
|
||||
List<String> contentTypes = null;
|
||||
Map<String, Object> results = ContentServicesComplex.getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, null, "To",
|
||||
null, null, assocTypes, contentTypes, Boolean.TRUE, null, null);
|
||||
null, null, assocTypes, contentTypes, Boolean.TRUE, null, null);
|
||||
List<GenericValue> valueList = UtilGenerics.cast(results.get("entityList"));
|
||||
if (valueList.size() > 0) {
|
||||
GenericValue value = valueList.get(0);
|
||||
@@ -583,7 +583,7 @@ public final class ContentManagementWorker {
|
||||
}
|
||||
Map<String, Object> results = null;
|
||||
results = EntityPermissionChecker.checkPermission(content, statusId, userLogin, passedPurposes, targetOperationList, roles, delegator,
|
||||
security, entityAction);
|
||||
security, entityAction);
|
||||
String permissionStatus = (String) results.get("permissionStatus");
|
||||
if (permissionStatus != null && "granted".equalsIgnoreCase(permissionStatus)) {
|
||||
String[] arr = {contentId, contentName};
|
||||
@@ -603,8 +603,8 @@ public final class ContentManagementWorker {
|
||||
List<GenericValue> relatedPubPts = null;
|
||||
try {
|
||||
relatedPubPts = EntityQuery.use(delegator).from("ContentAssoc")
|
||||
.where("contentIdTo", parentPubPt, "contentAssocTypeId", "DEPARTMENT")
|
||||
.cache().queryList();
|
||||
.where("contentIdTo", parentPubPt, "contentAssocTypeId", "DEPARTMENT")
|
||||
.cache().queryList();
|
||||
|
||||
} catch (GenericEntityException e) {
|
||||
throw new GeneralException(e.getMessage());
|
||||
@@ -640,7 +640,7 @@ public final class ContentManagementWorker {
|
||||
conditionMain.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList));
|
||||
}
|
||||
List<GenericValue> contentAssocs = EntityQuery.use(delegator).from("ContentAssoc").where(conditionMain)
|
||||
.filterByDate().cache().queryList();
|
||||
.filterByDate().cache().queryList();
|
||||
for (GenericValue contentAssoc : contentAssocs) {
|
||||
String subContentId = contentAssoc.getString("contentId");
|
||||
subLeafCount += updateStatsTopDown(delegator, subContentId, typeList);
|
||||
@@ -663,9 +663,9 @@ public final class ContentManagementWorker {
|
||||
throw new RuntimeException("No entity found for id=" + contentId);
|
||||
|
||||
List<GenericValue> contentAssocs = EntityQuery.use(delegator).from("ContentAssoc")
|
||||
.where(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList),
|
||||
EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId))
|
||||
.cache().filterByDate().queryList();
|
||||
.where(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList),
|
||||
EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId))
|
||||
.cache().filterByDate().queryList();
|
||||
for (GenericValue contentAssoc : contentAssocs) {
|
||||
String contentIdTo = contentAssoc.getString("contentIdTo");
|
||||
GenericValue contentTo = EntityQuery.use(delegator).from("Content").where("contentId", contentIdTo).queryOne();
|
||||
|
||||
@@ -118,240 +118,239 @@ public class CmsEvents {
|
||||
throw new GeneralRuntimeException("Error in the response writer/output stream while rendering content.", e);
|
||||
} catch (GeneralException e) {
|
||||
throw new GeneralRuntimeException("Error rendering content", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If an override view is present then use that in place of request.getPathInfo()
|
||||
String overrideViewUri = (String) request.getAttribute("_CURRENT_CHAIN_VIEW_");
|
||||
if (UtilValidate.isNotEmpty(overrideViewUri)) {
|
||||
pathInfo = overrideViewUri;
|
||||
} else {
|
||||
pathInfo = request.getPathInfo();
|
||||
if (targetRequest.equals(actualRequest) && pathInfo != null) {
|
||||
// was called directly -- path info is everything after the request
|
||||
String[] pathParsed = pathInfo.split("/", 3);
|
||||
if (pathParsed.length > 2) {
|
||||
pathInfo = pathParsed[2];
|
||||
} else {
|
||||
pathInfo = null;
|
||||
}
|
||||
} // if called through the default request, there is no request in pathinfo
|
||||
}
|
||||
|
||||
// if path info is null or path info is / (i.e application mounted on root); check for a default content
|
||||
if (pathInfo == null || "/".equals(pathInfo)) {
|
||||
GenericValue defaultContent = null;
|
||||
try {
|
||||
defaultContent = EntityQuery.use(delegator).from("WebSiteContent")
|
||||
.where("webSiteId", webSiteId, "webSiteContentTypeId", "DEFAULT_PAGE")
|
||||
.orderBy("-fromDate").filterByDate().cache().queryFirst();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
if (defaultContent != null) {
|
||||
pathInfo = defaultContent.getString("contentId");
|
||||
}
|
||||
}
|
||||
|
||||
// check for path alias first
|
||||
if (pathInfo != null) {
|
||||
// clean up the pathinfo for parsing
|
||||
pathInfo = pathInfo.trim();
|
||||
if (pathInfo.startsWith("/")) {
|
||||
pathInfo = pathInfo.substring(1);
|
||||
}
|
||||
if (pathInfo.endsWith("/")) {
|
||||
pathInfo = pathInfo.substring(0, pathInfo.length() - 1);
|
||||
}
|
||||
|
||||
GenericValue pathAlias = null;
|
||||
try {
|
||||
pathAlias = EntityQuery.use(delegator).from("WebSitePathAlias").where("webSiteId", webSiteId, "pathAlias", pathInfo).orderBy("-fromDate").cache().filterByDate().queryFirst();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
if (pathAlias != null) {
|
||||
String alias = pathAlias.getString("aliasTo");
|
||||
contentId = pathAlias.getString("contentId");
|
||||
mapKey = pathAlias.getString("mapKey");
|
||||
if (contentId == null && UtilValidate.isNotEmpty(alias)) {
|
||||
if (!alias.startsWith("/")) {
|
||||
alias = "/" + alias;
|
||||
}
|
||||
|
||||
String context = request.getContextPath();
|
||||
String location = context + request.getServletPath();
|
||||
GenericValue webSite = WebSiteWorker.getWebSite(request);
|
||||
if (webSite != null && webSite.getString("hostedPathAlias") != null && !"ROOT".equals(pathInfo))
|
||||
location += "/" + webSite.getString("hostedPathAlias");
|
||||
|
||||
String uriWithContext = request.getRequestURI();
|
||||
String uri = uriWithContext.substring(context.length());
|
||||
uri = uri.substring(0, uri.lastIndexOf('/'));
|
||||
|
||||
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
|
||||
response.setHeader("Location", location + uri + alias);
|
||||
response.setHeader("Connection", "close");
|
||||
|
||||
return null; // null to not process any views
|
||||
}
|
||||
}
|
||||
|
||||
// get the contentId/mapKey from URL
|
||||
if (contentId == null) {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Current PathInfo: " + pathInfo, MODULE);
|
||||
}
|
||||
String[] pathSplit = pathInfo.split("/");
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Split pathinfo: " + pathSplit.length, MODULE);
|
||||
}
|
||||
contentId = pathSplit[0];
|
||||
if (pathSplit.length > 1) {
|
||||
mapKey = pathSplit[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// verify the request content is associated with the current website
|
||||
int statusCode = -1;
|
||||
boolean hasErrorPage = false;
|
||||
|
||||
if (contentId != null) {
|
||||
try {
|
||||
statusCode = verifyContentToWebSite(delegator, webSiteId, contentId);
|
||||
} catch (GeneralException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
throw new GeneralRuntimeException(e.getMessage(), e);
|
||||
}
|
||||
// If an override view is present then use that in place of request.getPathInfo()
|
||||
String overrideViewUri = (String) request.getAttribute("_CURRENT_CHAIN_VIEW_");
|
||||
if (UtilValidate.isNotEmpty(overrideViewUri)) {
|
||||
pathInfo = overrideViewUri;
|
||||
} else {
|
||||
statusCode = HttpServletResponse.SC_NOT_FOUND;
|
||||
pathInfo = request.getPathInfo();
|
||||
if (targetRequest.equals(actualRequest) && pathInfo != null) {
|
||||
// was called directly -- path info is everything after the request
|
||||
String[] pathParsed = pathInfo.split("/", 3);
|
||||
if (pathParsed.length > 2) {
|
||||
pathInfo = pathParsed[2];
|
||||
} else {
|
||||
pathInfo = null;
|
||||
}
|
||||
} // if called through the default request, there is no request in pathinfo
|
||||
}
|
||||
|
||||
// We try to find a specific Error page for this website concerning the status code
|
||||
if (statusCode != HttpServletResponse.SC_OK) {
|
||||
GenericValue errorContainer = null;
|
||||
// if path info is null or path info is / (i.e application mounted on root); check for a default content
|
||||
if (pathInfo == null || "/".equals(pathInfo)) {
|
||||
GenericValue defaultContent = null;
|
||||
try {
|
||||
errorContainer = EntityQuery.use(delegator).from("WebSiteContent")
|
||||
.where("webSiteId", webSiteId, "webSiteContentTypeId", "ERROR_ROOT")
|
||||
.orderBy("fromDate").filterByDate().cache().queryFirst();
|
||||
defaultContent = EntityQuery.use(delegator).from("WebSiteContent")
|
||||
.where("webSiteId", webSiteId, "webSiteContentTypeId", "DEFAULT_PAGE")
|
||||
.orderBy("-fromDate").filterByDate().cache().queryFirst();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
if (defaultContent != null) {
|
||||
pathInfo = defaultContent.getString("contentId");
|
||||
}
|
||||
}
|
||||
|
||||
if (errorContainer != null) {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Found error containers: " + errorContainer, MODULE);
|
||||
// check for path alias first
|
||||
if (pathInfo != null) {
|
||||
// clean up the pathinfo for parsing
|
||||
pathInfo = pathInfo.trim();
|
||||
if (pathInfo.startsWith("/")) {
|
||||
pathInfo = pathInfo.substring(1);
|
||||
}
|
||||
if (pathInfo.endsWith("/")) {
|
||||
pathInfo = pathInfo.substring(0, pathInfo.length() - 1);
|
||||
}
|
||||
|
||||
GenericValue pathAlias = null;
|
||||
try {
|
||||
pathAlias = EntityQuery.use(delegator).from("WebSitePathAlias").where("webSiteId", webSiteId, "pathAlias", pathInfo).orderBy("-fromDate").cache().filterByDate().queryFirst();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
if (pathAlias != null) {
|
||||
String alias = pathAlias.getString("aliasTo");
|
||||
contentId = pathAlias.getString("contentId");
|
||||
mapKey = pathAlias.getString("mapKey");
|
||||
if (contentId == null && UtilValidate.isNotEmpty(alias)) {
|
||||
if (!alias.startsWith("/")) {
|
||||
alias = "/" + alias;
|
||||
}
|
||||
|
||||
String context = request.getContextPath();
|
||||
String location = context + request.getServletPath();
|
||||
GenericValue webSite = WebSiteWorker.getWebSite(request);
|
||||
if (webSite != null && webSite.getString("hostedPathAlias") != null && !"ROOT".equals(pathInfo))
|
||||
location += "/" + webSite.getString("hostedPathAlias");
|
||||
|
||||
String uriWithContext = request.getRequestURI();
|
||||
String uri = uriWithContext.substring(context.length());
|
||||
uri = uri.substring(0, uri.lastIndexOf('/'));
|
||||
|
||||
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
|
||||
response.setHeader("Location", location + uri + alias);
|
||||
response.setHeader("Connection", "close");
|
||||
|
||||
return null; // null to not process any views
|
||||
}
|
||||
}
|
||||
|
||||
GenericValue errorPage = null;
|
||||
// get the contentId/mapKey from URL
|
||||
if (contentId == null) {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Current PathInfo: " + pathInfo, MODULE);
|
||||
}
|
||||
String[] pathSplit = pathInfo.split("/");
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Split pathinfo: " + pathSplit.length, MODULE);
|
||||
}
|
||||
contentId = pathSplit[0];
|
||||
if (pathSplit.length > 1) {
|
||||
mapKey = pathSplit[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// verify the request content is associated with the current website
|
||||
int statusCode = -1;
|
||||
boolean hasErrorPage = false;
|
||||
|
||||
if (contentId != null) {
|
||||
try {
|
||||
errorPage = EntityQuery.use(delegator).from("ContentAssocViewTo")
|
||||
.where("contentIdStart", errorContainer.getString("contentId"),
|
||||
"caContentAssocTypeId", "TREE_CHILD",
|
||||
"contentTypeId", "DOCUMENT",
|
||||
"caMapKey", String.valueOf(statusCode))
|
||||
.filterByDate().queryFirst();
|
||||
statusCode = verifyContentToWebSite(delegator, webSiteId, contentId);
|
||||
} catch (GeneralException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
throw new GeneralRuntimeException(e.getMessage(), e);
|
||||
}
|
||||
} else {
|
||||
statusCode = HttpServletResponse.SC_NOT_FOUND;
|
||||
}
|
||||
|
||||
// We try to find a specific Error page for this website concerning the status code
|
||||
if (statusCode != HttpServletResponse.SC_OK) {
|
||||
GenericValue errorContainer = null;
|
||||
try {
|
||||
errorContainer = EntityQuery.use(delegator).from("WebSiteContent")
|
||||
.where("webSiteId", webSiteId, "webSiteContentTypeId", "ERROR_ROOT")
|
||||
.orderBy("fromDate").filterByDate().cache().queryFirst();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
if (errorPage != null) {
|
||||
|
||||
if (errorContainer != null) {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Found error pages " + statusCode + " : " + errorPage, MODULE);
|
||||
Debug.logVerbose("Found error containers: " + errorContainer, MODULE);
|
||||
}
|
||||
contentId = errorPage.getString("contentId");
|
||||
} else {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("No specific error page, falling back to the Error Container for " + statusCode, MODULE);
|
||||
|
||||
GenericValue errorPage = null;
|
||||
try {
|
||||
errorPage = EntityQuery.use(delegator).from("ContentAssocViewTo")
|
||||
.where("contentIdStart", errorContainer.getString("contentId"),
|
||||
"caContentAssocTypeId", "TREE_CHILD",
|
||||
"contentTypeId", "DOCUMENT",
|
||||
"caMapKey", String.valueOf(statusCode))
|
||||
.filterByDate().queryFirst();
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
contentId = errorContainer.getString("contentId");
|
||||
}
|
||||
mapKey = null;
|
||||
hasErrorPage = true;
|
||||
}
|
||||
// We try to find a generic content Error page concerning the status code
|
||||
if (!hasErrorPage) {
|
||||
try {
|
||||
GenericValue errorPage = EntityQuery.use(delegator).from("Content").where("contentId", "CONTENT_ERROR_" + statusCode).cache().queryOne();
|
||||
if (errorPage != null) {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Found generic page " + statusCode, MODULE);
|
||||
Debug.logVerbose("Found error pages " + statusCode + " : " + errorPage, MODULE);
|
||||
}
|
||||
contentId = errorPage.getString("contentId");
|
||||
mapKey = null;
|
||||
hasErrorPage = true;
|
||||
} else {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("No specific error page, falling back to the Error Container for " + statusCode, MODULE);
|
||||
}
|
||||
contentId = errorContainer.getString("contentId");
|
||||
}
|
||||
mapKey = null;
|
||||
hasErrorPage = true;
|
||||
}
|
||||
// We try to find a generic content Error page concerning the status code
|
||||
if (!hasErrorPage) {
|
||||
try {
|
||||
GenericValue errorPage = EntityQuery.use(delegator).from("Content").where("contentId", "CONTENT_ERROR_" + statusCode).cache().queryOne();
|
||||
if (errorPage != null) {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Found generic page " + statusCode, MODULE);
|
||||
}
|
||||
contentId = errorPage.getString("contentId");
|
||||
mapKey = null;
|
||||
hasErrorPage = true;
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (statusCode == HttpServletResponse.SC_OK || hasErrorPage) {
|
||||
// create the template map
|
||||
MapStack<String> templateMap = MapStack.create();
|
||||
ScreenRenderer.populateContextForRequest(templateMap, null, request, response, servletContext);
|
||||
templateMap.put("statusCode", statusCode);
|
||||
|
||||
// make the link prefix
|
||||
templateMap.put("_REQUEST_HANDLER_", RequestHandler.from(request));
|
||||
|
||||
//Cache Headers
|
||||
UtilHttp.setResponseBrowserProxyNoCache(response);
|
||||
//Security Headers
|
||||
UtilHttp.setResponseBrowserDefaultSecurityHeaders(response, null);
|
||||
|
||||
response.setStatus(statusCode);
|
||||
|
||||
try {
|
||||
writer = response.getWriter();
|
||||
// TODO: replace "screen" to support dynamic rendering of different output
|
||||
if (visualTheme == null) {
|
||||
String defaultVisualThemeId = EntityUtilProperties.getPropertyValue("general", "VISUAL_THEME", delegator);
|
||||
visualTheme = ThemeFactory.getVisualThemeFromId(defaultVisualThemeId);
|
||||
}
|
||||
FormStringRenderer formStringRenderer = new MacroFormRenderer(visualTheme.getModelTheme().getFormRendererLocation("screen"), request, response);
|
||||
templateMap.put("formStringRenderer", formStringRenderer);
|
||||
|
||||
// if use web analytics
|
||||
List<GenericValue> webAnalytics = EntityQuery.use(delegator).from("WebAnalyticsConfig").where("webSiteId", webSiteId).queryList();
|
||||
// render
|
||||
if (UtilValidate.isNotEmpty(webAnalytics) && hasErrorPage) {
|
||||
ContentWorker.renderContentAsText(dispatcher, contentId, writer, templateMap, locale, "text/html", null, null, true, webAnalytics);
|
||||
} else if (UtilValidate.isEmpty(mapKey)) {
|
||||
ContentWorker.renderContentAsText(dispatcher, contentId, writer, templateMap, locale, "text/html", null, null, true);
|
||||
} else {
|
||||
ContentWorker.renderSubContentAsText(dispatcher, contentId, writer, mapKey, templateMap, locale, "text/html", true);
|
||||
}
|
||||
|
||||
} catch (TemplateException e) {
|
||||
throw new GeneralRuntimeException(String.format("Error creating form renderer while rendering content [%s] with path alias [%s]", contentId, pathInfo), e);
|
||||
} catch (IOException e) {
|
||||
throw new GeneralRuntimeException(String.format("Error in the response writer/output stream while rendering content [%s] with path alias [%s]", contentId, pathInfo), e);
|
||||
} catch (GeneralException e) {
|
||||
throw new GeneralRuntimeException(String.format("Error rendering content [%s] with path alias [%s]", contentId, pathInfo), e);
|
||||
}
|
||||
|
||||
return "success";
|
||||
} else {
|
||||
String contentName = null;
|
||||
String siteName = null;
|
||||
try {
|
||||
GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
|
||||
if (content != null && UtilValidate.isNotEmpty(content.getString("contentName"))) {
|
||||
contentName = content.getString("contentName");
|
||||
} else {
|
||||
request.setAttribute("_ERROR_MESSAGE_", "Content: [" + contentId + "] is not a publish point for the current website: [" + webSiteId + "]");
|
||||
return "error";
|
||||
}
|
||||
siteName = EntityQuery.use(delegator).from("WebSite").where("webSiteId", webSiteId).cache().queryOne().getString("siteName");
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
request.setAttribute("_ERROR_MESSAGE_", "Content: " + contentName + " [" + contentId + "] is not a publish point for the current website: " + siteName + " [" + webSiteId + "]");
|
||||
return "error";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (statusCode == HttpServletResponse.SC_OK || hasErrorPage) {
|
||||
// create the template map
|
||||
MapStack<String> templateMap = MapStack.create();
|
||||
ScreenRenderer.populateContextForRequest(templateMap, null, request, response, servletContext);
|
||||
templateMap.put("statusCode", statusCode);
|
||||
|
||||
// make the link prefix
|
||||
templateMap.put("_REQUEST_HANDLER_", RequestHandler.from(request));
|
||||
|
||||
//Cache Headers
|
||||
UtilHttp.setResponseBrowserProxyNoCache(response);
|
||||
//Security Headers
|
||||
UtilHttp.setResponseBrowserDefaultSecurityHeaders(response, null);
|
||||
|
||||
response.setStatus(statusCode);
|
||||
|
||||
try {
|
||||
writer = response.getWriter();
|
||||
// TODO: replace "screen" to support dynamic rendering of different output
|
||||
if (visualTheme == null) {
|
||||
String defaultVisualThemeId = EntityUtilProperties.getPropertyValue("general", "VISUAL_THEME", delegator);
|
||||
visualTheme = ThemeFactory.getVisualThemeFromId(defaultVisualThemeId);
|
||||
}
|
||||
FormStringRenderer formStringRenderer = new MacroFormRenderer(visualTheme.getModelTheme().getFormRendererLocation("screen"), request, response);
|
||||
templateMap.put("formStringRenderer", formStringRenderer);
|
||||
|
||||
// if use web analytics
|
||||
List<GenericValue> webAnalytics = EntityQuery.use(delegator).from("WebAnalyticsConfig").where("webSiteId", webSiteId).queryList();
|
||||
// render
|
||||
if (UtilValidate.isNotEmpty(webAnalytics) && hasErrorPage) {
|
||||
ContentWorker.renderContentAsText(dispatcher, contentId, writer, templateMap, locale, "text/html", null, null, true, webAnalytics);
|
||||
} else if (UtilValidate.isEmpty(mapKey)) {
|
||||
ContentWorker.renderContentAsText(dispatcher, contentId, writer, templateMap, locale, "text/html", null, null, true);
|
||||
} else {
|
||||
ContentWorker.renderSubContentAsText(dispatcher, contentId, writer, mapKey, templateMap, locale, "text/html", true);
|
||||
}
|
||||
|
||||
} catch (TemplateException e) {
|
||||
throw new GeneralRuntimeException(String.format("Error creating form renderer while rendering content [%s] with path alias [%s]", contentId, pathInfo), e);
|
||||
} catch (IOException e) {
|
||||
throw new GeneralRuntimeException(String.format("Error in the response writer/output stream while rendering content [%s] with path alias [%s]", contentId, pathInfo), e);
|
||||
} catch (GeneralException e) {
|
||||
throw new GeneralRuntimeException(String.format("Error rendering content [%s] with path alias [%s]", contentId, pathInfo), e);
|
||||
}
|
||||
|
||||
return "success";
|
||||
} else {
|
||||
String contentName = null;
|
||||
String siteName = null;
|
||||
try {
|
||||
GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
|
||||
if (content != null && UtilValidate.isNotEmpty(content.getString("contentName"))) {
|
||||
contentName = content.getString("contentName");
|
||||
} else {
|
||||
request.setAttribute("_ERROR_MESSAGE_", "Content: [" + contentId + "] is not a publish point for the current website: [" + webSiteId + "]");
|
||||
return "error";
|
||||
}
|
||||
siteName = EntityQuery.use(delegator).from("WebSite").where("webSiteId", webSiteId).cache().queryOne().getString("siteName");
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
request.setAttribute("_ERROR_MESSAGE_", "Content: " + contentName + " [" + contentId + "] is not a publish point for the current website: " + siteName + " [" + webSiteId + "]");
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
}
|
||||
String siteName = null;
|
||||
GenericValue webSite = null;
|
||||
|
||||
+11
-11
@@ -56,8 +56,8 @@ public class ContentJsonEvents {
|
||||
String contentId = request.getParameter("contentId");
|
||||
|
||||
EntityCondition condition = EntityCondition.makeCondition(
|
||||
EntityCondition.makeCondition(UtilMisc.toMap("contentId", contentId)),
|
||||
EntityUtil.getFilterByDateExpr());
|
||||
EntityCondition.makeCondition(UtilMisc.toMap("contentId", contentId)),
|
||||
EntityUtil.getFilterByDateExpr());
|
||||
List<GenericValue> assocs = delegator.findList("ContentAssoc", condition, null, null, null, false);
|
||||
|
||||
List<Map<String, Object>> nodes = new LinkedList<>();
|
||||
@@ -133,8 +133,8 @@ public class ContentJsonEvents {
|
||||
public static void deleteContent(Delegator delegator, String contentId) throws GenericEntityException {
|
||||
Timestamp now = UtilDateTime.nowTimestamp();
|
||||
EntityCondition condition = EntityCondition.makeCondition(
|
||||
EntityCondition.makeCondition(UtilMisc.toMap("contentIdTo", contentId)),
|
||||
EntityUtil.getFilterByDateExpr());
|
||||
EntityCondition.makeCondition(UtilMisc.toMap("contentIdTo", contentId)),
|
||||
EntityUtil.getFilterByDateExpr());
|
||||
List<GenericValue> assocs = delegator.findList("ContentAssoc", condition, null, null, null, true);
|
||||
for (GenericValue assoc : assocs) {
|
||||
assoc.set("thruDate", now);
|
||||
@@ -146,8 +146,8 @@ public class ContentJsonEvents {
|
||||
private static void deleteWebPathAliases(Delegator delegator, String contentId) throws GenericEntityException {
|
||||
Timestamp now = UtilDateTime.nowTimestamp();
|
||||
EntityCondition condition = EntityCondition.makeCondition(
|
||||
EntityCondition.makeCondition(UtilMisc.toMap("contentId", contentId)),
|
||||
EntityUtil.getFilterByDateExpr());
|
||||
EntityCondition.makeCondition(UtilMisc.toMap("contentId", contentId)),
|
||||
EntityUtil.getFilterByDateExpr());
|
||||
List<GenericValue> pathAliases = delegator.findList("WebSitePathAlias", condition, null, null, null, true);
|
||||
for (GenericValue alias : pathAliases) {
|
||||
alias.set("thruDate", now);
|
||||
@@ -172,14 +172,14 @@ public class ContentJsonEvents {
|
||||
Map<String, Object> data = UtilMisc.toMap("title", (Object) contentName);
|
||||
|
||||
Map<String, Object> attr = UtilMisc.toMap(
|
||||
"id", assoc.get("contentIdTo"),
|
||||
"contentId", assoc.get("contentId"),
|
||||
"fromDate", assoc.getTimestamp("fromDate").toString(),
|
||||
"contentAssocTypeId", assoc.get("contentAssocTypeId"));
|
||||
"id", assoc.get("contentIdTo"),
|
||||
"contentId", assoc.get("contentId"),
|
||||
"fromDate", assoc.getTimestamp("fromDate").toString(),
|
||||
"contentAssocTypeId", assoc.get("contentAssocTypeId"));
|
||||
|
||||
Map<String, Object> node = UtilMisc.toMap("data", (Object) data, "attr", (Object) attr);
|
||||
|
||||
List<GenericValue> assocChildren = content != null ? content.getRelated("FromContentAssoc", null, null, true) : null;
|
||||
List<GenericValue> assocChildren = content != null ? content.getRelated("FromContentAssoc", null, null, true) : null;
|
||||
assocChildren = EntityUtil.filterByDate(assocChildren);
|
||||
if (!CollectionUtils.isEmpty(assocChildren)) {
|
||||
node.put("state", "closed");
|
||||
|
||||
+2
-2
@@ -102,7 +102,7 @@ public class CompDocEvents {
|
||||
Map<String, Object> persistResult = dispatcher.runSync("persistContentAndAssoc", persistMap);
|
||||
if (ServiceUtil.isError(persistResult)) {
|
||||
String errMsg = "Error running serviceName, 'persistContentAndAssoc'. " + ServiceUtil.getErrorMessage(persistResult);
|
||||
request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + "</li>");
|
||||
request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + "</li>");
|
||||
Debug.logError(errMsg, MODULE);
|
||||
return "error";
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class CompDocEvents {
|
||||
Map<String, Object> result = dispatcher.runSync("persistContentRevisionAndItem", contentRevisionMap);
|
||||
if (ServiceUtil.isError(result)) {
|
||||
String errMsg = "Error running serviceName, 'persistContentRevisionAndItem'. " + ServiceUtil.getErrorMessage(result);
|
||||
request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + "</li>");
|
||||
request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + "</li>");
|
||||
Debug.logError(errMsg, MODULE);
|
||||
return "error";
|
||||
}
|
||||
|
||||
+31
-28
@@ -105,13 +105,13 @@ public class ContentPermissionServices {
|
||||
Boolean bDisplayFailCond = (Boolean) context.get("displayFailCond");
|
||||
boolean displayFailCond = false;
|
||||
if (bDisplayFailCond != null && bDisplayFailCond) {
|
||||
displayFailCond = true;
|
||||
displayFailCond = true;
|
||||
}
|
||||
Debug.logInfo("displayFailCond(0):" + displayFailCond, "");
|
||||
Debug.logInfo("displayFailCond(0):" + displayFailCond, "");
|
||||
Boolean bDisplayPassCond = (Boolean) context.get("displayPassCond");
|
||||
boolean displayPassCond = false;
|
||||
if (bDisplayPassCond != null && bDisplayPassCond) {
|
||||
displayPassCond = true;
|
||||
displayPassCond = true;
|
||||
}
|
||||
Debug.logInfo("displayPassCond(0):" + displayPassCond, "");
|
||||
Map<String, Object> results = new HashMap<>();
|
||||
@@ -150,7 +150,7 @@ public class ContentPermissionServices {
|
||||
passedPurposes.addAll(purposesFromString);
|
||||
}
|
||||
|
||||
EntityPermissionChecker.StdAuxiliaryValueGetter auxGetter = new EntityPermissionChecker.StdAuxiliaryValueGetter("ContentPurpose", "contentPurposeTypeId", "contentId");
|
||||
EntityPermissionChecker.StdAuxiliaryValueGetter auxGetter = new EntityPermissionChecker.StdAuxiliaryValueGetter("ContentPurpose", "contentPurposeTypeId", "contentId");
|
||||
// Sometimes permissions need to be checked before an entity is created, so
|
||||
// there needs to be a method for setting a purpose list
|
||||
auxGetter.setList(passedPurposes);
|
||||
@@ -163,10 +163,10 @@ public class ContentPermissionServices {
|
||||
}
|
||||
targetOperations.addAll(operationsFromString);
|
||||
}
|
||||
EntityPermissionChecker.StdPermissionConditionGetter permCondGetter = new EntityPermissionChecker.StdPermissionConditionGetter("ContentPurposeOperation", "contentOperationId", "roleTypeId", "statusId", "contentPurposeTypeId", "privilegeEnumId");
|
||||
EntityPermissionChecker.StdPermissionConditionGetter permCondGetter = new EntityPermissionChecker.StdPermissionConditionGetter("ContentPurposeOperation", "contentOperationId", "roleTypeId", "statusId", "contentPurposeTypeId", "privilegeEnumId");
|
||||
permCondGetter.setOperationList(targetOperations);
|
||||
|
||||
EntityPermissionChecker.StdRelatedRoleGetter roleGetter = new EntityPermissionChecker.StdRelatedRoleGetter("Content", "roleTypeId", "contentId", "partyId", "ownerContentId", "ContentRole");
|
||||
EntityPermissionChecker.StdRelatedRoleGetter roleGetter = new EntityPermissionChecker.StdRelatedRoleGetter("Content", "roleTypeId", "contentId", "partyId", "ownerContentId", "ContentRole");
|
||||
List<String> passedRoles = UtilGenerics.cast(context.get("roleTypeList"));
|
||||
if (passedRoles == null) passedRoles = new LinkedList<>();
|
||||
String roleTypeString = (String) context.get("roleTypeString");
|
||||
@@ -189,23 +189,26 @@ public class ContentPermissionServices {
|
||||
results.put("permissionStatus", "granted");
|
||||
permissionStatus = "granted";
|
||||
if (displayPassCond) {
|
||||
errBuf.append("\n hasEntityPermission(" + entityAction + "): PASSED");
|
||||
errBuf.append("\n hasEntityPermission(" + entityAction + "): PASSED");
|
||||
}
|
||||
|
||||
} else {
|
||||
if (displayFailCond) {
|
||||
errBuf.append("\n hasEntityPermission(" + entityAction + "): FAILED");
|
||||
errBuf.append("\n hasEntityPermission(" + entityAction + "): FAILED");
|
||||
}
|
||||
|
||||
if (content != null)
|
||||
if (content != null) {
|
||||
entityIds.add(content);
|
||||
}
|
||||
String quickCheckContentId = (String) context.get("quickCheckContentId");
|
||||
if (UtilValidate.isNotEmpty(quickCheckContentId)) {
|
||||
List<String> quickList = StringUtil.split(quickCheckContentId, "|");
|
||||
if (UtilValidate.isNotEmpty(quickList)) entityIds.addAll(quickList);
|
||||
List<String> quickList = StringUtil.split(quickCheckContentId, "|");
|
||||
if (UtilValidate.isNotEmpty(quickList)) {
|
||||
entityIds.addAll(quickList);
|
||||
}
|
||||
}
|
||||
try {
|
||||
boolean check = EntityPermissionChecker.checkPermissionMethod(delegator, partyId, "Content", entityIds, auxGetter, roleGetter, permCondGetter);
|
||||
boolean check = EntityPermissionChecker.checkPermissionMethod(delegator, partyId, "Content", entityIds, auxGetter, roleGetter, permCondGetter);
|
||||
if (check) {
|
||||
results.put("permissionStatus", "granted");
|
||||
} else {
|
||||
@@ -220,27 +223,27 @@ public class ContentPermissionServices {
|
||||
}
|
||||
|
||||
if (("granted".equals(permissionStatus) && displayPassCond)
|
||||
|| ("rejected".equals(permissionStatus) && displayFailCond)) {
|
||||
|| ("rejected".equals(permissionStatus) && displayFailCond)) {
|
||||
// Don't show this if passed on 'hasEntityPermission'
|
||||
if (displayFailCond || displayPassCond) {
|
||||
if (!passed) {
|
||||
errBuf.append("\n targetOperations:");
|
||||
errBuf.append(targetOperations);
|
||||
if (!passed) {
|
||||
errBuf.append("\n targetOperations:");
|
||||
errBuf.append(targetOperations);
|
||||
|
||||
String errMsg = permCondGetter.dumpAsText();
|
||||
errBuf.append("\n");
|
||||
errBuf.append(errMsg);
|
||||
errBuf.append("\n partyId:");
|
||||
errBuf.append(partyId);
|
||||
errBuf.append("\n entityIds:");
|
||||
errBuf.append(entityIds);
|
||||
String errMsg = permCondGetter.dumpAsText();
|
||||
errBuf.append("\n");
|
||||
errBuf.append(errMsg);
|
||||
errBuf.append("\n partyId:");
|
||||
errBuf.append(partyId);
|
||||
errBuf.append("\n entityIds:");
|
||||
errBuf.append(entityIds);
|
||||
|
||||
errBuf.append("\n auxList:");
|
||||
errBuf.append(auxGetter.getList());
|
||||
errBuf.append("\n auxList:");
|
||||
errBuf.append(auxGetter.getList());
|
||||
|
||||
errBuf.append("\n roleList:");
|
||||
errBuf.append(roleGetter.getList());
|
||||
}
|
||||
errBuf.append("\n roleList:");
|
||||
errBuf.append(roleGetter.getList());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+25
-21
@@ -243,30 +243,34 @@ public class ContentServicesComplex {
|
||||
List<GenericValue> contentAssocDataResourceList = new LinkedList<>();
|
||||
Locale locale = Locale.getDefault(); // TODO: this needs to be passed in
|
||||
try {
|
||||
for (GenericValue contentAssocView : contentAssocsTypeFiltered) {
|
||||
GenericValue contentAssoc = EntityQuery.use(delegator).from("ContentAssoc").where(UtilMisc.toMap("contentId", contentAssocView.getString("contentId"),
|
||||
"contentIdTo", contentAssocView.getString(contentFieldName), "contentAssocTypeId", contentAssocView.getString("caContentAssocTypeId"),
|
||||
"fromDate", contentAssocView.getTimestamp("caFromDate"))).queryOne();
|
||||
content = contentAssoc.getRelatedOne(assocRelationName, true);
|
||||
if (UtilValidate.isNotEmpty(contentTypes)) {
|
||||
String contentTypeId = (String) content.get("contentTypeId");
|
||||
if (contentTypes.contains(contentTypeId)) {
|
||||
for (GenericValue contentAssocView : contentAssocsTypeFiltered) {
|
||||
GenericValue contentAssoc = EntityQuery.use(delegator).from("ContentAssoc").where(UtilMisc.toMap("contentId",
|
||||
contentAssocView.getString("contentId"),
|
||||
"contentIdTo", contentAssocView.getString(contentFieldName), "contentAssocTypeId", contentAssocView.getString(
|
||||
"caContentAssocTypeId"),
|
||||
"fromDate", contentAssocView.getTimestamp("caFromDate"))).queryOne();
|
||||
content = contentAssoc.getRelatedOne(assocRelationName, true);
|
||||
if (UtilValidate.isNotEmpty(contentTypes)) {
|
||||
String contentTypeId = (String) content.get("contentTypeId");
|
||||
if (contentTypes.contains(contentTypeId)) {
|
||||
contentAssocDataResourceView = delegator.makeValue(viewName);
|
||||
contentAssocDataResourceView.setAllFields(content, true, null, null);
|
||||
}
|
||||
} else {
|
||||
contentAssocDataResourceView = delegator.makeValue(viewName);
|
||||
contentAssocDataResourceView.setAllFields(content, true, null, null);
|
||||
}
|
||||
} else {
|
||||
contentAssocDataResourceView = delegator.makeValue(viewName);
|
||||
contentAssocDataResourceView.setAllFields(content, true, null, null);
|
||||
SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocOut",
|
||||
contentAssoc, contentAssocDataResourceView, new LinkedList<>(), locale);
|
||||
String dataResourceId = content.getString("dataResourceId");
|
||||
if (UtilValidate.isNotEmpty(dataResourceId))
|
||||
dataResource = content.getRelatedOne("DataResource", true);
|
||||
if (dataResource != null) {
|
||||
SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "dataResourceOut",
|
||||
dataResource, contentAssocDataResourceView, new LinkedList<>(), locale);
|
||||
}
|
||||
contentAssocDataResourceList.add(contentAssocDataResourceView);
|
||||
}
|
||||
SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocOut", contentAssoc, contentAssocDataResourceView, new LinkedList<>(), locale);
|
||||
String dataResourceId = content.getString("dataResourceId");
|
||||
if (UtilValidate.isNotEmpty(dataResourceId))
|
||||
dataResource = content.getRelatedOne("DataResource", true);
|
||||
if (dataResource != null) {
|
||||
SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "dataResourceOut", dataResource, contentAssocDataResourceView, new LinkedList<>(), locale);
|
||||
}
|
||||
contentAssocDataResourceList.add(contentAssocDataResourceView);
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
return ServiceUtil.returnError(e.getMessage());
|
||||
@@ -274,7 +278,7 @@ public class ContentServicesComplex {
|
||||
|
||||
if (UtilValidate.isNotEmpty(orderBy)) {
|
||||
List<String> orderByList = StringUtil.split(orderBy, "|");
|
||||
contentAssocDataResourceList = EntityUtil.orderBy(contentAssocDataResourceList, orderByList);
|
||||
contentAssocDataResourceList = EntityUtil.orderBy(contentAssocDataResourceList, orderByList);
|
||||
}
|
||||
Map<String, Object> results = new HashMap<>();
|
||||
results.put("entityList", contentAssocDataResourceList);
|
||||
|
||||
+21
-20
@@ -719,13 +719,13 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
|
||||
boolean isPick = booleanDataType(thisNode.get("isPick"));
|
||||
kids.add(thisNode);
|
||||
if (isPick) {
|
||||
Integer count = (Integer) currentNode.get("count");
|
||||
if (count == null) {
|
||||
count = 1;
|
||||
} else {
|
||||
count = count + 1;
|
||||
}
|
||||
currentNode.put("count", count);
|
||||
Integer count = (Integer) currentNode.get("count");
|
||||
if (count == null) {
|
||||
count = 1;
|
||||
} else {
|
||||
count = count + 1;
|
||||
}
|
||||
currentNode.put("count", count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -971,22 +971,23 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Map<String, Object>> getContentAncestryNodeTrail(Delegator delegator, String contentId, String contentAssocTypeId, String direction) throws GenericEntityException {
|
||||
List<GenericValue> contentAncestorList = new LinkedList<>();
|
||||
List<Map<String, Object>> nodeTrail = new LinkedList<>();
|
||||
getContentAncestry(delegator, contentId, contentAssocTypeId, direction, contentAncestorList);
|
||||
for (GenericValue value : contentAncestorList) {
|
||||
Map<String, Object> thisNode = ContentWorker.makeNode(value);
|
||||
nodeTrail.add(thisNode);
|
||||
}
|
||||
return nodeTrail;
|
||||
public static List<Map<String, Object>> getContentAncestryNodeTrail(Delegator delegator, String contentId, String contentAssocTypeId,
|
||||
String direction) throws GenericEntityException {
|
||||
List<GenericValue> contentAncestorList = new LinkedList<>();
|
||||
List<Map<String, Object>> nodeTrail = new LinkedList<>();
|
||||
getContentAncestry(delegator, contentId, contentAssocTypeId, direction, contentAncestorList);
|
||||
for (GenericValue value : contentAncestorList) {
|
||||
Map<String, Object> thisNode = ContentWorker.makeNode(value);
|
||||
nodeTrail.add(thisNode);
|
||||
}
|
||||
return nodeTrail;
|
||||
}
|
||||
|
||||
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;
|
||||
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 {
|
||||
|
||||
+1
-1
@@ -26,6 +26,6 @@ import org.apache.ofbiz.base.util.StringUtil;
|
||||
|
||||
public interface ContentWrapper {
|
||||
|
||||
public StringUtil.StringWrapper get(String contentTypeId, String encoderType);
|
||||
StringUtil.StringWrapper get(String contentTypeId, String encoderType);
|
||||
|
||||
}
|
||||
|
||||
@@ -359,10 +359,10 @@ public class DataEvents {
|
||||
request.setAttribute("dataResourceId", result.get("dataResourceId"));
|
||||
String dataResourceTypeId = (String) serviceInMap.get("dataResourceTypeId");
|
||||
if (dataResourceTypeId != null) {
|
||||
if ("ELECTRONIC_TEXT".equals(dataResourceTypeId)
|
||||
|| "IMAGE_OBJECT".equals(dataResourceTypeId)) {
|
||||
if ("ELECTRONIC_TEXT".equals(dataResourceTypeId)
|
||||
|| "IMAGE_OBJECT".equals(dataResourceTypeId)) {
|
||||
returnStr = dataResourceTypeId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+19
-18
@@ -153,9 +153,9 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
|
||||
// The other test is to only get all the children if the "leaf" node where all the
|
||||
// children of the leaf are wanted for expansion.
|
||||
if (parentCategoryId == null
|
||||
|| "ROOT".equals(parentCategoryId)
|
||||
|| (currentDataCategoryId != null && currentDataCategoryId.equals(parentCategoryId))
|
||||
|| getAll) {
|
||||
|| "ROOT".equals(parentCategoryId)
|
||||
|| (currentDataCategoryId != null && currentDataCategoryId.equals(parentCategoryId))
|
||||
|| getAll) {
|
||||
categoryNode.put("kids", subCategoryIds);
|
||||
}
|
||||
return errorMsg;
|
||||
@@ -482,8 +482,8 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
|
||||
mimeType = view.getString("drMimeTypeId");
|
||||
}
|
||||
if (UtilValidate.isEmpty(mimeType) && UtilValidate.isNotEmpty(dataResourceId)) {
|
||||
GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne();
|
||||
mimeType = dataResource.getString("mimeTypeId");
|
||||
GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne();
|
||||
mimeType = dataResource.getString("mimeTypeId");
|
||||
|
||||
}
|
||||
return mimeType;
|
||||
@@ -623,19 +623,20 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
|
||||
}
|
||||
}
|
||||
|
||||
public static String renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, String dataResourceId, Map<String, Object> templateContext,
|
||||
Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException {
|
||||
public static String renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, String dataResourceId,
|
||||
Map<String, Object> templateContext,
|
||||
Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException {
|
||||
try (Writer writer = new StringWriter()) {
|
||||
renderDataResourceAsText(dispatcher, delegator, dataResourceId, writer, templateContext, locale, targetMimeTypeId, cache, null);
|
||||
return writer.toString();
|
||||
renderDataResourceAsText(dispatcher, delegator, dataResourceId, writer, templateContext, locale, targetMimeTypeId, cache, null);
|
||||
return writer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static String renderDataResourceAsText(LocalDispatcher dispatcher, String dataResourceId, Appendable out,
|
||||
Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException {
|
||||
renderDataResourceAsText(dispatcher, null, dataResourceId, out, templateContext, locale, targetMimeTypeId, cache, null);
|
||||
return out.toString();
|
||||
}
|
||||
Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException {
|
||||
renderDataResourceAsText(dispatcher, null, dataResourceId, out, templateContext, locale, targetMimeTypeId, cache, null);
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static void renderDataResourceAsText(LocalDispatcher dispatcher, Delegator delegator, String dataResourceId,
|
||||
Appendable out, Map<String, Object> templateContext, Locale locale, String targetMimeTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException {
|
||||
@@ -720,7 +721,7 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
|
||||
}
|
||||
|
||||
} else if ("XSLT".equals(dataTemplateTypeId)) {
|
||||
File targetFileLocation = new File(System.getProperty("ofbiz.home")+"/runtime/tempfiles/docbook.css");
|
||||
File targetFileLocation = new File(System.getProperty("ofbiz.home") + "/runtime/tempfiles/docbook.css");
|
||||
String defaultVisualThemeId = EntityUtilProperties.getPropertyValue("general", "VISUAL_THEME", delegator);
|
||||
visualTheme = ThemeFactory.getVisualThemeFromId(defaultVisualThemeId);
|
||||
modelTheme = visualTheme.getModelTheme();
|
||||
@@ -885,10 +886,10 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
|
||||
if (url.getHost() != null) { // is absolute
|
||||
int c;
|
||||
try (InputStream in = url.openStream(); StringWriter sw = new StringWriter()) {
|
||||
while ((c = in.read()) != -1) {
|
||||
sw.write(c);
|
||||
}
|
||||
text = sw.toString();
|
||||
while ((c = in.read()) != -1) {
|
||||
sw.write(c);
|
||||
}
|
||||
text = sw.toString();
|
||||
}
|
||||
} else {
|
||||
String prefix = DataResourceWorker.buildRequestPrefix(delegator, locale, webSiteId, https);
|
||||
|
||||
@@ -140,7 +140,7 @@ public class DataServices {
|
||||
try {
|
||||
GenericValue statusItem = EntityQuery.use(delegator).from("StatusItem").where("statusTypeId", "CONTENT_STATUS").orderBy("sequenceId").queryFirst();
|
||||
if (statusItem != null) {
|
||||
dataResource.put("statusId", statusItem.get("statusId"));
|
||||
dataResource.put("statusId", statusItem.get("statusId"));
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(e.getMessage());
|
||||
|
||||
+3
-3
@@ -304,9 +304,9 @@ public class PdfSurveyServices {
|
||||
return ServiceUtil.returnError(e.getMessage());
|
||||
}
|
||||
|
||||
Map<String, Object> results = ServiceUtil.returnSuccess();
|
||||
results.put("acroFieldMap", acroFieldMap);
|
||||
return results;
|
||||
Map<String, Object> results = ServiceUtil.returnSuccess();
|
||||
results.put("acroFieldMap", acroFieldMap);
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+25
-26
@@ -83,9 +83,9 @@ public class SurveyWrapper {
|
||||
this.checkParameters();
|
||||
}
|
||||
|
||||
public SurveyWrapper(Delegator delegator, String responseId, String partyId, String surveyId, Map<String, Object> passThru) {
|
||||
this(delegator, responseId, partyId, surveyId, passThru, null);
|
||||
}
|
||||
public SurveyWrapper(Delegator delegator, String responseId, String partyId, String surveyId, Map<String, Object> passThru) {
|
||||
this(delegator, responseId, partyId, surveyId, passThru, null);
|
||||
}
|
||||
|
||||
public SurveyWrapper(Delegator delegator, String surveyId) {
|
||||
this(delegator, null, null, surveyId, null);
|
||||
@@ -223,9 +223,8 @@ public class SurveyWrapper {
|
||||
Configuration config = FreeMarkerWorker.getDefaultOfbizConfig();
|
||||
|
||||
Template template = null;
|
||||
try (
|
||||
InputStream templateStream = templateUrl.openStream();
|
||||
InputStreamReader templateReader = new InputStreamReader(templateStream, StandardCharsets.UTF_8);) {
|
||||
try (InputStream templateStream = templateUrl.openStream();
|
||||
InputStreamReader templateReader = new InputStreamReader(templateStream, StandardCharsets.UTF_8);) {
|
||||
template = new Template(templateUrl.toExternalForm(), templateReader, config);
|
||||
} catch (IOException e) {
|
||||
Debug.logError(e, "Unable to get template from URL :" + templateUrl.toExternalForm(), MODULE);
|
||||
@@ -460,27 +459,27 @@ public class SurveyWrapper {
|
||||
// note this will need to be updated as new types are added
|
||||
if ("OPTION".equals(questionType)) {
|
||||
Map<String, Object> thisResult = getOptionResult(question);
|
||||
Long questionTotal = (Long) thisResult.remove("_total");
|
||||
if (questionTotal == null) {
|
||||
questionTotal = 0L;
|
||||
}
|
||||
// set the total responses
|
||||
resultMap.put("_total", questionTotal);
|
||||
Long questionTotal = (Long) thisResult.remove("_total");
|
||||
if (questionTotal == null) {
|
||||
questionTotal = 0L;
|
||||
}
|
||||
// set the total responses
|
||||
resultMap.put("_total", questionTotal);
|
||||
|
||||
// create the map of option info ("_total", "_percent")
|
||||
// create the map of option info ("_total", "_percent")
|
||||
for (Entry<String, Object> entry : thisResult.entrySet()) {
|
||||
Map<String, Object> optMap = new HashMap<>();
|
||||
Long optTotal = (Long) entry.getValue();
|
||||
String optId = entry.getKey();
|
||||
if (optTotal == null) {
|
||||
optTotal = 0L;
|
||||
}
|
||||
Long percent = (long) (((double) optTotal / (double) questionTotal) * 100);
|
||||
optMap.put("_total", optTotal);
|
||||
optMap.put("_percent", percent);
|
||||
resultMap.put(optId, optMap);
|
||||
Map<String, Object> optMap = new HashMap<>();
|
||||
Long optTotal = (Long) entry.getValue();
|
||||
String optId = entry.getKey();
|
||||
if (optTotal == null) {
|
||||
optTotal = 0L;
|
||||
}
|
||||
resultMap.put("_a_type", "option");
|
||||
Long percent = (long) (((double) optTotal / (double) questionTotal) * 100);
|
||||
optMap.put("_total", optTotal);
|
||||
optMap.put("_percent", percent);
|
||||
resultMap.put(optId, optMap);
|
||||
}
|
||||
resultMap.put("_a_type", "option");
|
||||
} else if ("BOOLEAN".equals(questionType)) {
|
||||
long[] thisResult = getBooleanResult(question);
|
||||
long yesPercent = thisResult[1] > 0 ? (long) (((double) thisResult[1] / (double) thisResult[0]) * 100) : 0;
|
||||
@@ -527,7 +526,7 @@ public class SurveyWrapper {
|
||||
try {
|
||||
beganTransaction = TransactionUtil.begin();
|
||||
|
||||
long[] result = { 0, 0, 0 };
|
||||
long[] result = {0, 0, 0 };
|
||||
// index 0 = total responses
|
||||
// index 1 = total yes
|
||||
// index 2 = total no
|
||||
@@ -566,7 +565,7 @@ public class SurveyWrapper {
|
||||
}
|
||||
|
||||
private double[] getNumberResult(GenericValue question, int type) throws SurveyWrapperException {
|
||||
double[] result = { 0, 0, 0 };
|
||||
double[] result = {0, 0, 0 };
|
||||
// index 0 = total responses
|
||||
// index 1 = tally
|
||||
// index 2 = average
|
||||
|
||||
+1
-1
@@ -155,7 +155,7 @@ public class SimpleContentViewHandler extends AbstractViewHandler {
|
||||
}
|
||||
}
|
||||
// setup content type
|
||||
String contentType2 = UtilValidate.isNotEmpty(mimeTypeId) ? mimeTypeId + "; charset=" +charset : contentType;
|
||||
String contentType2 = UtilValidate.isNotEmpty(mimeTypeId) ? mimeTypeId + "; charset=" + charset : contentType;
|
||||
String fileName = null;
|
||||
if (UtilValidate.isNotEmpty(dataResource.getString("dataResourceName"))) {
|
||||
fileName = dataResource.getString("dataResourceName").replace(" ", "_"); // spaces in filenames can be a problem
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ import freemarker.template.TemplateTransformModel;
|
||||
public class EditRenderSubContentCacheTransform implements TemplateTransformModel {
|
||||
|
||||
private static final String MODULE = EditRenderSubContentCacheTransform.class.getName();
|
||||
static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly"};
|
||||
static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly"};
|
||||
|
||||
/**
|
||||
* @deprecated use FreeMarkerWorker.getWrappedObject()
|
||||
|
||||
+7
-7
@@ -107,7 +107,7 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel {
|
||||
List<Map<String, ? extends Object>> trail = UtilGenerics.cast(templateCtx.get("globalNodeTrail"));
|
||||
|
||||
if (Debug.infoOn()) {
|
||||
Debug.logInfo("in InjectNodeTrailCsv(0), trail:"+trail, MODULE);
|
||||
Debug.logInfo("in InjectNodeTrailCsv(0), trail:" + trail, MODULE);
|
||||
}
|
||||
// This will build a nodeTrail if none exists
|
||||
// Maybe only contentId or subContentId are passed in
|
||||
@@ -116,15 +116,15 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel {
|
||||
if (UtilValidate.isEmpty(trail) || (redo != null && "true".equalsIgnoreCase(redo))) {
|
||||
String subContentId = (String) templateCtx.get("subContentId");
|
||||
if (Debug.infoOn()) {
|
||||
Debug.logInfo("in InjectNodeTrailCsv(0), subContentId:"+subContentId, MODULE);
|
||||
Debug.logInfo("in InjectNodeTrailCsv(0), subContentId:" + subContentId, MODULE);
|
||||
}
|
||||
String contentId = (String) templateCtx.get("contentId");
|
||||
if (Debug.infoOn()) {
|
||||
Debug.logInfo("in InjectNodeTrailCsv(0), contentId:"+contentId, MODULE);
|
||||
Debug.logInfo("in InjectNodeTrailCsv(0), contentId:" + contentId, MODULE);
|
||||
}
|
||||
String contentAssocTypeId = (String) templateCtx.get("contentAssocTypeId");
|
||||
if (Debug.infoOn()) {
|
||||
Debug.logInfo("in InjectNodeTrailCsv(0), contentAssocTypeId:"+contentAssocTypeId, MODULE);
|
||||
Debug.logInfo("in InjectNodeTrailCsv(0), contentAssocTypeId:" + contentAssocTypeId, MODULE);
|
||||
}
|
||||
try {
|
||||
if (UtilValidate.isNotEmpty(subContentId)) {
|
||||
@@ -144,7 +144,7 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel {
|
||||
throw new RuntimeException("Error getting current content. " + e.toString());
|
||||
}
|
||||
if (Debug.infoOn()) {
|
||||
Debug.logInfo("in InjectNodeTrailCsv(0), csvTrail:"+csvTrail, MODULE);
|
||||
Debug.logInfo("in InjectNodeTrailCsv(0), csvTrail:" + csvTrail, MODULE);
|
||||
}
|
||||
} else {
|
||||
// Build nodeTrail if one does not exist
|
||||
@@ -163,8 +163,8 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel {
|
||||
Map<String, ? extends Object> nd = trail.get(0);
|
||||
String firstTrailContentId = (String) nd.get("contentId");
|
||||
if (UtilValidate.isNotEmpty(firstTrailContentId)
|
||||
&& UtilValidate.isNotEmpty(lastPassedContentId)
|
||||
&& firstTrailContentId.equals(lastPassedContentId)) {
|
||||
&& UtilValidate.isNotEmpty(lastPassedContentId)
|
||||
&& firstTrailContentId.equals(lastPassedContentId)) {
|
||||
csvTrail += "," + ContentWorker.nodeTrailToCsv(trail.subList(1, trail.size()));
|
||||
} else {
|
||||
csvTrail += "," + ContentWorker.nodeTrailToCsv(trail);
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class RenderContentAsText implements TemplateTransformModel {
|
||||
|
||||
private static final String MODULE = RenderContentAsText.class.getName();
|
||||
static final String[] upSaveKeyNames = {"globalNodeTrail"};
|
||||
static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "globalNodeTrail"};
|
||||
static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "globalNodeTrail"};
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class RenderSubContentAsText implements TemplateTransformModel {
|
||||
|
||||
private static final String MODULE = RenderSubContentAsText.class.getName();
|
||||
public static final String[] upSaveKeyNames = {"globalNodeTrail"};
|
||||
public static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "globalNodeTrail"};
|
||||
public static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "globalNodeTrail"};
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public class TraverseSubContentCacheTransform implements TemplateTransformModel
|
||||
|
||||
private static final String MODULE = TraverseSubContentCacheTransform.class.getName();
|
||||
static final String[] upSaveKeyNames = {"globalNodeTrail"};
|
||||
static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "globalNodeTrail"};
|
||||
static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "globalNodeTrail"};
|
||||
|
||||
/**
|
||||
* @deprecated use FreeMarkerWorker.getWrappedObject()
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public class WrapSubContentCacheTransform implements TemplateTransformModel {
|
||||
|
||||
private static final String MODULE = WrapSubContentCacheTransform.class.getName();
|
||||
static final String[] upSaveKeyNames = {"globalNodeTrail"};
|
||||
static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly"};
|
||||
static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly"};
|
||||
|
||||
/**
|
||||
* @deprecated use FreeMarkerWorker.getWrappedObject()
|
||||
|
||||
+52
-41
@@ -34,7 +34,8 @@ import org.apache.ofbiz.service.GenericServiceException;
|
||||
import org.apache.ofbiz.service.LocalDispatcher;
|
||||
import org.apache.ofbiz.service.ServiceUtil;
|
||||
|
||||
/** Helper class containing static method useful when dealing
|
||||
/**
|
||||
* Helper class containing static method useful when dealing
|
||||
* with product's bills of materials.
|
||||
* These methods are also available as services (see {@link BOMServices}).
|
||||
*/
|
||||
@@ -42,18 +43,21 @@ public final class BOMHelper {
|
||||
|
||||
private static final String MODULE = BOMHelper.class.getName();
|
||||
|
||||
/** Creates a new instance of BOMHelper */
|
||||
private BOMHelper() {
|
||||
}
|
||||
/**
|
||||
* Creates a new instance of BOMHelper
|
||||
*/
|
||||
private BOMHelper() { }
|
||||
|
||||
/** Returns the product's low level code (llc) i.e. the maximum depth
|
||||
/**
|
||||
* Returns the product's low level code (llc) i.e. the maximum depth
|
||||
* in which the productId can be found in any of the
|
||||
* bills of materials of bomType type.
|
||||
* @return The low level code for the productId. (0 = root, 1 = first level, etc...)
|
||||
*
|
||||
* @param productId The product id
|
||||
* @param bomType The bill of materials type (e.g. manufacturing, engineering,...)
|
||||
* @param bomType The bill of materials type (e.g. manufacturing, engineering,...)
|
||||
* @param delegator Validity date (if null, today is used).
|
||||
* @param inDate The delegator
|
||||
* @param inDate The delegator
|
||||
* @return The low level code for the productId. (0 = root, 1 = first level, etc...)
|
||||
* @throws GenericEntityException If a db problem occurs.
|
||||
*/
|
||||
/*
|
||||
@@ -84,26 +88,29 @@ public final class BOMHelper {
|
||||
return maxDepth;
|
||||
}
|
||||
|
||||
/** Returns the ProductAssoc generic value for a duplicate productIdKey
|
||||
/**
|
||||
* Returns the ProductAssoc generic value for a duplicate productIdKey
|
||||
* ancestor if present, null otherwise.
|
||||
* Useful to avoid loops when adding new assocs (components)
|
||||
* to a bill of materials.
|
||||
* @param productId The product to which we want to add a new child.
|
||||
* @param productIdKey The new component we want to add to the existing bom.
|
||||
* @param bomType The bill of materials type (e.g. manufacturing, engineering).
|
||||
* @param inDate Validity date (if null, today is used).
|
||||
*
|
||||
* @param delegator The delegator used
|
||||
* @throws GenericEntityException If a db problem occurs
|
||||
* @param productId The product to which we want to add a new child.
|
||||
* @param productIdKey The new component we want to add to the existing bom.
|
||||
* @param bomType The bill of materials type (e.g. manufacturing, engineering).
|
||||
* @param inDate Validity date (if null, today is used).
|
||||
* @param delegator The delegator used
|
||||
* @return the ProductAssoc generic value for a duplicate productIdKey
|
||||
* ancestor if present, null otherwise.
|
||||
* @throws GenericEntityException If a db problem occurs
|
||||
*/
|
||||
public static GenericValue searchDuplicatedAncestor(String productId, String productIdKey, String bomType, Date inDate, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException {
|
||||
public static GenericValue searchDuplicatedAncestor(String productId, String productIdKey, String bomType, Date inDate, Delegator delegator,
|
||||
LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException {
|
||||
return searchDuplicatedAncestor(productId, productIdKey, null, bomType, inDate, delegator, dispatcher, userLogin);
|
||||
}
|
||||
|
||||
private static GenericValue searchDuplicatedAncestor(String productId, String productIdKey, List<String> productIdKeys,
|
||||
String bomType, Date inDate, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException {
|
||||
String bomType, Date inDate, Delegator delegator, LocalDispatcher dispatcher,
|
||||
GenericValue userLogin) throws GenericEntityException {
|
||||
// If the date is null, set it to today.
|
||||
if (inDate == null) inDate = new Date();
|
||||
if (productIdKeys == null) {
|
||||
@@ -122,7 +129,8 @@ public final class BOMHelper {
|
||||
return oneNode;
|
||||
}
|
||||
}
|
||||
duplicatedNode = searchDuplicatedAncestor(oneNode.getString("productId"), productIdKey, productIdKeys, bomType, inDate, delegator, dispatcher, userLogin);
|
||||
duplicatedNode = searchDuplicatedAncestor(oneNode.getString("productId"), productIdKey, productIdKeys, bomType, inDate, delegator,
|
||||
dispatcher, userLogin);
|
||||
if (duplicatedNode != null) {
|
||||
break;
|
||||
}
|
||||
@@ -130,7 +138,8 @@ public final class BOMHelper {
|
||||
return duplicatedNode;
|
||||
}
|
||||
|
||||
public static String createProductionRunsForShipment(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) {
|
||||
public static String createProductionRunsForShipment(javax.servlet.http.HttpServletRequest request,
|
||||
javax.servlet.http.HttpServletResponse response) {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
|
||||
GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
|
||||
@@ -138,30 +147,32 @@ public final class BOMHelper {
|
||||
String shipmentId = request.getParameter("shipmentId");
|
||||
|
||||
try {
|
||||
List<GenericValue> shipmentPlans = EntityQuery.use(delegator).from("OrderShipment")
|
||||
.where("shipmentId", shipmentId).queryList();
|
||||
for (GenericValue shipmentPlan : shipmentPlans) {
|
||||
GenericValue orderItem = shipmentPlan.getRelatedOne("OrderItem", false);
|
||||
List<GenericValue> shipmentPlans = EntityQuery.use(delegator).from("OrderShipment")
|
||||
.where("shipmentId", shipmentId).queryList();
|
||||
for (GenericValue shipmentPlan : shipmentPlans) {
|
||||
GenericValue orderItem = shipmentPlan.getRelatedOne("OrderItem", false);
|
||||
|
||||
List<GenericValue> productionRuns = EntityQuery.use(delegator).from("WorkOrderItemFulfillment")
|
||||
.where("orderId", shipmentPlan.get("orderId"),
|
||||
"orderItemSeqId", shipmentPlan.get("orderItemSeqId"),
|
||||
"shipGroupSeqId", shipmentPlan.get("shipGroupSeqId"))
|
||||
.cache().queryList();
|
||||
if (UtilValidate.isNotEmpty(productionRuns)) {
|
||||
Debug.logError("Production Run for order item (" + orderItem.getString("orderId") + "/" + orderItem.getString("orderItemSeqId") + ") not created.", MODULE);
|
||||
continue;
|
||||
List<GenericValue> productionRuns = EntityQuery.use(delegator).from("WorkOrderItemFulfillment")
|
||||
.where("orderId", shipmentPlan.get("orderId"),
|
||||
"orderItemSeqId", shipmentPlan.get("orderItemSeqId"),
|
||||
"shipGroupSeqId", shipmentPlan.get("shipGroupSeqId"))
|
||||
.cache().queryList();
|
||||
if (UtilValidate.isNotEmpty(productionRuns)) {
|
||||
Debug.logError("Production Run for order item (" + orderItem.getString("orderId") + "/" + orderItem.getString("orderItemSeqId") + ") not created.", MODULE);
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> result = dispatcher.runSync("createProductionRunsForOrder", UtilMisc.<String, Object>toMap("quantity",
|
||||
shipmentPlan.getBigDecimal("quantity"), "orderId",
|
||||
shipmentPlan.getString("orderId"), "orderItemSeqId", shipmentPlan.getString("orderItemSeqId"), "shipGroupSeqId",
|
||||
shipmentPlan.getString("shipGroupSeqId"), "shipmentId",
|
||||
shipmentId, "userLogin", userLogin));
|
||||
if (ServiceUtil.isError(result)) {
|
||||
String errorMessage = ServiceUtil.getErrorMessage(result);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errorMessage);
|
||||
Debug.logError(errorMessage, MODULE);
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
Map<String, Object> result = dispatcher.runSync("createProductionRunsForOrder", UtilMisc.<String, Object>toMap("quantity", shipmentPlan.getBigDecimal("quantity"), "orderId",
|
||||
shipmentPlan.getString("orderId"), "orderItemSeqId", shipmentPlan.getString("orderItemSeqId"), "shipGroupSeqId", shipmentPlan.getString("shipGroupSeqId"), "shipmentId",
|
||||
shipmentId, "userLogin", userLogin));
|
||||
if (ServiceUtil.isError(result)) {
|
||||
String errorMessage = ServiceUtil.getErrorMessage(result);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errorMessage);
|
||||
Debug.logError(errorMessage, MODULE);
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
} catch (GenericEntityException | GenericServiceException ge) {
|
||||
Debug.logWarning(ge, MODULE);
|
||||
}
|
||||
|
||||
+2
-2
@@ -367,7 +367,7 @@ public class BOMNode {
|
||||
}
|
||||
|
||||
public BOMNode getRootNode() {
|
||||
return (parentNode != null? getParentNode(): this);
|
||||
return (parentNode != null ? getParentNode() : this);
|
||||
}
|
||||
/** Setter for property parentNode.
|
||||
* @param parentNode New value of property parentNode.
|
||||
@@ -675,7 +675,7 @@ public class BOMNode {
|
||||
}
|
||||
|
||||
public boolean isVirtual() {
|
||||
return (product.get("isVirtual") != null? "Y".equals(product.get("isVirtual")): false);
|
||||
return (product.get("isVirtual") != null ? "Y".equals(product.get("isVirtual")) : false);
|
||||
}
|
||||
|
||||
public void isConfigured(List<BOMNode> arr) {
|
||||
|
||||
+1
-1
@@ -524,7 +524,7 @@ public class BOMServices {
|
||||
OrderReadHelper orderReadHelper = (OrderReadHelper) orderReadHelpers.get(orderShipment.getString("orderId"));
|
||||
if (orderReadHelper != null) {
|
||||
Map<String, Object> orderShipmentReadMap = UtilMisc.toMap("orderShipment", orderShipment, "orderReadHelper", orderReadHelper);
|
||||
String partyId = (orderReadHelper.getPlacingParty() != null? orderReadHelper.getPlacingParty().getString("partyId"): null); // FIXME: is it the customer?
|
||||
String partyId = (orderReadHelper.getPlacingParty() != null ? orderReadHelper.getPlacingParty().getString("partyId") : null); // FIXME: is it the customer?
|
||||
if (partyId != null) {
|
||||
if (!partyOrderShipments.containsKey(partyId)) {
|
||||
List<Map<String, Object>> orderShipmentReadMapList = new LinkedList<>();
|
||||
|
||||
+2
-2
@@ -117,7 +117,7 @@ public class BOMTree {
|
||||
// We load the information about the product that needs to be manufactured
|
||||
// from Product entity
|
||||
GenericValue product = EntityQuery.use(delegator).from("Product")
|
||||
.where("productId", (manufacturedAsProduct != null? manufacturedAsProduct.getString("productIdTo"): productId))
|
||||
.where("productId", (manufacturedAsProduct != null ? manufacturedAsProduct.getString("productIdTo") : productId))
|
||||
.queryOne();
|
||||
if (product == null) return;
|
||||
BOMNode originalNode = new BOMNode(product, dispatcher, userLogin);
|
||||
@@ -135,7 +135,7 @@ public class BOMTree {
|
||||
productIdForRules = virtualProduct.getString("productId");
|
||||
manufacturedAsProduct = manufacturedAsProduct(virtualProduct.getString("productId"), inDate);
|
||||
product = EntityQuery.use(delegator).from("Product")
|
||||
.where("productId", (manufacturedAsProduct != null? manufacturedAsProduct.getString("productIdTo"): virtualProduct.get("productId")))
|
||||
.where("productId", (manufacturedAsProduct != null ? manufacturedAsProduct.getString("productIdTo") : virtualProduct.get("productId")))
|
||||
.queryOne();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -376,7 +376,7 @@ public class ProductionRun {
|
||||
Debug.logWarning(e.getMessage(), MODULE);
|
||||
}
|
||||
}
|
||||
return (UtilValidate.isNotEmpty(productionRunRoutingTasks) ? productionRunRoutingTasks.get(productionRunRoutingTasks.size() - 1): null);
|
||||
return (UtilValidate.isNotEmpty(productionRunRoutingTasks) ? productionRunRoutingTasks.get(productionRunRoutingTasks.size() - 1) : null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+284
-187
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -41,7 +41,7 @@ public class InventoryEventPlannedServices {
|
||||
/**
|
||||
*
|
||||
* Create an MrpEvent.
|
||||
* Make an update if a record exist with same key, (adding the event quantity to the exiting record)
|
||||
* Make an update if a record exist with same key, (adding the event quantity to the exiting record)
|
||||
*
|
||||
* @param ctx the dispatch context
|
||||
* @param context a map containing the parameters used to create an MrpEvent
|
||||
@@ -58,7 +58,7 @@ public class InventoryEventPlannedServices {
|
||||
try {
|
||||
createOrUpdateMrpEvent(parameters, quantity, (String) context.get("facilityId"), (String) context.get("eventName"), false, delegator);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Error : findOne(\"MrpEvent\", parameters =)"+parameters, MODULE);
|
||||
Debug.logError(e, "Error : findOne(\"MrpEvent\", parameters =)" + parameters, MODULE);
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCreateOrUpdateEvent", UtilMisc.toMap("parameters", parameters), locale));
|
||||
}
|
||||
return ServiceUtil.returnSuccess();
|
||||
|
||||
+126
-73
@@ -53,7 +53,6 @@ import com.ibm.icu.util.Calendar;
|
||||
|
||||
/**
|
||||
* Services for running MRP
|
||||
*
|
||||
*/
|
||||
public class MrpServices {
|
||||
|
||||
@@ -83,7 +82,7 @@ public class MrpServices {
|
||||
try {
|
||||
delegator.removeAll(listResult);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Error : removeAll(listResult), listResult ="+listResult, MODULE);
|
||||
Debug.logError(e, "Error : removeAll(listResult), listResult =" + listResult, MODULE);
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventRemoveError", locale));
|
||||
}
|
||||
}
|
||||
@@ -122,7 +121,7 @@ public class MrpServices {
|
||||
}
|
||||
if (listResult != null) {
|
||||
try {
|
||||
for (GenericValue tempRequirement: listResult) {
|
||||
for (GenericValue tempRequirement : listResult) {
|
||||
requirementStatus.addAll(tempRequirement.getRelated("RequirementStatus", null, null, false));
|
||||
}
|
||||
delegator.removeAll(requirementStatus);
|
||||
@@ -199,9 +198,11 @@ public class MrpServices {
|
||||
}
|
||||
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", requiredByDate, "mrpEventTypeId", "SALES_ORDER_SHIP");
|
||||
try {
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("orderId") + "-" + genericResult.getString("orderItemSeqId"), false, delegator);
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null,
|
||||
genericResult.getString("orderId") + "-" + genericResult.getString("orderItemSeqId"), false, delegator);
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap("mrpEventTypeId", "SALES_ORDER_SHIP"), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
|
||||
"mrpEventTypeId", "SALES_ORDER_SHIP"), locale));
|
||||
}
|
||||
}
|
||||
// ----------------------------------------
|
||||
@@ -229,9 +230,11 @@ public class MrpServices {
|
||||
|
||||
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId", "PROD_REQ_RECP");
|
||||
try {
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("requirementId"), false, delegator);
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("requirementId"),
|
||||
false, delegator);
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap("mrpEventTypeId", "PROD_REQ_RECP"), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
|
||||
"mrpEventTypeId", "PROD_REQ_RECP"), locale));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +267,8 @@ public class MrpServices {
|
||||
if (!newOrderId.equals(orderId)) {
|
||||
orderDeliverySchedule = null;
|
||||
orderId = newOrderId;
|
||||
orderDeliverySchedule = EntityQuery.use(delegator).from("OrderDeliverySchedule").where("orderId", orderId, "orderItemSeqId", "_NA_").queryOne();
|
||||
orderDeliverySchedule = EntityQuery.use(delegator).from("OrderDeliverySchedule").where("orderId", orderId, "orderItemSeqId",
|
||||
"_NA_").queryOne();
|
||||
}
|
||||
String productId = genericResult.getString("productId");
|
||||
BigDecimal shipGroupQuantity = genericResult.getBigDecimal("quantity");
|
||||
@@ -277,7 +281,9 @@ public class MrpServices {
|
||||
}
|
||||
|
||||
try {
|
||||
List<GenericValue> shipmentReceipts = EntityQuery.use(delegator).select("quantityAccepted", "quantityRejected").from("ShipmentReceipt").where("orderId", genericResult.getString("orderId"), "orderItemSeqId", genericResult.getString("orderItemSeqId")).queryList();
|
||||
List<GenericValue> shipmentReceipts = EntityQuery.use(delegator).select("quantityAccepted", "quantityRejected").from(
|
||||
"ShipmentReceipt").where("orderId", genericResult.getString("orderId"), "orderItemSeqId", genericResult.getString(
|
||||
"orderItemSeqId")).queryList();
|
||||
for (GenericValue shipmentReceipt : shipmentReceipts) {
|
||||
shipGroupQuantity = shipGroupQuantity.subtract(shipmentReceipt.getBigDecimal("quantityAccepted"));
|
||||
shipGroupQuantity = shipGroupQuantity.subtract(shipmentReceipt.getBigDecimal("quantityRejected"));
|
||||
@@ -286,7 +292,8 @@ public class MrpServices {
|
||||
Debug.logWarning(e, MODULE);
|
||||
}
|
||||
GenericValue orderItemDeliverySchedule = null;
|
||||
orderItemDeliverySchedule = EntityQuery.use(delegator).from("OrderDeliverySchedule").where("orderId", orderId, "orderItemSeqId", genericResult.getString("orderItemSeqId")).queryOne();
|
||||
orderItemDeliverySchedule = EntityQuery.use(delegator).from("OrderDeliverySchedule").where("orderId", orderId, "orderItemSeqId",
|
||||
genericResult.getString("orderItemSeqId")).queryOne();
|
||||
Timestamp estimatedShipDate = null;
|
||||
if (orderItemDeliverySchedule != null && orderItemDeliverySchedule.get("estimatedReadyDate") != null) {
|
||||
estimatedShipDate = orderItemDeliverySchedule.getTimestamp("estimatedReadyDate");
|
||||
@@ -299,10 +306,13 @@ public class MrpServices {
|
||||
estimatedShipDate = now;
|
||||
}
|
||||
|
||||
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId", "PUR_ORDER_RECP");
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, shipGroupQuantity, null, genericResult.getString("orderId") + "-" + genericResult.getString("orderItemSeqId"), false, delegator);
|
||||
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId",
|
||||
"PUR_ORDER_RECP");
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, shipGroupQuantity, null,
|
||||
genericResult.getString("orderId") + "-" + genericResult.getString("orderItemSeqId"), false, delegator);
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap("mrpEventTypeId", "PUR_ORDER_RECP"), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
|
||||
"mrpEventTypeId", "PUR_ORDER_RECP"), locale));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,8 +327,8 @@ public class MrpServices {
|
||||
.queryList();
|
||||
for (GenericValue genericResult : resultList) {
|
||||
if ("PRUN_CLOSED".equals(genericResult.getString("currentStatusId"))
|
||||
|| "PRUN_COMPLETED".equals(genericResult.getString("currentStatusId"))
|
||||
|| "PRUN_CANCELLED".equals(genericResult.getString("currentStatusId"))) {
|
||||
|| "PRUN_COMPLETED".equals(genericResult.getString("currentStatusId"))
|
||||
|| "PRUN_CANCELLED".equals(genericResult.getString("currentStatusId"))) {
|
||||
continue;
|
||||
}
|
||||
String productId = genericResult.getString("productId");
|
||||
@@ -336,12 +346,15 @@ public class MrpServices {
|
||||
estimatedShipDate = now;
|
||||
}
|
||||
|
||||
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId", "MANUF_ORDER_REQ");
|
||||
String eventName = (UtilValidate.isEmpty(genericResult.getString("workEffortParentId"))? genericResult.getString("workEffortId"): genericResult.getString("workEffortParentId") + "-" + genericResult.getString("workEffortId"));
|
||||
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId",
|
||||
"MANUF_ORDER_REQ");
|
||||
String eventName = (UtilValidate.isEmpty(genericResult.getString("workEffortParentId")) ? genericResult.getString("workEffortId")
|
||||
: genericResult.getString("workEffortParentId") + "-" + genericResult.getString("workEffortId"));
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, eventName, false, delegator);
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap("mrpEventTypeId", "MANUF_ORDER_REQ"), locale) + " " + e.getMessage());
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
|
||||
"mrpEventTypeId", "MANUF_ORDER_REQ"), locale) + " " + e.getMessage());
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
@@ -356,8 +369,8 @@ public class MrpServices {
|
||||
.queryList();
|
||||
for (GenericValue genericResult : resultList) {
|
||||
if ("PRUN_CLOSED".equals(genericResult.getString("currentStatusId"))
|
||||
|| "PRUN_COMPLETED".equals(genericResult.getString("currentStatusId"))
|
||||
|| "PRUN_CANCELLED".equals(genericResult.getString("currentStatusId"))) {
|
||||
|| "PRUN_COMPLETED".equals(genericResult.getString("currentStatusId"))
|
||||
|| "PRUN_CANCELLED".equals(genericResult.getString("currentStatusId"))) {
|
||||
continue;
|
||||
}
|
||||
BigDecimal qtyToProduce = genericResult.getBigDecimal("quantityToProduce");
|
||||
@@ -379,11 +392,14 @@ public class MrpServices {
|
||||
estimatedShipDate = now;
|
||||
}
|
||||
|
||||
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId", "MANUF_ORDER_RECP");
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("workEffortId"), false, delegator);
|
||||
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId",
|
||||
"MANUF_ORDER_RECP");
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("workEffortId"),
|
||||
false, delegator);
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap("mrpEventTypeId", "MANUF_ORDER_RECP"), locale) + " " + e.getMessage());
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
|
||||
"mrpEventTypeId", "MANUF_ORDER_RECP"), locale) + " " + e.getMessage());
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
@@ -422,7 +438,8 @@ public class MrpServices {
|
||||
try {
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, BigDecimal.ZERO, null, null, false, delegator);
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap("mrpEventTypeId", "REQUIRED_MRP"), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
|
||||
"mrpEventTypeId", "REQUIRED_MRP"), locale));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,7 +469,8 @@ public class MrpServices {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCannotFindCustomTimePeriod", locale));
|
||||
}
|
||||
if (customTimePeriod != null) {
|
||||
if (UtilValidate.isNotEmpty(customTimePeriod.getTimestamp("thruDate")) && customTimePeriod.getTimestamp("thruDate").before(UtilDateTime.nowTimestamp())) {
|
||||
if (UtilValidate.isNotEmpty(customTimePeriod.getTimestamp("thruDate"))
|
||||
&& customTimePeriod.getTimestamp("thruDate").before(UtilDateTime.nowTimestamp())) {
|
||||
continue;
|
||||
} else {
|
||||
List<GenericValue> salesForecastDetails = null;
|
||||
@@ -470,11 +488,14 @@ public class MrpServices {
|
||||
continue;
|
||||
}
|
||||
eventQuantityTmp = eventQuantityTmp.negate();
|
||||
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", customTimePeriod.getDate("fromDate"), "mrpEventTypeId", "SALES_FORECAST");
|
||||
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", customTimePeriod.getDate("fromDate"),
|
||||
"mrpEventTypeId", "SALES_FORECAST");
|
||||
try {
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, sfd.getString("salesForecastDetailId"), false, delegator);
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, sfd.getString(
|
||||
"salesForecastDetailId"), false, delegator);
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap("mrpEventTypeId", "SALES_FORECAST"), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing",
|
||||
UtilMisc.toMap("mrpEventTypeId", "SALES_FORECAST"), locale));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -494,11 +515,14 @@ public class MrpServices {
|
||||
* </ul>
|
||||
*
|
||||
* @param product the product for which the Quantity Available is required
|
||||
* @return the sum of all the totalAvailableToPromise of the inventoryItem related to the product, if the related facility is Mrp available (not yet implemented!!)
|
||||
* @return the sum of all the totalAvailableToPromise of the inventoryItem related to the product, if the related facility is Mrp available
|
||||
* (not yet implemented!!)
|
||||
*/
|
||||
public static BigDecimal findProductMrpQoh(String mrpId, GenericValue product, String facilityId, LocalDispatcher dispatcher, Delegator delegator) {
|
||||
public static BigDecimal findProductMrpQoh(String mrpId, GenericValue product, String facilityId, LocalDispatcher dispatcher,
|
||||
Delegator delegator) {
|
||||
return findProductMrpQoh(mrpId, product.getString("productId"), facilityId, dispatcher, delegator);
|
||||
}
|
||||
|
||||
public static BigDecimal findProductMrpQoh(String mrpId, String productId, String facilityId, LocalDispatcher dispatcher, Delegator delegator) {
|
||||
Map<String, Object> resultMap = null;
|
||||
try {
|
||||
@@ -522,14 +546,15 @@ public class MrpServices {
|
||||
public static void logMrpError(String mrpId, String productId, String errorMessage, Delegator delegator) {
|
||||
logMrpError(mrpId, productId, UtilDateTime.nowTimestamp(), errorMessage, delegator);
|
||||
}
|
||||
|
||||
public static void logMrpError(String mrpId, String productId, Timestamp eventDate, String errorMessage, Delegator delegator) {
|
||||
try {
|
||||
if (UtilValidate.isNotEmpty(productId) && UtilValidate.isNotEmpty(errorMessage)) {
|
||||
GenericValue inventoryEventError = delegator.makeValue("MrpEvent", UtilMisc.toMap("productId", productId,
|
||||
"mrpId", mrpId,
|
||||
"eventDate", eventDate,
|
||||
"mrpEventTypeId", "ERROR",
|
||||
"eventName", errorMessage));
|
||||
"mrpId", mrpId,
|
||||
"eventDate", eventDate,
|
||||
"mrpEventTypeId", "ERROR",
|
||||
"eventName", errorMessage));
|
||||
delegator.createOrStore(inventoryEventError);
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -540,15 +565,17 @@ public class MrpServices {
|
||||
/**
|
||||
* Process the bill of material (bom) of the product to insert components in the MrpEvent table.
|
||||
* Before inserting in the entity, test if there is the record already existing to add quantity rather to create a new one.
|
||||
* @param mrpId the mrp id
|
||||
* @param product GenericValue oject of the product
|
||||
* @param eventQuantity the product quantity needed
|
||||
* @param startDate the startDate of the productionRun which will used to produce the product
|
||||
*
|
||||
* @param mrpId the mrp id
|
||||
* @param product GenericValue oject of the product
|
||||
* @param eventQuantity the product quantity needed
|
||||
* @param startDate the startDate of the productionRun which will used to produce the product
|
||||
* @param routingTaskStartDate Map with all the routingTask as keys and startDate of each of them
|
||||
* @param listComponent a List with all the components
|
||||
* @param listComponent a List with all the components
|
||||
*/
|
||||
|
||||
public static void processBomComponent(String mrpId, GenericValue product, BigDecimal eventQuantity, Timestamp startDate, Map<String, Object> routingTaskStartDate, List<BOMNode> listComponent) {
|
||||
public static void processBomComponent(String mrpId, GenericValue product, BigDecimal eventQuantity, Timestamp startDate,
|
||||
Map<String, Object> routingTaskStartDate, List<BOMNode> listComponent) {
|
||||
// TODO : change the return type to boolean to be able to test if all is ok or if it have had a exception
|
||||
Delegator delegator = product.getDelegator();
|
||||
|
||||
@@ -557,7 +584,8 @@ public class MrpServices {
|
||||
GenericValue productComponent = node.getProductAssoc();
|
||||
// read the startDate for the component
|
||||
String routingTask = node.getProductAssoc().getString("routingWorkEffortId");
|
||||
Timestamp eventDate = (routingTask == null || !routingTaskStartDate.containsKey(routingTask)) ? startDate : (Timestamp) routingTaskStartDate.get(routingTask);
|
||||
Timestamp eventDate = (routingTask == null || !routingTaskStartDate.containsKey(routingTask)) ? startDate
|
||||
: (Timestamp) routingTaskStartDate.get(routingTask);
|
||||
// if the components is valid at the event Date create the Mrp requirement in the M entity
|
||||
if (EntityUtil.isValueActive(productComponent, eventDate)) {
|
||||
Map<String, Object> parameters = UtilMisc.<String, Object>toMap("productId", node.getProduct().getString("productId"));
|
||||
@@ -566,7 +594,8 @@ public class MrpServices {
|
||||
parameters.put("mrpEventTypeId", "MRP_REQUIREMENT");
|
||||
BigDecimal componentEventQuantity = node.getQuantity();
|
||||
try {
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, componentEventQuantity.negate(), null, product.get("productId") + ": " + eventDate, false, delegator);
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, componentEventQuantity.negate(), null, product.get(
|
||||
"productId") + ": " + eventDate, false, delegator);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError("Error : findOne(\"MrpEvent\", parameters) =" + parameters + "--" + e.getMessage(), MODULE);
|
||||
logMrpError(mrpId, node.getProduct().getString("productId"), "Unable to create event (processBomComponent)", delegator);
|
||||
@@ -585,7 +614,7 @@ public class MrpServices {
|
||||
* <li>OUTPUT : Result to put in the map : <ul><li>none</li></ul></li>
|
||||
* </ul>
|
||||
*
|
||||
* @param ctx The DispatchContext that this service is operating in.
|
||||
* @param ctx The DispatchContext that this service is operating in.
|
||||
* @param context Map containing the input parameters, productId routingId, quantity, startDate.
|
||||
* @return Map with the result of the service, the output parameters.
|
||||
*/
|
||||
@@ -608,11 +637,13 @@ public class MrpServices {
|
||||
try {
|
||||
GenericValue facilityGroup = EntityQuery.use(delegator).from("FacilityGroup").where("facilityGroupId", facilityGroupId).queryOne();
|
||||
if (UtilValidate.isEmpty(facilityGroup)) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpFacilityGroupIsNotValid", UtilMisc.toMap("facilityGroupId", facilityGroupId), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpFacilityGroupIsNotValid", UtilMisc.toMap(
|
||||
"facilityGroupId", facilityGroupId), locale));
|
||||
}
|
||||
List<GenericValue> facilities = facilityGroup.getRelated("FacilityGroupMember", null, UtilMisc.toList("sequenceNum"), false);
|
||||
if (UtilValidate.isEmpty(facilities)) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpFacilityGroupIsNotAssociatedToFacility", UtilMisc.toMap("facilityGroupId", facilityGroupId), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpFacilityGroupIsNotAssociatedToFacility",
|
||||
UtilMisc.toMap("facilityGroupId", facilityGroupId), locale));
|
||||
}
|
||||
for (GenericValue facilityMember : facilities) {
|
||||
GenericValue facility = facilityMember.getRelatedOne("Facility", false);
|
||||
@@ -624,14 +655,16 @@ public class MrpServices {
|
||||
}
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpFacilityGroupCannotBeLoad", UtilMisc.toMap("errorString", e.getMessage()), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpFacilityGroupCannotBeLoad", UtilMisc.toMap(
|
||||
"errorString", e.getMessage()), locale));
|
||||
}
|
||||
} else {
|
||||
manufacturingFacilityId = facilityId;
|
||||
}
|
||||
|
||||
if (UtilValidate.isEmpty(facilityId) || UtilValidate.isEmpty(manufacturingFacilityId)) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpFacilityOrManufacturingFacilityNotAvailable", locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpFacilityOrManufacturingFacilityNotAvailable",
|
||||
locale));
|
||||
}
|
||||
|
||||
int bomLevelWithNoEvent = 0;
|
||||
@@ -657,7 +690,8 @@ public class MrpServices {
|
||||
ListIterator<GenericValue> iteratorListInventoryEventForMRP = null;
|
||||
|
||||
// Initialization of the MrpEvent table, This table will contain the products we want to buy or build.
|
||||
parameters = UtilMisc.<String, Object>toMap("mrpId", mrpId, "reInitialize", Boolean.TRUE, "defaultYearsOffset", defaultYearsOffset, "userLogin", userLogin);
|
||||
parameters = UtilMisc.<String, Object>toMap("mrpId", mrpId, "reInitialize", Boolean.TRUE, "defaultYearsOffset", defaultYearsOffset,
|
||||
"userLogin", userLogin);
|
||||
parameters.put("facilityId", facilityId);
|
||||
parameters.put("manufacturingFacilityId", manufacturingFacilityId);
|
||||
try {
|
||||
@@ -666,7 +700,8 @@ public class MrpServices {
|
||||
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
|
||||
}
|
||||
} catch (GenericServiceException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpErrorRunningInitMrpEvents", UtilMisc.toMap("errorString", e.getMessage()), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpErrorRunningInitMrpEvents", UtilMisc.toMap(
|
||||
"errorString", e.getMessage()), locale));
|
||||
}
|
||||
long bomLevel = 0;
|
||||
do {
|
||||
@@ -674,8 +709,8 @@ public class MrpServices {
|
||||
EntityCondition filterByConditions = null;
|
||||
if (bomLevel == 0) {
|
||||
filterByConditions = EntityCondition.makeCondition(EntityCondition.makeCondition("billOfMaterialLevel", EntityOperator.EQUALS, null),
|
||||
EntityOperator.OR,
|
||||
EntityCondition.makeCondition("billOfMaterialLevel", EntityOperator.EQUALS, bomLevel));
|
||||
EntityOperator.OR,
|
||||
EntityCondition.makeCondition("billOfMaterialLevel", EntityOperator.EQUALS, bomLevel));
|
||||
} else {
|
||||
filterByConditions = EntityCondition.makeCondition("billOfMaterialLevel", EntityOperator.EQUALS, bomLevel);
|
||||
}
|
||||
@@ -686,7 +721,8 @@ public class MrpServices {
|
||||
.queryList();
|
||||
} catch (GenericEntityException e) {
|
||||
Long bomLevelToString = bomLevel;
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpErrorForBomLevel", UtilMisc.toMap("bomLevel", bomLevelToString.toString(), "errorString", e.getMessage()), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpErrorForBomLevel", UtilMisc.toMap("bomLevel",
|
||||
bomLevelToString.toString(), "errorString", e.getMessage()), locale));
|
||||
}
|
||||
|
||||
if (UtilValidate.isNotEmpty(listInventoryEventForMRP)) {
|
||||
@@ -698,15 +734,17 @@ public class MrpServices {
|
||||
eventCount++;
|
||||
|
||||
productId = inventoryEventForMRP.getString("productId");
|
||||
boolean isLastEvent = (eventCount == listInventoryEventForMRP.size() || !productId.equals(listInventoryEventForMRP.get(eventCount).getString("productId")));
|
||||
boolean isLastEvent = (eventCount == listInventoryEventForMRP.size()
|
||||
|| !productId.equals(listInventoryEventForMRP.get(eventCount).getString("productId")));
|
||||
eventQuantity = inventoryEventForMRP.getBigDecimal("quantity");
|
||||
|
||||
if (!productId.equals(oldProductId)) {
|
||||
BigDecimal positiveEventQuantity = eventQuantity.compareTo(BigDecimal.ZERO) > 0 ? eventQuantity: eventQuantity.negate();
|
||||
BigDecimal positiveEventQuantity = eventQuantity.compareTo(BigDecimal.ZERO) > 0 ? eventQuantity : eventQuantity.negate();
|
||||
// It's a new product, so it's necessary to read the MrpQoh
|
||||
try {
|
||||
product = inventoryEventForMRP.getRelatedOne("Product", true);
|
||||
productFacility = EntityUtil.getFirst(product.getRelated("ProductFacility", UtilMisc.toMap("facilityId", facilityId), null, true));
|
||||
productFacility = EntityUtil.getFirst(product.getRelated("ProductFacility", UtilMisc.toMap("facilityId", facilityId),
|
||||
null, true));
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCannotFindProductForEvent", locale));
|
||||
}
|
||||
@@ -717,16 +755,20 @@ public class MrpServices {
|
||||
"mrpEventTypeId", "INITIAL_QOH", "eventDate", now),
|
||||
stockTmp, facilityId, null, false, delegator);
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCreateOrUpdateEvent", UtilMisc.toMap("parameters", parameters), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCreateOrUpdateEvent",
|
||||
UtilMisc.toMap("parameters", parameters), locale));
|
||||
}
|
||||
// days to ship is only relevant for sales order to plan for preparatory days to ship. Otherwise MRP will push event dates for manufacturing parts
|
||||
// days to ship is only relevant for sales order to plan for preparatory days to ship. Otherwise MRP will push event dates
|
||||
// for manufacturing parts
|
||||
// as well and cause problems
|
||||
daysToShip = 0;
|
||||
if (productFacility != null) {
|
||||
reorderQuantity = (productFacility.getBigDecimal("reorderQuantity") != null ? productFacility.getBigDecimal("reorderQuantity"): BigDecimal.ONE.negate());
|
||||
minimumStock = (productFacility.getBigDecimal("minimumStock") != null ? productFacility.getBigDecimal("minimumStock"): BigDecimal.ZERO);
|
||||
reorderQuantity = (productFacility.getBigDecimal("reorderQuantity") != null ? productFacility.getBigDecimal(
|
||||
"reorderQuantity") : BigDecimal.ONE.negate());
|
||||
minimumStock = (productFacility.getBigDecimal("minimumStock") != null ? productFacility.getBigDecimal("minimumStock")
|
||||
: BigDecimal.ZERO);
|
||||
if ("SALES_ORDER_SHIP".equals(inventoryEventForMRP.getString("mrpEventTypeId"))) {
|
||||
daysToShip = (productFacility.getLong("daysToShip") != null? productFacility.getLong("daysToShip").intValue(): 0);
|
||||
daysToShip = (productFacility.getLong("daysToShip") != null ? productFacility.getLong("daysToShip").intValue() : 0);
|
||||
}
|
||||
} else {
|
||||
minimumStock = BigDecimal.ZERO;
|
||||
@@ -736,7 +778,9 @@ public class MrpServices {
|
||||
// The components are also loaded thru the configurator
|
||||
Map<String, Object> serviceResponse = null;
|
||||
try {
|
||||
serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.<String, Object>toMap("productId", product.getString("productId"), "quantity", positiveEventQuantity, "excludeWIPs", Boolean.FALSE, "userLogin", userLogin));
|
||||
serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.<String, Object>toMap("productId",
|
||||
product.getString("productId"), "quantity", positiveEventQuantity, "excludeWIPs", Boolean.FALSE, "userLogin",
|
||||
userLogin));
|
||||
if (ServiceUtil.isError(serviceResponse)) {
|
||||
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResponse));
|
||||
}
|
||||
@@ -757,12 +801,13 @@ public class MrpServices {
|
||||
}
|
||||
|
||||
stockTmp = stockTmp.add(eventQuantity);
|
||||
if (stockTmp.compareTo(minimumStock) < 0 && (eventQuantity.compareTo(BigDecimal.ZERO) < 0 || isLastEvent)) { // No need to create a supply event/requirement if the current event is not a demand and there are other events to process
|
||||
if (stockTmp.compareTo(minimumStock) < 0 && (eventQuantity.compareTo(BigDecimal.ZERO) < 0 || isLastEvent)) { // No need to
|
||||
// create a supply event/requirement if the current event is not a demand and there are other events to process
|
||||
BigDecimal qtyToStock = minimumStock.subtract(stockTmp);
|
||||
//need to buy or build the product as we have not enough stock
|
||||
eventDate = inventoryEventForMRP.getTimestamp("eventDate");
|
||||
// to be just before the requirement
|
||||
eventDate.setTime(eventDate.getTime()-1);
|
||||
eventDate.setTime(eventDate.getTime() - 1);
|
||||
ProposedOrder proposedOrder = new ProposedOrder(product, facilityId, manufacturingFacilityId, isBuilt, eventDate, qtyToStock);
|
||||
proposedOrder.setMrpName(mrpName);
|
||||
// calculate the ProposedOrder quantity and update the quantity object property.
|
||||
@@ -772,7 +817,9 @@ public class MrpServices {
|
||||
// The components are also loaded thru the configurator
|
||||
Map<String, Object> serviceResponse = null;
|
||||
try {
|
||||
serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.<String, Object>toMap("productId", product.getString("productId"), "quantity", proposedOrder.getQuantity(), "excludeWIPs", Boolean.FALSE, "userLogin", userLogin));
|
||||
serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.<String, Object>toMap("productId",
|
||||
product.getString("productId"), "quantity", proposedOrder.getQuantity(), "excludeWIPs", Boolean.FALSE,
|
||||
"userLogin", userLogin));
|
||||
if (ServiceUtil.isError(serviceResponse)) {
|
||||
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResponse));
|
||||
}
|
||||
@@ -786,7 +833,8 @@ public class MrpServices {
|
||||
try {
|
||||
routing = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", routingId).queryOne();
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCannotFindProductForEvent", locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCannotFindProductForEvent",
|
||||
locale));
|
||||
}
|
||||
} else {
|
||||
routing = null;
|
||||
@@ -800,10 +848,12 @@ public class MrpServices {
|
||||
// #####################################################
|
||||
|
||||
// calculate the ProposedOrder requirementStartDate and update the requirementStartDate object property.
|
||||
Map<String, Object> routingTaskStartDate = proposedOrder.calculateStartDate(daysToShip, routing, delegator, dispatcher, userLogin);
|
||||
Map<String, Object> routingTaskStartDate = proposedOrder.calculateStartDate(daysToShip, routing, delegator, dispatcher,
|
||||
userLogin);
|
||||
if (isBuilt) {
|
||||
// process the product components
|
||||
processBomComponent(mrpId, product, proposedOrder.getQuantity(), proposedOrder.getRequirementStartDate(), routingTaskStartDate, components);
|
||||
processBomComponent(mrpId, product, proposedOrder.getQuantity(), proposedOrder.getRequirementStartDate(),
|
||||
routingTaskStartDate, components);
|
||||
}
|
||||
// create the ProposedOrder (only if the product is warehouse managed), and the MrpEvent associated
|
||||
String requirementId = null;
|
||||
@@ -811,20 +861,23 @@ public class MrpServices {
|
||||
requirementId = proposedOrder.create(ctx, userLogin);
|
||||
}
|
||||
if (UtilValidate.isEmpty(productFacility) && !isBuilt) {
|
||||
logMrpError(mrpId, productId, now, "No ProductFacility record for [" + facilityId + "]; no requirement created.", delegator);
|
||||
logMrpError(mrpId, productId, now, "No ProductFacility record for [" + facilityId + "]; no requirement created.",
|
||||
delegator);
|
||||
}
|
||||
String eventName = null;
|
||||
if (UtilValidate.isNotEmpty(requirementId)) {
|
||||
eventName = "*" + requirementId + " (" + proposedOrder.getRequirementStartDate() + ")*";
|
||||
}
|
||||
Map<String, Object> eventMap = UtilMisc.<String, Object>toMap("productId", product.getString("productId"),
|
||||
"mrpId", mrpId,
|
||||
"eventDate", eventDate,
|
||||
"mrpEventTypeId", (isBuilt? "PROP_MANUF_O_RECP" : "PROP_PUR_O_RECP"));
|
||||
"mrpId", mrpId,
|
||||
"eventDate", eventDate,
|
||||
"mrpEventTypeId", (isBuilt ? "PROP_MANUF_O_RECP" : "PROP_PUR_O_RECP"));
|
||||
try {
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(eventMap, proposedOrder.getQuantity(), null, eventName, (proposedOrder.getRequirementStartDate().compareTo(now) < 0), delegator);
|
||||
InventoryEventPlannedServices.createOrUpdateMrpEvent(eventMap, proposedOrder.getQuantity(), null,
|
||||
eventName, (proposedOrder.getRequirementStartDate().compareTo(now) < 0), delegator);
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCreateOrUpdateEvent", UtilMisc.toMap("parameters", parameters), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCreateOrUpdateEvent",
|
||||
UtilMisc.toMap("parameters", parameters), locale));
|
||||
}
|
||||
//
|
||||
stockTmp = stockTmp.add(proposedOrder.getQuantity());
|
||||
|
||||
+2
-2
@@ -176,7 +176,7 @@ public class ProposedOrder {
|
||||
try {
|
||||
routingTask = routingTaskAssoc.getRelatedOne("ToWorkEffort", true);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e.getMessage(), MODULE);
|
||||
Debug.logError(e.getMessage(), MODULE);
|
||||
}
|
||||
// Calculate the estimatedStartDate
|
||||
long totalTime = ProductionRun.getEstimatedTaskTime(routingTask, quantity, dispatcher);
|
||||
@@ -267,7 +267,7 @@ public class ProposedOrder {
|
||||
}
|
||||
return (String) result.get("requirementId");
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, "Error : createRequirement with parameters = "+parameters+"--" + e.getMessage(), MODULE);
|
||||
Debug.logError(e, "Error : createRequirement with parameters = " + parameters + "--" + e.getMessage(), MODULE);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-6
@@ -137,10 +137,11 @@ public class TechDataServices {
|
||||
if (listRoutingTaskAssoc != null) {
|
||||
for (GenericValue routingTaskAssoc : listRoutingTaskAssoc) {
|
||||
if (!workEffortIdFrom.equals(routingTaskAssoc.getString("workEffortIdFrom"))
|
||||
|| !workEffortIdTo.equals(routingTaskAssoc.getString("workEffortIdTo"))
|
||||
|| !workEffortAssocTypeId.equals(routingTaskAssoc.getString("workEffortAssocTypeId"))
|
||||
|| !sequenceNum.equals(routingTaskAssoc.getLong("sequenceNum"))) {
|
||||
if (routingTaskAssoc.getTimestamp("thruDate") == null && routingTaskAssoc.getTimestamp("fromDate") == null) sequenceNumNotOk = "Y";
|
||||
|| !workEffortIdTo.equals(routingTaskAssoc.getString("workEffortIdTo"))
|
||||
|| !workEffortAssocTypeId.equals(routingTaskAssoc.getString("workEffortAssocTypeId"))
|
||||
|| !sequenceNum.equals(routingTaskAssoc.getLong("sequenceNum"))) {
|
||||
if (routingTaskAssoc.getTimestamp("thruDate") == null && routingTaskAssoc.getTimestamp("fromDate") == null)
|
||||
sequenceNumNotOk = "Y";
|
||||
else if (routingTaskAssoc.getTimestamp("thruDate") == null) {
|
||||
if (thruDate == null) sequenceNumNotOk = "Y";
|
||||
else if (thruDate.after(routingTaskAssoc.getTimestamp("fromDate"))) sequenceNumNotOk = "Y";
|
||||
@@ -152,7 +153,9 @@ public class TechDataServices {
|
||||
if (fromDate.before(routingTaskAssoc.getTimestamp("thruDate"))) sequenceNumNotOk = "Y";
|
||||
} else if (fromDate == null) {
|
||||
if (thruDate.after(routingTaskAssoc.getTimestamp("fromDate"))) sequenceNumNotOk = "Y";
|
||||
} else if (routingTaskAssoc.getTimestamp("fromDate").before(thruDate) && fromDate.before(routingTaskAssoc.getTimestamp("thruDate"))) sequenceNumNotOk = "Y";
|
||||
} else if (routingTaskAssoc.getTimestamp("fromDate").before(thruDate) && fromDate.before(routingTaskAssoc.getTimestamp(
|
||||
"thruDate")))
|
||||
sequenceNumNotOk = "Y";
|
||||
} else if (createProcess) sequenceNumNotOk = "Y";
|
||||
}
|
||||
}
|
||||
@@ -436,7 +439,7 @@ public class TechDataServices {
|
||||
Double capacity = (Double) position.get("capacity");
|
||||
Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateFrom).getTime() + startTime.getTime() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET));
|
||||
if (dateFrom.before(startAvailablePeriod)) return 0;
|
||||
Timestamp endAvailablePeriod = new Timestamp(startAvailablePeriod.getTime()+capacity.longValue());
|
||||
Timestamp endAvailablePeriod = new Timestamp(startAvailablePeriod.getTime() + capacity.longValue());
|
||||
if (dateFrom.after(endAvailablePeriod)) return 0;
|
||||
return dateFrom.getTime() - startAvailablePeriod.getTime();
|
||||
}
|
||||
|
||||
+1
-2
@@ -277,8 +277,7 @@ public class TrackingCodeEvents {
|
||||
String siteIdEnc;
|
||||
try {
|
||||
siteIdEnc = URLEncoder.encode(siteId, "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Debug.logWarning("There went something wrong while encoding for the cookie creation in TrackingCodeEvents.processTrackingCode", MODULE);
|
||||
return "error";
|
||||
}
|
||||
|
||||
+121
-108
@@ -40,22 +40,19 @@ import org.apache.ofbiz.entity.util.EntityQuery;
|
||||
|
||||
/**
|
||||
* A package of methods for improving efficiency of financial accounts services
|
||||
*
|
||||
*/
|
||||
public final class FinAccountHelper {
|
||||
private static final String MODULE = FinAccountHelper.class.getName();
|
||||
/**
|
||||
* Precision: since we're just adding and subtracting, the interim figures should have one more decimal place of precision than the final numbers
|
||||
*/
|
||||
* Precision: since we're just adding and subtracting, the interim figures should have one more decimal place of precision than the final numbers
|
||||
*/
|
||||
private static final int DECIMALS = UtilNumber.getBigDecimalScale("finaccount.decimals");
|
||||
private static final RoundingMode ROUNDING = UtilNumber.getRoundingMode("finaccount.rounding");
|
||||
private static final BigDecimal ZERO = BigDecimal.ZERO.setScale(DECIMALS, ROUNDING);
|
||||
private static final String GC_FIN_ACCOUNT_TYPE = "GIFTCERT_ACCOUNT";
|
||||
|
||||
protected FinAccountHelper() { }
|
||||
|
||||
// pool of available characters for account codes, here numbers plus uppercase characters
|
||||
private static char[] charPool = new char[10 + 26];
|
||||
|
||||
static {
|
||||
int j = 0;
|
||||
for (int i = "0".charAt(0); i <= "9".charAt(0); i++) {
|
||||
@@ -65,118 +62,131 @@ public final class FinAccountHelper {
|
||||
charPool[j++] = (char) i;
|
||||
}
|
||||
}
|
||||
|
||||
protected FinAccountHelper() {
|
||||
}
|
||||
|
||||
public static int getDecimals() {
|
||||
return DECIMALS;
|
||||
}
|
||||
|
||||
public static RoundingMode getRounding() {
|
||||
return ROUNDING;
|
||||
}
|
||||
|
||||
public static BigDecimal getZero() {
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
public static String getGiftCertFinAccountTypeId() {
|
||||
return GC_FIN_ACCOUNT_TYPE;
|
||||
}
|
||||
/**
|
||||
* A convenience method which adds transactions.get(0).get(fieldName) to initialValue, all done in BigDecimal to decimals and rounding
|
||||
* @param initialValue the initial value
|
||||
* @param transactions a List of GenericValue objects of transactions
|
||||
* @param fieldName the field name to get the value from the transaction
|
||||
* @param decimals number of decimals
|
||||
* @param rounding how to rounding
|
||||
* @return the new value in a BigDecimal field
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
public static BigDecimal addFirstEntryAmount(BigDecimal initialValue, List<GenericValue> transactions, String fieldName, int decimals, RoundingMode rounding) throws GenericEntityException {
|
||||
if ((transactions != null) && (transactions.size() == 1)) {
|
||||
GenericValue firstEntry = transactions.get(0);
|
||||
if (firstEntry.get(fieldName) != null) {
|
||||
BigDecimal valueToAdd = firstEntry.getBigDecimal(fieldName);
|
||||
return initialValue.add(valueToAdd).setScale(decimals, rounding);
|
||||
} else {
|
||||
return initialValue;
|
||||
}
|
||||
} else {
|
||||
return initialValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique randomly generated account code for FinAccount.finAccountCode composed of uppercase letters and numbers
|
||||
* @param codeLength length of code in number of characters
|
||||
* @param delegator the delegator
|
||||
* @return returns a unique randomly generated account code for FinAccount.finAccountCode composed of uppercase letters and numbers
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
public static String getNewFinAccountCode(int codeLength, Delegator delegator) throws GenericEntityException {
|
||||
/**
|
||||
* A convenience method which adds transactions.get(0).get(fieldName) to initialValue, all done in BigDecimal to decimals and rounding
|
||||
*
|
||||
* @param initialValue the initial value
|
||||
* @param transactions a List of GenericValue objects of transactions
|
||||
* @param fieldName the field name to get the value from the transaction
|
||||
* @param decimals number of decimals
|
||||
* @param rounding how to rounding
|
||||
* @return the new value in a BigDecimal field
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
public static BigDecimal addFirstEntryAmount(BigDecimal initialValue, List<GenericValue> transactions, String fieldName, int decimals,
|
||||
RoundingMode rounding) throws GenericEntityException {
|
||||
if ((transactions != null) && (transactions.size() == 1)) {
|
||||
GenericValue firstEntry = transactions.get(0);
|
||||
if (firstEntry.get(fieldName) != null) {
|
||||
BigDecimal valueToAdd = firstEntry.getBigDecimal(fieldName);
|
||||
return initialValue.add(valueToAdd).setScale(decimals, rounding);
|
||||
} else {
|
||||
return initialValue;
|
||||
}
|
||||
} else {
|
||||
return initialValue;
|
||||
}
|
||||
}
|
||||
|
||||
// keep generating new account codes until a unique one is found
|
||||
Random r = new Random();
|
||||
boolean foundUniqueNewCode = false;
|
||||
StringBuilder newAccountCode = null;
|
||||
long count = 0;
|
||||
/**
|
||||
* Returns a unique randomly generated account code for FinAccount.finAccountCode composed of uppercase letters and numbers
|
||||
*
|
||||
* @param codeLength length of code in number of characters
|
||||
* @param delegator the delegator
|
||||
* @return returns a unique randomly generated account code for FinAccount.finAccountCode composed of uppercase letters and numbers
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
public static String getNewFinAccountCode(int codeLength, Delegator delegator) throws GenericEntityException {
|
||||
|
||||
while (!foundUniqueNewCode) {
|
||||
newAccountCode = new StringBuilder(codeLength);
|
||||
for (int i = 0; i < codeLength; i++) {
|
||||
newAccountCode.append(charPool[r.nextInt(charPool.length)]);
|
||||
}
|
||||
// keep generating new account codes until a unique one is found
|
||||
Random r = new Random();
|
||||
boolean foundUniqueNewCode = false;
|
||||
StringBuilder newAccountCode = null;
|
||||
long count = 0;
|
||||
|
||||
GenericValue existingAccountWithCode = EntityQuery.use(delegator).from("FinAccount")
|
||||
.where("finAccountCode", newAccountCode.toString()).queryFirst();
|
||||
if (existingAccountWithCode == null) {
|
||||
foundUniqueNewCode = true;
|
||||
}
|
||||
while (!foundUniqueNewCode) {
|
||||
newAccountCode = new StringBuilder(codeLength);
|
||||
for (int i = 0; i < codeLength; i++) {
|
||||
newAccountCode.append(charPool[r.nextInt(charPool.length)]);
|
||||
}
|
||||
|
||||
count++;
|
||||
if (count > 999999) {
|
||||
throw new GenericEntityException("Unable to locate unique FinAccountCode! Length [" + codeLength + "]");
|
||||
}
|
||||
}
|
||||
GenericValue existingAccountWithCode = EntityQuery.use(delegator).from("FinAccount")
|
||||
.where("finAccountCode", newAccountCode.toString()).queryFirst();
|
||||
if (existingAccountWithCode == null) {
|
||||
foundUniqueNewCode = true;
|
||||
}
|
||||
|
||||
return newAccountCode.toString();
|
||||
}
|
||||
count++;
|
||||
if (count > 999999) {
|
||||
throw new GenericEntityException("Unable to locate unique FinAccountCode! Length [" + codeLength + "]");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first (and should be only) FinAccount based on finAccountCode, which will be cleaned up to be only uppercase and alphanumeric
|
||||
* @param finAccountCode the financial account code
|
||||
* @param delegator the delegator
|
||||
* @return gets the first financial account by code
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
public static GenericValue getFinAccountFromCode(String finAccountCode, Delegator delegator) throws GenericEntityException {
|
||||
if (finAccountCode == null) {
|
||||
return null;
|
||||
}
|
||||
return newAccountCode.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first (and should be only) FinAccount based on finAccountCode, which will be cleaned up to be only uppercase and alphanumeric
|
||||
*
|
||||
* @param finAccountCode the financial account code
|
||||
* @param delegator the delegator
|
||||
* @return gets the first financial account by code
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
public static GenericValue getFinAccountFromCode(String finAccountCode, Delegator delegator) throws GenericEntityException {
|
||||
if (finAccountCode == null) {
|
||||
return null;
|
||||
}
|
||||
finAccountCode = finAccountCode.toUpperCase(Locale.getDefault()).replaceAll("[^0-9A-Z]", "");
|
||||
|
||||
// now look for the account
|
||||
List<GenericValue> accounts = EntityQuery.use(delegator).from("FinAccount")
|
||||
.where("finAccountCode", finAccountCode)
|
||||
.filterByDate().queryList();
|
||||
if (UtilValidate.isEmpty(accounts)) {
|
||||
// OK to display - not a code anyway
|
||||
Debug.logWarning("No fin account found for account code [" + finAccountCode + "]", MODULE);
|
||||
return null;
|
||||
} else if (accounts.size() > 1) {
|
||||
// This should never happen, but don't display the code if it does -- it is supposed to be encrypted!
|
||||
Debug.logError("Multiple fin accounts found", MODULE);
|
||||
return null;
|
||||
} else {
|
||||
return accounts.get(0);
|
||||
}
|
||||
}
|
||||
// now look for the account
|
||||
List<GenericValue> accounts = EntityQuery.use(delegator).from("FinAccount")
|
||||
.where("finAccountCode", finAccountCode)
|
||||
.filterByDate().queryList();
|
||||
if (UtilValidate.isEmpty(accounts)) {
|
||||
// OK to display - not a code anyway
|
||||
Debug.logWarning("No fin account found for account code [" + finAccountCode + "]", MODULE);
|
||||
return null;
|
||||
} else if (accounts.size() > 1) {
|
||||
// This should never happen, but don't display the code if it does -- it is supposed to be encrypted!
|
||||
Debug.logError("Multiple fin accounts found", MODULE);
|
||||
return null;
|
||||
} else {
|
||||
return accounts.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sum of all DEPOSIT and ADJUSTMENT transactions minus all WITHDRAWAL transactions whose transactionDate is before asOfDateTime
|
||||
* @param finAccountId the financial account id
|
||||
* @param asOfDateTime the validity date
|
||||
* @param delegator the delegator
|
||||
* @return returns the sum of all DEPOSIT and ADJUSTMENT transactions minus all WITHDRAWAL transactions
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
public static BigDecimal getBalance(String finAccountId, Timestamp asOfDateTime, Delegator delegator) throws GenericEntityException {
|
||||
/**
|
||||
* Sum of all DEPOSIT and ADJUSTMENT transactions minus all WITHDRAWAL transactions whose transactionDate is before asOfDateTime
|
||||
*
|
||||
* @param finAccountId the financial account id
|
||||
* @param asOfDateTime the validity date
|
||||
* @param delegator the delegator
|
||||
* @return returns the sum of all DEPOSIT and ADJUSTMENT transactions minus all WITHDRAWAL transactions
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
public static BigDecimal getBalance(String finAccountId, Timestamp asOfDateTime, Delegator delegator) throws GenericEntityException {
|
||||
if (asOfDateTime == null) asOfDateTime = UtilDateTime.nowTimestamp();
|
||||
|
||||
BigDecimal incrementTotal = ZERO; // total amount of transactions which increase balance
|
||||
@@ -191,7 +201,7 @@ public final class FinAccountHelper {
|
||||
EntityCondition.makeCondition(UtilMisc.toList(
|
||||
EntityCondition.makeCondition("finAccountTransTypeId", EntityOperator.EQUALS, "DEPOSIT"),
|
||||
EntityCondition.makeCondition("finAccountTransTypeId", EntityOperator.EQUALS, "ADJUSTMENT")),
|
||||
EntityOperator.OR))
|
||||
EntityOperator.OR))
|
||||
.queryList();
|
||||
incrementTotal = addFirstEntryAmount(incrementTotal, transSums, "amount", (DECIMALS + 1), ROUNDING);
|
||||
|
||||
@@ -209,14 +219,15 @@ public final class FinAccountHelper {
|
||||
return incrementTotal.subtract(decrementTotal).setScale(DECIMALS, ROUNDING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the net balance (see above) minus the sum of all authorization amounts which are not expired and were authorized by the as of date
|
||||
* @param finAccountId the financial account id
|
||||
* @param asOfDateTime the validity date
|
||||
* @param delegator the delegator
|
||||
* @return returns the net balance (see above) minus the sum of all authorization amounts which are not expired
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
/**
|
||||
* Returns the net balance (see above) minus the sum of all authorization amounts which are not expired and were authorized by the as of date
|
||||
*
|
||||
* @param finAccountId the financial account id
|
||||
* @param asOfDateTime the validity date
|
||||
* @param delegator the delegator
|
||||
* @return returns the net balance (see above) minus the sum of all authorization amounts which are not expired
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
public static BigDecimal getAvailableBalance(String finAccountId, Timestamp asOfDateTime, Delegator delegator) throws GenericEntityException {
|
||||
if (asOfDateTime == null) asOfDateTime = UtilDateTime.nowTimestamp();
|
||||
|
||||
@@ -242,9 +253,10 @@ public final class FinAccountHelper {
|
||||
|
||||
/**
|
||||
* Validates a FinAccount's PIN number
|
||||
* @param delegator the delegator
|
||||
*
|
||||
* @param delegator the delegator
|
||||
* @param finAccountId the financial account id
|
||||
* @param pinNumber a pin number
|
||||
* @param pinNumber a pin number
|
||||
* @return true if the bin is valid
|
||||
*/
|
||||
public static boolean validatePin(Delegator delegator, String finAccountId, String pinNumber) {
|
||||
@@ -269,9 +281,10 @@ public final class FinAccountHelper {
|
||||
|
||||
/**
|
||||
* Generate a random financial number
|
||||
*
|
||||
* @param delegator the delegator
|
||||
* @param length length of the number to generate (up to 19 digits)
|
||||
* @param isId to be used as an ID (will check the DB to make sure it doesn't already exist)
|
||||
* @param length length of the number to generate (up to 19 digits)
|
||||
* @param isId to be used as an ID (will check the DB to make sure it doesn't already exist)
|
||||
* @return Generated number
|
||||
* @throws GenericEntityException
|
||||
*/
|
||||
|
||||
+24
-24
@@ -53,24 +53,24 @@ public final class OrderChangeHelper {
|
||||
}
|
||||
|
||||
// interal status for held orders
|
||||
String HEADER_STATUS = "ORDER_PROCESSING";
|
||||
String ITEM_STATUS = "ITEM_CREATED";
|
||||
String DIGITAL_ITEM_STATUS = "ITEM_APPROVED";
|
||||
String headerStatus = "ORDER_PROCESSING";
|
||||
String itemStatus = "ITEM_CREATED";
|
||||
String digitalItemStatus = "ITEM_APPROVED";
|
||||
|
||||
if (!holdOrder) {
|
||||
if (productStore.get("headerApprovedStatus") != null) {
|
||||
HEADER_STATUS = productStore.getString("headerApprovedStatus");
|
||||
headerStatus = productStore.getString("headerApprovedStatus");
|
||||
}
|
||||
if (productStore.get("itemApprovedStatus") != null) {
|
||||
ITEM_STATUS = productStore.getString("itemApprovedStatus");
|
||||
itemStatus = productStore.getString("itemApprovedStatus");
|
||||
}
|
||||
if (productStore.get("digitalItemApprovedStatus") != null) {
|
||||
DIGITAL_ITEM_STATUS = productStore.getString("digitalItemApprovedStatus");
|
||||
digitalItemStatus = productStore.getString("digitalItemApprovedStatus");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
OrderChangeHelper.orderStatusChanges(dispatcher, userLogin, orderId, HEADER_STATUS, "ITEM_CREATED", ITEM_STATUS, DIGITAL_ITEM_STATUS);
|
||||
OrderChangeHelper.orderStatusChanges(dispatcher, userLogin, orderId, headerStatus, "ITEM_CREATED", itemStatus, digitalItemStatus);
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, "Service invocation error, status changes were not updated for order #" + orderId, MODULE);
|
||||
return false;
|
||||
@@ -81,17 +81,17 @@ public final class OrderChangeHelper {
|
||||
|
||||
public static boolean rejectOrder(LocalDispatcher dispatcher, GenericValue userLogin, String orderId) {
|
||||
GenericValue productStore = OrderReadHelper.getProductStoreFromOrder(dispatcher.getDelegator(), orderId);
|
||||
String HEADER_STATUS = "ORDER_REJECTED";
|
||||
String ITEM_STATUS = "ITEM_REJECTED";
|
||||
String headerStatus = "ORDER_REJECTED";
|
||||
String itemStatus = "ITEM_REJECTED";
|
||||
if (productStore.get("headerDeclinedStatus") != null) {
|
||||
HEADER_STATUS = productStore.getString("headerDeclinedStatus");
|
||||
}
|
||||
if (productStore.get("itemDeclinedStatus") != null) {
|
||||
ITEM_STATUS = productStore.getString("itemDeclinedStatus");
|
||||
}
|
||||
headerStatus = productStore.getString("headerDeclinedStatus");
|
||||
}
|
||||
if (productStore.get("itemDeclinedStatus") != null) {
|
||||
itemStatus = productStore.getString("itemDeclinedStatus");
|
||||
}
|
||||
|
||||
try {
|
||||
OrderChangeHelper.orderStatusChanges(dispatcher, userLogin, orderId, HEADER_STATUS, null, ITEM_STATUS, null);
|
||||
OrderChangeHelper.orderStatusChanges(dispatcher, userLogin, orderId, headerStatus, null, itemStatus, null);
|
||||
OrderChangeHelper.cancelInventoryReservations(dispatcher, userLogin, orderId);
|
||||
OrderChangeHelper.releasePaymentAuthorizations(dispatcher, userLogin, orderId);
|
||||
} catch (GenericServiceException e) {
|
||||
@@ -115,17 +115,17 @@ public final class OrderChangeHelper {
|
||||
|
||||
public static boolean cancelOrder(LocalDispatcher dispatcher, GenericValue userLogin, String orderId) {
|
||||
GenericValue productStore = OrderReadHelper.getProductStoreFromOrder(dispatcher.getDelegator(), orderId);
|
||||
String HEADER_STATUS = "ORDER_CANCELLED";
|
||||
String ITEM_STATUS = "ITEM_CANCELLED";
|
||||
String headerStatus = "ORDER_CANCELLED";
|
||||
String itemStatus = "ITEM_CANCELLED";
|
||||
if (productStore.get("headerCancelStatus") != null) {
|
||||
HEADER_STATUS = productStore.getString("headerCancelStatus");
|
||||
}
|
||||
if (productStore.get("itemCancelStatus") != null) {
|
||||
ITEM_STATUS = productStore.getString("itemCancelStatus");
|
||||
}
|
||||
headerStatus = productStore.getString("headerCancelStatus");
|
||||
}
|
||||
if (productStore.get("itemCancelStatus") != null) {
|
||||
itemStatus = productStore.getString("itemCancelStatus");
|
||||
}
|
||||
|
||||
try {
|
||||
OrderChangeHelper.orderStatusChanges(dispatcher, userLogin, orderId, HEADER_STATUS, null, ITEM_STATUS, null);
|
||||
OrderChangeHelper.orderStatusChanges(dispatcher, userLogin, orderId, headerStatus, null, itemStatus, null);
|
||||
OrderChangeHelper.cancelInventoryReservations(dispatcher, userLogin, orderId);
|
||||
OrderChangeHelper.releasePaymentAuthorizations(dispatcher, userLogin, orderId);
|
||||
} catch (GenericServiceException e) {
|
||||
@@ -266,7 +266,7 @@ public final class OrderChangeHelper {
|
||||
// only do this one time; if we have payment already for this pref ignore.
|
||||
Map<String, Object> results = dispatcher.runSync("createPaymentFromPreference",
|
||||
UtilMisc.<String, Object>toMap("userLogin", userLogin, "orderPaymentPreferenceId", opp.getString("orderPaymentPreferenceId"),
|
||||
"paymentRefNum", UtilDateTime.nowTimestamp().toString(), "paymentFromId", partyId));
|
||||
"paymentRefNum", UtilDateTime.nowTimestamp().toString(), "paymentFromId", partyId));
|
||||
if (ServiceUtil.isError(results)) {
|
||||
String errorMessage = ServiceUtil.getErrorMessage(results);
|
||||
Debug.logError(errorMessage, MODULE);
|
||||
|
||||
@@ -107,7 +107,7 @@ public class OrderEvents {
|
||||
String[] orderItemSeqIdAndOrderItemShipGrpId = selectedItem.split(":");
|
||||
String orderItemSeqId = orderItemSeqIdAndOrderItemShipGrpId[0];
|
||||
String shipGroupSeqId = orderItemSeqIdAndOrderItemShipGrpId[1];
|
||||
BigDecimal cancelQuantity = new BigDecimal(request.getParameter("iqm_"+orderItemSeqId+":"+shipGroupSeqId));
|
||||
BigDecimal cancelQuantity = new BigDecimal(request.getParameter("iqm_" + orderItemSeqId + ":" + shipGroupSeqId));
|
||||
Map<String, Object> contextMap = new HashMap<>();
|
||||
contextMap.put("orderId", orderId);
|
||||
contextMap.put("orderItemSeqId", orderItemSeqId);
|
||||
|
||||
@@ -254,7 +254,7 @@ public class OrderListState implements Serializable {
|
||||
typeConditions.add(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, parameterToOrderTypeId.get(type)));
|
||||
}
|
||||
|
||||
EntityCondition statusConditionsList = EntityCondition.makeCondition(statusConditions, EntityOperator.OR);
|
||||
EntityCondition statusConditionsList = EntityCondition.makeCondition(statusConditions, EntityOperator.OR);
|
||||
EntityCondition typeConditionsList = EntityCondition.makeCondition(typeConditions, EntityOperator.OR);
|
||||
if (statusConditions.size() > 0) {
|
||||
allConditions.add(statusConditionsList);
|
||||
|
||||
+1
-1
@@ -632,7 +632,7 @@ public class OrderLookupServices {
|
||||
result.put("viewSize", viewSize);
|
||||
result.put("showAll", showAll);
|
||||
|
||||
result.put("paramList", (paramString != null? paramString: ""));
|
||||
result.put("paramList", (paramString != null ? paramString : ""));
|
||||
result.put("orderList", orderList);
|
||||
result.put("orderListSize", orderCount);
|
||||
|
||||
|
||||
@@ -1220,7 +1220,7 @@ public class OrderReadHelper {
|
||||
itemInfo.put("productId", item.getString("productId"));
|
||||
itemInfo.put("quantity", getOrderItemQuantity(item));
|
||||
itemInfo.put("weight", this.getItemWeight(item));
|
||||
itemInfo.put("size", this.getItemSize(item));
|
||||
itemInfo.put("size", this.getItemSize(item));
|
||||
itemInfo.put("piecesIncluded", this.getItemPiecesIncluded(item));
|
||||
itemInfo.put("featureSet", this.getItemFeatureSet(item));
|
||||
return itemInfo;
|
||||
@@ -1540,7 +1540,7 @@ public class OrderReadHelper {
|
||||
return getOrderItemAdjustmentList(orderItem, getAdjustments());
|
||||
}
|
||||
|
||||
public String getCurrentOrderItemWorkEffort(GenericValue orderItem) {
|
||||
public String getCurrentOrderItemWorkEffort(GenericValue orderItem) {
|
||||
String orderItemSeqId = orderItem.getString("orderItemSeqId");
|
||||
String orderId = orderItem.getString("orderId");
|
||||
Delegator delegator = orderItem.getDelegator();
|
||||
@@ -2422,7 +2422,7 @@ public class OrderReadHelper {
|
||||
Iterator<GenericValue> weIter = UtilMisc.toIterator(workEfforts);
|
||||
while (weIter != null && weIter.hasNext()) {
|
||||
GenericValue workEffort = weIter.next();
|
||||
if (workEffort.getString("workEffortId").compareTo(orderItem.getString("orderItemSeqId")) == 0) {
|
||||
if (workEffort.getString("workEffortId").compareTo(orderItem.getString("orderItemSeqId")) == 0) {
|
||||
itemTotal = itemTotal.multiply(getWorkEffortRentalQuantity(workEffort)).setScale(DECIMALS, ROUNDING);
|
||||
break;
|
||||
}
|
||||
@@ -2490,7 +2490,7 @@ public class OrderReadHelper {
|
||||
while (itemIter != null && itemIter.hasNext()) {
|
||||
result = result.add(getOrderItemTotal(itemIter.next(), adjustments));
|
||||
}
|
||||
return result.setScale(DECIMALS, ROUNDING);
|
||||
return result.setScale(DECIMALS, ROUNDING);
|
||||
}
|
||||
|
||||
public static BigDecimal getOrderItemTotal(GenericValue orderItem, List<GenericValue> adjustments) {
|
||||
@@ -2543,7 +2543,7 @@ public class OrderReadHelper {
|
||||
}
|
||||
|
||||
BigDecimal rentalAdjustment = ZERO;
|
||||
if (persons.compareTo(BigDecimal.ONE) == 1) {
|
||||
if (persons.compareTo(BigDecimal.ONE) == 1) {
|
||||
if (persons.compareTo(new BigDecimal(2)) == 1) {
|
||||
persons = persons.subtract(new BigDecimal(2));
|
||||
if (nthPersonPerc.signum() == 1) {
|
||||
|
||||
+2
-2
@@ -836,7 +836,7 @@ public class OrderReturnServices {
|
||||
createAccountCtx.put("finAccountTypeId", "STORE_CREDIT_ACCT");
|
||||
createAccountCtx.put("productStoreId", productStore.getString("productStoreId"));
|
||||
createAccountCtx.put("currencyUomId", returnHeader.getString("currencyUomId"));
|
||||
createAccountCtx.put("finAccountName", "Store Credit Account for party ["+fromPartyId+"]");
|
||||
createAccountCtx.put("finAccountName", "Store Credit Account for party [" + fromPartyId + "]");
|
||||
createAccountCtx.put("userLogin", userLogin);
|
||||
Map<String, Object> createAccountResult = null;
|
||||
try {
|
||||
@@ -1751,7 +1751,7 @@ public class OrderReturnServices {
|
||||
orderMap.put("webSiteId", orderHeader.get("webSiteId"));
|
||||
orderMap.put("visitId", orderHeader.get("visitId"));
|
||||
orderMap.put("currencyUom", orderHeader.get("currencyUom"));
|
||||
orderMap.put("grandTotal", BigDecimal.ZERO);
|
||||
orderMap.put("grandTotal", BigDecimal.ZERO);
|
||||
|
||||
// make the contact mechs
|
||||
List<GenericValue> contactMechs = new LinkedList<>();
|
||||
|
||||
@@ -307,14 +307,14 @@ public class OrderServices {
|
||||
try {
|
||||
product = EntityQuery.use(delegator).from("Product").where("productId", currentProductId).cache().queryOne();
|
||||
} catch (GenericEntityException e) {
|
||||
String errMsg = UtilProperties.getMessage(RES_ERROR, "product.not_found", new Object[] { currentProductId }, locale);
|
||||
String errMsg = UtilProperties.getMessage(RES_ERROR, "product.not_found", new Object[] {currentProductId }, locale);
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
errorMessages.add(errMsg);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (product == null) {
|
||||
String errMsg = UtilProperties.getMessage(RES_ERROR, "product.not_found", new Object[] { currentProductId }, locale);
|
||||
String errMsg = UtilProperties.getMessage(RES_ERROR, "product.not_found", new Object[] {currentProductId }, locale);
|
||||
Debug.logError(errMsg, MODULE);
|
||||
errorMessages.add(errMsg);
|
||||
continue;
|
||||
@@ -359,7 +359,7 @@ public class OrderServices {
|
||||
errorMessages.addAll(errMsgList);
|
||||
} else if (!"Y".equals(invReqResult.get("availableOrNotRequired"))) {
|
||||
String invErrMsg = UtilProperties.getMessage(RES_ERROR, "product.out_of_stock",
|
||||
new Object[] { getProductName(product, itemName), currentProductId }, locale);
|
||||
new Object[] {getProductName(product, itemName), currentProductId }, locale);
|
||||
Debug.logWarning(invErrMsg, MODULE);
|
||||
errorMessages.add(invErrMsg);
|
||||
continue;
|
||||
@@ -377,8 +377,8 @@ public class OrderServices {
|
||||
for (GenericValue orderItem : orderItems) {
|
||||
if ("RENTAL_ORDER_ITEM".equals(orderItem.getString("orderItemTypeId"))) {
|
||||
// check to see if workefforts are available for this order type.
|
||||
if (UtilValidate.isEmpty(workEfforts)) {
|
||||
String errMsg = "Work Efforts missing for ordertype RENTAL_ORDER_ITEM " + "Product: " + orderItem.getString("productId");
|
||||
if (UtilValidate.isEmpty(workEfforts)) {
|
||||
String errMsg = "Work Efforts missing for ordertype RENTAL_ORDER_ITEM " + "Product: " + orderItem.getString("productId");
|
||||
Debug.logError(errMsg, MODULE);
|
||||
errorMessages.add(errMsg);
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
|
||||
@@ -387,7 +387,7 @@ public class OrderServices {
|
||||
for (GenericValue workEffort : workEfforts) {
|
||||
// find the related workEffortItem (workEffortId = orderSeqId)
|
||||
// create the entity maps required.
|
||||
if (workEffort.getString("workEffortId").equals(orderItem.getString("orderItemSeqId"))) {
|
||||
if (workEffort.getString("workEffortId").equals(orderItem.getString("orderItemSeqId"))) {
|
||||
List<GenericValue> selFixedAssetProduct = null;
|
||||
try {
|
||||
selFixedAssetProduct = EntityQuery.use(delegator).from("FixedAssetProduct").where("productId", orderItem.getString("productId"), "fixedAssetProductTypeId", "FAPT_USE").filterByDate(nowTimestamp, "fromDate", "thruDate").queryList();
|
||||
@@ -676,8 +676,7 @@ public class OrderServices {
|
||||
Debug.logInfo("find the fixedAsset", MODULE);
|
||||
try {
|
||||
fixedAsset = EntityQuery.use(delegator).from("FixedAsset").where("fixedAssetId", workEffort.get("fixedAssetId")).queryOne();
|
||||
}
|
||||
catch (GenericEntityException e) {
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
|
||||
"OrderFixedAssetNotFoundFixedAssetId",
|
||||
UtilMisc.toMap("fixedAssetId", workEffort.get("fixedAssetId")), locale));
|
||||
@@ -690,9 +689,9 @@ public class OrderServices {
|
||||
// see if this fixed asset has a calendar, when no create one and attach to fixed asset
|
||||
Debug.logInfo("find the techdatacalendar", MODULE);
|
||||
GenericValue techDataCalendar = null;
|
||||
try { techDataCalendar = fixedAsset.getRelatedOne("TechDataCalendar", false);
|
||||
}
|
||||
catch (GenericEntityException e) {
|
||||
try {
|
||||
techDataCalendar = fixedAsset.getRelatedOne("TechDataCalendar", false);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logInfo("TechData calendar does not exist yet so create for fixedAsset: " + fixedAsset.get("fixedAssetId"), MODULE);
|
||||
}
|
||||
if (techDataCalendar == null) {
|
||||
@@ -736,15 +735,14 @@ public class OrderServices {
|
||||
// please note that calendarId is the same for (TechData)Calendar, CalendarExcDay and CalendarExWeek
|
||||
Timestamp estimatedStartDate = workEffort.getTimestamp("estimatedStartDate");
|
||||
Timestamp estimatedCompletionDate = workEffort.getTimestamp("estimatedCompletionDate");
|
||||
long dayCount = (estimatedCompletionDate.getTime() - estimatedStartDate.getTime())/86400000;
|
||||
while (--dayCount >= 0) {
|
||||
long dayCount = (estimatedCompletionDate.getTime() - estimatedStartDate.getTime()) / 86400000;
|
||||
while (--dayCount >= 0) {
|
||||
GenericValue techDataCalendarExcDay = null;
|
||||
// find an existing Day exception record
|
||||
Timestamp exceptionDateStartTime = UtilDateTime.getDayStart(new Timestamp(estimatedStartDate.getTime()), (int) dayCount);
|
||||
try {
|
||||
techDataCalendarExcDay = EntityQuery.use(delegator).from("TechDataCalendarExcDay").where("calendarId", fixedAsset.get("calendarId"), "exceptionDateStartTime", exceptionDateStartTime).queryOne();
|
||||
}
|
||||
catch (GenericEntityException e) {
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logInfo(" techData excday record not found so creating........", MODULE);
|
||||
}
|
||||
if (techDataCalendarExcDay == null) {
|
||||
@@ -756,7 +754,7 @@ public class OrderServices {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (techDataCalendarExcDay == null) {
|
||||
if (techDataCalendarExcDay == null) {
|
||||
techDataCalendarExcDay = delegator.makeValue("TechDataCalendarExcDay");
|
||||
techDataCalendarExcDay.set("calendarId", fixedAsset.get("calendarId"));
|
||||
techDataCalendarExcDay.set("exceptionDateStartTime", exceptionDateStartTime);
|
||||
@@ -766,8 +764,8 @@ public class OrderServices {
|
||||
// add the quantity to the quantity on the date record
|
||||
BigDecimal newUsedCapacity = techDataCalendarExcDay.getBigDecimal("usedCapacity").add(workEffort.getBigDecimal("quantityToProduce"));
|
||||
// check to see if the requested quantity is available on the requested day but only when the maximum capacity is set on the fixed asset
|
||||
if (fixedAsset.get("productionCapacity") != null) {
|
||||
if (newUsedCapacity.compareTo(techDataCalendarExcDay.getBigDecimal("exceptionCapacity")) > 0) {
|
||||
if (fixedAsset.get("productionCapacity") != null) {
|
||||
if (newUsedCapacity.compareTo(techDataCalendarExcDay.getBigDecimal("exceptionCapacity")) > 0) {
|
||||
String errMsg = UtilProperties.getMessage(RES_ERROR, "OrderFixedAssetSoldOut", UtilMisc.toMap("fixedAssetId", workEffort.get("fixedAssetId"), "exceptionDateStartTime", techDataCalendarExcDay.getString("exceptionDateStartTime")), locale);
|
||||
Debug.logError(errMsg, MODULE);
|
||||
errorMessages.add(errMsg);
|
||||
@@ -1015,25 +1013,25 @@ public class OrderServices {
|
||||
|
||||
// store the OrderTerm entities
|
||||
|
||||
List<GenericValue> orderTerms = UtilGenerics.cast(context.get("orderTerms"));
|
||||
if (UtilValidate.isNotEmpty(orderTerms)) {
|
||||
for (GenericValue orderTerm : orderTerms) {
|
||||
orderTerm.set("orderId", orderId);
|
||||
if (orderTerm.get("orderItemSeqId") == null) {
|
||||
orderTerm.set("orderItemSeqId", "_NA_");
|
||||
}
|
||||
toBeStored.add(orderTerm);
|
||||
}
|
||||
}
|
||||
List<GenericValue> orderTerms = UtilGenerics.cast(context.get("orderTerms"));
|
||||
if (UtilValidate.isNotEmpty(orderTerms)) {
|
||||
for (GenericValue orderTerm : orderTerms) {
|
||||
orderTerm.set("orderId", orderId);
|
||||
if (orderTerm.get("orderItemSeqId") == null) {
|
||||
orderTerm.set("orderItemSeqId", "_NA_");
|
||||
}
|
||||
toBeStored.add(orderTerm);
|
||||
}
|
||||
}
|
||||
|
||||
// if a workEffortId is passed, then prepare a OrderHeaderWorkEffort value
|
||||
String workEffortId = (String) context.get("workEffortId");
|
||||
if (UtilValidate.isNotEmpty(workEffortId)) {
|
||||
GenericValue orderHeaderWorkEffort = delegator.makeValue("OrderHeaderWorkEffort");
|
||||
orderHeaderWorkEffort.set("orderId", orderId);
|
||||
orderHeaderWorkEffort.set("workEffortId", workEffortId);
|
||||
toBeStored.add(orderHeaderWorkEffort);
|
||||
}
|
||||
// if a workEffortId is passed, then prepare a OrderHeaderWorkEffort value
|
||||
String workEffortId = (String) context.get("workEffortId");
|
||||
if (UtilValidate.isNotEmpty(workEffortId)) {
|
||||
GenericValue orderHeaderWorkEffort = delegator.makeValue("OrderHeaderWorkEffort");
|
||||
orderHeaderWorkEffort.set("orderId", orderId);
|
||||
orderHeaderWorkEffort.set("workEffortId", workEffortId);
|
||||
toBeStored.add(orderHeaderWorkEffort);
|
||||
}
|
||||
|
||||
try {
|
||||
// store line items, etc so that they will be there for the foreign key checks
|
||||
@@ -1467,7 +1465,7 @@ public class OrderServices {
|
||||
Debug.logError(e, errorMessage, MODULE);
|
||||
return ServiceUtil.returnError(errorMessage + e.getMessage() + ").");
|
||||
}
|
||||
showPricesWithVatTax = productStore.getString("showPricesWithVatTax");
|
||||
showPricesWithVatTax = productStore.getString("showPricesWithVatTax");
|
||||
}
|
||||
BigDecimal remainingSubTotal = ZERO;
|
||||
if (UtilValidate.isNotEmpty(productStoreId) && "Y".equalsIgnoreCase(showPricesWithVatTax)) {
|
||||
@@ -1958,7 +1956,7 @@ 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);
|
||||
}
|
||||
@@ -2021,7 +2019,7 @@ public class OrderServices {
|
||||
Map<String, String> itemCommentMap = UtilGenerics.cast(context.get("itemCommentMap"));
|
||||
Map<String, String> itemQuantityMap = UtilGenerics.cast(context.get("itemQtyMap"));
|
||||
if ((cancelQuantity == null) && UtilValidate.isNotEmpty(itemQuantityMap)) {
|
||||
String key = orderItemSeqId+":"+shipGroupSeqId;
|
||||
String key = orderItemSeqId + ":" + shipGroupSeqId;
|
||||
if (UtilValidate.isNotEmpty(itemQuantityMap.get(key))) {
|
||||
cancelQuantity = new BigDecimal(itemQuantityMap.get(key));
|
||||
}
|
||||
@@ -2098,7 +2096,7 @@ public class OrderServices {
|
||||
itemQuantity = itemQuantity.subtract(receivedQty);
|
||||
} else {
|
||||
BigDecimal shippedQty = orh.getItemShippedQuantity(orderItem);
|
||||
if (shippedQty.compareTo(BigDecimal.ZERO) > 0 ) {
|
||||
if (shippedQty.compareTo(BigDecimal.ZERO) > 0) {
|
||||
itemStatus = "ITEM_COMPLETED";
|
||||
}
|
||||
itemQuantity = itemQuantity.subtract(shippedQty);
|
||||
@@ -2178,8 +2176,8 @@ public class OrderServices {
|
||||
try {
|
||||
BigDecimal quantity = thisCancelQty.setScale(1, ROUNDING);
|
||||
String cancelledItemToOrder = UtilProperties.getMessage(RESOURCE, "OrderCancelledItemToOrder", locale);
|
||||
resp = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", cancelledItemToOrder +
|
||||
orderItem.getString("productId") + " (" + quantity + ")", "internalNote", "Y", "userLogin", userLogin));
|
||||
resp = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", cancelledItemToOrder
|
||||
+ orderItem.getString("productId") + " (" + quantity + ")", "internalNote", "Y", "userLogin", userLogin));
|
||||
if (ServiceUtil.isError(resp)) {
|
||||
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resp));
|
||||
}
|
||||
@@ -3620,7 +3618,7 @@ public class OrderServices {
|
||||
if (itemAttributesMap != null) {
|
||||
// go through the item attributes map once to get a list of key names
|
||||
Set<String> attributeNames = new HashSet<>();
|
||||
Set<String> keys = itemAttributesMap.keySet();
|
||||
Set<String> keys = itemAttributesMap.keySet();
|
||||
for (String key : keys) {
|
||||
attributeNames.add(key);
|
||||
}
|
||||
@@ -3650,8 +3648,8 @@ public class OrderServices {
|
||||
// log an order note
|
||||
try {
|
||||
String addedItemToOrder = UtilProperties.getMessage(RESOURCE, "OrderAddedItemToOrder", locale);
|
||||
Map<String, Object> result = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", addedItemToOrder +
|
||||
productId + " (" + quantity + ")", "internalNote", "Y", "userLogin", userLogin));
|
||||
Map<String, Object> result = dispatcher.runSync("createOrderNote", UtilMisc.<String, Object>toMap("orderId", orderId, "note", addedItemToOrder
|
||||
+ productId + " (" + quantity + ")", "internalNote", "Y", "userLogin", userLogin));
|
||||
if (ServiceUtil.isError(result)) {
|
||||
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
|
||||
}
|
||||
@@ -3801,7 +3799,7 @@ public class OrderServices {
|
||||
if (itemAttributesMap != null) {
|
||||
// go through the item attributes map once to get a list of key names
|
||||
Set<String> attributeNames = new HashSet<>();
|
||||
Set<String> keys = itemAttributesMap.keySet();
|
||||
Set<String> keys = itemAttributesMap.keySet();
|
||||
for (String key : keys) {
|
||||
String[] attributeInfo = key.split(":");
|
||||
attributeNames.add(attributeInfo[0]);
|
||||
@@ -4665,15 +4663,15 @@ public class OrderServices {
|
||||
// create the payment
|
||||
Map<String, Object> paymentParams = new HashMap<>();
|
||||
BigDecimal maxAmount = orderPaymentPreference.getBigDecimal("maxAmount");
|
||||
paymentParams.put("paymentTypeId", "CUSTOMER_PAYMENT");
|
||||
paymentParams.put("paymentMethodTypeId", orderPaymentPreference.getString("paymentMethodTypeId"));
|
||||
paymentParams.put("paymentPreferenceId", orderPaymentPreference.getString("orderPaymentPreferenceId"));
|
||||
paymentParams.put("amount", maxAmount);
|
||||
paymentParams.put("statusId", "PMNT_RECEIVED");
|
||||
paymentParams.put("effectiveDate", eventDate);
|
||||
paymentParams.put("partyIdFrom", paymentFromId);
|
||||
paymentParams.put("currencyUomId", productStore.getString("defaultCurrencyUomId"));
|
||||
paymentParams.put("partyIdTo", payToPartyId);
|
||||
paymentParams.put("paymentTypeId", "CUSTOMER_PAYMENT");
|
||||
paymentParams.put("paymentMethodTypeId", orderPaymentPreference.getString("paymentMethodTypeId"));
|
||||
paymentParams.put("paymentPreferenceId", orderPaymentPreference.getString("orderPaymentPreferenceId"));
|
||||
paymentParams.put("amount", maxAmount);
|
||||
paymentParams.put("statusId", "PMNT_RECEIVED");
|
||||
paymentParams.put("effectiveDate", eventDate);
|
||||
paymentParams.put("partyIdFrom", paymentFromId);
|
||||
paymentParams.put("currencyUomId", productStore.getString("defaultCurrencyUomId"));
|
||||
paymentParams.put("partyIdTo", payToPartyId);
|
||||
if (paymentRefNum != null) {
|
||||
paymentParams.put("paymentRefNum", paymentRefNum);
|
||||
}
|
||||
@@ -6036,8 +6034,7 @@ public class OrderServices {
|
||||
if (rowCountInt == rowNumberInt - 1) {
|
||||
try {
|
||||
message = validateOrderItemShipGroupAssoc(delegator, dispatcher, orderItem, totalQuantity, oisga, userLogin, locale);
|
||||
}
|
||||
catch (GeneralException e) {
|
||||
} catch (GeneralException e) {
|
||||
String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderQuantityAssociatedIsLessThanOrderItemQuantity", locale);
|
||||
Debug.logError(errMsg, MODULE);
|
||||
return ServiceUtil.returnError(errMsg);
|
||||
@@ -6049,20 +6046,21 @@ public class OrderServices {
|
||||
result.put(ModelService.SUCCESS_MESSAGE, message);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
BigDecimal actualQuantity = totalQuantity.add(quantity);
|
||||
BigDecimal qty = (BigDecimal) orderItem.get("quantity");
|
||||
if (UtilValidate.isEmpty(qty)) {
|
||||
qty = BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal cancelQty = (BigDecimal) orderItem.get("cancelQuantity");
|
||||
if (UtilValidate.isEmpty(cancelQty)) {
|
||||
cancelQty = BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal orderItemQuantity = qty.subtract(cancelQty);
|
||||
BigDecimal actualQuantity = totalQuantity.add(quantity);
|
||||
BigDecimal qty = (BigDecimal) orderItem.get("quantity");
|
||||
if (UtilValidate.isEmpty(qty)) {
|
||||
qty = BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal cancelQty = (BigDecimal) orderItem.get("cancelQuantity");
|
||||
if (UtilValidate.isEmpty(cancelQty)) {
|
||||
cancelQty = BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal orderItemQuantity = qty.subtract(cancelQty);
|
||||
if (actualQuantity.compareTo(orderItemQuantity) > 0) {
|
||||
String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderQuantityAssociatedIsBiggerThanOrderItemQuantity", locale);
|
||||
String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderQuantityAssociatedIsBiggerThanOrderItemQuantity",
|
||||
locale);
|
||||
Debug.logError(errMsg, MODULE);
|
||||
return ServiceUtil.returnError(errMsg);
|
||||
}
|
||||
@@ -6102,9 +6100,8 @@ public class OrderServices {
|
||||
int rowNumberInt = rowNumber;
|
||||
if (rowCountInt == rowNumberInt - 1) {
|
||||
try {
|
||||
message = validateOrderItemShipGroupAssoc(delegator, dispatcher, orderItem, totalQuantity, oisga, userLogin, locale);
|
||||
}
|
||||
catch (GeneralException e) {
|
||||
message = validateOrderItemShipGroupAssoc(delegator, dispatcher, orderItem, totalQuantity, oisga, userLogin, locale);
|
||||
} catch (GeneralException e) {
|
||||
String errMsg = mainErrorMessage + UtilProperties.getMessage(RES_ERROR, "OrderQuantityAssociatedIsLessThanOrderItemQuantity", locale);
|
||||
Debug.logError(errMsg, MODULE);
|
||||
return ServiceUtil.returnError(errMsg);
|
||||
@@ -6380,7 +6377,7 @@ public class OrderServices {
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
String orderId = (String) context.get("orderId");
|
||||
String shipGroupSeqId = (String) context.get("shipGroupSeqId");
|
||||
String contactMechId = (String) context.get("contactMechId");
|
||||
@@ -6446,8 +6443,8 @@ public class OrderServices {
|
||||
shoppingCart.setShipmentMethodTypeId(groupIdx - 1, shippingMethods.get(0).getString("shipmentMethodTypeId"));
|
||||
shoppingCart.setCarrierPartyId(groupIdx - 1, shippingMethods.get(0).getString("carrierPartyId"));
|
||||
|
||||
String newShipMethTypeDesc =null;
|
||||
String shipMethTypeDesc=null;
|
||||
String newShipMethTypeDesc = null;
|
||||
String shipMethTypeDesc = null;
|
||||
try {
|
||||
shipMethTypeDesc = EntityQuery.use(delegator).from("ShipmentMethodType").where("shipmentMethodTypeId", shipmentMethodTypeId).queryOne().getString("description");
|
||||
newShipMethTypeDesc = EntityQuery.use(delegator).from("ShipmentMethodType").where("shipmentMethodTypeId", shippingMethods.get(0).getString("shipmentMethodTypeId")).queryOne().getString("description");
|
||||
@@ -6455,7 +6452,7 @@ public class OrderServices {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
// message to notify user for not applicability of shipping method
|
||||
message= "Shipping Method "+carrierPartyId+" "+shipMethTypeDesc+" is not applicable to shipping address. "+shippingMethods.get(0).getString("carrierPartyId")+" "+newShipMethTypeDesc+" has been set for shipping address.";
|
||||
message = "Shipping Method " + carrierPartyId + " " + shipMethTypeDesc + " is not applicable to shipping address. " + shippingMethods.get(0).getString("carrierPartyId") + " " + newShipMethTypeDesc + " has been set for shipping address.";
|
||||
}
|
||||
shoppingCart.setShippingContactMechId(groupIdx-1, contactMechId);
|
||||
}
|
||||
@@ -6478,7 +6475,7 @@ public class OrderServices {
|
||||
public static Map<String, Object> associateOrderWithAllocationPlans(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
String orderId = (String) context.get("orderId");
|
||||
Map<String, String> productPlanMap = new HashMap<>();
|
||||
Map<String, Object> serviceResult = new HashMap<>();
|
||||
@@ -6513,7 +6510,7 @@ public class OrderServices {
|
||||
serviceCtx.put("planId", planId);
|
||||
serviceCtx.put("productId", productId);
|
||||
serviceCtx.put("planTypeId", "SALES_ORD_ALLOCATION");
|
||||
serviceCtx.put("planName", "Allocation Plan For Product #"+productId);
|
||||
serviceCtx.put("planName", "Allocation Plan For Product #" + productId);
|
||||
serviceCtx.put("statusId", "ALLOC_PLAN_CREATED");
|
||||
serviceCtx.put("createdByUserLogin", userLoginId);
|
||||
serviceCtx.put("userLogin", userLogin);
|
||||
@@ -6597,7 +6594,7 @@ public class OrderServices {
|
||||
public static Map<String, Object> approveAllocationPlanItems(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
String planId = (String) context.get("planId");
|
||||
Map<String, Object> serviceCtx = new HashMap<>();
|
||||
Map<String, Object> serviceResult = new HashMap<>();
|
||||
@@ -6661,7 +6658,7 @@ public class OrderServices {
|
||||
public static Map<String, Object> cancelAllocationPlanItems(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
String planId = (String) context.get("planId");
|
||||
Map<String, Object> serviceCtx = new HashMap<>();
|
||||
Map<String, Object> serviceResult = new HashMap<>();
|
||||
@@ -6698,7 +6695,7 @@ public class OrderServices {
|
||||
public static Map<String, Object> changeAllocationPlanStatus(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
String planId = (String) context.get("planId");
|
||||
String statusId = (String) context.get("statusId");
|
||||
@@ -6749,7 +6746,7 @@ public class OrderServices {
|
||||
public static Map<String, Object> changeAllocationPlanItemStatus(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
String planId = (String) context.get("planId");
|
||||
String planItemSeqId = (String) context.get("planItemSeqId");
|
||||
@@ -6799,7 +6796,7 @@ public class OrderServices {
|
||||
public static Map<String, Object> completeAllocationPlanItemByOrderItem(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
String orderId = (String) context.get("orderId");
|
||||
String orderItemSeqId = (String) context.get("orderItemSeqId");
|
||||
try {
|
||||
@@ -6865,7 +6862,7 @@ public class OrderServices {
|
||||
public static Map<String, Object> cancelAllocationPlanItemByOrderItem(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
String orderId = (String) context.get("orderId");
|
||||
String orderItemSeqId = (String) context.get("orderItemSeqId");
|
||||
try {
|
||||
@@ -6930,7 +6927,7 @@ public class OrderServices {
|
||||
public static Map<String, Object> updateAllocatedQuantityOnOrderItemChange(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
String orderId = (String) context.get("orderId");
|
||||
try {
|
||||
OrderReadHelper orderReadHelper = new OrderReadHelper(delegator, orderId);
|
||||
@@ -6977,7 +6974,7 @@ public class OrderServices {
|
||||
public static Map<String, Object> createAllocationPlanAndItems(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
String productId = (String) context.get("productId");
|
||||
Integer itemListSize = (Integer) context.get("itemListSize");
|
||||
|
||||
+1
-1
@@ -891,7 +891,7 @@ public class CheckOutEvents {
|
||||
//See whether we need to return an error or not
|
||||
callResult = ServiceUtil.returnSuccess();
|
||||
if (errorMessages.size() > 0) {
|
||||
callResult.put(ModelService.ERROR_MESSAGE_LIST, errorMessages);
|
||||
callResult.put(ModelService.ERROR_MESSAGE_LIST, errorMessages);
|
||||
callResult.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
|
||||
}
|
||||
if (errorMaps.size() > 0) {
|
||||
|
||||
+53
-49
@@ -366,27 +366,27 @@ public class CheckOutHelper {
|
||||
}
|
||||
|
||||
public Map<String, Object> setCheckOutDates(Timestamp shipBefore, Timestamp shipAfter) {
|
||||
List<String> errorMessages = new ArrayList<>();
|
||||
Map<String, Object> result = null;
|
||||
String errMsg = null;
|
||||
List<String> errorMessages = new ArrayList<>();
|
||||
Map<String, Object> result = null;
|
||||
String errMsg = null;
|
||||
|
||||
if (UtilValidate.isNotEmpty(this.cart)) {
|
||||
this.cart.setShipBeforeDate(shipBefore);
|
||||
this.cart.setShipAfterDate(shipAfter);
|
||||
} else {
|
||||
errMsg = UtilProperties.getMessage(RES_ERROR, "checkhelper.no_items_in_cart",
|
||||
(cart != null ? cart.getLocale() : Locale.getDefault()));
|
||||
errorMessages.add(errMsg);
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(this.cart)) {
|
||||
this.cart.setShipBeforeDate(shipBefore);
|
||||
this.cart.setShipAfterDate(shipAfter);
|
||||
} else {
|
||||
errMsg = UtilProperties.getMessage(RES_ERROR, "checkhelper.no_items_in_cart",
|
||||
(cart != null ? cart.getLocale() : Locale.getDefault()));
|
||||
errorMessages.add(errMsg);
|
||||
}
|
||||
|
||||
if (errorMessages.size() == 1) {
|
||||
result = ServiceUtil.returnError(errorMessages.get(0));
|
||||
} else if (errorMessages.size() > 0) {
|
||||
result = ServiceUtil.returnError(errorMessages);
|
||||
} else {
|
||||
result = ServiceUtil.returnSuccess();
|
||||
}
|
||||
return result;
|
||||
if (errorMessages.size() == 1) {
|
||||
result = ServiceUtil.returnError(errorMessages.get(0));
|
||||
} else if (errorMessages.size() > 0) {
|
||||
result = ServiceUtil.returnError(errorMessages);
|
||||
} else {
|
||||
result = ServiceUtil.returnSuccess();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -950,11 +950,11 @@ public class CheckOutHelper {
|
||||
|
||||
public static Map<String, Object> processPayment(String orderId, BigDecimal orderTotal, String currencyUomId, GenericValue productStore, GenericValue userLogin, boolean faceToFace, boolean manualHold, LocalDispatcher dispatcher, Delegator delegator) throws GeneralException {
|
||||
// Get some payment related strings
|
||||
String DECLINE_MESSAGE = productStore.getString("authDeclinedMessage");
|
||||
String ERROR_MESSAGE = productStore.getString("authErrorMessage");
|
||||
String RETRY_ON_ERROR = productStore.getString("retryFailedAuths");
|
||||
if (RETRY_ON_ERROR == null) {
|
||||
RETRY_ON_ERROR = "Y";
|
||||
String declineMessage = productStore.getString("authDeclinedMessage");
|
||||
String errMessage = productStore.getString("authErrorMessage");
|
||||
String retryOnError = productStore.getString("retryFailedAuths");
|
||||
if (retryOnError == null) {
|
||||
retryOnError = "Y";
|
||||
}
|
||||
|
||||
List<GenericValue> allPaymentPreferences = null;
|
||||
@@ -1033,6 +1033,8 @@ public class CheckOutHelper {
|
||||
|
||||
// Check the payment preferences; if we have ANY w/ status PAYMENT_NOT_AUTH invoke payment service.
|
||||
// Invoke payment processing.
|
||||
Debug.log("==========allPaymentPreferences=======" + allPaymentPreferences);
|
||||
Debug.log("==========onlinePaymentPrefs=======" + onlinePaymentPrefs);
|
||||
if (UtilValidate.isNotEmpty(onlinePaymentPrefs)) {
|
||||
boolean autoApproveOrder = UtilValidate.isEmpty(productStore.get("autoApproveOrder")) || "Y".equalsIgnoreCase(productStore.getString("autoApproveOrder"));
|
||||
if (orderTotal.compareTo(BigDecimal.ZERO) == 0 && autoApproveOrder) {
|
||||
@@ -1078,7 +1080,7 @@ public class CheckOutHelper {
|
||||
throw new GeneralException("Problem with order change; see above error");
|
||||
}
|
||||
if (UtilValidate.isEmpty(messages)) {
|
||||
return ServiceUtil.returnError(DECLINE_MESSAGE);
|
||||
return ServiceUtil.returnError(declineMessage);
|
||||
}
|
||||
return ServiceUtil.returnError(messages);
|
||||
} else if ("APPROVED".equals(authResp)) {
|
||||
@@ -1119,16 +1121,16 @@ public class CheckOutHelper {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Payment auth failed due to processor trouble.", MODULE);
|
||||
}
|
||||
if (!faceToFace && "Y".equalsIgnoreCase(RETRY_ON_ERROR)) {
|
||||
if (!faceToFace && "Y".equalsIgnoreCase(retryOnError)) {
|
||||
// never do this for a face to face purchase regardless of store setting
|
||||
return ServiceUtil.returnSuccess(ERROR_MESSAGE);
|
||||
return ServiceUtil.returnSuccess(errMessage);
|
||||
}
|
||||
boolean ok = OrderChangeHelper.cancelOrder(dispatcher, userLogin, orderId);
|
||||
if (!ok) {
|
||||
throw new GeneralException("Problem with order change; see above error");
|
||||
}
|
||||
if (UtilValidate.isEmpty(messages)) {
|
||||
return ServiceUtil.returnError(ERROR_MESSAGE);
|
||||
return ServiceUtil.returnError(errMessage);
|
||||
}
|
||||
return ServiceUtil.returnError(messages);
|
||||
} else {
|
||||
@@ -1140,15 +1142,15 @@ public class CheckOutHelper {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Payment auth failed due to processor trouble.", MODULE);
|
||||
}
|
||||
if (!faceToFace && "Y".equalsIgnoreCase(RETRY_ON_ERROR)) {
|
||||
if (!faceToFace && "Y".equalsIgnoreCase(retryOnError)) {
|
||||
// never do this for a face to face purchase regardless of store setting
|
||||
return ServiceUtil.returnSuccess(ERROR_MESSAGE);
|
||||
return ServiceUtil.returnSuccess(errMessage);
|
||||
}
|
||||
boolean ok = OrderChangeHelper.cancelOrder(dispatcher, userLogin, orderId);
|
||||
if (!ok) {
|
||||
throw new GeneralException("Problem with order change; see above error");
|
||||
}
|
||||
return ServiceUtil.returnError(ERROR_MESSAGE);
|
||||
return ServiceUtil.returnError(errMessage);
|
||||
}
|
||||
} else {
|
||||
// Get the paymentMethodTypeIds - this will need to change when ecom supports multiple payments
|
||||
@@ -1158,6 +1160,7 @@ public class CheckOutHelper {
|
||||
EntityCondition.makeCondition("paymentMethodTypeId", EntityOperator.EQUALS, "EXT_BILLACT"));
|
||||
List<GenericValue> cashCodPcBaPaymentPreferences = EntityUtil.filterByOr(allPaymentPreferences, cashCodPcBaExpr);
|
||||
|
||||
Debug.log("==========cashCodPcBaPaymentPreferences=======" + cashCodPcBaPaymentPreferences);
|
||||
if (UtilValidate.isNotEmpty(cashCodPcBaPaymentPreferences)
|
||||
&& UtilValidate.isNotEmpty(allPaymentPreferences)
|
||||
&& cashCodPcBaPaymentPreferences.size() == allPaymentPreferences.size()) {
|
||||
@@ -1472,31 +1475,32 @@ public class CheckOutHelper {
|
||||
|
||||
// set ship before date
|
||||
if ((shipBeforeDate != null) && (shipBeforeDate.length() > 8)) {
|
||||
shipBeforeDate = shipBeforeDate.trim();
|
||||
if (shipBeforeDate.length() < 14) {
|
||||
shipBeforeDate = shipBeforeDate + " " + "00:00:00.000";
|
||||
}
|
||||
shipBeforeDate = shipBeforeDate.trim();
|
||||
if (shipBeforeDate.length() < 14) {
|
||||
shipBeforeDate = shipBeforeDate + " " + "00:00:00.000";
|
||||
}
|
||||
|
||||
try {
|
||||
this.cart.setShipBeforeDate(shipGroupIndex, (Timestamp) ObjectType.simpleTypeOrObjectConvert(shipBeforeDate, "Timestamp", null, null));
|
||||
} catch (Exception e) {
|
||||
errMsg = "Ship Before Date must be a valid date formed ";
|
||||
result = ServiceUtil.returnError(errMsg);
|
||||
}
|
||||
try {
|
||||
this.cart.setShipBeforeDate(shipGroupIndex, (Timestamp) ObjectType.simpleTypeOrObjectConvert(shipBeforeDate, "Timestamp", null,
|
||||
null));
|
||||
} catch (Exception e) {
|
||||
errMsg = "Ship Before Date must be a valid date formed ";
|
||||
result = ServiceUtil.returnError(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
// set ship after date
|
||||
if ((shipAfterDate != null) && (shipAfterDate.length() > 8)) {
|
||||
shipAfterDate = shipAfterDate.trim();
|
||||
if (shipAfterDate.length() < 14) {
|
||||
shipAfterDate = shipAfterDate + " " + "00:00:00.000";
|
||||
}
|
||||
shipAfterDate = shipAfterDate.trim();
|
||||
if (shipAfterDate.length() < 14) {
|
||||
shipAfterDate = shipAfterDate + " " + "00:00:00.000";
|
||||
}
|
||||
|
||||
try {
|
||||
this.cart.setShipAfterDate(shipGroupIndex, (Timestamp) ObjectType.simpleTypeOrObjectConvert(shipAfterDate, "Timestamp", null, null));
|
||||
try {
|
||||
this.cart.setShipAfterDate(shipGroupIndex, (Timestamp) ObjectType.simpleTypeOrObjectConvert(shipAfterDate, "Timestamp", null, null));
|
||||
} catch (Exception e) {
|
||||
errMsg = "Ship After Date must be a valid date formed ";
|
||||
result = ServiceUtil.returnError(errMsg);
|
||||
errMsg = "Ship After Date must be a valid date formed ";
|
||||
result = ServiceUtil.returnError(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+146
-89
@@ -587,11 +587,12 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
if (supplierProduct != null && supplierProduct.getBigDecimal("lastPrice") != null) {
|
||||
sci.setSupplierProductId(supplierProduct.getString("supplierProductId"));
|
||||
sci.setBasePrice(supplierProduct.getBigDecimal("lastPrice"));
|
||||
sci.setName(ShoppingCartItem.getPurchaseOrderItemDescription(sci.getProduct(), supplierProduct, this.getLocale(), dispatcher));
|
||||
sci.setName(ShoppingCartItem.getPurchaseOrderItemDescription(sci.getProduct(), supplierProduct, this.getLocale(),
|
||||
dispatcher));
|
||||
} else {
|
||||
throw new CartItemModifyException("SupplierProduct not found");
|
||||
throw new CartItemModifyException("SupplierProduct not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -600,7 +601,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
if ("PURCHASE_ORDER".equals(getOrderType())) {
|
||||
supplierProduct = getSupplierProduct(productId, quantity, dispatcher);
|
||||
if (supplierProduct != null || "_NA_".equals(this.getPartyId())) {
|
||||
item = ShoppingCartItem.makePurchaseOrderItem(0, productId, selectedAmount, quantity, features, attributes, prodCatalogId, configWrapper, itemType, itemGroup, dispatcher, this, supplierProduct, shipBeforeDate, shipAfterDate, cancelBackOrderDate);
|
||||
item = ShoppingCartItem.makePurchaseOrderItem(0, productId, selectedAmount, quantity, features, attributes, prodCatalogId,
|
||||
configWrapper, itemType, itemGroup, dispatcher, this, supplierProduct, shipBeforeDate, shipAfterDate, cancelBackOrderDate);
|
||||
} else {
|
||||
throw new CartItemModifyException("SupplierProduct not found");
|
||||
}
|
||||
@@ -664,55 +666,105 @@ 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, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher,
|
||||
Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
|
||||
HashMap<String, Object> attributes, String prodCatalogId, String itemType, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher,
|
||||
Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
|
||||
return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, null, null, null, null, null, features,
|
||||
attributes, prodCatalogId, configWrapper, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null,
|
||||
Boolean.FALSE, Boolean.FALSE));
|
||||
}
|
||||
|
||||
/** Add an item to the shopping cart. */
|
||||
/**
|
||||
* 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 {
|
||||
return addItemToEnd(productId, amount, quantity, unitPrice, features, attributes, prodCatalogId, itemType, dispatcher, triggerExternalOps, triggerPriceRules, Boolean.FALSE, Boolean.FALSE);
|
||||
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);
|
||||
}
|
||||
|
||||
/** 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 {
|
||||
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));
|
||||
}
|
||||
|
||||
/** 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 {
|
||||
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));
|
||||
}
|
||||
|
||||
/** 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 {
|
||||
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));
|
||||
}
|
||||
|
||||
/** 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, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
|
||||
return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, Boolean.FALSE, Boolean.FALSE));
|
||||
}
|
||||
|
||||
/** 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, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
|
||||
return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
|
||||
}
|
||||
|
||||
/** Add an accommodation(rental/aggregated)item to the shopping cart. */
|
||||
/**
|
||||
* Add an (rental)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, 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, triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
|
||||
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));
|
||||
}
|
||||
|
||||
/** 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 {
|
||||
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));
|
||||
/**
|
||||
* 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 {
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
, Boolean triggerExternalOps, Boolean triggerPriceRules) throws CartItemModifyException, ItemNotFoundException {
|
||||
return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons,
|
||||
accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this,
|
||||
triggerExternalOps, triggerPriceRules, null, Boolean.FALSE, Boolean.FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
, Boolean triggerExternalOps, Boolean triggerPriceRules, Boolean skipInventoryChecks, Boolean skipProductChecks) throws CartItemModifyException, ItemNotFoundException {
|
||||
return addItemToEnd(ShoppingCartItem.makeItem(null, productId, amount, quantity, unitPrice, reservStart, reservLength, reservPersons,
|
||||
accommodationMapId, accommodationSpotId, null, null, features, attributes, prodCatalogId, null, itemType, null, dispatcher, this,
|
||||
triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,
|
||||
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,
|
||||
triggerExternalOps, triggerPriceRules, null, skipInventoryChecks, skipProductChecks));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
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));
|
||||
}
|
||||
|
||||
/** Add an item to the shopping cart. */
|
||||
@@ -1183,69 +1235,74 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
*/
|
||||
public void setShipBeforeDate(int idx, Timestamp shipBeforeDate) {
|
||||
CartShipInfo csi = this.getShipInfo(idx);
|
||||
csi.shipBeforeDate = shipBeforeDate;
|
||||
csi.shipBeforeDate = shipBeforeDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ship before date for ship group 0
|
||||
* @param shipBeforeDate
|
||||
*/
|
||||
*/
|
||||
public void setShipBeforeDate(Timestamp shipBeforeDate) {
|
||||
this.setShipBeforeDate(0, shipBeforeDate);
|
||||
this.setShipBeforeDate(0, shipBeforeDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ship before date for a particular ship group
|
||||
* @param idx the ship group number
|
||||
* @return ship before date for a given ship group
|
||||
*/
|
||||
public Timestamp getShipBeforeDate(int idx) {
|
||||
CartShipInfo csi = this.getShipInfo(idx);
|
||||
return csi.shipBeforeDate;
|
||||
CartShipInfo csi = this.getShipInfo(idx);
|
||||
return csi.shipBeforeDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ship before date for ship group 0
|
||||
* @return ship before date for the first ship group
|
||||
*/
|
||||
* Get ship before date for ship group 0
|
||||
*
|
||||
* @return ship before date for the first ship group
|
||||
*/
|
||||
public Timestamp getShipBeforeDate() {
|
||||
return this.getShipBeforeDate(0);
|
||||
}
|
||||
return this.getShipBeforeDate(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ship after date for a particular ship group
|
||||
* @param idx the ship group number
|
||||
* @param shipAfterDate the ship after date to be set for the given ship group
|
||||
*/
|
||||
/**
|
||||
* Set ship after date for a particular ship group
|
||||
*
|
||||
* @param idx the ship group number
|
||||
* @param shipAfterDate the ship after date to be set for the given ship group
|
||||
*/
|
||||
public void setShipAfterDate(int idx, Timestamp shipAfterDate) {
|
||||
CartShipInfo csi = this.getShipInfo(idx);
|
||||
csi.shipAfterDate = shipAfterDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ship after date for a particular ship group
|
||||
* @param shipAfterDate the ship after date to be set for the first ship group
|
||||
*/
|
||||
public void setShipAfterDate(Timestamp shipAfterDate) {
|
||||
this.setShipAfterDate(0, shipAfterDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ship after date for a particular ship group
|
||||
* @param idx the ship group number
|
||||
* @return return the ship after date for the given ship group
|
||||
*/
|
||||
/**
|
||||
* Get ship after date for a particular ship group
|
||||
*
|
||||
* @param idx the ship group number
|
||||
* @return return the ship after date for the given ship group
|
||||
*/
|
||||
public Timestamp getShipAfterDate(int idx) {
|
||||
CartShipInfo csi = this.getShipInfo(idx);
|
||||
return csi.shipAfterDate;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get ship after date for ship group 0
|
||||
* @return return the ship after date for the first ship group
|
||||
*/
|
||||
public Timestamp getShipAfterDate() {
|
||||
return this.getShipAfterDate(0);
|
||||
}
|
||||
return this.getShipAfterDate(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ship after date for a particular ship group
|
||||
*
|
||||
* @param shipAfterDate the ship after date to be set for the first ship group
|
||||
*/
|
||||
public void setShipAfterDate(Timestamp shipAfterDate) {
|
||||
this.setShipAfterDate(0, shipAfterDate);
|
||||
}
|
||||
|
||||
public void setDefaultShipBeforeDate(Timestamp defaultShipBeforeDate) {
|
||||
this.defaultShipBeforeDate = defaultShipBeforeDate != null ? (Timestamp) defaultShipBeforeDate.clone() : null;
|
||||
@@ -2264,20 +2321,20 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
* @return
|
||||
*/
|
||||
public int getItemShipGroupIndex(int itemId) {
|
||||
int shipGroupIndex = this.getShipGroupSize() - 1;
|
||||
ShoppingCartItem item = this.findCartItem(itemId);
|
||||
int result = 0;
|
||||
for (int i = 0; i < (shipGroupIndex + 1); i++) {
|
||||
CartShipInfo csi = this.getShipInfo(i);
|
||||
Iterator<ShoppingCartItem> it = csi.shipItemInfo.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
ShoppingCartItem item2 = it.next();
|
||||
if (item.equals(item2)) {
|
||||
result = i;
|
||||
int shipGroupIndex = this.getShipGroupSize() - 1;
|
||||
ShoppingCartItem item = this.findCartItem(itemId);
|
||||
int result = 0;
|
||||
for (int i = 0; i < (shipGroupIndex + 1); i++) {
|
||||
CartShipInfo csi = this.getShipInfo(i);
|
||||
Iterator<ShoppingCartItem> it = csi.shipItemInfo.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
ShoppingCartItem item2 = it.next();
|
||||
if (item.equals(item2)) {
|
||||
result = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Sets the shipping contact mech id. */
|
||||
@@ -2776,7 +2833,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
return OrderReadHelper.calcOrderAdjustments(tempAdjustmentsList, this.getSubTotal(), false, true, true);
|
||||
}
|
||||
public BigDecimal getDisplayTaxIncluded() {
|
||||
BigDecimal taxIncluded = getDisplaySubTotal().subtract(getSubTotal());
|
||||
BigDecimal taxIncluded = getDisplaySubTotal().subtract(getSubTotal());
|
||||
return taxIncluded.setScale(TAX_FINAL_SCALE, TAX_ROUNDING);
|
||||
}
|
||||
|
||||
@@ -4203,8 +4260,8 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
for (int i = 0; i < this.shipInfo.size(); i++) {
|
||||
CartShipInfo csi = shipInfo.get(i);
|
||||
if ((csi.supplierPartyId == null && supplierPartyId == null)
|
||||
|| (UtilValidate.isNotEmpty(csi.supplierPartyId) && csi.supplierPartyId.equals(supplierPartyId))) {
|
||||
shipGroups.put(i, csi);
|
||||
|| (UtilValidate.isNotEmpty(csi.supplierPartyId) && csi.supplierPartyId.equals(supplierPartyId))) {
|
||||
shipGroups.put(i, csi);
|
||||
}
|
||||
}
|
||||
return shipGroups;
|
||||
@@ -4786,7 +4843,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
Timestamp estimatedShipDate = null;
|
||||
if (estimatedShipDates.size() > 0) {
|
||||
estimatedShipDates.sort(null);
|
||||
estimatedShipDate = estimatedShipDates.getLast();
|
||||
estimatedShipDate = estimatedShipDates.getLast();
|
||||
shipGroup.set("estimatedShipDate", estimatedShipDate);
|
||||
}
|
||||
|
||||
|
||||
+30
-29
@@ -890,13 +890,13 @@ public class ShoppingCartHelper {
|
||||
}
|
||||
|
||||
if (parameterName.toUpperCase(Locale.getDefault()).startsWith("COMMENT")) {
|
||||
if (!oldItemComment.equals(itemComment)) {
|
||||
if (security.hasEntityPermission("ORDERMGR", "_CREATE", userLogin)) {
|
||||
if (item != null) {
|
||||
item.setItemComment(itemComment);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!oldItemComment.equals(itemComment)) {
|
||||
if (security.hasEntityPermission("ORDERMGR", "_CREATE", userLogin)) {
|
||||
if (item != null) {
|
||||
item.setItemComment(itemComment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parameterName.toUpperCase(Locale.getDefault()).startsWith("PRICE")) {
|
||||
@@ -1091,24 +1091,26 @@ public class ShoppingCartHelper {
|
||||
}
|
||||
|
||||
try {
|
||||
// clear the existing order terms
|
||||
cart.removeOrderTerms();
|
||||
// set order terms based on agreement terms
|
||||
List<GenericValue> agreementTerms = EntityUtil.filterByDate(agreement.getRelated("AgreementTerm", null, null, false));
|
||||
if (agreementTerms.size() > 0) {
|
||||
for (int i = 0; agreementTerms.size() > i;i++) {
|
||||
GenericValue agreementTerm = agreementTerms.get(i);
|
||||
String termTypeId = (String) agreementTerm.get("termTypeId");
|
||||
BigDecimal termValue = agreementTerm.getBigDecimal("termValue");
|
||||
Long termDays = (Long) agreementTerm.get("termDays");
|
||||
String textValue = agreementTerm.getString("textValue");
|
||||
cart.addOrderTerm(termTypeId, termValue, termDays, textValue);
|
||||
}
|
||||
}
|
||||
// clear the existing order terms
|
||||
cart.removeOrderTerms();
|
||||
// set order terms based on agreement terms
|
||||
List<GenericValue> agreementTerms = EntityUtil.filterByDate(agreement.getRelated("AgreementTerm", null, null, false));
|
||||
if (agreementTerms.size() > 0) {
|
||||
for (int i = 0; agreementTerms.size() > i; i++) {
|
||||
GenericValue agreementTerm = agreementTerms.get(i);
|
||||
String termTypeId = (String) agreementTerm.get("termTypeId");
|
||||
BigDecimal termValue = agreementTerm.getBigDecimal("termValue");
|
||||
Long termDays = (Long) agreementTerm.get("termDays");
|
||||
String textValue = agreementTerm.getString("textValue");
|
||||
cart.addOrderTerm(termTypeId, termValue, termDays, textValue);
|
||||
}
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logWarning(e.toString(), MODULE);
|
||||
result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderCouldNotGetAgreementTermsThrough", UtilMisc.toMap("agreementId", agreementId), this.cart.getLocale()) + UtilProperties.getMessage(RES_ERROR, "OrderError", this.cart.getLocale()) + e.getMessage());
|
||||
return result;
|
||||
Debug.logWarning(e.toString(), MODULE);
|
||||
result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderCouldNotGetAgreementTermsThrough", UtilMisc.toMap(
|
||||
"agreementId", agreementId), this.cart.getLocale()) + UtilProperties.getMessage(RES_ERROR, "OrderError",
|
||||
this.cart.getLocale()) + e.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -1120,10 +1122,10 @@ public class ShoppingCartHelper {
|
||||
try {
|
||||
this.cart.setCurrency(this.dispatcher, currencyUomId);
|
||||
result = ServiceUtil.returnSuccess();
|
||||
} catch (CartItemModifyException ex) {
|
||||
result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderSetCurrencyError", this.cart.getLocale()) + ex.getMessage());
|
||||
return result;
|
||||
}
|
||||
} catch (CartItemModifyException ex) {
|
||||
result = ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "OrderSetCurrencyError", this.cart.getLocale()) + ex.getMessage());
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1144,5 +1146,4 @@ public class ShoppingCartHelper {
|
||||
result = ServiceUtil.returnSuccess();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+56
-54
@@ -429,18 +429,18 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
|
||||
// check to see if the product is a rental item
|
||||
if ("ASSET_USAGE".equals(product.getString("productTypeId")) || "ASSET_USAGE_OUT_IN".equals(product.getString("productTypeId"))) {
|
||||
if (reservStart == null) {
|
||||
if (reservStart == null) {
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.missing_reservation_starting_date", cart.getLocale());
|
||||
throw new CartItemModifyException(excMsg);
|
||||
}
|
||||
|
||||
if (reservStart.before(UtilDateTime.nowTimestamp())) {
|
||||
if (reservStart.before(UtilDateTime.nowTimestamp())) {
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.reservation_from_tomorrow", cart.getLocale());
|
||||
throw new CartItemModifyException(excMsg);
|
||||
}
|
||||
newItem.setReservStart(reservStart);
|
||||
|
||||
if (reservLength.compareTo(BigDecimal.ONE) < 0) {
|
||||
if (reservLength.compareTo(BigDecimal.ONE) < 0) {
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.number_of_days", cart.getLocale());
|
||||
throw new CartItemModifyException(excMsg);
|
||||
}
|
||||
@@ -448,32 +448,34 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
|
||||
if (product.get("reservMaxPersons") != null) {
|
||||
BigDecimal reservMaxPersons = product.getBigDecimal("reservMaxPersons");
|
||||
if (reservMaxPersons.compareTo(reservPersons) < 0) {
|
||||
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("reservMaxPersons", product.getString("reservMaxPersons"), "reservPersons", reservPersons);
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.maximum_number_of_person_renting", messageMap, cart.getLocale());
|
||||
if (reservMaxPersons.compareTo(reservPersons) < 0) {
|
||||
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("reservMaxPersons", product.getString("reservMaxPersons"),
|
||||
"reservPersons", reservPersons);
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.maximum_number_of_person_renting", messageMap, cart.getLocale());
|
||||
|
||||
Debug.logInfo(excMsg, MODULE);
|
||||
throw new CartItemModifyException(excMsg);
|
||||
}
|
||||
}
|
||||
newItem.setReservPersons(reservPersons);
|
||||
Debug.logInfo(excMsg, MODULE);
|
||||
throw new CartItemModifyException(excMsg);
|
||||
}
|
||||
}
|
||||
newItem.setReservPersons(reservPersons);
|
||||
|
||||
if (product.get("reserv2ndPPPerc") != null) {
|
||||
if (product.get("reserv2ndPPPerc") != null) {
|
||||
newItem.setReserv2ndPPPerc(product.getBigDecimal("reserv2ndPPPerc"));
|
||||
}
|
||||
|
||||
if (product.get("reservNthPPPerc") != null) {
|
||||
if (product.get("reservNthPPPerc") != null) {
|
||||
newItem.setReservNthPPPerc(product.getBigDecimal("reservNthPPPerc"));
|
||||
}
|
||||
|
||||
if ((accommodationMapId != null) && (accommodationSpotId != null)) {
|
||||
if ((accommodationMapId != null) && (accommodationSpotId != null)) {
|
||||
newItem.setAccommodationId(accommodationMapId, accommodationSpotId);
|
||||
}
|
||||
}
|
||||
|
||||
// check to see if the related fixed asset is available for rent
|
||||
String isAvailable = checkAvailability(product.getString("productId"), quantity, reservStart, reservLength, cart);
|
||||
if (isAvailable.compareTo("OK") != 0) {
|
||||
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productId", product.getString("productId"), "availableMessage", isAvailable);
|
||||
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productId", product.getString("productId"), "availableMessage",
|
||||
isAvailable);
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.product_not_available", messageMap, cart.getLocale());
|
||||
Debug.logInfo(excMsg, MODULE);
|
||||
throw new CartItemModifyException(isAvailable);
|
||||
@@ -548,41 +550,41 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public static void isValidCartProduct(ProductConfigWrapper configWrapper, GenericValue product, Timestamp nowTimestamp, Locale locale) throws CartItemModifyException {
|
||||
// check to see if introductionDate hasn't passed yet
|
||||
if (product.get("introductionDate") != null && nowTimestamp.before(product.getTimestamp("introductionDate"))) {
|
||||
// check to see if introductionDate hasn't passed yet
|
||||
if (product.get("introductionDate") != null && nowTimestamp.before(product.getTimestamp("introductionDate"))) {
|
||||
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productName", product.getString("productName"),
|
||||
"productId", product.getString("productId"));
|
||||
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.cannot_add_product_not_yet_available",
|
||||
messageMap, locale);
|
||||
|
||||
Debug.logWarning(excMsg, MODULE);
|
||||
throw new CartItemModifyException(excMsg);
|
||||
}
|
||||
|
||||
// check to see if salesDiscontinuationDate has passed
|
||||
if (product.get("salesDiscontinuationDate") != null && nowTimestamp.after(product.getTimestamp("salesDiscontinuationDate"))) {
|
||||
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productName", product.getString("productName"),
|
||||
"productId", product.getString("productId"));
|
||||
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.cannot_add_product_no_longer_available",
|
||||
messageMap, locale);
|
||||
|
||||
Debug.logWarning(excMsg, MODULE);
|
||||
throw new CartItemModifyException(excMsg);
|
||||
}
|
||||
|
||||
// check to see if the product is fully configured
|
||||
if ("AGGREGATED".equals(product.getString("productTypeId")) || "AGGREGATED_SERVICE".equals(product.getString("productTypeId"))) {
|
||||
if (configWrapper == null || !configWrapper.isCompleted()) {
|
||||
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productName", product.getString("productName"),
|
||||
"productId", product.getString("productId"));
|
||||
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.cannot_add_product_not_yet_available",
|
||||
messageMap, locale);
|
||||
|
||||
"productId", product.getString("productId"));
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.cannot_add_product_not_configured_correctly",
|
||||
messageMap, locale);
|
||||
Debug.logWarning(excMsg, MODULE);
|
||||
throw new CartItemModifyException(excMsg);
|
||||
}
|
||||
|
||||
// check to see if salesDiscontinuationDate has passed
|
||||
if (product.get("salesDiscontinuationDate") != null && nowTimestamp.after(product.getTimestamp("salesDiscontinuationDate"))) {
|
||||
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productName", product.getString("productName"),
|
||||
"productId", product.getString("productId"));
|
||||
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.cannot_add_product_no_longer_available",
|
||||
messageMap, locale);
|
||||
|
||||
Debug.logWarning(excMsg, MODULE);
|
||||
throw new CartItemModifyException(excMsg);
|
||||
}
|
||||
|
||||
// check to see if the product is fully configured
|
||||
if ("AGGREGATED".equals(product.getString("productTypeId")) || "AGGREGATED_SERVICE".equals(product.getString("productTypeId"))) {
|
||||
if (configWrapper == null || !configWrapper.isCompleted()) {
|
||||
Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productName", product.getString("productName"),
|
||||
"productId", product.getString("productId"));
|
||||
String excMsg = UtilProperties.getMessage(RES_ERROR, "item.cannot_add_product_not_configured_correctly",
|
||||
messageMap, locale);
|
||||
Debug.logWarning(excMsg, MODULE);
|
||||
throw new CartItemModifyException(excMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -850,19 +852,19 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
this.reservNthPPPerc = reservNthPPPerc;
|
||||
}
|
||||
/** Sets the reservation start date */
|
||||
public void setReservStart(Timestamp reservStart) {
|
||||
public void setReservStart(Timestamp reservStart) {
|
||||
this.reservStart = reservStart != null ? (Timestamp) reservStart.clone() : null;
|
||||
}
|
||||
/** Sets the reservation length */
|
||||
public void setReservLength(BigDecimal reservLength) {
|
||||
public void setReservLength(BigDecimal reservLength) {
|
||||
this.reservLength = reservLength;
|
||||
}
|
||||
/** Sets number of persons using the reservation */
|
||||
public void setReservPersons(BigDecimal reservPersons) {
|
||||
public void setReservPersons(BigDecimal reservPersons) {
|
||||
this.reservPersons = reservPersons;
|
||||
}
|
||||
/** Sets accommodationId using the reservation */
|
||||
public void setAccommodationId(String accommodationMapId, String accommodationSpotId) {
|
||||
public void setAccommodationId(String accommodationMapId, String accommodationSpotId) {
|
||||
this.accommodationMapId = accommodationMapId;
|
||||
this.accommodationSpotId = accommodationSpotId;
|
||||
}
|
||||
@@ -1321,11 +1323,11 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
}
|
||||
|
||||
/** Returns accommodationMapId */
|
||||
public String getAccommodationMapId() {
|
||||
public String getAccommodationMapId() {
|
||||
return this.accommodationMapId;
|
||||
}
|
||||
/** Returns accommodationSpotId */
|
||||
public String getAccommodationSpotId() {
|
||||
public String getAccommodationSpotId() {
|
||||
return this.accommodationSpotId;
|
||||
}
|
||||
|
||||
@@ -2070,7 +2072,7 @@ public class ShoppingCartItem implements java.io.Serializable {
|
||||
}
|
||||
BigDecimal persons = this.getReservPersons();
|
||||
BigDecimal rentalValue = BigDecimal.ZERO;
|
||||
if (persons.compareTo(BigDecimal.ONE) > 0) {
|
||||
if (persons.compareTo(BigDecimal.ONE) > 0) {
|
||||
if (persons.compareTo(new BigDecimal("2")) > 0) {
|
||||
persons = persons.subtract(new BigDecimal("2"));
|
||||
if (getReservNthPPPerc().compareTo(BigDecimal.ZERO) > 0) {
|
||||
|
||||
+10
-10
@@ -246,18 +246,18 @@ public final class ProductDisplayWorker {
|
||||
}
|
||||
|
||||
// if desired check view allow category
|
||||
String currentCatalogId = CatalogWorker.getCurrentCatalogId(request);
|
||||
String viewProductCategoryId = CatalogWorker.getCatalogViewAllowCategoryId(delegator, currentCatalogId);
|
||||
if (viewProductCategoryId != null) {
|
||||
for (Map.Entry<String, GenericValue> entry : products.entrySet()) {
|
||||
String productId = entry.getKey();
|
||||
if (!CategoryWorker.isProductInCategory(delegator, productId, viewProductCategoryId)) {
|
||||
products.remove(productId);
|
||||
productQuantities.remove(productId);
|
||||
productOccurances.remove(productId);
|
||||
}
|
||||
String currentCatalogId = CatalogWorker.getCurrentCatalogId(request);
|
||||
String viewProductCategoryId = CatalogWorker.getCatalogViewAllowCategoryId(delegator, currentCatalogId);
|
||||
if (viewProductCategoryId != null) {
|
||||
for (Map.Entry<String, GenericValue> entry : products.entrySet()) {
|
||||
String productId = entry.getKey();
|
||||
if (!CategoryWorker.isProductInCategory(delegator, productId, viewProductCategoryId)) {
|
||||
products.remove(productId);
|
||||
productQuantities.remove(productId);
|
||||
productOccurances.remove(productId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<GenericValue> reorderProds = new LinkedList<>();
|
||||
reorderProds.addAll(products.values());
|
||||
|
||||
+7
-7
@@ -1187,10 +1187,10 @@ public class CommunicationEventServices {
|
||||
|
||||
private static List<String> getCommEventAttachmentNames(final Delegator delegator, final String communicationEventId) throws GenericEntityException {
|
||||
List<GenericValue> commEventContentAssocList = EntityQuery.use(delegator)
|
||||
.from("CommEventContentDataResource")
|
||||
.where(EntityCondition.makeCondition("communicationEventId", communicationEventId))
|
||||
.filterByDate()
|
||||
.queryList();
|
||||
.from("CommEventContentDataResource")
|
||||
.where(EntityCondition.makeCondition("communicationEventId", communicationEventId))
|
||||
.filterByDate()
|
||||
.queryList();
|
||||
|
||||
List<String> attachmentNames = new ArrayList<>();
|
||||
for (GenericValue commEventContentAssoc : commEventContentAssocList) {
|
||||
@@ -1431,7 +1431,7 @@ public class CommunicationEventServices {
|
||||
part2Text = "";
|
||||
}
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Part 2 Text :\n\n" + part2Text, MODULE);
|
||||
Debug.logVerbose("Part 2 Text :\n\n" + part2Text, MODULE);
|
||||
}
|
||||
|
||||
// find the "Action" element and obtain its value (looking for "failed")
|
||||
@@ -1449,7 +1449,7 @@ public class CommunicationEventServices {
|
||||
part3Text = "";
|
||||
}
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Part 3 Text :\n\n" + part3Text, MODULE);
|
||||
Debug.logVerbose("Part 3 Text :\n\n" + part3Text, MODULE);
|
||||
}
|
||||
|
||||
// find the "Message-Id" element and obtain its value (looking for "failed")
|
||||
@@ -1609,7 +1609,7 @@ public class CommunicationEventServices {
|
||||
try {
|
||||
imageUrl = FlexibleLocation.resolveLocation("component://common-theme/webapp/images/spacer.gif");
|
||||
try (InputStream imageStream = imageUrl.openStream()) {
|
||||
UtilHttp.streamContentToBrowser(response, imageStream, 43, "image/gif", null);
|
||||
UtilHttp.streamContentToBrowser(response, imageStream, 43, "image/gif", null);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
|
||||
+2
-2
@@ -161,7 +161,7 @@ public class PartyContentWrapper implements ContentWrapper {
|
||||
String outString = outWriter.toString();
|
||||
if (UtilValidate.isEmpty(outString)) {
|
||||
outString = party.getModelEntity().isField(candidateFieldName) ? party.getString(candidateFieldName): "";
|
||||
outString = outString == null? "" : outString;
|
||||
outString = outString == null ? "" : outString;
|
||||
}
|
||||
outString = encoder.sanitize(outString, null);
|
||||
if (partyContentCache != null) {
|
||||
@@ -171,7 +171,7 @@ public class PartyContentWrapper implements ContentWrapper {
|
||||
} catch (GeneralException | IOException e) {
|
||||
Debug.logError(e, "Error rendering PartyContent, inserting empty String", MODULE);
|
||||
String candidateOut = party.getModelEntity().isField(candidateFieldName) ? party.getString(candidateFieldName): "";
|
||||
return candidateOut == null? "" : encoder.sanitize(candidateOut, null);
|
||||
return candidateOut == null ? "" : encoder.sanitize(candidateOut, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1810,7 +1810,7 @@ public class PartyServices {
|
||||
// filter on infoString
|
||||
String infoString = (String) context.get("infoString");
|
||||
if (UtilValidate.isNotEmpty(infoString)) {
|
||||
andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER("%"+infoString+"%")));
|
||||
andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER("%"+ infoString +"%")));
|
||||
fieldsToSelect.add("infoString");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public class PartyWorker {
|
||||
String firstName, String middleName, String lastName) throws GeneralException {
|
||||
|
||||
List<GenericValue> matching = findMatchingPersonPostalAddresses(delegator, address1, address2, city, stateProvinceGeoId, postalCode,
|
||||
postalCodeExt, countryGeoId, firstName, middleName, lastName);
|
||||
postalCodeExt, countryGeoId, firstName, middleName, lastName);
|
||||
GenericValue v = EntityUtil.getFirst(matching);
|
||||
if (v != null) {
|
||||
return new String[] {v.getString("partyId"), v.getString("contactMechId") };
|
||||
@@ -462,7 +462,7 @@ public class PartyWorker {
|
||||
}
|
||||
partyList.add(associatedParty);
|
||||
}
|
||||
associatedParties = currentAssociatedParties;
|
||||
associatedParties = currentAssociatedParties;
|
||||
}
|
||||
partyIds = EntityUtil.getFieldListFromEntityList(partyList, "partyIdTo", true);
|
||||
} catch (GenericEntityException e) {
|
||||
|
||||
+57
-55
@@ -79,70 +79,72 @@ public class CatalogUrlServlet extends HttpServlet {
|
||||
RequestDispatcher rd = request.getRequestDispatcher("/" + WebAppUtil.CONTROL_MOUNT_POINT + "/main");
|
||||
rd.forward(request, response);
|
||||
} else {
|
||||
try {
|
||||
String lastPathElement = pathElements.get(pathElements.size() - 1);
|
||||
if (lastPathElement.startsWith("p_")) {
|
||||
productId = lastPathElement.substring(2);
|
||||
} else {
|
||||
GenericValue productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", lastPathElement).cache(true).queryOne();
|
||||
if (productCategory != null) {
|
||||
categoryId = lastPathElement;
|
||||
try {
|
||||
String lastPathElement = pathElements.get(pathElements.size() - 1);
|
||||
if (lastPathElement.startsWith("p_")) {
|
||||
productId = lastPathElement.substring(2);
|
||||
} else {
|
||||
productId = lastPathElement;
|
||||
GenericValue productCategory =
|
||||
EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", lastPathElement).cache(true).queryOne();
|
||||
if (productCategory != null) {
|
||||
categoryId = lastPathElement;
|
||||
} else {
|
||||
productId = lastPathElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
pathElements.remove(pathElements.size() - 1);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Error in looking up ProductUrl or CategoryUrl with path info [" + pathInfo + "]: " + e.toString(), MODULE);
|
||||
}
|
||||
|
||||
// get category info going with the IDs that remain
|
||||
if (pathElements.size() == 1) {
|
||||
CategoryWorker.setTrail(request, pathElements.get(0), null);
|
||||
categoryId = pathElements.get(0);
|
||||
} else if (pathElements.size() == 2) {
|
||||
CategoryWorker.setTrail(request, pathElements.get(1), pathElements.get(0));
|
||||
categoryId = pathElements.get(1);
|
||||
} else if (pathElements.size() > 2) {
|
||||
List<String> trail = CategoryWorker.getTrail(request);
|
||||
if (trail == null) {
|
||||
trail = new LinkedList<>();
|
||||
pathElements.remove(pathElements.size() - 1);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Error in looking up ProductUrl or CategoryUrl with path info [" + pathInfo + "]: " + e.toString(), MODULE);
|
||||
}
|
||||
|
||||
if (trail.contains(pathElements.get(0))) {
|
||||
// first category is in the trail, so remove it everything after that and fill it in with the list from the pathInfo
|
||||
int firstElementIndex = trail.indexOf(pathElements.get(0));
|
||||
while (trail.size() > firstElementIndex) {
|
||||
trail.remove(firstElementIndex);
|
||||
// get category info going with the IDs that remain
|
||||
if (pathElements.size() == 1) {
|
||||
CategoryWorker.setTrail(request, pathElements.get(0), null);
|
||||
categoryId = pathElements.get(0);
|
||||
} else if (pathElements.size() == 2) {
|
||||
CategoryWorker.setTrail(request, pathElements.get(1), pathElements.get(0));
|
||||
categoryId = pathElements.get(1);
|
||||
} else if (pathElements.size() > 2) {
|
||||
List<String> trail = CategoryWorker.getTrail(request);
|
||||
if (trail == null) {
|
||||
trail = new LinkedList<>();
|
||||
}
|
||||
trail.addAll(pathElements);
|
||||
} else {
|
||||
// first category is NOT in the trail, so clear out the trail and use the pathElements list
|
||||
trail.clear();
|
||||
trail.addAll(pathElements);
|
||||
|
||||
if (trail.contains(pathElements.get(0))) {
|
||||
// first category is in the trail, so remove it everything after that and fill it in with the list from the pathInfo
|
||||
int firstElementIndex = trail.indexOf(pathElements.get(0));
|
||||
while (trail.size() > firstElementIndex) {
|
||||
trail.remove(firstElementIndex);
|
||||
}
|
||||
trail.addAll(pathElements);
|
||||
} else {
|
||||
// first category is NOT in the trail, so clear out the trail and use the pathElements list
|
||||
trail.clear();
|
||||
trail.addAll(pathElements);
|
||||
}
|
||||
CategoryWorker.setTrail(request, trail);
|
||||
categoryId = pathElements.get(pathElements.size() - 1);
|
||||
}
|
||||
if (categoryId != null) {
|
||||
request.setAttribute("productCategoryId", categoryId);
|
||||
}
|
||||
CategoryWorker.setTrail(request, trail);
|
||||
categoryId = pathElements.get(pathElements.size() - 1);
|
||||
}
|
||||
if (categoryId != null) {
|
||||
request.setAttribute("productCategoryId", categoryId);
|
||||
}
|
||||
|
||||
String rootCategoryId = null;
|
||||
if (pathElements.size() >= 1) {
|
||||
rootCategoryId = pathElements.get(0);
|
||||
}
|
||||
if (rootCategoryId != null) {
|
||||
request.setAttribute("rootCategoryId", rootCategoryId);
|
||||
}
|
||||
String rootCategoryId = null;
|
||||
if (pathElements.size() >= 1) {
|
||||
rootCategoryId = pathElements.get(0);
|
||||
}
|
||||
if (rootCategoryId != null) {
|
||||
request.setAttribute("rootCategoryId", rootCategoryId);
|
||||
}
|
||||
|
||||
if (productId != null) {
|
||||
request.setAttribute("product_id", productId);
|
||||
request.setAttribute("productId", productId);
|
||||
}
|
||||
if (productId != null) {
|
||||
request.setAttribute("product_id", productId);
|
||||
request.setAttribute("productId", productId);
|
||||
}
|
||||
|
||||
RequestDispatcher rd = request.getRequestDispatcher("/" + WebAppUtil.CONTROL_MOUNT_POINT + "/" + (productId != null ? PRODUCT_REQUEST : CATEGORY_REQUEST));
|
||||
rd.forward(request, response);
|
||||
RequestDispatcher rd = request.getRequestDispatcher("/" + WebAppUtil.CONTROL_MOUNT_POINT + "/" + (productId != null ? PRODUCT_REQUEST
|
||||
: CATEGORY_REQUEST));
|
||||
rd.forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ public class CategoryContentWrapper implements ContentWrapper {
|
||||
String outString = outWriter.toString();
|
||||
if (UtilValidate.isEmpty(outString)) {
|
||||
outString = productCategory.getModelEntity().isField(candidateFieldName) ? productCategory.getString(candidateFieldName): "";
|
||||
outString = outString == null? "" : outString;
|
||||
outString = outString == null ? "" : outString;
|
||||
}
|
||||
outString = encoder.sanitize(outString, null);
|
||||
categoryContentCache.put(cacheKey, outString);
|
||||
|
||||
+1
-1
@@ -398,7 +398,7 @@ public final class CategoryWorker {
|
||||
}
|
||||
/**
|
||||
* Returns a complete category trail - can be used for exporting proper category trees.
|
||||
* This is mostly useful when used in combination with bread-crumbs, for building a
|
||||
* This is mostly useful when used in combination with bread-crumbs, for building a
|
||||
* faceted index tree, or to export a category tree for migration to another system.
|
||||
* Will create the tree from root point to categoryId.
|
||||
* This method is not meant to be run on every request.
|
||||
|
||||
+2
-2
@@ -132,7 +132,7 @@ public class ProductConfigItemContentWrapper implements ContentWrapper {
|
||||
String outString = outWriter.toString();
|
||||
if (UtilValidate.isEmpty(outString)) {
|
||||
outString = productConfigItem.getModelEntity().isField(candidateFieldName) ? productConfigItem.getString(candidateFieldName): "";
|
||||
outString = outString == null? "" : outString;
|
||||
outString = outString == null ? "" : outString;
|
||||
}
|
||||
outString = encoder.sanitize(outString, null);
|
||||
configItemContentCache.put(cacheKey, outString);
|
||||
@@ -140,7 +140,7 @@ public class ProductConfigItemContentWrapper implements ContentWrapper {
|
||||
} catch (GeneralException | IOException e) {
|
||||
Debug.logError(e, "Error rendering ProdConfItemContent, inserting empty String", MODULE);
|
||||
String candidateOut = productConfigItem.getModelEntity().isField(candidateFieldName) ? productConfigItem.getString(candidateFieldName): "";
|
||||
return candidateOut == null? "" : encoder.sanitize(candidateOut, null);
|
||||
return candidateOut == null ? "" : encoder.sanitize(candidateOut, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -296,14 +296,14 @@ public final class ProductConfigWorker {
|
||||
|
||||
if (match && (UtilValidate.isEmpty(configOptionProductOptions))) {
|
||||
configWrapper.configId = tempConfigId;
|
||||
Debug.logInfo("Existing configuration found with configId:"+ tempConfigId, MODULE);
|
||||
Debug.logInfo("Existing configuration found with configId:"+ tempConfigId, MODULE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
configWrapper.configId = tempConfigId;
|
||||
Debug.logInfo("Existing configuration found with configId:"+ tempConfigId, MODULE);
|
||||
Debug.logInfo("Existing configuration found with configId:"+ tempConfigId, MODULE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -380,7 +380,7 @@ 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);
|
||||
Debug.logInfo("New configId created:"+ configId, MODULE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+22
-22
@@ -476,7 +476,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
if (content != null) {
|
||||
question = content.get("DESCRIPTION", "html").toString();
|
||||
} else {
|
||||
question = (configItem.getString("description") != null? configItem.getString("description"): "");
|
||||
question = (configItem.getString("description") != null ? configItem.getString("description") : "");
|
||||
}
|
||||
}
|
||||
return question;
|
||||
@@ -490,7 +490,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
if (content != null) {
|
||||
description = content.get("LONG_DESCRIPTION", "html").toString();
|
||||
} else {
|
||||
description = (configItem.getString("longDescription") != null? configItem.getString("longDescription"): "");
|
||||
description = (configItem.getString("longDescription") != null ? configItem.getString("longDescription") : "");
|
||||
}
|
||||
}
|
||||
return description;
|
||||
@@ -692,20 +692,20 @@ public class ProductConfigWrapper implements Serializable {
|
||||
}
|
||||
|
||||
public String getOptionName() {
|
||||
return (configOption.getString("configOptionName") != null? configOption.getString("configOptionName"): "no option name");
|
||||
return (configOption.getString("configOptionName") != null ? configOption.getString("configOptionName") : "no option name");
|
||||
}
|
||||
|
||||
public String getOptionName(Locale locale) {
|
||||
|
||||
return (configOption.getString("configOptionName") != null? (String) configOption.get("configOptionName", locale): "no option name");
|
||||
return (configOption.getString("configOptionName") != null ? (String) configOption.get("configOptionName", locale) : "no option name");
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return (configOption.getString("description") != null? configOption.getString("description"): "no description");
|
||||
return (configOption.getString("description") != null ? configOption.getString("description") : "no description");
|
||||
}
|
||||
|
||||
public String getDescription(Locale locale) {
|
||||
return (configOption.getString("description") != null? (String) configOption.get("description", locale): "no description");
|
||||
return (configOption.getString("description") != null ? (String) configOption.get("description", locale) : "no description");
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
@@ -751,20 +751,20 @@ public class ProductConfigWrapper implements Serializable {
|
||||
return this.equals(defaultConfigOption);
|
||||
}
|
||||
|
||||
public boolean hasVirtualComponent () {
|
||||
List<GenericValue> components = getComponents();
|
||||
if (UtilValidate.isNotEmpty(components)) {
|
||||
for (GenericValue component : components) {
|
||||
if (isVirtualComponent(component)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean hasVirtualComponent() {
|
||||
List<GenericValue> components = getComponents();
|
||||
if (UtilValidate.isNotEmpty(components)) {
|
||||
for (GenericValue component : components) {
|
||||
if (isVirtualComponent(component)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVirtualComponent (GenericValue component) {
|
||||
public boolean isVirtualComponent(GenericValue component) {
|
||||
int index = getComponents().indexOf(component);
|
||||
if (index != -1) {
|
||||
try {
|
||||
@@ -806,10 +806,10 @@ public class ProductConfigWrapper implements Serializable {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ConfigOption that = (ConfigOption) o;
|
||||
return Objects.equals(availabilityDate, that.availabilityDate) &&
|
||||
Objects.equals(componentList, that.componentList) &&
|
||||
Objects.equals(getComponentOptions(), that.getComponentOptions()) &&
|
||||
Objects.equals(configOption, that.configOption);
|
||||
return Objects.equals(availabilityDate, that.availabilityDate)
|
||||
&& Objects.equals(componentList, that.componentList)
|
||||
&& Objects.equals(getComponentOptions(), that.getComponentOptions())
|
||||
&& Objects.equals(configOption, that.configOption);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-8
@@ -110,7 +110,7 @@ public class FrameImage {
|
||||
|
||||
// Image Frame
|
||||
BufferedImage bufImg1 = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + imageName));
|
||||
BufferedImage bufImg2 = ImageIO.read(new File(imageServerPath + "/frame/"+frameImageName));
|
||||
BufferedImage bufImg2 = ImageIO.read(new File(imageServerPath + "/frame/" + frameImageName));
|
||||
|
||||
int bufImgType;
|
||||
if (BufferedImage.TYPE_CUSTOM == bufImg1.getType()) {
|
||||
@@ -224,10 +224,10 @@ public class FrameImage {
|
||||
result.putAll(context);
|
||||
}
|
||||
} else {
|
||||
String errMsg = UtilProperties.getMessage(RES_ERROR, "ProductPleaseSelectImage", locale);
|
||||
Debug.logFatal(errMsg, MODULE);
|
||||
result = ServiceUtil.returnError(errMsg);
|
||||
result.putAll(context);
|
||||
String errMsg = UtilProperties.getMessage(RES_ERROR, "ProductPleaseSelectImage", locale);
|
||||
Debug.logFatal(errMsg, MODULE);
|
||||
result = ServiceUtil.returnError(errMsg);
|
||||
result.putAll(context);
|
||||
}
|
||||
String successMsg = UtilProperties.getMessage(RESOURCE, "ProductFrameImageSuccessfully", locale);
|
||||
result = ServiceUtil.returnSuccess(successMsg);
|
||||
@@ -409,7 +409,7 @@ public class FrameImage {
|
||||
}
|
||||
|
||||
int width = Integer.parseInt(request.getParameter("imageWidth"));
|
||||
int height= Integer.parseInt(request.getParameter("imageHeight"));
|
||||
int height = Integer.parseInt(request.getParameter("imageHeight"));
|
||||
|
||||
Image newImg1 = bufImg1.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||
Image newImg2 = bufImg2.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||
@@ -418,8 +418,8 @@ public class FrameImage {
|
||||
ImageIO.write(bufNewImg, mimeType, new File(imageServerPath + "/preview/" + "/previewImage.jpg"));
|
||||
|
||||
} else {
|
||||
String errMsg = "Please select Image.";
|
||||
request.setAttribute("_EVENT_MESSAGE_", errMsg);
|
||||
String errMsg = "Please select Image.";
|
||||
request.setAttribute("_EVENT_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
return "success";
|
||||
|
||||
+1
-1
@@ -303,7 +303,7 @@ public class ImageManagementServices {
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
List<String> sizeTypeList = null;
|
||||
if (UtilValidate.isNotEmpty(resizeType)) {
|
||||
sizeTypeList = UtilMisc.toList(resizeType);
|
||||
sizeTypeList = UtilMisc.toList(resizeType);
|
||||
} else {
|
||||
sizeTypeList = UtilMisc.toList("small","100x75", "150x112", "320x240", "640x480", "800x600", "1024x768", "1280x1024", "1600x1200");
|
||||
}
|
||||
|
||||
+53
-49
@@ -689,56 +689,56 @@ public class InventoryServices {
|
||||
BigDecimal minQuantityOnHandTotal = null;
|
||||
BigDecimal minAvailableToPromiseTotal = null;
|
||||
|
||||
// loop through each associated product.
|
||||
for (GenericValue productAssoc: productAssocList) {
|
||||
String productIdTo = productAssoc.getString("productIdTo");
|
||||
BigDecimal assocQuantity = productAssoc.getBigDecimal("quantity");
|
||||
// loop through each associated product.
|
||||
for (GenericValue productAssoc : productAssocList) {
|
||||
String productIdTo = productAssoc.getString("productIdTo");
|
||||
BigDecimal assocQuantity = productAssoc.getBigDecimal("quantity");
|
||||
|
||||
// if there is no quantity for the associated product in ProductAssoc entity, default it to 1.0
|
||||
if (assocQuantity == null) {
|
||||
Debug.logWarning("ProductAssoc from [" + productAssoc.getString("productId") + "] to [" + productAssoc.getString("productIdTo")
|
||||
+ "] has no quantity, assuming 1.0", MODULE);
|
||||
assocQuantity = BigDecimal.ONE;
|
||||
}
|
||||
// if there is no quantity for the associated product in ProductAssoc entity, default it to 1.0
|
||||
if (assocQuantity == null) {
|
||||
Debug.logWarning("ProductAssoc from [" + productAssoc.getString("productId") + "] to [" + productAssoc.getString("productIdTo")
|
||||
+ "] has no quantity, assuming 1.0", MODULE);
|
||||
assocQuantity = BigDecimal.ONE;
|
||||
}
|
||||
|
||||
// figure out the inventory available for this associated product
|
||||
Map<String, Object> resultOutput = null;
|
||||
try {
|
||||
Map<String, String> inputMap = UtilMisc.toMap("productId", productIdTo, "statusId", statusId);
|
||||
if (facilityId != null) {
|
||||
inputMap.put("facilityId", facilityId);
|
||||
resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", inputMap);
|
||||
} else {
|
||||
resultOutput = dispatcher.runSync("getProductInventoryAvailable", inputMap);
|
||||
}
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, "Problems getting inventory available by facility", MODULE);
|
||||
return ServiceUtil.returnError(e.getMessage());
|
||||
}
|
||||
// figure out the inventory available for this associated product
|
||||
Map<String, Object> resultOutput = null;
|
||||
try {
|
||||
Map<String, String> inputMap = UtilMisc.toMap("productId", productIdTo, "statusId", statusId);
|
||||
if (facilityId != null) {
|
||||
inputMap.put("facilityId", facilityId);
|
||||
resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", inputMap);
|
||||
} else {
|
||||
resultOutput = dispatcher.runSync("getProductInventoryAvailable", inputMap);
|
||||
}
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, "Problems getting inventory available by facility", MODULE);
|
||||
return ServiceUtil.returnError(e.getMessage());
|
||||
}
|
||||
|
||||
// Figure out what the QOH and ATP inventory would be with this associated product
|
||||
BigDecimal currentQuantityOnHandTotal = (BigDecimal) resultOutput.get("quantityOnHandTotal");
|
||||
BigDecimal currentAvailableToPromiseTotal = (BigDecimal) resultOutput.get("availableToPromiseTotal");
|
||||
BigDecimal tmpQuantityOnHandTotal = currentQuantityOnHandTotal.divideToIntegralValue(assocQuantity, GEN_ROUNDING);
|
||||
BigDecimal tmpAvailableToPromiseTotal = currentAvailableToPromiseTotal.divideToIntegralValue(assocQuantity, GEN_ROUNDING);
|
||||
// Figure out what the QOH and ATP inventory would be with this associated product
|
||||
BigDecimal currentQuantityOnHandTotal = (BigDecimal) resultOutput.get("quantityOnHandTotal");
|
||||
BigDecimal currentAvailableToPromiseTotal = (BigDecimal) resultOutput.get("availableToPromiseTotal");
|
||||
BigDecimal tmpQuantityOnHandTotal = currentQuantityOnHandTotal.divideToIntegralValue(assocQuantity, GEN_ROUNDING);
|
||||
BigDecimal tmpAvailableToPromiseTotal = currentAvailableToPromiseTotal.divideToIntegralValue(assocQuantity, GEN_ROUNDING);
|
||||
|
||||
// reset the minimum QOH and ATP quantities if those quantities for this product are less
|
||||
if (minQuantityOnHandTotal == null || tmpQuantityOnHandTotal.compareTo(minQuantityOnHandTotal) < 0) {
|
||||
minQuantityOnHandTotal = tmpQuantityOnHandTotal;
|
||||
}
|
||||
if (minAvailableToPromiseTotal == null || tmpAvailableToPromiseTotal.compareTo(minAvailableToPromiseTotal) < 0) {
|
||||
minAvailableToPromiseTotal = tmpAvailableToPromiseTotal;
|
||||
}
|
||||
// reset the minimum QOH and ATP quantities if those quantities for this product are less
|
||||
if (minQuantityOnHandTotal == null || tmpQuantityOnHandTotal.compareTo(minQuantityOnHandTotal) < 0) {
|
||||
minQuantityOnHandTotal = tmpQuantityOnHandTotal;
|
||||
}
|
||||
if (minAvailableToPromiseTotal == null || tmpAvailableToPromiseTotal.compareTo(minAvailableToPromiseTotal) < 0) {
|
||||
minAvailableToPromiseTotal = tmpAvailableToPromiseTotal;
|
||||
}
|
||||
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("productIdTo = " + productIdTo + " assocQuantity = " + assocQuantity + "current QOH " + currentQuantityOnHandTotal
|
||||
+ "currentATP = " + currentAvailableToPromiseTotal + " minQOH = " + minQuantityOnHandTotal + " minATP = "
|
||||
+ minAvailableToPromiseTotal, MODULE);
|
||||
}
|
||||
}
|
||||
// the final QOH and ATP quantities are the minimum of all the products
|
||||
quantityOnHandTotal = minQuantityOnHandTotal;
|
||||
availableToPromiseTotal = minAvailableToPromiseTotal;
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("productIdTo = " + productIdTo + " assocQuantity = " + assocQuantity + "current QOH " + currentQuantityOnHandTotal
|
||||
+ "currentATP = " + currentAvailableToPromiseTotal + " minQOH = " + minQuantityOnHandTotal + " minATP = "
|
||||
+ minAvailableToPromiseTotal, MODULE);
|
||||
}
|
||||
}
|
||||
// the final QOH and ATP quantities are the minimum of all the products
|
||||
quantityOnHandTotal = minQuantityOnHandTotal;
|
||||
availableToPromiseTotal = minAvailableToPromiseTotal;
|
||||
}
|
||||
|
||||
Map<String, Object> result = ServiceUtil.returnSuccess();
|
||||
@@ -802,10 +802,13 @@ public class InventoryServices {
|
||||
|
||||
// get both the real ATP/QOH available and the quantities available from marketing packages
|
||||
try {
|
||||
if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG")) {
|
||||
mktgPkgInvResult = dispatcher.runSync("getMktgPackagesAvailable", UtilMisc.toMap("productId", productId, "facilityId", facility.getString("facilityId")));
|
||||
if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId",
|
||||
"MARKETING_PKG")) {
|
||||
mktgPkgInvResult = dispatcher.runSync("getMktgPackagesAvailable", UtilMisc.toMap("productId", productId, "facilityId",
|
||||
facility.getString("facilityId")));
|
||||
}
|
||||
invResult = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, "facilityId", facility.getString("facilityId")));
|
||||
invResult = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, "facilityId",
|
||||
facility.getString("facilityId")));
|
||||
} catch (GenericServiceException e) {
|
||||
Debug.logError(e, "Could not find inventory for facility " + facility.getString("facilityId"), MODULE);
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
|
||||
@@ -824,7 +827,8 @@ public class InventoryServices {
|
||||
qoh = qoh.add(fqoh);
|
||||
}
|
||||
}
|
||||
if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG") && ServiceUtil.isSuccess(mktgPkgInvResult)) {
|
||||
if (EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId",
|
||||
"MARKETING_PKG") && ServiceUtil.isSuccess(mktgPkgInvResult)) {
|
||||
BigDecimal fatp = (BigDecimal) mktgPkgInvResult.get("availableToPromiseTotal");
|
||||
BigDecimal fqoh = (BigDecimal) mktgPkgInvResult.get("quantityOnHandTotal");
|
||||
if (fatp != null) {
|
||||
|
||||
+30
-23
@@ -461,11 +461,12 @@ public class PriceServices {
|
||||
ruleListToUse.addAll(nonQuantityProductPriceRules);
|
||||
|
||||
Map<String, Object> quantCalcResults = calcPriceResultFromRules(ruleListToUse, listPrice, defaultPrice, promoPrice,
|
||||
wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
|
||||
averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
|
||||
webSiteId, partyId, null, currencyDefaultUomId, delegator, nowTimestamp, locale);
|
||||
Map<String, Object> quantErrorResult = addGeneralResults(quantCalcResults, competitivePriceValue, specialPromoPriceValue, productStore,
|
||||
checkIncludeVat, currencyDefaultUomId, productId, quantity, partyId, dispatcher, locale);
|
||||
wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
|
||||
averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
|
||||
webSiteId, partyId, null, currencyDefaultUomId, delegator, nowTimestamp, locale);
|
||||
Map<String, Object> quantErrorResult = addGeneralResults(quantCalcResults, competitivePriceValue, specialPromoPriceValue,
|
||||
productStore,
|
||||
checkIncludeVat, currencyDefaultUomId, productId, quantity, partyId, dispatcher, locale);
|
||||
if (quantErrorResult != null) return quantErrorResult;
|
||||
|
||||
// also add the quantityProductPriceRule to the Map so it can be used for quantity break information
|
||||
@@ -477,9 +478,9 @@ public class PriceServices {
|
||||
|
||||
// use a quantity 1 to get the main price, then fill in the quantity break prices
|
||||
Map<String, Object> calcResults = calcPriceResultFromRules(allProductPriceRules, listPrice, defaultPrice, promoPrice,
|
||||
wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
|
||||
averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
|
||||
webSiteId, partyId, BigDecimal.ONE, currencyDefaultUomId, delegator, nowTimestamp, locale);
|
||||
wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
|
||||
averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
|
||||
webSiteId, partyId, BigDecimal.ONE, currencyDefaultUomId, delegator, nowTimestamp, locale);
|
||||
result.putAll(calcResults);
|
||||
// The orderItemPriceInfos out parameter requires a special treatment:
|
||||
// the list of OrderItemPriceInfos generated by the price rule is appended to
|
||||
@@ -495,9 +496,9 @@ public class PriceServices {
|
||||
if (errorResult != null) return errorResult;
|
||||
} else {
|
||||
Map<String, Object> calcResults = calcPriceResultFromRules(allProductPriceRules, listPrice, defaultPrice, promoPrice,
|
||||
wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
|
||||
averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
|
||||
webSiteId, partyId, quantity, currencyDefaultUomId, delegator, nowTimestamp, locale);
|
||||
wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
|
||||
averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
|
||||
webSiteId, partyId, quantity, currencyDefaultUomId, delegator, nowTimestamp, locale);
|
||||
result.putAll(calcResults);
|
||||
// The orderItemPriceInfos out parameter requires a special treatment:
|
||||
// the list of OrderItemPriceInfos generated by the price rule is appended to
|
||||
@@ -509,7 +510,7 @@ public class PriceServices {
|
||||
result.put("orderItemPriceInfos", orderItemPriceInfos);
|
||||
|
||||
Map<String, Object> errorResult = addGeneralResults(result, competitivePriceValue, specialPromoPriceValue, productStore,
|
||||
checkIncludeVat, currencyDefaultUomId, productId, quantity, partyId, dispatcher, locale);
|
||||
checkIncludeVat, currencyDefaultUomId, productId, quantity, partyId, dispatcher, locale);
|
||||
if (errorResult != null) return errorResult;
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -544,7 +545,8 @@ public class PriceServices {
|
||||
if (tempPrice != null && tempPrice != BigDecimal.ZERO) {
|
||||
Map<String, Object> priceResults = new HashMap<>();
|
||||
try {
|
||||
priceResults = dispatcher.runSync("convertUom", UtilMisc.<String, Object> toMap("uomId", currencyDefaultUomId, "uomIdTo", currencyUomIdTo,
|
||||
priceResults = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", currencyDefaultUomId,
|
||||
"uomIdTo", currencyUomIdTo,
|
||||
"originalValue", tempPrice, "defaultDecimalScale", 2L, "defaultRoundingMode", "HalfUp"));
|
||||
if (ServiceUtil.isError(priceResults) || (priceResults.get("convertedValue") == null)) {
|
||||
Debug.logWarning("Unable to convert " + entry.getKey() + " for product " + productId, MODULE);
|
||||
@@ -573,8 +575,8 @@ public class PriceServices {
|
||||
if (filteredPrices != null && filteredPrices.size() > 1) {
|
||||
if (Debug.infoOn()) {
|
||||
Debug.logInfo("There is more than one " + productPriceTypeId + " with the currencyUomId " + priceValue.getString("currencyUomId")
|
||||
+ " and productId " + priceValue.getString("productId") + ", using the latest found with price: "
|
||||
+ priceValue.getBigDecimal("price"), MODULE);
|
||||
+ " and productId " + priceValue.getString("productId") + ", using the latest found with price: "
|
||||
+ priceValue.getBigDecimal("price"), MODULE);
|
||||
}
|
||||
}
|
||||
if (priceValue == null && secondaryPriceList != null) {
|
||||
@@ -584,8 +586,9 @@ public class PriceServices {
|
||||
}
|
||||
|
||||
public static Map<String, Object> addGeneralResults(Map<String, Object> result, GenericValue competitivePriceValue,
|
||||
GenericValue specialPromoPriceValue, GenericValue productStore, String checkIncludeVat, String currencyUomId, String productId,
|
||||
BigDecimal quantity, String partyId, LocalDispatcher dispatcher, Locale locale) {
|
||||
GenericValue specialPromoPriceValue, GenericValue productStore, String checkIncludeVat,
|
||||
String currencyUomId, String productId,
|
||||
BigDecimal quantity, String partyId, LocalDispatcher dispatcher, Locale locale) {
|
||||
result.put("competitivePrice", competitivePriceValue != null ? competitivePriceValue.getBigDecimal("price") : null);
|
||||
result.put("specialPromoPrice", specialPromoPriceValue != null ? specialPromoPriceValue.getBigDecimal("price") : null);
|
||||
result.put("currencyUsed", currencyUomId);
|
||||
@@ -790,11 +793,15 @@ public class PriceServices {
|
||||
return productPriceRules;
|
||||
}
|
||||
|
||||
public static Map<String, Object> calcPriceResultFromRules(List<GenericValue> productPriceRules, BigDecimal listPrice, BigDecimal defaultPrice, BigDecimal promoPrice,
|
||||
BigDecimal wholesalePrice, GenericValue maximumPriceValue, GenericValue minimumPriceValue, boolean validPriceFound,
|
||||
GenericValue averageCostValue, String productId, String virtualProductId, String prodCatalogId, String productStoreGroupId,
|
||||
String webSiteId, String partyId, BigDecimal quantity, String currencyUomId, Delegator delegator, Timestamp nowTimestamp,
|
||||
Locale locale) throws GenericEntityException {
|
||||
public static Map<String, Object> calcPriceResultFromRules(List<GenericValue> productPriceRules, BigDecimal listPrice, BigDecimal defaultPrice,
|
||||
BigDecimal promoPrice,
|
||||
BigDecimal wholesalePrice, GenericValue maximumPriceValue,
|
||||
GenericValue minimumPriceValue, boolean validPriceFound,
|
||||
GenericValue averageCostValue, String productId, String virtualProductId,
|
||||
String prodCatalogId, String productStoreGroupId,
|
||||
String webSiteId, String partyId, BigDecimal quantity, String currencyUomId,
|
||||
Delegator delegator, Timestamp nowTimestamp,
|
||||
Locale locale) throws GenericEntityException {
|
||||
|
||||
Map<String, Object> calcResults = new HashMap<>();
|
||||
|
||||
@@ -1057,7 +1064,7 @@ public class PriceServices {
|
||||
int compare = 0;
|
||||
|
||||
if ("PRIP_PRODUCT_ID".equals(productPriceCond.getString("inputParamEnumId"))) {
|
||||
compare = UtilMisc.toList(productId, virtualProductId).contains(productPriceCond.getString("condValue"))? 0: 1;
|
||||
compare = UtilMisc.toList(productId, virtualProductId).contains(productPriceCond.getString("condValue")) ? 0 : 1;
|
||||
} else if ("PRIP_PROD_CAT_ID".equals(productPriceCond.getString("inputParamEnumId"))) {
|
||||
// if a ProductCategoryMember exists for this productId and the specified productCategoryId
|
||||
String productCategoryId = productPriceCond.getString("condValue");
|
||||
|
||||
+17
-18
@@ -121,16 +121,16 @@ public class ProductContentWrapper implements ContentWrapper {
|
||||
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 = product.getModelEntity().isField(candidateFieldName) ? product.getString(candidateFieldName) : "";
|
||||
outString = outString == null ? "" : outString;
|
||||
}
|
||||
outString = encoder.sanitize(outString, null);
|
||||
productContentCache.put(cacheKey, outString);
|
||||
return outString;
|
||||
} catch (GeneralException | IOException e) {
|
||||
Debug.logError(e, "Error rendering ProductContent, inserting empty String", MODULE);
|
||||
String candidateOut = product.getModelEntity().isField(candidateFieldName) ? product.getString(candidateFieldName): "";
|
||||
return candidateOut == null? "" : encoder.sanitize(candidateOut, null);
|
||||
String candidateOut = product.getModelEntity().isField(candidateFieldName) ? product.getString(candidateFieldName) : "";
|
||||
return candidateOut == null ? "" : encoder.sanitize(candidateOut, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,22 +183,21 @@ public class ProductContentWrapper implements ContentWrapper {
|
||||
}
|
||||
|
||||
if (productModel.isField(candidateFieldName)) {
|
||||
String candidateValue = product.getString(candidateFieldName);
|
||||
if (UtilValidate.isNotEmpty(candidateValue)) {
|
||||
outWriter.write(candidateValue);
|
||||
return;
|
||||
} else if ("Y".equals(product.getString("isVariant"))) {
|
||||
// look up the virtual product
|
||||
GenericValue parent = ProductWorker.getParentProduct(productId, delegator);
|
||||
if (parent != null) {
|
||||
candidateValue = parent.getString(candidateFieldName);
|
||||
if (UtilValidate.isNotEmpty(candidateValue)) {
|
||||
outWriter.write(candidateValue);
|
||||
return;
|
||||
}
|
||||
String candidateValue = product.getString(candidateFieldName);
|
||||
if (UtilValidate.isNotEmpty(candidateValue)) {
|
||||
outWriter.write(candidateValue);
|
||||
return;
|
||||
} else if ("Y".equals(product.getString("isVariant"))) {
|
||||
// look up the virtual product
|
||||
GenericValue parent = ProductWorker.getParentProduct(productId, delegator);
|
||||
if (parent != null) {
|
||||
candidateValue = parent.getString(candidateFieldName);
|
||||
if (UtilValidate.isNotEmpty(candidateValue)) {
|
||||
outWriter.write(candidateValue);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -127,7 +127,7 @@ public class ProductPromoContentWrapper implements ContentWrapper {
|
||||
String outString = outWriter.toString();
|
||||
if (UtilValidate.isEmpty(outString)) {
|
||||
outString = productPromo.getModelEntity().isField(candidateFieldName) ? productPromo.getString(candidateFieldName): "";
|
||||
outString = outString == null? "" : outString;
|
||||
outString = outString == null ? "" : outString;
|
||||
}
|
||||
outString = encoder.sanitize(outString, null);
|
||||
productPromoContentCache.put(cacheKey, outString);
|
||||
@@ -135,7 +135,7 @@ public class ProductPromoContentWrapper implements ContentWrapper {
|
||||
} catch (GeneralException | IOException e) {
|
||||
Debug.logError(e, "Error rendering ProductPromoContent, inserting empty String", MODULE);
|
||||
String candidateOut = productPromo.getModelEntity().isField(candidateFieldName) ? productPromo.getString(candidateFieldName): "";
|
||||
return candidateOut == null? "" : encoder.sanitize(candidateOut, null);
|
||||
return candidateOut == null ? "" : encoder.sanitize(candidateOut, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -357,11 +357,11 @@ public class ProductSearch {
|
||||
|
||||
public void finishCategoryAndFeatureConstraints() {
|
||||
if (includeCategoryIds.size() == 0 && excludeCategoryIds.size() == 0 && alwaysIncludeCategoryIds.size() == 0
|
||||
&& includeCategoryIdOrSetAndList.size() == 0 && alwaysIncludeCategoryIdOrSetAndList.size() == 0
|
||||
&& includeFeatureIds.size() == 0 && excludeFeatureIds.size() == 0 && alwaysIncludeFeatureIds.size() == 0
|
||||
&& includeFeatureIdOrSetAndList.size() == 0 && alwaysIncludeFeatureIdOrSetAndList.size() == 0
|
||||
&& includeFeatureCategoryIds.size() == 0 && excludeFeatureCategoryIds.size() == 0 && alwaysIncludeFeatureCategoryIds.size() == 0
|
||||
&& includeFeatureGroupIds.size() == 0 && excludeFeatureGroupIds.size() == 0 && alwaysIncludeFeatureGroupIds.size() == 0) {
|
||||
&& includeCategoryIdOrSetAndList.size() == 0 && alwaysIncludeCategoryIdOrSetAndList.size() == 0
|
||||
&& includeFeatureIds.size() == 0 && excludeFeatureIds.size() == 0 && alwaysIncludeFeatureIds.size() == 0
|
||||
&& includeFeatureIdOrSetAndList.size() == 0 && alwaysIncludeFeatureIdOrSetAndList.size() == 0
|
||||
&& includeFeatureCategoryIds.size() == 0 && excludeFeatureCategoryIds.size() == 0 && alwaysIncludeFeatureCategoryIds.size() == 0
|
||||
&& includeFeatureGroupIds.size() == 0 && excludeFeatureGroupIds.size() == 0 && alwaysIncludeFeatureGroupIds.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+191
-160
@@ -51,25 +51,28 @@ import org.apache.ofbiz.webapp.stats.VisitHandler;
|
||||
*/
|
||||
public class ProductSearchEvents {
|
||||
|
||||
public static final int DEFAULT_TX_TIMEOUT = 600;
|
||||
private static final String MODULE = ProductSearchEvents.class.getName();
|
||||
private static final String RESOURCE = "ProductErrorUiLabels";
|
||||
public static final int DEFAULT_TX_TIMEOUT = 600;
|
||||
|
||||
/** Removes the results of a search from the specified category
|
||||
*@param request The HTTPRequest object for the current request
|
||||
*@param response The HTTPResponse object for the current request
|
||||
*@return String specifying the exit status of this event
|
||||
/**
|
||||
* Removes the results of a search from the specified category
|
||||
*
|
||||
* @param request The HTTPRequest object for the current request
|
||||
* @param response The HTTPResponse object for the current request
|
||||
* @return String specifying the exit status of this event
|
||||
*/
|
||||
public static String searchRemoveFromCategory(HttpServletRequest request, HttpServletResponse response) {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
String productCategoryId = request.getParameter("SE_SEARCH_CATEGORY_ID");
|
||||
String errMsg=null;
|
||||
String errMsg = null;
|
||||
|
||||
try {
|
||||
boolean beganTransaction = TransactionUtil.begin(DEFAULT_TX_TIMEOUT);
|
||||
try (EntityListIterator eli = getProductSearchResults(request)) {
|
||||
if (eli == null) {
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints", UtilHttp.getLocale(request));
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints",
|
||||
UtilHttp.getLocale(request));
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
@@ -78,14 +81,16 @@ public class ProductSearchEvents {
|
||||
GenericValue searchResultView = null;
|
||||
while ((searchResultView = eli.next()) != null) {
|
||||
String productId = searchResultView.getString("mainProductId");
|
||||
numRemoved += delegator.removeByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId));
|
||||
numRemoved += delegator.removeByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId,
|
||||
"productId", productId));
|
||||
}
|
||||
Map<String, String> messageMap = UtilMisc.toMap("numRemoved", Integer.toString(numRemoved));
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.removed_x_items", messageMap, UtilHttp.getLocale(request));
|
||||
request.setAttribute("_EVENT_MESSAGE_", errMsg);
|
||||
} catch (GenericEntityException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errSearchResult", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap, UtilHttp.getLocale(request));
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap,
|
||||
UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
TransactionUtil.rollback(beganTransaction, errMsg, e);
|
||||
@@ -103,148 +108,161 @@ public class ProductSearchEvents {
|
||||
return "success";
|
||||
}
|
||||
|
||||
/** Sets the thru date of the results of a search to the specified date for the specified catogory
|
||||
*@param request The HTTPRequest object for the current request
|
||||
*@param response The HTTPResponse object for the current request
|
||||
*@return String specifying the exit status of this event
|
||||
*/
|
||||
public static String searchExpireFromCategory(HttpServletRequest request, HttpServletResponse response) {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
String productCategoryId = request.getParameter("SE_SEARCH_CATEGORY_ID");
|
||||
String thruDateStr = request.getParameter("thruDate");
|
||||
String errMsg=null;
|
||||
/**
|
||||
* Sets the thru date of the results of a search to the specified date for the specified catogory
|
||||
*
|
||||
* @param request The HTTPRequest object for the current request
|
||||
* @param response The HTTPResponse object for the current request
|
||||
* @return String specifying the exit status of this event
|
||||
*/
|
||||
public static String searchExpireFromCategory(HttpServletRequest request, HttpServletResponse response) {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
String productCategoryId = request.getParameter("SE_SEARCH_CATEGORY_ID");
|
||||
String thruDateStr = request.getParameter("thruDate");
|
||||
String errMsg = null;
|
||||
|
||||
Timestamp thruDate;
|
||||
try {
|
||||
thruDate = Timestamp.valueOf(thruDateStr);
|
||||
} catch (RuntimeException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errDateFormat", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.thruDate_not_formatted_properly", messageMap, UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
try {
|
||||
boolean beganTransaction = TransactionUtil.begin(DEFAULT_TX_TIMEOUT);
|
||||
try (EntityListIterator eli = getProductSearchResults(request)) {
|
||||
if (eli == null) {
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints", UtilHttp.getLocale(request));
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
GenericValue searchResultView = null;
|
||||
int numExpired = 0;
|
||||
while ((searchResultView = eli.next()) != null) {
|
||||
String productId = searchResultView.getString("mainProductId");
|
||||
//get all tuples that match product and category
|
||||
List<GenericValue> pcmList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", productCategoryId, "productId", productId).queryList();
|
||||
|
||||
//set those thrudate to that specificed maybe remove then add new one
|
||||
for (GenericValue pcm: pcmList) {
|
||||
if (pcm.get("thruDate") == null) {
|
||||
pcm.set("thruDate", thruDate);
|
||||
pcm.store();
|
||||
numExpired++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> messageMap = UtilMisc.toMap("numExpired", Integer.toString(numExpired));
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.expired_x_items", messageMap, UtilHttp.getLocale(request));
|
||||
request.setAttribute("_EVENT_MESSAGE_", errMsg);
|
||||
} catch (GenericEntityException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errSearchResult", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap, UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
TransactionUtil.rollback(beganTransaction, errMsg, e);
|
||||
return "error";
|
||||
} finally {
|
||||
TransactionUtil.commit(beganTransaction);
|
||||
}
|
||||
} catch (GenericTransactionException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errSearchResult", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap, UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
return "success";
|
||||
}
|
||||
|
||||
/** Adds the results of a search to the specified catogory
|
||||
*@param request The HTTPRequest object for the current request
|
||||
*@param response The HTTPResponse object for the current request
|
||||
*@return String specifying the exit status of this event
|
||||
*/
|
||||
public static String searchAddToCategory(HttpServletRequest request, HttpServletResponse response) {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
String productCategoryId = request.getParameter("SE_SEARCH_CATEGORY_ID");
|
||||
String fromDateStr = request.getParameter("fromDate");
|
||||
Timestamp fromDate = null;
|
||||
String errMsg = null;
|
||||
|
||||
try {
|
||||
fromDate = Timestamp.valueOf(fromDateStr);
|
||||
Timestamp thruDate;
|
||||
try {
|
||||
thruDate = Timestamp.valueOf(thruDateStr);
|
||||
} catch (RuntimeException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errDateFormat", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.fromDate_not_formatted_properly", messageMap, UtilHttp.getLocale(request));
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errDateFormat", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.thruDate_not_formatted_properly", messageMap,
|
||||
UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
try {
|
||||
boolean beganTransaction = TransactionUtil.begin(DEFAULT_TX_TIMEOUT);
|
||||
try (EntityListIterator eli = getProductSearchResults(request)) {
|
||||
if (eli == null) {
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints", UtilHttp.getLocale(request));
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
try {
|
||||
boolean beganTransaction = TransactionUtil.begin(DEFAULT_TX_TIMEOUT);
|
||||
try (EntityListIterator eli = getProductSearchResults(request)) {
|
||||
if (eli == null) {
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints",
|
||||
UtilHttp.getLocale(request));
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
GenericValue searchResultView = null;
|
||||
int numAdded = 0;
|
||||
while ((searchResultView = eli.next()) != null) {
|
||||
String productId = searchResultView.getString("mainProductId");
|
||||
GenericValue searchResultView = null;
|
||||
int numExpired = 0;
|
||||
while ((searchResultView = eli.next()) != null) {
|
||||
String productId = searchResultView.getString("mainProductId");
|
||||
//get all tuples that match product and category
|
||||
List<GenericValue> pcmList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId",
|
||||
productCategoryId, "productId", productId).queryList();
|
||||
|
||||
GenericValue pcm=delegator.makeValue("ProductCategoryMember");
|
||||
pcm.set("productCategoryId", productCategoryId);
|
||||
pcm.set("productId", productId);
|
||||
pcm.set("fromDate", fromDate);
|
||||
pcm.create();
|
||||
//set those thrudate to that specificed maybe remove then add new one
|
||||
for (GenericValue pcm : pcmList) {
|
||||
if (pcm.get("thruDate") == null) {
|
||||
pcm.set("thruDate", thruDate);
|
||||
pcm.store();
|
||||
numExpired++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> messageMap = UtilMisc.toMap("numExpired", Integer.toString(numExpired));
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.expired_x_items", messageMap, UtilHttp.getLocale(request));
|
||||
request.setAttribute("_EVENT_MESSAGE_", errMsg);
|
||||
} catch (GenericEntityException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errSearchResult", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap,
|
||||
UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
TransactionUtil.rollback(beganTransaction, errMsg, e);
|
||||
return "error";
|
||||
} finally {
|
||||
TransactionUtil.commit(beganTransaction);
|
||||
}
|
||||
} catch (GenericTransactionException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errSearchResult", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap, UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
return "success";
|
||||
}
|
||||
|
||||
numAdded++;
|
||||
}
|
||||
Map<String, String> messageMap = UtilMisc.toMap("numAdded", Integer.toString(numAdded));
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.added_x_product_category_members", messageMap, UtilHttp.getLocale(request));
|
||||
request.setAttribute("_EVENT_MESSAGE_", errMsg);
|
||||
} catch (GenericEntityException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errSearchResult", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap, UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
TransactionUtil.rollback(beganTransaction, errMsg, e);
|
||||
return "error";
|
||||
} finally {
|
||||
TransactionUtil.commit(beganTransaction);
|
||||
}
|
||||
} catch (GenericTransactionException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errSearchResult", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap, UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
/**
|
||||
* Adds the results of a search to the specified catogory
|
||||
*
|
||||
* @param request The HTTPRequest object for the current request
|
||||
* @param response The HTTPResponse object for the current request
|
||||
* @return String specifying the exit status of this event
|
||||
*/
|
||||
public static String searchAddToCategory(HttpServletRequest request, HttpServletResponse response) {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
String productCategoryId = request.getParameter("SE_SEARCH_CATEGORY_ID");
|
||||
String fromDateStr = request.getParameter("fromDate");
|
||||
Timestamp fromDate = null;
|
||||
String errMsg = null;
|
||||
|
||||
return "success";
|
||||
}
|
||||
try {
|
||||
fromDate = Timestamp.valueOf(fromDateStr);
|
||||
} catch (RuntimeException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errDateFormat", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.fromDate_not_formatted_properly", messageMap,
|
||||
UtilHttp.getLocale(request));
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
/** Adds a feature to search results
|
||||
*@param request The HTTPRequest object for the current request
|
||||
*@param response The HTTPResponse object for the current request
|
||||
*@return String specifying the exit status of this event
|
||||
try {
|
||||
boolean beganTransaction = TransactionUtil.begin(DEFAULT_TX_TIMEOUT);
|
||||
try (EntityListIterator eli = getProductSearchResults(request)) {
|
||||
if (eli == null) {
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints",
|
||||
UtilHttp.getLocale(request));
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
GenericValue searchResultView = null;
|
||||
int numAdded = 0;
|
||||
while ((searchResultView = eli.next()) != null) {
|
||||
String productId = searchResultView.getString("mainProductId");
|
||||
|
||||
GenericValue pcm = delegator.makeValue("ProductCategoryMember");
|
||||
pcm.set("productCategoryId", productCategoryId);
|
||||
pcm.set("productId", productId);
|
||||
pcm.set("fromDate", fromDate);
|
||||
pcm.create();
|
||||
|
||||
numAdded++;
|
||||
}
|
||||
Map<String, String> messageMap = UtilMisc.toMap("numAdded", Integer.toString(numAdded));
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.added_x_product_category_members", messageMap,
|
||||
UtilHttp.getLocale(request));
|
||||
request.setAttribute("_EVENT_MESSAGE_", errMsg);
|
||||
} catch (GenericEntityException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errSearchResult", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap,
|
||||
UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
TransactionUtil.rollback(beganTransaction, errMsg, e);
|
||||
return "error";
|
||||
} finally {
|
||||
TransactionUtil.commit(beganTransaction);
|
||||
}
|
||||
} catch (GenericTransactionException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errSearchResult", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap, UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
|
||||
return "success";
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a feature to search results
|
||||
*
|
||||
* @param request The HTTPRequest object for the current request
|
||||
* @param response The HTTPResponse object for the current request
|
||||
* @return String specifying the exit status of this event
|
||||
*/
|
||||
public static String searchAddFeature(HttpServletRequest request, HttpServletResponse response) {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
@@ -273,7 +291,7 @@ public class ProductSearchEvents {
|
||||
amount = new BigDecimal(amountStr);
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(sequenceNumStr)) {
|
||||
sequenceNum= Long.valueOf(sequenceNumStr);
|
||||
sequenceNum = Long.valueOf(sequenceNumStr);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
String errorMsg = UtilProperties.getMessage(RESOURCE, "productSearchEvents.error_casting_types", locale) + " : " + e.toString();
|
||||
@@ -286,7 +304,8 @@ public class ProductSearchEvents {
|
||||
boolean beganTransaction = TransactionUtil.begin(DEFAULT_TX_TIMEOUT);
|
||||
try (EntityListIterator eli = getProductSearchResults(request)) {
|
||||
if (eli == null) {
|
||||
String errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints", UtilHttp.getLocale(request));
|
||||
String errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints",
|
||||
UtilHttp.getLocale(request));
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
@@ -295,7 +314,7 @@ public class ProductSearchEvents {
|
||||
int numAdded = 0;
|
||||
while ((searchResultView = eli.next()) != null) {
|
||||
String productId = searchResultView.getString("mainProductId");
|
||||
GenericValue pfa=delegator.makeValue("ProductFeatureAppl");
|
||||
GenericValue pfa = delegator.makeValue("ProductFeatureAppl");
|
||||
pfa.set("productId", productId);
|
||||
pfa.set("productFeatureId", productFeatureId);
|
||||
pfa.set("fromDate", fromDate);
|
||||
@@ -328,10 +347,12 @@ public class ProductSearchEvents {
|
||||
return "success";
|
||||
}
|
||||
|
||||
/** Removes a feature from search results
|
||||
*@param request The HTTPRequest object for the current request
|
||||
*@param response The HTTPResponse object for the current request
|
||||
*@return String specifying the exit status of this event
|
||||
/**
|
||||
* Removes a feature from search results
|
||||
*
|
||||
* @param request The HTTPRequest object for the current request
|
||||
* @param response The HTTPResponse object for the current request
|
||||
* @return String specifying the exit status of this event
|
||||
*/
|
||||
public static String searchRemoveFeature(HttpServletRequest request, HttpServletResponse response) {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
@@ -343,7 +364,8 @@ public class ProductSearchEvents {
|
||||
boolean beganTransaction = TransactionUtil.begin(DEFAULT_TX_TIMEOUT);
|
||||
try (EntityListIterator eli = getProductSearchResults(request)) {
|
||||
if (eli == null) {
|
||||
String errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints", UtilHttp.getLocale(request));
|
||||
String errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints",
|
||||
UtilHttp.getLocale(request));
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
@@ -352,7 +374,8 @@ public class ProductSearchEvents {
|
||||
int numRemoved = 0;
|
||||
while ((searchResultView = eli.next()) != null) {
|
||||
String productId = searchResultView.getString("mainProductId");
|
||||
numRemoved += delegator.removeByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productId, "productFeatureId", productFeatureId));
|
||||
numRemoved += delegator.removeByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productId, "productFeatureId",
|
||||
productFeatureId));
|
||||
}
|
||||
Map<String, Object> messageMap = UtilMisc.toMap("numRemoved", numRemoved, "productFeatureId", productFeatureId);
|
||||
String eventMsg = UtilProperties.getMessage(RESOURCE, "productSearchEvents.removed_param_features", messageMap, locale) + ".";
|
||||
@@ -376,10 +399,12 @@ public class ProductSearchEvents {
|
||||
return "success";
|
||||
}
|
||||
|
||||
/** Formats the results of a search to the screen as a tab-delimited output
|
||||
*@param request The HTTPRequest object for the current request
|
||||
*@param response The HTTPResponse object for the current request
|
||||
*@return String specifying the exit status of this event
|
||||
/**
|
||||
* Formats the results of a search to the screen as a tab-delimited output
|
||||
*
|
||||
* @param request The HTTPRequest object for the current request
|
||||
* @param response The HTTPResponse object for the current request
|
||||
* @return String specifying the exit status of this event
|
||||
*/
|
||||
public static String searchExportProductList(HttpServletRequest request, HttpServletResponse response) {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
@@ -390,7 +415,8 @@ public class ProductSearchEvents {
|
||||
boolean beganTransaction = TransactionUtil.begin(DEFAULT_TX_TIMEOUT);
|
||||
try (EntityListIterator eli = getProductSearchResults(request)) {
|
||||
if (eli == null) {
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints", UtilHttp.getLocale(request));
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.no_results_found_probably_error_constraints",
|
||||
UtilHttp.getLocale(request));
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
return "error";
|
||||
}
|
||||
@@ -401,17 +427,21 @@ public class ProductSearchEvents {
|
||||
String productId = searchResultView.getString("mainProductId");
|
||||
productMap.put("productId", productId);
|
||||
|
||||
productMap.put("productFeatureCustom", EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureTypeId", "HAZMAT").filterByDate().queryFirst());
|
||||
productMap.put("productFeatureCustom", EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId,
|
||||
"productFeatureTypeId", "HAZMAT").filterByDate().queryFirst());
|
||||
|
||||
List<GenericValue> productCategories = EntityQuery.use(delegator).from("ProductCategoryAndMember").where("productId", productId).filterByDate().queryList();
|
||||
List<GenericValue> productCategories = EntityQuery.use(delegator).from("ProductCategoryAndMember").where("productId",
|
||||
productId).filterByDate().queryList();
|
||||
productMap.put("productCategories", productCategories);
|
||||
List<GenericValue> productFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId).filterByDate().queryList();
|
||||
List<GenericValue> productFeatures =
|
||||
EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId).filterByDate().queryList();
|
||||
productMap.put("productFeatures", productFeatures);
|
||||
productExportList.add(productMap);
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
Map<String, String> messageMap = UtilMisc.toMap("errSearchResult", e.toString());
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap, UtilHttp.getLocale(request));
|
||||
errMsg = UtilProperties.getMessage(RESOURCE, "productsearchevents.error_getting_search_results", messageMap,
|
||||
UtilHttp.getLocale(request));
|
||||
Debug.logError(e, errMsg, MODULE);
|
||||
request.setAttribute("_ERROR_MESSAGE_", errMsg);
|
||||
TransactionUtil.rollback(beganTransaction, errMsg, e);
|
||||
@@ -436,7 +466,8 @@ public class ProductSearchEvents {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
String visitId = VisitHandler.getVisitId(session);
|
||||
|
||||
List<ProductSearch.ProductSearchConstraint> productSearchConstraintList = ProductSearchSession.ProductSearchOptions.getConstraintList(session);
|
||||
List<ProductSearch.ProductSearchConstraint> productSearchConstraintList =
|
||||
ProductSearchSession.ProductSearchOptions.getConstraintList(session);
|
||||
// if no constraints, don't do a search...
|
||||
if (UtilValidate.isNotEmpty(productSearchConstraintList)) {
|
||||
ResultSortOrder resultSortOrder = ProductSearchSession.ProductSearchOptions.getResultSortOrder(request);
|
||||
|
||||
+1
-1
@@ -1336,7 +1336,7 @@ public class ProductServices {
|
||||
filenameToUse += "." + extension.getString("fileExtensionId");
|
||||
}
|
||||
|
||||
File makeResourceDirectory = new File(imageServerPath + "/" + filePathPrefix);
|
||||
File makeResourceDirectory = new File(imageServerPath + "/" + filePathPrefix);
|
||||
if (!makeResourceDirectory.exists()) {
|
||||
if (!makeResourceDirectory.mkdirs()) {
|
||||
Debug.logError("Directory :" + makeResourceDirectory.getPath() + ", couldn't be created", MODULE);
|
||||
|
||||
+13
-13
@@ -100,11 +100,11 @@ public final class ProductWorker {
|
||||
return true;
|
||||
}
|
||||
// exclusion
|
||||
for (GenericValue productGeo: excludeGeos) {
|
||||
for (GenericValue productGeo : excludeGeos) {
|
||||
List<GenericValue> excludeGeoGroup = GeoWorker.expandGeoGroup(productGeo.getString("geoId"), delegator);
|
||||
if (GeoWorker.containsGeo(excludeGeoGroup, postalAddress.getString("countryGeoId"), delegator)
|
||||
|| GeoWorker.containsGeo(excludeGeoGroup, postalAddress.getString("stateProvinceGeoId"), delegator)
|
||||
|| GeoWorker.containsGeo(excludeGeoGroup, postalAddress.getString("postalCodeGeoId"), delegator)) {
|
||||
|| GeoWorker.containsGeo(excludeGeoGroup, postalAddress.getString("stateProvinceGeoId"), delegator)
|
||||
|| GeoWorker.containsGeo(excludeGeoGroup, postalAddress.getString("postalCodeGeoId"), delegator)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -750,7 +750,7 @@ public final class ProductWorker {
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logWarning(e.getMessage(), MODULE);
|
||||
}
|
||||
String isDigitalValue = (productType != null? productType.getString("isDigital"): null);
|
||||
String isDigitalValue = (productType != null ? productType.getString("isDigital") : null);
|
||||
isDigital = isDigitalValue != null && "Y".equalsIgnoreCase(isDigitalValue);
|
||||
}
|
||||
return isDigital;
|
||||
@@ -765,7 +765,7 @@ public final class ProductWorker {
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logWarning(e.getMessage(), MODULE);
|
||||
}
|
||||
String isPhysicalValue = (productType != null? productType.getString("isPhysical"): null);
|
||||
String isPhysicalValue = (productType != null ? productType.getString("isPhysical") : null);
|
||||
isPhysical = isPhysicalValue != null && "Y".equalsIgnoreCase(isPhysicalValue);
|
||||
}
|
||||
return isPhysical;
|
||||
@@ -909,7 +909,7 @@ public final class ProductWorker {
|
||||
}
|
||||
|
||||
public static List<GenericValue> findProductsById(Delegator delegator, String idToFind, String goodIdentificationTypeId)
|
||||
throws GenericEntityException {
|
||||
throws GenericEntityException {
|
||||
return findProductsById(delegator, idToFind, goodIdentificationTypeId, true, false);
|
||||
}
|
||||
|
||||
@@ -1051,7 +1051,7 @@ public final class ProductWorker {
|
||||
// find variant
|
||||
List<GenericValue> productAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList();
|
||||
boolean productFound = false;
|
||||
nextProd:
|
||||
nextProd:
|
||||
for (GenericValue productAssoc: productAssocs) {
|
||||
for (String featureId: selectedFeatures) {
|
||||
List<GenericValue> pAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productAssoc.getString("productIdTo"), "productFeatureId", featureId, "productFeatureApplTypeId", "STANDARD_FEATURE").cache(true).queryList();
|
||||
@@ -1070,7 +1070,7 @@ nextProd:
|
||||
*/
|
||||
if (!productFound) {
|
||||
// copy product to be variant
|
||||
GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
|
||||
GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
|
||||
product.put("isVariant", "Y");
|
||||
product.put("isVirtual", "N");
|
||||
product.put("productId", delegator.getNextSeqId("Product"));
|
||||
@@ -1081,13 +1081,13 @@ nextProd:
|
||||
UtilMisc.toMap("productId", product.getString("productId"), "productFeatureApplTypeId", "STANDARD_FEATURE"));
|
||||
productFeatureAppl.put("fromDate", UtilDateTime.nowTimestamp());
|
||||
for (String productFeatureId: selectedFeatures) {
|
||||
productFeatureAppl.put("productFeatureId", productFeatureId);
|
||||
productFeatureAppl.put("productFeatureId", productFeatureId);
|
||||
productFeatureAppl.create();
|
||||
}
|
||||
//add standard features too
|
||||
List<GenericValue> stdFeaturesAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE").filterByDate().queryList();
|
||||
for (GenericValue stdFeaturesAppl: stdFeaturesAppls) {
|
||||
stdFeaturesAppl.put("productId", product.getString("productId"));
|
||||
stdFeaturesAppl.put("productId", product.getString("productId"));
|
||||
stdFeaturesAppl.create();
|
||||
}
|
||||
/* 3. use the price of the virtual product(Entity:ProductPrice) as a basis and adjust according the prices in the feature price table.
|
||||
@@ -1110,7 +1110,7 @@ nextProd:
|
||||
if (productPrice.get("price") == null) {
|
||||
productPrice.put("price", productPrice.getBigDecimal("price"));
|
||||
}
|
||||
productPrice.put("productId", product.getString("productId"));
|
||||
productPrice.put("productId", product.getString("productId"));
|
||||
productPrice.create();
|
||||
}
|
||||
// add the product association
|
||||
@@ -1123,7 +1123,7 @@ nextProd:
|
||||
List<GenericValue> supplierProducts = EntityQuery.use(delegator).from("SupplierProduct").where("productId", productId).cache(true).queryList();
|
||||
for (GenericValue supplierProduct: supplierProducts) {
|
||||
supplierProduct = (GenericValue) supplierProduct.clone();
|
||||
supplierProduct.set("productId", product.getString("productId"));
|
||||
supplierProduct.set("productId", product.getString("productId"));
|
||||
supplierProduct.create();
|
||||
}
|
||||
|
||||
@@ -1131,7 +1131,7 @@ nextProd:
|
||||
List<GenericValue> productContents = EntityQuery.use(delegator).from("ProductContent").where("productId", productId).cache(true).queryList();
|
||||
for (GenericValue productContent: productContents) {
|
||||
productContent = (GenericValue) productContent.clone();
|
||||
productContent.set("productId", product.getString("productId"));
|
||||
productContent.set("productId", product.getString("productId"));
|
||||
productContent.create();
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -94,8 +94,7 @@ public class PromoServices {
|
||||
GenericValue existingPromoCode = null;
|
||||
try {
|
||||
existingPromoCode = EntityQuery.use(delegator).from("ProductPromoCode").where("productPromoCodeId", newPromoCodeId).cache().queryOne();
|
||||
}
|
||||
catch (GenericEntityException e) {
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logWarning("Could not find ProductPromoCode for just generated ID: " + newPromoCodeId, MODULE);
|
||||
}
|
||||
if (existingPromoCode == null) {
|
||||
|
||||
+6
-5
@@ -326,9 +326,9 @@ public class SubscriptionServices {
|
||||
|
||||
if (subscriptionList != null) {
|
||||
for (GenericValue subscription : subscriptionList) {
|
||||
expirationCompletedDate = subscription.getTimestamp("expirationCompletedDate");
|
||||
if (expirationCompletedDate == null) {
|
||||
Calendar currentDate = Calendar.getInstance();
|
||||
expirationCompletedDate = subscription.getTimestamp("expirationCompletedDate");
|
||||
if (expirationCompletedDate == null) {
|
||||
Calendar currentDate = Calendar.getInstance();
|
||||
currentDate.setTime(UtilDateTime.nowTimestamp());
|
||||
// check if the thruDate + grace period (if provided) is earlier than today's date
|
||||
Calendar endDateSubscription = Calendar.getInstance();
|
||||
@@ -377,10 +377,11 @@ public class SubscriptionServices {
|
||||
Debug.logInfo("Service mentioned in serviceNameOnExpiry called with result: " + ServiceUtil.makeSuccessMessage(result, "", "", "", ""), MODULE);
|
||||
} else if (result == null && subscriptionId != null) {
|
||||
Debug.logError("Subscription couldn't be expired for subscriptionId: " + subscriptionId, MODULE);
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "ProductSubscriptionCouldntBeExpired", UtilMisc.toMap("subscriptionId", subscriptionId), locale));
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "ProductSubscriptionCouldntBeExpired",
|
||||
UtilMisc.toMap("subscriptionId", subscriptionId), locale));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (GenericServiceException e) {
|
||||
|
||||
+8
-8
@@ -20,16 +20,16 @@ package org.apache.ofbiz.shipment.packing;
|
||||
|
||||
public interface PackingEvent extends java.io.Serializable {
|
||||
|
||||
public static final int EVENT_CODE_ADD = 1;
|
||||
public static final int EVENT_CODE_EREG = 5;
|
||||
public static final int EVENT_CODE_CLEAR = 20;
|
||||
public static final int EVENT_CODE_COMPLETE = 100;
|
||||
int EVENT_CODE_ADD = 1;
|
||||
int EVENT_CODE_EREG = 5;
|
||||
int EVENT_CODE_CLEAR = 20;
|
||||
int EVENT_CODE_COMPLETE = 100;
|
||||
|
||||
public void runEvent(PackingSession session, int eventCode);
|
||||
void runEvent(PackingSession session, int eventCode);
|
||||
|
||||
public String receiveMessage();
|
||||
String receiveMessage();
|
||||
|
||||
public int getEventStatus();
|
||||
int getEventStatus();
|
||||
|
||||
public int getEventCode();
|
||||
int getEventCode();
|
||||
}
|
||||
|
||||
+1
-1
@@ -194,7 +194,7 @@ public class PackingServices {
|
||||
}
|
||||
}
|
||||
for (int numPackage = 0; numPackage < numPackages; numPackage++) {
|
||||
session.addOrIncreaseLine(orderId, orderItemSeqId, shipGroupSeqId, prdStr, quantity, packageSeq+numPackage, weightSeq, updateQuantity);
|
||||
session.addOrIncreaseLine(orderId, orderItemSeqId, shipGroupSeqId, prdStr, quantity, packageSeq + numPackage, weightSeq, updateQuantity);
|
||||
}
|
||||
} catch (GeneralException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
|
||||
+16
-16
@@ -238,11 +238,11 @@ public class PackingSession implements java.io.Serializable {
|
||||
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())
|
||||
&& shipGroupSeqId.equals(line.getShipGroupSeqId())
|
||||
&& productId.equals(line.getProductId())
|
||||
&& inventoryItemId.equals(line.getInventoryItemId())
|
||||
&& packageSeq == line.getPackageSeq()) {
|
||||
&& orderItemSeqId.equals(line.getOrderItemSeqId())
|
||||
&& shipGroupSeqId.equals(line.getShipGroupSeqId())
|
||||
&& productId.equals(line.getProductId())
|
||||
&& inventoryItemId.equals(line.getInventoryItemId())
|
||||
&& packageSeq == line.getPackageSeq()) {
|
||||
return line;
|
||||
}
|
||||
}
|
||||
@@ -374,13 +374,13 @@ public class PackingSession implements java.io.Serializable {
|
||||
public Map<Object, Object> getPackingSessionLinesByPackage() {
|
||||
Map<Integer, List<PackingSessionLine>> packageMap = new HashMap<>();
|
||||
for (PackingSessionLine line : packLines) {
|
||||
int pSeq = line.getPackageSeq();
|
||||
List<PackingSessionLine> packageLineList = packageMap.get(pSeq);
|
||||
if (packageLineList == null) {
|
||||
packageLineList = new LinkedList<>();
|
||||
packageMap.put(pSeq, packageLineList);
|
||||
}
|
||||
packageLineList.add(line);
|
||||
int pSeq = line.getPackageSeq();
|
||||
List<PackingSessionLine> packageLineList = packageMap.get(pSeq);
|
||||
if (packageLineList == null) {
|
||||
packageLineList = new LinkedList<>();
|
||||
packageMap.put(pSeq, packageLineList);
|
||||
}
|
||||
packageLineList.add(line);
|
||||
}
|
||||
Object[] keys = packageMap.keySet().toArray();
|
||||
java.util.Arrays.sort(keys);
|
||||
@@ -415,11 +415,11 @@ public class PackingSession implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public BigDecimal getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId) {
|
||||
return getPackedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId, null, -1);
|
||||
return getPackedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId, null, -1);
|
||||
}
|
||||
|
||||
public BigDecimal getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, int packageSeq) {
|
||||
return getPackedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId, null, packageSeq);
|
||||
return getPackedQuantity(orderId, orderItemSeqId, shipGroupSeqId, productId, null, packageSeq);
|
||||
}
|
||||
|
||||
public BigDecimal getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, int packageSeq) {
|
||||
@@ -735,7 +735,7 @@ public class PackingSession implements java.io.Serializable {
|
||||
lookupMap.put("shipGroupSeqId", shipGroupSeqId);
|
||||
}
|
||||
try {
|
||||
issues = this.getDelegator().findByAnd("ItemIssuance", lookupMap, null, false);
|
||||
issues = this.getDelegator().findByAnd("ItemIssuance", lookupMap, null, false);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
@@ -801,7 +801,7 @@ public class PackingSession implements java.io.Serializable {
|
||||
List<PackingSessionLine> processedLines = new LinkedList<>();
|
||||
for (PackingSessionLine line: this.getLines()) {
|
||||
if (this.checkLine(processedLines, line)) {
|
||||
BigDecimal totalPacked = this.getPackedQuantity(line.getOrderId(), line.getOrderItemSeqId(),
|
||||
BigDecimal totalPacked = this.getPackedQuantity(line.getOrderId(), line.getOrderItemSeqId(),
|
||||
line.getShipGroupSeqId(), line.getProductId(), line.getInventoryItemId(), -1);
|
||||
|
||||
line.issueItemToShipment(shipmentId, picklistBinId, userLogin, totalPacked, getDispatcher());
|
||||
|
||||
+23
-23
@@ -401,12 +401,12 @@ public class ShipmentServices {
|
||||
}
|
||||
|
||||
// Calculate priority based on available data.
|
||||
double PRIORITY_PARTY = 9;
|
||||
double PRIORITY_ROLE = 8;
|
||||
double PRIORITY_GEO = 4;
|
||||
double PRIORITY_WEIGHT = 1;
|
||||
double PRIORITY_QTY = 1;
|
||||
double PRIORITY_PRICE = 1;
|
||||
double priorityParty = 9;
|
||||
double priorityRole = 8;
|
||||
double priorityGeo = 4;
|
||||
double priorityWeight = 1;
|
||||
double priorityQty = 1;
|
||||
double priorityPrice = 1;
|
||||
|
||||
int estimateIndex = 0;
|
||||
|
||||
@@ -416,22 +416,22 @@ public class ShipmentServices {
|
||||
for (GenericValue currentEstimate: estimateList) {
|
||||
int prioritySum = 0;
|
||||
if (UtilValidate.isNotEmpty(currentEstimate.getString("partyId"))) {
|
||||
prioritySum += PRIORITY_PARTY;
|
||||
prioritySum += priorityParty;
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(currentEstimate.getString("roleTypeId"))) {
|
||||
prioritySum += PRIORITY_ROLE;
|
||||
prioritySum += priorityRole;
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(currentEstimate.getString("geoIdTo"))) {
|
||||
prioritySum += PRIORITY_GEO;
|
||||
prioritySum += priorityGeo;
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(currentEstimate.getString("weightBreakId"))) {
|
||||
prioritySum += PRIORITY_WEIGHT;
|
||||
prioritySum += priorityWeight;
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(currentEstimate.getString("quantityBreakId"))) {
|
||||
prioritySum += PRIORITY_QTY;
|
||||
prioritySum += priorityQty;
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(currentEstimate.getString("priceBreakId"))) {
|
||||
prioritySum += PRIORITY_PRICE;
|
||||
prioritySum += priorityPrice;
|
||||
}
|
||||
|
||||
// there will be only one of each priority; latest will replace
|
||||
@@ -684,10 +684,12 @@ public class ShipmentServices {
|
||||
if ("00001".equals(packageSeqId)) {
|
||||
// only need to do this for the first package
|
||||
GenericValue rtSeg = null;
|
||||
rtSeg = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", "00001").queryOne();
|
||||
rtSeg = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId",
|
||||
"00001").queryOne();
|
||||
|
||||
if (rtSeg == null) {
|
||||
rtSeg = delegator.makeValue("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", "00001"));
|
||||
rtSeg = delegator.makeValue("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId",
|
||||
"00001"));
|
||||
try {
|
||||
delegator.create(rtSeg);
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -700,7 +702,7 @@ public class ShipmentServices {
|
||||
rtSeg.set("billingWeight", pkgInfo.get("billingWeight"));
|
||||
rtSeg.set("actualCost", pkgInfo.get("shippingTotal"));
|
||||
rtSeg.set("trackingIdNumber", pkgInfo.get("trackingNumber"));
|
||||
delegator.store(rtSeg);
|
||||
delegator.store(rtSeg);
|
||||
}
|
||||
|
||||
Map<String, Object> pkgCtx = new HashMap<>();
|
||||
@@ -709,24 +711,22 @@ public class ShipmentServices {
|
||||
|
||||
// first update the weight of the package
|
||||
GenericValue pkg = null;
|
||||
pkg = EntityQuery.use(delegator).from("ShipmentPackage")
|
||||
.where(pkgCtx)
|
||||
.queryOne();
|
||||
pkg = EntityQuery.use(delegator).from("ShipmentPackage").where(pkgCtx).queryOne();
|
||||
|
||||
if (pkg == null) {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
|
||||
"ProductShipmentPackageNotFound",
|
||||
UtilMisc.toMap("shipmentPackageSeqId", packageSeqId,
|
||||
"shipmentId", shipmentId), locale));
|
||||
"ProductShipmentPackageNotFound",
|
||||
UtilMisc.toMap("shipmentPackageSeqId", packageSeqId,
|
||||
"shipmentId", shipmentId), locale));
|
||||
}
|
||||
|
||||
pkg.set("weight", pkgInfo.get("packageWeight"));
|
||||
delegator.store(pkg);
|
||||
delegator.store(pkg);
|
||||
|
||||
// need if we are the first package (only) update the route seg info
|
||||
pkgCtx.put("shipmentRouteSegmentId", "00001");
|
||||
GenericValue pkgRtSeg = null;
|
||||
pkgRtSeg = EntityQuery.use(delegator).from("ShipmentPackageRouteSeg").where(pkgCtx).queryOne();
|
||||
pkgRtSeg = EntityQuery.use(delegator).from("ShipmentPackageRouteSeg").where(pkgCtx).queryOne();
|
||||
|
||||
if (pkgRtSeg == null) {
|
||||
pkgRtSeg = delegator.makeValue("ShipmentPackageRouteSeg", pkgCtx);
|
||||
|
||||
Vendored
+3
-4
@@ -207,8 +207,7 @@ public class DhlServices {
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
|
||||
"FacilityShipmentUnableFoundShipToAddresss", locale));
|
||||
}
|
||||
}
|
||||
catch (GenericEntityException e) {
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, MODULE);
|
||||
}
|
||||
}
|
||||
@@ -595,7 +594,7 @@ public class DhlServices {
|
||||
if ((billingWeight != null) && (billingWeight.compareTo(BigDecimal.ZERO) > 0)) {
|
||||
hasBillingWeight = true;
|
||||
if (billingWeightUomId == null) {
|
||||
Debug.logWarning("Shipment Route Segment missing billingWeightUomId in shipmentId " + shipmentId, MODULE);
|
||||
Debug.logWarning("Shipment Route Segment missing billingWeightUomId in shipmentId " + shipmentId, MODULE);
|
||||
billingWeightUomId = "WT_lb"; // TODO: this should be specified in a properties file
|
||||
}
|
||||
// convert
|
||||
@@ -637,7 +636,7 @@ public class DhlServices {
|
||||
// convert weight
|
||||
String weightUomId = (String) shipmentPackage.get("weightUomId");
|
||||
if (weightUomId == null) {
|
||||
Debug.logWarning("Shipment Route Segment missing weightUomId in shipmentId " + shipmentId, MODULE);
|
||||
Debug.logWarning("Shipment Route Segment missing weightUomId in shipmentId " + shipmentId, MODULE);
|
||||
weightUomId = "WT_lb"; // TODO: this should be specified in a properties file
|
||||
}
|
||||
results = dispatcher.runSync("convertUom", UtilMisc.<String, Object>toMap("uomId", weightUomId, "uomIdTo", DHL_WEIGHT_UOM_ID, "originalValue", packageWeight));
|
||||
|
||||
Vendored
+13
-12
@@ -763,7 +763,7 @@ public class FedexServices {
|
||||
if ((billingWeight != null) && (billingWeight.compareTo(BigDecimal.ZERO) > 0)) {
|
||||
hasBillingWeight = true;
|
||||
if (billingWeightUomId == null) {
|
||||
Debug.logWarning("Shipment Route Segment missing billingWeightUomId in shipmentId " + shipmentId + ", assuming default shipment.fedex.weightUomId of " + weightUomId + " from " + shipmentPropertiesFile, MODULE);
|
||||
Debug.logWarning("Shipment Route Segment missing billingWeightUomId in shipmentId " + shipmentId + ", assuming default shipment.fedex.weightUomId of " + weightUomId + " from " + shipmentPropertiesFile, MODULE);
|
||||
billingWeightUomId = weightUomId;
|
||||
}
|
||||
|
||||
@@ -830,7 +830,7 @@ public class FedexServices {
|
||||
if (!UtilValidate.isEmpty(boxDimensionsUom)) {
|
||||
boxDimensionsUomId = boxDimensionsUom.getString("uomId");
|
||||
} else {
|
||||
Debug.logWarning("Packaging type for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId + " is missing dimensionUomId, assuming default shipment.default.dimension.uom of " + dimensionsUomId + " from " + shipmentPropertiesFile, MODULE);
|
||||
Debug.logWarning("Packaging type for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId + " is missing dimensionUomId, assuming default shipment.default.dimension.uom of " + dimensionsUomId + " from " + shipmentPropertiesFile, MODULE);
|
||||
boxDimensionsUomId = dimensionsUomId;
|
||||
}
|
||||
if (dimensionsLength != null && dimensionsLength.compareTo(BigDecimal.ZERO) > 0) {
|
||||
@@ -890,7 +890,7 @@ public class FedexServices {
|
||||
// Convert weight if necessary
|
||||
String packageWeightUomId = shipmentPackage.getString("weightUomId");
|
||||
if (UtilValidate.isEmpty(packageWeightUomId)) {
|
||||
Debug.logWarning("Shipment Route Segment missing weightUomId in shipmentId " + shipmentId + ", assuming shipment.default.weight.uom of " + weightUomId + " from " + shipmentPropertiesFile, MODULE);
|
||||
Debug.logWarning("Shipment Route Segment missing weightUomId in shipmentId " + shipmentId + ", assuming shipment.default.weight.uom of " + weightUomId + " from " + shipmentPropertiesFile, MODULE);
|
||||
packageWeightUomId = weightUomId;
|
||||
}
|
||||
if (!packageWeightUomId.equals(weightUomId)) {
|
||||
@@ -914,17 +914,18 @@ public class FedexServices {
|
||||
}
|
||||
|
||||
// Populate the Freemarker context with package-related information
|
||||
shipRequestContext.put("CustomerReference", shipmentId + ":" + shipmentRouteSegmentId + ":" + shipmentPackage.getString("shipmentPackageSeqId"));
|
||||
shipRequestContext.put("CustomerReference", shipmentId + ":" + shipmentRouteSegmentId + ":" + shipmentPackage.getString(
|
||||
"shipmentPackageSeqId"));
|
||||
shipRequestContext.put("DropoffType", dropoffType);
|
||||
shipRequestContext.put("Packaging", packaging);
|
||||
if (UtilValidate.isNotEmpty(dimensionsUomId)
|
||||
&& dimensionsLength != null && dimensionsLength.setScale(0, RoundingMode.HALF_UP).compareTo(BigDecimal.ZERO) > 0
|
||||
&& dimensionsWidth != null && dimensionsWidth.setScale(0, RoundingMode.HALF_UP).compareTo(BigDecimal.ZERO) > 0
|
||||
&& dimensionsHeight != null && dimensionsHeight.setScale(0, RoundingMode.HALF_UP).compareTo(BigDecimal.ZERO) > 0) {
|
||||
shipRequestContext.put("DimensionsUnits", "LEN_in".equals(dimensionsUomId) ? "IN" : "CM");
|
||||
shipRequestContext.put("DimensionsLength", dimensionsLength.setScale(0, RoundingMode.HALF_UP).toString());
|
||||
shipRequestContext.put("DimensionsWidth", dimensionsWidth.setScale(0, RoundingMode.HALF_UP).toString());
|
||||
shipRequestContext.put("DimensionsHeight", dimensionsHeight.setScale(0, RoundingMode.HALF_UP).toString());
|
||||
&& dimensionsLength != null && dimensionsLength.setScale(0, RoundingMode.HALF_UP).compareTo(BigDecimal.ZERO) > 0
|
||||
&& dimensionsWidth != null && dimensionsWidth.setScale(0, RoundingMode.HALF_UP).compareTo(BigDecimal.ZERO) > 0
|
||||
&& dimensionsHeight != null && dimensionsHeight.setScale(0, RoundingMode.HALF_UP).compareTo(BigDecimal.ZERO) > 0) {
|
||||
shipRequestContext.put("DimensionsUnits", "LEN_in".equals(dimensionsUomId) ? "IN" : "CM");
|
||||
shipRequestContext.put("DimensionsLength", dimensionsLength.setScale(0, RoundingMode.HALF_UP).toString());
|
||||
shipRequestContext.put("DimensionsWidth", dimensionsWidth.setScale(0, RoundingMode.HALF_UP).toString());
|
||||
shipRequestContext.put("DimensionsHeight", dimensionsHeight.setScale(0, RoundingMode.HALF_UP).toString());
|
||||
}
|
||||
shipRequestContext.put("Weight", weight.setScale(1, RoundingMode.UP).toString());
|
||||
}
|
||||
@@ -936,7 +937,7 @@ public class FedexServices {
|
||||
String errorMessage = "Cannot confirm Fedex shipment: Failed to render Fedex XML Ship Request Template [" + templateLocation + "].";
|
||||
Debug.logError(e, errorMessage, MODULE);
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
|
||||
"FacilityShipmentFedexShipmentTemplateError",
|
||||
"FacilityShipmentFedexShipmentTemplateError",
|
||||
UtilMisc.toMap("templateLocation", templateLocation, "errorString", e.getMessage()), locale));
|
||||
}
|
||||
|
||||
|
||||
Vendored
+449
-244
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -536,7 +536,7 @@ public class UspsServices {
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
if ((UtilValidate.isEmpty(state) && UtilValidate.isEmpty(city) && UtilValidate.isEmpty(zip5)) || // No state, city or zip5
|
||||
(UtilValidate.isEmpty(zip5) && (UtilValidate.isEmpty(state) || UtilValidate.isEmpty(city)))) { // Both state and city are required if no zip5
|
||||
Debug.logError("USPS address validation requires either zip5 or city and state", MODULE);
|
||||
Debug.logError("USPS address validation requires either zip5 or city and state", MODULE);
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
|
||||
"FacilityShipmentUspsAddressValidationStateAndCityOrZipRqd", locale));
|
||||
}
|
||||
|
||||
+1
-1
@@ -372,7 +372,7 @@ public class VerifyPickSession implements Serializable {
|
||||
List<VerifyPickSessionRow> processedRows = new LinkedList<>();
|
||||
for (VerifyPickSessionRow pickRow : this.getPickRows()) {
|
||||
if (this.checkLine(processedRows, pickRow)) {
|
||||
BigDecimal totalVerifiedQty = this.getVerifiedQuantity(pickRow.getOrderId(), pickRow.getOrderItemSeqId(), pickRow.getShipGroupSeqId(), pickRow.getProductId(), pickRow.getInventoryItemId());
|
||||
BigDecimal totalVerifiedQty = this.getVerifiedQuantity(pickRow.getOrderId(), pickRow.getOrderItemSeqId(), pickRow.getShipGroupSeqId(), pickRow.getProductId(), pickRow.getInventoryItemId());
|
||||
pickRow.issueItemToShipment(shipmentId, picklistBinId, userLogin, totalVerifiedQty, getDispatcher(), locale);
|
||||
processedRows.add(pickRow);
|
||||
}
|
||||
|
||||
+4
-4
@@ -254,8 +254,8 @@ public class WorkEffortContentWrapper implements ContentWrapper {
|
||||
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 = workEffort.getModelEntity().isField(candidateFieldName) ? workEffort.getString(candidateFieldName) : "";
|
||||
outString = outString == null ? "" : outString;
|
||||
}
|
||||
outString = encoder.sanitize(outString, null);
|
||||
if (workEffortContentCache != null) {
|
||||
@@ -264,8 +264,8 @@ public class WorkEffortContentWrapper implements ContentWrapper {
|
||||
return outString;
|
||||
} catch (GeneralException | IOException e) {
|
||||
Debug.logError(e, "Error rendering WorkEffortContent, inserting empty String", MODULE);
|
||||
String candidateOut = workEffort.getModelEntity().isField(candidateFieldName) ? workEffort.getString(candidateFieldName): "";
|
||||
return candidateOut == null? "" : encoder.sanitize(candidateOut, null);
|
||||
String candidateOut = workEffort.getModelEntity().isField(candidateFieldName) ? workEffort.getString(candidateFieldName) : "";
|
||||
return candidateOut == null ? "" : encoder.sanitize(candidateOut, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-12
@@ -1062,23 +1062,24 @@ public class WorkEffortSearch {
|
||||
|
||||
EntityConditionList<EntityExpr> dateConditions = null;
|
||||
EntityExpr dateCondition=null;
|
||||
if (fromDate !=null && thruDate!=null) {
|
||||
dateConditions= EntityCondition.makeCondition(UtilMisc.toList(
|
||||
EntityCondition.makeCondition("lastModifiedDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate),
|
||||
EntityCondition.makeCondition("lastModifiedDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate)), EntityOperator.AND);
|
||||
} if (fromDate !=null) {
|
||||
dateCondition=EntityCondition.makeCondition("lastModifiedDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate);
|
||||
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);
|
||||
} 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(
|
||||
dateConditions,
|
||||
EntityCondition.makeCondition("lastModifiedDate", EntityOperator.EQUALS, null)),
|
||||
EntityOperator.OR);
|
||||
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);
|
||||
|
||||
+10
-9
@@ -193,16 +193,17 @@ public class WorkEffortSearchSession {
|
||||
}
|
||||
// add a Work Effort Assoc Type to the search
|
||||
if (UtilValidate.isNotEmpty(parameters.get("SEARCH_WORK_EFFORT_ID"))) {
|
||||
String workEffortId=(String) parameters.get("SEARCH_WORK_EFFORT_ID");
|
||||
String workEffortAssocTypeId=(String) parameters.get("workEffortAssocTypeId");
|
||||
boolean includeAllSubWorkEfforts =!"N".equalsIgnoreCase((String) parameters.get("SEARCH_SUB_WORK_EFFORTS"));
|
||||
searchAddConstraint(new WorkEffortSearch.WorkEffortAssocConstraint(workEffortId, workEffortAssocTypeId, includeAllSubWorkEfforts), session);
|
||||
String workEffortId = (String) parameters.get("SEARCH_WORK_EFFORT_ID");
|
||||
String workEffortAssocTypeId = (String) parameters.get("workEffortAssocTypeId");
|
||||
boolean includeAllSubWorkEfforts = !"N".equalsIgnoreCase((String) parameters.get("SEARCH_SUB_WORK_EFFORTS"));
|
||||
searchAddConstraint(new WorkEffortSearch.WorkEffortAssocConstraint(workEffortId, workEffortAssocTypeId, includeAllSubWorkEfforts),
|
||||
session);
|
||||
constraintsChanged = true;
|
||||
}
|
||||
// add a Work Effort Party Assignment to the search
|
||||
// add a Work Effort Party Assignment to the search
|
||||
if (UtilValidate.isNotEmpty(parameters.get("partyId"))) {
|
||||
String partyId=(String) parameters.get("partyId");
|
||||
String roleTypeId=(String) parameters.get("roleTypeId");
|
||||
String partyId = (String) parameters.get("partyId");
|
||||
String roleTypeId = (String) parameters.get("roleTypeId");
|
||||
searchAddConstraint(new WorkEffortSearch.PartyAssignmentConstraint(partyId, roleTypeId), session);
|
||||
constraintsChanged = true;
|
||||
}
|
||||
@@ -220,9 +221,9 @@ public class WorkEffortSearchSession {
|
||||
|
||||
// add a WorkEfort 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;
|
||||
|
||||
Reference in New Issue
Block a user