Author: doogie
Date: Sun Jun 26 18:10:29 2011 New Revision: 1139879 URL: http://svn.apache.org/viewvc?rev=1139879&view=rev Log: FEATURE: Start passing ModelFieldTypeReader around(nothing uses it yet, coming soon). This will allow view entities to do stuff with field type definitions. Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java 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=1139879&r1=1139878&r2=1139879&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 Sun Jun 26 18:10:29 2011 @@ -76,7 +76,7 @@ public class EntityConditionSubSelect ex sql.append(localModelField.getColName()); // FROM clause and when necessary the JOIN or LEFT JOIN clause(s) as well - sql.append(SqlJdbcUtil.makeFromClause(localModelEntity, datasourceInfo)); + sql.append(SqlJdbcUtil.makeFromClause(localModelEntity, null, datasourceInfo)); // WHERE clause StringBuilder whereString = new StringBuilder(); 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=1139879&r1=1139878&r2=1139879&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 Sun Jun 26 18:10:29 2011 @@ -525,7 +525,7 @@ public class GenericDAO { sqlBuffer.append("*"); } - sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, datasourceInfo)); + sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, modelFieldTypeReader, datasourceInfo)); sqlBuffer.append(SqlJdbcUtil.makeWhereClause(modelEntity, modelEntity.getPkFieldsUnmodifiable(), entity, "AND", datasourceInfo.joinStyle)); try { @@ -594,7 +594,7 @@ public class GenericDAO { } else { sqlBuffer.append("*"); } - sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, datasourceInfo)); + sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, modelFieldTypeReader, datasourceInfo)); sqlBuffer.append(SqlJdbcUtil.makeWhereClause(modelEntity, modelEntity.getPkFieldsUnmodifiable(), entity, "AND", datasourceInfo.joinStyle)); SQLProcessor sqlP = new SQLProcessor(helperInfo); @@ -701,7 +701,7 @@ public class GenericDAO { } // FROM clause and when necessary the JOIN or LEFT JOIN clause(s) as well - sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, datasourceInfo)); + sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, modelFieldTypeReader, datasourceInfo)); // WHERE clause List<EntityConditionParam> whereEntityConditionParams = FastList.newInstance(); @@ -1035,7 +1035,7 @@ public class GenericDAO { } // FROM clause and when necessary the JOIN or LEFT JOIN clause(s) as well - sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, datasourceInfo)); + sqlBuffer.append(SqlJdbcUtil.makeFromClause(modelEntity, modelFieldTypeReader, datasourceInfo)); // WHERE clause List<EntityConditionParam> whereEntityConditionParams = FastList.newInstance(); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java?rev=1139879&r1=1139878&r2=1139879&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java Sun Jun 26 18:10:29 2011 @@ -73,7 +73,7 @@ public class SqlJdbcUtil { public static final int CHAR_BUFFER_SIZE = 4096; /** Makes the FROM clause and when necessary the JOIN clause(s) as well */ - public static String makeFromClause(ModelEntity modelEntity, DatasourceInfo datasourceInfo) throws GenericEntityException { + public static String makeFromClause(ModelEntity modelEntity, ModelFieldTypeReader modelFieldTypeReader, DatasourceInfo datasourceInfo) throws GenericEntityException { StringBuilder sql = new StringBuilder(" FROM "); if (modelEntity instanceof ModelViewEntity) { @@ -119,7 +119,7 @@ public class SqlJdbcUtil { if (i == 0) { // this is the first referenced member alias, so keep track of it for future use... - restOfStatement.append(makeViewTable(linkEntity, datasourceInfo)); + restOfStatement.append(makeViewTable(linkEntity, modelFieldTypeReader, datasourceInfo)); //another possible one that some dbs might need, but not sure of any yet: restOfStatement.append(" AS "); restOfStatement.append(" "); restOfStatement.append(viewLink.getEntityAlias()); @@ -140,7 +140,7 @@ public class SqlJdbcUtil { restOfStatement.append(" INNER JOIN "); } - restOfStatement.append(makeViewTable(relLinkEntity, datasourceInfo)); + restOfStatement.append(makeViewTable(relLinkEntity, modelFieldTypeReader, datasourceInfo)); //another possible one that some dbs might need, but not sure of any yet: restOfStatement.append(" AS "); restOfStatement.append(" "); restOfStatement.append(viewLink.getRelEntityAlias()); @@ -198,7 +198,7 @@ public class SqlJdbcUtil { if (!fromEmpty) sql.append(", "); fromEmpty = false; - sql.append(makeViewTable(fromEntity, datasourceInfo)); + sql.append(makeViewTable(fromEntity, modelFieldTypeReader, datasourceInfo)); sql.append(" "); sql.append(aliasName); } @@ -213,7 +213,7 @@ public class SqlJdbcUtil { String aliasName = meIter.next(); ModelEntity fromEntity = modelViewEntity.getMemberModelEntity(aliasName); - sql.append(makeViewTable(fromEntity, datasourceInfo)); + sql.append(makeViewTable(fromEntity, modelFieldTypeReader, datasourceInfo)); sql.append(" "); sql.append(aliasName); if (meIter.hasNext()) sql.append(", "); @@ -394,7 +394,7 @@ public class SqlJdbcUtil { return sql.toString(); } - public static String makeViewTable(ModelEntity modelEntity, DatasourceInfo datasourceInfo) throws GenericEntityException { + public static String makeViewTable(ModelEntity modelEntity, ModelFieldTypeReader modelFieldTypeReader, DatasourceInfo datasourceInfo) throws GenericEntityException { if (modelEntity instanceof ModelViewEntity) { StringBuilder sql = new StringBuilder("(SELECT "); Iterator<ModelField> fieldsIter = modelEntity.getFieldsIterator(); @@ -411,7 +411,7 @@ public class SqlJdbcUtil { sql.append(filterColName(curField.getColName())); } } - sql.append(makeFromClause(modelEntity, datasourceInfo)); + sql.append(makeFromClause(modelEntity, modelFieldTypeReader, datasourceInfo)); String viewWhereClause = makeViewWhereClause(modelEntity, datasourceInfo.joinStyle); if (UtilValidate.isNotEmpty(viewWhereClause)) { sql.append(" WHERE "); |
Free forum by Nabble | Edit this page |