You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by de...@apache.org on 2017/12/13 09:02:59 UTC
svn commit: r1817986 - in /ofbiz/ofbiz-plugins/trunk:
bi/src/main/java/org/apache/ofbiz/bi/util/ ebaystore/template/store/
ecommerce/template/order/ passport/groovyScripts/login/
passport/src/main/java/org/apache/ofbiz/passport/event/ passport/src/main...
Author: deepak
Date: Wed Dec 13 09:02:59 2017
New Revision: 1817986
URL: http://svn.apache.org/viewvc?rev=1817986&view=rev
Log:
Improved: Replace all delegator findByAnd and findOne method calling by EntityQuery methods (OFBIZ-10029)
Applied slightly modified patch, rearrange import properly,
Thanks Suraj Khurana for your contribution
Modified:
ofbiz/ofbiz-plugins/trunk/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java
ofbiz/ofbiz-plugins/trunk/ebaystore/template/store/ProductSearchExport.ftl
ofbiz/ofbiz-plugins/trunk/ecommerce/template/order/OrderHistory.ftl
ofbiz/ofbiz-plugins/trunk/passport/groovyScripts/login/GetThirdPartyLogins.groovy
ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/event/GitHubEvents.java
ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/event/LinkedInEvents.java
ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java
ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java
ofbiz/ofbiz-plugins/trunk/pricat/groovyScripts/pricat/FindMyExcelImport.groovy
ofbiz/ofbiz-plugins/trunk/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy
ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java
ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java
ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java
ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java
ofbiz/ofbiz-plugins/trunk/projectmgr/template/project/EditTaskAndAssoc.ftl
ofbiz/ofbiz-plugins/trunk/scrum/template/includes/BurnDown.ftl
ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java
ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/test/SolrTests.java
Modified: ofbiz/ofbiz-plugins/trunk/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java (original)
+++ ofbiz/ofbiz-plugins/trunk/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java Wed Dec 13 09:02:59 2017
@@ -35,7 +35,7 @@ import org.apache.ofbiz.base.util.UtilVa
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<GenericValue> 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());
}
Modified: ofbiz/ofbiz-plugins/trunk/ebaystore/template/store/ProductSearchExport.ftl
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/ebaystore/template/store/ProductSearchExport.ftl?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/ebaystore/template/store/ProductSearchExport.ftl (original)
+++ ofbiz/ofbiz-plugins/trunk/ebaystore/template/store/ProductSearchExport.ftl Wed Dec 13 09:02:59 2017
@@ -467,7 +467,7 @@ under the License.
<tr>
<td class="label">${uiLabelMap.CommonCountry}</td>
<#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/>
</#if>
Modified: ofbiz/ofbiz-plugins/trunk/ecommerce/template/order/OrderHistory.ftl
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/ecommerce/template/order/OrderHistory.ftl?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/ecommerce/template/order/OrderHistory.ftl (original)
+++ ofbiz/ofbiz-plugins/trunk/ecommerce/template/order/OrderHistory.ftl Wed Dec 13 09:02:59 2017
@@ -41,7 +41,7 @@ under the License.
<td><@ofbizCurrency amount=orderHeader.grandTotal isoCode=orderHeader.currencyUom /></td>
<td>${status.get("description",locale)}</td>
<#-- 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>
<td>
Modified: ofbiz/ofbiz-plugins/trunk/passport/groovyScripts/login/GetThirdPartyLogins.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/passport/groovyScripts/login/GetThirdPartyLogins.groovy?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/passport/groovyScripts/login/GetThirdPartyLogins.groovy (original)
+++ ofbiz/ofbiz-plugins/trunk/passport/groovyScripts/login/GetThirdPartyLogins.groovy Wed Dec 13 09:02:59 2017
@@ -35,7 +35,7 @@ if (!adminErrorInfo || !adminErrorInfo.h
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.h
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
Modified: ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/event/GitHubEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/event/GitHubEvents.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/event/GitHubEvents.java (original)
+++ ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/event/GitHubEvents.java Wed Dec 13 09:02:59 2017
@@ -55,7 +55,7 @@ import org.apache.ofbiz.common.login.Log
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();
}
}
Modified: ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/event/LinkedInEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/event/LinkedInEvents.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/event/LinkedInEvents.java (original)
+++ ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/event/LinkedInEvents.java Wed Dec 13 09:02:59 2017
@@ -56,7 +56,7 @@ import org.apache.ofbiz.common.login.Log
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();
}
}
Modified: ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java (original)
+++ ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java Wed Dec 13 09:02:59 2017
@@ -40,7 +40,7 @@ import org.apache.ofbiz.entity.GenericVa
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 impleme
Map<String, Object> 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 impleme
Map<String, Object> 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 impleme
Map<String, Object> 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 impleme
public String createUser(Map<String, Object> 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 impleme
// 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);
}
Modified: ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java (original)
+++ ofbiz/ofbiz-plugins/trunk/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java Wed Dec 13 09:02:59 2017
@@ -46,7 +46,7 @@ import org.apache.ofbiz.entity.GenericVa
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 imple
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 imple
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 imple
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 imple
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 imple
// 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);
}
Modified: ofbiz/ofbiz-plugins/trunk/pricat/groovyScripts/pricat/FindMyExcelImport.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/pricat/groovyScripts/pricat/FindMyExcelImport.groovy?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/pricat/groovyScripts/pricat/FindMyExcelImport.groovy (original)
+++ ofbiz/ofbiz-plugins/trunk/pricat/groovyScripts/pricat/FindMyExcelImport.groovy Wed Dec 13 09:02:59 2017
@@ -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;
Modified: ofbiz/ofbiz-plugins/trunk/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy (original)
+++ ofbiz/ofbiz-plugins/trunk/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy Wed Dec 13 09:02:59 2017
@@ -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;
Modified: ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java (original)
+++ ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java Wed Dec 13 09:02:59 2017
@@ -68,7 +68,7 @@ import org.apache.ofbiz.entity.GenericEn
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 AbstractPricatPars
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 AbstractPricatPars
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 AbstractPricatPars
protected void cleanupLogAndCommentedExcel() {
try {
report.print(UtilProperties.getMessage(resource, "CLEANUP_LOGANDEXCEL_BEGIN", locale), InterfaceReport.FORMAT_DEFAULT);
- List<GenericValue> historyValues = delegator.findByAnd("ExcelImportHistory", UtilMisc.toMap("userLoginId", userLoginId), UtilMisc.toList("sequenceNum DESC"), false);
+ List<GenericValue> 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);
Modified: ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java (original)
+++ ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java Wed Dec 13 09:02:59 2017
@@ -34,12 +34,12 @@ import org.apache.ofbiz.base.location.Co
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";
Modified: ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java (original)
+++ ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java Wed Dec 13 09:02:59 2017
@@ -57,6 +57,7 @@ import org.apache.ofbiz.entity.GenericVa
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
public synchronized long addExcelImportHistory() {
long latestId = 1;
try {
- List<GenericValue> 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;
}
Modified: ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java (original)
+++ ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java Wed Dec 13 09:02:59 2017
@@ -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
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);
Modified: ofbiz/ofbiz-plugins/trunk/projectmgr/template/project/EditTaskAndAssoc.ftl
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/projectmgr/template/project/EditTaskAndAssoc.ftl?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/projectmgr/template/project/EditTaskAndAssoc.ftl (original)
+++ ofbiz/ofbiz-plugins/trunk/projectmgr/template/project/EditTaskAndAssoc.ftl Wed Dec 13 09:02:59 2017
@@ -91,14 +91,14 @@ under the License.
<#if task??>
<#assign currentStatus = task.geRelatedOne("CurrentStatusItem")!>
<option selected="selected" value="${currentStatus.currentStatusId}">${currentStatus.description}</option>
- <#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>
<option value=${statusValidChangeToDetail.statusId}>[${uiLabelMap.WorkEffortGeneral}]${statusValidChangeToDetail.description}</option>
</#list>
<#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>
<option value="${statusItem.statusId!}">[${uiLabelMap.WorkEffortGeneral}]${statusItem.description}</option>
</#list>
@@ -149,7 +149,7 @@ under the License.
<tr>
<td class="label">${uiLabelMap.ProjectMgrWorkEffortScopeEnumId}</td>
<td>
- <#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()!>
<select name="scopeEnumId">
<#if task??>
<#assign scopeEnumId = task.scopeEnumId!>
Modified: ofbiz/ofbiz-plugins/trunk/scrum/template/includes/BurnDown.ftl
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/scrum/template/includes/BurnDown.ftl?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/scrum/template/includes/BurnDown.ftl (original)
+++ ofbiz/ofbiz-plugins/trunk/scrum/template/includes/BurnDown.ftl Wed Dec 13 09:02:59 2017
@@ -22,7 +22,7 @@ under the License.
<#assign actualCompletionDay = Static["org.apache.ofbiz.base.util.UtilDateTime"].getDayStart(sprint.actualCompletionDate, timeZone, locale)/>
<#assign dayNumber = ((actualCompletionDay.getTime() - actualStartDay.getTime())/1000/60/60/24) + 1/>
<#assign estimatedHrs = sprint.estimatedMilliSeconds/1000/60/60/>
-<#assign members = delegator.findByAnd("WorkEffortPartyAssignment", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("workEffortId", parameters.get("sprintId")), null, false)/>
+<#assign members = EntityQuery.use(delegator).from("WorkEffortPartyAssignment").where("workEffortId", parameters.get("sprintId")!).queryList()!/>
<#if members.size() > 0 >
<#assign maxHours = estimatedHrs * members.size()/>
<div id="params_birtReport" style='display:none'>
Modified: ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java (original)
+++ ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java Wed Dec 13 09:02:59 2017
@@ -49,6 +49,7 @@ import org.apache.ofbiz.entity.Delegator
import org.apache.ofbiz.entity.GenericDelegator;
import org.apache.ofbiz.entity.GenericEntityException;
import org.apache.ofbiz.entity.GenericValue;
+import org.apache.ofbiz.entity.util.EntityQuery;
import org.apache.ofbiz.service.DispatchContext;
import org.apache.ofbiz.service.GenericServiceException;
import org.apache.ofbiz.service.LocalDispatcher;
@@ -79,7 +80,7 @@ public abstract class SolrProductSearch
if (SolrUtil.isSolrEcaEnabled()) {
// Debug.logVerbose("Solr: addToSolr: Running indexing for productId '" + productId + "'", module);
try {
- GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
Map<String, Object> dispatchContext = ProductUtil.getProductContent(product, dctx, context);
dispatchContext.put("treatConnectErrorNonFatal", SolrUtil.isEcaTreatConnectErrorNonFatal());
dispatchContext.put("indexName", solrIndexName);
Modified: ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/test/SolrTests.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/test/SolrTests.java?rev=1817986&r1=1817985&r2=1817986&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/test/SolrTests.java (original)
+++ ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/test/SolrTests.java Wed Dec 13 09:02:59 2017
@@ -62,7 +62,7 @@ public class SolrTests extends OFBizTest
public void testAddProductToIndex() throws Exception {
- GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", validTestProductId), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", validTestProductId).queryOne();
Map<String, Object> ctx = new HashMap<String, Object>();
ctx.put("instance", product);
@@ -99,8 +99,8 @@ public class SolrTests extends OFBizTest
List<Map<String, Object>> products = new ArrayList<>();
Map<String, Object> product_1 = new HashMap<>();
Map<String, Object> product_2 = new HashMap<>();
- GenericValue validTestProduct = delegator.findOne("Product", UtilMisc.toMap("productId", validTestProductId), false);
- GenericValue validTestProduct_2 = delegator.findOne("Product", UtilMisc.toMap("productId", validTestProductId_2), false);
+ GenericValue validTestProduct = EntityQuery.use(delegator).from("Product").where("productId", validTestProductId).queryOne();
+ GenericValue validTestProduct_2 = EntityQuery.use(delegator).from("Product").where("productId", validTestProductId_2).queryOne();
product_1.put("productId", validTestProduct);
product_2.put("productId", validTestProduct_2);
@@ -119,8 +119,8 @@ public class SolrTests extends OFBizTest
List<Map<String, Object>> products = new ArrayList<>();
Map<String, Object> product_1 = new HashMap<>();
Map<String, Object> product_2 = new HashMap<>();
- GenericValue testProduct = delegator.findOne("Product", UtilMisc.toMap("productId", validTestProductId), false);
- GenericValue testProduct_2 = delegator.findOne("Product", UtilMisc.toMap("productId", validTestProductId_2), false);
+ GenericValue testProduct = EntityQuery.use(delegator).from("Product").where("productId", validTestProductId).queryOne();
+ GenericValue testProduct_2 = EntityQuery.use(delegator).from("Product").where("productId", validTestProductId_2).queryOne();
testProduct.replace("productId", invalidTestProductId);
testProduct.replace("productId", invalidTestProductId);