You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2014/09/29 22:12:11 UTC
svn commit: r1628288 [2/2] - in
/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting: agreement/
finaccount/ invoice/ payment/
Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java?rev=1628288&r1=1628287&r2=1628288&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java Mon Sep 29 20:12:10 2014
@@ -37,6 +37,7 @@ import org.ofbiz.base.util.collections.R
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.entity.util.EntityUtilProperties;
import org.ofbiz.order.finaccount.FinAccountHelper;
@@ -85,7 +86,9 @@ public class GiftCertificateServices {
final String accountName = "Gift Certificate Account";
final String deposit = "DEPOSIT";
- GenericValue giftCertSettings = delegator.findOne("ProductStoreFinActSetting", UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId), true);
+ GenericValue giftCertSettings = EntityQuery.use(delegator).from("ProductStoreFinActSetting")
+ .where("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId)
+ .cache().queryOne();
Map<String, Object> acctResult = null;
if ("Y".equals(giftCertSettings.getString("requirePinCode"))) {
@@ -129,7 +132,7 @@ public class GiftCertificateServices {
// create the initial (deposit) transaction
// do something tricky here: run as the "system" user
// that can actually create a financial account transaction
- GenericValue permUserLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true);
+ GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
refNum = createTransaction(delegator, dispatcher, permUserLogin, initialAmount, productStoreId,
partyId, currencyUom, deposit, finAccountId, locale);
@@ -182,7 +185,9 @@ public class GiftCertificateServices {
GenericValue finAccount = null;
// validate the pin if the store requires it and figure out the finAccountId from card number
try {
- GenericValue giftCertSettings = delegator.findOne("ProductStoreFinActSetting", UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId), true);
+ GenericValue giftCertSettings = EntityQuery.use(delegator).from("ProductStoreFinActSetting")
+ .where("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId)
+ .cache().queryOne();
if ("Y".equals(giftCertSettings.getString("requirePinCode"))) {
if (!validatePin(delegator, cardNumber, pinNumber)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
@@ -209,7 +214,7 @@ public class GiftCertificateServices {
if (finAccount == null) {
try {
- finAccount = delegator.findOne("FinAccount", UtilMisc.toMap("finAccountId", finAccountId), false);
+ finAccount = EntityQuery.use(delegator).from("FinAccount").where("finAccountId", finAccountId).queryOne();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"AccountingFinAccountNotFound", UtilMisc.toMap("finAccountId", finAccountId), locale));
@@ -274,7 +279,9 @@ public class GiftCertificateServices {
// validate the pin if the store requires it
try {
- GenericValue giftCertSettings = delegator.findOne("ProductStoreFinActSetting", UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId), true);
+ GenericValue giftCertSettings = EntityQuery.use(delegator).from("ProductStoreFinActSetting")
+ .where("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId)
+ .cache().queryOne();
if ("Y".equals(giftCertSettings.getString("requirePinCode")) && !validatePin(delegator, cardNumber, pinNumber)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"AccountingGiftCerticateNumberPinNotValid", locale));
@@ -289,7 +296,7 @@ public class GiftCertificateServices {
GenericValue finAccount = null;
try {
- finAccount = delegator.findOne("FinAccount", UtilMisc.toMap("finAccountId", cardNumber), false);
+ finAccount = EntityQuery.use(delegator).from("FinAccount").where("finAccountId", cardNumber).queryOne();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"AccountingFinAccountNotFound", UtilMisc.toMap("finAccountId", cardNumber), locale));
@@ -343,7 +350,7 @@ public class GiftCertificateServices {
GenericValue finAccount = null;
try {
- finAccount = delegator.findOne("FinAccount", UtilMisc.toMap("finAccountId", cardNumber), false);
+ finAccount = EntityQuery.use(delegator).from("FinAccount").where("finAccountId", cardNumber).queryOne();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"AccountingFinAccountNotFound", UtilMisc.toMap("finAccountId", cardNumber), locale));
@@ -387,7 +394,7 @@ public class GiftCertificateServices {
// get the gift certificate and its authorization from the authorization
String finAccountAuthId = authTransaction.getString("referenceNum");
try {
- GenericValue finAccountAuth = delegator.findOne("FinAccountAuth", UtilMisc.toMap("finAccountAuthId", finAccountAuthId), false);
+ GenericValue finAccountAuth = EntityQuery.use(delegator).from("FinAccountAuth").where("finAccountAuthId", finAccountAuthId).queryOne();
GenericValue giftCard = finAccountAuth.getRelatedOne("FinAccount", false);
// make sure authorization has not expired
Timestamp authExpiration = finAccountAuth.getTimestamp("thruDate");
@@ -478,14 +485,16 @@ public class GiftCertificateServices {
try {
// if the store requires pin codes, then validate pin code against card number, and the gift certificate's finAccountId is the gift card's card number
// otherwise, the gift card's card number is an ecrypted string, which must be decoded to find the FinAccount
- GenericValue giftCertSettings = delegator.findOne("ProductStoreFinActSetting", UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId), true);
+ GenericValue giftCertSettings = EntityQuery.use(delegator).from("ProductStoreFinActSetting")
+ .where("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId)
+ .cache().queryOne();
GenericValue finAccount = null;
String finAccountId = null;
if (UtilValidate.isNotEmpty(giftCertSettings)) {
if ("Y".equals(giftCertSettings.getString("requirePinCode"))) {
if (validatePin(delegator, giftCard.getString("cardNumber"), giftCard.getString("pinNumber"))) {
finAccountId = giftCard.getString("cardNumber");
- finAccount = delegator.findOne("FinAccount", UtilMisc.toMap("finAccountId", finAccountId), false);
+ finAccount = EntityQuery.use(delegator).from("FinAccount").where("finAccountId", finAccountId).queryOne();
}
} else {
finAccount = FinAccountHelper.getFinAccountFromCode(giftCard.getString("cardNumber"), delegator);
@@ -754,7 +763,9 @@ public class GiftCertificateServices {
// Gift certificate settings are per store in this entity
GenericValue giftCertSettings = null;
try {
- giftCertSettings = delegator.findOne("ProductStoreFinActSetting", UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId), true);
+ giftCertSettings = EntityQuery.use(delegator).from("ProductStoreFinActSetting")
+ .where("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId)
+ .cache().queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get Product Store FinAccount settings for " + FinAccountHelper.giftCertFinAccountTypeId, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
@@ -769,12 +780,10 @@ public class GiftCertificateServices {
// get the survey response
GenericValue surveyResponse = null;
try {
- Map<String, Object> fields = UtilMisc.<String, Object>toMap("orderId", orderId,
- "orderItemSeqId", orderItem.get("orderItemSeqId"), "surveyId", surveyId);
- List<String> order = UtilMisc.toList("-responseDate");
- List<GenericValue> responses = delegator.findByAnd("SurveyResponse", fields, order, false);
// there should be only one
- surveyResponse = EntityUtil.getFirst(responses);
+ surveyResponse = EntityQuery.use(delegator).from("SurveyResponse")
+ .where("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "surveyId", surveyId)
+ .orderBy("-responseDate").queryFirst();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
@@ -883,8 +892,7 @@ public class GiftCertificateServices {
GenericValue productStoreEmail = null;
String emailType = "PRDS_GC_PURCHASE";
try {
- productStoreEmail = delegator.findOne("ProductStoreEmailSetting",
- UtilMisc.toMap("productStoreId", productStoreId, "emailType", emailType), false);
+ productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", emailType).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get product store email setting for gift card purchase", module);
}
@@ -1004,12 +1012,10 @@ public class GiftCertificateServices {
// get the survey response
GenericValue surveyResponse = null;
try {
- Map<String, Object> fields = UtilMisc.toMap("orderId", orderId,
- "orderItemSeqId", orderItem.get("orderItemSeqId"), "surveyId", surveyId);
- List<String> order = UtilMisc.toList("-responseDate");
- List<GenericValue> responses = delegator.findByAnd("SurveyResponse", fields, order, false);
// there should be only one
- surveyResponse = EntityUtil.getFirst(responses);
+ surveyResponse = EntityQuery.use(delegator).from("SurveyResponse")
+ .where("orderId", orderId, "orderItemSeqId", orderItem.get("orderItemSeqId"), "surveyId", surveyId)
+ .orderBy("-responseDate").queryFirst();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrderError,
@@ -1124,7 +1130,7 @@ public class GiftCertificateServices {
GenericValue productStoreEmail = null;
String emailType = "PRDS_GC_RELOAD";
try {
- productStoreEmail = delegator.findOne("ProductStoreEmailSetting", UtilMisc.toMap("productStoreId", productStoreId, "emailType", emailType), false);
+ productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", emailType).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get product store email setting for gift card purchase", module);
}
@@ -1296,10 +1302,10 @@ public class GiftCertificateServices {
Debug.logVerbose("Created return item : " + returnId + " / " + returnItemSeqId, module);
}
- // need the admin userLogin to "fake" out the update service
+ // need the system userLogin to "fake" out the update service
GenericValue admin = null;
try {
- admin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "admin"), false);
+ admin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrderError,
@@ -1336,7 +1342,7 @@ public class GiftCertificateServices {
private static boolean validatePin(Delegator delegator, String cardNumber, String pinNumber) {
GenericValue finAccount = null;
try {
- finAccount = delegator.findOne("FinAccount", UtilMisc.toMap("finAccountId", cardNumber), false);
+ finAccount = EntityQuery.use(delegator).from("FinAccount").where("finAccountId", cardNumber).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
@@ -1466,7 +1472,7 @@ public class GiftCertificateServices {
}
private static boolean checkNumberInDatabase(Delegator delegator, String number) throws GenericEntityException {
- GenericValue finAccount = delegator.findOne("FinAccount", UtilMisc.toMap("finAccountId", number), false);
+ GenericValue finAccount = EntityQuery.use(delegator).from("FinAccount").where("finAccountId", number).queryOne();
if (finAccount == null) {
return true;
}
@@ -1482,7 +1488,7 @@ public class GiftCertificateServices {
String payToPartyId = "Company"; // default value
GenericValue productStore = null;
try {
- productStore = delegator.findOne("ProductStore", UtilMisc.toMap("productStoreId", productStoreId), false);
+ productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to locate ProductStore (" + productStoreId + ")", module);
return null;
Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java?rev=1628288&r1=1628287&r2=1628288&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Mon Sep 29 20:12:10 2014
@@ -52,6 +52,7 @@ import org.ofbiz.entity.condition.Entity
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.model.ModelEntity;
import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.entity.util.EntityUtilProperties;
import org.ofbiz.order.order.OrderChangeHelper;
@@ -128,8 +129,7 @@ public class PaymentGatewayServices {
GenericValue orderHeader = null;
GenericValue orderPaymentPreference = null;
try {
- orderPaymentPreference = delegator.findOne("OrderPaymentPreference",
- UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId), false);
+ orderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne();
orderHeader = orderPaymentPreference.getRelatedOne("OrderHeader", false);
} catch (GenericEntityException e) {
Debug.logError(e, module);
@@ -231,8 +231,7 @@ public class PaymentGatewayServices {
}
if (UtilValidate.isNotEmpty(billToPartyId)) {
- otherPaymentMethodAndCreditCardList = delegator.findByAnd("PaymentMethodAndCreditCard",
- UtilMisc.toMap("partyId", billToPartyId, "paymentMethodTypeId", "CREDIT_CARD"), null, false);
+ otherPaymentMethodAndCreditCardList = delegator.findByAnd("PaymentMethodAndCreditCard", UtilMisc.toMap("partyId", billToPartyId, "paymentMethodTypeId", "CREDIT_CARD"), null, false);
otherPaymentMethodAndCreditCardList = EntityUtil.filterByDate(otherPaymentMethodAndCreditCardList, true);
}
@@ -333,7 +332,7 @@ public class PaymentGatewayServices {
try {
// get the OrderHeader
- orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+ orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
// get the payments to auth
Map<String, String> lookupMap = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_AUTH");
@@ -716,8 +715,7 @@ public class PaymentGatewayServices {
GenericValue paymentPref = null;
try {
if (orderPaymentPreferenceId != null) {
- paymentPref = delegator.findOne("OrderPaymentPreference",
- UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId), false);
+ paymentPref = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne();
orderId = paymentPref.getString("orderId");
}
else {
@@ -885,7 +883,7 @@ public class PaymentGatewayServices {
// Get the OrderPaymentPreference
GenericValue paymentPref = null;
try {
- paymentPref = delegator.findOne("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId), false);
+ paymentPref = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne();
} catch (GenericEntityException e) {
Debug.logWarning(e, "Problem getting OrderPaymentPreference for orderPaymentPreferenceId " +
orderPaymentPreferenceId, module);
@@ -905,7 +903,7 @@ public class PaymentGatewayServices {
GenericValue orderHeader = null;
String orderId = paymentPref.getString("orderId");
try {
- orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+ orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
} catch (GenericEntityException e) {
Debug.logWarning(e, "Problem getting OrderHeader for orderId " + orderId, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder,
@@ -1089,7 +1087,7 @@ public class PaymentGatewayServices {
// lookup the invoice
GenericValue invoice = null;
try {
- invoice = delegator.findOne("Invoice", UtilMisc.toMap("invoiceId", invoiceId), false);
+ invoice = EntityQuery.use(delegator).from("Invoice").where("invoiceId", invoiceId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Trouble looking up Invoice #" + invoiceId, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
@@ -1181,7 +1179,7 @@ public class PaymentGatewayServices {
List<GenericValue> paymentPrefsBa = null;
try {
- orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+ orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
// get the payment prefs
Map<String, String> lookupMap = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_AUTHORIZED");
@@ -1507,7 +1505,7 @@ public class PaymentGatewayServices {
try {
// Note that the partyIdFrom of the Payment should be the partyIdTo of the invoice, since you're receiving a payment from the party you billed
- GenericValue invoice = delegator.findOne("Invoice", UtilMisc.toMap("invoiceId", invoiceId), false);
+ GenericValue invoice = EntityQuery.use(delegator).from("Invoice").where("invoiceId", invoiceId).queryOne();
Map<String, Object> paymentParams = UtilMisc.<String, Object>toMap("paymentTypeId", "CUSTOMER_PAYMENT", "paymentMethodTypeId", "EXT_BILLACT",
"partyIdFrom", invoice.getString("partyId"), "partyIdTo", invoice.getString("partyIdFrom"),
"statusId", "PMNT_RECEIVED", "effectiveDate", UtilDateTime.nowTimestamp());
@@ -1534,7 +1532,7 @@ public class PaymentGatewayServices {
if (orderId != null && captureAmount.compareTo(BigDecimal.ZERO) > 0) {
// Create a paymentGatewayResponse, if necessary
- GenericValue order = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+ GenericValue order = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
if (order == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingNoPaymentGatewayResponseCreatedForInvoice",
@@ -1542,9 +1540,8 @@ public class PaymentGatewayServices {
"orderId", orderId), locale));
}
// See if there's an orderPaymentPreference - there should be only one OPP for EXT_BILLACT per order
- List<GenericValue> orderPaymentPreferences = delegator.findByAnd("OrderPaymentPreference", UtilMisc.toMap("orderId", orderId, "paymentMethodTypeId", "EXT_BILLACT"), null, false);
- if (orderPaymentPreferences.size() > 0) {
- GenericValue orderPaymentPreference = EntityUtil.getFirst(orderPaymentPreferences);
+ GenericValue orderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId", orderId, "paymentMethodTypeId", "EXT_BILLACT").queryFirst();
+ if (orderPaymentPreference != null) {
// Check the productStore setting to see if we need to do this explicitly
GenericValue productStore = order.getRelatedOne("ProductStore", false);
@@ -1593,11 +1590,9 @@ public class PaymentGatewayServices {
try {
// Select all the unapplied payment applications associated to the billing account
- List<EntityExpr> conditionList = UtilMisc.toList(EntityCondition.makeCondition("billingAccountId", EntityOperator.EQUALS, billingAccountId),
- EntityCondition.makeCondition("invoiceId", EntityOperator.EQUALS, GenericEntity.NULL_FIELD));
- EntityCondition conditions = EntityCondition.makeCondition(conditionList, EntityOperator.AND);
-
- List<GenericValue> paymentApplications = delegator.findList("PaymentApplication", conditions, null, UtilMisc.toList("-amountApplied"), null, false);
+ List<GenericValue> paymentApplications = EntityQuery.use(delegator).from("PaymentApplication")
+ .where("billingAccountId", billingAccountId, "invoiceId", null)
+ .orderBy("-amountApplied").queryList();
if (UtilValidate.isNotEmpty(paymentApplications)) {
Iterator<GenericValue> paymentApplicationsIt = paymentApplications.iterator();
while (paymentApplicationsIt.hasNext()) {
@@ -1909,7 +1904,7 @@ public class PaymentGatewayServices {
try {
String paymentMethodId = orderPaymentPreference.getString("paymentMethodId");
- GenericValue paymentMethod = delegator.findOne("PaymentMethod", UtilMisc.toMap("paymentMethodId", paymentMethodId), false);
+ GenericValue paymentMethod = EntityQuery.use(delegator).from("PaymentMethod").where("paymentMethodId", paymentMethodId).queryOne();
GenericValue creditCard = null;
if (paymentMethod != null && "CREDIT_CARD".equals(paymentMethod.getString("paymentMethodTypeId"))) {
creditCard = paymentMethod.getRelatedOne("CreditCard", false);
@@ -2046,13 +2041,11 @@ public class PaymentGatewayServices {
// and that have resultNsf = Y, ie only consider other NSF responses
Long autoOrderCcTryLaterMax = productStore.getLong("autoOrderCcTryLaterMax");
if (autoOrderCcTryLaterMax != null) {
- long failedTries = delegator.findCountByCondition("PaymentGatewayResponse",
- EntityCondition.makeCondition(UtilMisc.toMap(
- "orderPaymentPreferenceId", orderPaymentPreference.get("orderPaymentPreferenceId"),
- "paymentMethodId", orderPaymentPreference.get("paymentMethodId"),
- "resultNsf", "Y"),
- EntityOperator.AND),
- null, null);
+ long failedTries = EntityQuery.use(delegator).from("PaymentGatewayResponse")
+ .where("orderPaymentPreferenceId", orderPaymentPreference.get("orderPaymentPreferenceId"),
+ "paymentMethodId", orderPaymentPreference.get("paymentMethodId"),
+ "resultNsf", "Y")
+ .queryCount();
if (failedTries < autoOrderCcTryLaterMax.longValue()) {
needsNsfRetry = true;
}
@@ -2282,7 +2275,7 @@ public class PaymentGatewayServices {
GenericValue invoice = null;
if (invoiceId != null) {
try {
- invoice = delegator.findOne("Invoice", UtilMisc.toMap("invoiceId", invoiceId), false);
+ invoice = EntityQuery.use(delegator).from("Invoice").where("invoiceId", invoiceId).queryOne();
} catch (GenericEntityException e) {
String message = "Failed to process capture result: Could not find invoice ["+invoiceId+"] due to entity error: " + e.getMessage();
Debug.logError(e, message, module);
@@ -2298,14 +2291,13 @@ public class PaymentGatewayServices {
} else {
// otherwise get the party from the order's OrderRole
String orderId = paymentPreference.getString("orderId");
- List<GenericValue> orl = null;
+ GenericValue orderRole = null;
try {
- orl = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "BILL_TO_CUSTOMER"), null, false);
+ orderRole = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "roleTypeId", "BILL_TO_CUSTOMER").queryFirst();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
- if (UtilValidate.isNotEmpty(orl)) {
- GenericValue orderRole = EntityUtil.getFirst(orl);
+ if (orderRole != null) {
partyIdFrom = orderRole.getString("partyId");
}
}
@@ -2384,7 +2376,7 @@ public class PaymentGatewayServices {
Locale locale = (Locale) context.get("locale");
GenericValue orderPaymentPreference = null;
try {
- orderPaymentPreference = delegator.findOne("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId), false);
+ orderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
@@ -2639,7 +2631,7 @@ public class PaymentGatewayServices {
// get the order header
GenericValue orderHeader = null;
try {
- orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+ orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.toString());
@@ -2706,8 +2698,11 @@ public class PaymentGatewayServices {
EntityListIterator eli = null;
try {
- eli = delegator.find("OrderPaymentPreference",
- EntityCondition.makeCondition(exprs, EntityOperator.AND), null, null, UtilMisc.toList("orderId"), null);
+ eli = EntityQuery.use(delegator).from("OrderPaymentPreference")
+ .where(UtilMisc.toList(
+ EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PAYMENT_NOT_AUTH"),
+ EntityCondition.makeCondition("processAttempt", EntityOperator.GREATER_THAN, Long.valueOf(0))))
+ .orderBy("orderId").queryIterator();
List<String> processList = FastList.newInstance();
if (eli != null) {
Debug.logInfo("Processing failed order re-auth(s)", module);
@@ -2756,6 +2751,11 @@ public class PaymentGatewayServices {
eli = delegator.find("OrderPaymentPreference",
EntityCondition.makeCondition(EntityCondition.makeCondition("needsNsfRetry", EntityOperator.EQUALS, "Y"), EntityOperator.AND, EntityCondition.makeCondition(ModelEntity.STAMP_FIELD, EntityOperator.LESS_THAN_EQUAL_TO, oneWeekAgo)),
null, null, UtilMisc.toList("orderId"), null);
+ eli = EntityQuery.use(delegator).from("OrderPaymentPreference")
+ .where(UtilMisc.toList(
+ EntityCondition.makeCondition("needsNsfRetry", EntityOperator.EQUALS, "Y"),
+ EntityCondition.makeCondition(ModelEntity.STAMP_FIELD, EntityOperator.LESS_THAN_EQUAL_TO, oneWeekAgo)))
+ .orderBy("orderId").queryIterator();
List<String> processList = FastList.newInstance();
if (eli != null) {
@@ -3009,7 +3009,7 @@ public class PaymentGatewayServices {
// check the payment method; verify type
GenericValue paymentMethod;
try {
- paymentMethod = delegator.findOne("PaymentMethod", UtilMisc.toMap("paymentMethodId", paymentMethodId), false);
+ paymentMethod = EntityQuery.use(delegator).from("PaymentMethod").where("paymentMethodId", paymentMethodId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -3031,7 +3031,7 @@ public class PaymentGatewayServices {
// get the credit card object
GenericValue creditCard;
try {
- creditCard = delegator.findOne("CreditCard", UtilMisc.toMap("paymentMethodId", paymentMethodId), false);
+ creditCard = EntityQuery.use(delegator).from("CreditCard").where("paymentMethodId", paymentMethodId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -3146,7 +3146,7 @@ public class PaymentGatewayServices {
// Get the OrderPaymentPreference
GenericValue paymentPref = null;
try {
- paymentPref = delegator.findOne("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId), false);
+ paymentPref = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne();
} catch (GenericEntityException e) {
Debug.logWarning(e, "Problem getting OrderPaymentPreference for orderPaymentPreferenceId " +
orderPaymentPreferenceId, module);
@@ -3166,7 +3166,7 @@ public class PaymentGatewayServices {
GenericValue orderHeader = null;
String orderId = paymentPref.getString("orderId");
try {
- orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+ orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
} catch (GenericEntityException e) {
Debug.logWarning(e, "Problem getting OrderHeader for orderId " + orderId, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder,
@@ -3733,7 +3733,7 @@ public class PaymentGatewayServices {
String serviceName = null;
GenericValue customMethod = null;
try {
- customMethod = delegator.findOne("CustomMethod", UtilMisc.toMap("customMethodId", customMethodId), false);
+ customMethod = EntityQuery.use(delegator).from("CustomMethod").where("customMethodId", customMethodId).queryOne();
if (UtilValidate.isNotEmpty(customMethod)) {
serviceName = customMethod.getString("customMethodName");
}