Author: lektran
Date: Wed Sep 16 00:58:07 2009
New Revision: 815581
URL:
http://svn.apache.org/viewvc?rev=815581&view=revLog:
Added date filtering to getProductFeatureByApplTypeId and cleaned up the method a little
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java?rev=815581&r1=815580&r2=815581&view=diff==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java Wed Sep 16 00:58:07 2009
@@ -43,6 +43,8 @@
import org.ofbiz.entity.GenericDelegator;
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.util.EntityUtil;
import org.ofbiz.product.config.ProductConfigWrapper;
import org.ofbiz.product.config.ProductConfigWrapper.ConfigOption;
@@ -448,23 +450,24 @@
if (product == null) {
return null;
}
- List<GenericValue> features = FastList.newInstance();
+ List<GenericValue> features = null;
try {
if (product != null) {
List<GenericValue> productAppls;
- if (productFeatureApplTypeId == null) {
- productAppls = product.getRelated("ProductFeatureAppl");
- } else {
- productAppls = product.getRelatedByAnd("ProductFeatureAppl",
- UtilMisc.toMap("productFeatureApplTypeId", productFeatureApplTypeId));
- }
- for (GenericValue productAppl: productAppls) {
- features.add(productAppl.getRelatedOne("ProductFeature"));
- }
- features = EntityUtil.orderBy(features, UtilMisc.toList("description"));
+ List<EntityCondition> condList = UtilMisc.toList(
+ EntityCondition.makeCondition("productId", product.getString("productId")),
+ EntityUtil.getFilterByDateExpr()
+ );
+ if (productFeatureApplTypeId != null) {
+ condList.add(EntityCondition.makeCondition("productFeatureApplTypeId", productFeatureApplTypeId));
+ }
+ EntityCondition cond = EntityCondition.makeCondition(condList);
+ productAppls = product.getDelegator().findList("ProductFeatureAppl", cond, null, UtilMisc.toList("description"), null, false);
+ features = EntityUtil.getRelated("ProductFeature", productAppls);
}
} catch (GenericEntityException e) {
Debug.logError(e, module);
+ features = FastList.newInstance();
}
return features;
}