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 2010/06/02 04:18:14 UTC
svn commit: r950338 -
/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
Author: doogie
Date: Wed Jun 2 02:18:14 2010
New Revision: 950338
URL: http://svn.apache.org/viewvc?rev=950338&view=rev
Log:
Refactor makeConditionWhereString to use the entity condition system to
build the where string.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java?rev=950338&r1=950337&r2=950338&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java Wed Jun 2 02:18:14 2010
@@ -47,6 +47,7 @@ import org.ofbiz.entity.GenericNotImplem
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityConditionParam;
+import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.config.DatasourceInfo;
import org.ofbiz.entity.config.EntityConfigUtil;
import org.ofbiz.entity.jdbc.DatabaseUtil;
@@ -767,43 +768,25 @@ public class GenericDAO {
modelViewEntity = (ModelViewEntity) modelEntity;
}
- String entityCondWhereString = "";
+ List<EntityCondition> conditions = FastList.newInstance();
if (whereEntityCondition != null) {
- entityCondWhereString = whereEntityCondition.makeWhereString(modelEntity, whereEntityConditionParams, this.datasourceInfo);
+ conditions.add(whereEntityCondition);
}
- String viewEntityCondWhereString = null;
- if (modelViewEntity != null) {
+ if (modelViewEntity != null && !viewWhereConditions.isEmpty()) {
EntityCondition viewWhereEntityCondition = EntityCondition.makeCondition(viewWhereConditions);
- if (viewWhereEntityCondition != null) {
- viewEntityCondWhereString = viewWhereEntityCondition.makeWhereString(modelEntity, whereEntityConditionParams, this.datasourceInfo);
- }
+ conditions.add(viewWhereEntityCondition);
}
String viewClause = SqlJdbcUtil.makeViewWhereClause(modelEntity, datasourceInfo.joinStyle);
StringBuilder whereString = new StringBuilder();
- if (entityCondWhereString.length() > 0) {
- boolean addParens = entityCondWhereString.charAt(0) != '(';
- if (addParens) whereString.append("(");
- whereString.append(entityCondWhereString);
- if (addParens) whereString.append(")");
- }
-
- if (UtilValidate.isNotEmpty(viewEntityCondWhereString)) {
- if (whereString.length() > 0) whereString.append(" AND ");
- boolean addParens = viewEntityCondWhereString.charAt(0) != '(';
- if (addParens) whereString.append("(");
- whereString.append(viewEntityCondWhereString);
- if (addParens) whereString.append(")");
+ if (viewClause.length() > 0) {
+ conditions.add(EntityCondition.makeConditionWhere(viewClause));
}
- if (viewClause.length() > 0) {
- if (whereString.length() > 0) whereString.append(" AND ");
- boolean addParens = viewClause.charAt(0) != '(';
- if (addParens) whereString.append("(");
- whereString.append(viewClause);
- if (addParens) whereString.append(")");
+ if (!conditions.isEmpty()) {
+ whereString.append(EntityCondition.makeCondition(conditions, EntityOperator.AND).makeWhereString(modelEntity, whereEntityConditionParams, this.datasourceInfo));
}
return whereString;