diff --git a/applications/accounting/groovyScripts/reports/InvoiceAcctgTransEntryParameters.groovy b/applications/accounting/groovyScripts/reports/InvoiceAcctgTransEntryParameters.groovy index acd1e4d296..88a5085313 100644 --- a/applications/accounting/groovyScripts/reports/InvoiceAcctgTransEntryParameters.groovy +++ b/applications/accounting/groovyScripts/reports/InvoiceAcctgTransEntryParameters.groovy @@ -20,16 +20,15 @@ import org.apache.ofbiz.base.util.UtilMisc import org.apache.ofbiz.entity.condition.EntityCondition import org.apache.ofbiz.entity.condition.EntityOperator -import org.apache.ofbiz.entity.util.EntityUtil invoiceId = parameters.invoiceId userLoginId = userLogin.userLoginId -userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false) -userLoginNameView = delegator.findOne("PartyNameView", UtilMisc.toMap("partyId", userLogin.get("partyId")), false) +userLogin = from("UserLogin").where("userLoginId", userLoginId).queryOne(); +userLoginNameView = from("PartyNameView").where("partyId", userLogin.get("partyId")).queryOne(); userLoginName = userLoginNameView.getString("firstName") + " " + userLoginNameView.getString("lastName") dateFormatter = new java.text.SimpleDateFormat("dd MMMMM yyyy") -invoice = delegator.findOne("Invoice", UtilMisc.toMap("invoiceId", invoiceId), false) +invoice = from("Invoice").where("invoiceId", invoiceId).queryOne(); if (invoice) { context.invoiceDescription = invoice.get("description") context.invoiceTypeDescription = invoice.getRelatedOne("InvoiceType", false).get("description") @@ -44,7 +43,7 @@ if ("PURCHASE_INVOICE".equals(invoice.get("invoiceTypeId")) || "PURCHASE_INVOICE partyId = invoice.get("partyId") } partyName = "" -partyNameView = delegator.findOne("PartyNameView", UtilMisc.toMap("partyId", partyId), false) +partyNameView = from("PartyNameView").where("partyId", partyId).queryOne(); if (partyNameView.get("firstName")) { partyName += partyNameView.get("firstName") + " " } diff --git a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java index 0d123fe881..6f0ee632eb 100644 --- a/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java +++ b/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java @@ -597,10 +597,10 @@ public class InvoiceServices { to adjust tax amount in invoice item. */ BigDecimal otherInvoiceTaxAmount = BigDecimal.ZERO; - GenericValue orderAdjBilling = EntityUtil.getFirst(delegator.findByAnd("OrderAdjustmentBilling", UtilMisc.toMap("orderAdjustmentId", adj.getString("orderAdjustmentId")), null, false)); + GenericValue orderAdjBilling = EntityQuery.use(delegator).from("OrderAdjustmentBilling").where("orderAdjustmentId", adj.getString("orderAdjustmentId")).queryFirst(); if (UtilValidate.isNotEmpty(orderAdjBilling)) { - List invoiceItems = delegator.findByAnd("InvoiceItem", - UtilMisc.toMap("invoiceId", orderAdjBilling.getString("invoiceId"), "invoiceItemTypeId", "ITM_SALES_TAX", "productId", originalOrderItem.getString("productId")), null, isTaxIncludedInPrice); + //FIXME: Need to check here isTaxIncludedInPrice pass to use cache + List invoiceItems = EntityQuery.use(delegator).from("InvoiceItem").where("invoiceId", orderAdjBilling.getString("invoiceId"), "invoiceItemTypeId", "ITM_SALES_TAX", "productId", originalOrderItem.getString("productId")).cache(isTaxIncludedInPrice).queryList(); for (GenericValue invoiceItem : invoiceItems) { otherInvoiceTaxAmount = otherInvoiceTaxAmount.add(invoiceItem.getBigDecimal("amount")); } diff --git a/applications/accounting/template/finaccounttrans/FinAccountTrans.ftl b/applications/accounting/template/finaccounttrans/FinAccountTrans.ftl index c41ddce48c..3526dc462c 100644 --- a/applications/accounting/template/finaccounttrans/FinAccountTrans.ftl +++ b/applications/accounting/template/finaccounttrans/FinAccountTrans.ftl @@ -95,7 +95,7 @@ function getFinAccountTransRunningTotalAndBalances() { - <#assign glReconciliations = delegator.findByAnd("GlReconciliation", {"glAccountId" : finAccount.postToGlAccountId!, "statusId" : "GLREC_CREATED"}, Static["org.apache.ofbiz.base.util.UtilMisc"].toList("reconciledDate DESC"), false)> + <#assign glReconciliations = EntityQuery.use(delegator).from("GlReconciliation").where("glAccountId", finAccount.postToGlAccountId!, "statusId", "GLREC_CREATED").orderBy("reconciledDate DESC").queryList()!> <#if (glReconciliationId?has_content && ("_NA_" == glReconciliationId && finAccountTransList?has_content)) || !grandTotal??>
<#if grandTotal??> @@ -153,26 +153,26 @@ function getFinAccountTransRunningTotalAndBalances() { <#assign glReconciliation = ""> <#assign partyName = ""> <#if finAccountTrans.paymentId?has_content> - <#assign payment = delegator.findOne("Payment", {"paymentId" : finAccountTrans.paymentId}, true)> + <#assign payment = EntityQuery.use(delegator).from("Payment").where("paymentId", finAccountTrans.paymentId!).cache().queryOne()!> <#else> - <#assign payments = delegator.findByAnd("Payment", {"finAccountTransId" : finAccountTrans.finAccountTransId}, null, false)> + <#assign payments = EntityQuery.use(delegator).from("Payment").where("finAccountTransId", finAccountTrans.finAccountTransId!).queryList()!> - <#assign finAccountTransType = delegator.findOne("FinAccountTransType", {"finAccountTransTypeId" : finAccountTrans.finAccountTransTypeId}, true)> + <#assign finAccountTransType = EntityQuery.use(delegator).from("FinAccountTransType").where("finAccountTransTypeId", finAccountTrans.finAccountTransTypeId!).cache().queryOne()!> <#if finAccountTrans.statusId?has_content> - <#assign status = delegator.findOne("StatusItem", {"statusId" : finAccountTrans.statusId}, true)> + <#assign status = EntityQuery.use(delegator).from("StatusItem").where("statusId", finAccountTrans.statusId!).cache().queryOne()!> <#if payment?has_content && payment.paymentTypeId?has_content> - <#assign paymentType = delegator.findOne("PaymentType", {"paymentTypeId" : payment.paymentTypeId}, true)> + <#assign paymentType = EntityQuery.use(delegator).from("PaymentType").where("paymentTypeId", payment.paymentTypeId!).cache().queryOne()!> <#if payment?has_content && payment.paymentMethodTypeId?has_content> - <#assign paymentMethodType = delegator.findOne("PaymentMethodType", {"paymentMethodTypeId" : payment.paymentMethodTypeId}, true)> + <#assign paymentMethodType = EntityQuery.use(delegator).from("PaymentMethodType").where("paymentMethodTypeId", payment.paymentMethodTypeId!).cache().queryOne()!> <#if finAccountTrans.glReconciliationId?has_content> - <#assign glReconciliation = delegator.findOne("GlReconciliation", {"glReconciliationId" : finAccountTrans.glReconciliationId}, true)> + <#assign glReconciliation = EntityQuery.use(delegator).from("GlReconciliation").where("glReconciliationId", finAccountTrans.glReconciliationId!).cache().queryOne()!> <#if finAccountTrans.partyId?has_content> - <#assign partyName = (delegator.findOne("PartyNameView", {"partyId" : finAccountTrans.partyId}, true))!> + <#assign partyName = EntityQuery.use(delegator).from("PartyNameView").where("partyId", finAccountTrans.partyId!).cache().queryOne()!!> class="alternate-row"> @@ -191,17 +191,17 @@ function getFinAccountTransRunningTotalAndBalances() { <#list payments as payment> <#if payment?? && payment.paymentTypeId?has_content> - <#assign paymentType = delegator.findOne("PaymentType", {"paymentTypeId" : payment.paymentTypeId}, true)> + <#assign paymentType = EntityQuery.use(delegator).from("PaymentType").where("paymentTypeId", payment.paymentTypeId!).cache().queryOne()!> <#if payment?has_content && payment.paymentMethodTypeId?has_content> - <#assign paymentMethodType = delegator.findOne("PaymentMethodType", {"paymentMethodTypeId" : payment.paymentMethodTypeId}, true)> + <#assign paymentMethodType = EntityQuery.use(delegator).from("PaymentMethodType").where("paymentMethodTypeId", payment.paymentMethodTypeId!).cache().queryOne()!> <#if payment?has_content> <#assign paymentGroupMembers = Static["org.apache.ofbiz.entity.util.EntityUtil"].filterByDate(payment.getRelated("PaymentGroupMember", null, null, false)!) /> <#assign fromParty = payment.getRelatedOne("FromParty", false)! /> - <#assign fromPartyName = delegator.findOne("PartyNameView", {"partyId" : fromParty.partyId}, true) /> + <#assign fromPartyName = EntityQuery.use(delegator).from("PartyNameView").where("partyId", fromParty.partyId!).cache().queryOne()!/> <#assign toParty = payment.getRelatedOne("ToParty", false)! /> - <#assign toPartyName = delegator.findOne("PartyNameView", {"partyId" : toParty.partyId}, true) /> + <#assign toPartyName =EntityQuery.use(delegator).from("PartyNameView").where("partyId", toParty.partyId!).cache().queryOne()!/> <#if paymentGroupMembers?has_content> <#assign paymentGroupMember = Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(paymentGroupMembers) /> diff --git a/applications/accounting/template/finaccounttrans/GlReconciledFinAccountTrans.ftl b/applications/accounting/template/finaccounttrans/GlReconciledFinAccountTrans.ftl index 509269bd82..521e5221ba 100644 --- a/applications/accounting/template/finaccounttrans/GlReconciledFinAccountTrans.ftl +++ b/applications/accounting/template/finaccounttrans/GlReconciledFinAccountTrans.ftl @@ -30,7 +30,7 @@ under the License.
${uiLabelMap.CommonEdit} - <#assign finAcctTransCondList = delegator.findByAnd("FinAccountTrans", {"glReconciliationId" : glReconciliationId, "statusId" : "FINACT_TRNS_CREATED"}, null, false)> + <#assign finAcctTransCondList = EntityQuery.use(delegator).from("FinAccountTrans").where("glReconciliationId", glReconciliationId!, "statusId", "FINACT_TRNS_CREATED").queryList()!> <#if finAcctTransCondList?has_content> ${uiLabelMap.AccountingCancelBankReconciliation} @@ -152,20 +152,20 @@ under the License. <#assign paymentMethodType = ""> <#assign partyName = ""> <#if finAccountTrans.paymentId?has_content> - <#assign payment = delegator.findOne("Payment", {"paymentId" : finAccountTrans.paymentId}, true)> + <#assign payment = EntityQuery.use(delegator).from("Payment").where("paymentId", finAccountTrans.paymentId!).cache().queryOne()!> - <#assign finAccountTransType = delegator.findOne("FinAccountTransType", {"finAccountTransTypeId" : finAccountTrans.finAccountTransTypeId}, true)> + <#assign finAccountTransType = EntityQuery.use(delegator).from("FinAccountTransType").where("finAccountTransTypeId", finAccountTrans.finAccountTransTypeId!).cache().queryOne()!> <#if finAccountTrans.statusId?has_content> - <#assign status = delegator.findOne("StatusItem", {"statusId" : finAccountTrans.statusId}, true)> + <#assign status = EntityQuery.use(delegator).from("StatusItem").where("statusId", finAccountTrans.statusId!).cache().queryOne()!> <#if payment?has_content && payment.paymentTypeId?has_content> - <#assign paymentType = delegator.findOne("PaymentType", {"paymentTypeId" : payment.paymentTypeId}, true)> + <#assign paymentType = EntityQuery.use(delegator).from("PaymentType").where("paymentTypeId", payment.paymentTypeId!).cache().queryOne()!> <#if payment?has_content && payment.paymentMethodTypeId?has_content> - <#assign paymentMethodType = delegator.findOne("PaymentMethodType", {"paymentMethodTypeId" : payment.paymentMethodTypeId}, true)> + <#assign paymentMethodType = EntityQuery.use(delegator).from("PaymentMethodType").where("paymentMethodTypeId", payment.paymentMethodTypeId!).cache().queryOne()!> <#if finAccountTrans.partyId?has_content> - <#assign partyName = (delegator.findOne("PartyNameView", {"partyId" : finAccountTrans.partyId}, true))> + <#assign partyName = EntityQuery.use(delegator).from("PartyNameView").where("partyId", finAccountTrans.partyId!).cache().queryOne()!> class="alternate-row"> diff --git a/applications/accounting/template/finaccounttrans/ShowGlTransactions.ftl b/applications/accounting/template/finaccounttrans/ShowGlTransactions.ftl index cc4ddb61ea..df07d7f0fd 100644 --- a/applications/accounting/template/finaccounttrans/ShowGlTransactions.ftl +++ b/applications/accounting/template/finaccounttrans/ShowGlTransactions.ftl @@ -53,13 +53,13 @@ under the License. ${acctgTransEntry.isPosted!} <#if acctgTransEntry.glFiscalTypeId?has_content> - <#assign glFiscalType = delegator.findOne("GlFiscalType", {"glFiscalTypeId" : acctgTransEntry.glFiscalTypeId}, false)/> + <#assign glFiscalType = EntityQuery.use(delegator).from("GlFiscalType").where("glFiscalTypeId", acctgTransEntry.glFiscalTypeId!).queryOne()!/> ${glFiscalType.description!} <#if acctgTransEntry.acctgTransTypeId?has_content> - <#assign acctgTransType = delegator.findOne("AcctgTransType", {"acctgTransTypeId" : acctgTransEntry.acctgTransTypeId}, false)/> + <#assign acctgTransType = EntityQuery.use(delegator).from("AcctgTransType").where("acctgTransTypeId", acctgTransEntry.acctgTransTypeId!).queryOne()!/> ${acctgTransType.description!} @@ -75,7 +75,7 @@ under the License. ${acctgTransEntry.origAmount!} <#if acctgTransEntry.organizationPartyId?has_content> - <#assign partyName = delegator.findOne("PartyNameView", {"partyId" : acctgTransEntry.organizationPartyId}, false)> + <#assign partyName = EntityQuery.use(delegator).from("PartyNameView").where("partyId", acctgTransEntry.organizationPartyId!).queryOne()!> <#if "PERSON" == partyName.partyTypeId> ${partyName.firstName!} ${partyName.lastName!} <#elseif (partyName.partyTypeId) != "PARTY_GROUP"> @@ -85,7 +85,7 @@ under the License. <#if (acctgTransEntry.glAccountTypeId)?has_content> - <#assign glAccountType = delegator.findOne("GlAccountType", {"glAccountTypeId" : acctgTransEntry.glAccountTypeId}, false)> + <#assign glAccountType = EntityQuery.use(delegator).from("GlAccountType").where("glAccountTypeId", acctgTransEntry.glAccountTypeId!).queryOne()!> ${glAccountType.description!} @@ -93,20 +93,20 @@ under the License. ${acctgTransEntry.accountName!} <#if acctgTransEntry.glAccountClassId?has_content> - <#assign glAccountClass = delegator.findOne("GlAccountClass", {"glAccountClassId" : acctgTransEntry.glAccountClassId}, false)/> + <#assign glAccountClass = EntityQuery.use(delegator).from("GlAccountClass").where("glAccountClassId", acctgTransEntry.glAccountClassId!).queryOne()!/> ${glAccountClass.description!} ${acctgTransEntry.partyId!} <#if acctgTransEntry.reconcileStatusId?has_content> - <#assign status = delegator.findOne("StatusItem", {"statusId" : finAccountTrans.statusId}, true)> + <#assign status =EntityQuery.use(delegator).from("StatusItem").where("statusId", finAccountTrans.statusId!).cache().queryOne()!> ${status.description!} <#if acctgTransEntry.acctgTransEntryTypeId?has_content> - <#assign acctgTransEntryType = delegator.findOne("AcctgTransEntryType", {"acctgTransEntryTypeId" : acctgTransEntry.acctgTransEntryTypeId}, true)> + <#assign acctgTransEntryType = EntityQuery.use(delegator).from("AcctgTransEntryType").where("acctgTransEntryTypeId", acctgTransEntry.acctgTransEntryTypeId!).cache().queryOne()!> ${acctgTransEntryType.description!} diff --git a/applications/commonext/groovyScripts/ofbizsetup/FindFacility.groovy b/applications/commonext/groovyScripts/ofbizsetup/FindFacility.groovy index dbb97554df..08bffe5c1b 100644 --- a/applications/commonext/groovyScripts/ofbizsetup/FindFacility.groovy +++ b/applications/commonext/groovyScripts/ofbizsetup/FindFacility.groovy @@ -18,7 +18,7 @@ */ import org.apache.ofbiz.entity.util.EntityUtil -findResult = delegator.findByAnd("Facility", [ownerPartyId: partyId], null, false) +findResult = from("Facility").where("ownerPartyId", partyId).queryList(); findResultSize = findResult.size() if (findResultSize == 1) { context.showScreen = "one" @@ -32,7 +32,7 @@ if ((findResultSize > 1 ) && (findResultSize <= 10)) { context.showScreen = "more" } -listPartyPostalAddress = delegator.findByAnd("PartyAndPostalAddress", [partyId: partyId], null, false) +listPartyPostalAddress = from("PartyAndPostalAddress").where("partyId", partyId).queryList(); partyPostalAddress = EntityUtil.getFirst(EntityUtil.filterByDate(listPartyPostalAddress)) context.partyPostalAddress = partyPostalAddress @@ -49,7 +49,7 @@ if("productstore".equals(tabButtonItemTop)){ if (!facilityId && request.getAttribute("facilityId")) { facilityId = request.getAttribute("facilityId") } - facility = delegator.findOne("Facility", [facilityId : facilityId], false) + facility = from("Facility").where("facilityId", facilityId).queryOne(); if(facility){ facilityType = facility.getRelatedOne("FacilityType", false) context.facilityType = facilityType diff --git a/applications/commonext/groovyScripts/ofbizsetup/GetProdCatalog.groovy b/applications/commonext/groovyScripts/ofbizsetup/GetProdCatalog.groovy index 9a595aff69..c155d2debd 100644 --- a/applications/commonext/groovyScripts/ofbizsetup/GetProdCatalog.groovy +++ b/applications/commonext/groovyScripts/ofbizsetup/GetProdCatalog.groovy @@ -25,7 +25,7 @@ showScreen = "origin" List errMsgList = [] - productStore = EntityUtil.getFirst(delegator.findByAnd("ProductStore", [payToPartyId: partyId], null, false)) + productStore = from("ProductStore").where("payToPartyId", partyId).queryFirst(); if(productStore){ context.productStoreId = productStore.productStoreId } @@ -33,8 +33,8 @@ errMsgList.add("Product Store not set!") showScreen = "message" } else { - facility = delegator.findOne("Facility", [facilityId : productStore.inventoryFacilityId], false) - webSite = EntityUtil.getFirst(delegator.findByAnd("WebSite", [productStoreId: productStore.productStoreId], null, false)) + facility =from("Facility").where("facilityId", productStore.inventoryFacilityId).queryOne(); + webSite = from("WebSite").where("productStoreId", productStore.productStoreId).queryFirst(); if(UtilValidate.isEmpty(facility)){ errMsgList.add("Facility not set!") @@ -50,7 +50,7 @@ return } - productStoreCatalog = EntityUtil.getFirst(delegator.findByAnd("ProductStoreCatalog", [productStoreId: productStore.productStoreId], null, false)) + productStoreCatalog = from("ProductStoreCatalog").where("productStoreId", productStore.productStoreId).queryFirst(); if(productStoreCatalog){ prodCatalog = productStoreCatalog.getRelatedOne("ProdCatalog", false) prodCatalogId = prodCatalog.prodCatalogId @@ -69,9 +69,9 @@ showErrorMsg = "Y" } - prodCatalogCategory = EntityUtil.getFirst(delegator.findByAnd("ProdCatalogCategory", [prodCatalogId: prodCatalogId, sequenceNum: new Long(1)], null, false)) + prodCatalogCategory = from("ProdCatalogCategory").where("prodCatalogId", prodCatalogId, "sequenceNum", new Long(1)).queryFirst(); if(prodCatalogCategory){ - productCategory = EntityUtil.getFirst(delegator.findByAnd("ProductCategory", [primaryParentCategoryId : prodCatalogCategory.productCategoryId], null, false)) + productCategory = from("ProductCategory").where("primaryParentCategoryId", prodCatalogCategory.productCategoryId).queryFirst(); if(productCategory){ productCategoryId = productCategory.productCategoryId } @@ -88,12 +88,12 @@ showErrorMsg = "Y" } /**************** get product from ProductCategory ******************/ - productCategoryMember = EntityUtil.getFirst(delegator.findByAnd("ProductCategoryMember", [productCategoryId: productCategoryId], null, false)) + productCategoryMember = from("ProductCategoryMember").where("productCategoryId", productCategoryId).queryFirst(); if(productCategoryMember){ product = productCategoryMember.getRelatedOne("Product", false) productId = product.productId // Average cost - averageCostValues = delegator.findByAnd("ProductPrice", [productId : productId, productPricePurposeId : "PURCHASE", productPriceTypeId : "AVERAGE_COST"], null, false) + averageCostValues = from("ProductPrice").where("productId", productId, "productPricePurposeId", "PURCHASE", "productPriceTypeId", "AVERAGE_COST").queryList() if(averageCostValues){ averageCostValue = EntityUtil.getFirst(EntityUtil.filterByDate(averageCostValues)) if (averageCostValue?.price != null) { @@ -101,7 +101,7 @@ } } // Default cost - defaultPriceValues = delegator.findByAnd("ProductPrice", [productId : productId, productPricePurposeId : "PURCHASE", productPriceTypeId : "DEFAULT_PRICE"], null, false) + defaultPriceValues = from("ProductPrice").where("productId", productId, "productPricePurposeId", "PURCHASE", "productPriceTypeId", "DEFAULT_PRICE").queryList(); if(defaultPriceValues){ defaultPrice = EntityUtil.getFirst(EntityUtil.filterByDate(defaultPriceValues)) if (defaultPrice?.price != null) { diff --git a/applications/commonext/groovyScripts/ofbizsetup/GetProductStoreAndWebSite.groovy b/applications/commonext/groovyScripts/ofbizsetup/GetProductStoreAndWebSite.groovy index d40e57b3a9..0a15c7db97 100644 --- a/applications/commonext/groovyScripts/ofbizsetup/GetProductStoreAndWebSite.groovy +++ b/applications/commonext/groovyScripts/ofbizsetup/GetProductStoreAndWebSite.groovy @@ -20,7 +20,7 @@ productStoreId = null -productStore = EntityUtil.getFirst(delegator.findByAnd("ProductStore", [payToPartyId: partyId], null, false)) +productStore = from("ProductStore").where("payToPartyId", partyId).queryFirst(); if(productStore){ productStoreId = productStore.productStoreId } @@ -29,7 +29,7 @@ context.productStore = productStore if("website".equals(tabButtonItemTop)){ if(productStoreId != null){ - webSite = EntityUtil.getFirst(delegator.findByAnd("WebSite", [productStoreId: productStoreId], null, false)) + webSite = from("WebSite").where("productStoreId", productStoreId).queryFirst(); context.showScreen = "origin" }else{ request.setAttribute("_ERROR_MESSAGE_", "Product Store not set!") diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java index bb2f7e1134..a8b0e0d585 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java @@ -44,6 +44,7 @@ import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.condition.EntityCondition; import org.apache.ofbiz.entity.transaction.TransactionUtil; import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityQuery; public class ContentJsonEvents { @@ -103,7 +104,7 @@ public class ContentJsonEvents { GenericValue assoc = TransactionUtil.inTransaction(new Callable() { @Override public GenericValue call() throws Exception { - GenericValue oldAssoc = delegator.findOne("ContentAssoc", UtilMisc.toMap("contentIdTo", contentIdTo, "contentId", contentIdFrom, "contentAssocTypeId", contentAssocTypeId, "fromDate", fromDate), false); + GenericValue oldAssoc = EntityQuery.use(delegator).from("ContentAssoc").where("contentIdTo", contentIdTo, "contentId", contentIdFrom, "contentAssocTypeId", contentAssocTypeId, "fromDate", fromDate).queryOne(); if (oldAssoc == null) { throw new GenericEntityNotFoundException("Could not find ContentAssoc by primary key [contentIdTo: $contentIdTo, contentId: $contentIdFrom, contentAssocTypeId: $contentAssocTypeId, fromDate: $fromDate]"); } diff --git a/applications/content/template/content/ContentNav.ftl b/applications/content/template/content/ContentNav.ftl index 868888f5d8..b625b8b88c 100644 --- a/applications/content/template/content/ContentNav.ftl +++ b/applications/content/template/content/ContentNav.ftl @@ -37,7 +37,7 @@ var rawdata = [ <#assign content = delegator.findOne("Content",Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("contentId",assoc.contentIdTo), false)/> { "data": {"title" : unescapeHtmlText("${content.contentName!assoc.contentIdTo}"), "attr": {"href": "javascript:void(0);", "onClick" : "callDocument('${assoc.contentIdTo}');"}}, - <#assign assocChilds = delegator.findByAnd("ContentAssoc",Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("contentId",assoc.contentIdTo,"contentAssocTypeId", "TREE_CHILD"), null, false)/> + <#assign assocChilds = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", assoc.contentIdTo!, "contentAssocTypeId", "TREE_CHILD").queryList()!/> "attr": {"id" : "${assoc.contentIdTo}", "contentId" : "${assoc.contentId}", "AssocType" : "${assoc.contentAssocTypeId}", "fromDate" : "${assoc.fromDate}"} <#if assocChilds?has_content> ,"children": [ diff --git a/applications/content/template/content/DisplayContentNav.ftl b/applications/content/template/content/DisplayContentNav.ftl index 70d7cc7d87..e70c634e84 100644 --- a/applications/content/template/content/DisplayContentNav.ftl +++ b/applications/content/template/content/DisplayContentNav.ftl @@ -42,7 +42,7 @@ var rawdata = [ { "data": {"title" : unescapeHtmlText("${content.contentName!assoc.contentIdTo}"), "attr": {"href": "javascript:void(0);", "onClick" : "callDocument('${assoc.contentIdTo}');"}}, - <#assign assocChilds = delegator.findByAnd("ContentAssoc",Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("contentId",assoc.contentIdTo,"contentAssocTypeId", "TREE_CHILD"), Static["org.apache.ofbiz.base.util.UtilMisc"].toList("sequenceNum"), false)/> + <#assign assocChilds = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", assoc.contentIdTo!, "contentAssocTypeId", "TREE_CHILD").orderBy("sequenceNum").queryList()!/> "attr": {"id" : "${assoc.contentIdTo}", "contentId" : "${assoc.contentId}", "AssocType" : "${assoc.contentAssocTypeId}", "fromDate" : "${assoc.fromDate}"} <#if assocChilds?has_content> ,"children": [ diff --git a/applications/manufacturing/groovyScripts/bom/FindProductBom.groovy b/applications/manufacturing/groovyScripts/bom/FindProductBom.groovy index 8a86c316bd..8b455c0e17 100644 --- a/applications/manufacturing/groovyScripts/bom/FindProductBom.groovy +++ b/applications/manufacturing/groovyScripts/bom/FindProductBom.groovy @@ -17,7 +17,6 @@ * under the License. */ -import org.apache.ofbiz.entity.util.EntityQuery import org.apache.ofbiz.entity.condition.EntityCondition import org.apache.ofbiz.entity.condition.EntityOperator diff --git a/applications/manufacturing/groovyScripts/jobshopmgt/ShowProductionRun.groovy b/applications/manufacturing/groovyScripts/jobshopmgt/ShowProductionRun.groovy index bf7c8ecacd..df72629c8a 100644 --- a/applications/manufacturing/groovyScripts/jobshopmgt/ShowProductionRun.groovy +++ b/applications/manufacturing/groovyScripts/jobshopmgt/ShowProductionRun.groovy @@ -31,11 +31,11 @@ if (UtilValidate.isEmpty(productionRunId)) { } if (UtilValidate.isNotEmpty(productionRunId)) { - GenericValue productionRun = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", productionRunId), false) + GenericValue productionRun = from("WorkEffort").where("workEffortId", productionRunId).queryOne(); if (UtilValidate.isNotEmpty(productionRun)) { // If this is a task, get the parent production run if (productionRun.getString("workEffortTypeId") != null && "PROD_ORDER_TASK".equals(productionRun.getString("workEffortTypeId"))) { - productionRun = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", productionRun.getString("workEffortParentId")), false) + productionRun = from("WorkEffort").where("workEffortId", productionRun.getString("workEffortParentId")).queryOne(); } } diff --git a/applications/manufacturing/groovyScripts/reports/CuttingListReport.groovy b/applications/manufacturing/groovyScripts/reports/CuttingListReport.groovy index 236fb46320..14164f6246 100644 --- a/applications/manufacturing/groovyScripts/reports/CuttingListReport.groovy +++ b/applications/manufacturing/groovyScripts/reports/CuttingListReport.groovy @@ -37,7 +37,7 @@ selectPrimaryCategoryIdParameter = "CABINETS" // struttura shipmentId = request.getParameter("shipmentId") context.shipmentId = shipmentId -shipment = delegator.findOne("Shipment", [shipmentId : shipmentId], false) +shipment = from("Shipment").where("shipmentId", shipmentId).queryOne(); context.shipment = shipment // dimensionsByFeatureMap [key=feature; value=productsByShapeMap] diff --git a/applications/manufacturing/template/mrp/FindInventoryEventPlan.ftl b/applications/manufacturing/template/mrp/FindInventoryEventPlan.ftl index dd81f39001..9396664929 100644 --- a/applications/manufacturing/template/mrp/FindInventoryEventPlan.ftl +++ b/applications/manufacturing/template/mrp/FindInventoryEventPlan.ftl @@ -152,8 +152,8 @@ document.lookupinventory.productId.focus(); <#if !(product == productTmp)> <#assign quantityAvailableAtDate = 0> - <#assign errorEvents = delegator.findByAnd("MrpEvent", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("mrpEventTypeId", "ERROR", "productId", inven.productId), null, false)> - <#assign qohEvents = delegator.findByAnd("MrpEvent", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("mrpEventTypeId", "INITIAL_QOH", "productId", inven.productId), null, false)> + <#assign errorEvents = EntityQuery.use(delegator).from("MrpEvent").where("mrpEventTypeId", "ERROR", "productId", inven.productId!).queryList()!> + <#assign qohEvents = EntityQuery.use(delegator).from("MrpEvent").where("mrpEventTypeId", "INITIAL_QOH", "productId", inven.productId!).queryList()!> <#assign additionalErrorMessage = ""> <#assign initialQohEvent = ""> <#assign productFacility = ""> diff --git a/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy b/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy index c4111b4183..2137ac44b0 100644 --- a/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy +++ b/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy @@ -24,7 +24,6 @@ import org.apache.ofbiz.base.util.UtilMisc import org.apache.ofbiz.base.util.UtilProperties -import org.apache.ofbiz.entity.util.EntityQuery import org.apache.ofbiz.product.product.ProductContentWrapper import org.apache.ofbiz.product.config.ProductConfigWorker import org.apache.ofbiz.product.catalog.CatalogWorker @@ -53,7 +52,7 @@ if (cart.isSalesOrder()) { } if (!facilityId) { - productStoreFacility = EntityQuery.use(delegator).select("facilityId").from("ProductStoreFacility").where("productStoreId", productStoreId).queryFirst() + productStoreFacility = select("facilityId").from("ProductStoreFacility").where("productStoreId", productStoreId).queryFirst() if (productStoreFacility) { facilityId = productStoreFacility.facilityId } diff --git a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java index fb2a52c7e7..885d54c41d 100644 --- a/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java +++ b/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java @@ -4956,7 +4956,7 @@ public class OrderServices { // This ship group is a drop shipment: we create a purchase order for it String supplierPartyId = shipGroup.getString("supplierPartyId"); // Set supplier preferred currency for drop-ship (PO) order to support multi currency - GenericValue supplierParty = delegator.findOne("Party", UtilMisc.toMap("partyId", supplierPartyId), false); + GenericValue supplierParty = EntityQuery.use(delegator).from("Party").where("partyId", supplierPartyId).queryOne(); String currencyUomId = supplierParty.getString("preferredCurrencyUomId"); // If supplier currency not found then set currency of sales order if (UtilValidate.isEmpty(currencyUomId)) { @@ -6378,8 +6378,8 @@ public class OrderServices { String newShipMethTypeDesc =null; String shipMethTypeDesc=null; try { - shipMethTypeDesc = delegator.findOne("ShipmentMethodType", UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId), false).getString("description"); - newShipMethTypeDesc = delegator.findOne("ShipmentMethodType", UtilMisc.toMap("shipmentMethodTypeId", shippingMethods.get(0).getString("shipmentMethodTypeId")), false).getString("description"); + shipMethTypeDesc = EntityQuery.use(delegator).from("ShipmentMethodType").where("shipmentMethodTypeId", shipmentMethodTypeId).queryOne().getString("description"); + newShipMethTypeDesc = EntityQuery.use(delegator).from("ShipmentMethodType").where("shipmentMethodTypeId", shippingMethods.get(0).getString("shipmentMethodTypeId")).queryOne().getString("description"); } catch(GenericEntityException e) { Debug.logError(e, module); } diff --git a/applications/order/template/order/EditOrderItems.ftl b/applications/order/template/order/EditOrderItems.ftl index f0ade99f46..6e0240dc76 100644 --- a/applications/order/template/order/EditOrderItems.ftl +++ b/applications/order/template/order/EditOrderItems.ftl @@ -137,7 +137,7 @@ under the License. <#assign shippedQuantity = orderReadHelper.getItemShippedQuantity(orderItem)> - <#assign shipmentReceipts = delegator.findByAnd("ShipmentReceipt", {"orderId" : orderHeader.getString("orderId"), "orderItemSeqId" : orderItem.orderItemSeqId}, null, false)/> + <#assign shipmentReceipts = EntityQuery.use(delegator).from("ShipmentReceipt").where("orderId", orderHeader.getString("orderId")!, "orderItemSeqId", orderItem.orderItemSeqId!).queryList()!/> <#assign totalReceived = 0.0> <#if shipmentReceipts?? && shipmentReceipts?has_content> <#list shipmentReceipts as shipmentReceipt> @@ -302,7 +302,7 @@ under the License. <#assign productPromoCodeId = ''> <#if "PROMOTION_ADJUSTMENT" == adjustmentType.get("orderAdjustmentTypeId") && orderHeaderAdjustment.get("productPromoId")?has_content> <#assign productPromo = orderHeaderAdjustment.getRelatedOne("ProductPromo", false)> - <#assign productPromoCodes = delegator.findByAnd("ProductPromoCode", {"productPromoId":productPromo.productPromoId}, null, false)> + <#assign productPromoCodes = EntityQuery.use(delegator).from("ProductPromoCode").where("productPromoId", productPromo.productPromoId!).queryList()!> <#assign orderProductPromoCode = ''> <#list productPromoCodes as productPromoCode> <#if !(orderProductPromoCode?has_content)> diff --git a/applications/order/template/order/OrderItems.ftl b/applications/order/template/order/OrderItems.ftl index c371674bfb..425a27f691 100644 --- a/applications/order/template/order/OrderItems.ftl +++ b/applications/order/template/order/OrderItems.ftl @@ -81,13 +81,7 @@ under the License.
- <#assign downloadContents = delegator.findByAnd("OrderItemAndProductContentInfo", { - "orderId" : orderItem.orderId, - "orderItemSeqId" : orderItem.orderItemSeqId, - "productContentTypeId" : "DIGITAL_DOWNLOAD", - "statusId" : "ITEM_COMPLETED"}, - null, - false)/> + <#assign downloadContents = EntityQuery.use(delegator).from("OrderItemAndProductContentInfo").where( "orderId", orderItem.orderId!, "orderItemSeqId", orderItem.orderItemSeqId!, "productContentTypeId", "DIGITAL_DOWNLOAD", "statusId", "ITEM_COMPLETED").queryList()!/> <#if downloadContents?has_content> <#list downloadContents as downloadContent> ${uiLabelMap.ContentDownload}  @@ -228,7 +222,7 @@ under the License. <#assign shippedQuantity = orderReadHelper.getItemShippedQuantity(orderItem)> - <#assign shipmentReceipts = delegator.findByAnd("ShipmentReceipt", {"orderId" : orderHeader.getString("orderId"), "orderItemSeqId" : orderItem.orderItemSeqId}, null, false)/> + <#assign shipmentReceipts = EntityQuery.use(delegator).from("ShipmentReceipt").where("orderId", orderHeader.getString("orderId")!, "orderItemSeqId", orderItem.orderItemSeqId!).queryList()!/> <#assign totalReceived = 0.0> <#if shipmentReceipts?? && shipmentReceipts?has_content> <#list shipmentReceipts as shipmentReceipt> @@ -358,8 +352,8 @@ under the License. <#-- show linked order lines --> - <#assign linkedOrderItemsTo = delegator.findByAnd("OrderItemAssoc", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("orderId", orderItem.getString("orderId"), "orderItemSeqId", orderItem.getString("orderItemSeqId")), null, false)> - <#assign linkedOrderItemsFrom = delegator.findByAnd("OrderItemAssoc", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("toOrderId", orderItem.getString("orderId"), "toOrderItemSeqId", orderItem.getString("orderItemSeqId")), null, false)> + <#assign linkedOrderItemsTo = EntityQuery.use(delegator).from("OrderItemAssoc").where("orderId", orderItem.getString("orderId"), "orderItemSeqId", orderItem.getString("orderItemSeqId")).queryList()!> + <#assign linkedOrderItemsFrom = EntityQuery.use(delegator).from("OrderItemAssoc").where("toOrderId", orderItem.getString("orderId")!, "toOrderItemSeqId", orderItem.getString("orderItemSeqId")!).queryList()!> <#if linkedOrderItemsTo?has_content> <#list linkedOrderItemsTo as linkedOrderItem> <#assign linkedOrderId = linkedOrderItem.toOrderId> diff --git a/applications/order/template/order/OrderShippingInfo.ftl b/applications/order/template/order/OrderShippingInfo.ftl index bb62cfc7cb..a7d0f50b5e 100644 --- a/applications/order/template/order/OrderShippingInfo.ftl +++ b/applications/order/template/order/OrderShippingInfo.ftl @@ -757,7 +757,7 @@ under the License. ${uiLabelMap.CommonNbr}${shipment.shipmentId}   ${uiLabelMap.ProductPackingSlip} <#if "SALES_ORDER" == orderHeader.orderTypeId && "ORDER_COMPLETED" == orderHeader.statusId> - <#assign shipmentRouteSegments = delegator.findByAnd("ShipmentRouteSegment", {"shipmentId" : shipment.shipmentId}, null, false)> + <#assign shipmentRouteSegments = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipment.shipmentId!).queryList()!> <#if shipmentRouteSegments?has_content> <#assign shipmentRouteSegment = Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(shipmentRouteSegments)> <#if "UPS" == (shipmentRouteSegment.carrierPartyId)!> diff --git a/applications/order/template/quote/ViewQuoteItemInfo.ftl b/applications/order/template/quote/ViewQuoteItemInfo.ftl index 249a8cef75..16bb9fe1ab 100644 --- a/applications/order/template/quote/ViewQuoteItemInfo.ftl +++ b/applications/order/template/quote/ViewQuoteItemInfo.ftl @@ -74,7 +74,7 @@ under the License. ${quoteItem.quoteItemSeqId} - <#assign quoteTerms = delegator.findByAnd("QuoteTerm", {"quoteId" : quoteItem.quoteId, "quoteItemSeqId" : quoteItem.quoteItemSeqId}, null, false)> + <#assign quoteTerms = EntityQuery.use(delegator).from("QuoteTerm").where("quoteId", quoteItem.quoteId!, "quoteItemSeqId", quoteItem.quoteItemSeqId!).queryList()!>
diff --git a/applications/order/template/return/ReturnLinks.ftl b/applications/order/template/return/ReturnLinks.ftl index 0044b77d8d..62ca028dcb 100644 --- a/applications/order/template/return/ReturnLinks.ftl +++ b/applications/order/template/return/ReturnLinks.ftl @@ -37,22 +37,22 @@ under the License.
  • PDF
  • <#if returnId??> - <#assign returnItems = delegator.findByAnd("ReturnItem", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("returnId", returnId, "returnTypeId", "RTN_REFUND"), null, false)/> + <#assign returnItems = EntityQuery.use(delegator).from("ReturnItem").where("returnId", returnId!, "returnTypeId", "RTN_REFUND").queryList()!/> <#if returnItems?has_content> <#assign orderId = (Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(returnItems)).getString("orderId")/> <#assign partyId = "${(returnHeader.fromPartyId)!}"/> ${uiLabelMap.OrderCreateExchangeOrder} ${uiLabelMap.CommonFor} ${orderId!} <#if returnHeader.statusId?has_content && "RETURN_ACCEPTED" == returnHeader.statusId> - <#assign returnItems = delegator.findByAnd("ReturnItem", {"returnId" : returnId}, null, false)/> + <#assign returnItems = EntityQuery.use(delegator).from("ReturnItem").where("returnId", returnId!).queryList()!/> <#if returnItems?has_content> <#assign orderId = (Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(returnItems)).getString("orderId")/> - <#assign shipGroupAssoc = Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(delegator.findByAnd("OrderItemShipGroupAssoc", {"orderId" : orderId}, null, false))/> + <#assign shipGroupAssoc = EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId", orderId!).queryFirst()!/> <#assign shipGroup = delegator.findOne("OrderItemShipGroup", {"orderId" : orderId, "shipGroupSeqId" : shipGroupAssoc.shipGroupSeqId}, false)> <#if shipGroup?? && shipGroup.shipmentMethodTypeId != "NO_SHIPPING"> - <#assign shipGroupShipment = Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(delegator.findByAnd("Shipment", {"primaryOrderId" : shipGroup.orderId, "primaryShipGroupSeqId" : shipGroup.shipGroupSeqId}, null, false))/> + <#assign shipGroupShipment = EntityQuery.use(delegator).from("Shipment").where("primaryOrderId", shipGroup.orderId!, "primaryShipGroupSeqId", shipGroup.shipGroupSeqId!).queryFirst()! /> <#if shipGroupShipment??> - <#assign shipmentRouteSegment = Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(delegator.findByAnd("ShipmentRouteSegment", {"shipmentId" : shipGroupShipment.shipmentId}, null, false))!> + <#assign shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipGroupShipment.shipmentId!).queryFirst()!> <#if shipmentRouteSegment??> <#if "UPS" == shipmentRouteSegment.carrierPartyId!>
  • ${uiLabelMap.ProductEmailReturnShippingLabelUPS}
  • diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoCatalogUrlServlet.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoCatalogUrlServlet.java index b9f4c925cf..47362c2f21 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoCatalogUrlServlet.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoCatalogUrlServlet.java @@ -35,6 +35,7 @@ import org.apache.ofbiz.base.util.UtilMisc; import org.apache.ofbiz.base.util.UtilValidate; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericEntityException; +import org.apache.ofbiz.entity.util.EntityQuery; /** * SeoCatalogUrlServlet.java @@ -73,7 +74,7 @@ public class SeoCatalogUrlServlet extends HttpServlet { String productId = null; try { String lastPathElement = pathElements.get(pathElements.size() - 1); - if (lastPathElement.startsWith("p_") || delegator.findOne("Product", UtilMisc.toMap("productId", lastPathElement), true) != null) { + if (lastPathElement.startsWith("p_") || EntityQuery.use(delegator).from("Product").where("productId", lastPathElement).cache().queryOne() != null) { if (lastPathElement.startsWith("p_")) { productId = lastPathElement.substring(2); } else { diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java index 6fa22e6fb8..736b639a89 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContentUrlFilter.java @@ -40,6 +40,7 @@ import org.apache.ofbiz.common.UrlServletHelper; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityQuery; public class SeoContentUrlFilter implements Filter { public final static String module = SeoContentUrlFilter.class.getName(); @@ -64,12 +65,11 @@ public class SeoContentUrlFilter implements Filter { String alternativeUrl = pathInfo.substring(pathInfo.lastIndexOf('/')); if (alternativeUrl.endsWith("-content")) { try { - List contentDataResourceViews = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("drObjectInfo", alternativeUrl), null, false); + List contentDataResourceViews = EntityQuery.use(delegator).from("ContentDataResourceView").where("drObjectInfo", alternativeUrl).queryList(); if (contentDataResourceViews.size() > 0) { contentDataResourceViews = EntityUtil.orderBy(contentDataResourceViews, UtilMisc.toList("createdDate DESC")); GenericValue contentDataResourceView = EntityUtil.getFirst(contentDataResourceViews); - List contents = EntityUtil.filterByDate(delegator.findByAnd("ContentAssoc", - UtilMisc.toMap("contentAssocTypeId", "ALTERNATIVE_URL", "contentIdTo", contentDataResourceView.getString("contentId")), null, false)); + List contents = EntityQuery.use(delegator).from("ContentAssoc").where("contentAssocTypeId", "ALTERNATIVE_URL", "contentIdTo", contentDataResourceView.getString("contentId")).filterByDate().queryList(); if (contents.size() > 0) { GenericValue content = EntityUtil.getFirst(contents); urlContentId = content.getString("contentId"); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogAltUrlSeoTransform.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogAltUrlSeoTransform.java index 6667b5a2e1..eb685cc110 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogAltUrlSeoTransform.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogAltUrlSeoTransform.java @@ -49,6 +49,7 @@ import freemarker.template.SimpleNumber; import freemarker.template.SimpleScalar; import freemarker.template.TemplateModelException; import freemarker.template.TemplateTransformModel; +import org.apache.ofbiz.entity.util.EntityQuery; public class CatalogAltUrlSeoTransform implements TemplateTransformModel { public final static String module = CatalogUrlSeoTransform.class.getName(); @@ -149,7 +150,7 @@ public class CatalogAltUrlSeoTransform implements TemplateTransformModel { contextPath = prefixString.substring(prefixString.lastIndexOf('/')); } if (UtilValidate.isNotEmpty(productId)) { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); ProductContentWrapper wrapper = new ProductContentWrapper(dispatcher, product, locale, EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", delegator)); if (SeoConfigUtil.isCategoryUrlEnabled(contextPath)) { url = CatalogUrlSeoTransform.makeProductUrl(delegator, wrapper, prefixString, contextPath, productCategoryId, previousCategoryId, productId); @@ -157,7 +158,7 @@ public class CatalogAltUrlSeoTransform implements TemplateTransformModel { url = CatalogUrlFilter.makeProductUrl(wrapper, null, prefixString, previousCategoryId, productCategoryId, productId); } } else { - GenericValue productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", productCategoryId), false); + GenericValue productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).queryOne(); CategoryContentWrapper wrapper = new CategoryContentWrapper(dispatcher, productCategory, locale, EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", delegator)); if (SeoConfigUtil.isCategoryUrlEnabled(contextPath)) { url = CatalogUrlSeoTransform.makeCategoryUrl(delegator, wrapper, prefixString, productCategoryId, previousCategoryId, productId, viewSize, viewIndex, viewSort, searchString); diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java index 73a0b67a5f..ff9cc81be2 100644 --- a/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java +++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/ftl/CatalogUrlSeoTransform.java @@ -61,6 +61,7 @@ import freemarker.ext.beans.StringModel; import freemarker.template.SimpleScalar; import freemarker.template.TemplateModelException; import freemarker.template.TemplateTransformModel; +import org.apache.ofbiz.entity.util.EntityQuery; public class CatalogUrlSeoTransform implements TemplateTransformModel { public final static String module = CatalogUrlSeoTransform.class.getName(); @@ -208,7 +209,7 @@ public class CatalogUrlSeoTransform implements TemplateTransformModel { categoryNameId = categoryIdName; } } else { - GenericValue productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", categoryId), true); + GenericValue productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", categoryId).cache().queryOne(); CategoryContentWrapper wrapper = new CategoryContentWrapper(productCategory, request); StringWrapper alternativeUrl = wrapper.get("ALTERNATIVE_URL", "url"); if (UtilValidate.isNotEmpty(alternativeUrl) && UtilValidate.isNotEmpty(alternativeUrl.toString())) { @@ -256,7 +257,7 @@ public class CatalogUrlSeoTransform implements TemplateTransformModel { } if (UtilValidate.isNotEmpty(productId)) { try { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error looking up product info for productId [" + productId + "]: " + e.toString(), module); } @@ -546,7 +547,7 @@ public class CatalogUrlSeoTransform implements TemplateTransformModel { List urlElements = StringUtil.split(lastPathElement, URL_HYPHEN); if (UtilValidate.isEmpty(urlElements)) { try { - if (delegator.findOne("Product", UtilMisc.toMap("productId", lastPathElement), true) != null) { + if (EntityQuery.use(delegator).from("Product").where("productId", lastPathElement).cache().queryOne() != null) { productId = lastPathElement; } } catch (GenericEntityException e) { @@ -688,7 +689,7 @@ public class CatalogUrlSeoTransform implements TemplateTransformModel { } if (UtilValidate.isNotEmpty(productId)) { try { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error looking up product info for productId [" + productId + "]: " + e.toString(), module); } diff --git a/applications/product/template/category/CreateProductInCategoryStart.ftl b/applications/product/template/category/CreateProductInCategoryStart.ftl index 5ca20bc1a8..8e4d4f9f29 100644 --- a/applications/product/template/category/CreateProductInCategoryStart.ftl +++ b/applications/product/template/category/CreateProductInCategoryStart.ftl @@ -67,7 +67,7 @@ under the License.
${uiLabelMap.ProductDefaultPrice}: <#assign findCurrenciesMap = Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("uomTypeId", "CURRENCY_MEASURE")> - <#assign currencies = delegator.findByAnd('Uom', findCurrenciesMap, null, true) /> + <#assign currencies = EntityQuery.use(delegator).from("Uom").where(findCurrenciesMap!).cache().queryList()! /> <#if currencies?has_content && (currencies?size > 0)> - <#assign userLoginApprovers = delegator.findByAnd("UserLogin",Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("partyId", partyRole.partyId), null, false)/> + <#assign userLoginApprovers = EntityQuery.use(delegator).from("UserLogin").where("partyId", partyRole.partyId!).queryList()!/> <#assign userLoginApprover = userLoginApprovers[0]> <#assign userLoginAndPartyDetails = delegator.findOne("UserLoginAndPartyDetails", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("partyId", userLoginApprover.partyId, "userLoginId", userLoginApprover.userLoginId), false)!> <#if userLoginAndPartyDetails?has_content> - <#assign partyContentDetail = delegator.findByAnd("ContentApproval",Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("roleTypeId", "IMAGEAPPROVER", "approvalStatusId", "IM_PENDING", "partyId", userLoginAndPartyDetails.partyId), null, false)/> + <#assign partyContentDetail = EntityQuery.use(delegator).from("ContentApproval").where("roleTypeId", "IMAGEAPPROVER", "approvalStatusId", "IM_PENDING", "partyId", userLoginAndPartyDetails.partyId!).queryList()!/> <#assign imageApproveSize = partyContentDetail.size()> <#if userLoginAndPartyDetails.userLoginId == userLogin.userLoginId> <#if userMap.checkUser == userLoginAndPartyDetails.userLoginId> diff --git a/applications/product/template/product/ViewProductOrders.ftl b/applications/product/template/product/ViewProductOrders.ftl index 47bd4c7973..5329d9ad12 100644 --- a/applications/product/template/product/ViewProductOrders.ftl +++ b/applications/product/template/product/ViewProductOrders.ftl @@ -72,7 +72,7 @@ under the License. <#if orderList?has_content && productId??> <#list orderList as order> - <#assign orderItems = delegator.findByAnd("OrderItem", {"orderId" : order.orderId, "productId" : productId}, null, false)/> + <#assign orderItems = EntityQuery.use(delegator).from("OrderItem").where("orderId", order.orderId!, "productId", productId!).queryList()!/> <#list orderItems as orderItem> diff --git a/applications/product/template/shipment/VerifyPick.ftl b/applications/product/template/shipment/VerifyPick.ftl index 4e4e51fe3d..2a927c146b 100644 --- a/applications/product/template/shipment/VerifyPick.ftl +++ b/applications/product/template/shipment/VerifyPick.ftl @@ -208,10 +208,10 @@ under the License. <#assign readyToVerify = verifyPickSession.getReadyToVerifyQuantity(orderId,orderItemSeqId)> <#assign orderItemQuantity = orderItem.getBigDecimal("quantity")> <#assign verifiedQuantity = 0.000000> - <#assign shipments = delegator.findByAnd("Shipment", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("primaryOrderId", orderItem.getString("orderId"), "statusId", "SHIPMENT_PICKED"), null, false)/> + <#assign shipments = EntityQuery.use(delegator).from("Shipment").where("primaryOrderId", orderItem.getString("orderId")!, "statusId", "SHIPMENT_PICKED").queryList()!/> <#if (shipments?has_content)> <#list shipments as shipment> - <#assign itemIssuances = delegator.findByAnd("ItemIssuance", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("shipmentId", shipment.getString("shipmentId"), "orderItemSeqId", orderItemSeqId), null, false)/> + <#assign itemIssuances = EntityQuery.use(delegator).from("ItemIssuance").where("shipmentId", shipment.getString("shipmentId")!, "orderItemSeqId", orderItemSeqId!).queryList()!/> <#if itemIssuances?has_content> <#list itemIssuances as itemIssuance> <#assign verifiedQuantity = verifiedQuantity + itemIssuance.getBigDecimal("quantity")> @@ -267,7 +267,7 @@ under the License. <#if workOrderItemFulfillment?has_content> <#assign workEffort = workOrderItemFulfillment.getRelatedOne("WorkEffort", false)/> <#if workEffort?has_content> - <#assign workEffortTask = Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(delegator.findByAnd("WorkEffort", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("workEffortParentId", workEffort.workEffortId), null, false))/> + <#assign workEffortTask = EntityQuery.use(delegator).from("WorkEffort").where("workEffortParentId", workEffort.workEffortId!).queryFirst()!/> <#if workEffortTask?has_content> <#assign workEffortInventoryAssigns = workEffortTask.getRelated("WorkEffortInventoryAssign", null, null, false)/> <#if workEffortInventoryAssigns?has_content> diff --git a/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java b/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java index f1b4d4854a..35658266e1 100644 --- a/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java +++ b/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java @@ -127,7 +127,7 @@ public class LoginEvents { String errMsg = null; try { - GenericValue userLoginSecurityQuestion = delegator.findOne("UserLoginSecurityQuestion", UtilMisc.toMap("questionEnumId", questionEnumId, "userLoginId", userLoginId), true); + GenericValue userLoginSecurityQuestion = EntityQuery.use(delegator).from("UserLoginSecurityQuestion").where("questionEnumId", questionEnumId, "userLoginId", userLoginId).cache().queryOne(); if (userLoginSecurityQuestion != null) { if (UtilValidate.isEmpty(securityAnswer)) { errMsg = UtilProperties.getMessage(resource, "loginservices.security_answer_empty", UtilHttp.getLocale(request)); diff --git a/applications/workeffort/groovyScripts/ical/IsCalOwner.groovy b/applications/workeffort/groovyScripts/ical/IsCalOwner.groovy index 6407477c50..01e65e0351 100644 --- a/applications/workeffort/groovyScripts/ical/IsCalOwner.groovy +++ b/applications/workeffort/groovyScripts/ical/IsCalOwner.groovy @@ -21,7 +21,7 @@ import java.util.* import org.apache.ofbiz.entity.util.* boolean isCalOwner = false -List partyAssignments = EntityUtil.filterByDate(delegator.findByAnd("WorkEffortPartyAssignment", ["workEffortId" : parameters.workEffortId, "partyId" : parameters.userLogin.partyId], null, false)) +List partyAssignments = from("WorkEffortPartyAssignment").where("workEffortId", parameters.workEffortId, "partyId", parameters.userLogin.partyId).filterByDate().queryFirst(); for (partyAssign in partyAssignments) { if ("CAL_OWNER".equals(partyAssign.roleTypeId) || "CAL_DELEGATE".equals(partyAssign.roleTypeId)) { isCalOwner = true diff --git a/applications/workeffort/template/calendar/CalendarEventContent.ftl b/applications/workeffort/template/calendar/CalendarEventContent.ftl index c3f1f48002..9526fcc3b1 100644 --- a/applications/workeffort/template/calendar/CalendarEventContent.ftl +++ b/applications/workeffort/template/calendar/CalendarEventContent.ftl @@ -25,7 +25,7 @@ under the License. <#if workOrderItemFulfillments?has_content> <#list workOrderItemFulfillments as workOrderItemFulfillment>
${uiLabelMap.OrderOrderId}: ${workOrderItemFulfillment.orderId} / ${workOrderItemFulfillment.orderItemSeqId} - <#assign orderItemAndShipGroupAssocs = delegator.findByAnd("OrderHeaderItemAndShipGroup", {"orderId", workOrderItemFulfillment.orderId, "orderItemSeqId", workOrderItemFulfillment.orderItemSeqId}, null, false)!/> + <#assign orderItemAndShipGroupAssocs = EntityQuery.use(delegator).from("OrderHeaderItemAndShipGroup").where("orderId", workOrderItemFulfillment.orderId!, "orderItemSeqId", workOrderItemFulfillment.orderItemSeqId!).queryList()!/> <#list orderItemAndShipGroupAssocs as orderItemAndShipGroupAssoc> <#if orderItemAndShipGroupAssoc.shipByDate?has_content> ${uiLabelMap.OrderShipBeforeDate}: ${orderItemAndShipGroupAssoc.shipByDate} @@ -41,7 +41,7 @@ under the License. <#if parentWorkOrderItemFulfillments?has_content> <#list parentWorkOrderItemFulfillments as parentWorkOrderItemFulfillment>
${uiLabelMap.OrderOrderId}: ${parentWorkOrderItemFulfillment.orderId} / ${parentWorkOrderItemFulfillment.orderItemSeqId} - <#assign orderItemAndShipGroupAssocs = delegator.findByAnd("OrderHeaderItemAndShipGroup", {"orderId", parentWorkOrderItemFulfillment.orderId, "orderItemSeqId", parentWorkOrderItemFulfillment.orderItemSeqId}, null, false)!/> + <#assign orderItemAndShipGroupAssocs = EntityQuery.use(delegator).from("OrderHeaderItemAndShipGroup").where("orderId", parentWorkOrderItemFulfillment.orderId!, "orderItemSeqId", parentWorkOrderItemFulfillment.orderItemSeqId!).queryList()!/> <#list orderItemAndShipGroupAssocs as orderItemAndShipGroupAssoc> <#if orderItemAndShipGroupAssoc.shipByDate?has_content> ${uiLabelMap.OrderShipBeforeDate}: ${orderItemAndShipGroupAssoc.shipByDate} diff --git a/framework/common/groovyScripts/GeoLocation.groovy b/framework/common/groovyScripts/GeoLocation.groovy index fb9fa27111..cf113a670a 100644 --- a/framework/common/groovyScripts/GeoLocation.groovy +++ b/framework/common/groovyScripts/GeoLocation.groovy @@ -18,6 +18,6 @@ */ if (geoPoint && geoPoint.elevationUomId) { - elevationUom = delegator.findOne("Uom", [uomId : geoPoint.elevationUomId], false) + elevationUom = from("Uom").where("uomId", geoPoint.elevationUomId).queryList(); context.elevationUomAbbr = elevationUom.abbreviation } diff --git a/framework/common/groovyScripts/GetParentPortalPageId.groovy b/framework/common/groovyScripts/GetParentPortalPageId.groovy index 3784eeb0bf..90d6c1f2cd 100644 --- a/framework/common/groovyScripts/GetParentPortalPageId.groovy +++ b/framework/common/groovyScripts/GetParentPortalPageId.groovy @@ -43,7 +43,7 @@ if (userLogin && parameters.parentPortalPageId && !parameters.portalPageId) { if (portalMainPages) { portalPageId = portalMainPages.get(0).portalPageId // check if overridden with a privat page - privatMainPages = delegator.findByAnd("PortalPage", [originalPortalPageId : portalPageId, ownerUserLoginId : userLogin.userLoginId], null, false) + privatMainPages = from("PortalPage").where("originalPortalPageId", portalPageId, "ownerUserLoginId", userLogin.userLoginId).queryList(); if (privatMainPages) { context.parameters.portalPageId = privatMainPages.get(0).portalPageId } else { @@ -53,7 +53,7 @@ if (userLogin && parameters.parentPortalPageId && !parameters.portalPageId) { } // Debug.log('======portalPageId: ' + parameters.portalPageId) if (userLogin && parameters.portalPageId) { - portalPage = delegator.findOne("PortalPage", [portalPageId : parameters.portalPageId], false) + portalPage = from("PortalPage").where("portalPageId", parameters.portalPageId).queryOne(); if (portalPage) { if (portalPage.parentPortalPageId) { context.parameters.parentPortalPageId = portalPage.parentPortalPageId diff --git a/framework/common/groovyScripts/SetLocaleFromBrowser.groovy b/framework/common/groovyScripts/SetLocaleFromBrowser.groovy index 9c1a18c198..9e0051101f 100644 --- a/framework/common/groovyScripts/SetLocaleFromBrowser.groovy +++ b/framework/common/groovyScripts/SetLocaleFromBrowser.groovy @@ -17,13 +17,11 @@ * under the License. *******************************************************************************/ -import org.apache.ofbiz.entity.util.EntityQuery -import org.apache.ofbiz.service.GenericServiceException import org.apache.ofbiz.service.ServiceUtil public Map setLocaleFromBrowser() { Map results = ServiceUtil.returnSuccess() - userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", parameters.userLogin.userLoginId).queryFirst(); + userLogin = from("UserLogin").where("userLoginId", parameters.userLogin.userLoginId).queryFirst(); if (userLogin) { if (!userLogin.lastTimeZone || "null".equals(userLogin.lastTimeZone)) { userLogin.lastTimeZone = parameters.localeName diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java b/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java index 95d85cffad..787e09d707 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java @@ -33,6 +33,7 @@ import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.util.EntityListIterator; import org.apache.ofbiz.service.ServiceUtil; import org.apache.ofbiz.service.testtools.OFBizTestCase; +import org.apache.ofbiz.entity.util.EntityQuery; public class PerformFindTests extends OFBizTestCase { @@ -54,7 +55,7 @@ public class PerformFindTests extends OFBizTestCase { } private void prepareData() throws Exception { - if (delegator.findOne("TestingType", false, "testingTypeId", "PERFOMFINDTEST") == null) { + if (EntityQuery.use(delegator).from("TestingType").where("testingTypeId", "PERFOMFINDTEST").cache().queryOne() == null) { delegator.create("TestingType", "testingTypeId", "PERFOMFINDTEST"); delegator.create("Testing", "testingId", "PERF_TEST_1", "testingTypeId", "PERFOMFINDTEST", "testingName", "nice name one"); delegator.create("Testing", "testingId", "PERF_TEST_2", "testingTypeId", "PERFOMFINDTEST", "testingName", "nice other name two"); @@ -111,7 +112,7 @@ public class PerformFindTests extends OFBizTestCase { } private void performFindConditionFieldEquals() throws Exception { - GenericValue userLogin = delegator.findOne("UserLogin", true, "userLoginId", "system"); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); prepareData(); Map inputFields = new HashMap(); @@ -148,7 +149,7 @@ public class PerformFindTests extends OFBizTestCase { } private void performFindConditionFieldLike() throws Exception { - GenericValue userLogin = delegator.findOne("UserLogin", true, "userLoginId", "system"); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); prepareData(); //first test like condition @@ -185,7 +186,7 @@ public class PerformFindTests extends OFBizTestCase { } private void performFindConditionDistinct() throws Exception { - GenericValue userLogin = delegator.findOne("UserLogin", true, "userLoginId", "system"); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); prepareData(); //first test without distinct condition @@ -206,7 +207,7 @@ public class PerformFindTests extends OFBizTestCase { } private void performFindFilterByDate() throws Exception { - GenericValue userLogin = delegator.findOne("UserLogin", true, "userLoginId", "system"); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); prepareData(); //first test without filterDate condition @@ -226,7 +227,7 @@ public class PerformFindTests extends OFBizTestCase { } private void performFindFilterByDateWithDedicateDateField() throws Exception { - GenericValue userLogin = delegator.findOne("UserLogin", true, "userLoginId", "system"); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); prepareData(); //first test without filterDate condition diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityQueryTestSuite.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityQueryTestSuite.java index 6b893cb938..5b0f79d323 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityQueryTestSuite.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityQueryTestSuite.java @@ -131,7 +131,7 @@ public class EntityQueryTestSuite extends EntityTestCase { testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryOne-3", "description", "query three")); delegator.storeAll(testingTypes); - GenericValue findOneByEntityEngine = delegator.findOne("TestingType", false, UtilMisc.toMap("testingTypeId", "queryOne-2")); + GenericValue findOneByEntityEngine = EntityQuery.use(delegator).from("TestingType").where("testingTypeId", "queryOne-2").queryOne(); GenericValue queryOneByEntityQuery = EntityQuery.use(delegator).from("TestingType").where("testingTypeId", "queryOne-2").queryOne(); assertEquals("queryOne(): Record matched = testingTypeId", findOneByEntityEngine.getString("testingTypeId"), queryOneByEntityQuery.getString("testingTypeId")); diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaRule.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaRule.java index a1b14f39f6..4abe8dcf8d 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaRule.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaRule.java @@ -34,6 +34,7 @@ import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.service.DispatchContext; import org.w3c.dom.Element; +import org.apache.ofbiz.entity.util.EntityQuery; /** * Entity event-condition-action rule. @@ -135,7 +136,7 @@ public final class EntityEcaRule implements java.io.Serializable { if(!fieldsToLoad.isEmpty()) { Delegator delegator = dctx.getDelegator(); - GenericValue oldValue = delegator.findOne(entityName, value.getPrimaryKey(), false); + GenericValue oldValue = EntityQuery.use(delegator).from(entityName).where(value.getPrimaryKey()).queryOne(); if(UtilValidate.isNotEmpty(oldValue)) { for (String fieldName : fieldsToLoad) { value.put(fieldName, oldValue.get(fieldName)); diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEntityAutoTests.java b/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEntityAutoTests.java index 697426dfd9..49ea798832 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEntityAutoTests.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/test/ServiceEntityAutoTests.java @@ -200,7 +200,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase { delegator.create("StatusType", "statusTypeId", "TESTINGSTATUS"); delegator.create("StatusItem", "statusId", "TESTING_CREATE", "statusTypeId", "TESTINGSTATUS"); delegator.create("StatusItem", "statusId", "TESTING_UPDATE", "statusTypeId", "TESTINGSTATUS"); - GenericValue userLogin = delegator.findOne("UserLogin", true, "userLoginId", "system"); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); //test create testingStatus with userlogin Map testingStatusCreateMap = UtilMisc.toMap("testingId", "TESTING_7", "statusId", "TESTING_CREATE", "userLogin", userLogin); diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ExternalLoginKeysManager.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ExternalLoginKeysManager.java index c2afca319c..baf7b3f891 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ExternalLoginKeysManager.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ExternalLoginKeysManager.java @@ -45,6 +45,7 @@ import io.jsonwebtoken.Claims; import io.jsonwebtoken.JwtBuilder; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; +import org.apache.ofbiz.entity.util.EntityQuery; /** * This class manages the authentication tokens that provide single sign-on authentication to the OFBiz applications. @@ -184,7 +185,7 @@ public class ExternalLoginKeysManager { GenericValue currentUserLogin = (GenericValue) session.getAttribute("userLogin"); try { - GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", externalServerUserLoginId); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", externalServerUserLoginId).queryOne(); if (userLogin != null) { //to check it's the right tenant //in case username and password are the same in different tenants diff --git a/framework/webtools/groovyScripts/entity/EntityPerformanceTest.groovy b/framework/webtools/groovyScripts/entity/EntityPerformanceTest.groovy index e0cf35e0a3..7b7d52a056 100644 --- a/framework/webtools/groovyScripts/entity/EntityPerformanceTest.groovy +++ b/framework/webtools/groovyScripts/entity/EntityPerformanceTest.groovy @@ -33,7 +33,7 @@ if (security.hasPermission("ENTITY_MAINT", session)) { calls = 1000 startTime = System.currentTimeMillis() for (int i = 0; i < calls; i++) { - dummy = delegator.findOne("JobSandbox", [jobId : "PURGE_OLD_JOBS"], false) + dummy = from("JobSandbox").where("jobId", "PURGE_OLD_JOBS").queryOne(); } totalTime = System.currentTimeMillis() - startTime callsPerSecond = calls / (totalTime/1000) @@ -50,7 +50,7 @@ if (security.hasPermission("ENTITY_MAINT", session)) { calls = 10000 startTime = System.currentTimeMillis() for (int i = 0; i < calls; i++) { - dummy = delegator.findOne("JobSandbox", [jobId : "PURGE_OLD_JOBS"], true) + dummy = from("JobSandbox").where("jobId", "PURGE_OLD_JOBS").cache().queryOne(); } totalTime = System.currentTimeMillis() - startTime callsPerSecond = calls / (totalTime / 1000) @@ -67,7 +67,7 @@ if (security.hasPermission("ENTITY_MAINT", session)) { calls = 1000 startTime = System.currentTimeMillis() for (int i = 0; i < calls; i++) { - dummy = delegator.findOne("DataSourceType", [dataSourceTypeId : "ADMIN_ENTRY"], false) + dummy = from("DataSourceType").where("dataSourceTypeId", "ADMIN_ENTRY").queryOne(); } totalTime = System.currentTimeMillis() - startTime callsPerSecond = calls / (totalTime / 1000) @@ -84,7 +84,7 @@ if (security.hasPermission("ENTITY_MAINT", session)) { calls = 10000 startTime = System.currentTimeMillis() for (int i=0; i < calls; i++) { - dummy = delegator.findOne("DataSourceType", [dataSourceTypeId : "ADMIN_ENTRY"], true) + dummy = from("DataSourceType").where("dataSourceTypeId", "ADMIN_ENTRY").cache().queryOne() } totalTime = System.currentTimeMillis() - startTime callsPerSecond = calls / (totalTime / 1000) diff --git a/framework/webtools/groovyScripts/entity/ViewGeneric.groovy b/framework/webtools/groovyScripts/entity/ViewGeneric.groovy index b0c8b15b00..6a810ae901 100644 --- a/framework/webtools/groovyScripts/entity/ViewGeneric.groovy +++ b/framework/webtools/groovyScripts/entity/ViewGeneric.groovy @@ -81,7 +81,7 @@ context.put("curFindString", curFindString) GenericValue value = null //only try to find it if this is a valid primary key... if (findByPK.isPrimaryKey()) { - value = delegator.findOne(findByPK.getEntityName(), findByPK, false) + value = from("findByPK.getEntityName()").where(findByPK).queryOne(); } context.put("value", value) diff --git a/themes/rainbowstone/template/includes/HomeMenu.ftl b/themes/rainbowstone/template/includes/HomeMenu.ftl index 041a94205e..2be708862b 100644 --- a/themes/rainbowstone/template/includes/HomeMenu.ftl +++ b/themes/rainbowstone/template/includes/HomeMenu.ftl @@ -23,10 +23,10 @@ under the License. <#assign contextPath = request.getContextPath()> <#assign displayApps = Static["org.apache.ofbiz.base.component.ComponentConfig"].getAppBarWebInfos(ofbizServerName, "main")> <#assign displaySecondaryApps = Static["org.apache.ofbiz.base.component.ComponentConfig"].getAppBarWebInfos(ofbizServerName, "secondary")> -<#assign avatarList = delegator.findByAnd("PartyContent", {"partyId" : person.partyId, "partyContentTypeId" : "LGOIMGURL"}, null, false)> +<#assign avatarList = EntityQuery.use(delegator).from("PartyContent").where("partyId", person.partyId!, "partyContentTypeId", "LGOIMGURL").queryList()!> <#if avatarList?has_content> <#assign avatar = Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(avatarList)> - <#assign avatarDetail = Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(delegator.findByAnd("PartyContentDetail", {"partyId" : person.partyId, "contentId" : avatar.contentId}, null, false))> + <#assign avatarDetail = EntityQuery.use(delegator).from("PartyContentDetail").where("partyId", person.partyId!, "contentId", avatar.contentId!).queryFirst()!>
${orderItem.orderId}