You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2014/11/03 07:54:24 UTC
svn commit: r1636282 [2/20] - in
/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23: ./
applications/content/config/ applications/content/data/
applications/humanres/src/org/ofbiz/humanres/
applications/humanres/webapp/humanres/WEB-INF/ applicat...
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java Mon Nov 3 06:54:16 2014
@@ -31,6 +31,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.product.store.ProductStoreWorker;
import org.ofbiz.service.LocalDispatcher;
@@ -97,27 +98,28 @@ public class BOMTree {
this.delegator = delegator;
this.dispatcher = dispatcher;
- inputProduct = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
+ inputProduct = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
String productIdForRules = productId;
// The selected product features are loaded
- List<GenericValue> productFeaturesAppl = delegator.findByAnd("ProductFeatureAppl",
- UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE"), null, false);
+ List<GenericValue> productFeaturesAppl = EntityQuery.use(delegator).from("ProductFeatureAppl")
+ .where("productId", productId,
+ "productFeatureApplTypeId", "STANDARD_FEATURE")
+ .queryList();
List<GenericValue> productFeatures = FastList.newInstance();
GenericValue oneProductFeatureAppl = null;
for (int i = 0; i < productFeaturesAppl.size(); i++) {
oneProductFeatureAppl = productFeaturesAppl.get(i);
- productFeatures.add(delegator.findOne("ProductFeature",
- UtilMisc.toMap("productFeatureId", oneProductFeatureAppl.getString("productFeatureId")), false));
-
+ productFeatures.add(oneProductFeatureAppl.getRelatedOne("ProductFeature", false));
}
// If the product is manufactured as a different product,
// load the new product
GenericValue manufacturedAsProduct = manufacturedAsProduct(productId, inDate);
// We load the information about the product that needs to be manufactured
// from Product entity
- GenericValue product = delegator.findOne("Product",
- UtilMisc.toMap("productId", (manufacturedAsProduct != null? manufacturedAsProduct.getString("productIdTo"): productId)), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product")
+ .where("productId", (manufacturedAsProduct != null? manufacturedAsProduct.getString("productIdTo"): productId))
+ .queryOne();
if (product == null) return;
BOMNode originalNode = new BOMNode(product, dispatcher, userLogin);
originalNode.setTree(this);
@@ -133,8 +135,9 @@ public class BOMTree {
// load the new product
productIdForRules = virtualProduct.getString("productId");
manufacturedAsProduct = manufacturedAsProduct(virtualProduct.getString("productId"), inDate);
- product = delegator.findOne("Product",
- UtilMisc.toMap("productId", (manufacturedAsProduct != null? manufacturedAsProduct.getString("productIdTo"): virtualProduct.get("productId"))), false);
+ product = EntityQuery.use(delegator).from("Product")
+ .where("productId", (manufacturedAsProduct != null? manufacturedAsProduct.getString("productIdTo"): virtualProduct.get("productId")))
+ .queryOne();
}
}
if (product == null) return;
@@ -162,15 +165,10 @@ public class BOMTree {
}
private GenericValue manufacturedAsProduct(String productId, Date inDate) throws GenericEntityException {
- List<GenericValue> manufacturedAsProducts = delegator.findByAnd("ProductAssoc",
- UtilMisc.toMap("productId", productId,
- "productAssocTypeId", "PRODUCT_MANUFACTURED"), null, false);
- manufacturedAsProducts = EntityUtil.filterByDate(manufacturedAsProducts, inDate);
- GenericValue manufacturedAsProduct = null;
- if (UtilValidate.isNotEmpty(manufacturedAsProducts)) {
- manufacturedAsProduct = EntityUtil.getFirst(manufacturedAsProducts);
- }
- return manufacturedAsProduct;
+ return EntityQuery.use(delegator).from("ProductAssoc")
+ .where("productId", productId,
+ "productAssocTypeId", "PRODUCT_MANUFACTURED")
+ .filterByDate(inDate).queryFirst();
}
private boolean hasBom(GenericValue product, Date inDate) throws GenericEntityException {
@@ -333,7 +331,7 @@ public class BOMTree {
if (root != null) {
if (UtilValidate.isEmpty(facilityId)) {
if (orderId != null) {
- GenericValue order = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+ GenericValue order = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
String productStoreId = order.getString("productStoreId");
if (productStoreId != null) {
GenericValue productStore = ProductStoreWorker.getProductStore(productStoreId, delegator);
@@ -344,7 +342,7 @@ public class BOMTree {
}
if (facilityId == null && shipmentId != null) {
- GenericValue shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false);
+ GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne();
facilityId = shipment.getString("originFacilityId");
}
}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java Mon Nov 3 06:54:16 2014
@@ -33,6 +33,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.manufacturing.techdata.TechDataServices;
import org.ofbiz.service.LocalDispatcher;
@@ -76,11 +77,11 @@ public class ProductionRun {
try {
if (! UtilValidate.isEmpty(productionRunId)) {
this.dispatcher = dispatcher;
- GenericValue workEffort = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", productionRunId), false);
+ GenericValue workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", productionRunId).queryOne();
if (workEffort != null) {
// If this is a task, get the parent production run
if (workEffort.getString("workEffortTypeId") != null && "PROD_ORDER_TASK".equals(workEffort.getString("workEffortTypeId"))) {
- workEffort = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", workEffort.getString("workEffortParentId")), false);
+ workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", workEffort.getString("workEffortParentId")).queryOne();
}
}
this.productionRun = workEffort;
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java Mon Nov 3 06:54:16 2014
@@ -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;
import org.ofbiz.service.LocalDispatcher;
@@ -57,7 +58,7 @@ public class ProductionRunHelper {
try {
if (productionRunId != null) {
- GenericValue productionRun = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", productionRunId), false);
+ GenericValue productionRun = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", productionRunId).queryOne();
if (productionRun != null) {
List<GenericValue> productionRunProducts = productionRun.getRelated("WorkEffortGoodStandard", UtilMisc.toMap("workEffortGoodStdTypeId", "PRUN_PROD_DELIV"),null, false);
GenericValue productionRunProduct = EntityUtil.getFirst(productionRunProducts);
@@ -77,17 +78,20 @@ public class ProductionRunHelper {
}
public static boolean hasTask(Delegator delegator, String taskName, String workEffortId) throws GenericEntityException {
- List<GenericValue> tasks = delegator.findByAnd("WorkEffort",
- UtilMisc.toMap("workEffortParentId", workEffortId,
+ List<GenericValue> tasks = EntityQuery.use(delegator).from("WorkEffort")
+ .where("workEffortParentId", workEffortId,
"workEffortTypeId", "PROD_ORDER_TASK",
- "workEffortName", taskName), null, false);
+ "workEffortName", taskName)
+ .queryList();
return (UtilValidate.isNotEmpty(tasks));
}
public static void getLinkedProductionRuns(Delegator delegator, LocalDispatcher dispatcher, String productionRunId, List<ProductionRun> productionRuns) throws GenericEntityException {
productionRuns.add(new ProductionRun(productionRunId, delegator, dispatcher));
- List<GenericValue> linkedWorkEfforts = EntityUtil.filterByDate(delegator.findByAnd("WorkEffortAssoc",
- UtilMisc.toMap("workEffortIdTo", productionRunId, "workEffortAssocTypeId", "WORK_EFF_PRECEDENCY"), null, false));
+ List<GenericValue> linkedWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAssoc")
+ .where("workEffortIdTo", productionRunId,
+ "workEffortAssocTypeId", "WORK_EFF_PRECEDENCY")
+ .filterByDate().queryList();
for (int i = 0; i < linkedWorkEfforts.size(); i++) {
GenericValue link = linkedWorkEfforts.get(i);
getLinkedProductionRuns(delegator, dispatcher, link.getString("workEffortIdFrom"), productionRuns);
@@ -95,8 +99,9 @@ public class ProductionRunHelper {
}
public static String getRootProductionRun(Delegator delegator, String productionRunId) throws GenericEntityException {
- List<GenericValue> linkedWorkEfforts = delegator.findByAnd("WorkEffortAssoc", UtilMisc.toMap("workEffortIdFrom", productionRunId, "workEffortAssocTypeId", "WORK_EFF_PRECEDENCY"), null, false);
- GenericValue linkedWorkEffort = EntityUtil.getFirst(linkedWorkEfforts);
+ GenericValue linkedWorkEffort = EntityQuery.use(delegator).from("WorkEffortAssoc")
+ .where("workEffortIdFrom", productionRunId, "workEffortAssocTypeId", "WORK_EFF_PRECEDENCY")
+ .queryFirst();
if (linkedWorkEffort != null) {
productionRunId = getRootProductionRun(delegator, linkedWorkEffort.getString("workEffortIdTo"));
}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Mon Nov 3 06:54:16 2014
@@ -44,6 +44,7 @@ import org.ofbiz.entity.GenericPK;
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.entity.util.EntityTypeUtil;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.manufacturing.bom.BOMNode;
@@ -121,9 +122,11 @@ public class ProductionRunServices {
serviceContext.put("userLogin", userLogin);
dispatcher.runSync("updateWorkEffort", serviceContext);
// Cancel the product promised
- List<GenericValue> products = delegator.findByAnd("WorkEffortGoodStandard",
- UtilMisc.toMap("workEffortId", productionRunId, "workEffortGoodStdTypeId", "PRUN_PROD_DELIV",
- "statusId", "WEGS_CREATED"), null, false);
+ List<GenericValue> products = EntityQuery.use(delegator).from("WorkEffortGoodStandard")
+ .where("workEffortId", productionRunId,
+ "workEffortGoodStdTypeId", "PRUN_PROD_DELIV",
+ "statusId", "WEGS_CREATED")
+ .queryList();
if (!UtilValidate.isEmpty(products)) {
for (GenericValue product : products) {
product.set("statusId", "WEGS_CANCELLED");
@@ -142,9 +145,11 @@ public class ProductionRunServices {
serviceContext.put("userLogin", userLogin);
dispatcher.runSync("updateWorkEffort", serviceContext);
// cancel all the components
- List<GenericValue> components = delegator.findByAnd("WorkEffortGoodStandard",
- UtilMisc.toMap("workEffortId", taskId, "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED",
- "statusId", "WEGS_CREATED"), null, false);
+ List<GenericValue> components = EntityQuery.use(delegator).from("WorkEffortGoodStandard")
+ .where("workEffortId", taskId,
+ "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED",
+ "statusId", "WEGS_CREATED")
+ .queryList();
if (!UtilValidate.isEmpty(components)) {
for (GenericValue component : components) {
component.set("statusId", "WEGS_CANCELLED");
@@ -204,7 +209,7 @@ public class ProductionRunServices {
List<GenericValue> routingTaskAssocs = null;
try {
// Find the product
- product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
+ product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
if (product == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductNotExist", locale));
}
@@ -642,7 +647,10 @@ public class ProductionRunServices {
// change only the production run (header) status to PRUN_RUNNING
// First check if there are production runs with precedence not still completed
try {
- List<GenericValue> mandatoryWorkEfforts = EntityUtil.filterByDate(delegator.findByAnd("WorkEffortAssoc", UtilMisc.toMap("workEffortIdTo", productionRunId, "workEffortAssocTypeId", "WORK_EFF_PRECEDENCY"), null, false));
+ List<GenericValue> mandatoryWorkEfforts = EntityQuery.use(delegator).from("WorkEffortAssoc")
+ .where("workEffortIdTo", productionRunId,
+ "workEffortAssocTypeId", "WORK_EFF_PRECEDENCY")
+ .filterByDate().queryList();
for (int i = 0; i < mandatoryWorkEfforts.size(); i++) {
GenericValue mandatoryWorkEffortAssoc = mandatoryWorkEfforts.get(i);
GenericValue mandatoryWorkEffort = mandatoryWorkEffortAssoc.getRelatedOne("FromWorkEffort", false);
@@ -828,7 +836,9 @@ public class ProductionRunServices {
if (issueAllComponents.booleanValue()) {
// Issue all the components, if this task needs components and they still need to be issued
try {
- List<GenericValue> inventoryAssigned = delegator.findByAnd("WorkEffortInventoryAssign", UtilMisc.toMap("workEffortId", taskId), null, false);
+ List<GenericValue> inventoryAssigned = EntityQuery.use(delegator).from("WorkEffortInventoryAssign")
+ .where("workEffortId", taskId)
+ .queryList();
if (UtilValidate.isEmpty(inventoryAssigned)) {
serviceContext.clear();
serviceContext.put("workEffortId", taskId);
@@ -919,9 +929,9 @@ public class ProductionRunServices {
totalCost = ZERO;
}
- List<GenericValue> productCostComponentCalcs = delegator.findByAnd("ProductCostComponentCalc",
- UtilMisc.toMap("productId", productionRun.getProductProduced().getString("productId")),
- UtilMisc.toList("sequenceNum"), false);
+ List<GenericValue> productCostComponentCalcs = EntityQuery.use(delegator).from("ProductCostComponentCalc")
+ .where("productId", productionRun.getProductProduced().get("productId"))
+ .orderBy("sequenceNum").queryList();
for (int i = 0; i < productCostComponentCalcs.size(); i++) {
GenericValue productCostComponentCalc = productCostComponentCalcs.get(i);
GenericValue costComponentCalc = productCostComponentCalc.getRelatedOne("CostComponentCalc", false);
@@ -969,13 +979,14 @@ public class ProductionRunServices {
String workEffortId = (String)context.get("workEffortId");
Locale locale = (Locale) context.get("locale");
try {
- GenericValue workEffort = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", workEffortId), false);
+ GenericValue workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", workEffortId).queryOne();
if (workEffort == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingWorkEffortNotExist", locale) + " " + workEffortId);
}
// Get all the valid CostComponents entries
- List<GenericValue> costComponents = EntityUtil.filterByDate(delegator.findByAnd("CostComponent",
- UtilMisc.toMap("workEffortId", workEffortId), null, false));
+ List<GenericValue> costComponents = EntityQuery.use(delegator).from("CostComponent")
+ .where("workEffortId", workEffortId)
+ .filterByDate().queryList();
result.put("costComponents", costComponents);
// TODO: before doing these totals we should convert the cost components' costs to the
// base currency uom of the owner of the facility in which the task is running
@@ -1004,8 +1015,10 @@ public class ProductionRunServices {
String workEffortId = (String)context.get("workEffortId");
Locale locale = (Locale) context.get("locale");
try {
- List<GenericValue> tasks = delegator.findByAnd("WorkEffort",
- UtilMisc.toMap("workEffortParentId", workEffortId), UtilMisc.toList("workEffortId"), false);
+ List<GenericValue> tasks = EntityQuery.use(delegator).from("WorkEffort")
+ .where("workEffortParentId", workEffortId)
+ .orderBy("workEffortId")
+ .queryList();
BigDecimal totalCost = ZERO;
Map<String, Object> outputMap = dispatcher.runSync("getWorkEffortCosts",
UtilMisc.<String, Object>toMap("userLogin", userLogin, "workEffortId", workEffortId));
@@ -1033,7 +1046,7 @@ public class ProductionRunServices {
// this is the id of the actual (real) production run task
String productionRunTaskId = (String)context.get("productionRunTaskId");
try {
- GenericValue workEffort = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", productionRunTaskId), false);
+ GenericValue workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", productionRunTaskId).queryOne();
if (UtilValidate.isEmpty(workEffort)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunTaskNotFound", UtilMisc.toMap("productionRunTaskId", productionRunTaskId), locale));
}
@@ -1049,18 +1062,19 @@ public class ProductionRunServices {
actualTotalMilliSeconds += actualSetupMillis.doubleValue();
actualTotalMilliSeconds += actualMilliSeconds.doubleValue();
// Get the template (aka routing task) of the work effort
- GenericValue routingTaskAssoc = EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd("WorkEffortAssoc",
- UtilMisc.toMap("workEffortIdTo", productionRunTaskId,
- "workEffortAssocTypeId", "WORK_EFF_TEMPLATE"), null, false)));
+ GenericValue routingTaskAssoc = EntityQuery.use(delegator).from("WorkEffortAssoc")
+ .where("workEffortIdTo", productionRunTaskId,
+ "workEffortAssocTypeId", "WORK_EFF_TEMPLATE")
+ .filterByDate().queryFirst();
GenericValue routingTask = null;
- if (UtilValidate.isNotEmpty(routingTaskAssoc)) {
+ if (routingTaskAssoc != null) {
routingTask = routingTaskAssoc.getRelatedOne("FromWorkEffort", false);
}
// Get all the valid CostComponentCalc entries
- List<GenericValue> workEffortCostCalcs = delegator.findByAnd("WorkEffortCostCalc",
- UtilMisc.toMap("workEffortId", productionRunTaskId), null, false);
- workEffortCostCalcs = EntityUtil.filterByDate(workEffortCostCalcs);
+ List<GenericValue> workEffortCostCalcs = EntityQuery.use(delegator).from("WorkEffortCostCalc")
+ .where("workEffortId", productionRunTaskId)
+ .filterByDate().queryList();
for (GenericValue workEffortCostCalc : workEffortCostCalcs) {
GenericValue costComponentCalc = workEffortCostCalc.getRelatedOne("CostComponentCalc", false);
@@ -1139,8 +1153,8 @@ public class ProductionRunServices {
// materials costs: these are the costs derived from the materials used by the production run task
try {
Map<String, BigDecimal> materialsCostByCurrency = FastMap.newInstance();
- for (GenericValue inventoryConsumed : delegator.findByAnd("WorkEffortAndInventoryAssign",
- UtilMisc.toMap("workEffortId", productionRunTaskId), null, false)) {
+ for (GenericValue inventoryConsumed : EntityQuery.use(delegator).from("WorkEffortAndInventoryAssign")
+ .where("workEffortId", productionRunTaskId).queryList()) {
BigDecimal quantity = inventoryConsumed.getBigDecimal("quantity");
BigDecimal unitCost = inventoryConsumed.getBigDecimal("unitCost");
if (UtilValidate.isEmpty(unitCost) || UtilValidate.isEmpty(quantity)) {
@@ -1294,7 +1308,7 @@ public class ProductionRunServices {
try {
// Find the product
- GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
if (product == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductNotExist", locale));
}
@@ -1368,7 +1382,7 @@ public class ProductionRunServices {
try {
// Find the product
- GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false);
+ GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
if (product == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductNotExist", locale));
}
@@ -1437,7 +1451,7 @@ public class ProductionRunServices {
// The routing task is loaded
GenericValue routingTask = null;
try {
- routingTask = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", routingTaskId), false);
+ routingTask = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", routingTaskId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingRoutingTaskNotExists", locale));
@@ -1503,8 +1517,9 @@ public class ProductionRunServices {
// copy date valid WorkEffortPartyAssignments from the routing task to the run task
List<GenericValue> workEffortPartyAssignments = null;
try {
- workEffortPartyAssignments = EntityUtil.filterByDate(delegator.findByAnd("WorkEffortPartyAssignment",
- UtilMisc.toMap("workEffortId", routingTaskId), null, false));
+ workEffortPartyAssignments = EntityQuery.use(delegator).from("WorkEffortPartyAssignment")
+ .where("workEffortId", routingTaskId)
+ .filterByDate().queryList();
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), module);
}
@@ -1607,7 +1622,7 @@ public class ProductionRunServices {
if (UtilValidate.isNotEmpty(lotId)) {
try {
// Find the lot
- GenericValue lot = delegator.findOne("Lot", UtilMisc.toMap("lotId", lotId), false);
+ GenericValue lot = EntityQuery.use(delegator).from("Lot").where("lotId", lotId).queryOne();
if (lot == null) {
if (createLotIfNeeded.booleanValue()) {
lot = delegator.makeValue("Lot", UtilMisc.toMap("lotId", lotId, "creationDate", UtilDateTime.nowTimestamp()));
@@ -1960,17 +1975,20 @@ public class ProductionRunServices {
// If less than passed quantity then return an error message.
try {
BigDecimal totalIssued = BigDecimal.ZERO;
- for (GenericValue issuance : delegator.findByAnd("WorkEffortAndInventoryAssign",
- UtilMisc.toMap("workEffortId", productionRunTaskId, "productId", productId), null, false)) {
+ for (GenericValue issuance : EntityQuery.use(delegator).from("WorkEffortAndInventoryAssign")
+ .where("workEffortId", productionRunTaskId, "productId", productId).queryList()) {
BigDecimal issued = issuance.getBigDecimal("quantity");
if (issued != null) {
totalIssued = totalIssued.add(issued);
}
}
BigDecimal totalReturned = BigDecimal.ZERO;
- for (GenericValue returned : delegator.findByAnd("WorkEffortAndInventoryProduced",
- UtilMisc.toMap("workEffortId", productionRunTaskId, "productId", productId), null, false)) {
- GenericValue returnDetail = EntityUtil.getFirst(delegator.findByAnd("InventoryItemDetail", UtilMisc.toMap("inventoryItemId", returned.getString("inventoryItemId")), UtilMisc.toList("inventoryItemDetailSeqId"), false));
+ for (GenericValue returned : EntityQuery.use(delegator).from("WorkEffortAndInventoryProduced")
+ .where("workEffortId", productionRunTaskId, "productId", productId).queryList()) {
+ GenericValue returnDetail = EntityQuery.use(delegator).from("InventoryItemDetail")
+ .where("inventoryItemId", returned.get("inventoryItemId"))
+ .orderBy("inventoryItemDetailSeqId")
+ .queryFirst();
if (returnDetail != null) {
BigDecimal qtyReturned = returnDetail.getBigDecimal("quantityOnHandDiff");
if (qtyReturned != null) {
@@ -2092,7 +2110,10 @@ public class ProductionRunServices {
for (GenericValue component : components) {
BigDecimal totalRequiredMaterialQuantity = component.getBigDecimal("estimatedQuantity").multiply(totalQuantityProduced).divide(quantityToProduce, rounding);
// now get the units that have been already issued and subtract them
- List<GenericValue> issuances = delegator.findByAnd("WorkEffortAndInventoryAssign", UtilMisc.toMap("workEffortId", workEffortId, "productId", component.getString("productId")), null, false);
+ List<GenericValue> issuances = EntityQuery.use(delegator).from("WorkEffortAndInventoryAssign")
+ .where("workEffortId", workEffortId,
+ "productId", component.get("productId"))
+ .queryList();
BigDecimal totalIssued = BigDecimal.ZERO;
for (GenericValue issuance : issuances) {
BigDecimal issued = issuance.getBigDecimal("quantity");
@@ -2187,7 +2208,7 @@ public class ProductionRunServices {
String requirementId = (String)context.get("requirementId");
GenericValue requirement = null;
try {
- requirement = delegator.findOne("Requirement", UtilMisc.toMap("requirementId", requirementId), false);
+ requirement = EntityQuery.use(delegator).from("Requirement").where("requirementId", requirementId).queryOne();
} catch (GenericEntityException gee) {
}
@@ -2218,7 +2239,7 @@ public class ProductionRunServices {
GenericValue requirement = null;
try {
- requirement = delegator.findOne("Requirement", UtilMisc.toMap("requirementId", requirementId), false);
+ requirement = EntityQuery.use(delegator).from("Requirement").where("requirementId", requirementId).queryOne();
} catch (GenericEntityException gee) {
}
if (requirement == null) {
@@ -2344,9 +2365,10 @@ public class ProductionRunServices {
// check if a bom exists
List<GenericValue> bomList = null;
try {
- bomList = delegator.findByAnd("ProductAssoc",
- UtilMisc.toMap("productId", componentProductId, "productAssocTypeId", "MANUF_COMPONENT"), null, false);
- bomList = EntityUtil.filterByDate(bomList, UtilDateTime.nowTimestamp());
+ bomList = EntityQuery.use(delegator).from("ProductAssoc")
+ .where("productId", componentProductId,
+ "productAssocTypeId", "MANUF_COMPONENT")
+ .filterByDate().queryList();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunTryToGetBomListError", locale));
}
@@ -2441,7 +2463,7 @@ public class ProductionRunServices {
// hasn't been reserved and ATP not yet decreased
boolean isImmediatelyFulfilled = false;
try {
- GenericValue order = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false);
+ GenericValue order = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne();
GenericValue productStore = delegator.getRelatedOne("ProductStore", order, false);
isImmediatelyFulfilled = "Y".equals(productStore.getString("isImmediatelyFulfilled"));
} catch (GenericEntityException e) {
@@ -2450,7 +2472,7 @@ public class ProductionRunServices {
GenericValue orderItem = null;
try {
- orderItem = delegator.findOne("OrderItem", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId), false);
+ orderItem = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryOne();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunForMarketingPackagesCreationError", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "errorString", e.getMessage()), locale));
}
@@ -2568,9 +2590,9 @@ public class ProductionRunServices {
try {
GenericValue orderItem = null;
if (UtilValidate.isNotEmpty(shipGroupSeqId)) {
- orderItem = delegator.findOne("OrderItemShipGroupAssoc", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId), false);
+ orderItem = EntityQuery.use(delegator).from("OrderItemShipGroupAssoc").where("orderId", orderId, "orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId).queryOne();
} else {
- orderItem = delegator.findOne("OrderItem", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId), false);
+ orderItem = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId, "orderItemSeqId", orderItemSeqId).queryOne();
}
if (orderItem == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder, "OrderErrorOrderItemNotFound", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", ""), locale));
@@ -2584,7 +2606,7 @@ public class ProductionRunServices {
}
} else {
try {
- orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId), null, false);
+ orderItems = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId).queryList();
if (orderItems == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrder, "OrderErrorOrderItemNotFound", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", ""), locale));
}
@@ -2626,13 +2648,16 @@ public class ProductionRunServices {
try {
List<GenericValue> existingProductionRuns = null;
if (UtilValidate.isNotEmpty(shipGroupSeqId)) {
- existingProductionRuns = delegator.findByAnd("WorkOrderItemFulfillment",
- UtilMisc.toMap("orderId", orderItemOrShipGroupAssoc.getString("orderId"),
- "orderItemSeqId", orderItemOrShipGroupAssoc.getString("orderItemSeqId"), "shipGroupSeqId", shipGroupSeqId), null, true);
+ existingProductionRuns = EntityQuery.use(delegator).from("WorkOrderItemFulfillment")
+ .where("orderId", orderItemOrShipGroupAssoc.get("orderId"),
+ "orderItemSeqId", orderItemOrShipGroupAssoc.get("orderItemSeqId"),
+ "shipGroupSeqId", shipGroupSeqId)
+ .cache().queryList();
} else {
- existingProductionRuns = delegator.findByAnd("WorkOrderItemFulfillment",
- UtilMisc.toMap("orderId", orderItemOrShipGroupAssoc.getString("orderId"),
- "orderItemSeqId", orderItemOrShipGroupAssoc.getString("orderItemSeqId")), null, true);
+ existingProductionRuns = EntityQuery.use(delegator).from("WorkOrderItemFulfillment")
+ .where("orderId", orderItemOrShipGroupAssoc.get("orderId"),
+ "orderItemSeqId", orderItemOrShipGroupAssoc.get("orderItemSeqId"))
+ .cache().queryList();
}
if (UtilValidate.isNotEmpty(existingProductionRuns)) {
Debug.logWarning("Production Run for order item [" + orderItemOrShipGroupAssoc.getString("orderId") + "/" + orderItemOrShipGroupAssoc.getString("orderItemSeqId") + "] and ship group [" + shipGroupSeqId + "] already exists.", module);
@@ -2712,7 +2737,7 @@ public class ProductionRunServices {
try {
Map<String, Object> serviceContext = FastMap.newInstance();
Map<String, Object> resultService = null;
- GenericValue task = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", taskId), false);
+ GenericValue task = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", taskId).queryOne();
String currentStatusId = task.getString("currentStatusId");
String prevStatusId = "";
while (!"PRUN_COMPLETED".equals(currentStatusId)) {
@@ -2913,9 +2938,10 @@ public class ProductionRunServices {
findOutgoingProductionRunsStatusConds.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "PRUN_RUNNING"));
findOutgoingProductionRunsConds.add(EntityCondition.makeCondition(findOutgoingProductionRunsStatusConds, EntityOperator.OR));
- List<GenericValue> outgoingProductionRuns = delegator.findList("WorkEffortAndGoods",
- EntityCondition.makeCondition(findOutgoingProductionRunsConds, EntityOperator.AND), null,
- UtilMisc.toList("-estimatedStartDate"), null, false);
+ List<GenericValue> outgoingProductionRuns = EntityQuery.use(delegator).from("WorkEffortAndGoods")
+ .where(findOutgoingProductionRunsConds)
+ .orderBy("-estimatedStartDate")
+ .queryList();
if (outgoingProductionRuns != null) {
for (int i = 0; i < outgoingProductionRuns.size(); i++) {
GenericValue outgoingProductionRun = outgoingProductionRuns.get(i);
@@ -2945,7 +2971,7 @@ public class ProductionRunServices {
}
*/
try {
- GenericValue inventoryItem = delegator.findOne("InventoryItem", UtilMisc.toMap("inventoryItemId", inventoryItemId), false);
+ GenericValue inventoryItem = EntityQuery.use(delegator).from("InventoryItem").where("inventoryItemId", inventoryItemId).queryOne();
if (inventoryItem == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceProduct, "ProductInventoryItemNotFound", UtilMisc.toMap("inventoryItemId", inventoryItemId), locale));
}
@@ -2985,8 +3011,8 @@ public class ProductionRunServices {
BigDecimal quantity = (BigDecimal)context.get("quantity");
List<String> inventoryItemIds = FastList.newInstance();
try {
- GenericValue inventoryItem = delegator.findOne("InventoryItem",
- UtilMisc.toMap("inventoryItemId", inventoryItemId), false);
+ GenericValue inventoryItem = EntityQuery.use(delegator).from("InventoryItem")
+ .where("inventoryItemId", inventoryItemId).queryOne();
if (inventoryItem == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunCannotDecomposingInventoryItem", UtilMisc.toMap("inventoryItemId", inventoryItemId), locale));
}
@@ -3086,9 +3112,11 @@ public class ProductionRunServices {
Map<String, TreeMap<Timestamp, Object>> products = FastMap.newInstance();
try {
- List<GenericValue> resultList = delegator.findByAnd("WorkEffortAndGoods",
- UtilMisc.toMap("workEffortGoodStdTypeId", "PRUN_PROD_DELIV",
- "statusId", "WEGS_CREATED", "workEffortTypeId", "PROD_ORDER_HEADER"), null, false);
+ List<GenericValue> resultList = EntityQuery.use(delegator).from("WorkEffortAndGoods")
+ .where("workEffortGoodStdTypeId", "PRUN_PROD_DELIV",
+ "statusId", "WEGS_CREATED",
+ "workEffortTypeId", "PROD_ORDER_HEADER")
+ .queryList();
for (GenericValue genericResult : resultList) {
if ("PRUN_CLOSED".equals(genericResult.getString("currentStatusId")) ||
"PRUN_CREATED".equals(genericResult.getString("currentStatusId"))) {
@@ -3127,9 +3155,10 @@ public class ProductionRunServices {
}
// Approved purchase orders
- resultList = delegator.findByAnd("OrderHeaderAndItems",
- UtilMisc.toMap("orderTypeId", "PURCHASE_ORDER",
- "itemStatusId", "ITEM_APPROVED"), UtilMisc.toList("orderId"), false);
+ resultList = EntityQuery.use(delegator).from("OrderHeaderAndItems")
+ .where("orderTypeId", "PURCHASE_ORDER",
+ "itemStatusId", "ITEM_APPROVED")
+ .orderBy("orderId").queryList();
String orderId = null;
GenericValue orderDeliverySchedule = null;
for (GenericValue genericResult : resultList) {
@@ -3138,7 +3167,7 @@ public class ProductionRunServices {
orderDeliverySchedule = null;
orderId = newOrderId;
try {
- orderDeliverySchedule = delegator.findOne("OrderDeliverySchedule", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", "_NA_"), false);
+ orderDeliverySchedule = EntityQuery.use(delegator).from("OrderDeliverySchedule").where("orderId", orderId, "orderItemSeqId", "_NA_").queryOne();
} catch (GenericEntityException e) {
}
}
@@ -3146,7 +3175,7 @@ public class ProductionRunServices {
BigDecimal orderQuantity = genericResult.getBigDecimal("quantity");
GenericValue orderItemDeliverySchedule = null;
try {
- orderItemDeliverySchedule = delegator.findOne("OrderDeliverySchedule", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", genericResult.getString("orderItemSeqId")), false);
+ orderItemDeliverySchedule = EntityQuery.use(delegator).from("OrderDeliverySchedule").where("orderId", orderId, "orderItemSeqId", genericResult.getString("orderItemSeqId")).queryOne();
} catch (GenericEntityException e) {
}
Timestamp estimatedShipDate = null;
@@ -3180,13 +3209,16 @@ public class ProductionRunServices {
backordersCondList.add(EntityCondition.makeCondition("quantityNotAvailable", EntityOperator.GREATER_THAN, BigDecimal.ZERO));
//backordersCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ITEM_CREATED"), EntityOperator.OR, EntityCondition.makeCondition("statusId", EntityOperator.LESS_THAN, "ITEM_APPROVED")));
- List<GenericValue> backorders = delegator.findList("OrderItemAndShipGrpInvResAndItem",
- EntityCondition.makeCondition(backordersCondList, EntityOperator.AND), null,
- UtilMisc.toList("shipBeforeDate"), null, false);
+ List<GenericValue> backorders = EntityQuery.use(delegator).from("OrderItemAndShipGrpInvResAndItem")
+ .where(EntityCondition.makeCondition("quantityNotAvailable", EntityOperator.NOT_EQUAL, null),
+ EntityCondition.makeCondition("quantityNotAvailable", EntityOperator.GREATER_THAN, BigDecimal.ZERO))
+ .orderBy("shipBeforeDate").queryList();
for (GenericValue genericResult : backorders) {
String productId = genericResult.getString("productId");
- GenericValue orderItemShipGroup = delegator.findOne("OrderItemShipGroup", UtilMisc.toMap("orderId", genericResult.get("orderId"),
- "shipGroupSeqId", genericResult.get("shipGroupSeqId")), false);
+ GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup")
+ .where("orderId", genericResult.get("orderId"),
+ "shipGroupSeqId", genericResult.get("shipGroupSeqId"))
+ .queryOne();
Timestamp requiredByDate = orderItemShipGroup.getTimestamp("shipByDate");
BigDecimal quantityNotAvailable = genericResult.getBigDecimal("quantityNotAvailable");
@@ -3211,11 +3243,12 @@ public class ProductionRunServices {
if (remainingQty.compareTo(quantityNotAvailableRem) >= 0) {
remainingQty = remainingQty.subtract(quantityNotAvailableRem);
currentDateMap.put("remainingQty", remainingQty);
- GenericValue orderItemShipGrpInvRes = delegator.findOne("OrderItemShipGrpInvRes",
- UtilMisc.toMap("orderId", genericResult.getString("orderId"),
- "shipGroupSeqId", genericResult.getString("shipGroupSeqId"),
- "orderItemSeqId", genericResult.getString("orderItemSeqId"),
- "inventoryItemId", genericResult.getString("inventoryItemId")), false);
+ GenericValue orderItemShipGrpInvRes = EntityQuery.use(delegator).from("OrderItemShipGrpInvRes").
+ where("orderId", genericResult.get("orderId"),
+ "shipGroupSeqId", genericResult.get("shipGroupSeqId"),
+ "orderItemSeqId", genericResult.get("orderItemSeqId"),
+ "inventoryItemId", genericResult.get("inventoryItemId"))
+ .queryOne();
orderItemShipGrpInvRes.set("promisedDatetime", currentDate);
orderItemShipGrpInvRes.store();
// TODO: set the reservation
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java Mon Nov 3 06:54:16 2014
@@ -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.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
@@ -66,7 +67,7 @@ public class InventoryEventPlannedServic
public static void createOrUpdateMrpEvent(Map<String, Object> mrpEventKeyMap, BigDecimal newQuantity, String facilityId,
String eventName, boolean isLate, Delegator delegator) throws GenericEntityException {
GenericValue mrpEvent = null;
- mrpEvent = delegator.findOne("MrpEvent", mrpEventKeyMap, false);
+ mrpEvent = EntityQuery.use(delegator).from("MrpEvent").where(mrpEventKeyMap).queryOne();
if (mrpEvent == null) {
mrpEvent = delegator.makeValue("MrpEvent", mrpEventKeyMap);
mrpEvent.put("quantity", newQuantity.doubleValue());
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java Mon Nov 3 06:54:16 2014
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
-import java.util.Set;
import javolution.util.FastList;
import javolution.util.FastMap;
@@ -40,9 +39,8 @@ import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
-import org.ofbiz.entity.condition.EntityExpr;
-import org.ofbiz.entity.condition.EntityFieldMap;
import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.manufacturing.bom.BOMNode;
import org.ofbiz.order.order.OrderReadHelper;
@@ -77,7 +75,7 @@ public class MrpServices {
List<GenericValue> listResult = null;
try {
- listResult = delegator.findList("MrpEvent", null, null, null, null, false);
+ listResult = EntityQuery.use(delegator).from("MrpEvent").queryList();
//int numOfRecordsRemoved = delegator.removeByCondition("MrpEvent", null);
} catch (GenericEntityException e) {
Debug.logError(e,"Error : findList(\"MrpEvent\", null, null, null, null, false)", module);
@@ -96,7 +94,10 @@ public class MrpServices {
listResult = null;
List<GenericValue> listResultRoles = FastList.newInstance();
try {
- listResult = delegator.findByAnd("Requirement", UtilMisc.toMap("requirementTypeId", "PRODUCT_REQUIREMENT", "statusId", "REQ_PROPOSED"), null, false);
+ listResult = EntityQuery.use(delegator).from("Requirement")
+ .where("requirementTypeId", "PRODUCT_REQUIREMENT",
+ "statusId", "REQ_PROPOSED")
+ .queryList();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventFindError", locale));
}
@@ -114,7 +115,10 @@ public class MrpServices {
}
listResult = null;
try {
- listResult = delegator.findByAnd("Requirement", UtilMisc.toMap("requirementTypeId", "INTERNAL_REQUIREMENT", "statusId", "REQ_PROPOSED"), null, false);
+ listResult = EntityQuery.use(delegator).from("Requirement")
+ .where("requirementTypeId", "INTERNAL_REQUIREMENT",
+ "statusId", "REQ_PROPOSED")
+ .queryList();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventFindError", locale));
}
@@ -142,13 +146,13 @@ public class MrpServices {
notAssignedDate = new Timestamp(calendar.getTimeInMillis());
}
resultList = null;
- parameters = UtilMisc.<String, Object>toMap("orderTypeId", "SALES_ORDER", "oiStatusId", "ITEM_APPROVED");
- parameters.put("facilityId", facilityId);
try {
- resultList = delegator.findByAnd("OrderHeaderItemAndShipGroup", parameters, UtilMisc.toList("orderId"), false);
+ resultList = EntityQuery.use(delegator).from("OrderHeaderItemAndShipGroup")
+ .where("orderTypeId", "SALES_ORDER",
+ "oiStatusId", "ITEM_APPROVED",
+ "facilityId", facilityId)
+ .orderBy("orderId").queryList();
} catch (GenericEntityException e) {
- Debug.logError(e, "Error : findByAnd(\"OrderItem\", parameters\")", module);
- Debug.logError(e, "Error : parameters = "+parameters,module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventFindError", locale));
}
for (GenericValue genericResult : resultList) {
@@ -203,10 +207,12 @@ public class MrpServices {
// Loads all the approved product requirements (po requirements)
// ----------------------------------------
resultList = null;
- parameters = UtilMisc.<String, Object>toMap("requirementTypeId", "PRODUCT_REQUIREMENT",
- "statusId", "REQ_APPROVED", "facilityId", facilityId);
try {
- resultList = delegator.findByAnd("Requirement", parameters, null, false);
+ resultList = EntityQuery.use(delegator).from("Requirement")
+ .where("requirementTypeId", "PRODUCT_REQUIREMENT",
+ "statusId", "REQ_APPROVED",
+ "facilityId", facilityId)
+ .queryList();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventFindError", locale));
}
@@ -236,13 +242,19 @@ public class MrpServices {
String orderId = null;
GenericValue orderDeliverySchedule = null;
try {
- List<GenericValue> facilityContactMechs = EntityUtil.filterByDate(delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId), null, false));
+ List<GenericValue> facilityContactMechs = EntityQuery.use(delegator).from("FacilityContactMech")
+ .where("facilityId", facilityId)
+ .filterByDate().queryList();
List<String> facilityContactMechIds = EntityUtil.getFieldListFromEntityList(facilityContactMechs, "contactMechId", true);
- List<EntityExpr> searchConditions = UtilMisc.toList(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER"),
- EntityCondition.makeCondition("oiStatusId", EntityOperator.EQUALS, "ITEM_APPROVED"),
- EntityCondition.makeCondition("contactMechId", EntityOperator.IN, facilityContactMechIds));
- Set<String> fieldsToSelect = UtilMisc.toSet("orderId", "orderItemSeqId", "productId", "quantity", "cancelQuantity", "oiEstimatedDeliveryDate");
- resultList = delegator.findList("OrderHeaderItemAndShipGroup", EntityCondition.makeCondition(searchConditions, EntityOperator.AND), fieldsToSelect, UtilMisc.toList("orderDate"), null, false);
+
+ resultList = EntityQuery.use(delegator)
+ .select("orderId", "orderItemSeqId", "productId", "quantity", "cancelQuantity", "oiEstimatedDeliveryDate")
+ .from("OrderHeaderItemAndShipGroup")
+ .where(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER"),
+ EntityCondition.makeCondition("oiStatusId", EntityOperator.EQUALS, "ITEM_APPROVED"),
+ EntityCondition.makeCondition("contactMechId", EntityOperator.IN, facilityContactMechIds))
+ .orderBy("orderDate")
+ .queryList();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventFindError", locale));
@@ -253,7 +265,7 @@ public class MrpServices {
orderDeliverySchedule = null;
orderId = newOrderId;
try {
- orderDeliverySchedule = delegator.findOne("OrderDeliverySchedule", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", "_NA_"), false);
+ orderDeliverySchedule = EntityQuery.use(delegator).from("OrderDeliverySchedule").where("orderId", orderId, "orderItemSeqId", "_NA_").queryOne();
} catch (GenericEntityException e) {
}
}
@@ -280,7 +292,7 @@ public class MrpServices {
GenericValue orderItemDeliverySchedule = null;
try {
- orderItemDeliverySchedule = delegator.findOne("OrderDeliverySchedule", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", genericResult.getString("orderItemSeqId")), false);
+ orderItemDeliverySchedule = EntityQuery.use(delegator).from("OrderDeliverySchedule").where("orderId", orderId, "orderItemSeqId", genericResult.getString("orderItemSeqId")).queryOne();
} catch (GenericEntityException e) {
}
Timestamp estimatedShipDate = null;
@@ -307,10 +319,12 @@ public class MrpServices {
// PRODUCTION Run: components
// ----------------------------------------
resultList = null;
- parameters = UtilMisc.<String, Object>toMap("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED",
- "statusId", "WEGS_CREATED", "facilityId", facilityId);
try {
- resultList = delegator.findByAnd("WorkEffortAndGoods", parameters, null, false);
+ resultList = EntityQuery.use(delegator).from("WorkEffortAndGoods")
+ .where("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED",
+ "statusId", "WEGS_CREATED",
+ "facilityId", facilityId)
+ .queryList();
for (GenericValue genericResult : resultList) {
if ("PRUN_CLOSED".equals(genericResult.getString("currentStatusId")) ||
"PRUN_COMPLETED".equals(genericResult.getString("currentStatusId")) ||
@@ -320,7 +334,9 @@ public class MrpServices {
String productId = genericResult.getString("productId");
// get the inventory already consumed
BigDecimal consumedInventoryTotal = BigDecimal.ZERO;
- List<GenericValue> consumedInventoryItems = delegator.findByAnd("WorkEffortAndInventoryAssign", UtilMisc.toMap("workEffortId", genericResult.getString("workEffortId"), "productId", productId), null, false);
+ List<GenericValue> consumedInventoryItems = EntityQuery.use(delegator).from("WorkEffortAndInventoryAssign")
+ .where("workEffortId", genericResult.get("workEffortId"), "productId", productId)
+ .queryList();
for (GenericValue consumedInventoryItem : consumedInventoryItems) {
consumedInventoryTotal = consumedInventoryTotal.add(consumedInventoryItem.getBigDecimal("quantity"));
}
@@ -342,10 +358,13 @@ public class MrpServices {
// PRODUCTION Run: product produced
// ----------------------------------------
resultList = null;
- parameters = UtilMisc.<String, Object>toMap("workEffortGoodStdTypeId", "PRUN_PROD_DELIV",
- "statusId", "WEGS_CREATED", "workEffortTypeId", "PROD_ORDER_HEADER", "facilityId", facilityId);
try {
- resultList = delegator.findByAnd("WorkEffortAndGoods", parameters, null, false);
+ resultList = EntityQuery.use(delegator).from("WorkEffortAndGoods")
+ .where("workEffortGoodStdTypeId", "PRUN_PROD_DELIV",
+ "statusId", "WEGS_CREATED",
+ "workEffortTypeId", "PROD_ORDER_HEADER",
+ "facilityId", facilityId)
+ .queryList();
for (GenericValue genericResult : resultList) {
if ("PRUN_CLOSED".equals(genericResult.getString("currentStatusId")) ||
"PRUN_COMPLETED".equals(genericResult.getString("currentStatusId")) ||
@@ -384,7 +403,9 @@ public class MrpServices {
resultList = null;
parameters = UtilMisc.<String, Object>toMap("facilityId", facilityId);
try {
- resultList = delegator.findByAnd("ProductFacility", parameters, null, false);
+ resultList = EntityQuery.use(delegator).from("ProductFacility")
+ .where("facilityId", facilityId)
+ .queryList();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to retrieve ProductFacility records.", module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpCannotFindProductFacility", locale));
@@ -396,8 +417,9 @@ public class MrpServices {
minimumStock = BigDecimal.ZERO;
}
try {
- EntityFieldMap ecl = EntityCondition.makeCondition(UtilMisc.toMap("mrpId", mrpId, "productId", productId), EntityOperator.AND);
- long numOfEvents = delegator.findCountByCondition("MrpEvent", ecl, null, null);
+ long numOfEvents = EntityQuery.use(delegator).from("MrpEvent")
+ .where("mrpId", mrpId, "productId", productId)
+ .queryCount();
if (numOfEvents > 0) {
continue;
}
@@ -423,13 +445,15 @@ public class MrpServices {
resultList = null;
GenericValue facility = null;
try {
- facility = delegator.findOne("Facility", UtilMisc.toMap("facilityId", facilityId), false);
+ facility = EntityQuery.use(delegator).from("Facility").where("facilityId", facilityId).queryOne();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventFindError", locale));
}
String partyId = (String)facility.get("ownerPartyId");
try {
- resultList = delegator.findByAnd("SalesForecast", UtilMisc.toMap("organizationPartyId", partyId), null, false);
+ resultList = EntityQuery.use(delegator).from("SalesForecast")
+ .where("organizationPartyId", partyId)
+ .queryList();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpCannotFindSalesForecasts", locale));
}
@@ -437,7 +461,7 @@ public class MrpServices {
String customTimePeriodId = genericResult.getString("customTimePeriodId");
GenericValue customTimePeriod = null;
try {
- customTimePeriod = delegator.findOne("CustomTimePeriod", UtilMisc.toMap("customTimePeriodId", customTimePeriodId), false);
+ customTimePeriod = EntityQuery.use(delegator).from("CustomTimePeriod").where("customTimePeriodId", customTimePeriodId).queryOne();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpCannotFindCustomTimePeriod", locale));
}
@@ -447,7 +471,9 @@ public class MrpServices {
} else {
List<GenericValue> salesForecastDetails = null;
try {
- salesForecastDetails = delegator.findByAnd("SalesForecastDetail", UtilMisc.toMap("salesForecastId", genericResult.getString("salesForecastId")), null, false);
+ salesForecastDetails = EntityQuery.use(delegator).from("SalesForecastDetail")
+ .where("salesForecastId", genericResult.get("salesForecastId"))
+ .queryList();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpCannotFindSalesForecastDetails", locale));
}
@@ -590,7 +616,7 @@ public class MrpServices {
}
if (UtilValidate.isEmpty(facilityId)) {
try {
- GenericValue facilityGroup = delegator.findOne("FacilityGroup", UtilMisc.toMap("facilityGroupId", facilityGroupId), false);
+ GenericValue facilityGroup = EntityQuery.use(delegator).from("FacilityGroup").where("facilityGroupId", facilityGroupId).queryOne();
if (UtilValidate.isEmpty(facilityGroup)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpFacilityGroupIsNotValid", UtilMisc.toMap("facilityGroupId", facilityGroupId), locale));
}
@@ -661,7 +687,10 @@ public class MrpServices {
filterByConditions = EntityCondition.makeCondition("billOfMaterialLevel", EntityOperator.EQUALS, Long.valueOf(bomLevel));
}
try {
- listInventoryEventForMRP = delegator.findList("MrpEventView", filterByConditions, null, UtilMisc.toList("productId", "eventDate"), null, false);
+ listInventoryEventForMRP = EntityQuery.use(delegator).from("MrpEventView")
+ .where(filterByConditions)
+ .orderBy("productId", "eventDate")
+ .queryList();
} catch (GenericEntityException e) {
Long bomLevelToString = new Long(bomLevel);
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpErrorForBomLevel", UtilMisc.toMap("bomLevel", bomLevelToString.toString(), "errorString", e.getMessage()), locale));
@@ -750,7 +779,7 @@ public class MrpServices {
String routingId = (String)serviceResponse.get("workEffortId");
if (routingId != null) {
try {
- routing = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", routingId), false);
+ routing = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", routingId).queryOne();
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpCannotFindProductForEvent", locale));
}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java Mon Nov 3 06:54:16 2014
@@ -29,6 +29,7 @@ import org.ofbiz.base.util.UtilPropertie
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.manufacturing.jobshopmgt.ProductionRun;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.LocalDispatcher;
@@ -68,7 +69,7 @@ public class RoutingServices {
GenericValue task = null;
try {
- task = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", taskId), false);
+ task = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", taskId).queryOne();
} catch (GenericEntityException gee) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingRoutingErrorFindingTask", UtilMisc.toMap("taskId", taskId), locale));
}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java Mon Nov 3 06:54:16 2014
@@ -39,6 +39,7 @@ import org.ofbiz.entity.condition.Entity
import org.ofbiz.entity.condition.EntityConditionList;
import org.ofbiz.entity.condition.EntityExpr;
import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
@@ -81,9 +82,11 @@ public class TechDataServices {
constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "ROU_ACTIVE"));
constraints.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "ROU_TASK"));
- EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(constraints, EntityOperator.AND);
try {
- listRoutingTask = delegator.findList("WorkEffort", ecl, null, UtilMisc.toList("workEffortName"), null, false);
+ listRoutingTask = EntityQuery.use(delegator).from("WorkEffort")
+ .where(constraints)
+ .orderBy("workEffortName")
+ .queryList();
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingTechDataWorkEffortNotExist", UtilMisc.toMap("errorString", e.toString()), locale));
@@ -124,7 +127,10 @@ public class TechDataServices {
List<GenericValue> listRoutingTaskAssoc = null;
try {
- listRoutingTaskAssoc = delegator.findByAnd("WorkEffortAssoc",UtilMisc.toMap("workEffortIdFrom", workEffortIdFrom,"sequenceNum",sequenceNum), UtilMisc.toList("fromDate"), false);
+ listRoutingTaskAssoc = EntityQuery.use(delegator).from("WorkEffortAssoc")
+ .where("workEffortIdFrom", workEffortIdFrom,"sequenceNum",sequenceNum)
+ .orderBy("fromDate")
+ .queryList();
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingTechDataWorkEffortAssocNotExist", UtilMisc.toMap("errorString", e.toString()), locale));
@@ -197,7 +203,7 @@ public class TechDataServices {
if (techDataCalendar == null) {
try {
Delegator delegator = routingTask.getDelegator();
- techDataCalendar = delegator.findOne("TechDataCalendar",UtilMisc.toMap("calendarId","DEFAULT"), false);
+ techDataCalendar = EntityQuery.use(delegator).from("TechDataCalendar").where("calendarId", "DEFAULT").queryOne();
} catch (GenericEntityException e) {
Debug.logError("Pb reading TechDataCalendar DEFAULT"+e.getMessage(), module);
}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java Mon Nov 3 06:54:16 2014
@@ -19,7 +19,6 @@
package org.ofbiz.marketing.marketing;
import java.sql.Timestamp;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -31,9 +30,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.condition.EntityCondition;
-import org.ofbiz.entity.condition.EntityOperator;
-import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
@@ -67,33 +64,32 @@ public class MarketingServices {
try {
// locate the contact list
- Map<String, Object> input = UtilMisc.<String, Object>toMap("contactListId", contactListId);
- GenericValue contactList = delegator.findOne("ContactList", input, false);
+ GenericValue contactList = EntityQuery.use(delegator).from("ContactList").where("contactListId", contactListId).queryOne();
if (contactList == null) {
- String error = UtilProperties.getMessage(resourceMarketing, "MarketingContactListNotFound", input, locale);
+ String error = UtilProperties.getMessage(resourceMarketing, "MarketingContactListNotFound", UtilMisc.<String, Object>toMap("contactListId", contactListId), locale);
return ServiceUtil.returnError(error);
}
// perform actions as the system user
- GenericValue userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true);
+ GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
// associate the email with anonymous user TODO: do we need a custom contact mech purpose type, say MARKETING_EMAIL?
if (partyId == null) {
// Check existing email
- List<EntityCondition> conds = UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("infoString", EntityOperator.EQUALS, email));
- conds.add(EntityCondition.makeCondition("contactMechTypeId", EntityOperator.EQUALS, "EMAIL_ADDRESS"));
- conds.add(EntityCondition.makeCondition("contactMechPurposeTypeId", EntityOperator.EQUALS, "PRIMARY_EMAIL"));
- conds.add(EntityUtil.getFilterByDateExpr("purposeFromDate", "purposeThruDate"));
- conds.add(EntityUtil.getFilterByDateExpr());
- List<GenericValue> contacts = delegator.findList("PartyContactDetailByPurpose", EntityCondition.makeCondition(conds), null, UtilMisc.toList("-fromDate"), null, false);
- if (UtilValidate.isNotEmpty(contacts)) {
- GenericValue contact = EntityUtil.getFirst(contacts);
+ GenericValue contact = EntityQuery.use(delegator).from("PartyContactDetailByPurpose")
+ .where("infoString", email,
+ "contactMechTypeId", "EMAIL_ADDRESS",
+ "contactMechPurposeTypeId", "PRIMARY_EMAIL")
+ .orderBy("-fromDate")
+ .filterByDate("fromDate", "thruDate", "purposeFromDate", "purposeThruDate")
+ .queryFirst();
+ if (contact != null) {
partyId = contact.getString("partyId");
} else {
partyId = "_NA_";
}
}
- input = UtilMisc.toMap("userLogin", userLogin, "emailAddress", email, "partyId", partyId, "fromDate", fromDate, "contactMechPurposeTypeId", "OTHER_EMAIL");
+ Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "emailAddress", email, "partyId", partyId, "fromDate", fromDate, "contactMechPurposeTypeId", "OTHER_EMAIL");
Map<String, Object> serviceResults = dispatcher.runSync("createPartyEmailAddress", input);
if (ServiceUtil.isError(serviceResults)) {
throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceResults));
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java Mon Nov 3 06:54:16 2014
@@ -38,6 +38,7 @@ import org.ofbiz.webapp.website.WebSiteW
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.EntityUtilProperties;
import org.ofbiz.product.category.CategoryWorker;
@@ -61,7 +62,7 @@ public class TrackingCodeEvents {
Delegator delegator = (Delegator) request.getAttribute("delegator");
GenericValue trackingCode;
try {
- trackingCode = delegator.findOne("TrackingCode", UtilMisc.toMap("trackingCodeId", trackingCodeId), true);
+ trackingCode = EntityQuery.use(delegator).from("TrackingCode").where("trackingCodeId", trackingCodeId).cache().queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this trackingCodeId", module);
return "error";
@@ -98,7 +99,7 @@ public class TrackingCodeEvents {
Delegator delegator = (Delegator) request.getAttribute("delegator");
GenericValue trackingCode;
try {
- trackingCode = delegator.findOne("TrackingCode", UtilMisc.toMap("trackingCodeId", trackingCodeId), true);
+ trackingCode = EntityQuery.use(delegator).from("TrackingCode").where("trackingCodeId", trackingCodeId).cache().queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this trackingCodeId", module);
return "error";
@@ -114,7 +115,7 @@ public class TrackingCodeEvents {
if (UtilValidate.isNotEmpty(dtc)) {
GenericValue defaultTrackingCode = null;
try {
- defaultTrackingCode = delegator.findOne("TrackingCode", UtilMisc.toMap("trackingCodeId", dtc), true);
+ defaultTrackingCode = EntityQuery.use(delegator).from("TrackingCode").where("trackingCodeId", dtc).cache().queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up Default values TrackingCode with trackingCodeId [" + dtc + "], not using the dtc value for new TrackingCode defaults", module);
}
@@ -209,7 +210,7 @@ public class TrackingCodeEvents {
String webSiteId = WebSiteWorker.getWebSiteId(request);
if (webSiteId != null) {
try {
- GenericValue webSite = delegator.findOne("WebSite", UtilMisc.toMap("webSiteId", webSiteId), true);
+ GenericValue webSite = EntityQuery.use(delegator).from("WebSite").where("webSiteId", webSiteId).cache().queryOne();
if (webSite != null) {
cookieDomain = webSite.getString("cookieDomain");
}
@@ -320,7 +321,7 @@ public class TrackingCodeEvents {
String trackingCodeId = cookies[i].getValue();
GenericValue trackingCode;
try {
- trackingCode = delegator.findOne("TrackingCode", UtilMisc.toMap("trackingCodeId", trackingCodeId), true);
+ trackingCode = EntityQuery.use(delegator).from("TrackingCode").where("trackingCodeId", trackingCodeId).cache().queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this trackingCodeId", module);
continue;
@@ -382,7 +383,7 @@ public class TrackingCodeEvents {
// find the tracking code object
GenericValue trackingCode = null;
try {
- trackingCode = delegator.findOne("TrackingCode", UtilMisc.toMap("trackingCodeId", trackingCodeId), true);
+ trackingCode = EntityQuery.use(delegator).from("TrackingCode").where("trackingCodeId", trackingCodeId).cache().queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this trackingCodeId", module);
}
@@ -480,7 +481,7 @@ public class TrackingCodeEvents {
}
GenericValue trackingCode = null;
try {
- trackingCode = delegator.findOne("TrackingCode", UtilMisc.toMap("trackingCodeId", trackingCodeId), true);
+ trackingCode = EntityQuery.use(delegator).from("TrackingCode").where("trackingCodeId", trackingCodeId).cache().queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Error looking up TrackingCode with trackingCodeId [" + trackingCodeId + "], ignoring this trackingCodeId", module);
}
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/sfa/vcard/VCard.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/sfa/vcard/VCard.java?rev=1636282&r1=1636281&r2=1636282&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/sfa/vcard/VCard.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/marketing/src/org/ofbiz/sfa/vcard/VCard.java Mon Nov 3 06:54:16 2014
@@ -27,12 +27,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Iterator;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
import javolution.util.FastMap;
-
import net.wimpi.pim.Pim;
import net.wimpi.pim.contact.basicimpl.AddressImpl;
import net.wimpi.pim.contact.basicimpl.EmailAddressImpl;
@@ -61,7 +59,7 @@ import org.ofbiz.entity.GenericEntityExc
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityOperator;
-import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.party.party.PartyHelper;
import org.ofbiz.party.party.PartyWorker;
import org.ofbiz.service.DispatchContext;
@@ -116,23 +114,19 @@ public class VCard {
serviceCtx.put("city", workAddress.getCity());
serviceCtx.put("postalCode", workAddress.getPostalCode());
- List<GenericValue> countryGeoList = null;
- List<GenericValue> stateGeoList = null;
- EntityCondition cond = EntityCondition.makeCondition(UtilMisc.toList(
- EntityCondition.makeCondition("geoTypeId", EntityOperator.EQUALS, "COUNTRY"),
- EntityCondition.makeCondition("geoName", EntityOperator.LIKE, workAddress.getCountry())), EntityOperator.AND);
- countryGeoList = delegator.findList("Geo", cond, null, null, null, true);
- if (!countryGeoList.isEmpty()) {
- GenericValue countryGeo = EntityUtil.getFirst(countryGeoList);
+ GenericValue countryGeo = EntityQuery.use(delegator).from("Geo")
+ .where(EntityCondition.makeCondition("geoTypeId", EntityOperator.EQUALS, "COUNTRY"),
+ EntityCondition.makeCondition("geoName", EntityOperator.LIKE, workAddress.getCountry()))
+ .cache().queryFirst();
+ if (countryGeo != null) {
serviceCtx.put("countryGeoId", countryGeo.get("geoId"));
}
- EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(
- EntityCondition.makeCondition("geoTypeId", EntityOperator.EQUALS, "STATE"),
- EntityCondition.makeCondition("geoName", EntityOperator.LIKE, workAddress.getRegion())), EntityOperator.AND);
- stateGeoList = delegator.findList("Geo", condition, null, null, null, true);
- if (!stateGeoList.isEmpty()) {
- GenericValue stateGeo = EntityUtil.getFirst(stateGeoList);
+ GenericValue stateGeo = EntityQuery.use(delegator).from("Geo")
+ .where(EntityCondition.makeCondition("geoTypeId", EntityOperator.EQUALS, "STATE"),
+ EntityCondition.makeCondition("geoName", EntityOperator.LIKE, workAddress.getRegion()))
+ .cache().queryFirst();
+ if (stateGeo != null) {
serviceCtx.put("stateProvinceGeoId", stateGeo.get("geoId"));
}
}