Applied product folder related changes from jira issue - OFBIZ-5844 - Convert java files to EntityQuery.

Thanks Arun for the contribution.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1641044 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ashish Vijaywargiya
2014-11-22 11:26:20 +00:00
parent a090f96cad
commit f67ad0317d
46 changed files with 443 additions and 458 deletions
@@ -73,7 +73,7 @@ public class CatalogWorker {
List<GenericValue> catalogs = null;
Delegator delegator = (Delegator) request.getAttribute("delegator");
try {
catalogs = delegator.findList("ProdCatalog", null, null, UtilMisc.toList("catalogName"), null, false);
catalogs = EntityQuery.use(delegator).from("ProdCatalog").orderBy("catalogName").queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up all catalogs", module);
}
@@ -93,7 +93,7 @@ public class CatalogWorker {
public static List<GenericValue> getStoreCatalogs(Delegator delegator, String productStoreId) {
try {
return EntityUtil.filterByDate(delegator.findByAnd("ProductStoreCatalog", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNum", "prodCatalogId"), true), true);
return EntityQuery.use(delegator).from("ProductStoreCatalog").where("productStoreId", productStoreId).orderBy("sequenceNum", "prodCatalogId").cache(true).filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up store catalogs for store with id " + productStoreId, module);
}
@@ -117,7 +117,7 @@ public class CatalogWorker {
}
try {
return EntityUtil.filterByDate(delegator.findByAnd("ProdCatalogRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", "CUSTOMER"), UtilMisc.toList("sequenceNum", "prodCatalogId"), true), true);
return EntityQuery.use(delegator).from("ProdCatalogRole").where("partyId", partyId, "roleTypeId", "CUSTOMER").orderBy("sequenceNum", "prodCatalogId").cache(true).filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up ProdCatalog Roles for party with id " + partyId, module);
}
@@ -131,9 +131,12 @@ public class CatalogWorker {
public static List<GenericValue> getProdCatalogCategories(Delegator delegator, String prodCatalogId, String prodCatalogCategoryTypeId) {
try {
List<GenericValue> prodCatalogCategories = EntityUtil.filterByDate(delegator.findByAnd("ProdCatalogCategory",
UtilMisc.toMap("prodCatalogId", prodCatalogId),
UtilMisc.toList("sequenceNum", "productCategoryId"), true), true);
List<GenericValue> prodCatalogCategories = EntityQuery.use(delegator).from("ProdCatalogCategory")
.where("prodCatalogId", prodCatalogId)
.orderBy("sequenceNum", "productCategoryId")
.cache(true)
.filterByDate()
.queryList();
if (UtilValidate.isNotEmpty(prodCatalogCategoryTypeId) && prodCatalogCategories != null) {
prodCatalogCategories = EntityUtil.filterByAnd(prodCatalogCategories,
@@ -91,11 +91,11 @@ public class CatalogUrlFilter extends ContextFilter {
List<EntityCondition> productContentConds = FastList.newInstance();
productContentConds.add(EntityCondition.makeCondition("productContentTypeId", "ALTERNATIVE_URL"));
productContentConds.add(EntityUtil.getFilterByDateExpr());
List<GenericValue> productContentInfos = delegator.findList("ProductContentAndInfo", EntityCondition.makeCondition(productContentConds), null, UtilMisc.toList("-fromDate"), null, true);
List<GenericValue> productContentInfos = EntityQuery.use(delegator).from("ProductContentAndInfo").where(productContentConds).orderBy("-fromDate").cache(true).queryList();
if (UtilValidate.isNotEmpty(productContentInfos)) {
for (GenericValue productContentInfo : productContentInfos){
String contentId = (String) productContentInfo.get("contentId");
List<GenericValue> ContentAssocDataResourceViewTos = delegator.findByAnd("ContentAssocDataResourceViewTo", UtilMisc.toMap("contentIdStart", contentId, "caContentAssocTypeId", "ALTERNATE_LOCALE", "drDataResourceTypeId", "ELECTRONIC_TEXT"), null, true);
List<GenericValue> ContentAssocDataResourceViewTos = EntityQuery.use(delegator).where("ContentAssocDataResourceViewTo").where("contentIdStart", contentId, "caContentAssocTypeId", "ALTERNATE_LOCALE", "drDataResourceTypeId", "ELECTRONIC_TEXT").cache(true).queryList();
if (UtilValidate.isNotEmpty(ContentAssocDataResourceViewTos)){
for (GenericValue ContentAssocDataResourceViewTo : ContentAssocDataResourceViewTos) {
GenericValue ElectronicText = ContentAssocDataResourceViewTo.getRelatedOne("ElectronicText", true);
@@ -116,7 +116,7 @@ public class CatalogUrlFilter extends ContextFilter {
}
}
if (UtilValidate.isEmpty(productId)) {
List<GenericValue> contentDataResourceViews = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", contentId, "drDataResourceTypeId", "ELECTRONIC_TEXT"), null, true);
List<GenericValue> contentDataResourceViews = EntityQuery.use(delegator).where("ContentDataResourceView").where("contentId", contentId, "drDataResourceTypeId", "ELECTRONIC_TEXT").cache(true).queryList();
for (GenericValue contentDataResourceView : contentDataResourceViews) {
GenericValue ElectronicText = contentDataResourceView.getRelatedOne("ElectronicText", true);
if (UtilValidate.isNotEmpty(ElectronicText)) {
@@ -146,11 +146,11 @@ public class CatalogUrlFilter extends ContextFilter {
List<EntityCondition> productCategoryContentConds = FastList.newInstance();
productCategoryContentConds.add(EntityCondition.makeCondition("prodCatContentTypeId", "ALTERNATIVE_URL"));
productCategoryContentConds.add(EntityUtil.getFilterByDateExpr());
List<GenericValue> productCategoryContentInfos = delegator.findList("ProductCategoryContentAndInfo", EntityCondition.makeCondition(productCategoryContentConds), null, UtilMisc.toList("-fromDate"), null, true);
List<GenericValue> productCategoryContentInfos = EntityQuery.use(delegator).from("ProductCategoryContentAndInfo").where(productCategoryContentConds).orderBy("-fromDate").cache(true).queryList();
if (UtilValidate.isNotEmpty(productCategoryContentInfos)) {
for (GenericValue productCategoryContentInfo : productCategoryContentInfos){
String contentId = (String) productCategoryContentInfo.get("contentId");
List<GenericValue> ContentAssocDataResourceViewTos = delegator.findByAnd("ContentAssocDataResourceViewTo", UtilMisc.toMap("contentIdStart", contentId, "caContentAssocTypeId", "ALTERNATE_LOCALE", "drDataResourceTypeId", "ELECTRONIC_TEXT"), null, true);
List<GenericValue> ContentAssocDataResourceViewTos = EntityQuery.use(delegator).from("ContentAssocDataResourceViewTo").where("contentIdStart", contentId, "caContentAssocTypeId", "ALTERNATE_LOCALE", "drDataResourceTypeId", "ELECTRONIC_TEXT").cache(true).queryList();
if (UtilValidate.isNotEmpty(ContentAssocDataResourceViewTos)){
for (GenericValue ContentAssocDataResourceViewTo : ContentAssocDataResourceViewTos) {
GenericValue ElectronicText = ContentAssocDataResourceViewTo.getRelatedOne("ElectronicText", true);
@@ -173,7 +173,7 @@ public class CatalogUrlFilter extends ContextFilter {
}
}
if (UtilValidate.isEmpty(productCategoryId)) {
List<GenericValue> contentDataResourceViews = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", contentId, "drDataResourceTypeId", "ELECTRONIC_TEXT"), null, true);
List<GenericValue> contentDataResourceViews = EntityQuery.use(delegator).from("ContentDataResourceView").where("contentId", contentId, "drDataResourceTypeId", "ELECTRONIC_TEXT").cache(true).queryList();
for (GenericValue contentDataResourceView : contentDataResourceViews) {
GenericValue ElectronicText = contentDataResourceView.getRelatedOne("ElectronicText", true);
if (UtilValidate.isNotEmpty(ElectronicText)) {
@@ -211,7 +211,7 @@ public class CatalogUrlFilter extends ContextFilter {
List<EntityCondition> conds = FastList.newInstance();
conds.add(EntityCondition.makeCondition("productId", productId));
conds.add(EntityUtil.getFilterByDateExpr());
List<GenericValue> productCategoryMembers = delegator.findList("ProductCategoryMember", EntityCondition.makeCondition(conds), UtilMisc.toSet("productCategoryId"), UtilMisc.toList("-fromDate"), null, true);
List<GenericValue> productCategoryMembers = EntityQuery.use(delegator).select("productCategoryId").from("ProductCategoryMember").where(conds).orderBy("-fromDate").cache(true).queryList();
if (UtilValidate.isNotEmpty(productCategoryMembers)) {
GenericValue productCategoryMember = EntityUtil.getFirst(productCategoryMembers);
productCategoryId = productCategoryMember.getString("productCategoryId");
@@ -236,7 +236,7 @@ public class CatalogUrlFilter extends ContextFilter {
List<EntityCondition> rolllupConds = FastList.newInstance();
rolllupConds.add(EntityCondition.makeCondition("productId", productId));
rolllupConds.add(EntityUtil.getFilterByDateExpr());
List<GenericValue> productCategoryMembers = delegator.findList("ProductCategoryMember", EntityCondition.makeCondition(rolllupConds), null, UtilMisc.toList("-fromDate"), null, true);
List<GenericValue> productCategoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember").where(rolllupConds).orderBy("-fromDate").cache(true).queryList();
for (GenericValue productCategoryMember : productCategoryMembers) {
String trailCategoryId = productCategoryMember.getString("productCategoryId");
if (trailCategoryIds.contains(trailCategoryId)) {
@@ -260,7 +260,7 @@ public class CatalogUrlFilter extends ContextFilter {
List<EntityCondition> rolllupConds = FastList.newInstance();
rolllupConds.add(EntityCondition.makeCondition("productCategoryId", parentProductCategoryId));
rolllupConds.add(EntityUtil.getFilterByDateExpr());
List<GenericValue> productCategoryRollups = delegator.findList("ProductCategoryRollup", EntityCondition.makeCondition(rolllupConds), null, UtilMisc.toList("-fromDate"), null, true);
List<GenericValue> productCategoryRollups = EntityQuery.use(delegator).from("ProductCategoryRollup").where(rolllupConds).orderBy("-fromDate").cache(true).queryList();
if (UtilValidate.isNotEmpty(productCategoryRollups)) {
// add only categories that belong to the top category to trail
for (GenericValue productCategoryRollup : productCategoryRollups) {
@@ -36,6 +36,7 @@ import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.util.EntityQuery;
/**
* ControlServlet.java - Master servlet for the web application.
@@ -84,7 +85,7 @@ public class CatalogUrlServlet 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(true).queryOne() != null) {
if (lastPathElement.startsWith("p_")) {
productId = lastPathElement.substring(2);
} else {
@@ -141,7 +141,7 @@ public class CategoryContentWrapper implements ContentWrapper {
}
}
List<GenericValue> categoryContentList = delegator.findByAnd("ProductCategoryContent", UtilMisc.toMap("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId), UtilMisc.toList("-fromDate"), true);
List<GenericValue> categoryContentList = EntityQuery.use(delegator).from("ProductCategoryContent").where("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId).orderBy("-fromDate").cache(true).queryList();
categoryContentList = EntityUtil.filterByDate(categoryContentList);
GenericValue categoryContent = EntityUtil.getFirst(categoryContentList);
if (categoryContent != null) {
@@ -105,7 +105,7 @@ public class CategoryServices {
List<GenericValue> productCategoryMembers;
try {
productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", categoryId).cache().queryOne();
productCategoryMembers = delegator.findByAnd(entityName, UtilMisc.toMap("productCategoryId", categoryId), orderByFields, true);
productCategoryMembers = EntityQuery.use(delegator).from(entityName).where("productCategoryId", categoryId).orderBy(orderByFields).cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logInfo(e, "Error finding previous/next product info: " + e.toString(), module);
return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError, "categoryservices.error_find_next_products", UtilMisc.toMap("errMessage", e.getMessage()), locale));
@@ -276,7 +276,7 @@ public class CategoryServices {
try {
String productStoreId = (String) context.get("productStoreId");
if (UtilValidate.isNotEmpty(productStoreId)) {
GenericValue productStore = delegator.findOne("ProductStore", UtilMisc.toMap("productStoreId", productStoreId), false);
GenericValue productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne();
if (productStore != null && "N".equals(productStore.getString("showOutOfStockProducts"))) {
filterOutOfStock = true;
}
@@ -288,7 +288,7 @@ public class CategoryServices {
if (productCategory != null) {
try {
if (useCacheForMembers) {
productCategoryMembers = delegator.findByAnd(entityName, UtilMisc.toMap("productCategoryId", productCategoryId), orderByFields, true);
productCategoryMembers = EntityQuery.use(delegator).from(entityName).where("productCategoryId", productCategoryId).orderBy(orderByFields).cache(true).queryList();
if (activeOnly) {
productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, true);
}
@@ -351,10 +351,8 @@ public class CategoryServices {
EntityCondition mainCond = EntityCondition.makeCondition(mainCondList, EntityOperator.AND);
// set distinct on
EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, false);
findOpts.setMaxRows(highIndex);
// using list iterator
EntityListIterator pli = delegator.find(entityName, mainCond, null, null, orderByFields, findOpts);
EntityListIterator pli = EntityQuery.use(delegator).from(entityName).where(mainCond).orderBy(orderByFields).cursorScrollInsensitive().maxRows(highIndex).queryIterator();
// get the partial list for this page
if (limitView) {
@@ -455,17 +453,16 @@ public class CategoryServices {
List<String> sortList = org.ofbiz.base.util.UtilMisc.toList("sequenceNum", "title");
try {
GenericValue category = delegator.findOne(entityName ,UtilMisc.toMap(primaryKeyName, productCategoryId), false);
GenericValue category = EntityQuery.use(delegator).from(entityName).where(primaryKeyName, productCategoryId).queryOne();
if (UtilValidate.isNotEmpty(category)) {
if (isCatalog.equals("true") && isCategoryType.equals("false")) {
CategoryWorker.getRelatedCategories(request, "ChildCatalogList", CatalogWorker.getCatalogTopCategoryId(request, productCategoryId), true);
childOfCats = EntityUtil.filterByDate((List<GenericValue>) request.getAttribute("ChildCatalogList"));
} else if(isCatalog.equals("false") && isCategoryType.equals("false")){
childOfCats = EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryRollupAndChild", UtilMisc.toMap(
"parentProductCategoryId", productCategoryId ), null, false));
childOfCats = EntityQuery.use(delegator).from("ProductCategoryRollupAndChild").where("parentProductCategoryId", productCategoryId).filterByDate().queryList();
} else {
childOfCats = EntityUtil.filterByDate(delegator.findByAnd("ProdCatalogCategory", UtilMisc.toMap("prodCatalogId", productCategoryId), null, false));
childOfCats = EntityQuery.use(delegator).from("ProdCatalogCategory").where("prodCatalogId", productCategoryId).filterByDate().queryList();
}
if (UtilValidate.isNotEmpty(childOfCats)) {
@@ -481,11 +478,10 @@ public class CategoryServices {
List<GenericValue> childList = null;
// Get the child list of chosen category
childList = EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap(
"parentProductCategoryId", catId), null, false));
childList = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", catId).filterByDate().queryList();
// Get the chosen category information for the categoryContentWrapper
GenericValue cate = delegator.findOne("ProductCategory" ,UtilMisc.toMap("productCategoryId",catId), false);
GenericValue cate = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId",catId).queryOne();
// If chosen category's child exists, then put the arrow before category icon
if (UtilValidate.isNotEmpty(childList)) {
@@ -90,7 +90,7 @@ public class CategoryWorker {
Collection<GenericValue> results = FastList.newInstance();
try {
Collection<GenericValue> allCategories = delegator.findList("ProductCategory", null, null, null, null, false);
Collection<GenericValue> allCategories = EntityQuery.use(delegator).from("ProductCategory").queryList();
for (GenericValue curCat: allCategories) {
Collection<GenericValue> parentCats = curCat.getRelated("CurrentProductCategoryRollup", null, null, true);
@@ -148,9 +148,7 @@ public class CategoryWorker {
List<GenericValue> rollups = null;
try {
rollups = delegator.findByAnd("ProductCategoryRollup",
UtilMisc.toMap("parentProductCategoryId", parentId),
UtilMisc.toList("sequenceNum"), true);
rollups = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", parentId).orderBy("sequenceNum").cache(true).queryList();
if (limitView) {
rollups = EntityUtil.filterByDate(rollups, true);
}
@@ -213,7 +211,7 @@ public class CategoryWorker {
Delegator delegator = category.getDelegator();
long count = 0;
try {
count = delegator.findCountByCondition("ProductCategoryMember", buildCountCondition("productCategoryId", category.getString("productCategoryId")), null, null);
count = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", category.getString("productCategoryId")).queryCount();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
@@ -225,7 +223,7 @@ public class CategoryWorker {
Delegator delegator = category.getDelegator();
long count = 0;
try {
count = delegator.findCountByCondition("ProductCategoryRollup", buildCountCondition("parentProductCategoryId", category.getString("productCategoryId")), null, null);
count = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", category.getString("productCategoryId")).queryCount();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
@@ -363,8 +361,11 @@ public class CategoryWorker {
if (productCategoryId == null) return false;
if (UtilValidate.isEmpty(productId)) return false;
List<GenericValue> productCategoryMembers = EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryMember",
UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId), null, true), true);
List<GenericValue> productCategoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember")
.where("productCategoryId", productCategoryId, "productId", productId)
.cache(true)
.filterByDate()
.queryList();
if (UtilValidate.isEmpty(productCategoryMembers)) {
//before giving up see if this is a variant product, and if so look up the virtual product and check it...
GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne();
@@ -451,8 +452,7 @@ public class CategoryWorker {
List<EntityCondition> rolllupConds = FastList.newInstance();
rolllupConds.add(EntityCondition.makeCondition("productCategoryId", parentProductCategoryId));
rolllupConds.add(EntityUtil.getFilterByDateExpr());
List<GenericValue> productCategoryRollups = delegator.findList("ProductCategoryRollup",
EntityCondition.makeCondition(rolllupConds), null, UtilMisc.toList("sequenceNum"), null, true);
List<GenericValue> productCategoryRollups = EntityQuery.use(delegator).from("ProductCategoryRollup").where(rolllupConds).orderBy("sequenceNum").cache(true).queryList();
if (UtilValidate.isNotEmpty(productCategoryRollups)) {
// add only categories that belong to the top category to trail
for (GenericValue productCategoryRollup : productCategoryRollups) {
@@ -162,9 +162,12 @@ public class ProductConfigItemContentWrapper implements java.io.Serializable {
}
}
List<GenericValue> productConfigItemContentList = delegator.findByAnd("ProdConfItemContent", UtilMisc.toMap("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId), UtilMisc.toList("-fromDate"), true);
productConfigItemContentList = EntityUtil.filterByDate(productConfigItemContentList);
GenericValue productConfigItemContent = EntityUtil.getFirst(productConfigItemContentList);
GenericValue productConfigItemContent = EntityQuery.use(delegator).from("ProdConfItemContent")
.where("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId)
.orderBy("-fromDate")
.cache(true)
.filterByDate()
.queryFirst();
if (productConfigItemContent != null) {
// when rendering the product config item content, always include the ProductConfigItem and ProdConfItemContent records that this comes from
Map<String, Object> inContext = FastMap.newInstance();
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;
import javolution.util.FastList;
@@ -35,6 +36,7 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.product.catalog.CatalogWorker;
import org.ofbiz.product.config.ProductConfigWrapper.ConfigItem;
import org.ofbiz.product.config.ProductConfigWrapper.ConfigOption;
@@ -210,7 +212,7 @@ public class ProductConfigWorker {
configItemId = ci.getConfigItemAssoc().getString("configItemId");
sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum");
try {
List<GenericValue> configs = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configItemId",configItemId,"sequenceNum", sequenceNum), null, false);
List<GenericValue> configs = EntityQuery.use(delegator).from("ProductConfigConfig").where("configItemId",configItemId,"sequenceNum", sequenceNum).queryList();
for (GenericValue productConfigConfig: configs) {
for (ConfigOption oneOption: selectedOptions) {
String configOptionId = oneOption.configOption.getString("configOptionId");
@@ -233,9 +235,9 @@ public class ProductConfigWorker {
for (GenericValue productConfigConfig: configsToCheck) {
String tempConfigId = productConfigConfig.getString("configId");
try {
List<GenericValue> tempResult = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId",tempConfigId), null, false);
List<GenericValue> tempResult = EntityQuery.use(delegator).from("ProductConfigConfig").where("configId",tempConfigId).queryList();
if (tempResult.size() == selectedOptionSize && configsToCheck.containsAll(tempResult)) {
List<GenericValue> configOptionProductOptions = delegator.findByAnd("ConfigOptionProductOption", UtilMisc.toMap("configId",tempConfigId), null, false);
List<GenericValue> configOptionProductOptions = EntityQuery.use(delegator).from("ConfigOptionProductOption").where("configId",tempConfigId).queryList();
if (UtilValidate.isNotEmpty(configOptionProductOptions)) {
// check for variant product equality
@@ -125,8 +125,7 @@ public class ProductConfigWrapper implements Serializable {
}
questions = FastList.newInstance();
if ("AGGREGATED".equals(product.getString("productTypeId")) || "AGGREGATED_SERVICE".equals(product.getString("productTypeId"))) {
List<GenericValue> questionsValues = delegator.findByAnd("ProductConfig", UtilMisc.toMap("productId", productId), UtilMisc.toList("sequenceNum"), false);
questionsValues = EntityUtil.filterByDate(questionsValues);
List<GenericValue> questionsValues = EntityQuery.use(delegator).from("ProductConfig").where("productId", productId).orderBy("sequenceNum").filterByDate().queryList();
Set<String> itemIds = FastSet.newInstance();
for (GenericValue questionsValue: questionsValues) {
ConfigItem oneQuestion = new ConfigItem(questionsValue);
@@ -137,7 +136,7 @@ public class ProductConfigWrapper implements Serializable {
itemIds.add(oneQuestion.getConfigItem().getString("configItemId"));
}
questions.add(oneQuestion);
List<GenericValue> configOptions = delegator.findByAnd("ProductConfigOption", UtilMisc.toMap("configItemId", oneQuestion.getConfigItemAssoc().getString("configItemId")), UtilMisc.toList("sequenceNum"), false);
List<GenericValue> configOptions = EntityQuery.use(delegator).from("ProductConfigOption").where("configItemId", oneQuestion.getConfigItemAssoc().getString("configItemId")).orderBy("sequenceNum").queryList();
for (GenericValue configOption: configOptions) {
ConfigOption option = new ConfigOption(delegator, dispatcher, configOption, oneQuestion, catalogId, webSiteId, currencyUomId, autoUserLogin);
oneQuestion.addOption(option);
@@ -151,7 +150,7 @@ public class ProductConfigWrapper implements Serializable {
//configure ProductConfigWrapper according to ProductConfigConfig entity
if (UtilValidate.isNotEmpty(configId)) {
this.configId = configId;
List<GenericValue> productConfigConfig = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId", configId), null, false);
List<GenericValue> productConfigConfig = EntityQuery.use(delegator).from("ProductConfigConfig").where("configId", configId).queryList();
if (UtilValidate.isNotEmpty(productConfigConfig)) {
for (GenericValue pcc: productConfigConfig) {
String configItemId = pcc.getString("configItemId");
@@ -64,11 +64,11 @@ public class ParametricSearch {
public static Map<String, List<GenericValue>> makeCategoryFeatureLists(String productCategoryId, Delegator delegator, int perTypeMaxSize) {
Map<String, Map<String, GenericValue>> productFeaturesByTypeMap = FastMap.newInstance();
try {
List<GenericValue> productFeatureCategoryAppls = delegator.findByAnd("ProductFeatureCategoryAppl", UtilMisc.toMap("productCategoryId", productCategoryId), null, true);
List<GenericValue> productFeatureCategoryAppls = EntityQuery.use(delegator).from("ProductFeatureCategoryAppl").where("productCategoryId", productCategoryId).cache(true).queryList();
productFeatureCategoryAppls = EntityUtil.filterByDate(productFeatureCategoryAppls, true);
if (productFeatureCategoryAppls != null) {
for (GenericValue productFeatureCategoryAppl: productFeatureCategoryAppls) {
List<GenericValue> productFeatures = delegator.findByAnd("ProductFeature", UtilMisc.toMap("productFeatureCategoryId", productFeatureCategoryAppl.get("productFeatureCategoryId")), null, true);
List<GenericValue> productFeatures = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureCategoryId", productFeatureCategoryAppl.get("productFeatureCategoryId")).cache(true).queryList();
for (GenericValue productFeature: productFeatures) {
String productFeatureTypeId = productFeature.getString("productFeatureTypeId");
Map<String, GenericValue> featuresByType = productFeaturesByTypeMap.get(productFeatureTypeId);
@@ -87,11 +87,11 @@ public class ParametricSearch {
}
try {
List<GenericValue> productFeatureCatGrpAppls = delegator.findByAnd("ProductFeatureCatGrpAppl", UtilMisc.toMap("productCategoryId", productCategoryId), null, true);
List<GenericValue> productFeatureCatGrpAppls = EntityQuery.use(delegator).from("ProductFeatureCatGrpAppl").where("productCategoryId", productCategoryId).cache(true).queryList();
productFeatureCatGrpAppls = EntityUtil.filterByDate(productFeatureCatGrpAppls, true);
if (productFeatureCatGrpAppls != null) {
for (GenericValue productFeatureCatGrpAppl: productFeatureCatGrpAppls) {
List<GenericValue> productFeatureGroupAppls = delegator.findByAnd("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", productFeatureCatGrpAppl.get("productFeatureGroupId")), null, true);
List<GenericValue> productFeatureGroupAppls = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId", productFeatureCatGrpAppl.get("productFeatureGroupId")).cache(true).queryList();
for (GenericValue productFeatureGroupAppl: productFeatureGroupAppls) {
GenericValue productFeature = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureId", productFeatureGroupAppl.get("productFeatureId")).cache().queryOne();
@@ -128,7 +128,7 @@ public class ParametricSearch {
Map<String, List<GenericValue>> productFeaturesByTypeMap = FastMap.newInstance();
try {
Set<String> typesWithOverflowMessages = FastSet.newInstance();
EntityListIterator productFeatureEli = delegator.find("ProductFeature", null, null, null, UtilMisc.toList("description"), null);
EntityListIterator productFeatureEli = EntityQuery.use(delegator).from("ProductFeature").orderBy("description").queryIterator();
GenericValue productFeature = null;
while ((productFeature = productFeatureEli.next()) != null) {
String productFeatureTypeId = productFeature.getString("productFeatureTypeId");
@@ -36,6 +36,7 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
@@ -93,7 +94,7 @@ public class ProductFeatureServices {
try {
// get all product features in this feature category
List<GenericValue> allFeatures = delegator.findByAnd(entityToSearch, UtilMisc.toMap(fieldToSearch, valueToSearch), orderBy, false);
List<GenericValue> allFeatures = EntityQuery.use(delegator).from(entityToSearch).where(fieldToSearch, valueToSearch).orderBy(orderBy).queryList();
if (entityToSearch.equals("ProductFeatureAndAppl") && productFeatureApplTypeId != null)
allFeatures = EntityUtil.filterByAnd(allFeatures, UtilMisc.toMap("productFeatureApplTypeId", productFeatureApplTypeId));
@@ -141,7 +142,7 @@ public class ProductFeatureServices {
* see if it has every single feature in the list of productFeatureAppls as a STANDARD_FEATURE. If so, then
* it qualifies and add it to the list of existingVariantProductIds.
*/
List<GenericValue> productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"), null, false));
List<GenericValue> productAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList();
for (GenericValue productAssoc: productAssocs) {
//for each associated product, if it has all standard features, display it's productId
@@ -153,7 +154,7 @@ public class ProductFeatureServices {
//Debug.logInfo("Using findByMap: " + findByMap);
List<GenericValue> standardProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", findByMap, null, false));
List<GenericValue> standardProductFeatureAndAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where(findByMap).filterByDate().queryList();
if (UtilValidate.isEmpty(standardProductFeatureAndAppls)) {
// Debug.logInfo("Does NOT have this standard feature");
hasAllFeatures = false;
@@ -412,8 +412,7 @@ public class FrameImage {
String frameDataResourceId = null;
try {
List<GenericValue> contentDataResources = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", frameContentId), null, false);
GenericValue contentDataResource = EntityUtil.getFirst(contentDataResources);
GenericValue contentDataResource = EntityQuery.use(delegator).from("ContentDataResourceView").where("contentId", frameContentId).queryFirst();
frameDataResourceId = contentDataResource.getString("dataResourceId");
} catch (Exception e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
@@ -29,6 +29,7 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
public class ImageManagementHelper {
@@ -40,14 +41,14 @@ public class ImageManagementHelper {
if (request == null) return internalImageUrl;
try {
Delegator delegator = (Delegator) request.getAttribute("delegator");
List<GenericValue> defaultImageList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "productContentTypeId", "DEFAULT_IMAGE", "statusId", "IM_APPROVED", "drIsPublic", "N"), UtilMisc.toList("sequenceNum"), false);
List<GenericValue> defaultImageList = EntityQuery.use(delegator).from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "DEFAULT_IMAGE", "statusId", "IM_APPROVED", "drIsPublic", "N").orderBy("sequenceNum").queryList();
if (UtilValidate.isNotEmpty(defaultImageList)) {
GenericValue productContent = EntityUtil.getFirst(defaultImageList);
if (UtilValidate.isNotEmpty(productContent.get("drObjectInfo"))) {
internalImageUrl = (String) productContent.get("drObjectInfo");
}
} else {
List<GenericValue> productContentList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "productContentTypeId", "IMAGE", "statusId", "IM_APPROVED", "drIsPublic", "N"), UtilMisc.toList("sequenceNum"), false);
List<GenericValue> productContentList = EntityQuery.use(delegator).from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "IMAGE", "statusId", "IM_APPROVED", "drIsPublic", "N").orderBy("sequenceNum").queryList();
if (UtilValidate.isNotEmpty(productContentList)) {
GenericValue productContent = EntityUtil.getFirst(productContentList);
if (UtilValidate.isNotEmpty(productContent.get("drObjectInfo"))) {
@@ -131,7 +131,7 @@ public class ImageManagementServices {
List<GenericValue> fileExtension = FastList.newInstance();
try {
fileExtension = delegator.findByAnd("FileExtension", UtilMisc.toMap("mimeTypeId", fileContentType ), null, false);
fileExtension = EntityQuery.use(delegator).from("FileExtension").where("mimeTypeId", fileContentType).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -543,7 +543,7 @@ public class ImageManagementServices {
List<GenericValue> fileExtensionThumb = FastList.newInstance();
try {
fileExtensionThumb = delegator.findByAnd("FileExtension", UtilMisc.toMap("mimeTypeId", fileContentType), null, false);
fileExtensionThumb = EntityQuery.use(delegator).from("FileExtension").where("mimeTypeId", fileContentType).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -795,8 +795,7 @@ public class ImageManagementServices {
String imageUrl = imageServerUrl + "/" + productId + "/" + filenameToUse;
try {
List<GenericValue> productContentList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "contentId", contentId, "productContentTypeId", "IMAGE"), null, false);
GenericValue productContent = EntityUtil.getFirst(productContentList);
GenericValue productContent = EntityQuery.use(delegator).from("ProductContentAndInfo").where("productId", productId, "contentId", contentId, "productContentTypeId", "IMAGE").queryFirst();
String dataResourceName = (String) productContent.get("drDataResourceName");
String mimeType = filenameToUse.substring(filenameToUse.lastIndexOf("."));
@@ -848,12 +847,12 @@ public class ImageManagementServices {
}
}
List<GenericValue> contentAssocList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentAssocTypeId", "IMAGE_THUMBNAIL"), null, false);
List<GenericValue> contentAssocList = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", contentId, "contentAssocTypeId", "IMAGE_THUMBNAIL").queryList();
if (contentAssocList.size() > 0) {
for (int i = 0; i < contentAssocList.size(); i++) {
GenericValue contentAssoc = contentAssocList.get(i);
List<GenericValue> dataResourceAssocList = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", contentAssoc.get("contentIdTo")), null, false);
List<GenericValue> dataResourceAssocList = EntityQuery.use(delegator).from("ContentDataResourceView").where("contentId", contentAssoc.get("contentIdTo")).queryList();
GenericValue dataResourceAssoc = EntityUtil.getFirst(dataResourceAssocList);
String drDataResourceNameAssoc = (String) dataResourceAssoc.get("drDataResourceName");
@@ -34,6 +34,7 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.LocalDispatcher;
@@ -79,19 +80,16 @@ public class ReplaceImage{
BufferedImage bufImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceNameReplace));
ImageIO.write(bufImg, "jpg", new File(imageServerPath + "/" + productId + "/" + dataResourceNameExist));
List<GenericValue> contentAssocReplaceList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentIdReplace, "contentAssocTypeId", "IMAGE_THUMBNAIL"), null, false);
List<GenericValue> contentAssocReplaceList = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", contentIdReplace, "contentAssocTypeId", "IMAGE_THUMBNAIL").queryList();
if (contentAssocReplaceList.size() > 0) {
for (int i = 0; i < contentAssocReplaceList.size(); i++) {
GenericValue contentAssocReplace = contentAssocReplaceList.get(i);
List<GenericValue> dataResourceAssocReplaceList = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", contentAssocReplace.get("contentIdTo")), null, false);
GenericValue dataResourceAssocReplace = EntityUtil.getFirst(dataResourceAssocReplaceList);
GenericValue dataResourceAssocReplace = EntityQuery.use(delegator).from("ContentDataResourceView").where("contentId", contentAssocReplace.get("contentIdTo")).queryFirst();
List<GenericValue> contentAssocExistList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentIdExist, "contentAssocTypeId", "IMAGE_THUMBNAIL", "mapKey", contentAssocReplace.get("mapKey")), null, false);
GenericValue contentAssocExist = EntityUtil.getFirst(contentAssocExistList);
GenericValue contentAssocExist = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", contentIdExist, "contentAssocTypeId", "IMAGE_THUMBNAIL", "mapKey", contentAssocReplace.get("mapKey")).queryFirst();
List<GenericValue> dataResourceAssocExistList = delegator.findByAnd("ContentDataResourceView", UtilMisc.toMap("contentId", contentAssocExist.get("contentIdTo")), null, false);
GenericValue dataResourceAssocExist = EntityUtil.getFirst(dataResourceAssocExistList);
GenericValue dataResourceAssocExist = EntityQuery.use(delegator).from("ContentDataResourceView").where("contentId", contentAssocExist.get("contentIdTo")).queryFirst();
if (UtilValidate.isNotEmpty(dataResourceAssocExist)) {
BufferedImage bufImgAssocReplace = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceAssocReplace.get("drDataResourceName")));
@@ -104,8 +102,7 @@ public class ReplaceImage{
}
}
List<GenericValue> productContentList = delegator.findByAnd("ProductContent", UtilMisc.toMap("productId", productId, "contentId", contentIdReplace, "productContentTypeId", "IMAGE"), null, false);
GenericValue productContent = EntityUtil.getFirst(productContentList);
GenericValue productContent = EntityQuery.use(delegator).from("ProductContent").where("productId", productId, "contentId", contentIdReplace, "productContentTypeId", "IMAGE").queryFirst();
if (productContent != null) {
Map<String, Object> productContentCtx = FastMap.newInstance();
@@ -226,8 +226,7 @@ public class InventoryServices {
Locale locale = (Locale) context.get("locale");
try {
inventoryTransfer = delegator.findOne("InventoryTransfer",
UtilMisc.toMap("inventoryTransferId", inventoryTransferId), false);
inventoryTransfer = EntityQuery.use(delegator).from("InventoryTransfer").where("inventoryTransferId", inventoryTransferId).queryOne();
inventoryItem = inventoryTransfer.getRelatedOne("InventoryItem", false);
destinationFacility = inventoryTransfer.getRelatedOne("ToFacility", false);
} catch (GenericEntityException e) {
@@ -339,8 +338,7 @@ public class InventoryServices {
Locale locale = (Locale) context.get("locale");
try {
inventoryTransfer = delegator.findOne("InventoryTransfer",
UtilMisc.toMap("inventoryTransferId", inventoryTransferId), false);
inventoryTransfer = EntityQuery.use(delegator).from("InventoryTransfer").where("inventoryTransferId", inventoryTransferId).queryOne();
if (UtilValidate.isEmpty(inventoryTransfer)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"ProductInventoryItemTransferNotFound",
@@ -429,8 +427,7 @@ public class InventoryServices {
// find all inventory items w/ a negative ATP
List<GenericValue> inventoryItems = null;
try {
EntityExpr ee = EntityCondition.makeCondition("availableToPromiseTotal", EntityOperator.LESS_THAN, BigDecimal.ZERO);
inventoryItems = delegator.findList("InventoryItem", ee, null, null, null, false);
inventoryItems = EntityQuery.use(delegator).from("InventoryItem").where(EntityCondition.makeCondition("availableToPromiseTotal", EntityOperator.LESS_THAN, BigDecimal.ZERO)).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Trouble getting inventory items", module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
@@ -454,8 +451,7 @@ public class InventoryServices {
exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_DELIVERED"));
exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_CANCELLED"));
EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(exprs, EntityOperator.AND);
shipmentAndItems = delegator.findList("ShipmentAndItem", ecl, null, UtilMisc.toList("estimatedArrivalDate"), null, false);
shipmentAndItems = EntityQuery.use(delegator).from("ShipmentAndItem").where(EntityCondition.makeCondition(exprs, EntityOperator.AND)).orderBy("estimatedArrivalDate").queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Problem getting ShipmentAndItem records", module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
@@ -593,8 +589,7 @@ public class InventoryServices {
List<GenericValue> orderItemShipGroups = null;
try {
orderItemShipGroups= delegator.findByAnd("OrderItemShipGroup",
UtilMisc.toMap("orderId", orderId), null, false);
orderItemShipGroups= EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Cannot get OrderItemShipGroups from orderId" + orderId, module);
}
@@ -603,12 +598,7 @@ public class InventoryServices {
List<GenericValue> orderItems = FastList.newInstance();
List<GenericValue> orderItemShipGroupAssoc = null;
try {
orderItemShipGroupAssoc =
delegator.findByAnd("OrderItemShipGroupAssoc",
UtilMisc.toMap("shipGroupSeqId",
orderItemShipGroup.get("shipGroupSeqId"),
"orderId",
orderId), null, false);
orderItemShipGroupAssoc = EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("shipGroupSeqId", orderItemShipGroup.get("shipGroupSeqId"), "orderId", orderId).queryList();
for (GenericValue assoc: orderItemShipGroupAssoc) {
GenericValue orderItem = assoc.getRelatedOne("OrderItem", false);
@@ -784,9 +774,9 @@ public class InventoryServices {
List<GenericValue> facilities = null;
try {
if (facilityId != null) {
facilities = delegator.findByAnd("Facility", UtilMisc.toMap("facilityId", facilityId), null, false);
facilities = EntityQuery.use(delegator).from("Facility").where("facilityId", facilityId).queryList();
} else {
facilities = delegator.findList("Facility", null, null, null, null, false);
facilities = EntityQuery.use(delegator).from("Facility").queryList();
}
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
@@ -921,7 +911,7 @@ public class InventoryServices {
List<GenericValue> productPrices = null;
try {
productPrices = delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId",productId), UtilMisc.toList("-fromDate"), true);
productPrices = EntityQuery.use(delegator).from("ProductPrice").where("productId",productId).orderBy("-fromDate").cache(true).queryList();
} catch (GenericEntityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -979,17 +969,16 @@ public class InventoryServices {
// Make a query against the sales usage view entity
EntityListIterator salesUsageIt = null;
try {
salesUsageIt = delegator.findListIteratorByCondition(salesUsageViewEntity,
EntityCondition.makeCondition(
UtilMisc.toList(
EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId),
EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId),
EntityCondition.makeCondition("statusId", EntityOperator.IN, UtilMisc.toList("ORDER_COMPLETED", "ORDER_APPROVED", "ORDER_HELD")),
EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER"),
EntityCondition.makeCondition("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, checkTime)
),
EntityOperator.AND),
null, null, null, null);
EntityCondition cond = EntityCondition.makeCondition(
UtilMisc.toList(
EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId),
EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId),
EntityCondition.makeCondition("statusId", EntityOperator.IN, UtilMisc.toList("ORDER_COMPLETED", "ORDER_APPROVED", "ORDER_HELD")),
EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER"),
EntityCondition.makeCondition("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, checkTime)
),
EntityOperator.AND);
salesUsageIt = EntityQuery.use(delegator).from(salesUsageViewEntity).where(cond).queryIterator();
} catch (GenericEntityException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
@@ -1017,16 +1006,15 @@ public class InventoryServices {
// Make a query against the production usage view entity
EntityListIterator productionUsageIt = null;
try {
productionUsageIt = delegator.findListIteratorByCondition(productionUsageViewEntity,
EntityCondition.makeCondition(
EntityCondition conditions = EntityCondition.makeCondition(
UtilMisc.toList(
EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId),
EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId),
EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_TASK"),
EntityCondition.makeCondition("actualCompletionDate", EntityOperator.GREATER_THAN_EQUAL_TO, checkTime)
),
EntityOperator.AND),
null, null, null, null);
EntityOperator.AND);
productionUsageIt = EntityQuery.use(delegator).from(productionUsageViewEntity).where(conditions).queryIterator();
} catch (GenericEntityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
@@ -36,6 +36,7 @@ import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityConditionList;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.util.EntityQuery;
public class InventoryWorker {
@@ -57,8 +58,10 @@ public class InventoryWorker {
EntityCondition.makeCondition("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED"));
purchaseOrderConditions.add(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER"));
purchaseOrderConditions.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId));
List<GenericValue> purchaseOrders = delegator.findList("OrderHeaderAndItems", EntityCondition.makeCondition(purchaseOrderConditions, EntityOperator.AND),
null, UtilMisc.toList("estimatedDeliveryDate DESC", "orderDate"), null, false);
List<GenericValue> purchaseOrders = EntityQuery.use(delegator).from("OrderHeaderAndItems")
.where(EntityCondition.makeCondition(purchaseOrderConditions, EntityOperator.AND))
.orderBy("estimatedDeliveryDate DESC", "orderDate")
.queryList();
return purchaseOrders;
} catch (GenericEntityException ex) {
Debug.logError("Unable to find outstanding purchase orders for product [" + productId + "] due to " + ex.getMessage() + " - returning null", module);
@@ -123,7 +126,7 @@ public class InventoryWorker {
Map<String, BigDecimal> results = FastMap.newInstance();
try {
List<GenericValue> orderedProducts = delegator.findList("OrderItemQuantityReportGroupByProduct", conditions, fieldsToSelect, null, null, false);
List<GenericValue> orderedProducts = EntityQuery.use(delegator).select(fieldsToSelect).from("OrderItemQuantityReportGroupByProduct").where(conditions).queryList();
for (GenericValue value: orderedProducts) {
results.put(value.getString("productId"), value.getBigDecimal("quantityOpen"));
}
@@ -123,7 +123,7 @@ public class PriceServices {
productStoreGroupId = productStore.getString("primaryStoreGroupId");
} else {
// no ProductStore.primaryStoreGroupId, try ProductStoreGroupMember
List<GenericValue> productStoreGroupMemberList = delegator.findByAnd("ProductStoreGroupMember", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNum", "-fromDate"), true);
List<GenericValue> productStoreGroupMemberList = EntityQuery.use(delegator).from("ProductStoreGroupMember").where("productStoreId", productStoreId).orderBy("sequenceNum", "-fromDate").cache(true).queryList();
productStoreGroupMemberList = EntityUtil.filterByDate(productStoreGroupMemberList, true);
if (productStoreGroupMemberList.size() > 0) {
GenericValue productStoreGroupMember = EntityUtil.getFirst(productStoreGroupMemberList);
@@ -176,7 +176,7 @@ public class PriceServices {
List<GenericValue> virtualProductPrices = null;
if (virtualProductId != null) {
try {
virtualProductPrices = delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", virtualProductId, "currencyUomId", currencyDefaultUomId, "productStoreGroupId", productStoreGroupId), UtilMisc.toList("-fromDate"), true);
virtualProductPrices = EntityQuery.use(delegator).from("ProductPrice").where("productId", virtualProductId, "currencyUomId", currencyDefaultUomId, "productStoreGroupId", productStoreGroupId).orderBy("-fromDate").cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "An error occurred while getting the product prices", module);
}
@@ -222,7 +222,7 @@ public class PriceServices {
// for prices, get all ProductPrice entities for this productId and currencyUomId
List<GenericValue> productPrices = null;
try {
productPrices = delegator.findList("ProductPrice", productPriceEc, null, UtilMisc.toList("-fromDate"), null, true);
productPrices = EntityQuery.use(delegator).from("ProductPrice").where(productPriceEc).orderBy("-fromDate").cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "An error occurred while getting the product prices", module);
}
@@ -238,8 +238,7 @@ public class PriceServices {
// ProductPrice entity.
if (UtilValidate.isNotEmpty(agreementId)) {
try {
List<GenericValue> agreementPrices = delegator.findByAnd("AgreementItemAndProductAppl", UtilMisc.toMap("agreementId", agreementId, "productId", productId, "currencyUomId", currencyDefaultUomId), null, false);
GenericValue agreementPriceValue = EntityUtil.getFirst(agreementPrices);
GenericValue agreementPriceValue = EntityQuery.use(delegator).from("AgreementItemAndProductAppl").where("agreementId", agreementId, "productId", productId, "currencyUomId", currencyDefaultUomId).queryFirst();
if (agreementPriceValue != null && agreementPriceValue.get("price") != null) {
defaultPriceValue = agreementPriceValue;
}
@@ -266,12 +265,12 @@ public class PriceServices {
//use the cache to find the variant with the lowest default price
try {
List<GenericValue> variantAssocList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate"), true));
List<GenericValue> variantAssocList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT").orderBy("-fromDate").cache(true).filterByDate().queryList();
BigDecimal minDefaultPrice = null;
List<GenericValue> variantProductPrices = null;
for (GenericValue variantAssoc: variantAssocList) {
String curVariantProductId = variantAssoc.getString("productIdTo");
List<GenericValue> curVariantPriceList = EntityUtil.filterByDate(delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", curVariantProductId), UtilMisc.toList("-fromDate"), true), nowTimestamp);
List<GenericValue> curVariantPriceList = EntityQuery.use(delegator).from("ProductPrice").where("productId", curVariantProductId).orderBy("-fromDate").cache(true).filterByDate(nowTimestamp).queryList();
List<GenericValue> tempDefaultPriceList = EntityUtil.filterByAnd(curVariantPriceList, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
GenericValue curDefaultPriceValue = EntityUtil.getFirst(tempDefaultPriceList);
if (curDefaultPriceValue != null) {
@@ -430,7 +429,7 @@ public class PriceServices {
quantityProductPriceRules = FastList.newInstance();
nonQuantityProductPriceRules = FastList.newInstance();
for (GenericValue productPriceRule: allProductPriceRules) {
List<GenericValue> productPriceCondList = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("productPriceRuleId", productPriceRule.get("productPriceRuleId")), null, true);
List<GenericValue> productPriceCondList = EntityQuery.use(delegator).from("ProductPriceCond").where("productPriceRuleId", productPriceRule.get("productPriceRuleId")).cache(true).queryList();
boolean foundQuantityInputParam = false;
// only consider a rule if all conditions except the quantity condition are true
@@ -655,7 +654,7 @@ public class PriceServices {
// by productCategoryId
// for we will always include any rules that go by category, shouldn't be too many to iterate through each time and will save on cache entries
// note that we always want to put the category, quantity, etc ones that find all rules with these conditions in separate cache lists so that they can be easily cleared
Collection<GenericValue> productCategoryIdConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_CAT_ID"), null, true);
Collection<GenericValue> productCategoryIdConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_PROD_CAT_ID").cache(true).queryList();
if (UtilValidate.isNotEmpty(productCategoryIdConds)) {
for (GenericValue productCategoryIdCond: productCategoryIdConds) {
productPriceRuleIds.add(productCategoryIdCond.getString("productPriceRuleId"));
@@ -663,7 +662,7 @@ public class PriceServices {
}
// by productFeatureId
Collection<GenericValue> productFeatureIdConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_FEAT_ID"), null, true);
Collection<GenericValue> productFeatureIdConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_PROD_FEAT_ID").cache(true).queryList();
if (UtilValidate.isNotEmpty(productFeatureIdConds)) {
for (GenericValue productFeatureIdCond: productFeatureIdConds) {
productPriceRuleIds.add(productFeatureIdCond.getString("productPriceRuleId"));
@@ -673,7 +672,7 @@ public class PriceServices {
// by quantity -- should we really do this one, ie is it necessary?
// we could say that all rules with quantity on them must have one of these other values
// but, no we'll do it the other way, any that have a quantity will always get compared
Collection<GenericValue> quantityConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_QUANTITY"), null, true);
Collection<GenericValue> quantityConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_QUANTITY").cache(true).queryList();
if (UtilValidate.isNotEmpty(quantityConds)) {
for (GenericValue quantityCond: quantityConds) {
productPriceRuleIds.add(quantityCond.getString("productPriceRuleId"));
@@ -681,7 +680,7 @@ public class PriceServices {
}
// by roleTypeId
Collection<GenericValue> roleTypeIdConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_ROLE_TYPE"), null, true);
Collection<GenericValue> roleTypeIdConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_ROLE_TYPE").cache(true).queryList();
if (UtilValidate.isNotEmpty(roleTypeIdConds)) {
for (GenericValue roleTypeIdCond: roleTypeIdConds) {
productPriceRuleIds.add(roleTypeIdCond.getString("productPriceRuleId"));
@@ -693,7 +692,7 @@ public class PriceServices {
// later: (by partyClassificationTypeId)
// by listPrice
Collection<GenericValue> listPriceConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_LIST_PRICE"), null, true);
Collection<GenericValue> listPriceConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_LIST_PRICE").cache(true).queryList();
if (UtilValidate.isNotEmpty(listPriceConds)) {
for (GenericValue listPriceCond: listPriceConds) {
productPriceRuleIds.add(listPriceCond.getString("productPriceRuleId"));
@@ -703,7 +702,7 @@ public class PriceServices {
// ------- These are all of them that DO depend on the current inputs -------
// by productId
Collection<GenericValue> productIdConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PRODUCT_ID", "condValue", productId), null, true);
Collection<GenericValue> productIdConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_PRODUCT_ID", "condValue", productId).cache(true).queryList();
if (UtilValidate.isNotEmpty(productIdConds)) {
for (GenericValue productIdCond: productIdConds) {
productPriceRuleIds.add(productIdCond.getString("productPriceRuleId"));
@@ -712,7 +711,7 @@ public class PriceServices {
// by virtualProductId, if not null
if (virtualProductId != null) {
Collection<GenericValue> virtualProductIdConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PRODUCT_ID", "condValue", virtualProductId), null, true);
Collection<GenericValue> virtualProductIdConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_PRODUCT_ID", "condValue", virtualProductId).cache(true).queryList();
if (UtilValidate.isNotEmpty(virtualProductIdConds)) {
for (GenericValue virtualProductIdCond: virtualProductIdConds) {
productPriceRuleIds.add(virtualProductIdCond.getString("productPriceRuleId"));
@@ -722,7 +721,7 @@ public class PriceServices {
// by prodCatalogId - which is optional in certain cases
if (UtilValidate.isNotEmpty(prodCatalogId)) {
Collection<GenericValue> prodCatalogIdConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_CLG_ID", "condValue", prodCatalogId), null, true);
Collection<GenericValue> prodCatalogIdConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_PROD_CLG_ID", "condValue", prodCatalogId).cache(true).queryList();
if (UtilValidate.isNotEmpty(prodCatalogIdConds)) {
for (GenericValue prodCatalogIdCond: prodCatalogIdConds) {
productPriceRuleIds.add(prodCatalogIdCond.getString("productPriceRuleId"));
@@ -732,7 +731,7 @@ public class PriceServices {
// by productStoreGroupId
if (UtilValidate.isNotEmpty(productStoreGroupId)) {
Collection<GenericValue> storeGroupConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_SGRP_ID", "condValue", productStoreGroupId), null, true);
Collection<GenericValue> storeGroupConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_PROD_SGRP_ID", "condValue", productStoreGroupId).cache(true).queryList();
if (UtilValidate.isNotEmpty(storeGroupConds)) {
for (GenericValue storeGroupCond: storeGroupConds) {
productPriceRuleIds.add(storeGroupCond.getString("productPriceRuleId"));
@@ -742,7 +741,7 @@ public class PriceServices {
// by webSiteId
if (UtilValidate.isNotEmpty(webSiteId)) {
Collection<GenericValue> webSiteIdConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_WEBSITE_ID", "condValue", webSiteId), null, true);
Collection<GenericValue> webSiteIdConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_WEBSITE_ID", "condValue", webSiteId).cache(true).queryList();
if (UtilValidate.isNotEmpty(webSiteIdConds)) {
for (GenericValue webSiteIdCond: webSiteIdConds) {
productPriceRuleIds.add(webSiteIdCond.getString("productPriceRuleId"));
@@ -752,7 +751,7 @@ public class PriceServices {
// by partyId
if (UtilValidate.isNotEmpty(partyId)) {
Collection<GenericValue> partyIdConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PARTY_ID", "condValue", partyId), null, true);
Collection<GenericValue> partyIdConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_PARTY_ID", "condValue", partyId).cache(true).queryList();
if (UtilValidate.isNotEmpty(partyIdConds)) {
for (GenericValue partyIdCond: partyIdConds) {
productPriceRuleIds.add(partyIdCond.getString("productPriceRuleId"));
@@ -761,7 +760,7 @@ public class PriceServices {
}
// by currencyUomId
Collection<GenericValue> currencyUomIdConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_CURRENCY_UOMID", "condValue", currencyUomId), null, true);
Collection<GenericValue> currencyUomIdConds = EntityQuery.use(delegator).from("ProductPriceCond").where("inputParamEnumId", "PRIP_CURRENCY_UOMID", "condValue", currencyUomId).cache(true).queryList();
if (UtilValidate.isNotEmpty(currencyUomIdConds)) {
for (GenericValue currencyUomIdCond: currencyUomIdConds) {
productPriceRuleIds.add(currencyUomIdCond.getString("productPriceRuleId"));
@@ -780,7 +779,7 @@ public class PriceServices {
// EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, UtilDateTime.nowTimestamp()));
// productPriceRules = delegator.findByOr("ProductPriceRule", pprExprs);
productPriceRules = delegator.findList("ProductPriceRule", null, null, null, null, true);
productPriceRules = EntityQuery.use(delegator).from("ProductPriceRule").cache(true).queryList();
if (productPriceRules == null) productPriceRules = FastList.newInstance();
}
@@ -830,7 +829,7 @@ public class PriceServices {
// check all conditions
boolean allTrue = true;
StringBuilder condsDescription = new StringBuilder();
List<GenericValue> productPriceConds = delegator.findByAnd("ProductPriceCond", UtilMisc.toMap("productPriceRuleId", productPriceRuleId), null, true);
List<GenericValue> productPriceConds = EntityQuery.use(delegator).from("ProductPriceCond").where("productPriceRuleId", productPriceRuleId).cache(true).queryList();
for (GenericValue productPriceCond: productPriceConds) {
totalConds++;
@@ -872,7 +871,7 @@ public class PriceServices {
isSale = true;
}
List<GenericValue> productPriceActions = delegator.findByAnd("ProductPriceAction", UtilMisc.toMap("productPriceRuleId", productPriceRuleId), null, true);
List<GenericValue> productPriceActions = EntityQuery.use(delegator).from("ProductPriceAction").where("productPriceRuleId", productPriceRuleId).cache(true).queryList();
for (GenericValue productPriceAction: productPriceActions) {
totalActions++;
@@ -1052,10 +1051,12 @@ public class PriceServices {
} else if ("PRIP_PROD_CAT_ID".equals(productPriceCond.getString("inputParamEnumId"))) {
// if a ProductCategoryMember exists for this productId and the specified productCategoryId
String productCategoryId = productPriceCond.getString("condValue");
List<GenericValue> productCategoryMembers = delegator.findByAnd("ProductCategoryMember",
UtilMisc.toMap("productId", productId, "productCategoryId", productCategoryId), null, true);
// and from/thru date within range
productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, nowTimestamp, null, null, true);
List<GenericValue> productCategoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember")
.where("productId", productId, "productCategoryId", productCategoryId)
.cache(true)
.filterByDate(nowTimestamp)
.queryList();
// then 0 (equals), otherwise 1 (not equals)
if (UtilValidate.isNotEmpty(productCategoryMembers)) {
compare = 0;
@@ -1067,10 +1068,8 @@ public class PriceServices {
// NOTE: this is important becuase of the common scenario where a virtual product is a member of a category but the variants will typically NOT be
// NOTE: we may want to parameterize this in the future, ie with an indicator on the ProductPriceCond entity
if (compare == 1 && UtilValidate.isNotEmpty(virtualProductId)) {
List<GenericValue> virtualProductCategoryMembers = delegator.findByAnd("ProductCategoryMember",
UtilMisc.toMap("productId", virtualProductId, "productCategoryId", productCategoryId), null, true);
// and from/thru date within range
virtualProductCategoryMembers = EntityUtil.filterByDate(virtualProductCategoryMembers, nowTimestamp, null, null, true);
List<GenericValue> virtualProductCategoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember").where("productId", virtualProductId, "productCategoryId", productCategoryId).cache(true).filterByDate(nowTimestamp).queryList();
if (UtilValidate.isNotEmpty(virtualProductCategoryMembers)) {
// we found a member record? great, then this condition is satisfied
compare = 0;
@@ -1081,10 +1080,8 @@ public class PriceServices {
// if a ProductFeatureAppl exists for this productId and the specified productFeatureId
String productFeatureId = productPriceCond.getString("condValue");
List<GenericValue> productFeatureAppls = delegator.findByAnd("ProductFeatureAppl",
UtilMisc.toMap("productId", productId, "productFeatureId", productFeatureId), null, true);
// and from/thru date within range
productFeatureAppls = EntityUtil.filterByDate(productFeatureAppls, nowTimestamp, null, null, true);
List<GenericValue> productFeatureAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productId, "productFeatureId", productFeatureId).cache(true).filterByDate(nowTimestamp).queryList();
// then 0 (equals), otherwise 1 (not equals)
if (UtilValidate.isNotEmpty(productFeatureAppls)) {
compare = 0;
@@ -1135,9 +1132,8 @@ public class PriceServices {
// look for PartyRelationship with
// partyRelationshipTypeId=GROUP_ROLLUP, the partyIdTo is
// the group member, so the partyIdFrom is the groupPartyId
List<GenericValue> partyRelationshipList = delegator.findByAnd("PartyRelationship", UtilMisc.toMap("partyIdFrom", groupPartyId, "partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP"), null, true);
// and from/thru date within range
partyRelationshipList = EntityUtil.filterByDate(partyRelationshipList, nowTimestamp, null, null, true);
List<GenericValue> partyRelationshipList = EntityQuery.use(delegator).from("PartyRelationship").where("partyIdFrom", groupPartyId, "partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP").cache(true).filterByDate(nowTimestamp).queryList();
// then 0 (equals), otherwise 1 (not equals)
if (UtilValidate.isNotEmpty(partyRelationshipList)) {
compare = 0;
@@ -1152,9 +1148,8 @@ public class PriceServices {
} else {
String partyClassificationGroupId = productPriceCond.getString("condValue");
// find any PartyClassification
List<GenericValue> partyClassificationList = delegator.findByAnd("PartyClassification", UtilMisc.toMap("partyId", partyId, "partyClassificationGroupId", partyClassificationGroupId), null, true);
// and from/thru date within range
partyClassificationList = EntityUtil.filterByDate(partyClassificationList, nowTimestamp, null, null, true);
List<GenericValue> partyClassificationList = EntityQuery.use(delegator).from("PartyClassification").where("partyId", partyId, "partyClassificationGroupId", partyClassificationGroupId).cache(true).filterByDate(nowTimestamp).queryList();
// then 0 (equals), otherwise 1 (not equals)
if (UtilValidate.isNotEmpty(partyClassificationList)) {
compare = 0;
@@ -1165,8 +1160,7 @@ public class PriceServices {
} else if ("PRIP_ROLE_TYPE".equals(productPriceCond.getString("inputParamEnumId"))) {
if (partyId != null) {
// if a PartyRole exists for this partyId and the specified roleTypeId
GenericValue partyRole = delegator.findOne("PartyRole",
UtilMisc.toMap("partyId", partyId, "roleTypeId", productPriceCond.getString("condValue")), true);
GenericValue partyRole = EntityQuery.use(delegator).from("PartyRole").where("partyId", partyId, "roleTypeId", productPriceCond.getString("condValue")).cache(true).queryOne();
// then 0 (equals), otherwise 1 (not equals)
if (partyRole != null) {
@@ -1210,8 +1204,7 @@ public class PriceServices {
}
private static int checkConditionPartyHierarchy(Delegator delegator, Timestamp nowTimestamp, String groupPartyId, String partyId) throws GenericEntityException{
List<GenericValue> partyRelationshipList = delegator.findByAnd("PartyRelationship", UtilMisc.toMap("partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP"), null, true);
partyRelationshipList = EntityUtil.filterByDate(partyRelationshipList, nowTimestamp, null, null, true);
List<GenericValue> partyRelationshipList = EntityQuery.use(delegator).from("PartyRelationship").where("partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP").cache(true).filterByDate(nowTimestamp).queryList();
for (GenericValue genericValue : partyRelationshipList) {
String partyIdFrom = (String)genericValue.get("partyIdFrom");
if (partyIdFrom.equals(groupPartyId)) {
@@ -1297,16 +1290,14 @@ public class PriceServices {
if (!validPriceFound) {
List<GenericValue> prices = null;
try {
prices = delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", productId,
"productPricePurposeId", "PURCHASE"), UtilMisc.toList("-fromDate"), false);
prices = EntityQuery.use(delegator).from("ProductPrice").where("productId", productId, "productPricePurposeId", "PURCHASE").orderBy("-fromDate").queryList();
// if no prices are found; find the prices of the parent product
if (UtilValidate.isEmpty(prices)) {
GenericValue parentProduct = ProductWorker.getParentProduct(productId, delegator);
if (parentProduct != null) {
String parentProductId = parentProduct.getString("productId");
prices = delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", parentProductId,
"productPricePurposeId", "PURCHASE"), UtilMisc.toList("-fromDate"), false);
prices = EntityQuery.use(delegator).from("ProductPrice").where("productId", parentProductId, "productPricePurposeId", "PURCHASE").orderBy("-fromDate").queryList();
}
}
} catch (GenericEntityException e) {
@@ -38,6 +38,7 @@ import org.ofbiz.content.data.DataResourceWorker;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
/**
@@ -117,7 +118,7 @@ public class KeywordIndex {
!"0".equals(UtilProperties.getPropertyValue("prodsearch", "index.weight.ProductFeatureAndAppl.abbrev", "0")) ||
!"0".equals(UtilProperties.getPropertyValue("prodsearch", "index.weight.ProductFeatureAndAppl.idCode", "0"))) {
// get strings from attributes and features
List<GenericValue> productFeatureAndAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId), null, false);
List<GenericValue> productFeatureAndAppls = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId).queryList();
for (GenericValue productFeatureAndAppl: productFeatureAndAppls) {
addWeightedKeywordSourceString(productFeatureAndAppl, "description", strings);
addWeightedKeywordSourceString(productFeatureAndAppl, "abbrev", strings);
@@ -128,7 +129,7 @@ public class KeywordIndex {
// ProductAttribute
if (!"0".equals(UtilProperties.getPropertyValue("prodsearch", "index.weight.ProductAttribute.attrName", "0")) ||
!"0".equals(UtilProperties.getPropertyValue("prodsearch", "index.weight.ProductAttribute.attrValue", "0"))) {
List<GenericValue> productAttributes = delegator.findByAnd("ProductAttribute", UtilMisc.toMap("productId", productId), null, false);
List<GenericValue> productAttributes = EntityQuery.use(delegator).from("ProductAttribute").where("productId", productId).queryList();
for (GenericValue productAttribute: productAttributes) {
addWeightedKeywordSourceString(productAttribute, "attrName", strings);
addWeightedKeywordSourceString(productAttribute, "attrValue", strings);
@@ -137,7 +138,7 @@ public class KeywordIndex {
// GoodIdentification
if (!"0".equals(UtilProperties.getPropertyValue("prodsearch", "index.weight.GoodIdentification.idValue", "0"))) {
List<GenericValue> goodIdentifications = delegator.findByAnd("GoodIdentification", UtilMisc.toMap("productId", productId), null, false);
List<GenericValue> goodIdentifications = EntityQuery.use(delegator).from("GoodIdentification").where("productId", productId).queryList();
for (GenericValue goodIdentification: goodIdentifications) {
addWeightedKeywordSourceString(goodIdentification, "idValue", strings);
}
@@ -146,8 +147,7 @@ public class KeywordIndex {
// Variant Product IDs
if ("Y".equals(product.getString("isVirtual"))) {
if (!"0".equals(UtilProperties.getPropertyValue("prodsearch", "index.weight.Variant.Product.productId", "0"))) {
List<GenericValue> variantProductAssocs = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"), null, false);
variantProductAssocs = EntityUtil.filterByDate(variantProductAssocs);
List<GenericValue> variantProductAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList();
for (GenericValue variantProductAssoc: variantProductAssocs) {
int weight = 1;
try {
@@ -172,7 +172,7 @@ public class KeywordIndex {
Debug.logWarning("Could not parse weight number: " + e.toString(), module);
}
List<GenericValue> productContentAndInfos = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "productContentTypeId", productContentTypeId), null, false);
List<GenericValue> productContentAndInfos = EntityQuery.use(delegator).from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", productContentTypeId).queryList();
for (GenericValue productContentAndInfo: productContentAndInfos) {
addWeightedDataResourceString(productContentAndInfo, weight, strings, delegator, product);
@@ -33,7 +33,6 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.StringUtil;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.GeneralRuntimeException;
import org.ofbiz.base.util.cache.UtilCache;
@@ -178,13 +177,11 @@ public class ProductContentWrapper implements ContentWrapper {
}
}
List<GenericValue> productContentList = delegator.findByAnd("ProductContent", UtilMisc.toMap("productId", productId, "productContentTypeId", productContentTypeId), UtilMisc.toList("-fromDate"), true);
productContentList = EntityUtil.filterByDate(productContentList);
List<GenericValue> productContentList = EntityQuery.use(delegator).from("ProductContent").where("productId", productId, "productContentTypeId", productContentTypeId).orderBy("-fromDate").cache(true).filterByDate().queryList();
if (UtilValidate.isEmpty(productContentList) && ("Y".equals(product.getString("isVariant")))) {
GenericValue parent = ProductWorker.getParentProduct(productId, delegator);
if (UtilValidate.isNotEmpty(parent)) {
productContentList = delegator.findByAnd("ProductContent", UtilMisc.toMap("productId", parent.get("productId"), "productContentTypeId", productContentTypeId), UtilMisc.toList("-fromDate"), true);
productContentList = EntityUtil.filterByDate(productContentList);
productContentList = EntityQuery.use(delegator).from("ProductContent").where("productId", parent.get("productId"), "productContentTypeId", productContentTypeId).orderBy("-fromDate").cache(true).filterByDate().queryList();
}
}
GenericValue productContent = EntityUtil.getFirst(productContentList);
@@ -120,10 +120,10 @@ public class ProductEvents {
beganTx = TransactionUtil.begin(7200);
try {
if (Debug.infoOn()) {
long count = delegator.findCountByCondition("Product", condition, null, null);
long count = EntityQuery.use(delegator).from("Product").where(condition).queryCount();
Debug.logInfo("========== Found " + count + " products to index ==========", module);
}
entityListIterator = delegator.find("Product", condition, null, null, null, null);
entityListIterator = EntityQuery.use(delegator).from("Product").where(condition).queryIterator();
} catch (GenericEntityException gee) {
Debug.logWarning(gee, gee.getMessage(), module);
Map<String, String> messageMap = UtilMisc.toMap("gee", gee.toString());
@@ -281,7 +281,7 @@ public class ProductEvents {
GenericValue productAssoc = null;
try {
productAssoc = delegator.findOne(tempProductAssoc.getEntityName(), tempProductAssoc.getPrimaryKey(), false);
productAssoc = EntityQuery.use(delegator).from(tempProductAssoc.getEntityName()).where(tempProductAssoc.getPrimaryKey()).queryOne();
} catch (GenericEntityException e) {
Debug.logWarning(e.getMessage(), module);
productAssoc = null;
@@ -354,7 +354,7 @@ public class ProductEvents {
GenericValue productAssoc = null;
try {
productAssoc = delegator.findOne(tempProductAssoc.getEntityName(), tempProductAssoc.getPrimaryKey(), false);
productAssoc = EntityQuery.use(delegator).from(tempProductAssoc.getEntityName()).where(tempProductAssoc.getPrimaryKey()).queryOne();
} catch (GenericEntityException e) {
Debug.logWarning(e.getMessage(), module);
productAssoc = null;
@@ -454,7 +454,7 @@ public class ProductEvents {
BigDecimal ntwt = parseBigDecimalForEntity(request.getParameter("~ntwt"));
BigDecimal grams = parseBigDecimalForEntity(request.getParameter("~grams"));
List<GenericValue> currentProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE"), null, false), true);
List<GenericValue> currentProductFeatureAndAppls = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE").filterByDate().queryList();
setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ozUS", "AMOUNT", floz);
setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ml", "AMOUNT", ml);
setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "WT_g", "AMOUNT", grams);
@@ -484,7 +484,7 @@ public class ProductEvents {
BigDecimal ntwt = parseBigDecimalForEntity(request.getParameter("~ntwt" + attribIdx));
BigDecimal grams = parseBigDecimalForEntity(request.getParameter("~grams" + attribIdx));
List<GenericValue> currentProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE"), null, false), true);
List<GenericValue> currentProductFeatureAndAppls = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE").filterByDate().queryList();
setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ozUS", "AMOUNT", floz);
setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ml", "AMOUNT", ml);
setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "WT_g", "AMOUNT", grams);
@@ -557,7 +557,7 @@ public class ProductEvents {
// NOTE: if numberSpecified is null then foundOneEqual will always be false, so need to check both
if (numberSpecified != null && !foundOneEqual) {
String productFeatureId = null;
List<GenericValue> existingProductFeatureList = delegator.findByAnd("ProductFeature", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId, "numberSpecified", numberSpecified, "uomId", uomId), null, false);
List<GenericValue> existingProductFeatureList = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureTypeId", productFeatureTypeId, "numberSpecified", numberSpecified, "uomId", uomId).queryList();
if (existingProductFeatureList.size() > 0) {
GenericValue existingProductFeature = existingProductFeatureList.get(0);
productFeatureId = existingProductFeature.getString("productFeatureId");
@@ -670,8 +670,7 @@ public class ProductEvents {
GenericValue productFeatureAndAppl = null;
Set<String> descriptionsForThisType = FastSet.newInstance();
List<GenericValue> productFeatureAndApplList = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId,
"productFeatureApplTypeId", productFeatureApplTypeId, "productFeatureTypeId", productFeatureTypeId), null, false), true);
List<GenericValue> productFeatureAndApplList = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureApplTypeId", productFeatureApplTypeId, "productFeatureTypeId", productFeatureTypeId).filterByDate().queryList();
if (productFeatureAndApplList.size() > 0) {
Iterator<GenericValue> productFeatureAndApplIter = productFeatureAndApplList.iterator();
while (productFeatureAndApplIter.hasNext()) {
@@ -723,7 +722,7 @@ public class ProductEvents {
// see if a feature exists with the type and description specified (if doesn't exist will create later)
String productFeatureId = null;
List<GenericValue> existingProductFeatureList = delegator.findByAnd("ProductFeature", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId, "description", description), null, false);
List<GenericValue> existingProductFeatureList = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureTypeId", productFeatureTypeId, "description", description).queryList();
if (existingProductFeatureList.size() > 0) {
GenericValue existingProductFeature = existingProductFeatureList.get(0);
productFeatureId = existingProductFeature.getString("productFeatureId");
@@ -748,8 +747,7 @@ public class ProductEvents {
}
// check to see if the productFeatureId is already attached to the virtual or variant, if not attach them...
List<GenericValue> specificProductFeatureApplList = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productId,
"productFeatureApplTypeId", productFeatureApplTypeId, "productFeatureId", productFeatureId), null, false), true);
List<GenericValue> specificProductFeatureApplList = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productId, "productFeatureApplTypeId", productFeatureApplTypeId, "productFeatureId", productFeatureId).filterByDate().queryList();
if (specificProductFeatureApplList.size() == 0) {
delegator.create("ProductFeatureAppl",
@@ -831,10 +829,7 @@ public class ProductEvents {
if (categoryIds != null) {
for (String categoryId: categoryIds) {
try {
List<GenericValue> catMembs = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap(
"productCategoryId", categoryId,
"productId", productId), null, false);
catMembs = EntityUtil.filterByDate(catMembs);
List<GenericValue> catMembs = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", categoryId, "productId", productId).filterByDate().queryList();
if (catMembs.size() == 0) {
delegator.create("ProductCategoryMember",
UtilMisc.toMap("productCategoryId", categoryId, "productId", productId, "fromDate", fromDate));
@@ -859,9 +854,7 @@ public class ProductEvents {
thruDate = UtilDateTime.nowTimestamp().toString();
}
try {
List<GenericValue> prodCatMembs = delegator.findByAnd("ProductCategoryMember",
UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId), null, false);
prodCatMembs = EntityUtil.filterByDate(prodCatMembs);
List<GenericValue> prodCatMembs = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", productCategoryId, "productId", productId).filterByDate().queryList();
if (prodCatMembs.size() > 0) {
// there is one to modify
GenericValue prodCatMemb = prodCatMembs.get(0);
@@ -890,10 +883,7 @@ public class ProductEvents {
try {
for (String productFeatureId: productFeatureIdArray) {
if (!productFeatureId.equals("~~any~~")) {
List<GenericValue> featureAppls = delegator.findByAnd("ProductFeatureAppl",
UtilMisc.toMap("productId", productId,
"productFeatureId", productFeatureId,
"productFeatureApplTypeId", productFeatureApplTypeId), null, false);
List<GenericValue> featureAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productId, "productFeatureId", productFeatureId, "productFeatureApplTypeId", productFeatureApplTypeId).queryList();
if (featureAppls.size() == 0) {
// no existing application for this
delegator.create("ProductFeatureAppl",
@@ -963,9 +953,7 @@ public class ProductEvents {
if ("Y".equals(productStore.getString("requireCustomerRole"))) {
List<GenericValue> productStoreRoleList = null;
try {
productStoreRoleList = delegator.findByAnd("ProductStoreRole", UtilMisc.toMap("productStoreId", productStore.get("productStoreId"),
"partyId", userLogin.get("partyId"), "roleTypeId", "CUSTOMER"), null, false);
productStoreRoleList = EntityUtil.filterByDate(productStoreRoleList, true);
productStoreRoleList = EntityQuery.use(delegator).from("ProductStoreRole").where("productStoreId", productStore.get("productStoreId"), "partyId", userLogin.get("partyId"), "roleTypeId", "CUSTOMER").filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Database error finding CUSTOMER ProductStoreRole records, required by the ProductStore with ID [" + productStore.getString("productStoreId") + "]", module);
}
@@ -1000,8 +988,7 @@ public class ProductEvents {
GenericValue productStoreEmail = null;
try {
productStoreEmail = delegator.findOne("ProductStoreEmailSetting",
UtilMisc.toMap("productStoreId", productStoreId, "emailType", emailType), false);
productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", emailType).queryOne();
} catch (GenericEntityException e) {
String errMsg = "Unable to get product store email setting for tell-a-friend: " + e.toString();
Debug.logError(e, errMsg, module);
@@ -172,9 +172,8 @@ public class ProductPromoContentWrapper implements ContentWrapper {
List<EntityExpr> exprs = new ArrayList<EntityExpr>();
exprs.add(EntityCondition.makeCondition("productPromoId", EntityOperator.EQUALS, productPromoId));
exprs.add(EntityCondition.makeCondition("productPromoContentTypeId", EntityOperator.EQUALS, productPromoContentTypeId));
List<String> orderBy = UtilMisc.toList("-fromDate");
List<GenericValue> productPromoContentList = delegator.findList("ProductPromoContent", EntityCondition.makeCondition(exprs, EntityOperator.AND), null, orderBy, null, true);
List<GenericValue> productPromoContentList = EntityQuery.use(delegator).from("ProductPromoContent").where(EntityCondition.makeCondition(exprs, EntityOperator.AND)).orderBy("-fromDate").cache(true).queryList();
GenericValue productPromoContent = null;
if (UtilValidate.isNotEmpty(productPromoContentList)) {
productPromoContent = EntityUtil.getFirst(EntityUtil.filterByDate(productPromoContentList));
@@ -122,7 +122,7 @@ public class ProductSearch {
// now find all sub-categories, filtered by effective dates, and call this routine for them
try {
List<GenericValue> productCategoryRollupList = delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap("parentProductCategoryId", productCategoryId), null, true);
List<GenericValue> productCategoryRollupList = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", productCategoryId).cache(true).queryList();
for (GenericValue productCategoryRollup: productCategoryRollupList) {
String subProductCategoryId = productCategoryRollup.getString("productCategoryId");
if (productCategoryIdSet.contains(subProductCategoryId)) {
@@ -662,21 +662,23 @@ public class ProductSearch {
}
dynamicViewEntity.addAlias("PROD", "mainProductId", "productId", null, null, Boolean.valueOf(productIdGroupBy), null);
EntityCondition whereCondition = EntityCondition.makeCondition(entityConditionList, EntityOperator.AND);
EntityFindOptions efo = new EntityFindOptions();
efo.setDistinct(true);
efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE);
if (maxResults != null) {
int queryMaxResults = maxResults;
if (resultOffset != null) {
queryMaxResults += resultOffset - 1;
}
efo.setMaxRows(queryMaxResults);
}
EntityListIterator eli = null;
try {
eli = delegator.findListIteratorByCondition(dynamicViewEntity, whereCondition, null, fieldsToSelect, orderByList, efo);
int queryMaxResults = 0;
if (maxResults != null) {
queryMaxResults = maxResults;
if (resultOffset != null) {
queryMaxResults += resultOffset - 1;
}
}
eli = EntityQuery.use(delegator).select(UtilMisc.toSet(fieldsToSelect))
.from(dynamicViewEntity).where(entityConditionList)
.orderBy(orderByList)
.distinct(true)
.maxRows(queryMaxResults)
.cursorScrollInsensitive()
.queryIterator();
} catch (GenericEntityException e) {
Debug.logError(e, "Error in product search", module);
return null;
@@ -43,6 +43,7 @@ import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.transaction.GenericTransactionException;
import org.ofbiz.entity.transaction.TransactionUtil;
import org.ofbiz.entity.util.EntityListIterator;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.product.product.ProductSearch.ProductSearchContext;
import org.ofbiz.product.product.ProductSearch.ResultSortOrder;
@@ -143,7 +144,7 @@ public class ProductSearchEvents {
while ((searchResultView = eli.next()) != null) {
String productId = searchResultView.getString("mainProductId");
//get all tuples that match product and category
List<GenericValue> pcmList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId), null, false);
List<GenericValue> pcmList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", productCategoryId, "productId", productId).queryList();
//set those thrudate to that specificed maybe remove then add new one
for (GenericValue pcm: pcmList) {
@@ -413,15 +414,11 @@ public class ProductSearchEvents {
String productId = searchResultView.getString("mainProductId");
productMap.put("productId", productId);
List<GenericValue> productFeaturesCustomRaw = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureTypeId", "HAZMAT"), null, false);
List<GenericValue> productFeaturesCustom = EntityUtil.filterByDate(productFeaturesCustomRaw);
productMap.put("productFeatureCustom", EntityUtil.getFirst(productFeaturesCustom));
productMap.put("productFeatureCustom", EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureTypeId", "HAZMAT").filterByDate().queryFirst());
List<GenericValue> productCategoriesRaw = delegator.findByAnd("ProductCategoryAndMember", UtilMisc.toMap("productId", productId), null, false);
List<GenericValue> productCategories = EntityUtil.filterByDate(productCategoriesRaw);
List<GenericValue> productCategories = EntityQuery.use(delegator).from("ProductCategoryAndMember").where("productId", productId).filterByDate().queryList();
productMap.put("productCategories", productCategories);
List<GenericValue> productFeaturesRaw = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId), null, false);
List<GenericValue> productFeatures = EntityUtil.filterByDate(productFeaturesRaw);
List<GenericValue> productFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId).filterByDate().queryList();
productMap.put("productFeatures", productFeatures);
productExportList.add(productMap);
}
@@ -53,6 +53,7 @@ import org.ofbiz.entity.model.DynamicViewEntity;
import org.ofbiz.entity.model.ModelKeyMap;
import org.ofbiz.entity.util.EntityFindOptions;
import org.ofbiz.entity.util.EntityListIterator;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.product.catalog.CatalogWorker;
import org.ofbiz.product.category.CategoryWorker;
@@ -400,8 +401,7 @@ public class ProductSearchSession {
if (keywords.size() > 0) {
List<GenericValue> productStoreKeywordOvrdList = null;
try {
productStoreKeywordOvrdList = delegator.findByAnd("ProductStoreKeywordOvrd", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("-fromDate"), true);
productStoreKeywordOvrdList = EntityUtil.filterByDate(productStoreKeywordOvrdList, true);
productStoreKeywordOvrdList = EntityQuery.use(delegator).from("ProductStoreKeywordOvrd").where("productStoreId", productStoreId).orderBy("-fromDate").cache(true).filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Error reading ProductStoreKeywordOvrd list, not doing keyword override", module);
}
@@ -930,11 +930,16 @@ public class ProductSearchSession {
addOnTopProdCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, now)));
addOnTopProdCondList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN, now));
addOnTopProdCondList.add(EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, addOnTopProdCategoryId));
EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true);
findOpts.setMaxRows(highIndex);
EntityListIterator pli = null;
try {
pli = delegator.find("ProductCategoryMember", EntityCondition.makeCondition(addOnTopProdCondList, EntityOperator.AND), null, UtilMisc.toSet("productId", "sequenceNum"), UtilMisc.toList("sequenceNum"), findOpts);
pli = EntityQuery.use(delegator).select(UtilMisc.toSet("productId", "sequenceNum"))
.from("ProductCategoryMember")
.where(addOnTopProdCondList)
.orderBy("sequenceNum")
.cursorScrollInsensitive()
.distinct()
.maxRows(highIndex)
.queryIterator();
addOnTopProductCategoryMembers = pli.getPartialList(lowIndex, viewSize);
addOnTopListSize = addOnTopProductCategoryMembers.size();
for (GenericValue alwaysAddProductCategoryMember: addOnTopProductCategoryMembers) {
@@ -1219,7 +1224,6 @@ public class ProductSearchSession {
DynamicViewEntity dynamicViewEntity = productSearchContext.dynamicViewEntity;
List<EntityCondition> entityConditionList = productSearchContext.entityConditionList;
List<String> fieldsToSelect = FastList.newInstance();
dynamicViewEntity.addMemberEntity("PFAC", "ProductFeatureAppl");
dynamicViewEntity.addAlias("PFAC", "pfacProductFeatureId", "productFeatureId", null, null, Boolean.TRUE, null);
@@ -1227,8 +1231,6 @@ public class ProductSearchSession {
dynamicViewEntity.addAlias("PFAC", "pfacThruDate", "thruDate", null, null, null, null);
dynamicViewEntity.addAlias("PFAC", "featureCount", "productId", null, null, null, "count-distinct");
dynamicViewEntity.addViewLink("PROD", "PFAC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId"));
fieldsToSelect.add("pfacProductFeatureId");
fieldsToSelect.add("featureCount");
entityConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("pfacThruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("pfacThruDate", EntityOperator.GREATER_THAN, UtilDateTime.nowTimestamp())));
entityConditionList.add(EntityCondition.makeCondition("pfacFromDate", EntityOperator.LESS_THAN, UtilDateTime.nowTimestamp()));
@@ -1236,18 +1238,17 @@ public class ProductSearchSession {
dynamicViewEntity.addAlias("PFC", "pfcProductFeatureTypeId", "productFeatureTypeId", null, null, Boolean.TRUE, null);
dynamicViewEntity.addAlias("PFC", "pfcDescription", "description", null, null, Boolean.TRUE, null);
dynamicViewEntity.addViewLink("PFAC", "PFC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productFeatureId"));
fieldsToSelect.add("pfcDescription");
fieldsToSelect.add("pfcProductFeatureTypeId");
entityConditionList.add(EntityCondition.makeCondition("pfcProductFeatureTypeId", EntityOperator.EQUALS, productFeatureTypeId));
EntityCondition whereCondition = EntityCondition.makeCondition(entityConditionList, EntityOperator.AND);
EntityFindOptions efo = new EntityFindOptions();
efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE);
EntityListIterator eli = null;
try {
eli = delegator.findListIteratorByCondition(dynamicViewEntity, whereCondition, null, fieldsToSelect, productSearchContext.orderByList, efo);
eli = EntityQuery.use(delegator)
.select(UtilMisc.toSet("pfacProductFeatureId", "featureCount", "pfcDescription", "pfcProductFeatureTypeId"))
.from(dynamicViewEntity)
.where(entityConditionList)
.orderBy(productSearchContext.orderByList)
.cursorScrollInsensitive()
.queryIterator();
} catch (GenericEntityException e) {
Debug.logError(e, "Error in product search", module);
return null;
@@ -1318,14 +1319,14 @@ public class ProductSearchSession {
entityConditionList.add(EntityCondition.makeCondition("ppcPrice", EntityOperator.LESS_THAN_EQUAL_TO, priceHigh));
entityConditionList.add(EntityCondition.makeCondition("ppcProductPriceTypeId", EntityOperator.EQUALS, "LIST_PRICE"));
EntityCondition whereCondition = EntityCondition.makeCondition(entityConditionList, EntityOperator.AND);
EntityFindOptions efo = new EntityFindOptions();
efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE);
EntityListIterator eli = null;
try {
eli = delegator.findListIteratorByCondition(dynamicViewEntity, whereCondition, null, fieldsToSelect, productSearchContext.orderByList, efo);
eli = EntityQuery.use(delegator).select(UtilMisc.toSet(fieldsToSelect))
.from(dynamicViewEntity)
.where(entityConditionList)
.orderBy(productSearchContext.orderByList)
.cursorScrollInsensitive()
.queryIterator();
} catch (GenericEntityException e) {
Debug.logError(e, "Error in product search", module);
return 0;
@@ -1384,14 +1385,14 @@ public class ProductSearchSession {
ProductSearch.getAllSubCategoryIds(productCategoryId, productCategoryIdSet, delegator, productSearchContext.nowTimestamp);
entityConditionList.add(EntityCondition.makeCondition("pcmcProductCategoryId", EntityOperator.IN, productCategoryIdSet));
EntityCondition whereCondition = EntityCondition.makeCondition(entityConditionList, EntityOperator.AND);
EntityFindOptions efo = new EntityFindOptions();
efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE);
EntityListIterator eli = null;
try {
eli = delegator.findListIteratorByCondition(dynamicViewEntity, whereCondition, null, fieldsToSelect, productSearchContext.orderByList, efo);
eli = EntityQuery.use(delegator).select(UtilMisc.toSet(fieldsToSelect))
.from(dynamicViewEntity)
.where(entityConditionList)
.orderBy(productSearchContext.orderByList)
.cursorScrollInsensitive()
.queryIterator();
} catch (GenericEntityException e) {
Debug.logError(e, "Error in product search", module);
return 0;
@@ -165,9 +165,7 @@ public class ProductServices {
Set<String> featureSet = new LinkedHashSet<String>();
try {
Map<String, String> fields = UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", productFeatureApplTypeId);
List<String> order = UtilMisc.toList("sequenceNum", "productFeatureTypeId");
List<GenericValue> features = delegator.findByAnd("ProductFeatureAndAppl", fields, order, true);
List<GenericValue> features = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureApplTypeId", productFeatureApplTypeId).orderBy("sequenceNum", "productFeatureTypeId").cache(true).queryList();
for (GenericValue v: features) {
featureSet.add(v.getString("productFeatureTypeId"));
}
@@ -297,11 +295,7 @@ public class ProductServices {
// Make the selectable feature list
List<GenericValue> selectableFeatures = null;
try {
Map<String, String> fields = UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "SELECTABLE_FEATURE");
List<String> sort = UtilMisc.toList("sequenceNum");
selectableFeatures = delegator.findByAnd("ProductFeatureAndAppl", fields, sort, true);
selectableFeatures = EntityUtil.filterByDate(selectableFeatures, true);
selectableFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureApplTypeId", "SELECTABLE_FEATURE").orderBy("sequenceNum").cache(true).filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
@@ -374,11 +368,10 @@ public class ProductServices {
try {
Map<String, String> fields = UtilMisc.toMap("productId", productId);
List<String> order = UtilMisc.toList("sequenceNum", "productFeatureTypeId");
if (distinct != null) fields.put("productFeatureTypeId", distinct);
if (type != null) fields.put("productFeatureApplTypeId", type);
features = delegator.findByAnd("ProductFeatureAndAppl", fields, order, true);
features = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where(fields).orderBy("sequenceNum", "productFeatureTypeId").cache(true).queryList();
result.put("productFeatures", features);
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
} catch (GenericEntityException e) {
@@ -517,8 +510,7 @@ public class ProductServices {
EntityCondition.makeCondition("productId", productId),
EntityCondition.makeCondition("productIdTo", productId)
), EntityJoinOperator.OR);
cond = EntityCondition.makeCondition(cond, EntityCondition.makeCondition("productAssocTypeId", type));
productAssocs = delegator.findList("ProductAssoc", cond, null, orderBy, null, true);
productAssocs = EntityQuery.use(delegator).from("ProductAssoc").where(EntityCondition.makeCondition(cond, EntityCondition.makeCondition("productAssocTypeId", type))).orderBy(orderBy).cache(true).queryList();
} else {
if (productIdTo == null) {
productAssocs = product.getRelated("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", type), orderBy, true);
@@ -584,13 +576,13 @@ public class ProductServices {
List<GenericValue> features = null;
try {
Map<String, String> fields = UtilMisc.toMap("productId", thisItem, "productFeatureTypeId", orderKey,
"productFeatureApplTypeId", "STANDARD_FEATURE");
List<String> sort = UtilMisc.toList("sequenceNum");
// get the features and filter out expired dates
features = delegator.findByAnd("ProductFeatureAndAppl", fields, sort, true);
features = EntityUtil.filterByDate(features, true);
features = EntityQuery.use(delegator).from("ProductFeatureAndAppl")
.where("productId", thisItem, "productFeatureTypeId", orderKey, "productFeatureApplTypeId", "STANDARD_FEATURE")
.orderBy("sequenceNum")
.cache(true)
.filterByDate()
.queryList();
} catch (GenericEntityException e) {
throw new IllegalStateException("Problem reading relation: " + e.getMessage());
}
@@ -661,20 +653,19 @@ public class ProductServices {
List<GenericValue> features = null;
try {
Map<String, String> fields = UtilMisc.toMap("productId", productId, "productFeatureTypeId", feature,
"productFeatureApplTypeId", "STANDARD_FEATURE");
List<String> sort = UtilMisc.toList("sequenceNum", "description");
// get the features and filter out expired dates
features = delegator.findByAnd("ProductFeatureAndAppl", fields, sort, true);
features = EntityUtil.filterByDate(features, true);
features = EntityQuery.use(delegator).from("ProductFeatureAndAppl")
.where("productId", productId, "productFeatureTypeId", feature, "productFeatureApplTypeId", "STANDARD_FEATURE")
.orderBy("sequenceNum", "description")
.cache(true)
.filterByDate()
.queryList();
} catch (GenericEntityException e) {
throw new IllegalStateException("Problem reading relation: " + e.getMessage());
}
for (GenericValue featureAppl: features) {
try {
GenericValue product = delegator.findOne("Product",
UtilMisc.toMap("productId", productId), true);
GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache(true).queryOne();
tempSample.put(featureAppl.getString("description"), product);
} catch (GenericEntityException e) {
@@ -715,7 +706,7 @@ public class ProductServices {
return result;
}
// check if product exists
GenericValue variantProduct = delegator.findOne("Product",UtilMisc.toMap("productId", variantProductId), false);
GenericValue variantProduct = EntityQuery.use(delegator).from("Product").where("productId", variantProductId).queryOne();
boolean variantProductExists = (variantProduct != null);
if (variantProduct == null) {
//if product does not exist
@@ -847,7 +838,7 @@ public class ProductServices {
variantProductsById.put(variantProductId, variantProduct);
} else {
// is a GoodIdentification.idValue?
List<GenericValue> goodIdentificationList = delegator.findByAnd("GoodIdentification", UtilMisc.toMap("idValue", variantProductId), null, false);
List<GenericValue> goodIdentificationList = EntityQuery.use(delegator).from("GoodIdentification").where("idValue", variantProductId).queryList();
if (UtilValidate.isEmpty(goodIdentificationList)) {
// whoops, nothing found... return error
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
@@ -950,7 +941,7 @@ public class ProductServices {
// refresh the product so we can update it
GenericValue productToUpdate = null;
try {
productToUpdate = delegator.findOne("Product", product.getPrimaryKey(), false);
productToUpdate = EntityQuery.use(delegator).from("Product").where(product.getPrimaryKey()).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -1006,7 +997,7 @@ public class ProductServices {
List<GenericValue> fileExtension = FastList.newInstance();
try {
fileExtension = delegator.findByAnd("FileExtension", UtilMisc.toMap("mimeTypeId", (String) context.get("_uploadedFile_contentType")), null, false);
fileExtension = EntityQuery.use(delegator).from("FileExtension").where("mimeTypeId", (String) context.get("_uploadedFile_contentType")).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -1294,7 +1285,7 @@ public class ProductServices {
List<GenericValue> fileExtension = FastList.newInstance();
try {
fileExtension = delegator.findList("FileExtension", EntityCondition.makeCondition("mimeTypeId", EntityOperator.EQUALS, (String) context.get("_uploadedFile_contentType")), null, null, null, false);
fileExtension = EntityQuery.use(delegator).from("FileExtension").where("mimeTypeId", EntityOperator.EQUALS, (String) context.get("_uploadedFile_contentType")).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -74,7 +74,7 @@ public class ProductUtilServices {
EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.NOT_EQUAL, null),
EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp)
), EntityOperator.AND);
EntityListIterator eliOne = delegator.find("Product", conditionOne, null, null, null, null);
EntityListIterator eliOne = EntityQuery.use(delegator).from("Product").where(conditionOne).queryIterator();
GenericValue productOne = null;
int numSoFarOne = 0;
while ((productOne = eliOne.next()) != null) {
@@ -83,8 +83,10 @@ public class ProductUtilServices {
if (virtualProduct == null) {
continue;
}
List<GenericValue> passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", virtualProductId, "productIdTo", productOne.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), null, false);
passocList = EntityUtil.filterByDate(passocList);
List<GenericValue> passocList = EntityQuery.use(delegator).from("ProductAssoc")
.where("productId", virtualProductId, "productIdTo", productOne.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT")
.filterByDate()
.queryList();
if (passocList.size() > 0) {
for (GenericValue passoc: passocList) {
passoc.set("thruDate", nowTimestamp);
@@ -104,12 +106,11 @@ public class ProductUtilServices {
EntityCondition.makeCondition("isVirtual", EntityOperator.EQUALS, "Y"),
EntityCondition.makeCondition(EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp))
), EntityOperator.AND);
EntityListIterator eli = delegator.find("Product", condition, null, null, null, null);
EntityListIterator eli = EntityQuery.use(delegator).from("Product").where(condition).queryIterator();
GenericValue product = null;
int numSoFar = 0;
while ((product = eli.next()) != null) {
List<GenericValue> passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), null, false);
passocList = EntityUtil.filterByDate(passocList);
List<GenericValue> passocList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList();
if (passocList.size() == 0) {
product.set("salesDiscontinuationDate", nowTimestamp);
delegator.store(product);
@@ -143,12 +144,12 @@ public class ProductUtilServices {
EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.NOT_EQUAL, null),
EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp)
), EntityOperator.AND);
EntityListIterator eli = delegator.find("Product", condition, null, null, null, null);
EntityListIterator eli = EntityQuery.use(delegator).from("Product").where(condition).queryIterator();
GenericValue product = null;
int numSoFar = 0;
while ((product = eli.next()) != null) {
String productId = product.getString("productId");
List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productId", productId), null, false);
List<GenericValue> productCategoryMemberList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productId", productId).queryList();
if (productCategoryMemberList.size() > 0) {
for (GenericValue productCategoryMember: productCategoryMemberList) {
// coded this way rather than a removeByAnd so it can be easily changed...
@@ -192,11 +193,11 @@ public class ProductUtilServices {
EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)
), EntityOperator.AND);
EntityCondition havingCond = EntityCondition.makeCondition("productIdCount", EntityOperator.GREATER_THAN, Long.valueOf(1));
EntityListIterator eli = delegator.findListIteratorByCondition(dve, condition, havingCond, UtilMisc.toList("productId", "productCategoryId", "productIdCount"), null, null);
EntityListIterator eli = EntityQuery.use(delegator).select("productId", "productCategoryId", "productIdCount").from(dve).where(condition).having(havingCond).queryIterator();
GenericValue pcm = null;
int numSoFar = 0;
while ((pcm = eli.next()) != null) {
List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productId", pcm.get("productId"), "productCategoryId", pcm.get("productCategoryId")), null, false);
List<GenericValue> productCategoryMemberList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productId", pcm.get("productId"), "productCategoryId", pcm.get("productCategoryId")).queryList();
if (productCategoryMemberList.size() > 1) {
// remove all except the first...
productCategoryMemberList.remove(0);
@@ -251,7 +252,10 @@ public class ProductUtilServices {
EntityCondition.makeCondition(EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.GREATER_THAN, nowTimestamp))
), EntityOperator.AND);
EntityCondition havingCond = EntityCondition.makeCondition("productIdToCount", EntityOperator.EQUALS, Long.valueOf(1));
EntityListIterator eliOne = delegator.findListIteratorByCondition(dve, condition, havingCond, UtilMisc.toList("productId", "productIdToCount"), null, null);
EntityListIterator eliOne = EntityQuery.use(delegator).select("productId", "productIdToCount").from(dve)
.where(condition)
.having(havingCond)
.queryIterator();
List<GenericValue> valueList = eliOne.getCompleteList();
eliOne.close();
@@ -261,8 +265,7 @@ public class ProductUtilServices {
for (GenericValue value: valueList) {
// has only one variant period, is it valid? should already be discontinued if not
String productId = value.getString("productId");
List<GenericValue> paList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"), null, false);
paList = EntityUtil.filterByDate(paList);
List<GenericValue> paList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList();
// verify the query; tested on a bunch, looks good
if (paList.size() != 1) {
Debug.logInfo("Virtual product with ID " + productId + " should have 1 assoc, has " + paList.size(), module);
@@ -286,7 +289,10 @@ public class ProductUtilServices {
EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp),
EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp))
), EntityOperator.AND);
EntityListIterator eliMulti = delegator.findListIteratorByCondition(dve, conditionWithDates, havingCond, UtilMisc.toList("productId", "productIdToCount"), null, null);
EntityListIterator eliMulti = EntityQuery.use(delegator).select("productId", "productIdToCount").from(dve)
.where(conditionWithDates)
.having(havingCond)
.queryIterator();
List<GenericValue> valueMultiList = eliMulti.getCompleteList();
eliMulti.close();
@@ -297,7 +303,7 @@ public class ProductUtilServices {
// has only one valid variant
String productId = value.getString("productId");
List<GenericValue> paList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"), null, false));
List<GenericValue> paList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList();
// verify the query; tested on a bunch, looks good
if (paList.size() != 1) {
@@ -349,7 +355,7 @@ public class ProductUtilServices {
GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
Debug.logInfo("Processing virtual product with one variant with ID: " + productId + " and name: " + product.getString("internalName"), module);
List<GenericValue> paList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"), null, false));
List<GenericValue> paList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList();
if (paList.size() > 1) {
Map<String, String> messageMap = UtilMisc.toMap("productId", productId);
errMsg = UtilProperties.getMessage(resourceError,"productutilservices.found_more_than_one_valid_variant_for_virtual_ID", messageMap, locale);
@@ -457,7 +463,7 @@ public class ProductUtilServices {
// can't just set to null, need to remove the value so it isn't a constraint in the query
//findValue.set("fromDate", null);
findValue.remove("fromDate");
List<GenericValue> existingValueList = EntityUtil.filterByDate(delegator.findByAnd(relatedEntityName, findValue, null, false), nowTimestamp);
List<GenericValue> existingValueList = EntityQuery.use(delegator).from(relatedEntityName).where(findValue).filterByDate(nowTimestamp).queryList();
if (existingValueList.size() > 0) {
if (test) {
Debug.logInfo("Found " + existingValueList.size() + " existing values for related entity name: " + relatedEntityName + ", not copying, findValue is: " + findValue, module);
@@ -467,7 +473,7 @@ public class ProductUtilServices {
newRelatedValue.set("fromDate", nowTimestamp);
}
if (delegator.findCountByCondition(relatedEntityName, EntityCondition.makeCondition(newRelatedValue.getPrimaryKey(), EntityOperator.AND), null, null) == 0) {
if (EntityQuery.use(delegator).from(relatedEntityName).where(EntityCondition.makeCondition(newRelatedValue.getPrimaryKey(), EntityOperator.AND)).queryCount() == 0) {
if (test) {
Debug.logInfo("Test mode, would create: " + newRelatedValue, module);
} else {
@@ -501,7 +507,7 @@ public class ProductUtilServices {
}
try {
EntityListIterator eli = delegator.find("Product", null, null, null, null, null);
EntityListIterator eli = EntityQuery.use(delegator).from("Product").queryIterator();
GenericValue product = null;
int numSoFar = 0;
while ((product = eli.next()) != null) {
@@ -513,7 +519,7 @@ public class ProductUtilServices {
if ("Y".equals(product.getString("isVirtual"))) {
// find the first variant, use it's ID for the names...
List<GenericValue> productAssocList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"), null, false));
List<GenericValue> productAssocList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList();
if (productAssocList.size() > 0) {
GenericValue productAssoc = EntityUtil.getFirst(productAssocList);
smallMap.put("productId", productAssoc.getString("productIdTo"));
@@ -557,7 +563,7 @@ public class ProductUtilServices {
String errMsg = null;
try {
EntityListIterator eli = delegator.find("Product", EntityCondition.makeCondition("isVirtual", EntityOperator.EQUALS, "Y"), null, null, null, null);
EntityListIterator eli = EntityQuery.use(delegator).from("Product").where("isVirtual", "Y").queryIterator();
GenericValue product = null;
int numSoFar = 0;
while ((product = eli.next()) != null) {
@@ -654,7 +660,7 @@ while (allCatIter.hasNext()) {
}
// do sub-categories first so all feature groups will be in place
List<GenericValue> subCategoryList = delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap("parentProductCategoryId", productCategoryId), null, false);
List<GenericValue> subCategoryList = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", productCategoryId).queryList();
if (doSubCategories) {
for (GenericValue productCategoryRollup: subCategoryList) {
attachProductFeaturesToCategory(productCategoryRollup.getString("productCategoryId"), productFeatureTypeIdsToInclude, productFeatureTypeIdsToExclude, delegator, true, nowTimestamp);
@@ -663,7 +669,7 @@ while (allCatIter.hasNext()) {
// now get all features for this category and make associated feature groups
Map<String, Set<String>> productFeatureIdByTypeIdSetMap = FastMap.newInstance();
List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId), null, false);
List<GenericValue> productCategoryMemberList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", productCategoryId).queryList();
for (GenericValue productCategoryMember: productCategoryMemberList) {
String productId = productCategoryMember.getString("productId");
EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(
@@ -671,7 +677,7 @@ while (allCatIter.hasNext()) {
EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp),
EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp))
), EntityOperator.AND);
EntityListIterator productFeatureAndApplEli = delegator.find("ProductFeatureAndAppl", condition, null, null, null, null);
EntityListIterator productFeatureAndApplEli = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where(condition).queryIterator();
GenericValue productFeatureAndAppl = null;
while ((productFeatureAndAppl = productFeatureAndApplEli.next()) != null) {
String productFeatureId = productFeatureAndAppl.getString("productFeatureId");
@@ -721,7 +727,7 @@ while (allCatIter.hasNext()) {
EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp),
EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp))
), EntityOperator.AND);
if (delegator.findCountByCondition("ProductFeatureGroupAppl", condition, null, null) == 0) {
if (EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where(condition).queryCount() == 0) {
// if no valid ones, create one
GenericValue productFeatureGroupAppl = delegator.makeValue("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", productFeatureGroupId, "productFeatureId", productFeatureId, "fromDate", nowTimestamp));
productFeatureGroupAppl.create();
@@ -737,7 +743,7 @@ while (allCatIter.hasNext()) {
EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp),
EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp))
), EntityOperator.AND);
EntityListIterator productFeatureCatGrpApplEli = delegator.find("ProductFeatureCatGrpAppl", condition, null, null, null, null);
EntityListIterator productFeatureCatGrpApplEli = EntityQuery.use(delegator).from("ProductFeatureCatGrpAppl").where(condition).queryIterator();
GenericValue productFeatureCatGrpAppl = null;
while ((productFeatureCatGrpAppl = productFeatureCatGrpApplEli.next()) != null) {
String productFeatureGroupId = productFeatureCatGrpAppl.getString("productFeatureGroupId");
@@ -747,7 +753,7 @@ while (allCatIter.hasNext()) {
EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp),
EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp))
), EntityOperator.AND);
if (delegator.findCountByCondition("ProductFeatureCatGrpAppl", checkCondition, null, null) == 0) {
if (EntityQuery.use(delegator).from("ProductFeatureCatGrpAppl").where(checkCondition).queryCount() == 0) {
// if no valid ones, create one
GenericValue productFeatureGroupAppl = delegator.makeValue("ProductFeatureCatGrpAppl", UtilMisc.toMap("productFeatureGroupId", productFeatureGroupId, "productCategoryId", productCategoryId, "fromDate", nowTimestamp));
productFeatureGroupAppl.create();
@@ -281,7 +281,7 @@ public class ProductWorker {
// find all selectable features on the virtual product that are also standard features on the variant
Set<GenericValue> distFeatures = FastSet.newInstance();
List<GenericValue> variantDistinguishingFeatures = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "DISTINGUISHING_FEAT"), null, true);
List<GenericValue> variantDistinguishingFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "DISTINGUISHING_FEAT").cache(true).queryList();
// Debug.logInfo("Found variantDistinguishingFeatures: " + variantDistinguishingFeatures, module);
for (GenericValue variantDistinguishingFeature: EntityUtil.filterByDate(variantDistinguishingFeatures)) {
@@ -290,7 +290,7 @@ public class ProductWorker {
distFeatures.add(dummyFeature);
}
List<GenericValue> virtualSelectableFeatures = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", virtualProductId, "productFeatureApplTypeId", "SELECTABLE_FEATURE"), null, true);
List<GenericValue> virtualSelectableFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", virtualProductId, "productFeatureApplTypeId", "SELECTABLE_FEATURE").cache(true).queryList();
// Debug.logInfo("Found virtualSelectableFeatures: " + virtualSelectableFeatures, module);
Set<String> virtualSelectableFeatureIds = FastSet.newInstance();
@@ -298,7 +298,7 @@ public class ProductWorker {
virtualSelectableFeatureIds.add(virtualSelectableFeature.getString("productFeatureId"));
}
List<GenericValue> variantStandardFeatures = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "STANDARD_FEATURE"), null, true);
List<GenericValue> variantStandardFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "STANDARD_FEATURE").cache(true).queryList();
// Debug.logInfo("Found variantStandardFeatures: " + variantStandardFeatures, module);
for (GenericValue variantStandardFeature: EntityUtil.filterByDate(variantStandardFeatures)) {
@@ -427,10 +427,14 @@ public class ProductWorker {
List <List<Map<String,String>>> featureTypeFeatures = FastList.newInstance();
try {
Delegator delegator = product.getDelegator();
Map<String,String> fields = UtilMisc.toMap("productId", product.getString("productId"), "productFeatureApplTypeId", "SELECTABLE_FEATURE");
List<String> order = UtilMisc.toList("productFeatureTypeId", "sequenceNum");
List<GenericValue> features = delegator.findByAnd("ProductFeatureAndAppl", fields, order, true);
List<GenericValue> featuresSorted = EntityUtil.orderBy(features, order);
//List<GenericValue> features = delegator.findByAnd("ProductFeatureAndAppl", fields, order, true);
//List<GenericValue> featuresSorted = EntityUtil.orderBy(features, order);
List<GenericValue> featuresSorted = EntityQuery.use(delegator)
.from("ProductFeatureAndAppl")
.where("productId", product.getString("productId"), "productFeatureApplTypeId", "SELECTABLE_FEATURE")
.orderBy("productFeatureTypeId", "sequenceNum")
.cache(true)
.queryList();
String oldType = null;
List<Map<String,String>> featureList = FastList.newInstance();
for (GenericValue productFeatureAppl: featuresSorted) {
@@ -440,8 +444,7 @@ public class ProductWorker {
featureTypeFeatures.add(featureList);
featureList = FastList.newInstance();
}
GenericValue productFeatureType = delegator.findOne("ProductFeatureType", UtilMisc.toMap("productFeatureTypeId",
productFeatureAppl.getString("productFeatureTypeId")), false);
GenericValue productFeatureType = EntityQuery.use(delegator).from("ProductFeatureType").where("productFeatureTypeId", productFeatureAppl.getString("productFeatureTypeId")).queryOne();
featureList.add(UtilMisc.<String, String>toMap("productFeatureTypeId", productFeatureAppl.getString("productFeatureTypeId"),
"description", productFeatureType.getString("description")));
oldType = productFeatureAppl.getString("productFeatureTypeId");
@@ -453,8 +456,10 @@ public class ProductWorker {
} else {
featureData.put("description", productFeatureAppl.getString("productFeatureId"));
}
List<GenericValue> productFeaturePrices = EntityUtil.filterByDate(delegator.findByAnd("ProductFeaturePrice",
UtilMisc.toMap("productFeatureId", productFeatureAppl.getString("productFeatureId"), "productPriceTypeId", "DEFAULT_PRICE"), null, false));
List<GenericValue> productFeaturePrices = EntityQuery.use(delegator).from("ProductFeaturePrice")
.where("productFeatureId", productFeatureAppl.getString("productFeatureId"), "productPriceTypeId", "DEFAULT_PRICE")
.filterByDate()
.queryList();
if (UtilValidate.isNotEmpty(productFeaturePrices)) {
GenericValue productFeaturePrice = productFeaturePrices.get(0);
if (UtilValidate.isNotEmpty(productFeaturePrice.get("price"))) {
@@ -511,7 +516,7 @@ public class ProductWorker {
List<GenericValue> productFeatureAppls = null;
try {
productFeatureAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "OPTIONAL_FEATURE"), UtilMisc.toList("productFeatureTypeId", "sequenceNum"), false);
productFeatureAppls = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureApplTypeId", "OPTIONAL_FEATURE").orderBy("productFeatureTypeId", "sequenceNum").queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
@@ -709,12 +714,20 @@ public class ProductWorker {
}
try {
List<GenericValue> virtualProductAssocs = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate"), true);
virtualProductAssocs = EntityUtil.filterByDate(virtualProductAssocs);
List<GenericValue> virtualProductAssocs = EntityQuery.use(delegator).from("ProductAssoc")
.where("productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT")
.orderBy("-fromDate")
.cache(true)
.filterByDate()
.queryList();
if (UtilValidate.isEmpty(virtualProductAssocs)) {
//okay, not a variant, try a UNIQUE_ITEM
virtualProductAssocs = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "UNIQUE_ITEM"), UtilMisc.toList("-fromDate"), true);
virtualProductAssocs = EntityUtil.filterByDate(virtualProductAssocs);
virtualProductAssocs = EntityQuery.use(delegator).from("ProductAssoc")
.where("productIdTo", productId, "productAssocTypeId", "UNIQUE_ITEM")
.orderBy("-fromDate")
.cache(true)
.filterByDate()
.queryList();
}
if (UtilValidate.isNotEmpty(virtualProductAssocs)) {
//found one, set this first as the parent product
@@ -873,7 +886,7 @@ public class ProductWorker {
if (UtilValidate.isNotEmpty(goodIdentificationTypeId)) {
conditions.put("goodIdentificationTypeId", goodIdentificationTypeId);
}
productsFound = delegator.findByAnd("GoodIdentificationAndProduct", conditions, UtilMisc.toList("productId"), true);
productsFound = EntityQuery.use(delegator).from("GoodIdentificationAndProduct").where(conditions).orderBy("productId").cache(true).queryList();
}
if (! searchProductFirst) {
@@ -971,15 +984,13 @@ public class ProductWorker {
Set<String> productIdSet = FastSet.newInstance();
// find associated refurb items, we want serial number for main item or any refurb items too
List<GenericValue> refubProductAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc",
UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_REFURB"), null, false));
List<GenericValue> refubProductAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_REFURB").filterByDate().queryList();
for (GenericValue refubProductAssoc: refubProductAssocs) {
productIdSet.add(refubProductAssoc.getString("productIdTo"));
}
// see if this is a refurb productId to, and find product(s) it is a refurb of
List<GenericValue> refubProductToAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc",
UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_REFURB"), null, false));
List<GenericValue> refubProductToAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productIdTo", productId, "productAssocTypeId", "PRODUCT_REFURB").filterByDate().queryList();
for (GenericValue refubProductToAssoc: refubProductToAssocs) {
productIdSet.add(refubProductToAssoc.getString("productId"));
}
@@ -995,8 +1006,8 @@ public class ProductWorker {
for (String paramValue: selectedFeatures) {
// find incompatibilities..
List<GenericValue> incompatibilityVariants = delegator.findByAnd("ProductFeatureIactn", UtilMisc.toMap("productId", productId,
"productFeatureIactnTypeId","FEATURE_IACTN_INCOMP"), null, true);
List<GenericValue> incompatibilityVariants = EntityQuery.use(delegator).from("ProductFeatureIactn")
.where("productId", productId, "productFeatureIactnTypeId","FEATURE_IACTN_INCOMP").cache(true).queryList();
for (GenericValue incompatibilityVariant: incompatibilityVariants) {
String featur = incompatibilityVariant.getString("productFeatureId");
if (paramValue.equals(featur)) {
@@ -1011,8 +1022,8 @@ public class ProductWorker {
}
}
// find dependencies..
List<GenericValue> dependenciesVariants = delegator.findByAnd("ProductFeatureIactn", UtilMisc.toMap("productId", productId,
"productFeatureIactnTypeId","FEATURE_IACTN_DEPEND"), null, true);
List<GenericValue> dependenciesVariants = EntityQuery.use(delegator).from("ProductFeatureIactn")
.where("productId", productId, "productFeatureIactnTypeId","FEATURE_IACTN_DEPEND").cache(true).queryList();
for (GenericValue dpVariant: dependenciesVariants) {
String featur = dpVariant.getString("productFeatureId");
if (paramValue.equals(featur)) {
@@ -1033,12 +1044,12 @@ public class ProductWorker {
}
// find variant
// Debug.logInfo("=====try to find variant for product: " + productId + " and features: " + selectedFeatures);
List<GenericValue> productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId","PRODUCT_VARIANT"), null, false));
List<GenericValue> productAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId","PRODUCT_VARIANT").filterByDate().queryList();
boolean productFound = false;
nextProd:
for (GenericValue productAssoc: productAssocs) {
for (String featureId: selectedFeatures) {
List<GenericValue> pAppls = delegator.findByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productAssoc.getString("productIdTo"), "productFeatureId", featureId, "productFeatureApplTypeId","STANDARD_FEATURE"), null, true);
List<GenericValue> pAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productAssoc.getString("productIdTo"), "productFeatureId", featureId, "productFeatureApplTypeId","STANDARD_FEATURE").cache(true).queryList();
if (UtilValidate.isEmpty(pAppls)) {
continue nextProd;
}
@@ -1071,7 +1082,7 @@ nextProd:
productFeatureAppl.create();
}
//add standard features too
List<GenericValue> stdFeaturesAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE"), null, false));
List<GenericValue> stdFeaturesAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE").filterByDate().queryList();
for (GenericValue stdFeaturesAppl: stdFeaturesAppls) {
stdFeaturesAppl.put("productId", product.getString("productId"));
stdFeaturesAppl.create();
@@ -1080,11 +1091,12 @@ nextProd:
* take the default price from the vitual product, go to the productfeature table and retrieve all the prices for the difFerent features
* add these to the price of the virtual product, store the result as the default price on the variant you created.
*/
List<GenericValue> productPrices = EntityUtil.filterByDate(delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", productId), null, false));
List<GenericValue> productPrices = EntityQuery.use(delegator).from("ProductPrice").where("productId", productId).filterByDate().queryList();
for (GenericValue productPrice: productPrices) {
for (String selectedFeaturedId: selectedFeatures) {
List<GenericValue> productFeaturePrices = EntityUtil.filterByDate(delegator.findByAnd("ProductFeaturePrice",
UtilMisc.toMap("productFeatureId", selectedFeaturedId, "productPriceTypeId", productPrice.getString("productPriceTypeId")), null, false));
List<GenericValue> productFeaturePrices = EntityQuery.use(delegator).from("ProductFeaturePrice")
.where("productFeatureId", selectedFeaturedId, "productPriceTypeId", productPrice.getString("productPriceTypeId"))
.filterByDate().queryList();
if (UtilValidate.isNotEmpty(productFeaturePrices)) {
GenericValue productFeaturePrice = productFeaturePrices.get(0);
if (UtilValidate.isNotEmpty(productFeaturePrice)) {
@@ -1105,14 +1117,14 @@ nextProd:
Debug.logInfo("set the productId to: " + product.getString("productId"), module);
// copy the supplier
List<GenericValue> supplierProducts = delegator.findByAnd("SupplierProduct", UtilMisc.toMap("productId", productId), null, true);
List<GenericValue> supplierProducts = EntityQuery.use(delegator).from("SupplierProduct").where("productId", productId).cache(true).queryList();
for (GenericValue supplierProduct: supplierProducts) {
supplierProduct.set("productId", product.getString("productId"));
supplierProduct.create();
}
// copy the content
List<GenericValue> productContents = delegator.findByAnd("ProductContent", UtilMisc.toMap("productId", productId), null, true);
List<GenericValue> productContents = EntityQuery.use(delegator).from("ProductContent").where("productId", productId).cache(true).queryList();
for (GenericValue productContent: productContents) {
productContent.set("productId", product.getString("productId"));
productContent.create();
@@ -1143,7 +1155,7 @@ nextProd:
condList.add(EntityCondition.makeCondition("productId", virtualVariantId));
}
condList.add(EntityCondition.makeCondition("productAssocTypeId", "ALTERNATIVE_PACKAGE"));
alternativePackingProds = delegator.findList("ProductAssoc", EntityCondition.makeCondition(condList, EntityOperator.AND), null, null, null, true);
alternativePackingProds = EntityQuery.use(delegator).from("ProductAssoc").where(condList).cache(true).queryList();
if(UtilValidate.isNotEmpty(alternativePackingProds)) isAlternativePacking = true;
} catch (GenericEntityException e) {
Debug.logWarning(e, "Could not found alternative product: " + e.getMessage(), module);
@@ -1157,11 +1169,10 @@ nextProd:
if (isAlternativePacking) {
List<GenericValue> productAssocs = null;
try {
productAssocs = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId , "productAssocTypeId", "ALTERNATIVE_PACKAGE"), null, false);
productAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId , "productAssocTypeId", "ALTERNATIVE_PACKAGE").filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
productAssocs = EntityUtil.filterByDate(productAssocs);
if (productAssocs != null) {
GenericValue productAssoc = EntityUtil.getFirst(productAssocs);
@@ -1187,8 +1198,8 @@ nextProd:
if(UtilValidate.isEmpty(productStoreId)){
return Boolean.TRUE;
}
String allowDecimalStore = delegator.findOne("ProductStore", Boolean.TRUE, UtilMisc.toMap("productStoreId", productStoreId)).getString("orderDecimalQuantity");
String allowDecimalProduct = delegator.findOne("Product", Boolean.TRUE, UtilMisc.toMap("productId", productId)).getString("orderDecimalQuantity");
String allowDecimalStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).cache(true).queryOne().getString("orderDecimalQuantity");
String allowDecimalProduct = EntityQuery.use(delegator).from("Product").where("productId", productId).cache(true).queryOne().getString("orderDecimalQuantity");
if("N".equals(allowDecimalProduct) || (UtilValidate.isEmpty(allowDecimalProduct) && "N".equals(allowDecimalStore))){
return Boolean.FALSE;
@@ -1216,7 +1227,7 @@ nextProd:
for (GenericValue genericRecord : productsToFilter) {
String productId = genericRecord.getString("productId");
GenericValue product = null;
product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true);
product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache(true).queryOne();
Boolean isMarketingPackage = EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG");
if ( UtilValidate.isNotEmpty(isMarketingPackage) && isMarketingPackage) {
@@ -1229,7 +1240,7 @@ nextProd:
productsInStock.add(genericRecord);
}
} else {
List<GenericValue> facilities = delegator.findList("ProductFacility", EntityCondition.makeCondition("productId",EntityOperator.EQUALS, productId), null, null, null, false);
List<GenericValue> facilities = EntityQuery.use(delegator).from("ProductFacility").where("productId", productId).queryList();
BigDecimal availableInventory = BigDecimal.ZERO;
if (UtilValidate.isNotEmpty(facilities)) {
for (GenericValue facility : facilities) {
@@ -95,7 +95,7 @@ public class VariantEvents {
}
// check if product exists
GenericValue variantProduct = delegator.findOne("Product",UtilMisc.toMap("productId", variantProductId), false);
GenericValue variantProduct = EntityQuery.use(delegator).from("Product").where("productId", variantProductId).queryOne();
if (variantProduct == null) {
//if product does not exist
variantProduct = GenericValue.create(product);
@@ -138,10 +138,9 @@ public class PromoServices {
condList.add(EntityCondition.makeCondition("userEntered", EntityOperator.EQUALS, "Y"));
condList.add(EntityCondition.makeCondition("thruDate", EntityOperator.NOT_EQUAL, null));
condList.add(EntityCondition.makeCondition("thruDate", EntityOperator.LESS_THAN, nowTimestamp));
EntityCondition cond = EntityCondition.makeCondition(condList, EntityOperator.AND);
try {
EntityListIterator eli = delegator.find("ProductStorePromoAndAppl", cond, null, null, null, null);
EntityListIterator eli = EntityQuery.use(delegator).from("ProductStorePromoAndAppl").where(condList).queryIterator();
GenericValue productStorePromoAndAppl = null;
while ((productStorePromoAndAppl = eli.next()) != null) {
GenericValue productStorePromo = delegator.makeValue("ProductStorePromoAppl");
@@ -29,6 +29,7 @@ import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.util.EntityQuery;
public class ImportProductHelper {
@@ -65,8 +66,7 @@ public class ImportProductHelper {
GenericValue tmpProductGV;
boolean productExists = false;
try {
tmpProductGV = delegator.findOne("Product", UtilMisc
.toMap("productId", productId), false);
tmpProductGV = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
if (tmpProductGV != null
&& productId.equals(tmpProductGV.getString("productId")))
productExists = true;
@@ -33,6 +33,7 @@ import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
public class ProductStoreEvents {
@@ -51,18 +52,16 @@ public class ProductStoreEvents {
List<String> sortList = org.ofbiz.base.util.UtilMisc.toList("sequenceNum");
try {
GenericValue productStoreGroup = delegator.findOne("ProductStoreGroup" ,UtilMisc.toMap("productStoreGroupId", parentGroupId), true);
GenericValue productStoreGroup = EntityQuery.use(delegator).from("ProductStoreGroup").where("productStoreGroupId", parentGroupId).cache(true).queryOne();
if (UtilValidate.isNotEmpty(productStoreGroup)) {
children = EntityUtil.filterByDate(delegator.findList("ProductStoreGroupRollupAndChild",
EntityCondition.makeCondition("parentGroupId", parentGroupId), null, null, null, true));
children = EntityQuery.use(delegator).from("ProductStoreGroupRollupAndChild").where("parentGroupId", parentGroupId).cache(true).filterByDate().queryList();
if (UtilValidate.isNotEmpty(children)) {
for (GenericValue child : children ) {
String productStoreGroupId = child.getString("productStoreGroupId");
Map josonMap = FastMap.newInstance();
List<GenericValue> childList = null;
// Get the child list of chosen category
childList = EntityUtil.filterByDate(delegator.findList("ProductStoreGroupRollupAndChild",
EntityCondition.makeCondition("parentGroupId", productStoreGroupId), null, null, null, true));
childList = EntityQuery.use(delegator).from("ProductStoreGroupRollupAndChild").where("parentGroupId", productStoreGroupId).cache(true).filterByDate().queryList();
if (UtilValidate.isNotEmpty(childList)) {
josonMap.put("state", "closed");
@@ -175,8 +175,7 @@ public class ProductStoreWorker {
if (anyServiceType) {
if (storePayment == null) {
try {
List<GenericValue> storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId), null, false);
storePayment = EntityUtil.getFirst(storePayments);
storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId).queryFirst();
} catch (GenericEntityException e) {
Debug.logError(e, "Problems looking up store payment settings", module);
}
@@ -184,8 +183,7 @@ public class ProductStoreWorker {
if (storePayment == null) {
try {
List<GenericValue> storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId), null, false);
storePayment = EntityUtil.getFirst(storePayments);
storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId).queryFirst();
} catch (GenericEntityException e) {
Debug.logError(e, "Problems looking up store payment settings", module);
}
@@ -198,12 +196,14 @@ public class ProductStoreWorker {
public static List<GenericValue> getProductStoreShipmentMethods(Delegator delegator, String productStoreId,
String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId) {
// check for an external service call
Map<String, String> storeFields = UtilMisc.toMap("productStoreId", productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId,
"partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId);
List<GenericValue> storeShipMethods = null;
try {
storeShipMethods = delegator.findByAnd("ProductStoreShipmentMeth", storeFields, null, true);
storeShipMethods = EntityQuery.use(delegator).from("ProductStoreShipmentMeth")
.where("productStoreId", productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId,
"partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId)
.cache(true)
.queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
@@ -224,7 +224,7 @@ public class ProductStoreWorker {
}
List<GenericValue> shippingMethods = null;
try {
shippingMethods = delegator.findByAnd("ProductStoreShipmentMethView", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNumber"), true);
shippingMethods = EntityQuery.use(delegator).from("ProductStoreShipmentMethView").where("productStoreId", productStoreId).orderBy("sequenceNumber").cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get ProductStore shipping methods", module);
return null;
@@ -380,7 +380,7 @@ public class ProductStoreWorker {
if (UtilValidate.isNotEmpty(includeFeatures)) {
List<GenericValue> includedFeatures = null;
try {
includedFeatures = delegator.findByAnd("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", includeFeatures), null, true);
includedFeatures = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId", includeFeatures).cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + includeFeatures, module);
}
@@ -402,7 +402,7 @@ public class ProductStoreWorker {
if (UtilValidate.isNotEmpty(excludeFeatures)) {
List<GenericValue> excludedFeatures = null;
try {
excludedFeatures = delegator.findByAnd("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", excludeFeatures), null, true);
excludedFeatures = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId", excludeFeatures).cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + excludeFeatures, module);
}
@@ -465,7 +465,7 @@ public class ProductStoreWorker {
List<GenericValue> surveys = FastList.newInstance();
List<GenericValue> storeSurveys = null;
try {
storeSurveys = delegator.findByAnd("ProductStoreSurveyAppl", UtilMisc.toMap("productStoreId", productStoreId, "surveyApplTypeId", surveyApplTypeId), UtilMisc.toList("sequenceNum"), true);
storeSurveys = EntityQuery.use(delegator).from("ProductStoreSurveyAppl").where("productStoreId", productStoreId, "surveyApplTypeId", surveyApplTypeId).orderBy("sequenceNum").cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get ProductStoreSurveyAppl for store : " + productStoreId, module);
return surveys;
@@ -512,7 +512,7 @@ public class ProductStoreWorker {
} else if (surveyAppl.get("productCategoryId") != null) {
List<GenericValue> categoryMembers = null;
try {
categoryMembers = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", surveyAppl.get("productCategoryId")), null, true);
categoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", surveyAppl.get("productCategoryId")).cache(true).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to get ProductCategoryMember records for survey application : " + surveyAppl, module);
}
@@ -556,7 +556,7 @@ public class ProductStoreWorker {
List<GenericValue> surveyResponse = null;
try {
surveyResponse = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("surveyId", surveyId, "partyId", partyId), null, false);
surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyId", surveyId, "partyId", partyId).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return -1;
@@ -78,7 +78,7 @@ public class SubscriptionServices {
Map<String, String> subscriptionFindMap = UtilMisc.toMap("partyId", partyId, "subscriptionResourceId", subscriptionResourceId);
// if this subscription is attached to something the customer owns, filter by that too
if (UtilValidate.isNotEmpty(inventoryItemId)) subscriptionFindMap.put("inventoryItemId", inventoryItemId);
List<GenericValue> subscriptionList = delegator.findByAnd("Subscription", subscriptionFindMap, null, false);
List<GenericValue> subscriptionList = EntityQuery.use(delegator).from("Subscription").where(subscriptionFindMap).queryList();
// DEJ20070718 DON'T filter by date, we want to consider all subscriptions: List listFiltered = EntityUtil.filterByDate(subscriptionList, true);
List<GenericValue> listOrdered = EntityUtil.orderBy(subscriptionList, UtilMisc.toList("-fromDate"));
if (listOrdered.size() > 0) {
@@ -198,9 +198,11 @@ public class SubscriptionServices {
orderCreatedDate = UtilDateTime.nowTimestamp();
}
try {
List<GenericValue> productSubscriptionResourceList = delegator.findByAnd("ProductSubscriptionResource", UtilMisc.toMap("productId", productId), null, true);
productSubscriptionResourceList = EntityUtil.filterByDate(productSubscriptionResourceList, orderCreatedDate, null, null, true);
productSubscriptionResourceList = EntityUtil.filterByDate(productSubscriptionResourceList, orderCreatedDate, "purchaseFromDate", "purchaseThruDate", true);
List<GenericValue> productSubscriptionResourceList = EntityQuery.use(delegator).from("ProductSubscriptionResource")
.where("productId", productId)
.cache(true)
.filterByDate(orderCreatedDate, "fromDate", "thruDate", "purchaseFromDate", "purchaseThruDate")
.queryList();
if (productSubscriptionResourceList.size() == 0) {
Debug.logError("No ProductSubscriptionResource found for productId: " + productId, module);
@@ -254,7 +256,7 @@ public class SubscriptionServices {
GenericValue orderHeader = null;
try {
List<GenericValue> orderRoleList = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER"), null, false);
List<GenericValue> orderRoleList = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER").queryList();
if (orderRoleList.size() > 0) {
GenericValue orderRole = orderRoleList.get(0);
String partyId = (String) orderRole.get("partyId");
@@ -279,8 +281,7 @@ public class SubscriptionServices {
if (UtilValidate.isEmpty(productId)) {
continue;
}
List<GenericValue> productSubscriptionResourceList = delegator.findByAnd("ProductSubscriptionResource", UtilMisc.toMap("productId", productId), null, true);
List<GenericValue> productSubscriptionResourceListFiltered = EntityUtil.filterByDate(productSubscriptionResourceList, true);
List<GenericValue> productSubscriptionResourceListFiltered = EntityQuery.use(delegator).from("ProductSubscriptionResource").where("productId", productId).cache(true).filterByDate().queryList();
if (productSubscriptionResourceListFiltered.size() > 0) {
subContext.put("subscriptionTypeId", "PRODUCT_SUBSCR");
subContext.put("productId", productId);
@@ -322,7 +323,7 @@ public class SubscriptionServices {
EntityCondition cond2 = EntityCondition.makeCondition("automaticExtend", EntityOperator.EQUALS, null);
EntityCondition cond = EntityCondition.makeCondition(UtilMisc.toList(cond1, cond2), EntityOperator.OR);
List<GenericValue> subscriptionList = null;
subscriptionList = delegator.findList("Subscription", cond, null,null, null, false);
subscriptionList = EntityQuery.use(delegator).from("Subscription").where(cond).queryList();
if (subscriptionList != null) {
for (GenericValue subscription : subscriptionList) {
@@ -728,13 +728,13 @@ public class PackingSession implements java.io.Serializable {
newShipment.put("picklistBinId", picklistBinId);
newShipment.put("additionalShippingCharge", additionalShippingCharge);
newShipment.put("userLogin", userLogin);
GenericValue orderRoleShipTo = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", primaryOrderId, "roleTypeId", "SHIP_TO_CUSTOMER"), null, false));
GenericValue orderRoleShipTo = EntityQuery.use(delegator).from("OrderRole").where("orderId", primaryOrderId, "roleTypeId", "SHIP_TO_CUSTOMER").queryFirst();
if (UtilValidate.isNotEmpty(orderRoleShipTo)) {
newShipment.put("partyIdTo", orderRoleShipTo.getString("partyId"));
}
String partyIdFrom = null;
if (primaryOrderId != null) {
GenericValue orderItemShipGroup = EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGroup", UtilMisc.toMap("orderId", primaryOrderId, "shipGroupSeqId", primaryShipGrp), null, false));
GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", primaryOrderId, "shipGroupSeqId", primaryShipGrp).queryFirst();
if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("vendorPartyId"))) {
partyIdFrom = orderItemShipGroup.getString("vendorPartyId");
} else if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("facilityId"))) {
@@ -744,11 +744,11 @@ public class PackingSession implements java.io.Serializable {
}
}
if (UtilValidate.isEmpty(partyIdFrom)) {
GenericValue orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", primaryOrderId, "roleTypeId", "SHIP_FROM_VENDOR"), null, false));
GenericValue orderRoleShipFrom = EntityQuery.use(delegator).from("OrderRole").where("orderId", primaryOrderId, "roleTypeId", "SHIP_FROM_VENDOR").queryFirst();
if (UtilValidate.isNotEmpty(orderRoleShipFrom)) {
partyIdFrom = orderRoleShipFrom.getString("partyId");
} else {
orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", primaryOrderId, "roleTypeId", "BILL_FROM_VENDOR"), null, false));
orderRoleShipFrom = EntityQuery.use(delegator).from("OrderRole").where("orderId", primaryOrderId, "roleTypeId", "BILL_FROM_VENDOR").queryFirst();
partyIdFrom = orderRoleShipFrom.getString("partyId");
}
}
@@ -28,6 +28,7 @@ import org.ofbiz.base.util.UtilFormatOut;
import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ServiceUtil;
@@ -212,7 +213,10 @@ public class PackingSessionLine implements java.io.Serializable {
itemLookup.put("orderItemSeqId", this.getOrderItemSeqId());
itemLookup.put("shipGroupSeqId", this.getShipGroupSeqId());
itemLookup.put("inventoryItemId", this.getInventoryItemId());
GenericValue plItem = delegator.findOne("PicklistItem", itemLookup, false);
GenericValue plItem = EntityQuery.use(delegator)
.from("PicklistItem")
.where(itemLookup)
.queryOne();
if (plItem != null) {
Debug.logInfo("Found picklist bin: " + plItem, module);
BigDecimal itemQty = plItem.getBigDecimal("quantity");
@@ -33,6 +33,7 @@ import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
@@ -66,11 +67,12 @@ public class PickListServices {
EntityCondition idCond = EntityCondition.makeCondition(conditionList1, EntityOperator.OR);
conditionList2.add(idCond);
EntityCondition cond = EntityCondition.makeCondition(conditionList2, EntityOperator.AND);
// run the query
try {
orderHeaderList = delegator.findList("OrderHeader", cond, null, UtilMisc.toList("+orderDate"), null, false);
orderHeaderList = EntityQuery.use(delegator).from("OrderHeader")
.where(conditionList2)
.orderBy("orderDate")
.queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -89,7 +91,7 @@ public class PickListServices {
// lookup the items in the bin
List<GenericValue> items;
try {
items = delegator.findByAnd("PicklistItem", UtilMisc.toMap("picklistBinId", picklistBinId), null, false);
items = EntityQuery.use(delegator).from("PicklistItem").where("picklistBinId", picklistBinId).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
throw e;
@@ -273,7 +273,10 @@ public class ShipmentServices {
Collection<GenericValue> estimates = null;
try {
estimates = delegator.findList("ShipmentCostEstimate", estFieldsCond, null, null, null, true);
estimates = EntityQuery.use(delegator).from("ShipmentCostEstimate")
.where(estFieldsCond)
.cache(true)
.queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
@@ -302,8 +305,10 @@ public class ShipmentServices {
} else if (shippingPostalCode != null) {
String countryGeoId = null;
try {
EntityCondition cond =EntityCondition.makeCondition(UtilMisc.toMap("geoTypeId", "COUNTRY", "geoCode", shippingCountryCode));
GenericValue countryGeo = EntityUtil.getFirst(delegator.findList("Geo", cond, null, null, null, true));
GenericValue countryGeo = EntityQuery.use(delegator).from("Geo")
.where("geoTypeId", "COUNTRY", "geoCode", shippingCountryCode)
.cache(true)
.queryFirst();
if (countryGeo != null) {
countryGeoId = countryGeo.getString("geoId");
}
@@ -562,9 +567,11 @@ public class ShipmentServices {
GenericValue appl = null;
Map<String, String> fields = UtilMisc.toMap("productFeatureGroupId", featureGroupId, "productFeatureId", featureId);
try {
List<GenericValue> appls = delegator.findByAnd("ProductFeatureGroupAppl", fields, null, true);
appls = EntityUtil.filterByDate(appls);
appl = EntityUtil.getFirst(appls);
appl = EntityQuery.use(delegator).from("ProductFeatureGroupAppl")
.where("productFeatureGroupId", featureGroupId, "productFeatureId", featureId)
.cache(true)
.filterByDate()
.queryFirst();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to lookup feature/group" + fields, module);
}
@@ -722,20 +729,18 @@ public class ShipmentServices {
Delegator delegator = dctx.getDelegator();
GenericValue userLogin = (GenericValue) context.get("userLogin");
Locale locale = (Locale) context.get("locale");
List<String> orderBy = UtilMisc.toList("shipmentId", "shipmentPackageSeqId", "voidIndicator");
Map<String, String> shipmentMap = FastMap.newInstance();
EntityListIterator eli = null;
try {
eli = delegator.find("OdbcPackageIn", null, null, null, orderBy, null);
eli = EntityQuery.use(delegator).from("OdbcPackageIn").orderBy("shipmentId", "shipmentPackageSeqId", "voidIndicator").queryIterator();
GenericValue pkgInfo;
while ((pkgInfo = eli.next()) != null) {
String packageSeqId = pkgInfo.getString("shipmentPackageSeqId");
String shipmentId = pkgInfo.getString("shipmentId");
// locate the shipment package
GenericValue shipmentPackage = delegator.findOne("ShipmentPackage",
UtilMisc.toMap("shipmentId", shipmentId, "shipmentPackageSeqId", packageSeqId), false);
GenericValue shipmentPackage = EntityQuery.use(delegator).from("ShipmentPackage").where("shipmentId", shipmentId, "shipmentPackageSeqId", packageSeqId).queryOne();
if (shipmentPackage != null) {
if ("00001".equals(packageSeqId)) {
@@ -777,7 +782,9 @@ public class ShipmentServices {
// first update the weight of the package
GenericValue pkg = null;
try {
pkg = delegator.findOne("ShipmentPackage", pkgCtx, false);
pkg = EntityQuery.use(delegator).from("ShipmentPackage")
.where(pkgCtx)
.queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -802,7 +809,7 @@ public class ShipmentServices {
pkgCtx.put("shipmentRouteSegmentId", "00001");
GenericValue pkgRtSeg = null;
try {
pkgRtSeg = delegator.findOne("ShipmentPackageRouteSeg", pkgCtx, false);
pkgRtSeg = EntityQuery.use(delegator).from("ShipmentPackageRouteSeg").where(pkgCtx).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -910,7 +917,7 @@ public class ShipmentServices {
GenericValue userLogin = (GenericValue) context.get("userLogin");
try {
List<GenericValue> shipmentReceipts = delegator.findByAnd("ShipmentReceipt", UtilMisc.toMap("shipmentId", shipmentId), null, false);
List<GenericValue> shipmentReceipts = EntityQuery.use(delegator).from("ShipmentReceipt").where("shipmentId", shipmentId).queryList();
if (shipmentReceipts.size() == 0) return ServiceUtil.returnSuccess();
// If there are shipment receipts, the shipment must have been shipped, so set the shipment status to PURCH_SHIP_SHIPPED if it's only PURCH_SHIP_CREATED
@@ -922,7 +929,7 @@ public class ShipmentServices {
}
}
List<GenericValue> shipmentAndItems = delegator.findByAnd("ShipmentAndItem", UtilMisc.toMap("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED"), null, false);
List<GenericValue> shipmentAndItems = EntityQuery.use(delegator).from("ShipmentAndItem").where("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED").queryList();
if (shipmentAndItems.size() == 0) {
return ServiceUtil.returnSuccess();
}
@@ -1018,8 +1025,10 @@ public class ShipmentServices {
// get the carrierPartyId
try {
GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment",
UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), true);
GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment")
.where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId)
.cache(true)
.queryOne();
carrierPartyId = shipmentRouteSegment.getString("carrierPartyId");
} catch (GenericEntityException e) {
Debug.logError(e, module);
@@ -1083,7 +1092,7 @@ public class ShipmentServices {
return ServiceUtil.returnError(errorMessage);
}
List<GenericValue> packageContents = delegator.findByAnd("PackedQtyVsOrderItemQuantity", UtilMisc.toMap("shipmentId", shipmentId, "shipmentPackageSeqId", shipmentPackageSeqId), null, false);
List<GenericValue> packageContents = EntityQuery.use(delegator).from("PackedQtyVsOrderItemQuantity").where("shipmentId", shipmentId, "shipmentPackageSeqId", shipmentPackageSeqId).queryList();
for (GenericValue packageContent: packageContents) {
String orderId = packageContent.getString("orderId");
String orderItemSeqId = packageContent.getString("orderItemSeqId");
@@ -1244,14 +1253,10 @@ public class ShipmentServices {
String shipmentMethodTypeId = primaryOrderItemShipGroup.getString("shipmentMethodTypeId");
String carrierPartyId = primaryOrderItemShipGroup.getString("carrierPartyId");
String carrierRoleTypeId = primaryOrderItemShipGroup.getString("carrierRoleTypeId");
List<EntityCondition> conditions = FastList.newInstance();
conditions.add(EntityCondition.makeCondition("productStoreId", EntityOperator.EQUALS, productStoreId));
conditions.add(EntityCondition.makeCondition("shipmentMethodTypeId", EntityOperator.EQUALS, shipmentMethodTypeId));
conditions.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, carrierPartyId));
conditions.add(EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, carrierRoleTypeId));
EntityConditionList<EntityCondition> ecl = EntityCondition.makeCondition(conditions, EntityOperator.AND);
List<GenericValue> productStoreShipmentMeths = delegator.findList("ProductStoreShipmentMeth", ecl, null, null, null, false);
GenericValue productStoreShipmentMeth = EntityUtil.getFirst(productStoreShipmentMeths);
GenericValue productStoreShipmentMeth = EntityQuery.use(delegator).from("ProductStoreShipmentMeth")
.where("productStoreId",productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId,
"partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId)
.queryFirst();
if (UtilValidate.isNotEmpty(productStoreShipmentMeth)) {
shipmentGatewayConfig.put("shipmentGatewayConfigId", productStoreShipmentMeth.getString("shipmentGatewayConfigId"));
shipmentGatewayConfig.put("configProps", productStoreShipmentMeth.getString("configProps"));
@@ -170,8 +170,9 @@ public class DhlServices {
// translate shipmentMethodTypeId to DHL service code
String dhlShipmentDetailCode = null;
try {
GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod", UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId,
"partyId", carrierPartyId, "roleTypeId", "CARRIER"), false);
GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod")
.where("shipmentMethodTypeId", shipmentMethodTypeId, "partyId", carrierPartyId, "roleTypeId", "CARRIER")
.queryOne();
if (carrierShipmentMethod == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"FacilityShipmentDhlNoCarrierShipmentMethod",
@@ -711,8 +712,9 @@ public class DhlServices {
// translate shipmentMethodTypeId to DHL service code
String shipmentMethodTypeId = shipmentRouteSegment.getString("shipmentMethodTypeId");
String dhlShipmentDetailCode = null;
GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod", UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId,
"partyId", "DHL", "roleTypeId", "CARRIER"), false);
GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod")
.where("shipmentMethodTypeId", shipmentMethodTypeId, "partyId", "DHL", "roleTypeId", "CARRIER")
.queryOne();
if (carrierShipmentMethod == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"FacilityShipmentDhlNoCarrierShipmentMethod",
@@ -203,9 +203,10 @@ public class FedexServices {
}
// Get the contact information for the company
List<GenericValue> partyContactDetails = delegator.findByAnd("PartyContactDetailByPurpose", UtilMisc.toMap("partyId", companyPartyId), null, false);
partyContactDetails = EntityUtil.filterByDate(partyContactDetails);
partyContactDetails = EntityUtil.filterByDate(partyContactDetails, UtilDateTime.nowTimestamp(), "purposeFromDate", "purposeThruDate", true);
List<GenericValue> partyContactDetails = EntityQuery.use(delegator).from("PartyContactDetailByPurpose")
.where("partyId", companyPartyId)
.filterByDate(UtilDateTime.nowTimestamp(), "fromDate", "thruDate", "purposeFromDate", "purposeThruDate")
.queryList();
// Get the first valid postal address (address1, city, postalCode and countryGeoId are required by Fedex)
List<EntityCondition> postalAddressConditions = FastList.newInstance();
@@ -201,8 +201,7 @@ public class UpsServices {
UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));
}
Map<String, Object> findCarrierShipmentMethodMap = UtilMisc.toMap("partyId", shipmentRouteSegment.get("carrierPartyId"), "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentRouteSegment.get("shipmentMethodTypeId"));
GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod", findCarrierShipmentMethodMap, false);
GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod").where("partyId", shipmentRouteSegment.get("carrierPartyId"), "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentRouteSegment.get("shipmentMethodTypeId")).queryOne();
if (carrierShipmentMethod == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUpsRouteSegmentCarrierShipmentMethodNotFound",
UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId, "carrierPartyId", shipmentRouteSegment.get("carrierPartyId"), "shipmentMethodTypeId", shipmentRouteSegment.get("shipmentMethodTypeId")), locale));
@@ -241,7 +240,8 @@ public class UpsServices {
if (allowCOD) {
// Get the paymentMethodTypeIds of all the orderPaymentPreferences involved with the shipment
List<GenericValue> opps = delegator.findList("OrderPaymentPreference", EntityCondition.makeCondition("orderId", EntityOperator.IN, orderIdSet), null, null, null, false);
List<GenericValue> opps = EntityQuery.use(delegator).from("OrderPaymentPreference")
.where(EntityCondition.makeCondition("orderId", EntityOperator.IN, orderIdSet)).queryList();
List<String> paymentMethodTypeIds = EntityUtil.getFieldListFromEntityList(opps, "paymentMethodTypeId", true);
if (paymentMethodTypeIds.size() > 1 || ! paymentMethodTypeIds.contains("EXT_COD")) {
@@ -2078,8 +2078,9 @@ public class UpsServices {
// locate the CarrierShipmentMethod record
GenericValue carrierShipmentMethod = null;
try {
carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod", UtilMisc.toMap("shipmentMethodTypeId",
shipmentMethodTypeId, "partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId), false);
carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod")
.where("shipmentMethodTypeId", shipmentMethodTypeId, "partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId)
.queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
@@ -2481,8 +2482,9 @@ public class UpsServices {
UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));
}
Map<String, Object> findCarrierShipmentMethodMap = UtilMisc.toMap("partyId", shipmentRouteSegment.get("carrierPartyId"), "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentRouteSegment.get("shipmentMethodTypeId"));
GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod", findCarrierShipmentMethodMap, false);
GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod")
.where("partyId", shipmentRouteSegment.get("carrierPartyId"), "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentRouteSegment.get("shipmentMethodTypeId"))
.queryOne();
if (carrierShipmentMethod == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUpsRouteSegmentCarrierShipmentMethodNotFound",
UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId, "carrierPartyId", shipmentRouteSegment.get("carrierPartyId"), "shipmentMethodTypeId", shipmentRouteSegment.get("shipmentMethodTypeId")), locale));
@@ -2798,10 +2800,9 @@ public class UpsServices {
try {
if (shipmentRouteSegmentId != null) {
shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment", false, UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId));
shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne();
} else {
List<GenericValue> shipmentRouteSegments = delegator.findList("ShipmentRouteSegment", EntityCondition.makeCondition("shipmentId", EntityOperator.EQUALS, shipmentId), null, null, null, false);
shipmentRouteSegment = EntityUtil.getFirst(shipmentRouteSegments);
shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where(EntityCondition.makeCondition("shipmentId", EntityOperator.EQUALS, shipmentId)).queryFirst();
}
if (shipmentRouteSegment == null) {
@@ -3096,12 +3097,13 @@ public class UpsServices {
GenericValue carrierShipmentMethod = null;
// Filtering out rates of shipping methods which are not configured in ProductStoreShipmentMeth entity.
try {
List <GenericValue> productStoreShipmentMethods = delegator.findByAnd("ProductStoreShipmentMethView", UtilMisc.toMap("productStoreId", productStoreId), null, false);
List <GenericValue> productStoreShipmentMethods = EntityQuery.use(delegator).from("ProductStoreShipmentMethView").where("productStoreId", productStoreId).queryList();
for (GenericValue productStoreShipmentMethod :productStoreShipmentMethods) {
if ("UPS".equals(productStoreShipmentMethod.get("partyId"))) {
Map<String,Object> thisUpsRateCodeMap = FastMap.newInstance();
carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod", false, UtilMisc.toMap("shipmentMethodTypeId",
productStoreShipmentMethod.getString("shipmentMethodTypeId"), "partyId", productStoreShipmentMethod.getString("partyId"), "roleTypeId", productStoreShipmentMethod.getString("roleTypeId")));
carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod")
.where("shipmentMethodTypeId", productStoreShipmentMethod.getString("shipmentMethodTypeId"), "partyId", productStoreShipmentMethod.getString("partyId"), "roleTypeId", productStoreShipmentMethod.getString("roleTypeId"))
.queryOne();
String serviceCode = carrierShipmentMethod.getString("carrierServiceCode");
for (String thisServiceCode : upsRateCodeMap.keySet()) {
if (serviceCode.equals(thisServiceCode)) {
@@ -106,8 +106,7 @@ public class UspsServices {
GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, productStore.getString("inventoryFacilityId"), UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION"));
if (facilityContactMech != null) {
try {
GenericValue shipFromAddress = delegator.findOne("PostalAddress",
UtilMisc.toMap("contactMechId", facilityContactMech.getString("contactMechId")), false);
GenericValue shipFromAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", facilityContactMech.getString("contactMechId")).queryOne();
if (shipFromAddress != null) {
originationZip = shipFromAddress.getString("postalCode");
}
@@ -146,9 +145,9 @@ public class UspsServices {
// get the service code
String serviceCode = null;
try {
GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod",
UtilMisc.toMap("shipmentMethodTypeId", (String) context.get("shipmentMethodTypeId"),
"partyId", (String) context.get("carrierPartyId"), "roleTypeId", (String) context.get("carrierRoleTypeId")), false);
GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod")
.where("shipmentMethodTypeId", (String) context.get("shipmentMethodTypeId"), "partyId", (String) context.get("carrierPartyId"), "roleTypeId", (String) context.get("carrierRoleTypeId"))
.queryOne();
if (carrierShipmentMethod != null) {
serviceCode = carrierShipmentMethod.getString("carrierServiceCode").toUpperCase();
}
@@ -315,9 +314,9 @@ public class UspsServices {
// get the service code
String serviceCode = null;
try {
GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod",
UtilMisc.toMap("shipmentMethodTypeId", (String) context.get("shipmentMethodTypeId"),
"partyId", (String) context.get("carrierPartyId"), "roleTypeId", (String) context.get("carrierRoleTypeId")), false);
GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod")
.where("shipmentMethodTypeId", (String) context.get("shipmentMethodTypeId"), "partyId", (String) context.get("carrierPartyId"), "roleTypeId", (String) context.get("carrierRoleTypeId"))
.queryOne();
if (carrierShipmentMethod != null) {
serviceCode = carrierShipmentMethod.getString("carrierServiceCode");
}
@@ -934,8 +933,7 @@ public class UspsServices {
}
try {
GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment",
UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false);
GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne();
if (shipmentRouteSegment == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"ProductShipmentRouteSegmentNotFound",
@@ -991,8 +989,7 @@ public class UspsServices {
String shipmentMethodTypeId = shipmentRouteSegment.getString("shipmentMethodTypeId");
String partyId = shipmentRouteSegment.getString("carrierPartyId");
GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod",
UtilMisc.toMap("partyId", partyId, "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentMethodTypeId), false);
GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod").where("partyId", partyId, "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentMethodTypeId).queryOne();
if (carrierShipmentMethod == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"FacilityShipmentUspsNoCarrierShipmentMethod",
@@ -1241,8 +1238,7 @@ public class UspsServices {
"ProductShipmentNotFoundId", locale) + shipmentId);
}
GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment",
UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false);
GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne();
if (shipmentRouteSegment == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"ProductShipmentRouteSegmentNotFound",
@@ -1286,8 +1282,7 @@ public class UspsServices {
String shipmentMethodTypeId = shipmentRouteSegment.getString("shipmentMethodTypeId");
String partyId = shipmentRouteSegment.getString("carrierPartyId");
GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod",
UtilMisc.toMap("partyId", partyId, "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentMethodTypeId), false);
GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod").where("partyId", partyId, "roleTypeId", "CARRIER", "shipmentMethodTypeId", shipmentMethodTypeId).queryOne();
if (carrierShipmentMethod == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"FacilityShipmentUspsNoCarrierShipmentMethod",
@@ -1369,8 +1364,7 @@ public class UspsServices {
}
if (!"WT_oz".equals(weightUomId)) {
// attempt a conversion to pounds
GenericValue uomConversion = delegator.findOne("UomConversion",
UtilMisc.toMap("uomId", weightUomId, "uomIdTo", "WT_oz"), false);
GenericValue uomConversion = EntityQuery.use(delegator).from("UomConversion").where("uomId", weightUomId, "uomIdTo", "WT_oz").queryOne();
if (uomConversion == null || UtilValidate.isEmpty(uomConversion.getString("conversionFactor"))) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"FacilityShipmentUspsWeightUnsupported",
@@ -1443,8 +1437,7 @@ public class UspsServices {
String shipmentId = (String) context.get("shipmentId");
String shipmentRouteSegmentId = (String) context.get("shipmentRouteSegmentId");
GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment",
UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false);
GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne();
List<GenericValue> shipmentPackageRouteSegList = shipmentRouteSegment.getRelated("ShipmentPackageRouteSeg", null, UtilMisc.toList("+shipmentPackageSeqId"), false);
@@ -394,12 +394,12 @@ public class VerifyPickSession implements Serializable {
newShipment.put("shipmentTypeId", "OUTGOING_SHIPMENT");
newShipment.put("statusId", "SHIPMENT_SCHEDULED");
newShipment.put("userLogin", this.getUserLogin());
GenericValue orderRoleShipTo = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "SHIP_TO_CUSTOMER"), null, false));
GenericValue orderRoleShipTo = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "roleTypeId", "SHIP_TO_CUSTOMER").queryFirst();
if (UtilValidate.isNotEmpty(orderRoleShipTo)) {
newShipment.put("partyIdTo", orderRoleShipTo.getString("partyId"));
}
String partyIdFrom = null;
GenericValue orderItemShipGroup = EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGroup", UtilMisc.toMap("orderId", orderId, "shipGroupSeqId", line.getShipGroupSeqId()), null, false));
GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", orderId, "shipGroupSeqId", line.getShipGroupSeqId()).queryFirst();
if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("vendorPartyId"))) {
partyIdFrom = orderItemShipGroup.getString("vendorPartyId");
} else if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("facilityId"))) {
@@ -409,11 +409,11 @@ public class VerifyPickSession implements Serializable {
}
}
if (UtilValidate.isEmpty(partyIdFrom)) {
GenericValue orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "SHIP_FROM_VENDOR"), null, false));
GenericValue orderRoleShipFrom = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "roleTypeId", "SHIP_FROM_VENDOR").queryFirst();
if (UtilValidate.isNotEmpty(orderRoleShipFrom)) {
partyIdFrom = orderRoleShipFrom.getString("partyId");
} else {
orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "BILL_FROM_VENDOR"), null, false));
orderRoleShipFrom = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "roleTypeId", "BILL_FROM_VENDOR").queryFirst();
partyIdFrom = orderRoleShipFrom.getString("partyId");
}
}
@@ -23,6 +23,7 @@ import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Locale;
import java.util.Map;
import javolution.util.FastMap;
import org.ofbiz.base.util.GeneralException;
@@ -30,6 +31,7 @@ import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ServiceUtil;
@@ -159,7 +161,7 @@ public class VerifyPickSessionRow implements Serializable {
picklistItemMap.put("shipGroupSeqId", this.getShipGroupSeqId());
picklistItemMap.put("inventoryItemId", this.getInventoryItemId());
GenericValue picklistItem = delegator.findOne("PicklistItem", picklistItemMap, true);
GenericValue picklistItem = EntityQuery.use(delegator).from("PicklistItem").where(picklistItemMap).cache(true).queryOne();
if (UtilValidate.isNotEmpty(picklistItem)) {
BigDecimal itemQty = picklistItem.getBigDecimal("quantity");
if (itemQty.compareTo(quantity) == 0) {
@@ -31,6 +31,7 @@ import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
@@ -64,7 +65,7 @@ public class WeightPackageServices {
}
try {
// Checked no of packages, it should not be greater than ordered quantity
List<GenericValue> orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId, "statusId", "ITEM_APPROVED"), null, false);
List<GenericValue> orderItems = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId, "statusId", "ITEM_APPROVED").queryList();
BigDecimal orderedItemQty = ZERO;
for (GenericValue orderItem : orderItems) {
orderedItemQty = orderedItemQty.add(orderItem.getBigDecimal("quantity"));
@@ -353,7 +353,7 @@ public class WeightPackageSession implements Serializable {
protected BigDecimal upsShipmentConfirm() throws GeneralException {
Delegator delegator = this.getDelegator();
BigDecimal actualCost = ZERO;
List<GenericValue> shipmentRouteSegments = delegator.findByAnd("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId), null, false);
List<GenericValue> shipmentRouteSegments = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId).queryList();
if (UtilValidate.isNotEmpty(shipmentRouteSegments)) {
for (GenericValue shipmentRouteSegment : shipmentRouteSegments) {
Map<String, Object> shipmentRouteSegmentMap = FastMap.newInstance();