Hi Ashish, Arun,
Sorry I did get a chance to review this before committing, I had
intended to but have been a bit busy.
There's an issue with one type of change:
paymentMethodTypes =
EntityQuery.use(delegator).from("PaymentMethodType").where("paymentMethodTypeId",
EntityOperator.NOT_EQUAL, "EXT_OFFLINE").queryList();
The where() methods don't currently support creating an entity
condition in the style used above. You'll need to wrap those three
parameters in a EntityCondition.makeCondition() method, i.e.
paymentMethodTypes = EntityQuery.use(delegator).from("PaymentMethodType")
.where(EntityCondition.makeCondition("paymentMethodTypeId",
EntityOperator.NOT_EQUAL, "EXT_OFFLINE")).queryList();
Regards
Scott
On Sun, Nov 23, 2014 at 12:29 AM, <[email protected]> wrote:
> Author: ashish
> Date: Sat Nov 22 11:29:46 2014
> New Revision: 1641045
>
> URL: http://svn.apache.org/r1641045
> Log:
> Applied ordermgr component patch from jira issue - OFBIZ-5844 - Convert java
> files to EntityQuery.
> Thanks Arun for the contribution.
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/OrderManagerEvents.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/thirdparty/zipsales/ZipSalesServices.java
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/OrderManagerEvents.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/OrderManagerEvents.java?rev=1641045&r1=1641044&r2=1641045&view=diff
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/src/org/ofbiz/order/OrderManagerEvents.java
> (original)
> +++
> ofbiz/trunk/applications/order/src/org/ofbiz/order/OrderManagerEvents.java
> Sat Nov 22 11:29:46 2014
> @@ -45,7 +45,6 @@ import org.ofbiz.entity.condition.Entity
> import org.ofbiz.entity.condition.EntityExpr;
> import org.ofbiz.entity.condition.EntityOperator;
> import org.ofbiz.entity.util.EntityQuery;
> -import org.ofbiz.entity.util.EntityUtil;
> import org.ofbiz.order.order.OrderChangeHelper;
> import org.ofbiz.service.GenericServiceException;
> import org.ofbiz.service.LocalDispatcher;
> @@ -73,10 +72,8 @@ public class OrderManagerEvents {
> List<GenericValue> paymentPrefs = null;
> GenericValue placingCustomer = null;
> try {
> - paymentPrefs = delegator.findByAnd("OrderPaymentPreference",
> UtilMisc.toMap("orderId", orderId), null, false);
> - List<GenericValue> pRoles = delegator.findByAnd("OrderRole",
> UtilMisc.toMap("orderId", orderId, "roleTypeId", "PLACING_CUSTOMER"), null,
> false);
> - if (UtilValidate.isNotEmpty(pRoles))
> - placingCustomer = EntityUtil.getFirst(pRoles);
> + paymentPrefs =
> EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId",
> orderId).queryList();
> + placingCustomer =
> EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId,
> "roleTypeId", "PLACING_CUSTOMER").queryFirst();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problems looking up order payment
> preferences", module);
> request.setAttribute("_ERROR_MESSAGE_",
> UtilProperties.getMessage(resource_error,"OrderErrorProcessingOfflinePayments",
> locale));
> @@ -136,10 +133,8 @@ public class OrderManagerEvents {
>
> // get the order header & payment preferences
> GenericValue orderHeader = null;
> - List<GenericValue> orderRoles = null;
> try {
> orderHeader =
> EntityQuery.use(delegator).from("OrderHeader").where("orderId",
> orderId).queryOne();
> - orderRoles = delegator.findList("OrderRole",
> EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderId),
> null, null, null, false);
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problems reading order header from
> datasource.", module);
> request.setAttribute("_ERROR_MESSAGE_",
> UtilProperties.getMessage(resource_error,"OrderProblemsReadingOrderHeaderInformation",
> locale));
> @@ -155,8 +150,7 @@ public class OrderManagerEvents {
> List<GenericValue> paymentMethodTypes = null;
>
> try {
> - EntityExpr ee =
> EntityCondition.makeCondition("paymentMethodTypeId",
> EntityOperator.NOT_EQUAL, "EXT_OFFLINE");
> - paymentMethodTypes = delegator.findList("PaymentMethodType", ee,
> null, null, null, false);
> + paymentMethodTypes =
> EntityQuery.use(delegator).from("PaymentMethodType").where("paymentMethodTypeId",
> EntityOperator.NOT_EQUAL, "EXT_OFFLINE").queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problems getting payment types", module);
> request.setAttribute("_ERROR_MESSAGE_",
> UtilProperties.getMessage(resource_error,"OrderProblemsWithPaymentTypeLookup",
> locale));
> @@ -171,8 +165,7 @@ public class OrderManagerEvents {
> // get the payment methods to receive
> List<GenericValue> paymentMethods = null;
> try {
> - EntityExpr ee = EntityCondition.makeCondition("partyId",
> EntityOperator.EQUALS, partyId);
> - paymentMethods = delegator.findList("PaymentMethod", ee, null,
> null, null, false);
> + paymentMethods =
> EntityQuery.use(delegator).from("PaymentMethod").where("partyId",
> partyId).queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problems getting payment methods", module);
> request.setAttribute("_ERROR_MESSAGE_",
> UtilProperties.getMessage(resource_error,"OrderProblemsWithPaymentMethodLookup",
> locale));
> @@ -181,9 +174,7 @@ public class OrderManagerEvents {
>
> GenericValue placingCustomer = null;
> try {
> - List<GenericValue> pRoles = delegator.findByAnd("OrderRole",
> UtilMisc.toMap("orderId", orderId, "roleTypeId", "PLACING_CUSTOMER"), null,
> false);
> - if (UtilValidate.isNotEmpty(pRoles))
> - placingCustomer = EntityUtil.getFirst(pRoles);
> + placingCustomer =
> EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId,
> "roleTypeId", "PLACING_CUSTOMER").queryFirst();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problems looking up order payment
> preferences", module);
> request.setAttribute("_ERROR_MESSAGE_",
> UtilProperties.getMessage(resource_error,"OrderErrorProcessingOfflinePayments",
> locale));
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java?rev=1641045&r1=1641044&r2=1641045&view=diff
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java
> (original)
> +++
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReturnServices.java
> Sat Nov 22 11:29:46 2014
> @@ -155,18 +155,17 @@ public class OrderReturnServices {
> if (orderItemSeqId != null && orderId != null) {
> Debug.logInfo("Found order item reference", module);
> // locate the item issuance(s) for this order item
> - List<GenericValue> itemIssue = null;
> + GenericValue issue = null;
> try {
> - itemIssue = delegator.findByAnd("ItemIssuance",
> UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId), null,
> false);
> + issue =
> EntityQuery.use(delegator).from("ItemIssuance").where("orderId", orderId,
> "orderItemSeqId", orderItemSeqId).queryFirst();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> throw new GeneralRuntimeException(e.getMessage());
> }
> - if (UtilValidate.isNotEmpty(itemIssue)) {
> + if (UtilValidate.isNotEmpty(issue)) {
> Debug.logInfo("Found item issuance reference", module);
> // just use the first one for now; maybe later we can
> find a better way to determine which was the
> // actual item being returned; maybe by serial number
> - GenericValue issue = EntityUtil.getFirst(itemIssue);
> GenericValue inventoryItem = null;
> try {
> inventoryItem = issue.getRelatedOne("InventoryItem",
> false);
> @@ -213,9 +212,11 @@ public class OrderReturnServices {
> List<GenericValue> returnAdjustments = FastList.newInstance();
> try {
> returnItems = returnHeader.getRelated("ReturnItem", null, null,
> false);
> - returnAdjustments = delegator.findList("ReturnAdjustment",
> EntityCondition.makeCondition(
> - EntityCondition.makeCondition("returnId",
> EntityOperator.EQUALS, returnId), EntityOperator.AND,
> -
> EntityCondition.makeCondition("returnItemSeqId", EntityOperator.EQUALS,
> "_NA_")), null, UtilMisc.toList("returnAdjustmentTypeId"), null, true);
> + returnAdjustments =
> EntityQuery.use(delegator).from("ReturnAdjustment")
> + .where("returnId", returnId, "returnItemSeqId", "_NA_")
> + .orderBy("returnAdjustmentTypeId")
> + .cache(true)
> + .queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> @@ -323,9 +324,10 @@ public class OrderReturnServices {
> GenericValue userLogin = (GenericValue) context.get("userLogin");
> List<GenericValue> returnHeaders = null;
> try {
> - returnHeaders = delegator.findList("ReturnHeader",
> EntityCondition.makeCondition(
> - EntityCondition.makeCondition("statusId",
> EntityOperator.EQUALS, "RETURN_ACCEPTED"), EntityOperator.AND,
> - EntityCondition.makeCondition("returnHeaderTypeId",
> EntityOperator.EQUALS, "CUSTOMER_RETURN")), null,
> UtilMisc.toList("entryDate"), null, false);
> + returnHeaders = EntityQuery.use(delegator).from("ReturnHeader")
> + .where("statusId", "RETURN_ACCEPTED",
> "returnHeaderTypeId", "CUSTOMER_RETURN")
> + .orderBy("entryDate")
> + .queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problem getting Return headers", module);
> }
> @@ -347,9 +349,10 @@ public class OrderReturnServices {
> Date nowDate = new Date();
> if (cancelDate.equals(nowDate) || nowDate.after(cancelDate))
> {
> try {
> - List<GenericValue> returnItems =
> delegator.findList("ReturnItem", EntityCondition.makeCondition(
> - EntityCondition.makeCondition("returnId",
> EntityOperator.EQUALS, returnId), EntityOperator.AND,
> -
> EntityCondition.makeCondition("returnTypeId", EntityOperator.EQUALS,
> "RTN_WAIT_REPLACE_RES")), null, UtilMisc.toList("createdStamp"), null, false);
> + List<GenericValue> returnItems =
> EntityQuery.use(delegator).from("ReturnItem")
> + .where("returnId", returnId, "returnTypeId",
> "RTN_WAIT_REPLACE_RES")
> + .orderBy("createdStamp")
> + .queryList();
> for (GenericValue returnItem : returnItems) {
> GenericValue returnItemResponse =
> returnItem.getRelatedOne("ReturnItemResponse", false);
> if (returnItemResponse != null) {
> @@ -483,7 +486,7 @@ public class OrderReturnServices {
> */
> List<GenericValue> orderItemQuantitiesIssued = null;
> try {
> - orderItemQuantitiesIssued =
> delegator.findList("OrderItemQuantityReportGroupByItem", whereConditions,
> UtilMisc.toSet("orderId", "orderItemSeqId", "quantityIssued"),
> UtilMisc.toList("orderItemSeqId"), null, false);
> + orderItemQuantitiesIssued =
> EntityQuery.use(delegator).select("orderId", "orderItemSeqId",
> "quantityIssued").from("OrderItemQuantityReportGroupByItem").where(whereConditions).orderBy("orderItemSeqId").queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> @@ -764,12 +767,14 @@ public class OrderReturnServices {
> // First find a Billing Account with negative balance, and
> if found store credit to that
> List<GenericValue> billingAccounts = FastList.newInstance();
> try {
> - billingAccounts =
> delegator.findByAnd("BillingAccountRoleAndAddress", UtilMisc.toMap("partyId",
> fromPartyId, "roleTypeId", "BILL_TO_CUSTOMER"), null, false);
> + billingAccounts =
> EntityQuery.use(delegator).from("BillingAccountRoleAndAddress")
> + .where("partyId", fromPartyId, "roleTypeId",
> "BILL_TO_CUSTOMER")
> + .filterByDate()
> + .orderBy("-fromDate")
> + .queryList();
> } catch (GenericEntityException e) {
> return ServiceUtil.returnError(e.getMessage());
> }
> - billingAccounts = EntityUtil.filterByDate(billingAccounts);
> - billingAccounts = EntityUtil.orderBy(billingAccounts,
> UtilMisc.toList("-fromDate"));
> if (UtilValidate.isNotEmpty(billingAccounts)) {
> ListIterator<GenericValue> billingAccountItr =
> billingAccounts.listIterator();
> while (billingAccountItr.hasNext() && billingAccountId
> == null) {
> @@ -810,16 +815,18 @@ public class OrderReturnServices {
> }
> }
> } else {
> - List<GenericValue> finAccounts = null;
> + GenericValue finAccount = null;
> try {
> - finAccounts =
> delegator.findByAnd("FinAccountAndRole", UtilMisc.toMap("partyId",
> fromPartyId, "finAccountTypeId", "STORE_CREDIT_ACCT", "roleTypeId", "OWNER",
> "statusId", "FNACT_ACTIVE"), null, false);
> + finAccount =
> EntityQuery.use(delegator).from("FinAccountAndRole")
> + .where("partyId", fromPartyId,
> "finAccountTypeId", "STORE_CREDIT_ACCT", "roleTypeId", "OWNER", "statusId",
> "FNACT_ACTIVE")
> + .filterByDate()
> + .orderBy("-fromDate")
> + .queryFirst();
> } catch (GenericEntityException e) {
> return ServiceUtil.returnError(e.getMessage());
> }
> - finAccounts = EntityUtil.filterByDate(finAccounts);
> - finAccounts = EntityUtil.orderBy(finAccounts,
> UtilMisc.toList("-fromDate"));
> - if (UtilValidate.isNotEmpty(finAccounts)) {
> - finAccountId =
> EntityUtil.getFirst(finAccounts).getString("finAccountId");
> + if (UtilValidate.isNotEmpty(finAccount)) {
> + finAccountId =
> finAccount.getString("finAccountId");
> }
>
> if (finAccountId == null) {
> @@ -1194,9 +1201,11 @@ public class OrderReturnServices {
>
> // Check for replacement order
> if (UtilValidate.isEmpty(orderPayPrefs)) {
> - List<GenericValue> orderItemAssocs =
> delegator.findByAnd("OrderItemAssoc", UtilMisc.toMap("toOrderId", orderId,
> "orderItemAssocTypeId", "REPLACEMENT"), null, false);
> - if (UtilValidate.isNotEmpty(orderItemAssocs)) {
> - String originalOrderId =
> EntityUtil.getFirst(orderItemAssocs).getString("orderId");
> + GenericValue orderItemAssoc =
> EntityQuery.use(delegator).from("OrderItemAssoc")
> +
> .where("toOrderId", orderId, "orderItemAssocTypeId", "REPLACEMENT")
> + .queryFirst();
> + if (UtilValidate.isNotEmpty(orderItemAssoc)) {
> + String originalOrderId =
> orderItemAssoc.getString("orderId");
> orderHeader =
> EntityQuery.use(delegator).from("OrderHeader").where("orderId",
> originalOrderId).queryOne();
> orderPayPrefs =
> orderHeader.getRelated("OrderPaymentPreference", null,
> UtilMisc.toList("-maxAmount"), false);
> orderPayPrefs =
> EntityUtil.filterByOr(orderPayPrefs, exprs);
> @@ -1308,10 +1317,11 @@ public class OrderReturnServices {
> orderedRefundPaymentMethodTypes.add("EFT_ACCOUNT");
>
> // Add all the other paymentMethodTypes, in no particular
> order
> - EntityConditionList<EntityExpr> pmtConditionList =
> EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("paymentMethodTypeId",
> EntityOperator.NOT_IN, orderedRefundPaymentMethodTypes)),
> EntityOperator.AND);
> List<GenericValue> otherPaymentMethodTypes =
> FastList.newInstance();
> try {
> - otherPaymentMethodTypes =
> delegator.findList("PaymentMethodType", pmtConditionList, null, null, null,
> true);
> + otherPaymentMethodTypes =
> EntityQuery.use(delegator).from("PaymentMethodType")
> +
> .where(EntityCondition.makeCondition("paymentMethodTypeId",
> EntityOperator.NOT_IN, orderedRefundPaymentMethodTypes))
> + .cache(true).queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Cannot get PaymentMethodTypes",
> module);
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource,
> @@ -2174,7 +2184,7 @@ public class OrderReturnServices {
> // lookup subscriptions
> List<GenericValue> subscriptions;
> try {
> - subscriptions = delegator.findByAnd("Subscription",
> UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId), null,
> false);
> + subscriptions =
> EntityQuery.use(delegator).from("Subscription").where("orderId", orderId,
> "orderItemSeqId", orderItemSeqId).queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> return ServiceUtil.returnError(e.getMessage());
> @@ -2273,7 +2283,7 @@ public class OrderReturnServices {
> List<GenericValue> returnItems = null;
> Map<String, Object> returnAmountByOrder = FastMap.newInstance();
> try {
> - returnItems = delegator.findByAnd("ReturnItem",
> UtilMisc.toMap("returnId", returnId), null, false);
> + returnItems =
> EntityQuery.use(delegator).from("ReturnItem").where("returnId",
> returnId).queryList();
>
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problems looking up return information",
> module);
> @@ -2378,15 +2388,13 @@ public class OrderReturnServices {
> // get returnHeaderTypeId from ReturnHeader and then use it
> to figure out return item type mapping
> returnHeader =
> EntityQuery.use(delegator).from("ReturnHeader").where("returnId",
> returnId).queryOne();
> String returnHeaderTypeId = ((returnHeader != null) &&
> (returnHeader.getString("returnHeaderTypeId") != null)) ?
> returnHeader.getString("returnHeaderTypeId") : "CUSTOMER_RETURN";
> - returnItemTypeMap = delegator.findOne("ReturnItemTypeMap",
> - UtilMisc.toMap("returnHeaderTypeId",
> returnHeaderTypeId, "returnItemMapKey",
> orderAdjustment.get("orderAdjustmentTypeId")), false);
> + returnItemTypeMap =
> EntityQuery.use(delegator).from("ReturnItemTypeMap").where("returnHeaderTypeId",
> returnHeaderTypeId, "returnItemMapKey",
> orderAdjustment.get("orderAdjustmentTypeId")).queryOne();
> returnAdjustmentType =
> returnItemTypeMap.getRelatedOne("ReturnAdjustmentType", false);
> if (returnAdjustmentType != null &&
> UtilValidate.isEmpty(description)) {
> description =
> returnAdjustmentType.getString("description");
> }
> if ((returnItemSeqId != null) &&
> !("_NA_".equals(returnItemSeqId))) {
> - returnItem = delegator.findOne("ReturnItem",
> - UtilMisc.toMap("returnId", returnId,
> "returnItemSeqId", returnItemSeqId), false);
> + returnItem =
> EntityQuery.use(delegator).from("ReturnItem").where("returnId", returnId,
> "returnItemSeqId", returnItemSeqId).queryOne();
> Debug.logInfo("returnId:" + returnId +
> ",returnItemSeqId:" + returnItemSeqId, module);
> orderItem = returnItem.getRelatedOne("OrderItem", false);
> } else {
> @@ -2395,10 +2403,9 @@ public class OrderReturnServices {
> // associated to the same order item to which the
> adjustments refers (if any)
> if
> (UtilValidate.isNotEmpty(orderAdjustment.getString("orderItemSeqId")) &&
>
> !"_NA_".equals(orderAdjustment.getString("orderItemSeqId"))) {
> - returnItem =
> EntityUtil.getFirst(delegator.findByAnd("ReturnItem",
> -
> UtilMisc.toMap("returnId", returnId,
> -
> "orderId", orderAdjustment.getString("orderId"),
> -
> "orderItemSeqId",
> orderAdjustment.getString("orderItemSeqId")), null, false));
> + returnItem =
> EntityQuery.use(delegator).from("ReturnItem")
> + .where("returnId", returnId, "orderId",
> orderAdjustment.getString("orderId"), "orderItemSeqId",
> orderAdjustment.getString("orderItemSeqId"))
> + .queryFirst();
> if (UtilValidate.isNotEmpty(returnItem)) {
> orderItem =
> returnItem.getRelatedOne("OrderItem", false);
> }
> @@ -2473,8 +2480,7 @@ public class OrderReturnServices {
> try {
> returnAdjustment =
> EntityQuery.use(delegator).from("ReturnAdjustment").where("returnAdjustmentId",
> context.get("returnAdjustmentId")).queryOne();
> if (returnAdjustment != null) {
> - returnItem = delegator.findOne("ReturnItem",
> - UtilMisc.toMap("returnId",
> returnAdjustment.get("returnId"), "returnItemSeqId",
> returnAdjustment.get("returnItemSeqId")), false);
> + returnItem =
> EntityQuery.use(delegator).from("ReturnItem").where("returnId",
> returnAdjustment.get("returnId"), "returnItemSeqId",
> returnAdjustment.get("returnItemSeqId")).queryOne();
> returnAdjustmentTypeId =
> returnAdjustment.getString("returnAdjustmentTypeId");
> }
>
> @@ -2577,7 +2583,7 @@ public class OrderReturnServices {
> List<GenericValue> adjustments;
> try {
> // TODO: find on a view-entity with a sum is probably more
> efficient
> - adjustments = delegator.findByAnd("ReturnAdjustment", condition,
> null, false);
> + adjustments =
> EntityQuery.use(delegator).from("ReturnAdjustment").where(condition).queryList();
> if (adjustments != null) {
> for (GenericValue returnAdjustment : adjustments) {
> if ((returnAdjustment != null) &&
> (returnAdjustment.get("amount") != null)) {
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1641045&r1=1641044&r2=1641045&view=diff
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> (original)
> +++
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> Sat Nov 22 11:29:46 2014
> @@ -56,7 +56,6 @@ import org.ofbiz.entity.GenericEntity;
> import org.ofbiz.entity.GenericEntityException;
> import org.ofbiz.entity.GenericValue;
> import org.ofbiz.entity.condition.EntityCondition;
> -import org.ofbiz.entity.condition.EntityConditionList;
> import org.ofbiz.entity.condition.EntityExpr;
> import org.ofbiz.entity.condition.EntityOperator;
> import org.ofbiz.entity.transaction.GenericTransactionException;
> @@ -134,8 +133,7 @@ public class OrderServices {
> if (!hasPermission) {
> GenericValue placingCustomer = null;
> try {
> - Map<String, Object> placingCustomerFields =
> UtilMisc.<String, Object>toMap("orderId", orderId, "partyId",
> userLogin.getString("partyId"), "roleTypeId", "PLACING_CUSTOMER");
> - placingCustomer = delegator.findOne("OrderRole",
> placingCustomerFields, false);
> + placingCustomer =
> EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId,
> "partyId", userLogin.getString("partyId"), "roleTypeId",
> "PLACING_CUSTOMER").queryOne();
> } catch (GenericEntityException e) {
> Debug.logError("Could not select OrderRoles for order " +
> orderId + " due to " + e.getMessage(), module);
> }
> @@ -392,8 +390,7 @@ public class OrderServices {
> if
> (workEffort.getString("workEffortId").equals(orderItem.getString("orderItemSeqId")))
> {
> List<GenericValue> selFixedAssetProduct = null;
> try {
> - List<GenericValue> allFixedAssetProduct =
> delegator.findByAnd("FixedAssetProduct",UtilMisc.toMap("productId",orderItem.getString("productId"),"fixedAssetProductTypeId",
> "FAPT_USE"), null, false);
> - selFixedAssetProduct =
> EntityUtil.filterByDate(allFixedAssetProduct, nowTimestamp, "fromDate",
> "thruDate", true);
> + selFixedAssetProduct =
> EntityQuery.use(delegator).from("FixedAssetProduct").where("productId",orderItem.getString("productId"),"fixedAssetProductTypeId",
> "FAPT_USE").filterByDate(nowTimestamp, "fromDate", "thruDate").queryList();
> } catch (GenericEntityException e) {
> String excMsg = "Could not find related Fixed
> Asset for the product: " + orderItem.getString("productId");
> Debug.logError(excMsg, module);
> @@ -670,8 +667,8 @@ public class OrderServices {
> // find fixed asset supplied on the workeffort map
> GenericValue fixedAsset = null;
> Debug.logInfo("find the fixedAsset",module);
> - try { fixedAsset = delegator.findOne("FixedAsset",
> - UtilMisc.toMap("fixedAssetId",
> workEffort.get("fixedAssetId")), false);
> + try {
> + fixedAsset =
> EntityQuery.use(delegator).from("FixedAsset").where("fixedAssetId",
> workEffort.get("fixedAssetId")).queryOne();
> }
> catch (GenericEntityException e) {
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> @@ -739,8 +736,7 @@ public class OrderServices {
> // find an existing Day exception record
> Timestamp exceptionDateStartTime =
> UtilDateTime.getDayStart(new
> Timestamp(estimatedStartDate.getTime()),(int)dayCount);
> try {
> - techDataCalendarExcDay =
> delegator.findOne("TechDataCalendarExcDay",
> - UtilMisc.toMap("calendarId",
> fixedAsset.get("calendarId"), "exceptionDateStartTime",
> exceptionDateStartTime), false);
> + techDataCalendarExcDay =
> EntityQuery.use(delegator).from("TechDataCalendarExcDay").where("calendarId",
> fixedAsset.get("calendarId"), "exceptionDateStartTime",
> exceptionDateStartTime).queryOne();
> }
> catch (GenericEntityException e) {
> Debug.logInfo(" techData excday record not found so
> creating........", module);
> @@ -991,9 +987,11 @@ public class OrderServices {
> // find all parties in role VENDOR associated with WebSite OR
> ProductStore (where WebSite overrides, if specified), associated first valid
> with the Order
> if (UtilValidate.isNotEmpty(context.get("productStoreId"))) {
> try {
> - List<GenericValue> productStoreRoles =
> delegator.findByAnd("ProductStoreRole", UtilMisc.toMap("roleTypeId",
> "VENDOR", "productStoreId", context.get("productStoreId")),
> UtilMisc.toList("-fromDate"), false);
> - productStoreRoles =
> EntityUtil.filterByDate(productStoreRoles, true);
> - GenericValue productStoreRole =
> EntityUtil.getFirst(productStoreRoles);
> + GenericValue productStoreRole =
> EntityQuery.use(delegator).from("ProductStoreRole")
> + .where("roleTypeId", "VENDOR", "productStoreId",
> context.get("productStoreId"))
> + .orderBy("-fromDate")
> + .filterByDate()
> + .queryFirst();
> if (productStoreRole != null) {
> toBeStored.add(delegator.makeValue("OrderRole",
> UtilMisc.toMap("orderId", orderId, "partyId",
> productStoreRole.get("partyId"), "roleTypeId", "VENDOR")));
> @@ -1005,9 +1003,7 @@ public class OrderServices {
> }
> if (UtilValidate.isNotEmpty(context.get("webSiteId"))) {
> try {
> - List<GenericValue> webSiteRoles =
> delegator.findByAnd("WebSiteRole", UtilMisc.toMap("roleTypeId", "VENDOR",
> "webSiteId", context.get("webSiteId")), UtilMisc.toList("-fromDate"), false);
> - webSiteRoles = EntityUtil.filterByDate(webSiteRoles, true);
> - GenericValue webSiteRole = EntityUtil.getFirst(webSiteRoles);
> + GenericValue webSiteRole =
> EntityQuery.use(delegator).from("WebSiteRole").where("roleTypeId", "VENDOR",
> "webSiteId",
> context.get("webSiteId")).orderBy("-fromDate").filterByDate().queryFirst();
> if (webSiteRole != null) {
> toBeStored.add(delegator.makeValue("OrderRole",
> UtilMisc.toMap("orderId", orderId, "partyId",
> webSiteRole.get("partyId"), "roleTypeId", "VENDOR")));
> @@ -1162,7 +1158,7 @@ public class OrderServices {
> String productId = (String) context.get("productId");
> BigDecimal quantity = (BigDecimal) context.get("quantity");
> try {
> - productCalculatedInfoList =
> delegator.findByAnd("ProductCalculatedInfo", UtilMisc.toMap("productId",
> productId), null, false);
> + productCalculatedInfoList =
> EntityQuery.use(delegator).from("ProductCalculatedInfo").where("productId",
> productId).queryList();
> if (UtilValidate.isEmpty(productCalculatedInfoList)) {
> productCalculatedInfo =
> delegator.makeValue("ProductCalculatedInfo");
> productCalculatedInfo.set("productId", productId);
> @@ -1187,7 +1183,7 @@ public class OrderServices {
>
> String virtualProductId = null;
> try {
> - GenericValue product = delegator.findOne("Product",
> UtilMisc.toMap("productId", productId), true);
> + GenericValue product =
> EntityQuery.use(delegator).from("Product").where("productId",
> productId).cache(true).queryOne();
> virtualProductId = ProductWorker.getVariantVirtualId(product);
> } catch (GenericEntityException e) {
> Debug.logError(e, "Error calling countProductQuantityOrdered
> service", module);
> @@ -1544,11 +1540,10 @@ public class OrderServices {
> EntityCondition.makeCondition("remainingSubTotal",
> EntityOperator.EQUALS, null));
> cond = EntityCondition.makeCondition(exprs, EntityOperator.OR);
> }
> - Set<String> fields = UtilMisc.toSet("orderId");
>
> EntityListIterator eli = null;
> try {
> - eli = delegator.find("OrderHeader", cond, null, fields, null,
> null);
> + eli =
> EntityQuery.use(delegator).select("orderId").from("OrderHeader").where(cond).queryIterator();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> return ServiceUtil.returnError(e.getMessage());
> @@ -1625,7 +1620,7 @@ public class OrderServices {
> // Retrieve the order tax adjustments
> List<GenericValue> orderTaxAdjustments = null;
> try {
> - orderTaxAdjustments = delegator.findByAnd("OrderAdjustment",
> UtilMisc.toMap("orderId", orderId, "orderAdjustmentTypeId", "SALES_TAX"),
> null, false);
> + orderTaxAdjustments =
> EntityQuery.use(delegator).from("OrderAdjustment").where("orderId", orderId,
> "orderAdjustmentTypeId", "SALES_TAX").queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Unable to retrieve SALES_TAX adjustments for
> order : " + orderId, module);
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> @@ -1703,8 +1698,7 @@ public class OrderServices {
> GenericValue facilityContactMech =
> ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId,
> UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION"));
> if (facilityContactMech != null) {
> try {
> - shippingAddress =
> delegator.findOne("PostalAddress",
> - UtilMisc.toMap("contactMechId",
> facilityContactMech.getString("contactMechId")), false);
> + shippingAddress =
> EntityQuery.use(delegator).from("PostalAddress").where("contactMechId",
> facilityContactMech.getString("contactMechId")).queryOne();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> }
> @@ -1934,7 +1928,7 @@ public class OrderServices {
> // get the order items
> List<GenericValue> orderItems = null;
> try {
> - orderItems = delegator.findByAnd("OrderItem",
> UtilMisc.toMap("orderId", orderId), null, false);
> + orderItems =
> EntityQuery.use(delegator).from("OrderItem").where("orderId",
> orderId).queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Cannot get OrderItem records", module);
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> @@ -1987,9 +1981,7 @@ public class OrderServices {
> String headerApprovedStatus =
> productStore.getString("headerApprovedStatus");
> if
> (UtilValidate.isNotEmpty(headerApprovedStatus)) {
> if
> (headerApprovedStatus.equals(orderHeaderStatusId)) {
> - Map<String, Object> orderStatusCheckMap
> = UtilMisc.<String, Object>toMap("orderId", orderId, "statusId",
> headerApprovedStatus, "orderItemSeqId", null);
> -
> - List<GenericValue> orderStatusList =
> delegator.findByAnd("OrderStatus", orderStatusCheckMap, null, false);
> + List<GenericValue> orderStatusList =
> EntityQuery.use(delegator).from("OrderStatus").where("orderId", orderId,
> "statusId", headerApprovedStatus, "orderItemSeqId", null).queryList();
> // should be 1 in the history, but just
> in case accept 0 too
> if (orderStatusList.size() <= 1) {
> changeToApprove = false;
> @@ -2078,7 +2070,7 @@ public class OrderServices {
>
> List<GenericValue> orderItemShipGroupAssocs = null;
> try {
> - orderItemShipGroupAssocs =
> delegator.findByAnd("OrderItemShipGroupAssoc", fields, null, false);
> + orderItemShipGroupAssocs =
> EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where(fields).queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> @@ -2244,7 +2236,7 @@ public class OrderServices {
>
> List<GenericValue> orderItems = null;
> try {
> - orderItems = delegator.findList("OrderItem",
> EntityCondition.makeCondition(exprs, EntityOperator.AND), null, null, null,
> false);
> + orderItems =
> EntityQuery.use(delegator).from("OrderItem").where(exprs).queryList();
> } catch (GenericEntityException e) {
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> "OrderErrorCannotGetOrderItemEntity",locale) +
> e.getMessage());
> @@ -2266,8 +2258,7 @@ public class OrderServices {
> }
>
> try {
> - Map<String, String> statusFields = UtilMisc.<String,
> String>toMap("statusId", orderItem.getString("statusId"), "statusIdTo",
> statusId);
> - GenericValue statusChange =
> delegator.findOne("StatusValidChange", statusFields, true);
> + GenericValue statusChange =
> EntityQuery.use(delegator).from("StatusValidChange").where("statusId",
> orderItem.getString("statusId"), "statusIdTo", statusId).queryOne();
>
> if (statusChange == null) {
>
> Debug.logWarning(UtilProperties.getMessage(resource_error,
> @@ -2350,11 +2341,10 @@ public class OrderServices {
> return successResult;
> }
> try {
> - Map<String, String> statusFields = UtilMisc.<String,
> String>toMap("statusId", orderHeader.getString("statusId"), "statusIdTo",
> statusId);
> - GenericValue statusChange =
> delegator.findOne("StatusValidChange", statusFields, true);
> + GenericValue statusChange =
> EntityQuery.use(delegator).from("StatusValidChange").where("statusId",
> orderHeader.getString("statusId"), "statusIdTo",
> statusId).cache(true).queryOne();
> if (statusChange == null) {
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> -
> "OrderErrorCouldNotChangeOrderStatusStatusIsNotAValidChange", locale) + ": ["
> + statusFields.get("statusId") + "] -> [" + statusFields.get("statusIdTo") +
> "]");
> +
> "OrderErrorCouldNotChangeOrderStatusStatusIsNotAValidChange", locale) + ": ["
> + orderHeader.getString("statusId") + "] -> [" + statusId + "]");
> }
> } catch (GenericEntityException e) {
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> @@ -2476,7 +2466,7 @@ public class OrderServices {
>
> try {
> // first check and see if we are already there; if so, just
> return success
> - GenericValue testValue = delegator.findOne("OrderRole", fields,
> false);
> + GenericValue testValue =
> EntityQuery.use(delegator).from("OrderRole").where(fields).queryOne();
> if (testValue != null) {
> ServiceUtil.returnSuccess();
> } else {
> @@ -2499,13 +2489,12 @@ public class OrderServices {
> String orderId = (String) context.get("orderId");
> String partyId = (String) context.get("partyId");
> String roleTypeId = (String) context.get("roleTypeId");
> - Map<String, String> fields = UtilMisc.<String,
> String>toMap("orderId", orderId, "partyId", partyId, "roleTypeId",
> roleTypeId);
> //Locale locale = (Locale) context.get("locale");
>
> GenericValue testValue = null;
>
> try {
> - testValue = delegator.findOne("OrderRole", fields, false);
> + testValue =
> EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId,
> "partyId", partyId, "roleTypeId", roleTypeId).queryOne();
> } catch (GenericEntityException e) {
> result.put(ModelService.RESPONSE_MESSAGE,
> ModelService.RESPOND_ERROR);
> result.put(ModelService.ERROR_MESSAGE, "ERROR: Could not add
> role to order (" + e.getMessage() + ").");
> @@ -2518,7 +2507,7 @@ public class OrderServices {
> }
>
> try {
> - GenericValue value = delegator.findOne("OrderRole", fields,
> false);
> + GenericValue value =
> EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId,
> "partyId", partyId, "roleTypeId", roleTypeId).queryOne();
>
> value.remove();
> } catch (GenericEntityException e) {
> @@ -3006,8 +2995,7 @@ public class OrderServices {
> if (!security.hasEntityPermission("ORDERMGR", "_UPDATE", userLogin))
> {
> GenericValue placingCustomer = null;
> try {
> - Map<String, Object> placingCustomerFields =
> UtilMisc.<String, Object>toMap("orderId", orderId, "partyId",
> userLogin.getString("partyId"), "roleTypeId", "PLACING_CUSTOMER");
> - placingCustomer = delegator.findOne("OrderRole",
> placingCustomerFields, false);
> + placingCustomer =
> EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId,
> "partyId", userLogin.getString("partyId"), "roleTypeId",
> "PLACING_CUSTOMER").queryOne();
> } catch (GenericEntityException e) {
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> "OrderErrorCannotGetOrderRoleEntity", locale) +
> e.getMessage());
> @@ -3020,8 +3008,7 @@ public class OrderServices {
>
> GenericValue shipGroup = null;
> try {
> - Map<String, String> fields = UtilMisc.<String,
> String>toMap("orderId", orderId, "shipGroupSeqId", shipGroupSeqId);
> - shipGroup = delegator.findOne("OrderItemShipGroup", fields,
> false);
> + shipGroup =
> EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId",
> orderId, "shipGroupSeqId", shipGroupSeqId).queryOne();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problems getting OrderItemShipGroup for : " +
> orderId + " / " + shipGroupSeqId, module);
> return
> ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
> @@ -3060,11 +3047,10 @@ public class OrderServices {
> EntityCondition.makeCondition("statusId",
> EntityOperator.NOT_EQUAL, "ORDER_CANCELLED"),
> EntityCondition.makeCondition("statusId",
> EntityOperator.NOT_EQUAL, "ORDER_REJECTED")
> );
> - EntityConditionList<EntityCondition> ecl =
> EntityCondition.makeCondition(exprs, EntityOperator.AND);
>
> // get the orders
> try {
> - ordersToCheck = delegator.findList("OrderHeader", ecl, null,
> UtilMisc.toList("orderDate"), null, false);
> + ordersToCheck =
> EntityQuery.use(delegator).from("OrderHeader").where(exprs).orderBy("orderDate").queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problem getting order headers", module);
> }
> @@ -3131,11 +3117,9 @@ public class OrderServices {
>
> itemsExprs.add(EntityCondition.makeCondition("dontCancelSetDate",
> EntityOperator.EQUALS, GenericEntity.NULL_FIELD));
>
> itemsExprs.add(EntityCondition.makeCondition("autoCancelDate",
> EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD));
>
> - ecl = EntityCondition.makeCondition(itemsExprs);
> -
> List<GenericValue> orderItems = null;
> try {
> - orderItems = delegator.findList("OrderItem", ecl, null,
> null, null, false);
> + orderItems =
> EntityQuery.use(delegator).from("OrderItem").where(itemsExprs).queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problem getting order item records",
> module);
> }
> @@ -3369,7 +3353,7 @@ public class OrderServices {
> exprs.add(EntityCondition.makeCondition("productId",
> EntityOperator.EQUALS, product.getString("productId")));
>
> // try looking up the parent product if the product has
> no content and is a variant
> - List<GenericValue> allProductContent =
> delegator.findList("ProductContent", EntityCondition.makeCondition(exprs,
> EntityOperator.AND), null, null, null, false);
> + List<GenericValue> allProductContent =
> EntityQuery.use(delegator).from("ProductContent").where(exprs).queryList();
> if (UtilValidate.isEmpty(allProductContent) &&
> ("Y".equals(product.getString("isVariant")))) {
> GenericValue parentProduct =
> ProductWorker.getParentProduct(product.getString("productId"), delegator);
> if (allProductContent == null) {
> @@ -3957,7 +3941,7 @@ public class OrderServices {
> // find ship group associations
> List<GenericValue> shipGroupAssocs = null;
> try {
> - shipGroupAssocs = delegator.findByAnd("OrderItemShipGroupAssoc",
> UtilMisc.toMap("orderId", orderId), null, false);
> + shipGroupAssocs =
> EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId",
> orderId).queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> throw new GeneralException(e.getMessage());
> @@ -3988,7 +3972,7 @@ public class OrderServices {
> // cancel promo items -- if the promo still qualifies it will be
> added by the cart
> List<GenericValue> promoItems = null;
> try {
> - promoItems = delegator.findByAnd("OrderItem",
> UtilMisc.toMap("orderId", orderId, "isPromo", "Y"), null, false);
> + promoItems =
> EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId,
> "isPromo", "Y").queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> throw new GeneralException(e.getMessage());
> @@ -4036,8 +4020,7 @@ public class OrderServices {
> exprs.add(EntityCondition.makeCondition("statusId",
> EntityOperator.NOT_EQUAL, "PAYMENT_DECLINED"));
> exprs.add(EntityCondition.makeCondition("statusId",
> EntityOperator.NOT_EQUAL, "PAYMENT_SETTLED"));
> exprs.add(EntityCondition.makeCondition("statusId",
> EntityOperator.NOT_EQUAL, "PAYMENT_REFUNDED"));
> - EntityCondition cond = EntityCondition.makeCondition(exprs,
> EntityOperator.AND);
> - paymentPrefsToCancel =
> delegator.findList("OrderPaymentPreference", cond, null, null, null, false);
> + paymentPrefsToCancel =
> EntityQuery.use(delegator).from("OrderPaymentPreference").where(exprs).queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> throw new GeneralException(e.getMessage());
> @@ -4215,15 +4198,15 @@ public class OrderServices {
> if (deleteItems) {
> // flag to delete existing order items and adjustments
> try {
> -
> toRemove.addAll(delegator.findByAnd("OrderItemShipGroupAssoc",
> UtilMisc.toMap("orderId", orderId), null, false));
> - toRemove.addAll(delegator.findByAnd("OrderItemContactMech",
> UtilMisc.toMap("orderId", orderId), null, false));
> - toRemove.addAll(delegator.findByAnd("OrderItemPriceInfo",
> UtilMisc.toMap("orderId", orderId), null, false));
> - toRemove.addAll(delegator.findByAnd("OrderItemAttribute",
> UtilMisc.toMap("orderId", orderId), null, false));
> - toRemove.addAll(delegator.findByAnd("OrderItemBilling",
> UtilMisc.toMap("orderId", orderId), null, false));
> - toRemove.addAll(delegator.findByAnd("OrderItemRole",
> UtilMisc.toMap("orderId", orderId), null, false));
> - toRemove.addAll(delegator.findByAnd("OrderItemChange",
> UtilMisc.toMap("orderId", orderId), null, false));
> - toRemove.addAll(delegator.findByAnd("OrderAdjustment",
> UtilMisc.toMap("orderId", orderId), null, false));
> - toRemove.addAll(delegator.findByAnd("OrderItem",
> UtilMisc.toMap("orderId", orderId), null, false));
> +
> toRemove.addAll(EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId",
> orderId).queryList());
> +
> toRemove.addAll(EntityQuery.use(delegator).from("OrderItemContactMech").where("orderId",
> orderId).queryList());
> +
> toRemove.addAll(EntityQuery.use(delegator).from("OrderItemPriceInfo").where("orderId",
> orderId).queryList());
> +
> toRemove.addAll(EntityQuery.use(delegator).from("OrderItemAttribute").where("orderId",
> orderId).queryList());
> +
> toRemove.addAll(EntityQuery.use(delegator).from("OrderItemBilling").where("orderId",
> orderId).queryList());
> +
> toRemove.addAll(EntityQuery.use(delegator).from("OrderItemRole").where("orderId",
> orderId).queryList());
> +
> toRemove.addAll(EntityQuery.use(delegator).from("OrderItemChange").where("orderId",
> orderId).queryList());
> +
> toRemove.addAll(EntityQuery.use(delegator).from("OrderAdjustment").where("orderId",
> orderId).queryList());
> +
> toRemove.addAll(EntityQuery.use(delegator).from("OrderItem").where("orderId",
> orderId).queryList());
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> }
> @@ -4247,8 +4230,8 @@ public class OrderServices {
> List<GenericValue> existingPromoCodes = null;
> List<GenericValue> existingPromoUses = null;
> try {
> - existingPromoCodes =
> delegator.findByAnd("OrderProductPromoCode", UtilMisc.toMap("orderId",
> orderId), null, false);
> - existingPromoUses = delegator.findByAnd("ProductPromoUse",
> UtilMisc.toMap("orderId", orderId), null, false);
> + existingPromoCodes =
> EntityQuery.use(delegator).from("OrderProductPromoCode").where("orderId",
> orderId).queryList();
> + existingPromoUses =
> EntityQuery.use(delegator).from("ProductPromoUse").where("orderId",
> orderId).queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> }
> @@ -4782,8 +4765,7 @@ public class OrderServices {
> }
> List<GenericValue> invInfo = null;
> try {
> - invInfo =
> delegator.findByAnd("OrderItemAndShipGrpInvResAndItem",
> - UtilMisc.toMap("orderId", orderId, "statusId",
> "ITEM_APPROVED"), null, false);
> + invInfo =
> EntityQuery.use(delegator).from("OrderItemAndShipGrpInvResAndItem").where("orderId",
> orderId, "statusId", "ITEM_APPROVED").queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> return ServiceUtil.returnError(e.getMessage());
> @@ -5020,7 +5002,7 @@ public class OrderServices {
> // The checkOutPaymentId is either a paymentMethodId or
> paymentMethodTypeId
> // the original method did a "\d+" regexp to decide which is the
> case, this version is more explicit with its lookup of PaymentMethodType
> if (checkOutPaymentId != null) {
> - List<GenericValue> paymentMethodTypes =
> delegator.findList("PaymentMethodType", null, null, null, null, true);
> + List<GenericValue> paymentMethodTypes =
> EntityQuery.use(delegator).from("PaymentMethodType").cache(true).queryList();
> for (GenericValue type : paymentMethodTypes) {
> if
> (type.get("paymentMethodTypeId").equals(checkOutPaymentId)) {
> paymentMethodTypeId = (String)
> type.get("paymentMethodTypeId");
> @@ -5399,7 +5381,7 @@ public class OrderServices {
> List<GenericValue> orderItems =
> orderHeader.getRelated("OrderItem", null, UtilMisc.toList("orderItemSeqId"),
> false);
> for (GenericValue orderItem : orderItems) {
> // Look at the orderItemBillings to discover the amount and
> quantity ever invoiced for this order item
> - List<GenericValue> orderItemBillings =
> delegator.findByAnd("OrderItemBilling", UtilMisc.toMap("orderId", orderId,
> "orderItemSeqId", orderItem.get("orderItemSeqId")), null, false);
> + List<GenericValue> orderItemBillings =
> EntityQuery.use(delegator).from("OrderItemBilling").where("orderId", orderId,
> "orderItemSeqId", orderItem.get("orderItemSeqId")).queryList();
> for (GenericValue orderItemBilling : orderItemBillings) {
> BigDecimal quantity =
> orderItemBilling.getBigDecimal("quantity");
> BigDecimal amount =
> orderItemBilling.getBigDecimal("amount").setScale(orderDecimals,
> orderRounding);
> @@ -5416,12 +5398,12 @@ public class OrderServices {
> }
>
> // Retrieve the adjustments for this item
> - List<GenericValue> orderAdjustments =
> delegator.findByAnd("OrderAdjustment", UtilMisc.toMap("orderId", orderId,
> "orderItemSeqId", orderItem.get("orderItemSeqId")), null, false);
> + List<GenericValue> orderAdjustments =
> EntityQuery.use(delegator).from("OrderAdjustment").where("orderId", orderId,
> "orderItemSeqId", orderItem.get("orderItemSeqId")).queryList();
> for (GenericValue orderAdjustment : orderAdjustments) {
> String orderAdjustmentTypeId =
> orderAdjustment.getString("orderAdjustmentTypeId");
>
> // Look at the orderAdjustmentBillings to discove the
> amount ever invoiced for this order adjustment
> - List<GenericValue> orderAdjustmentBillings =
> delegator.findByAnd("OrderAdjustmentBilling",
> UtilMisc.toMap("orderAdjustmentId",
> orderAdjustment.get("orderAdjustmentId")), null, false);
> + List<GenericValue> orderAdjustmentBillings =
> EntityQuery.use(delegator).from("OrderAdjustmentBilling").where("orderAdjustmentId",
> orderAdjustment.get("orderAdjustmentId")).queryList();
> for (GenericValue orderAjustmentBilling :
> orderAdjustmentBillings) {
> BigDecimal amount =
> orderAjustmentBilling.getBigDecimal("amount").setScale(orderDecimals,
> orderRounding);
> if (UtilValidate.isEmpty(amount)) continue;
> @@ -5448,9 +5430,9 @@ public class OrderServices {
>
> // Total the order-header-level adjustments for the order
> BigDecimal orderHeaderAdjustmentsTotalValue = ZERO;
> - List<GenericValue> orderHeaderAdjustments =
> delegator.findByAnd("OrderAdjustment", UtilMisc.toMap("orderId", orderId,
> "orderItemSeqId", "_NA_"), null, false);
> + List<GenericValue> orderHeaderAdjustments =
> EntityQuery.use(delegator).from("OrderAdjustment").where("orderId", orderId,
> "orderItemSeqId", "_NA_").queryList();
> for (GenericValue orderHeaderAdjustment :
> orderHeaderAdjustments) {
> - List<GenericValue> orderHeaderAdjustmentBillings =
> delegator.findByAnd("OrderAdjustmentBilling",
> UtilMisc.toMap("orderAdjustmentId",
> orderHeaderAdjustment.get("orderAdjustmentId")), null, false);
> + List<GenericValue> orderHeaderAdjustmentBillings =
> EntityQuery.use(delegator).from("OrderAdjustmentBilling").where("orderAdjustmentId",
> orderHeaderAdjustment.get("orderAdjustmentId")).queryList();
> for (GenericValue orderHeaderAdjustmentBilling :
> orderHeaderAdjustmentBillings) {
> BigDecimal amount =
> orderHeaderAdjustmentBilling.getBigDecimal("amount").setScale(orderDecimals,
> orderRounding);
> if (UtilValidate.isEmpty(amount)) continue;
> @@ -5507,8 +5489,7 @@ public class OrderServices {
> orderStatus.put("changeReason", changeReason);
>
> // Check that the status has actually changed before creating a
> new record
> - List<GenericValue> previousStatusList =
> delegator.findByAnd("OrderStatus", UtilMisc.toMap("orderId", orderId,
> "orderPaymentPreferenceId", orderPaymentPreferenceId),
> UtilMisc.toList("-statusDatetime"), false);
> - GenericValue previousStatus =
> EntityUtil.getFirst(previousStatusList);
> + GenericValue previousStatus =
> EntityQuery.use(delegator).from("OrderStatus").where("orderId", orderId,
> "orderPaymentPreferenceId",
> orderPaymentPreferenceId).orderBy("-statusDatetime").queryFirst();
> if (previousStatus != null) {
> // Temporarily set some values on the new status so that we
> can do an equals() check
> orderStatus.put("orderStatusId",
> previousStatus.get("orderStatusId"));
> @@ -5545,9 +5526,8 @@ public class OrderServices {
> List<EntityExpr> exprs =
> UtilMisc.toList(EntityCondition.makeCondition("automaticExtend",
> EntityOperator.EQUALS, "Y"),
> EntityCondition.makeCondition("orderId",
> EntityOperator.NOT_EQUAL, null),
> EntityCondition.makeCondition("productId",
> EntityOperator.NOT_EQUAL, null));
> - EntityCondition cond = EntityCondition.makeCondition(exprs,
> EntityOperator.AND);
> EntityListIterator eli = null;
> - eli = delegator.find("Subscription", cond, null, null, null,
> null);
> + eli =
> EntityQuery.use(delegator).from("Subscription").where(exprs).queryIterator();
>
> if (eli != null) {
> GenericValue subscription;
> @@ -5663,7 +5643,7 @@ public class OrderServices {
> String shipGroupSeqId = (String) context.get("shipGroupSeqId");
> String shippingInstructions = (String)
> context.get("shippingInstructions");
> try {
> - GenericValue orderItemShipGroup =
> EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGroup",
> UtilMisc.toMap("orderId", orderId,"shipGroupSeqId",shipGroupSeqId), null,
> false));
> + GenericValue orderItemShipGroup =
> EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId",
> orderId,"shipGroupSeqId",shipGroupSeqId).queryFirst();
> orderItemShipGroup.set("shippingInstructions",
> shippingInstructions);
> orderItemShipGroup.store();
> } catch (GenericEntityException e) {
> @@ -5678,7 +5658,7 @@ public class OrderServices {
> String shipGroupSeqId = (String) context.get("shipGroupSeqId");
> String giftMessage = (String) context.get("giftMessage");
> try {
> - GenericValue orderItemShipGroup =
> EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGroup",
> UtilMisc.toMap("orderId", orderId,"shipGroupSeqId",shipGroupSeqId), null,
> false));
> + GenericValue orderItemShipGroup =
> EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId",
> orderId,"shipGroupSeqId",shipGroupSeqId).queryFirst();
> orderItemShipGroup.set("giftMessage", giftMessage);
> orderItemShipGroup.set("isGift", "Y");
> orderItemShipGroup.store();
> @@ -5739,7 +5719,7 @@ public class OrderServices {
> List<String> orderIds = new LinkedList<String>();
> EntityListIterator eli = null;
> try {
> - eli = delegator.find("OrderHeader", cond, null,
> UtilMisc.toSet("orderId"), UtilMisc.toList("entryDate ASC"), null);
> + eli =
> EntityQuery.use(delegator).select("orderId").from("OrderHeader").where(cond).orderBy("entryDate
> ASC").queryIterator();
> GenericValue orderHeader;
> while ((orderHeader = eli.next()) != null) {
> orderIds.add(orderHeader.getString("orderId"));
> @@ -5806,7 +5786,7 @@ public class OrderServices {
> GenericValue existingProductAssoc = null;
> try {
> // No point in using the cache because of the
> filterByDateExpr
> - existingProductAssoc =
> EntityUtil.getFirst(delegator.findList("ProductAssoc", cond, null,
> UtilMisc.toList("fromDate DESC"), null, false));
> + existingProductAssoc =
> EntityQuery.use(delegator).from("ProductAssoc").where(cond).orderBy("fromDate
> DESC").queryFirst();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> }
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java?rev=1641045&r1=1641044&r2=1641045&view=diff
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
> (original)
> +++
> ofbiz/trunk/applications/order/src/org/ofbiz/order/requirement/RequirementServices.java
> Sat Nov 22 11:29:46 2014
> @@ -59,7 +59,6 @@ public class RequirementServices {
> //TODO currencyUomId still not used
> //String currencyUomId = (String) context.get("currencyUomId");
> try {
> - List<String> orderBy = UtilMisc.toList("partyId",
> "requirementId");
> List<EntityCondition> conditions = UtilMisc.toList(
> EntityCondition.makeCondition("requirementTypeId",
> EntityOperator.EQUALS, "PRODUCT_REQUIREMENT"),
> EntityUtil.getFilterByDateExpr()
> @@ -81,8 +80,10 @@ public class RequirementServices {
> conditions.add(EntityCondition.makeCondition("roleTypeId",
> EntityOperator.EQUALS, "SUPPLIER"));
> }
>
> - EntityConditionList<EntityCondition> ecl =
> EntityCondition.makeCondition(conditions, EntityOperator.AND);
> - List<GenericValue> requirementAndRoles =
> delegator.findList("RequirementAndRole", ecl, null, orderBy, null, false);
> + List<GenericValue> requirementAndRoles =
> EntityQuery.use(delegator).from("RequirementAndRole")
> + .where(conditions)
> + .orderBy("partyId", "requirementId")
> + .queryList();
>
> // maps to cache the associated suppliers and products data, so
> we don't do redundant DB and service requests
> Map<String, GenericValue> suppliers = FastMap.newInstance();
> @@ -111,16 +112,12 @@ public class RequirementServices {
> String supplierKey = partyId + "^" + productId;
> GenericValue supplierProduct = suppliers.get(supplierKey);
> if (supplierProduct == null) {
> - conditions = UtilMisc.toList(
> - // TODO: it is possible to restrict to quantity
> > minimumOrderQuantity, but then the entire requirement must be skipped
> - EntityCondition.makeCondition("partyId",
> EntityOperator.EQUALS, partyId),
> - EntityCondition.makeCondition("productId",
> EntityOperator.EQUALS, productId),
> -
> EntityUtil.getFilterByDateExpr("availableFromDate", "availableThruDate")
> - );
> - ecl = EntityCondition.makeCondition(conditions,
> EntityOperator.AND);
> - List<GenericValue> supplierProducts =
> delegator.findList("SupplierProduct", ecl, null,
> UtilMisc.toList("minimumOrderQuantity", "lastPrice"), null, false);
> -
> - supplierProduct = EntityUtil.getFirst(supplierProducts);
> + // TODO: it is possible to restrict to quantity >
> minimumOrderQuantity, but then the entire requirement must be skipped
> + supplierProduct =
> EntityQuery.use(delegator).from("SupplierProduct")
> + .where("partyId", partyId, "productId",
> productId)
> + .orderBy("minimumOrderQuantity", "lastPrice")
> + .filterByDate("availableFromDate",
> "availableThruDate")
> + .queryFirst();
> suppliers.put(supplierKey, supplierProduct);
> }
>
> @@ -166,7 +163,7 @@ public class RequirementServices {
>
> EntityCondition.makeCondition("orderItemStatusId", EntityOperator.NOT_IN,
> UtilMisc.toList("ITEM_REJECTED", "ITEM_CANCELLED")),
> EntityCondition.makeCondition("orderDate",
> EntityOperator.GREATER_THAN_EQUAL_TO, timePeriodStart)
> ), EntityOperator.AND);
> - GenericValue count =
> EntityUtil.getFirst(delegator.findList("OrderItemQuantityReportGroupByProduct",
> prodConditions, UtilMisc.toSet("quantityOrdered"), null, null, false));
> + GenericValue count =
> EntityQuery.use(delegator).select("quantityOrdered").from("OrderItemQuantityReportGroupByProduct").where(prodConditions).queryFirst();
> if (count != null) {
> sold = count.getBigDecimal("quantityOrdered");
> if (sold != null) productsSold.put(productId, sold);
> @@ -309,7 +306,7 @@ public class RequirementServices {
> EntityCondition.makeCondition("statusId",
> EntityOperator.NOT_EQUAL, "REQ_ORDERED"),
> EntityCondition.makeCondition("statusId",
> EntityOperator.NOT_EQUAL, "REQ_REJECTED")),
> EntityOperator.AND);
> - List<GenericValue> requirements =
> delegator.findList("Requirement", ecl, null, null, null, false);
> + List<GenericValue> requirements =
> EntityQuery.use(delegator).from("Requirement").where(ecl).queryList();
> for (GenericValue requirement : requirements) {
> pendingRequirements =
> pendingRequirements.add(requirement.get("quantity") == null ? BigDecimal.ZERO
> : requirement.getBigDecimal("quantity"));
> }
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=1641045&r1=1641044&r2=1641045&view=diff
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
> (original)
> +++
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
> Sat Nov 22 11:29:46 2014
> @@ -44,7 +44,6 @@ 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.marketing.tracking.TrackingCodeEvents;
> import org.ofbiz.order.order.OrderReadHelper;
> import org.ofbiz.party.party.PartyWorker;
> @@ -651,10 +650,8 @@ public class CheckOutEvents {
> GenericValue productStore =
> ProductStoreWorker.getProductStore(cart.getProductStoreId(), delegator);
> String paymentMethodTypeId =
> request.getParameter("paymentMethodTypeId");
> if ("EXT_PAYPAL".equals(paymentMethodTypeId) ||
> cart.getPaymentMethodTypeIds().contains("EXT_PAYPAL")) {
> - List<GenericValue> payPalProdStorePaySettings = null;
> try {
> - payPalProdStorePaySettings =
> delegator.findByAnd("ProductStorePaymentSetting",
> UtilMisc.toMap("productStoreId", productStore.getString("productStoreId"),
> "paymentMethodTypeId", "EXT_PAYPAL"), null, false);
> - GenericValue payPalProdStorePaySetting =
> EntityUtil.getFirst(payPalProdStorePaySettings);
> + GenericValue payPalProdStorePaySetting =
> EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId",
> productStore.getString("productStoreId"), "paymentMethodTypeId",
> "EXT_PAYPAL").queryFirst();
> if (payPalProdStorePaySetting != null) {
> GenericValue gatewayConfig =
> payPalProdStorePaySetting.getRelatedOne("PaymentGatewayConfig", false);
> if (gatewayConfig != null &&
> "PAYFLOWPRO".equals(gatewayConfig.getString("paymentGatewayConfigTypeId"))) {
> @@ -1156,12 +1153,10 @@ public class CheckOutEvents {
> for (ShoppingCartItem sci : cartLines) {
> int index = cart.getItemIndex(sci);
> try {
> - Map<String, Object> orderItemMap = FastMap.newInstance();
> - orderItemMap.put("orderId", originalOrderId);
> - orderItemMap.put("isPromo", sci.getIsPromo() ? "Y" : "N");
> - orderItemMap.put("productId", sci.getProductId());
> - orderItemMap.put("orderItemTypeId", sci.getItemType());
> - GenericValue orderItem =
> EntityUtil.getFirst(delegator.findByAnd("OrderItem", orderItemMap, null,
> false));
> + GenericValue orderItem =
> EntityQuery.use(delegator).from("OrderItem")
> + .where("orderId",
> originalOrderId, "isPromo", sci.getIsPromo() ? "Y" : "N",
> + "productId",
> sci.getProductId(), "orderItemTypeId", sci.getItemType())
> + .queryFirst();
> if (UtilValidate.isNotEmpty(orderItem)) {
> sci.setAssociatedOrderId(orderItem.getString("orderId"));
>
> sci.setAssociatedOrderItemSeqId(orderItem.getString("orderItemSeqId"));
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=1641045&r1=1641044&r2=1641045&view=diff
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
> (original)
> +++
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
> Sat Nov 22 11:29:46 2014
> @@ -43,7 +43,6 @@ import org.ofbiz.entity.Delegator;
> import org.ofbiz.entity.GenericEntityException;
> import org.ofbiz.entity.GenericValue;
> import org.ofbiz.entity.condition.EntityCondition;
> -import org.ofbiz.entity.condition.EntityConditionList;
> import org.ofbiz.entity.condition.EntityExpr;
> import org.ofbiz.entity.condition.EntityFunction;
> import org.ofbiz.entity.condition.EntityOperator;
> @@ -264,7 +263,7 @@ public class CheckOutHelper {
> cart.setBillingAccount(billingAccountId, (billingAccountAmt
> != null ? billingAccountAmt: BigDecimal.ZERO));
> // copy the billing account terms as order terms
> try {
> - List<GenericValue> billingAccountTerms =
> delegator.findByAnd("BillingAccountTerm", UtilMisc.toMap("billingAccountId",
> billingAccountId), null, false);
> + List<GenericValue> billingAccountTerms =
> EntityQuery.use(delegator).from("BillingAccountTerm").where("billingAccountId",
> billingAccountId).queryList();
> if (UtilValidate.isNotEmpty(billingAccountTerms)) {
> for (GenericValue billingAccountTerm :
> billingAccountTerms) {
> // the term is not copied if in the cart a term
> of the same type is already set
> @@ -858,8 +857,7 @@ public class CheckOutHelper {
> GenericValue facilityContactMech =
> ContactMechWorker.getFacilityContactMechByPurpose(delegator,
> originFacilityId, UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION"));
> if (facilityContactMech != null) {
> try {
> - shipAddress = delegator.findOne("PostalAddress",
> - UtilMisc.toMap("contactMechId",
> facilityContactMech.getString("contactMechId")), false);
> + shipAddress =
> EntityQuery.use(delegator).from("PostalAddress").where("contactMechId",
> facilityContactMech.getString("contactMechId")).queryOne();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> }
> @@ -932,7 +930,7 @@ public class CheckOutHelper {
>
> List<GenericValue> allPaymentPreferences = null;
> try {
> - allPaymentPreferences =
> delegator.findByAnd("OrderPaymentPreference", UtilMisc.toMap("orderId",
> orderId), null, false);
> + allPaymentPreferences =
> EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId",
> orderId).queryList();
> } catch (GenericEntityException e) {
> throw new GeneralException("Problems getting payment
> preferences", e);
> }
> @@ -1055,7 +1053,9 @@ public class CheckOutHelper {
>
> // set the order and item status to approved
> if (autoApproveOrder) {
> - List<GenericValue> productStorePaymentSettingList =
> delegator.findByAnd("ProductStorePaymentSetting",
> UtilMisc.toMap("productStoreId", productStore.getString("productStoreId"),
> "paymentMethodTypeId", "CREDIT_CARD", "paymentService", "cyberSourceCCAuth"),
> null, false);
> + List<GenericValue> productStorePaymentSettingList =
> EntityQuery.use(delegator).from("ProductStorePaymentSetting")
> + .where("productStoreId",
> productStore.getString("productStoreId"), "paymentMethodTypeId",
> "CREDIT_CARD", "paymentService", "cyberSourceCCAuth")
> + .queryList();
> if (productStorePaymentSettingList.size() > 0) {
> String decision = (String)
> paymentResult.get("authCode");
> if (UtilValidate.isNotEmpty(decision)) {
> @@ -1235,8 +1235,7 @@ public class CheckOutHelper {
> List<GenericValue> blacklistFound = null;
> if (exprs.size() > 0) {
> try {
> - EntityConditionList<EntityExpr> ecl =
> EntityCondition.makeCondition(exprs, EntityOperator.AND);
> - blacklistFound = this.delegator.findList("OrderBlacklist",
> ecl, null, null, null, false);
> + blacklistFound =
> EntityQuery.use(this.delegator).from("OrderBlacklist").where(exprs).queryList();
> } catch (GenericEntityException e) {
> Debug.logError(e, "Problems with OrderBlacklist lookup.",
> module);
> errMsg =
> UtilProperties.getMessage(resource_error,"checkhelper.problems_reading_database",
> (cart != null ? cart.getLocale() : Locale.getDefault()));
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1641045&r1=1641044&r2=1641045&view=diff
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
> (original)
> +++
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
> Sat Nov 22 11:29:46 2014
> @@ -56,9 +56,6 @@ import org.ofbiz.entity.DelegatorFactory
> import org.ofbiz.entity.GenericEntityException;
> import org.ofbiz.entity.GenericPK;
> import org.ofbiz.entity.GenericValue;
> -import org.ofbiz.entity.condition.EntityCondition;
> -import org.ofbiz.entity.condition.EntityExpr;
> -import org.ofbiz.entity.condition.EntityOperator;
> import org.ofbiz.entity.util.EntityQuery;
> import org.ofbiz.entity.util.EntityUtil;
> import org.ofbiz.entity.util.EntityUtilProperties;
> @@ -1739,7 +1736,7 @@ public class ShoppingCart implements Ite
> String orderId = this.getOrderId();
> if (UtilValidate.isNotEmpty(orderId)) {
> try {
> - List<GenericValue> declinedPaymentMethods =
> delegator.findByAnd("OrderPaymentPreference", UtilMisc.toMap("orderId",
> orderId, "statusId", "PAYMENT_DECLINED"), null, false);
> + List<GenericValue> declinedPaymentMethods =
> EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId",
> orderId, "statusId", "PAYMENT_DECLINED").queryList();
> if (!UtilValidate.isEmpty(declinedPaymentMethods)) {
> List<String> paymentMethodIdsToRemove = new
> ArrayList<String>();
> for (GenericValue opp : declinedPaymentMethods) {
> @@ -3472,8 +3469,7 @@ public class ShoppingCart implements Ite
>
> //create a new WorkEffortGoodStandard based on existing one of
> AGGREGATED product .
> //Another approach could be to get WorkEffortGoodStandard of the
> AGGREGATED product while creating production run.
> - List<GenericValue> productionRunTemplates =
> delegator.findByAnd("WorkEffortGoodStandard", UtilMisc.toMap("productId",
> item.getProductId(), "workEffortGoodStdTypeId", "ROU_PROD_TEMPLATE",
> "statusId", "WEGS_CREATED"), null, false);
> - GenericValue productionRunTemplate =
> EntityUtil.getFirst(EntityUtil.filterByDate(productionRunTemplates));
> + GenericValue productionRunTemplate =
> EntityQuery.use(delegator).from("WorkEffortGoodStandard").where("productId",
> item.getProductId(), "workEffortGoodStdTypeId", "ROU_PROD_TEMPLATE",
> "statusId", "WEGS_CREATED").filterByDate().queryFirst();
> if (productionRunTemplate != null) {
> serviceContext.clear();
> serviceContext.put("workEffortId",
> productionRunTemplate.getString("workEffortId"));
> @@ -4036,9 +4032,11 @@ public class ShoppingCart implements Ite
> String requirementId = item.getRequirementId();
> if (requirementId != null) {
> try {
> - List<GenericValue> commitments =
> getDelegator().findByAnd("OrderRequirementCommitment",
> UtilMisc.toMap("requirementId", requirementId), null, false);
> // TODO: multiple commitments for the same
> requirement are still not supported
> - GenericValue commitment =
> EntityUtil.getFirst(commitments);
> + GenericValue commitment =
> EntityQuery.use(getDelegator())
> +
> .from("OrderRequirementCommitment")
> +
> .where("requirementId", requirementId)
> + .queryFirst();
> if (commitment != null) {
> GenericValue orderItemAssociation =
> getDelegator().makeValue("OrderItemAssoc");
> orderItemAssociation.set("orderId",
> commitment.getString("orderId"));
> @@ -4771,7 +4769,7 @@ public class ShoppingCart implements Ite
> }
>
> try {
> - return delegator.findOne(entityName, lookupFields, true);
> + return
> EntityQuery.use(delegator).from(entityName).where(lookupFields).cache(true).queryOne();
> } catch (GenericEntityException e) {
> Debug.logError(e, module);
> }
> @@ -4786,21 +4784,20 @@ public class ShoppingCart implements Ite
> if ("PaymentMethod".equals(valueObj.getEntityName())) {
> String paymentMethodTypeId =
> valueObj.getString("paymentMethodTypeId");
> String paymentMethodId =
> valueObj.getString("paymentMethodId");
> - Map<String, Object> lookupFields = UtilMisc.<String,
> Object>toMap("paymentMethodId", paymentMethodId);
>
> // billing account, credit card, gift card, eft account all
> have postal address
> try {
> GenericValue pmObj = null;
> if ("CREDIT_CARD".equals(paymentMethodTypeId)) {
> - pmObj = delegator.findOne("CreditCard",
> lookupFields, false);
> + pmObj =
> EntityQuery.use(delegator).from("CreditCard").where("paymentMethodId",
> paymentMethodId).queryOne();
> } else if ("GIFT_CARD".equals(paymentMethodTypeId)) {
> - pmObj = delegator.findOne("GiftCard", lookupFields,
> false);
> + pmObj =
> EntityQuery.use(delegator).from("GiftCard").where("paymentMethodId",
> paymentMethodId).queryOne();
> } else if ("EFT_ACCOUNT".equals(paymentMethodTypeId)) {
> - pmObj = delegator.findOne("EftAccount",
> lookupFields, false);
> + pmObj =
> EntityQuery.use(delegator).from("EftAccount").where("paymentMethodId",
> paymentMethodId).queryOne();
> } else if ("EXT_BILLACT".equals(paymentMethodTypeId)) {
> - pmObj = delegator.findOne("BillingAccount",
> lookupFields, false);
> + pmObj =
> EntityQuery.use(delegator).from("BillingAccount").where("paymentMethodId",
> paymentMethodId).queryOne();
> } else if ("EXT_PAYPAL".equals(paymentMethodTypeId)) {
> - pmObj = delegator.findOne("PayPalPaymentMethod",
> lookupFields, false);
> + pmObj =
> EntityQuery.use(delegator).from("PayPalPaymentMethod").where("paymentMethodId",
> paymentMethodId).queryOne();
> }
> if (pmObj != null) {
> postalAddress = pmObj.getRelatedOne("PostalAddress",
> false);
> @@ -5041,16 +5038,15 @@ public class ShoppingCart implements Ite
> BigDecimal minQuantity = BigDecimal.ZERO;
> BigDecimal minimumOrderPrice = BigDecimal.ZERO;
>
> - List<EntityExpr> exprs = new ArrayList<EntityExpr>();
> - exprs.add(EntityCondition.makeCondition("productId",
> EntityOperator.EQUALS, itemProductId));
> - exprs.add(EntityCondition.makeCondition("productPriceTypeId",
> EntityOperator.EQUALS, "MINIMUM_ORDER_PRICE"));
> -
> - List<GenericValue> minimumOrderPriceList =
> delegator.findList("ProductPrice", EntityCondition.makeCondition(exprs,
> EntityOperator.AND), null, null, null, false);
> - if (minimumOrderPriceList != null) {
> - minimumOrderPriceList =
> EntityUtil.filterByDate(minimumOrderPriceList);
> - }
> + List<GenericValue> minimumOrderPriceList =
> EntityQuery.use(delegator).from("ProductPrice")
> + .where("productId",
> itemProductId, "productPriceTypeId", "MINIMUM_ORDER_PRICE")
> + .filterByDate()
> + .queryList();
> if (itemBasePrice == null) {
> - List<GenericValue> productPriceList =
> EntityUtil.filterByDate(delegator.findList("ProductPrice",
> EntityCondition.makeCondition("productId", itemProductId), null, null, null,
> false));
> + List<GenericValue> productPriceList =
> EntityQuery.use(delegator).from("ProductPrice")
> + .where("productId",
> itemProductId)
> + .filterByDate()
> + .queryList();
> Map<String, BigDecimal> productPriceMap = FastMap.newInstance();
> for (GenericValue productPrice : productPriceList) {
>
> productPriceMap.put(productPrice.getString("productPriceTypeId"),
> productPrice.getBigDecimal("price"));
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=1641045&r1=1641044&r2=1641045&view=diff
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
> (original)
> +++
> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
> Sat Nov 22 11:29:46 2014
> @@ -573,8 +573,7 @@ public class ShoppingCartEvents {
> EntityCondition cond =
> EntityCondition.makeCondition(UtilMisc.toList(
>
> EntityCondition.makeCondition(EntityCondition.makeCondition("productId",
> EntityOperator.EQUALS, productId), EntityOperator.OR,
> EntityCondition.makeCondition("productIdTo", EntityOperator.EQUALS,
> productId)),
>
> EntityCondition.makeCondition("productAssocTypeId", EntityOperator.EQUALS,
> "PRODUCT_INCOMPATABLE")), EntityOperator.AND);
> - productAssocs = delegator.findList("ProductAssoc", cond,
> null, null, null, false);
> - productAssocs = EntityUtil.filterByDate(productAssocs);
> + productAssocs =
> EntityQuery.use(delegator).from("ProductAssoc").where(cond).filterByDate().queryList();
> List<String> productList = FastList.newInstance();
> for (GenericValue productAssoc : productAssocs) {
> if
> (productId.equals(productAssoc.getString("productId"))) {
> @@ -598,10 +597,7 @@ public class ShoppingCartEvents {
> }
> if ("Y".equals(addToCartReplaceUpsell)) {
> List<GenericValue> productList = null;
> - EntityCondition cond =
> EntityCondition.makeCondition(UtilMisc.toList(
> - EntityCondition.makeCondition("productIdTo",
> EntityOperator.EQUALS, productId),
> -
> EntityCondition.makeCondition("productAssocTypeId", EntityOperator.EQUALS,
> "PRODUCT_UPGRADE")), EntityOperator.AND);
> - productList = delegator.findList("ProductAssoc", cond,
> UtilMisc.toSet("productId"), null, null, false);
> + productList =
> EntityQuery.use(delegator).select("productId").from("ProductAssoc").where("productIdTo",
> productId, "productAssocTypeId", "PRODUCT_UPGRADE").queryList();
> if (productList != null) {
> for (ShoppingCartItem sci : cart) {
> if (productList.contains(sci.getProductId())) {
> @@ -1468,7 +1464,7 @@ public class ShoppingCartEvents {
> List<GenericValue> orderAdjustments = new
> ArrayList<GenericValue>();
> orderAdjustments = cart.getAdjustments();
> try {
> - orderAdjustmentList = delegator.findList("OrderAdjustment",
> EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderId),
> null, null, null, false);
> + orderAdjustmentList =
> EntityQuery.use(delegator).from("OrderAdjustment").where("orderId",
> orderId).queryList();
> } catch (Exception e) {
> Debug.logError(e, module);
> }
> @@ -1620,12 +1616,13 @@ public class ShoppingCartEvents {
> // if the user is a rep of the store, then he also
> has permission
> List<GenericValue> storeReps = null;
> try {
> - storeReps =
> delegator.findByAnd("ProductStoreRole", UtilMisc.toMap("productStoreId",
> productStore.getString("productStoreId"),
> - "partyId",
> userLogin.getString("partyId"), "roleTypeId", "SALES_REP"), null, false);
> + storeReps =
> EntityQuery.use(delegator).from("ProductStoreRole")
> + .where("productStoreId",
> productStore.getString("productStoreId"), "partyId",
> userLogin.getString("partyId"), "roleTypeId", "SALES_REP")
> + .filterByDate()
> + .queryList();
> } catch (GenericEntityException gee) {
> //
> }
> - storeReps = EntityUtil.filterByDate(storeReps);
> if (UtilValidate.isNotEmpty(storeReps)) {
> hasPermission = true;
> }
>
>