Author: jonesde
Date: Tue May 27 18:58:46 2008 New Revision: 660780 URL: http://svn.apache.org/viewvc?rev=660780&view=rev Log: Changed the way EntityCondition sub-classes work so they use the javolution Reusable class for recycling objects; now all conditions should be created using the factory methods on the EntityCondition object instead of the direct constructors; there is a small variety of classes available there now for ease of use; also changed a bunch of old code to not use the deprecated constructors; note that still need to do a pass similar to this on EntityExpr Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodWorker.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByAndFinder.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java ofbiz/trunk/framework/workflow/src/org/ofbiz/workflow/client/WorkflowServices.java Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Tue May 27 18:58:46 2008 @@ -68,10 +68,10 @@ public static List getStateList(GenericDelegator delegator) { List geoList = FastList.newInstance(); - EntityCondition condition = new EntityConditionList(UtilMisc.toList( + EntityCondition condition = EntityCondition.makeCondition(EntityOperator.OR, new EntityExpr("geoTypeId", EntityOperator.EQUALS, "STATE"), new EntityExpr("geoTypeId", EntityOperator.EQUALS, "PROVINCE"), - new EntityExpr("geoTypeId", EntityOperator.EQUALS, "TERRITORY")), EntityOperator.OR); - List sortList = UtilMisc.toList("geoName"); + new EntityExpr("geoTypeId", EntityOperator.EQUALS, "TERRITORY")); + List<String> sortList = UtilMisc.toList("geoName"); try { geoList = delegator.findList("Geo", condition, null, sortList, null, true); } catch (GenericEntityException e) { @@ -83,22 +83,20 @@ /** * Returns a list of regional geo associations. */ - public static List getAssociatedStateList(GenericDelegator delegator, String country) { + public static List<GenericValue> getAssociatedStateList(GenericDelegator delegator, String country) { if (country == null || country.length() == 0) { // Load the system default country country = UtilProperties.getPropertyValue("general.properties", "country.geo.id.default"); } - EntityCondition stateProvinceFindCond = new EntityConditionList(UtilMisc.toList( + EntityCondition stateProvinceFindCond = EntityCondition.makeCondition( new EntityExpr("geoIdFrom", EntityOperator.EQUALS, country), new EntityExpr("geoAssocTypeId", EntityOperator.EQUALS, "REGIONS"), - new EntityConditionList(UtilMisc.toList( + EntityCondition.makeCondition(EntityOperator.OR, new EntityExpr("geoTypeId", EntityOperator.EQUALS, "STATE"), - new EntityExpr("geoTypeId", EntityOperator.EQUALS, "PROVINCE") - ), EntityOperator.OR) - ), EntityOperator.AND); + new EntityExpr("geoTypeId", EntityOperator.EQUALS, "PROVINCE"))); List<String> sortList = UtilMisc.toList("geoId"); - List geoList = FastList.newInstance(); + List<GenericValue> geoList = FastList.newInstance(); try { geoList = delegator.findList("GeoAssocAndGeoTo", stateProvinceFindCond, null, sortList, null, true); } catch (GenericEntityException e) { Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java Tue May 27 18:58:46 2008 @@ -491,7 +491,7 @@ EntityConditionList exprList = null; if (tmpList.size() > 0) { - exprList = new EntityConditionList(tmpList, EntityOperator.AND); + exprList = EntityCondition.makeCondition(tmpList); } List orderByList = null; Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java Tue May 27 18:58:46 2008 @@ -377,8 +377,7 @@ EntityFindOptions efo = new EntityFindOptions(); efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE); exprs.add(new EntityExpr("userLoginId", EntityOperator.EQUALS, userLoginId)); - List orderBy = UtilMisc.toList("-fromDate"); - EntityListIterator eli = delegator.find("UserLoginPasswordHistory", new EntityConditionList(exprs, EntityOperator.AND), null, null, orderBy, efo); + EntityListIterator eli = delegator.find("UserLoginPasswordHistory", EntityCondition.makeCondition(exprs), null, null, UtilMisc.toList("-fromDate"), efo); Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); GenericValue pwdHist; if((pwdHist = (GenericValue) eli.next()) !=null){ Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodServices.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodServices.java Tue May 27 18:58:46 2008 @@ -28,7 +28,7 @@ import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.condition.EntityConditionList; +import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.service.DispatchContext; @@ -64,7 +64,7 @@ // if a periodTypeId was supplied, use it findClosedConditions.add(new EntityExpr("periodTypeId", EntityOperator.EQUALS, periodTypeId)); } - List closedTimePeriods = delegator.findList("CustomTimePeriod", new EntityConditionList(findClosedConditions, EntityOperator.AND), + List closedTimePeriods = delegator.findList("CustomTimePeriod", EntityCondition.makeCondition(findClosedConditions), UtilMisc.toSet("customTimePeriodId", "periodTypeId", "isClosed", "fromDate", "thruDate"), UtilMisc.toList("thruDate DESC"), null, false); Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodWorker.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodWorker.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/period/PeriodWorker.java Tue May 27 18:58:46 2008 @@ -49,11 +49,9 @@ thruDate = UtilDateTime.toTimestamp(timePeriod.getDate("thruDate")); } - EntityConditionList betweenCondition = new EntityConditionList(UtilMisc.toList( - new EntityExpr( fieldName, EntityOperator.GREATER_THAN, fromDate ), - new EntityExpr( fieldName, EntityOperator.LESS_THAN_EQUAL_TO, thruDate ) - ), EntityOperator.AND); - List conditions = UtilMisc.toList(new EntityExpr( fieldName, EntityOperator.NOT_EQUAL, null ), betweenCondition); - return new EntityConditionList(UtilMisc.toList(conditions), EntityOperator.AND); + EntityConditionList betweenCondition = EntityCondition.makeCondition( + new EntityExpr(fieldName, EntityOperator.GREATER_THAN, fromDate), + new EntityExpr(fieldName, EntityOperator.LESS_THAN_EQUAL_TO, thruDate)); + return EntityCondition.makeCondition(new EntityExpr(fieldName, EntityOperator.NOT_EQUAL, null), betweenCondition); } } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Tue May 27 18:58:46 2008 @@ -546,7 +546,7 @@ /** Creates a Primary Key in the form of a GenericPK without persisting it */ public GenericPK makePK(String entityName) { - return this.makePK(entityName, (Map) null); + return this.makePK(entityName, (Map<String, Object>) null); } /** Creates a Primary Key in the form of a GenericPK without persisting it */ @@ -1029,7 +1029,7 @@ *@return int representing number of rows effected by this operation */ public int removeByAnd(String entityName, Map<String, ? extends Object> fields, boolean doCacheClear) throws GenericEntityException { - EntityCondition ecl = new EntityFieldMap(fields, EntityOperator.AND); + EntityCondition ecl = EntityCondition.makeCondition(fields); return removeByCondition(entityName, ecl, doCacheClear); } @@ -1386,7 +1386,7 @@ } public int removeAll(String entityName) throws GenericEntityException { - return removeByAnd(entityName, (Map) null); + return removeByAnd(entityName, (Map<String, Object>) null); } /** Remove the Entities from the List from the persistent store. @@ -1891,7 +1891,7 @@ * @return List of GenericValue instances that match the query */ public List<GenericValue> findByAnd(String entityName, Map<String, ? extends Object> fields) throws GenericEntityException { - EntityCondition ecl = new EntityFieldMap(fields, EntityOperator.AND); + EntityCondition ecl = EntityCondition.makeCondition(fields); return this.findList(entityName, ecl, null, null, null, false); } @@ -1903,7 +1903,7 @@ *@deprecated Use findList() instead */ public List<GenericValue> findByOr(String entityName, Object... fields) throws GenericEntityException { - EntityCondition ecl = new EntityFieldMap(UtilMisc.<String, Object>toMap(fields), EntityOperator.OR); + EntityCondition ecl = EntityCondition.makeCondition(EntityOperator.OR, fields); return this.findList(entityName, ecl, null, null, null, false); } @@ -1915,7 +1915,7 @@ *@deprecated Use findList() instead */ public List<GenericValue> findByOr(String entityName, Map<String, ? extends Object> fields) throws GenericEntityException { - EntityCondition ecl = new EntityFieldMap(fields, EntityOperator.OR); + EntityCondition ecl = EntityCondition.makeCondition(fields, EntityOperator.OR); return this.findList(entityName, ecl, null, null, null, false); } @@ -1928,7 +1928,7 @@ * @return List of GenericValue instances that match the query */ public List<GenericValue> findByAnd(String entityName, Map<String, ? extends Object> fields, List<String> orderBy) throws GenericEntityException { - EntityCondition ecl = new EntityFieldMap(fields, EntityOperator.AND); + EntityCondition ecl = EntityCondition.makeCondition(fields); return this.findList(entityName, ecl, null, orderBy, null, false); } @@ -1942,7 +1942,7 @@ *@deprecated Use findList() instead */ public List<GenericValue> findByOr(String entityName, Map<String, ? extends Object> fields, List<String> orderBy) throws GenericEntityException { - EntityCondition ecl = new EntityFieldMap(fields, EntityOperator.OR); + EntityCondition ecl = EntityCondition.makeCondition(fields, EntityOperator.OR); return this.findList(entityName, ecl, null, orderBy, null, false); } @@ -1964,7 +1964,7 @@ *@return List of GenericValue instances that match the query */ public List<GenericValue> findByAndCache(String entityName, Map<String, ? extends Object> fields) throws GenericEntityException { - return this.findList(entityName, new EntityFieldMap(fields, EntityOperator.AND), null, null, null, true); + return this.findList(entityName, EntityCondition.makeCondition(fields), null, null, null, true); } /** Finds Generic Entity records by all of the specified fields (ie: combined using AND), looking first in the cache; uses orderBy for lookup, but only keys results on the entityName and fields @@ -1975,7 +1975,7 @@ *@return List of GenericValue instances that match the query */ public List<GenericValue> findByAndCache(String entityName, Map<String, ? extends Object> fields, List<String> orderBy) throws GenericEntityException { - return this.findList(entityName, new EntityFieldMap(fields, EntityOperator.AND), null, orderBy, null, true); + return this.findList(entityName, EntityCondition.makeCondition(fields), null, orderBy, null, true); } /** Finds Generic Entity records by all of the specified expressions (ie: combined using AND) @@ -1986,7 +1986,7 @@ *@deprecated Use findList() instead */ public <T extends EntityCondition> List<GenericValue> findByAnd(String entityName, T... expressions) throws GenericEntityException { - EntityConditionList<T> ecl = new EntityConditionList<T>(Arrays.asList(expressions), EntityOperator.AND); + EntityConditionList<T> ecl = EntityCondition.makeCondition(EntityOperator.AND, expressions); return this.findList(entityName, ecl, null, null, null, false); } @@ -1998,7 +1998,7 @@ *@deprecated Use findList() instead */ public <T extends EntityCondition> List<GenericValue> findByAnd(String entityName, List<T> expressions) throws GenericEntityException { - EntityConditionList<T> ecl = new EntityConditionList<T>(expressions, EntityOperator.AND); + EntityConditionList<T> ecl = EntityCondition.makeCondition(expressions, EntityOperator.AND); return this.findList(entityName, ecl, null, null, null, false); } @@ -2011,7 +2011,7 @@ *@deprecated Use findList() instead */ public <T extends EntityCondition> List<GenericValue> findByAnd(String entityName, List<T> expressions, List<String> orderBy) throws GenericEntityException { - EntityConditionList<T> ecl = new EntityConditionList<T>(expressions, EntityOperator.AND); + EntityConditionList<T> ecl = EntityCondition.makeCondition(expressions, EntityOperator.AND); return this.findList(entityName, ecl, null, orderBy, null, false); } @@ -2023,7 +2023,7 @@ *@deprecated Use findList() instead */ public <T extends EntityCondition> List<GenericValue> findByOr(String entityName, T... expressions) throws GenericEntityException { - return this.findList(entityName, new EntityConditionList<T>(Arrays.asList(expressions), EntityOperator.AND), null, null, null, false); + return this.findList(entityName, EntityCondition.makeCondition(EntityOperator.AND, expressions), null, null, null, false); } /** Finds Generic Entity records by all of the specified expressions (ie: combined using OR) @@ -2034,7 +2034,7 @@ *@deprecated Use findList() instead */ public <T extends EntityCondition> List<GenericValue> findByOr(String entityName, List<T> expressions) throws GenericEntityException { - EntityConditionList<T> ecl = new EntityConditionList<T>(expressions, EntityOperator.OR); + EntityConditionList<T> ecl = EntityCondition.makeCondition(expressions, EntityOperator.OR); return this.findList(entityName, ecl, null, null, null, false); } @@ -2047,7 +2047,7 @@ *@deprecated Use findList() instead */ public <T extends EntityCondition> List<GenericValue> findByOr(String entityName, List<T> expressions, List<String> orderBy) throws GenericEntityException { - EntityConditionList<T> ecl = new EntityConditionList<T>(expressions, EntityOperator.OR); + EntityConditionList<T> ecl = EntityCondition.makeCondition(expressions, EntityOperator.OR); return this.findList(entityName, ecl, null, orderBy, null, false); } @@ -2063,7 +2063,7 @@ likeExpressions.add(new EntityExpr(fieldEntry.getKey(), EntityOperator.LIKE, fieldEntry.getValue())); } } - EntityConditionList<EntityExpr> ecl = new EntityConditionList<EntityExpr>(likeExpressions, EntityOperator.AND); + EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(likeExpressions, EntityOperator.AND); return this.findList(entityName, ecl, null, null, null, false); } @@ -2078,7 +2078,7 @@ likeExpressions.add(new EntityExpr(fieldEntry.getKey(), EntityOperator.LIKE, fieldEntry.getValue())); } } - EntityConditionList<EntityExpr> ecl = new EntityConditionList<EntityExpr>(likeExpressions, EntityOperator.AND); + EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(likeExpressions, EntityOperator.AND); return this.findList(entityName, ecl, null, null, null, false); } @@ -2093,7 +2093,7 @@ likeExpressions.add(new EntityExpr(fieldEntry.getKey(), EntityOperator.LIKE, fieldEntry.getValue())); } } - EntityConditionList<EntityExpr> ecl = new EntityConditionList<EntityExpr>(likeExpressions, EntityOperator.AND); + EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(likeExpressions, EntityOperator.AND); return this.findList(entityName, ecl, null, orderBy, null, false); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java Tue May 27 18:58:46 2008 @@ -31,6 +31,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityFieldMap; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.model.ModelEntity; @@ -353,7 +354,7 @@ *@param fields the fields that must equal in order to keep *@return List of GenericValue instances as specified in the relation definition */ - public List getRelatedByAndCache(String relationName, Map<String, ? extends Object> fields) throws GenericEntityException { + public List<GenericValue> getRelatedByAndCache(String relationName, Map<String, ? extends Object> fields) throws GenericEntityException { return EntityUtil.filterByAnd(this.getDelegator().getRelatedCache(relationName, this), fields); } @@ -364,7 +365,7 @@ *@param fields the fields that must equal in order to keep *@return List of GenericValue instances as specified in the relation definition */ - public List getRelatedByAndEmbeddedCache(String relationName, Map<String, ? extends Object> fields) throws GenericEntityException { + public List<GenericValue> getRelatedByAndEmbeddedCache(String relationName, Map<String, ? extends Object> fields) throws GenericEntityException { return EntityUtil.filterByAnd(getRelatedEmbeddedCache(relationName), fields); } @@ -446,7 +447,7 @@ ModelKeyMap keyMap = relation.getKeyMap(i); fields.put(keyMap.getRelFieldName(), this.get(keyMap.getFieldName())); } - EntityFieldMap ecl = new EntityFieldMap(fields, EntityOperator.AND); + EntityFieldMap ecl = EntityCondition.makeCondition(fields); long count = this.getDelegator().findCountByCondition(relation.getRelEntityName(), ecl, null, null); if (count == 0) { if (insertDummy) { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java Tue May 27 18:58:46 2008 @@ -18,15 +18,15 @@ *******************************************************************************/ package org.ofbiz.entity.condition; -import java.util.ArrayList; import java.util.List; import java.util.Map; +import javolution.lang.Reusable; import javolution.util.FastList; import org.ofbiz.entity.GenericDelegator; -import org.ofbiz.entity.GenericModelException; import org.ofbiz.entity.GenericEntity; +import org.ofbiz.entity.GenericModelException; import org.ofbiz.entity.config.DatasourceInfo; import org.ofbiz.entity.model.ModelEntity; @@ -41,7 +41,79 @@ * These can be used in various combinations using the EntityConditionList and EntityExpr objects. * */ -public abstract class EntityCondition extends EntityConditionBase { +public abstract class EntityCondition extends EntityConditionBase implements Reusable { + + public static <T extends EntityCondition> EntityConditionList<T> makeCondition(EntityJoinOperator operator, T... conditionList) { + EntityConditionList<T> ecl = new EntityConditionList<T>(); + ecl.init(operator, conditionList); + return ecl; + } + + public static <T extends EntityCondition> EntityConditionList<T> makeCondition(T... conditionList) { + EntityConditionList<T> ecl = new EntityConditionList<T>(); + ecl.init(EntityOperator.AND, conditionList); + return ecl; + } + + public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList, EntityJoinOperator operator) { + EntityConditionList<T> ecl = new EntityConditionList<T>(); + ecl.init(conditionList, operator); + return ecl; + } + + public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList) { + EntityConditionList<T> ecl = new EntityConditionList<T>(); + ecl.init(conditionList, EntityOperator.AND); + return ecl; + } + + public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityComparisonOperator compOp, EntityJoinOperator joinOp) { + EntityFieldMap efm = new EntityFieldMap(); + efm.init(fieldMap, compOp, joinOp); + return efm; + } + + public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityJoinOperator joinOp) { + EntityFieldMap efm = new EntityFieldMap(); + efm.init(fieldMap, EntityOperator.EQUALS, joinOp); + return efm; + } + + public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap) { + EntityFieldMap efm = new EntityFieldMap(); + efm.init(fieldMap, EntityOperator.EQUALS, EntityOperator.AND); + return efm; + } + + public static EntityFieldMap makeCondition(EntityComparisonOperator compOp, EntityJoinOperator joinOp, Object... keysValues) { + EntityFieldMap efm = new EntityFieldMap(); + efm.init(compOp, joinOp, keysValues); + return efm; + } + + public static EntityFieldMap makeCondition(EntityJoinOperator joinOp, Object... keysValues) { + EntityFieldMap efm = new EntityFieldMap(); + efm.init(EntityOperator.EQUALS, joinOp, keysValues); + return efm; + } + + public static EntityFieldMap makeCondition(Object... keysValues) { + EntityFieldMap efm = new EntityFieldMap(); + efm.init(EntityOperator.EQUALS, EntityOperator.AND, keysValues); + return efm; + } + + public static EntityDateFilterCondition makeConditionDate(String fromDateName, String thruDateName) { + EntityDateFilterCondition edfc = new EntityDateFilterCondition(); + edfc.init(fromDateName, thruDateName); + return edfc; + } + + public static EntityWhereString makeConditionWhere(String sqlString) { + EntityWhereString ews = new EntityWhereString(); + ews.init(sqlString); + return ews; + } public String toString() { return makeWhereString(null, FastList.<EntityConditionParam>newInstance(), null); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java Tue May 27 18:58:46 2008 @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; +import javolution.lang.Reusable; import javolution.util.FastList; import javolution.util.FastMap; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionFunction.java Tue May 27 18:58:46 2008 @@ -48,16 +48,26 @@ } }; - protected int idInt; - protected String codeString; - protected EntityCondition condition; + protected Integer idInt = null; + protected String codeString = null; + protected EntityCondition condition = null; protected EntityConditionFunction(int id, String code, EntityCondition condition) { + init(id, code, condition); + } + + public void init(int id, String code, EntityCondition condition) { idInt = id; codeString = code; this.condition = condition; } + public void reset() { + idInt = null; + codeString = null; + this.condition = null; + } + public String getCode() { if (codeString == null) return "null"; @@ -76,13 +86,11 @@ public boolean equals(Object obj) { if (!(obj instanceof EntityConditionFunction)) return false; EntityConditionFunction otherFunc = (EntityConditionFunction) obj; - return - this.idInt == otherFunc.idInt - && ( this.condition != null ? condition.equals( otherFunc.condition ) : otherFunc.condition != null ); + return this.idInt == otherFunc.idInt && (this.condition != null ? condition.equals(otherFunc.condition) : otherFunc.condition != null); } public int hashCode() { - return idInt ^ condition.hashCode(); + return idInt.hashCode() ^ condition.hashCode(); } public String makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, DatasourceInfo datasourceInfo) { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java Tue May 27 18:58:46 2008 @@ -32,14 +32,16 @@ super(); } + /** @deprecated Use EntityCondition.makeCondition() instead */ public EntityConditionList(EntityJoinOperator operator, T... conditionList) { - super(operator, conditionList); + init(operator, conditionList); } + /** @deprecated Use EntityCondition.makeCondition() instead */ public EntityConditionList(List<T> conditionList, EntityJoinOperator operator) { - super(conditionList, operator); + init(conditionList, operator); } - + public int getConditionListSize() { return super.getConditionListSize(); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionListBase.java Tue May 27 18:58:46 2008 @@ -35,25 +35,38 @@ public abstract class EntityConditionListBase<T extends EntityCondition> extends EntityCondition { public static final String module = EntityConditionListBase.class.getName(); - protected List<T> conditionList; - protected EntityJoinOperator operator; + protected List<T> conditionList = null; + protected EntityJoinOperator operator = null; protected EntityConditionListBase() {} public EntityConditionListBase(EntityJoinOperator operator, T... conditionList) { + this.init(operator, conditionList); + } + + public EntityConditionListBase(List<T> conditionList, EntityJoinOperator operator) { + this.init(conditionList, operator); + } + + public void init(EntityJoinOperator operator, T... conditionList) { this.conditionList = Arrays.asList(conditionList); this.operator = operator; } - public EntityConditionListBase(List<T> conditionList, EntityJoinOperator operator) { + public void init(List<T> conditionList, EntityJoinOperator operator) { this.conditionList = conditionList; this.operator = operator; } + public void reset() { + this.conditionList = null; + this.operator = null; + } + public EntityOperator getOperator() { return this.operator; } - + public T getCondition(int index) { return this.conditionList.get(index); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java Tue May 27 18:58:46 2008 @@ -34,10 +34,10 @@ public class EntityConditionSubSelect extends EntityConditionValue { public static final String module = EntityConditionSubSelect.class.getName(); - protected ModelEntity localModelEntity; - protected String keyFieldName; - protected EntityCondition whereCond; - protected boolean requireAll; + protected ModelEntity localModelEntity = null; + protected String keyFieldName = null; + protected EntityCondition whereCond = null; + protected Boolean requireAll = null; protected EntityConditionSubSelect() { } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java Tue May 27 18:58:46 2008 @@ -30,14 +30,26 @@ public class EntityDateFilterCondition extends EntityCondition { - protected String fromDateName; - protected String thruDateName; + protected String fromDateName = null; + protected String thruDateName = null; + protected EntityDateFilterCondition() {} + + /** @deprecated Use EntityCondition.makeConditionDate() instead */ public EntityDateFilterCondition(String fromDateName, String thruDateName) { + init(fromDateName, thruDateName); + } + + public void init(String fromDateName, String thruDateName) { this.fromDateName = fromDateName; this.thruDateName = thruDateName; } + public void reset() { + this.fromDateName = null; + this.thruDateName = null; + } + public String makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, DatasourceInfo datasourceInfo) { EntityCondition condition = makeCondition(); return condition.makeWhereString(modelEntity, entityConditionParams, datasourceInfo); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java Tue May 27 18:58:46 2008 @@ -38,9 +38,9 @@ public class EntityExpr extends EntityCondition { public static final String module = EntityExpr.class.getName(); - private Object lhs; - private EntityOperator<?> operator; - private Object rhs; + private Object lhs = null; + private EntityOperator<?> operator = null; + private Object rhs = null; protected EntityExpr() {} @@ -114,6 +114,12 @@ this.rhs = rhs; } + public void reset() { + this.lhs = null; + this.operator = null; + this.rhs = null; + } + /** @deprecated */ public void setLUpper(boolean upper) { } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java Tue May 27 18:58:46 2008 @@ -25,6 +25,8 @@ import java.util.List; import java.util.Map; +import javolution.util.FastMap; + import org.ofbiz.entity.util.EntityUtil; /** @@ -33,7 +35,7 @@ */ public class EntityFieldMap extends EntityConditionListBase<EntityExpr> { - protected Map<String, ? extends Object> fieldMap; + protected Map<String, ? extends Object> fieldMap = null; protected EntityFieldMap() { super(); @@ -52,23 +54,44 @@ return list; } + + /** @deprecated Use EntityCondition.makeCondition() instead */ public EntityFieldMap(EntityComparisonOperator compOp, EntityJoinOperator joinOp, Object... keysValues) { - this(EntityUtil.makeFields(keysValues), compOp, joinOp); + this.init(compOp, joinOp, keysValues); } + /** @deprecated Use EntityCondition.makeCondition() instead */ public EntityFieldMap(Map<String, ? extends Object> fieldMap, EntityComparisonOperator compOp, EntityJoinOperator joinOp) { - super(makeConditionList(fieldMap, compOp), joinOp); - this.fieldMap = fieldMap; - if (this.fieldMap == null) this.fieldMap = new LinkedHashMap<String, Object>(); - this.operator = joinOp; + this.init(fieldMap, compOp, joinOp); } + /** @deprecated Use EntityCondition.makeCondition() instead */ public EntityFieldMap(EntityJoinOperator operator, Object... keysValues) { - this(EntityOperator.EQUALS, operator, keysValues); + this.init(EntityOperator.EQUALS, operator, keysValues); } + /** @deprecated Use EntityCondition.makeCondition() instead */ public EntityFieldMap(Map<String, ? extends Object> fieldMap, EntityJoinOperator operator) { - this(fieldMap, EntityOperator.EQUALS, operator); + this.init(fieldMap, EntityOperator.EQUALS, operator); + } + + public void init(EntityComparisonOperator compOp, EntityJoinOperator joinOp, Object... keysValues) { + super.init(makeConditionList(EntityUtil.makeFields(keysValues), compOp), joinOp); + this.fieldMap = EntityUtil.makeFields(keysValues); + if (this.fieldMap == null) this.fieldMap = FastMap.newInstance(); + this.operator = joinOp; + } + + public void init(Map<String, ? extends Object> fieldMap, EntityComparisonOperator compOp, EntityJoinOperator joinOp) { + super.init(makeConditionList(fieldMap, compOp), joinOp); + this.fieldMap = fieldMap; + if (this.fieldMap == null) this.fieldMap = FastMap.newInstance(); + this.operator = joinOp; + } + + public void reset() { + super.reset(); + this.fieldMap = null; } public Object getField(String name) { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityJoinOperator.java Tue May 27 18:58:46 2008 @@ -87,7 +87,7 @@ for (EntityCondition condition: conditionList) { newList.add(condition.freeze()); } - return new EntityConditionList<EntityCondition>(newList, this); + return EntityCondition.makeCondition(newList, this); } public void visit(EntityConditionVisitor visitor, List<? extends EntityCondition> conditionList) { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java Tue May 27 18:58:46 2008 @@ -44,9 +44,18 @@ protected EntityWhereString() {} + /** @deprecated Use EntityCondition.makeConditionWhere() instead */ public EntityWhereString(String sqlString) { + init(sqlString); + } + + public void init(String sqlString) { this.sqlString = sqlString; } + + public void reset() { + this.sqlString = null; + } public String makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, DatasourceInfo datasourceInfo) { return sqlString; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByAndFinder.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByAndFinder.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByAndFinder.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByAndFinder.java Tue May 27 18:58:46 2008 @@ -53,7 +53,7 @@ EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, entityContext); // then convert the types... modelEntity.convertFieldMapInPlace(entityContext, delegator); - return new EntityFieldMap(entityContext, EntityOperator.AND); + return EntityCondition.makeCondition(entityContext); } } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java Tue May 27 18:58:46 2008 @@ -290,7 +290,7 @@ throw new IllegalArgumentException("Could not find an entity operator for the name: " + operatorName); } - return new EntityConditionList<EntityCondition>(entityConditionList, (EntityJoinOperator) operator); + return EntityCondition.makeCondition(entityConditionList, (EntityJoinOperator) operator); } } public static class ConditionObject implements Condition { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java Tue May 27 18:58:46 2008 @@ -168,7 +168,7 @@ if (filterByDate) { EntityCondition filterByDateCondition = EntityUtil.getFilterByDateExpr(); if (whereEntityCondition != null) { - whereEntityCondition = new EntityConditionList<EntityCondition>(UtilMisc.toList(whereEntityCondition, filterByDateCondition), EntityJoinOperator.AND); + whereEntityCondition = EntityCondition.makeCondition(UtilMisc.toList(whereEntityCondition, filterByDateCondition)); } else { whereEntityCondition = filterByDateCondition; } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java Tue May 27 18:58:46 2008 @@ -130,17 +130,13 @@ GenericValue root = delegator.create("TestingNode", "testingNodeId", delegator.getNextSeqId("TestingNode"), "primaryParentNodeId", GenericEntity.NULL_FIELD, - "description", "root" - ); + "description", "root"); int level1; for(level1 = 0; level1 < _level1max; level1++) { String nextSeqId = delegator.getNextSeqId("TestingNode"); - GenericValue v = - delegator.create("TestingNode", - "testingNodeId", nextSeqId, + GenericValue v = delegator.create("TestingNode", "testingNodeId", nextSeqId, "primaryParentNodeId", root.get("testingNodeId"), - "description", "node-level #1" - ); + "description", "node-level #1"); } long created = level1; @@ -217,9 +213,8 @@ public void testFindDistinct() throws Exception { List<EntityExpr> exprList = UtilMisc.toList( new EntityExpr("testingSize", EntityOperator.EQUALS, new Long(10)), - new EntityExpr("comments", EntityOperator.EQUALS, "No-comments") - ); - EntityConditionList<EntityExpr> condition = new EntityConditionList<EntityExpr>(exprList, EntityOperator.AND); + new EntityExpr("comments", EntityOperator.EQUALS, "No-comments")); + EntityConditionList<EntityExpr> condition = EntityCondition.makeCondition(exprList); EntityFindOptions findOptions = new EntityFindOptions(); findOptions.setDistinct(true); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtil.java Tue May 27 18:58:46 2008 @@ -95,11 +95,11 @@ } public static EntityCondition getFilterByDateExpr() { - return new EntityDateFilterCondition("fromDate", "thruDate"); + return EntityCondition.makeConditionDate("fromDate", "thruDate"); } public static EntityCondition getFilterByDateExpr(String fromDateName, String thruDateName) { - return new EntityDateFilterCondition(fromDateName, thruDateName); + return EntityCondition.makeConditionDate(fromDateName, thruDateName); } public static EntityCondition getFilterByDateExpr(java.util.Date moment) { @@ -399,10 +399,8 @@ } public static List<GenericValue> findDatedInclusionEntity(GenericDelegator delegator, String entityName, Map<String, ? extends Object> search, Timestamp now) throws GenericEntityException { - EntityCondition searchCondition = new EntityConditionList<EntityCondition>(UtilMisc.toList( - new EntityFieldMap(search, EntityOperator.AND), - EntityUtil.getFilterByDateExpr(now) - ), EntityOperator.AND); + EntityCondition searchCondition = EntityCondition.makeCondition(UtilMisc.toList( + EntityCondition.makeCondition(search), EntityUtil.getFilterByDateExpr(now))); return delegator.findList(entityName, searchCondition, null, UtilMisc.toList("-fromDate"), null, false); } Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java Tue May 27 18:58:46 2008 @@ -31,6 +31,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import javolution.util.FastList; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilDateTime; @@ -63,7 +65,7 @@ protected FlexibleStringExpander entityIdExdr; protected FlexibleStringExpander entityNameExdr; protected boolean displayFailCond; - protected List targetOperationList; + protected List<String> targetOperationList; protected PermissionConditionGetter permissionConditionGetter; protected RelatedRoleGetter relatedRoleGetter; protected AuxiliaryValueGetter auxiliaryValueGetter; @@ -92,9 +94,9 @@ } String targetOperationString = element.getAttribute("target-operation"); if (UtilValidate.isNotEmpty(targetOperationString)) { - List operationsFromString = StringUtil.split(targetOperationString, "|"); + List<String> operationsFromString = StringUtil.split(targetOperationString, "|"); if (targetOperationList == null) { - targetOperationList = new ArrayList(); + targetOperationList = FastList.newInstance(); } targetOperationList.addAll(operationsFromString); } @@ -912,16 +914,13 @@ //EntityExpr roleTypeIdToExpr = new EntityExpr("roleTypeIdTo", EntityOperator.EQUALS, "CONTENT_PERMISSION_GROUP"); EntityExpr fromExpr = new EntityExpr("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, fromDate); - EntityCondition thruCond = new EntityConditionList( - UtilMisc.toList( - new EntityExpr("thruDate", EntityOperator.EQUALS, null), - new EntityExpr("thruDate", EntityOperator.GREATER_THAN, thruDate) ), - EntityOperator.OR); + EntityCondition thruCond = EntityCondition.makeCondition(UtilMisc.toList(new EntityExpr("thruDate", EntityOperator.EQUALS, null), + new EntityExpr("thruDate", EntityOperator.GREATER_THAN, thruDate)), EntityOperator.OR); // This method is simplified to make it work, these conditions need to be added back in. //List joinList = UtilMisc.toList(fromExpr, thruCond, partyFromExpr, partyToExpr, relationExpr); List joinList = UtilMisc.toList( partyFromExpr, partyToExpr); - EntityCondition condition = new EntityConditionList(joinList, EntityOperator.AND); + EntityCondition condition = EntityCondition.makeCondition(joinList); List partyRelationships = null; try { Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java Tue May 27 18:58:46 2008 @@ -349,9 +349,9 @@ try { // get the values created within the current time range - EntityCondition findValCondition = new EntityConditionList(UtilMisc.toList( + EntityCondition findValCondition = EntityCondition.makeCondition( new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.GREATER_THAN_EQUAL_TO, currentRunStartTime), - new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.LESS_THAN, currentRunEndTime)), EntityOperator.AND); + new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.LESS_THAN, currentRunEndTime)); EntityListIterator eli = delegator.find(modelEntity.getEntityName(), findValCondition, null, null, UtilMisc.toList(ModelEntity.CREATE_STAMP_TX_FIELD, ModelEntity.CREATE_STAMP_FIELD), null); GenericValue nextValue = null; long valuesPerEntity = 0; @@ -378,10 +378,9 @@ if (valuesPerEntity == 0) { Timestamp startCheckStamp = new Timestamp(System.currentTimeMillis() - syncEndBufferMillis); - EntityCondition findNextCondition = new EntityConditionList(UtilMisc.toList( + EntityCondition findNextCondition = EntityCondition.makeCondition( new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.NOT_EQUAL, null), - new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.GREATER_THAN_EQUAL_TO, currentRunEndTime)), - EntityOperator.AND); + new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.GREATER_THAN_EQUAL_TO, currentRunEndTime)); EntityListIterator eliNext = delegator.find(modelEntity.getEntityName(), findNextCondition, null, null, UtilMisc.toList(ModelEntity.CREATE_STAMP_TX_FIELD), null); // get the first element and it's tx time value... GenericValue firstVal = (GenericValue) eliNext.next(); @@ -490,11 +489,10 @@ new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.EQUALS, null), EntityOperator.OR, new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.LESS_THAN, currentRunStartTime)); - EntityCondition findValCondition = new EntityConditionList(UtilMisc.toList( + EntityCondition findValCondition = EntityCondition.makeCondition( new EntityExpr(ModelEntity.STAMP_TX_FIELD, EntityOperator.GREATER_THAN_EQUAL_TO, currentRunStartTime), new EntityExpr(ModelEntity.STAMP_TX_FIELD, EntityOperator.LESS_THAN, currentRunEndTime), - createdBeforeStartCond), - EntityOperator.AND); + createdBeforeStartCond); EntityListIterator eli = delegator.find(modelEntity.getEntityName(), findValCondition, null, null, UtilMisc.toList(ModelEntity.STAMP_TX_FIELD, ModelEntity.STAMP_FIELD), null); GenericValue nextValue = null; long valuesPerEntity = 0; @@ -521,12 +519,11 @@ if (valuesPerEntity == 0) { Timestamp startCheckStamp = new Timestamp(System.currentTimeMillis() - syncEndBufferMillis); - EntityCondition findNextCondition = new EntityConditionList(UtilMisc.toList( + EntityCondition findNextCondition = EntityCondition.makeCondition( new EntityExpr(ModelEntity.STAMP_TX_FIELD, EntityOperator.NOT_EQUAL, null), new EntityExpr(ModelEntity.STAMP_TX_FIELD, EntityOperator.GREATER_THAN_EQUAL_TO, currentRunEndTime), new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.NOT_EQUAL, null), - new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.LESS_THAN, currentRunEndTime)), - EntityOperator.AND); + new EntityExpr(ModelEntity.CREATE_STAMP_TX_FIELD, EntityOperator.LESS_THAN, currentRunEndTime)); EntityListIterator eliNext = delegator.find(modelEntity.getEntityName(), findNextCondition, null, null, UtilMisc.toList(ModelEntity.STAMP_TX_FIELD), null); // get the first element and it's tx time value... GenericValue firstVal = (GenericValue) eliNext.next(); @@ -615,9 +612,9 @@ try { // find all instances of this entity with the STAMP_TX_FIELD != null, sort ascending to get lowest/oldest value first, then grab first and consider as candidate currentRunStartTime - EntityCondition findValCondition = new EntityConditionList(UtilMisc.toList( + EntityCondition findValCondition = EntityCondition.makeCondition( new EntityExpr(ModelEntity.STAMP_TX_FIELD, EntityOperator.GREATER_THAN_EQUAL_TO, currentRunStartTime), - new EntityExpr(ModelEntity.STAMP_TX_FIELD, EntityOperator.LESS_THAN, currentRunEndTime)), EntityOperator.AND); + new EntityExpr(ModelEntity.STAMP_TX_FIELD, EntityOperator.LESS_THAN, currentRunEndTime)); EntityListIterator removeEli = delegator.find("EntitySyncRemove", findValCondition, null, null, UtilMisc.toList(ModelEntity.STAMP_TX_FIELD, ModelEntity.STAMP_FIELD), null); GenericValue entitySyncRemove = null; while ((entitySyncRemove = (GenericValue) removeEli.next()) != null) { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java Tue May 27 18:58:46 2008 @@ -83,7 +83,7 @@ if (useIterator) { EntityCondition whereCond = null; if (!mapAcsr.isEmpty()) { - whereCond = new EntityFieldMap((Map) mapAcsr.get(methodContext), EntityOperator.AND); + whereCond = EntityCondition.makeCondition((Map) mapAcsr.get(methodContext)); } listAcsr.put(methodContext, delegator.find(entityName, whereCond, null, null, orderByNames, null)); } else { Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceUtil.java Tue May 27 18:58:46 2008 @@ -360,11 +360,11 @@ List<EntityExpr> canExp = UtilMisc.toList(new EntityExpr("cancelDateTime", EntityOperator.NOT_EQUAL, null)); canExp.add(new EntityExpr("cancelDateTime", EntityOperator.LESS_THAN, purgeTime)); - EntityCondition cancelled = new EntityConditionList<EntityExpr>(canExp, EntityOperator.AND); - EntityCondition finished = new EntityConditionList<EntityExpr>(finExp, EntityOperator.AND); + EntityCondition cancelled = EntityCondition.makeCondition(canExp); + EntityCondition finished = EntityCondition.makeCondition(finExp); - EntityCondition doneCond = new EntityConditionList<EntityCondition>(UtilMisc.toList(cancelled, finished), EntityOperator.OR); - EntityCondition mainCond = new EntityConditionList<EntityCondition>(UtilMisc.toList(doneCond, pool), EntityOperator.AND); + EntityCondition doneCond = EntityCondition.makeCondition(UtilMisc.toList(cancelled, finished), EntityOperator.OR); + EntityCondition mainCond = EntityCondition.makeCondition(UtilMisc.toList(doneCond, pool)); // configure the find options EntityFindOptions findOptions = new EntityFindOptions(); @@ -605,7 +605,7 @@ return UtilGenerics.checkMap(UtilMisc.toMap(args)); } - public static Map resetJob(DispatchContext dctx, Map context) { + public static Map<String, Object> resetJob(DispatchContext dctx, Map<String, Object> context) { GenericDelegator delegator = dctx.getDelegator(); Security security = dctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java Tue May 27 18:58:46 2008 @@ -126,9 +126,9 @@ } // make the conditions - EntityCondition baseCondition = new EntityConditionList<EntityExpr>(expressions, EntityOperator.AND); - EntityCondition poolCondition = new EntityConditionList<EntityExpr>(poolsExpr, EntityOperator.OR); - EntityCondition mainCondition = new EntityConditionList<EntityCondition>(UtilMisc.toList(baseCondition, poolCondition), EntityOperator.AND); + EntityCondition baseCondition = EntityCondition.makeCondition(expressions); + EntityCondition poolCondition = EntityCondition.makeCondition(poolsExpr, EntityOperator.OR); + EntityCondition mainCondition = EntityCondition.makeCondition(UtilMisc.toList(baseCondition, poolCondition)); // we will loop until we have no more to do boolean pollDone = false; @@ -207,7 +207,7 @@ List<EntityExpr> exprs = UtilMisc.toList(new EntityExpr("finishDateTime", EntityOperator.EQUALS, null)); exprs.add(new EntityExpr("cancelDateTime", EntityOperator.EQUALS, null)); exprs.add(new EntityExpr("runByInstanceId", EntityOperator.EQUALS, instanceId)); - EntityConditionList<EntityExpr> ecl = new EntityConditionList<EntityExpr>(exprs, EntityOperator.AND); + EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(exprs); try { crashed = delegator.findList("JobSandbox", ecl, null, UtilMisc.toList("startDateTime"), null, false); Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Tue May 27 18:58:46 2008 @@ -40,6 +40,7 @@ import javax.transaction.Transaction; import javolution.util.FastList; +import javolution.util.FastMap; import org.ofbiz.base.component.ComponentConfig; import org.ofbiz.base.util.Debug; @@ -54,6 +55,7 @@ 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.EntityConditionList; import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; @@ -79,7 +81,7 @@ public static final String X509_CERT_ATTR = "SSLx509Cert"; /** This Map is keyed by the randomly generated externalLoginKey and the value is a UserLogin GenericValue object */ - public static Map externalLoginKeys = new HashMap(); + public static Map<String, GenericValue> externalLoginKeys = FastMap.newInstance(); public static String makeLoginUrl(PageContext pageContext) { return makeLoginUrl(pageContext, "checkLogin"); @@ -724,36 +726,36 @@ } protected static boolean checkValidIssuer(GenericDelegator delegator, Map x500Map, BigInteger serialNumber) throws GeneralException { - List conds = FastList.newInstance(); - conds.add(new EntityConditionList(UtilMisc.toList(new EntityExpr("commonName", EntityOperator.EQUALS, x500Map.get("CN")), + List<EntityCondition> conds = FastList.newInstance(); + conds.add(EntityCondition.makeCondition(EntityOperator.OR, new EntityExpr("commonName", EntityOperator.EQUALS, x500Map.get("CN")), new EntityExpr("commonName", EntityOperator.EQUALS, null), - new EntityExpr("commonName", EntityOperator.EQUALS, "")), EntityOperator.OR)); + new EntityExpr("commonName", EntityOperator.EQUALS, ""))); - conds.add(new EntityConditionList(UtilMisc.toList(new EntityExpr("organizationalUnit", EntityOperator.EQUALS, x500Map.get("OU")), + conds.add(EntityCondition.makeCondition(EntityOperator.OR, new EntityExpr("organizationalUnit", EntityOperator.EQUALS, x500Map.get("OU")), new EntityExpr("organizationalUnit", EntityOperator.EQUALS, null), - new EntityExpr("organizationalUnit", EntityOperator.EQUALS, "")), EntityOperator.OR)); + new EntityExpr("organizationalUnit", EntityOperator.EQUALS, ""))); - conds.add(new EntityConditionList(UtilMisc.toList(new EntityExpr("organizationName", EntityOperator.EQUALS, x500Map.get("O")), + conds.add(EntityCondition.makeCondition(EntityOperator.OR, new EntityExpr("organizationName", EntityOperator.EQUALS, x500Map.get("O")), new EntityExpr("organizationName", EntityOperator.EQUALS, null), - new EntityExpr("organizationName", EntityOperator.EQUALS, "")), EntityOperator.OR)); + new EntityExpr("organizationName", EntityOperator.EQUALS, ""))); - conds.add(new EntityConditionList(UtilMisc.toList(new EntityExpr("cityLocality", EntityOperator.EQUALS, x500Map.get("L")), + conds.add(EntityCondition.makeCondition(EntityOperator.OR, new EntityExpr("cityLocality", EntityOperator.EQUALS, x500Map.get("L")), new EntityExpr("cityLocality", EntityOperator.EQUALS, null), - new EntityExpr("cityLocality", EntityOperator.EQUALS, "")), EntityOperator.OR)); + new EntityExpr("cityLocality", EntityOperator.EQUALS, ""))); - conds.add(new EntityConditionList(UtilMisc.toList(new EntityExpr("stateProvince", EntityOperator.EQUALS, x500Map.get("ST")), + conds.add(EntityCondition.makeCondition(EntityOperator.OR, new EntityExpr("stateProvince", EntityOperator.EQUALS, x500Map.get("ST")), new EntityExpr("stateProvince", EntityOperator.EQUALS, null), - new EntityExpr("stateProvince", EntityOperator.EQUALS, "")), EntityOperator.OR)); + new EntityExpr("stateProvince", EntityOperator.EQUALS, ""))); - conds.add(new EntityConditionList(UtilMisc.toList(new EntityExpr("country", EntityOperator.EQUALS, x500Map.get("C")), + conds.add(EntityCondition.makeCondition(EntityOperator.OR, new EntityExpr("country", EntityOperator.EQUALS, x500Map.get("C")), new EntityExpr("country", EntityOperator.EQUALS, null), - new EntityExpr("country", EntityOperator.EQUALS, "")), EntityOperator.OR)); + new EntityExpr("country", EntityOperator.EQUALS, ""))); - conds.add(new EntityConditionList(UtilMisc.toList(new EntityExpr("serialNumber", EntityOperator.EQUALS, serialNumber.toString(16)), + conds.add(EntityCondition.makeCondition(EntityOperator.OR, new EntityExpr("serialNumber", EntityOperator.EQUALS, serialNumber.toString(16)), new EntityExpr("serialNumber", EntityOperator.EQUALS, null), - new EntityExpr("serialNumber", EntityOperator.EQUALS, "")), EntityOperator.OR)); + new EntityExpr("serialNumber", EntityOperator.EQUALS, ""))); - EntityConditionList condition = new EntityConditionList(conds, EntityOperator.AND); + EntityConditionList<EntityCondition> condition = EntityCondition.makeCondition(conds); Debug.logInfo("Doing issuer lookup: " + condition.toString(), module); long count = delegator.findCountByCondition("X509IssuerProvision", condition, null, null); return count > 0; Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Tue May 27 18:58:46 2008 @@ -110,7 +110,7 @@ GenericValue userLogin = (GenericValue) context.get("userLogin"); LocalDispatcher dispatcher = dctx.getDispatcher(); - List messages = new ArrayList(); + List<String> messages = FastList.newInstance(); String filename = (String)context.get("filename"); String fmfilename = (String)context.get("fmfilename"); @@ -980,14 +980,14 @@ result.put("filterJobsWithFinishedStatus", filterJobFinished); } if (filterExprs.size() > 0) { - conditions.add(new EntityConditionList(filterExprs, EntityOperator.OR)); + conditions.add(EntityCondition.makeCondition(filterExprs, EntityOperator.OR)); } // set distinct on so we only get one row per job EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); List orderBy = UtilMisc.toList("-runTime"); EntityCondition cond = null; if (conditions.size() > 0) { - cond = new EntityConditionList(conditions, EntityOperator.AND); + cond = EntityCondition.makeCondition(conditions); } if (cond != null || "Y".equals(showAll)) { try { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Tue May 27 18:58:46 2008 @@ -1681,7 +1681,7 @@ EntityFinderUtil.Condition condition = (EntityFinderUtil.Condition) constraintIter.next(); expandedConditionList.add(condition.createCondition(context, this.entityName, delegator)); } - findCondition = new EntityConditionList(expandedConditionList, EntityOperator.AND); + findCondition = EntityCondition.makeCondition(expandedConditionList); } try { Modified: ofbiz/trunk/framework/workflow/src/org/ofbiz/workflow/client/WorkflowServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/workflow/src/org/ofbiz/workflow/client/WorkflowServices.java?rev=660780&r1=660779&r2=660780&view=diff ============================================================================== --- ofbiz/trunk/framework/workflow/src/org/ofbiz/workflow/client/WorkflowServices.java (original) +++ ofbiz/trunk/framework/workflow/src/org/ofbiz/workflow/client/WorkflowServices.java Tue May 27 18:58:46 2008 @@ -19,10 +19,8 @@ package org.ofbiz.workflow.client; import java.sql.Timestamp; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.ofbiz.base.util.Debug; @@ -31,6 +29,7 @@ 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.EntityConditionList; import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; @@ -447,7 +446,7 @@ return true; } else { String partyId = userLogin.getString("partyId"); - EntityConditionList<EntityExpr> ecl = new EntityConditionList<EntityExpr>( + EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition( EntityOperator.AND, new EntityExpr[] { new EntityExpr("partyId", EntityOperator.EQUALS, partyId), @@ -469,7 +468,7 @@ return false; } if (c.size() == 0) { - ecl = new EntityConditionList<EntityExpr>( + ecl = EntityCondition.makeCondition( EntityOperator.AND, new EntityExpr[] { new EntityExpr("partyId", EntityOperator.EQUALS, partyId), |
Free forum by Nabble | Edit this page |