diff --git a/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java b/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java index e0e3435d0..eb6eb9d90 100644 --- a/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java +++ b/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java @@ -35,7 +35,7 @@ import org.apache.ofbiz.base.util.UtilValidate; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.service.DispatchContext; import org.apache.ofbiz.service.ServiceUtil; @@ -52,7 +52,7 @@ public class DimensionServices { GenericValue lastDimensionValue = null; try { // TODO: improve performance - lastDimensionValue = EntityUtil.getFirst(delegator.findByAnd(dimensionEntityName, UtilMisc.toMap(naturalKeyFields), UtilMisc.toList("-createdTxStamp"), false)); + lastDimensionValue = EntityQuery.use(delegator).from(dimensionEntityName).where(naturalKeyFields).orderBy("-createdTxStamp").queryFirst(); } catch (GenericEntityException gee) { return ServiceUtil.returnError(gee.getMessage()); } @@ -79,7 +79,7 @@ public class DimensionServices { } List existingDimensionValues = null; try { - existingDimensionValues = delegator.findByAnd(dimensionValue.getEntityName(), UtilMisc.toMap(andCondition), null, false); + existingDimensionValues = EntityQuery.use(delegator).from(dimensionValue.getEntityName()).where(andCondition).queryList(); } catch (GenericEntityException gee) { return ServiceUtil.returnError(gee.getMessage()); } @@ -136,7 +136,7 @@ public class DimensionServices { while (currentDate.compareTo(thruDate) <= 0) { GenericValue dateValue = null; try { - dateValue = EntityUtil.getFirst(delegator.findByAnd("DateDimension", UtilMisc.toMap("dateValue", currentDate), null, false)); + dateValue = EntityQuery.use(delegator).from("DateDimension").where("dateValue", currentDate).queryFirst(); } catch (GenericEntityException gee) { return ServiceUtil.returnError(gee.getMessage()); } diff --git a/ebaystore/template/store/ProductSearchExport.ftl b/ebaystore/template/store/ProductSearchExport.ftl index 99db18fa7..a8a6a7d70 100644 --- a/ebaystore/template/store/ProductSearchExport.ftl +++ b/ebaystore/template/store/ProductSearchExport.ftl @@ -467,7 +467,7 @@ under the License. ${uiLabelMap.CommonCountry} <#if item.getCountry().value()??> - <#assign country = Static["org.apache.ofbiz.entity.util.EntityUtil"].getFirst(delegator.findByAnd("Geo", {"geoCode": item.getCountry().value()}, null, false))/> + <#assign country = EntityQuery.use(delegator).from("Geo").where("geoCode", item.getCountry().value()!).queryFirst()!/> <#if country?has_content> <#assign countryname = country.geoName/> diff --git a/ecommerce/template/order/OrderHistory.ftl b/ecommerce/template/order/OrderHistory.ftl index fd89d3fe9..ad152a878 100644 --- a/ecommerce/template/order/OrderHistory.ftl +++ b/ecommerce/template/order/OrderHistory.ftl @@ -41,7 +41,7 @@ under the License. <@ofbizCurrency amount=orderHeader.grandTotal isoCode=orderHeader.currencyUom /> ${status.get("description",locale)} <#-- invoices --> - <#assign invoices = delegator.findByAnd("OrderItemBilling", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("orderId", "${orderHeader.orderId}"), Static["org.apache.ofbiz.base.util.UtilMisc"].toList("invoiceId"), false) /> + <#assign invoices = EntityQuery.use(delegator).from("OrderItemBilling").where("orderId", orderHeader.orderId).orderBy("invoiceId").queryList()!/> <#assign distinctInvoiceIds = Static["org.apache.ofbiz.entity.util.EntityUtil"].getFieldListFromEntityList(invoices, "invoiceId", true)> <#if distinctInvoiceIds?has_content> diff --git a/passport/groovyScripts/login/GetThirdPartyLogins.groovy b/passport/groovyScripts/login/GetThirdPartyLogins.groovy index d2287b249..3e0d1e3fb 100644 --- a/passport/groovyScripts/login/GetThirdPartyLogins.groovy +++ b/passport/groovyScripts/login/GetThirdPartyLogins.groovy @@ -35,7 +35,7 @@ if (!adminErrorInfo || !adminErrorInfo.hasError()) { storePassportLoginMethList = null // Get lists of passport login methods if (productStoreId) { - storePassportLoginMethList = delegator.findByAnd("ThirdPartyLogin", ["productStoreId": productStoreId], ["sequenceNum ASC"], false) + storePassportLoginMethList = from("ThirdPartyLogin").where("productStoreId", productStoreId).orderBy("sequenceNum ASC").queryList(); storePassportLoginMethList = EntityUtil.filterByDate(storePassportLoginMethList) } @@ -43,7 +43,7 @@ if (!adminErrorInfo || !adminErrorInfo.hasError()) { if (storePassportLoginMethList) { storeLoginMethList = [] for (storeLoginMeth in storePassportLoginMethList) { - storeLoginMethDetail = EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd(storeLoginMeth.loginMethTypeId + storeLoginMeth.loginProviderId, ["productStoreId": productStoreId], null, false))) + storeLoginMethDetail = from(storeLoginMeth.loginMethTypeId + storeLoginMeth.loginProviderId).where("productStoreId", productStoreId).filterByDate().queryFirst(); storeLoginMethList.add(storeLoginMethDetail) } context.storeLoginMethList = storeLoginMethList diff --git a/passport/src/main/java/org/apache/ofbiz/passport/event/GitHubEvents.java b/passport/src/main/java/org/apache/ofbiz/passport/event/GitHubEvents.java index 48bc55aa3..5c022161a 100644 --- a/passport/src/main/java/org/apache/ofbiz/passport/event/GitHubEvents.java +++ b/passport/src/main/java/org/apache/ofbiz/passport/event/GitHubEvents.java @@ -55,7 +55,7 @@ import org.apache.ofbiz.common.login.LoginServices; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.entity.util.EntityUtilProperties; import org.apache.ofbiz.product.store.ProductStoreWorker; import org.apache.ofbiz.service.LocalDispatcher; @@ -240,7 +240,7 @@ public class GitHubEvents { String gitHubUserId = (String) userInfo.get("login"); GenericValue gitHubUser = null; try { - gitHubUser = delegator.findOne("GitHubUser", UtilMisc.toMap("gitHubUserId", gitHubUserId), false); + gitHubUser = EntityQuery.use(delegator).from("GitHubUser").where("gitHubUserId", gitHubUserId).queryOne(); } catch (GenericEntityException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; @@ -278,12 +278,12 @@ public class GitHubEvents { } } try { - GenericValue userLogin = EntityUtil.getFirst(delegator.findByAnd("UserLogin", UtilMisc.toMap("externalAuthId", gitHubUserId), null, false)); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("externalAuthId", gitHubUserId).queryFirst(); GitHubAuthenticator authn = new GitHubAuthenticator(); authn.initialize(dispatcher); if (UtilValidate.isEmpty(userLogin)) { String userLoginId = authn.createUser(userInfo); - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); } String autoPassword = RandomStringUtils.randomAlphanumeric(EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5).intValue()); boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security", "password.encrypt")); @@ -317,6 +317,6 @@ public class GitHubEvents { } public static GenericValue getOAuth2GitHubConfig(Delegator delegator, String productStoreId) throws GenericEntityException { - return EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd("OAuth2GitHub", UtilMisc.toMap("productStoreId", productStoreId), null, false))); + return EntityQuery.use(delegator).from("OAuth2GitHub").where("productStoreId", productStoreId).filterByDate().queryFirst(); } } diff --git a/passport/src/main/java/org/apache/ofbiz/passport/event/LinkedInEvents.java b/passport/src/main/java/org/apache/ofbiz/passport/event/LinkedInEvents.java index 00397d682..f027b806f 100644 --- a/passport/src/main/java/org/apache/ofbiz/passport/event/LinkedInEvents.java +++ b/passport/src/main/java/org/apache/ofbiz/passport/event/LinkedInEvents.java @@ -56,7 +56,7 @@ import org.apache.ofbiz.common.login.LoginServices; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.entity.util.EntityUtilProperties; import org.apache.ofbiz.product.store.ProductStoreWorker; import org.apache.ofbiz.service.LocalDispatcher; @@ -247,7 +247,7 @@ public class LinkedInEvents { String linkedInUserId = LinkedInAuthenticator.getLinkedInUserId(userInfo); GenericValue linkedInUser = null; try { - linkedInUser = delegator.findOne("LinkedInUser", UtilMisc.toMap("linkedInUserId", linkedInUserId), false); + linkedInUser = EntityQuery.use(delegator).from("LinkedInUser").where("linkedInUserId", linkedInUserId).queryOne(); } catch (GenericEntityException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; @@ -285,12 +285,12 @@ public class LinkedInEvents { } } try { - GenericValue userLogin = EntityUtil.getFirst(delegator.findByAnd("UserLogin", UtilMisc.toMap("externalAuthId", linkedInUserId), null, false)); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("externalAuthId", linkedInUserId).queryFirst(); LinkedInAuthenticator authn = new LinkedInAuthenticator(); authn.initialize(dispatcher); if (UtilValidate.isEmpty(userLogin)) { String userLoginId = authn.createUser(userInfo); - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); } String autoPassword = RandomStringUtils.randomAlphanumeric(EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5).intValue()); boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security", "password.encrypt")); @@ -324,6 +324,6 @@ public class LinkedInEvents { } public static GenericValue getOAuth2LinkedInConfig(Delegator delegator, String productStoreId) throws GenericEntityException { - return EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd("OAuth2LinkedIn", UtilMisc.toMap("productStoreId", productStoreId), null, false))); + return EntityQuery.use(delegator).from("OAuth2LinkedIn").where("productStoreId", productStoreId).filterByDate().queryFirst(); } } diff --git a/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java b/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java index 095506125..43cc53c01 100644 --- a/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java +++ b/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java @@ -40,7 +40,7 @@ import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.transaction.TransactionUtil; import org.apache.ofbiz.entity.transaction.GenericTransactionException; -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; @@ -101,9 +101,9 @@ public class GitHubAuthenticator implements Authenticator { Map user = null; HttpGet getMethod = null; try { - GenericValue userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); String externalAuthId = userLogin.getString("externalAuthId"); - GenericValue gitHubUser = delegator.findOne("GitHubUser", UtilMisc.toMap("gitHubUserId", externalAuthId), false); + GenericValue gitHubUser = EntityQuery.use(delegator).from("GitHubUser").where("gitHubUserId", externalAuthId).queryOne(); if (UtilValidate.isNotEmpty(gitHubUser)) { String accessToken = gitHubUser.getString("accessToken"); String tokenType = gitHubUser.getString("tokenType"); @@ -147,14 +147,14 @@ public class GitHubAuthenticator implements Authenticator { Map userMap = getGitHubUserinfo(userLoginId); GenericValue system; try { - system = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true); + system = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); } catch (GenericEntityException e) { throw new AuthenticatorException(e.getMessage(), e); } GenericValue userLogin; try { - userLogin = EntityUtil.getFirst(delegator.findByAnd("UserLogin", UtilMisc.toMap("externalAuthId", (String) userMap.get("id")), null, false)); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("externalAuthId", (String) userMap.get("id")).queryFirst(); } catch (GenericEntityException e) { throw new AuthenticatorException(e.getMessage(), e); } @@ -207,9 +207,9 @@ public class GitHubAuthenticator implements Authenticator { Map user = null; HttpGet getMethod = null; try { - GenericValue userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); String externalAuthId = userLogin.getString("externalAuthId"); - GenericValue gitHubUser = delegator.findOne("GitHubUser", UtilMisc.toMap("gitHubUserId", externalAuthId), false); + GenericValue gitHubUser = EntityQuery.use(delegator).from("GitHubUser").where("gitHubUserId", externalAuthId).queryOne(); if (UtilValidate.isNotEmpty(gitHubUser)) { String accessToken = gitHubUser.getString("accessToken"); String tokenType = gitHubUser.getString("tokenType"); @@ -229,7 +229,7 @@ public class GitHubAuthenticator implements Authenticator { public String createUser(Map userMap) throws AuthenticatorException { GenericValue system; try { - system = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true); + system = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); } catch (GenericEntityException e) { throw new AuthenticatorException(e.getMessage(), e); } @@ -296,7 +296,7 @@ public class GitHubAuthenticator implements Authenticator { // check and make sure the security group exists GenericValue secGroup = null; try { - secGroup = delegator.findOne("SecurityGroup", UtilMisc.toMap("groupId", securityGroup), true); + secGroup = EntityQuery.use(delegator).from("SecurityGroup").where("groupId", securityGroup).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, e.getMessage(), module); } diff --git a/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java b/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java index 83848ec8d..7c6545cec 100644 --- a/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java +++ b/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java @@ -46,7 +46,7 @@ import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.transaction.TransactionUtil; import org.apache.ofbiz.entity.transaction.GenericTransactionException; -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilMisc; @@ -102,9 +102,9 @@ public class LinkedInAuthenticator implements Authenticator { Document user = null; HttpGet getMethod = null; try { - GenericValue userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); String externalAuthId = userLogin.getString("externalAuthId"); - GenericValue linkedInUser = delegator.findOne("LinkedInUser", UtilMisc.toMap("linedInUserId", externalAuthId), false); + GenericValue linkedInUser = EntityQuery.use(delegator).from("LinkedInUser").where("linkedInUserId", externalAuthId).queryOne(); if (linkedInUser != null) { String accessToken = linkedInUser.getString("accessToken"); if (UtilValidate.isNotEmpty(accessToken)) { @@ -154,14 +154,14 @@ public class LinkedInAuthenticator implements Authenticator { GenericValue system; try { - system = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true); + system = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); } catch (GenericEntityException e) { throw new AuthenticatorException(e.getMessage(), e); } GenericValue userLogin; try { - userLogin = EntityUtil.getFirst(delegator.findByAnd("UserLogin", UtilMisc.toMap("externalAuthId", getLinkedInUserId(user)), null, false)); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("externalAuthId", getLinkedInUserId(user)).queryFirst(); } catch (GenericEntityException e) { throw new AuthenticatorException(e.getMessage(), e); } @@ -214,9 +214,9 @@ public class LinkedInAuthenticator implements Authenticator { Document user = null; HttpGet getMethod = null; try { - GenericValue userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); String externalAuthId = userLogin.getString("externalAuthId"); - GenericValue linkedInUser = delegator.findOne("LinkedInUser", UtilMisc.toMap("linkedInUserId", externalAuthId), false); + GenericValue linkedInUser = EntityQuery.use(delegator).from("LinkedInUser").where("linkedInUserId", externalAuthId).queryOne(); if (linkedInUser != null) { String accessToken = linkedInUser.getString("accessToken"); if (UtilValidate.isNotEmpty(accessToken)) { @@ -245,7 +245,7 @@ public class LinkedInAuthenticator implements Authenticator { public String createUser(Document user) throws AuthenticatorException { GenericValue system; try { - system = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true); + system = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); } catch (GenericEntityException e) { throw new AuthenticatorException(e.getMessage(), e); } @@ -316,7 +316,7 @@ public class LinkedInAuthenticator implements Authenticator { // check and make sure the security group exists GenericValue secGroup = null; try { - secGroup = delegator.findOne("SecurityGroup", UtilMisc.toMap("groupId", securityGroup), true); + secGroup = EntityQuery.use(delegator).from("SecurityGroup").where("groupId", securityGroup).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, e.getMessage(), module); } diff --git a/pricat/groovyScripts/pricat/FindMyExcelImport.groovy b/pricat/groovyScripts/pricat/FindMyExcelImport.groovy index b686b70e4..d5c6b62c4 100644 --- a/pricat/groovyScripts/pricat/FindMyExcelImport.groovy +++ b/pricat/groovyScripts/pricat/FindMyExcelImport.groovy @@ -20,5 +20,5 @@ import org.apache.ofbiz.base.util.*; module = "FindMyExcelImport.groovy"; -data = delegator.findByAnd("ExcelImportHistory", [userLoginId : userLogin.userLoginId], ["sequenceNum DESC"], false); +data = from("ExcelImportHistory").where("userLoginId", userLogin.userLoginId).orderBy("sequenceNum DESC").queryList(); context.data = data; diff --git a/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy b/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy index 334f17d0c..c7d570df6 100644 --- a/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy +++ b/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy @@ -31,7 +31,7 @@ if (sequenceNum == null) { return; } -historyEntry = delegator.findOne("ExcelImportHistory", [sequenceNum : Long.valueOf(sequenceNum), userLoginId : userLogin.userLoginId], false); +historyEntry = from("ExcelImportHistory").where("sequenceNum", Long.valueOf(sequenceNum), "userLoginId", userLogin.userLoginId).queryOne(); if (historyEntry == null) { context.logFileContent = "No import history found."; return; diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java b/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java index ac4cbe00a..9073f7a68 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java @@ -68,7 +68,7 @@ import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.condition.EntityCondition; import org.apache.ofbiz.entity.condition.EntityOperator; -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ServiceUtil; @@ -556,10 +556,9 @@ public abstract class AbstractPricatParser implements InterfacePricatParser { try { GenericValue historyValue = null; if (sequenceNum < 1L) { - historyValue = EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd("ExcelImportHistory", - UtilMisc.toMap("userLoginId", userLoginId, "logFileName", logFileName), UtilMisc.toList("sequenceNum DESC"), false))); + historyValue = EntityQuery.use(delegator).from("ExcelImportHistory").where("userLoginId", userLoginId, "logFileName", logFileName).orderBy("sequenceNum DESC").filterByDate().queryFirst(); } else { - historyValue = delegator.findOne("ExcelImportHistory", UtilMisc.toMap("userLoginId", userLoginId, "sequenceNum", (Long) sequenceNum), false); + historyValue = EntityQuery.use(delegator).from("ExcelImportHistory").where("userLoginId", userLoginId, "sequenceNum", (Long) sequenceNum).queryOne(); } Timestamp now = UtilDateTime.nowTimestamp(); if (UtilValidate.isEmpty(historyValue)) { @@ -601,7 +600,7 @@ public abstract class AbstractPricatParser implements InterfacePricatParser { Delegator delegator = (Delegator) request.getAttribute("delegator"); GenericValue historyValue = null; try { - historyValue = delegator.findOne("ExcelImportHistory", UtilMisc.toMap("userLoginId", userLoginId, "sequenceNum", Long.valueOf(sequenceNum)), false); + historyValue = EntityQuery.use(delegator).from("ExcelImportHistory").where("userLoginId", userLoginId, "sequenceNum", Long.valueOf(sequenceNum)).queryOne(); } catch (NumberFormatException e) { Debug.logError(e.getMessage(), module); return false; @@ -623,7 +622,7 @@ public abstract class AbstractPricatParser implements InterfacePricatParser { protected void cleanupLogAndCommentedExcel() { try { report.print(UtilProperties.getMessage(resource, "CLEANUP_LOGANDEXCEL_BEGIN", locale), InterfaceReport.FORMAT_DEFAULT); - List historyValues = delegator.findByAnd("ExcelImportHistory", UtilMisc.toMap("userLoginId", userLoginId), UtilMisc.toList("sequenceNum DESC"), false); + List historyValues = EntityQuery.use(delegator).from("ExcelImportHistory").where("userLoginId", userLoginId).orderBy("sequenceNum DESC").queryList(); if (UtilValidate.isEmpty(historyValues) || historyValues.size() <= HISTORY_MAX_FILENUMBER) { report.print(UtilProperties.getMessage(resource, "HistoryLessThan", new Object[] {String.valueOf(HISTORY_MAX_FILENUMBER)}, locale), InterfaceReport.FORMAT_NOTE); report.println(" ... " + UtilProperties.getMessage(resource, "skipped", locale), InterfaceReport.FORMAT_NOTE); diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java b/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java index 28289a47a..daee95531 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java @@ -34,12 +34,12 @@ import org.apache.ofbiz.base.location.ComponentLocationResolver; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.FileUtil; import org.apache.ofbiz.base.util.UtilHttp; -import org.apache.ofbiz.base.util.UtilMisc; import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.base.util.UtilValidate; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; +import org.apache.ofbiz.entity.util.EntityQuery; public class PricatEvents { @@ -149,7 +149,7 @@ public class PricatEvents { Delegator delegator = (Delegator) request.getAttribute("delegator"); GenericValue historyValue = null; try { - historyValue = delegator.findOne("ExcelImportHistory", UtilMisc.toMap("userLoginId", userLoginId, "sequenceNum", Long.valueOf(sequenceNum)), false); + historyValue = EntityQuery.use(delegator).from("ExcelImportHistory").where("userLoginId", userLoginId, "sequenceNum", Long.valueOf(sequenceNum)).queryOne(); } catch (NumberFormatException e) { Debug.logError(e.getMessage(), module); return "error"; diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java b/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java index 28ffcb85a..4e84604e6 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java @@ -57,6 +57,7 @@ import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.condition.EntityCondition; import org.apache.ofbiz.entity.condition.EntityOperator; import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.service.LocalDispatcher; /** @@ -341,8 +342,7 @@ public class PricatParseExcelHtmlThread extends AbstractReportThread { public synchronized long addExcelImportHistory() { long latestId = 1; try { - List historyValues = delegator.findByAnd("ExcelImportHistory", UtilMisc.toMap("userLoginId", userLoginId), UtilMisc.toList("sequenceNum DESC"), false); - GenericValue latestHistoryValue = EntityUtil.getFirst(historyValues); + GenericValue latestHistoryValue = EntityQuery.use(delegator).from("ExcelImportHistory").where("userLoginId", userLoginId).orderBy("sequenceNum DESC").queryFirst(); if (UtilValidate.isNotEmpty(latestHistoryValue)) { latestId = latestHistoryValue.getLong("sequenceNum") + 1; } diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java b/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java index 792684eac..d2a966554 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java @@ -36,6 +36,7 @@ import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.transaction.GenericTransactionException; +import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.htmlreport.InterfaceReport; import org.apache.ofbiz.order.finaccount.FinAccountHelper; import org.apache.ofbiz.pricat.AbstractPricatParser; @@ -165,7 +166,7 @@ public class SamplePricatParser extends AbstractPricatParser { return false; } else { try { - GenericValue currencyUom = delegator.findOne("Uom", UtilMisc.toMap("uomId", currencyId), false); + GenericValue currencyUom = EntityQuery.use(delegator).from("Uom").where("uomId", currencyId).queryOne(); if (!"CURRENCY_MEASURE".equals(currencyUom.getString("uomTypeId"))) { String errorMessage = UtilProperties.getMessage(resource, "CurrencyIdNotCurrency", new Object[] {currencyId}, locale); report.println(errorMessage, InterfaceReport.FORMAT_ERROR); diff --git a/projectmgr/template/project/EditTaskAndAssoc.ftl b/projectmgr/template/project/EditTaskAndAssoc.ftl index 37936a9c2..127ba0e7f 100644 --- a/projectmgr/template/project/EditTaskAndAssoc.ftl +++ b/projectmgr/template/project/EditTaskAndAssoc.ftl @@ -91,14 +91,14 @@ under the License. <#if task??> <#assign currentStatus = task.geRelatedOne("CurrentStatusItem")!> - <#assign statusValidChangeToDetailList = delegator.findByAnd("StatusValidChangeToDetail", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("statusId", currentStatus.currentStatusId), null, false)> + <#assign statusValidChangeToDetailList = EntityQuery.use(delegator).from("StatusValidChangeToDetail").where("statusId", currentStatus.currentStatusId!).queryList()!> <#list statusValidChangeToDetailList as statusValidChangeToDetail> <#else> - <#assign statusItemGenrals = delegator.findByAnd("StatusItem", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("statusTypeId", "CALENDAR_STATUS"), null, false)> - <#assign statusItemTasks = delegator.findByAnd("StatusItem", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("statusTypeId", "TASK_STATUS"), null, false)> - <#assign statusItemEvents = delegator.findByAnd("StatusItem", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("statusTypeId", "EVENT_STATUS"), null, false)> + <#assign statusItemGenrals = EntityQuery.use(delegator).from("StatusItem").where("statusTypeId", "CALENDAR_STATUS").queryList()!> + <#assign statusItemTasks = EntityQuery.use(delegator).from("StatusItem").where("statusTypeId", "TASK_STATUS").queryList()!> + <#assign statusItemEvents = EntityQuery.use(delegator).from("StatusItem").where("statusTypeId", "EVENT_STATUS").queryList()! > <#list statusItemGenrals as statusItem> @@ -149,7 +149,7 @@ under the License. ${uiLabelMap.ProjectMgrWorkEffortScopeEnumId} - <#assign enumerations = delegator.findByAnd("Enumeration", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("enumTypeId", "WORK_EFF_SCOPE"), null, false)> + <#assign enumerations = EntityQuery.use(delegator).from("Enumeration").where("enumTypeId", "WORK_EFF_SCOPE").queryList()!>