You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2007/10/18 05:05:02 UTC
svn commit: r585808 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity:
./ condition/ model/
Author: doogie
Date: Wed Oct 17 20:05:01 2007
New Revision: 585808
URL: http://svn.apache.org/viewvc?rev=585808&view=rev
Log:
Add varargs variants to all entity source.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorInterface.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.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/EntityFieldMap.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorInterface.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorInterface.java?rev=585808&r1=585807&r2=585808&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorInterface.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorInterface.java Wed Oct 17 20:05:01 2007
@@ -69,18 +69,26 @@
GenericValue makeValue(String entityName);
+ GenericValue makeValue(String entityName, Object... fields);
+
GenericValue makeValue(String entityName, Map fields);
GenericValue makeValueSingle(String entityName, Object singlePkValue);
+ GenericValue makeValidValue(String entityName, Object... fields);
+
GenericValue makeValidValue(String entityName, Map fields);
GenericPK makePK(String entityName);
+ GenericPK makePK(String entityName, Object... fields);
+
GenericPK makePK(String entityName, Map fields);
GenericPK makePKSingle(String entityName, Object singlePkValue);
+ GenericValue create(String entityName, Object... fields) throws GenericEntityException;
+
GenericValue create(String entityName, Map fields) throws GenericEntityException;
GenericValue createSingle(String entityName, Object singlePkValue) throws GenericEntityException;
@@ -101,14 +109,20 @@
GenericValue findByPrimaryKeyCache(GenericPK primaryKey) throws GenericEntityException;
+ GenericValue findByPrimaryKey(String entityName, Object... fields) throws GenericEntityException;
+
GenericValue findByPrimaryKey(String entityName, Map fields) throws GenericEntityException;
GenericValue findByPrimaryKeySingle(String entityName, Object singlePkValue) throws GenericEntityException;
+ GenericValue findByPrimaryKeyCache(String entityName, Object... fields) throws GenericEntityException;
+
GenericValue findByPrimaryKeyCache(String entityName, Map fields) throws GenericEntityException;
GenericValue findByPrimaryKeyCacheSingle(String entityName, Object singlePkValue) throws GenericEntityException;
+ GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, String... keys) throws GenericEntityException;
+
GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set keys) throws GenericEntityException;
List findAllByPrimaryKeys(Collection primaryKeys) throws GenericEntityException;
@@ -125,14 +139,22 @@
List findAll(String entityName) throws GenericEntityException;
+ List findAll(String entityName, String... orderBy) throws GenericEntityException;
+
List findAll(String entityName, List orderBy) throws GenericEntityException;
List findAllCache(String entityName) throws GenericEntityException;
+ List findAllCache(String entityName, String... orderBy) throws GenericEntityException;
+
List findAllCache(String entityName, List orderBy) throws GenericEntityException;
+ List findByAnd(String entityName, Object... fields) throws GenericEntityException;
+
List findByAnd(String entityName, Map fields) throws GenericEntityException;
+ List findByOr(String entityName, Object... fields) throws GenericEntityException;
+
List findByOr(String entityName, Map fields) throws GenericEntityException;
List findByAnd(String entityName, Map fields, List orderBy) throws GenericEntityException;
@@ -141,18 +163,26 @@
List findByOr(String entityName, Map fields, List orderBy) throws GenericEntityException;
+ List findByAndCache(String entityName, Object... fields) throws GenericEntityException;
+
List findByAndCache(String entityName, Map fields) throws GenericEntityException;
List findByAndCache(String entityName, Map fields, List orderBy) throws GenericEntityException;
+ List findByAnd(String entityName, EntityCondition... expressions) throws GenericEntityException;
+
List findByAnd(String entityName, List expressions) throws GenericEntityException;
+ List findByOr(String entityName, EntityCondition... expressions) throws GenericEntityException;
+
List findByOr(String entityName, List expressions) throws GenericEntityException;
List findByAnd(String entityName, List expressions, List orderBy) throws GenericEntityException;
List findByOr(String entityName, List expressions, List orderBy) throws GenericEntityException;
+ List findByLike(String entityName, Object... fields) throws GenericEntityException;
+
List findByLike(String entityName, Map fields) throws GenericEntityException;
List findByLike(String entityName, Map fields, List orderBy) throws GenericEntityException;
@@ -166,8 +196,12 @@
EntityCondition havingEntityCondition, Collection fieldsToSelect, List orderBy, EntityFindOptions findOptions)
throws GenericEntityException;
+ int removeByAnd(String entityName, Object... fields) throws GenericEntityException;
+
int removeByAnd(String entityName, Map fields) throws GenericEntityException;
+ int removeByAnd(String entityName, boolean doCacheClear, Object... fields) throws GenericEntityException;
+
int removeByAnd(String entityName, Map fields, boolean doCacheClear) throws GenericEntityException;
int removeByCondition(String entityName, EntityCondition condition) throws GenericEntityException;
@@ -225,6 +259,8 @@
void clearAllCaches(boolean distribute);
void clearCacheLine(String entityName);
+
+ void clearCacheLine(String entityName, Object... fields);
void clearCacheLine(String entityName, Map fields);
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=585808&r1=585807&r2=585808&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Wed Oct 17 20:05:01 2007
@@ -21,6 +21,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -445,6 +446,11 @@
}
/** Creates a Entity in the form of a GenericValue without persisting it */
+ public GenericValue makeValue(String entityName, Object... fields) {
+ return makeValue(entityName, UtilMisc.toMap(fields));
+ }
+
+ /** Creates a Entity in the form of a GenericValue without persisting it */
public GenericValue makeValue(String entityName, Map fields) {
ModelEntity entity = this.getModelEntity(entityName);
if (entity == null) {
@@ -467,6 +473,11 @@
}
/** Creates a Entity in the form of a GenericValue without persisting it; only valid fields will be pulled from the fields Map */
+ public GenericValue makeValidValue(String entityName, Object... fields) {
+ return makeValidValue(entityName, UtilMisc.toMap(fields));
+ }
+
+ /** Creates a Entity in the form of a GenericValue without persisting it; only valid fields will be pulled from the fields Map */
public GenericValue makeValidValue(String entityName, Map fields) {
ModelEntity entity = this.getModelEntity(entityName);
if (entity == null) {
@@ -492,6 +503,11 @@
}
/** Creates a Primary Key in the form of a GenericPK without persisting it */
+ public GenericPK makePK(String entityName, Object... fields) {
+ return makePK(entityName, UtilMisc.toMap(fields));
+ }
+
+ /** Creates a Primary Key in the form of a GenericPK without persisting it */
public GenericPK makePK(String entityName, Map fields) {
ModelEntity entity = this.getModelEntity(entityName);
if (entity == null) {
@@ -539,6 +555,13 @@
/** Creates a Entity in the form of a GenericValue and write it to the database
*@return GenericValue instance containing the new instance
*/
+ public GenericValue create(String entityName, Object... fields) throws GenericEntityException {
+ return create(entityName, UtilMisc.toMap(fields));
+ }
+
+ /** Creates a Entity in the form of a GenericValue and write it to the database
+ *@return GenericValue instance containing the new instance
+ */
public GenericValue create(String entityName, Map fields) throws GenericEntityException {
if (entityName == null || fields == null) {
return null;
@@ -901,12 +924,31 @@
*@param fields The fields of the named entity to query by with their corresponging values
*@return int representing number of rows effected by this operation
*/
+ public int removeByAnd(String entityName, Object... fields) throws GenericEntityException {
+ return removeByAnd(entityName, UtilMisc.toMap(fields));
+ }
+
+ /** Removes/deletes Generic Entity records found by all of the specified fields (ie: combined using AND)
+ *@param entityName The Name of the Entity as defined in the entity XML file
+ *@param fields The fields of the named entity to query by with their corresponging values
+ *@return int representing number of rows effected by this operation
+ */
public int removeByAnd(String entityName, Map fields) throws GenericEntityException {
return this.removeByAnd(entityName, fields, true);
}
/** Removes/deletes Generic Entity records found by all of the specified fields (ie: combined using AND)
*@param entityName The Name of the Entity as defined in the entity XML file
+ *@param doCacheClear boolean that specifies whether to clear cache entries for this value to be removed
+ *@param fields The fields of the named entity to query by with their corresponging values
+ *@return int representing number of rows effected by this operation
+ */
+ public int removeByAnd(String entityName, boolean doCacheClear, Object... fields) throws GenericEntityException {
+ return removeByAnd(entityName, UtilMisc.<String, Object>toMap(fields), doCacheClear);
+ }
+
+ /** Removes/deletes Generic Entity records found by all of the specified fields (ie: combined using AND)
+ *@param entityName The Name of the Entity as defined in the entity XML file
*@param fields The fields of the named entity to query by with their corresponging values
*@param doCacheClear boolean that specifies whether to clear cache entries for this value to be removed
*@return int representing number of rows effected by this operation
@@ -1412,6 +1454,15 @@
*@param fields The fields of the named entity to query by with their corresponging values
*@return The GenericValue corresponding to the primaryKey
*/
+ public GenericValue findByPrimaryKey(String entityName, Object... fields) throws GenericEntityException {
+ return findByPrimaryKey(entityName, UtilMisc.toMap(fields));
+ }
+
+ /** Find a Generic Entity by its Primary Key
+ *@param entityName The Name of the Entity as defined in the entity XML file
+ *@param fields The fields of the named entity to query by with their corresponging values
+ *@return The GenericValue corresponding to the primaryKey
+ */
public GenericValue findByPrimaryKey(String entityName, Map fields) throws GenericEntityException {
return findByPrimaryKey(makePK(entityName, fields));
}
@@ -1430,6 +1481,15 @@
*@param fields The fields of the named entity to query by with their corresponging values
*@return The GenericValue corresponding to the primaryKey
*/
+ public GenericValue findByPrimaryKeyCache(String entityName, Object... fields) throws GenericEntityException {
+ return findByPrimaryKeyCache(entityName, UtilMisc.toMap(fields));
+ }
+
+ /** Find a CACHED Generic Entity by its Primary Key
+ *@param entityName The Name of the Entity as defined in the entity XML file
+ *@param fields The fields of the named entity to query by with their corresponging values
+ *@return The GenericValue corresponding to the primaryKey
+ */
public GenericValue findByPrimaryKeyCache(String entityName, Map fields) throws GenericEntityException {
return findByPrimaryKeyCache(makePK(entityName, fields));
}
@@ -1448,6 +1508,15 @@
*@param keys The keys, or names, of the values to retrieve; only these values will be retrieved
*@return The GenericValue corresponding to the primaryKey
*/
+ public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, String... keys) throws GenericEntityException {
+ return findByPrimaryKeyPartial(primaryKey, UtilMisc.toSet(keys));
+ }
+
+ /** Find a Generic Entity by its Primary Key and only returns the values requested by the passed keys (names)
+ *@param primaryKey The primary key to find by.
+ *@param keys The keys, or names, of the values to retrieve; only these values will be retrieved
+ *@return The GenericValue corresponding to the primaryKey
+ */
public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set keys) throws GenericEntityException {
boolean beganTransaction = false;
try {
@@ -1644,6 +1713,15 @@
*@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending
*@return List containing all Generic entities
*/
+ public List findAll(String entityName, String... orderBy) throws GenericEntityException {
+ return findAll(entityName, Arrays.asList(orderBy));
+ }
+
+ /** Finds all Generic entities
+ *@param entityName The Name of the Entity as defined in the entity XML file
+ *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending
+ *@return List containing all Generic entities
+ */
public List findAll(String entityName, List orderBy) throws GenericEntityException {
return this.findByAnd(entityName, FastMap.newInstance(), orderBy);
}
@@ -1653,7 +1731,16 @@
*@return List containing all Generic entities
*/
public List findAllCache(String entityName) throws GenericEntityException {
- return this.findAllCache(entityName, null);
+ return this.findAllCache(entityName, (List) null);
+ }
+
+ /** Finds all Generic entities, looking first in the cache; uses orderBy for lookup, but only keys results on the entityName and fields
+ *@param entityName The Name of the Entity as defined in the entity XML file
+ *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending
+ *@return List containing all Generic entities
+ */
+ public List findAllCache(String entityName, String... orderBy) throws GenericEntityException {
+ return findAllCache(entityName, Arrays.asList(orderBy));
}
/** Finds all Generic entities, looking first in the cache; uses orderBy for lookup, but only keys results on the entityName and fields
@@ -1683,6 +1770,15 @@
* @param fields The fields of the named entity to query by with their corresponging values
* @return List of GenericValue instances that match the query
*/
+ public List findByAnd(String entityName, Object... fields) throws GenericEntityException {
+ return findByAnd(entityName, UtilMisc.toMap(fields));
+ }
+
+ /** Finds Generic Entity records by all of the specified fields (ie: combined using AND)
+ * @param entityName The Name of the Entity as defined in the entity XML file
+ * @param fields The fields of the named entity to query by with their corresponging values
+ * @return List of GenericValue instances that match the query
+ */
public List findByAnd(String entityName, Map fields) throws GenericEntityException {
return this.findByAnd(entityName, fields, null);
}
@@ -1692,6 +1788,15 @@
* @param fields The fields of the named entity to query by with their corresponging values
* @return List of GenericValue instances that match the query
*/
+ public List findByOr(String entityName, Object... fields) throws GenericEntityException {
+ return findByOr(entityName, UtilMisc.toMap(fields));
+ }
+
+ /** Finds Generic Entity records by all of the specified fields (ie: combined using OR)
+ * @param entityName The Name of the Entity as defined in the entity XML file
+ * @param fields The fields of the named entity to query by with their corresponging values
+ * @return List of GenericValue instances that match the query
+ */
public List findByOr(String entityName, Map fields) throws GenericEntityException {
return this.findByOr(entityName, fields, null);
}
@@ -1730,6 +1835,15 @@
*@param fields The fields of the named entity to query by with their corresponging values
*@return List of GenericValue instances that match the query
*/
+ public List findByAndCache(String entityName, Object... fields) throws GenericEntityException {
+ return findByAndCache(entityName, UtilMisc.toMap(fields));
+ }
+
+ /** 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
+ *@param entityName The Name of the Entity as defined in the entity XML file
+ *@param fields The fields of the named entity to query by with their corresponging values
+ *@return List of GenericValue instances that match the query
+ */
public List findByAndCache(String entityName, Map fields) throws GenericEntityException {
return this.findByAndCache(entityName, fields, null);
}
@@ -1749,6 +1863,15 @@
*@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to
*@return List of GenericValue instances that match the query
*/
+ public List findByAnd(String entityName, EntityCondition... expressions) throws GenericEntityException {
+ return findByAnd(entityName, Arrays.asList(expressions));
+ }
+
+ /** Finds Generic Entity records by all of the specified expressions (ie: combined using AND)
+ *@param entityName The Name of the Entity as defined in the entity XML file
+ *@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to
+ *@return List of GenericValue instances that match the query
+ */
public List findByAnd(String entityName, List expressions) throws GenericEntityException {
EntityConditionList ecl = new EntityConditionList(expressions, EntityOperator.AND);
return findByCondition(entityName, ecl, null, null);
@@ -1770,6 +1893,15 @@
*@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to
*@return List of GenericValue instances that match the query
*/
+ public List findByOr(String entityName, EntityCondition... expressions) throws GenericEntityException {
+ return findByOr(entityName, Arrays.asList(expressions));
+ }
+
+ /** Finds Generic Entity records by all of the specified expressions (ie: combined using OR)
+ *@param entityName The Name of the Entity as defined in the entity XML file
+ *@param expressions The expressions to use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare to
+ *@return List of GenericValue instances that match the query
+ */
public List findByOr(String entityName, List expressions) throws GenericEntityException {
EntityConditionList ecl = new EntityConditionList(expressions, EntityOperator.OR);
return findByCondition(entityName, ecl, null, null);
@@ -1786,6 +1918,10 @@
return findByCondition(entityName, ecl, null, orderBy);
}
+ public List findByLike(String entityName, Object... fields) throws GenericEntityException {
+ return findByLike(entityName, UtilMisc.toMap(fields));
+ }
+
public List findByLike(String entityName, Map fields) throws GenericEntityException {
return findByLike(entityName, fields, null);
}
@@ -1979,6 +2115,10 @@
return findCountByAnd(entityName, (Map<String, Object>) null);
}
+ public long findCountByAnd(String entityName, Object... fields) throws GenericEntityException {
+ return findCountByAnd(entityName, UtilMisc.<String, Object>toMap(fields));
+ }
+
public long findCountByAnd(String entityName, Map fields) throws GenericEntityException {
return findCountByCondition(entityName, new EntityFieldMap(fields, EntityOperator.AND), null);
}
@@ -2286,6 +2426,14 @@
*/
public void clearCacheLine(String entityName) {
cache.remove(entityName);
+ }
+
+ /** Remove a CACHED Generic Entity (List) from the cache, either a PK, ByAnd, or All
+ *@param entityName The Name of the Entity as defined in the entity XML file
+ *@param fields The fields of the named entity to query by with their corresponging values
+ */
+ public void clearCacheLine(String entityName, Object... fields) {
+ clearCacheLine(entityName, UtilMisc.toMap(fields));
}
/** Remove a CACHED Generic Entity (List) from the cache, either a PK, ByAnd, or All
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=585808&r1=585807&r2=585808&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 Wed Oct 17 20:05:01 2007
@@ -32,6 +32,10 @@
super();
}
+ public EntityConditionList(EntityJoinOperator operator, EntityCondition... conditionList) {
+ super(operator, conditionList);
+ }
+
public EntityConditionList(List conditionList, EntityJoinOperator operator) {
super(conditionList, operator);
}
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=585808&r1=585807&r2=585808&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 Wed Oct 17 20:05:01 2007
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.entity.condition;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -38,6 +39,11 @@
protected EntityJoinOperator operator;
protected EntityConditionListBase() {}
+
+ public EntityConditionListBase(EntityJoinOperator operator, EntityCondition... conditionList) {
+ this.conditionList = Arrays.asList(conditionList);
+ this.operator = operator;
+ }
public EntityConditionListBase(List conditionList, EntityJoinOperator operator) {
this.conditionList = conditionList;
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=585808&r1=585807&r2=585808&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 Wed Oct 17 20:05:01 2007
@@ -25,6 +25,8 @@
import java.util.List;
import java.util.Map;
+import org.ofbiz.base.util.UtilMisc;
+
/**
* Encapsulates simple expressions used for specifying queries
*
@@ -37,6 +39,10 @@
super();
}
+ public static List<EntityExpr> makeConditionList(EntityComparisonOperator op, Object... keysValues) {
+ return makeConditionList(UtilMisc.toMap(keysValues), op);
+ }
+
public static List makeConditionList(Map fieldMap, EntityComparisonOperator op) {
if (fieldMap == null) return new ArrayList();
List list = new ArrayList(fieldMap.size());
@@ -50,11 +56,19 @@
return list;
}
+ public EntityFieldMap(EntityComparisonOperator compOp, EntityJoinOperator joinOp, Object... keysValues) {
+ this(UtilMisc.toMap(keysValues), compOp, joinOp);
+ }
+
public EntityFieldMap(Map fieldMap, EntityComparisonOperator compOp, EntityJoinOperator joinOp) {
super(makeConditionList(fieldMap, compOp), joinOp);
this.fieldMap = fieldMap;
if (this.fieldMap == null) this.fieldMap = new LinkedHashMap();
this.operator = joinOp;
+ }
+
+ public EntityFieldMap(EntityJoinOperator joinOp, Object... keysValues) {
+ this(UtilMisc.toMap(keysValues), joinOp);
}
public EntityFieldMap(Map fieldMap, EntityJoinOperator operator) {
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java?rev=585808&r1=585807&r2=585808&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java Wed Oct 17 20:05:01 2007
@@ -20,6 +20,7 @@
package org.ofbiz.entity.condition;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
@@ -36,10 +37,20 @@
public OrderByList() {
}
+ public OrderByList(String... orderByList) {
+ addOrderBy(orderByList);
+ }
+
public OrderByList(Collection orderByList) {
addOrderBy(orderByList);
}
+ public void addOrderBy(String... orderByList) {
+ for (String orderByItem: orderByList) {
+ addOrderBy(orderByItem);
+ }
+ }
+
public void addOrderBy(Collection orderByList) {
Iterator it = orderByList.iterator();
while (it.hasNext()) {
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java?rev=585808&r1=585807&r2=585808&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java Wed Oct 17 20:05:01 2007
@@ -19,6 +19,7 @@
package org.ofbiz.entity.model;
import java.io.Serializable;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -619,6 +620,10 @@
return getFieldNamesFromFieldVector(nopks);
}
+ public List getFieldNamesFromFieldVector(ModelField... modelFields) {
+ return getFieldNamesFromFieldVector(Arrays.asList(modelFields));
+ }
+
public List getFieldNamesFromFieldVector(List modelFields) {
List nameList = FastList.newInstance();
@@ -755,6 +760,10 @@
return returnString.toString();
}
+ public String typeNameString(ModelField... flds) {
+ return typeNameString(Arrays.asList(flds));
+ }
+
public String typeNameString(List flds) {
StringBuffer returnString = new StringBuffer();
@@ -806,14 +815,26 @@
return fieldsStringList(fields, "null", ", ", false, true);
}
+ public String fieldsStringList(String eachString, String separator, ModelField... flds) {
+ return fieldsStringList(Arrays.asList(flds), eachString, separator);
+ }
+
public String fieldsStringList(List flds, String eachString, String separator) {
return fieldsStringList(flds, eachString, separator, false, false);
}
+ public String fieldsStringList(String eachString, String separator, boolean appendIndex, ModelField... flds) {
+ return fieldsStringList(Arrays.asList(flds), eachString, separator, appendIndex, false);
+ }
+
public String fieldsStringList(List flds, String eachString, String separator, boolean appendIndex) {
return fieldsStringList(flds, eachString, separator, appendIndex, false);
}
+ public String fieldsStringList(String eachString, String separator, boolean appendIndex, boolean onlyNonPK, ModelField... flds) {
+ return fieldsStringList(Arrays.asList(flds), eachString, separator, appendIndex, onlyNonPK);
+ }
+
public String fieldsStringList(List flds, String eachString, String separator, boolean appendIndex, boolean onlyNonPK) {
StringBuffer returnString = new StringBuffer();
@@ -832,10 +853,18 @@
return returnString.toString();
}
+ public String colNameString(ModelField... flds) {
+ return colNameString(Arrays.asList(flds));
+ }
+
public String colNameString(List flds) {
return colNameString(flds, ", ", "", false);
}
+ public String colNameString(String separator, String afterLast, boolean alias, ModelField... flds) {
+ return colNameString(Arrays.asList(flds), separator, afterLast, alias);
+ }
+
public String colNameString(List flds, String separator, String afterLast, boolean alias) {
StringBuffer returnString = new StringBuffer();
@@ -856,10 +885,18 @@
return returnString.toString();
}
+ public String classNameString(ModelField... flds) {
+ return classNameString(Arrays.asList(flds));
+ }
+
public String classNameString(List flds) {
return classNameString(flds, ", ", "");
}
+ public String classNameString(String separator, String afterLast, ModelField... flds) {
+ return classNameString(Arrays.asList(flds), separator, afterLast);
+ }
+
public String classNameString(List flds, String separator, String afterLast) {
StringBuffer returnString = new StringBuffer();
@@ -878,6 +915,10 @@
return returnString.toString();
}
+ public String finderQueryString(ModelField... flds) {
+ return finderQueryString(Arrays.asList(flds));
+ }
+
public String finderQueryString(List flds) {
StringBuffer returnString = new StringBuffer();
@@ -899,6 +940,10 @@
return returnString.toString();
}
+ public String httpArgList(ModelField... flds) {
+ return httpArgList(Arrays.asList(flds));
+ }
+
public String httpArgList(List flds) {
StringBuffer returnString = new StringBuffer();
@@ -925,6 +970,10 @@
return returnString.toString();
}
+ public String httpArgListFromClass(ModelField... flds) {
+ return httpArgListFromClass(Arrays.asList(flds));
+ }
+
public String httpArgListFromClass(List flds) {
StringBuffer returnString = new StringBuffer();
@@ -957,6 +1006,10 @@
return returnString.toString();
}
+ public String httpArgListFromClass(String entityNameSuffix, ModelField... flds) {
+ return httpArgListFromClass(Arrays.asList(flds), entityNameSuffix);
+ }
+
public String httpArgListFromClass(List flds, String entityNameSuffix) {
StringBuffer returnString = new StringBuffer();
@@ -991,6 +1044,10 @@
return returnString.toString();
}
+ public String httpRelationArgList(ModelRelation relation, ModelField... flds) {
+ return httpRelationArgList(Arrays.asList(flds), relation);
+ }
+
public String httpRelationArgList(List flds, ModelRelation relation) {
StringBuffer returnString = new StringBuffer();
@@ -1051,6 +1108,10 @@
return returnString;
}
*/
+ public String typeNameStringRelatedNoMapped(ModelRelation relation, ModelField... flds) {
+ return typeNameStringRelatedNoMapped(Arrays.asList(flds), relation);
+ }
+
public String typeNameStringRelatedNoMapped(List flds, ModelRelation relation) {
StringBuffer returnString = new StringBuffer();
@@ -1075,6 +1136,10 @@
}
}
return returnString.toString();
+ }
+
+ public String typeNameStringRelatedAndMain(ModelRelation relation, ModelField... flds) {
+ return typeNameStringRelatedAndMain(Arrays.asList(flds), relation);
}
public String typeNameStringRelatedAndMain(List flds, ModelRelation relation) {
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java?rev=585808&r1=585807&r2=585808&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Wed Oct 17 20:05:01 2007
@@ -280,6 +280,10 @@
this.viewLinks.add(viewLink);
}
+ public String colNameString(String separator, String afterLast, boolean alias, ModelField... flds) {
+ return colNameString(Arrays.asList(flds), separator, afterLast, alias);
+ }
+
public String colNameString(List flds, String separator, String afterLast, boolean alias) {
StringBuffer returnString = new StringBuffer();
@@ -974,6 +978,10 @@
}
}
+ public ModelViewLink(String entityAlias, String relEntityAlias, Boolean relOptional, ModelKeyMap... keyMaps) {
+ this(entityAlias, relEntityAlias, relOptional, Arrays.asList(keyMaps));
+ }
+
public ModelViewLink(String entityAlias, String relEntityAlias, Boolean relOptional, List keyMaps) {
this.entityAlias = entityAlias;
this.relEntityAlias = relEntityAlias;
@@ -1062,6 +1070,10 @@
newValues.put((String) it.next(), EntityOperator.WILDCARD);
}
return newValues;
+ }
+
+ public void addAllAliasConversions(String fieldName, String... aliases) {
+ addAllAliasConversions(Arrays.asList(aliases), fieldName);
}
public void addAllAliasConversions(List aliases, String fieldName) {