On 06/26/2011 02:19 PM, [hidden email] wrote:
> Author: doogie > Date: Sun Jun 26 19:19:00 2011 > New Revision: 1139921 > > URL: http://svn.apache.org/viewvc?rev=1139921&view=rev > Log: > FEATURE:<view-conditon> on<view-link> is now supported. > This allows for LEFT JOINs that have additional filtering applied to > them. FIXME: not implemented on theta- database types. > > This feature depends on the following svn commits: 1139856, 1139869, > 1139870, 1139879, 1139919. This is another major new feature. <view-link> has supported parsing of <view-condition> for a long time, but it was never implemented in the code. The change below is deceptively simple. There has been support for <view-condition> on <view>, however, the implementation of that is actually quite buggy. If you join 2 views together, and the inner view has a <view-condition>, and the join is optional, then the current code base will add that to the other WHERE clause, but without considering the optional flag. This effectively makes the join required, which then breaks the view. Based on this new feature here, it should be possible to fix the above flaw. > Modified: > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java > ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java > > 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=1139921&r1=1139920&r2=1139921&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 19:19:00 2011 > @@ -52,6 +52,7 @@ import org.ofbiz.entity.GenericEntityExc > import org.ofbiz.entity.GenericModelException; > import org.ofbiz.entity.GenericNotImplementedException; > import org.ofbiz.entity.GenericValue; > +import org.ofbiz.entity.condition.EntityCondition; > import org.ofbiz.entity.condition.EntityConditionParam; > import org.ofbiz.entity.condition.OrderByList; > import org.ofbiz.entity.config.DatasourceInfo; > @@ -177,8 +178,14 @@ public class SqlJdbcUtil { > throw new GenericModelException("No view-link/join key-maps found for the " + viewLink.getEntityAlias() + " and the " + viewLink.getRelEntityAlias() + " member-entities of the " + modelViewEntity.getEntityName() + " view-entity."); > } > > - // TODO add expression from entity-condition on view-link > - > + ModelViewEntity.ViewEntityCondition viewEntityCondition = viewLink.getViewEntityCondition(); > + if (viewEntityCondition != null) { > + EntityCondition whereCondition = viewEntityCondition.getWhereCondition(modelFieldTypeReader, null); > + if (whereCondition != null) { > + condBuffer.append(" AND "); > + condBuffer.append(whereCondition.makeWhereString(modelEntity, null, datasourceInfo)); > + } > + } > > restOfStatement.append(condBuffer.toString()); > > > 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=1139921&r1=1139920&r2=1139921&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 Sun Jun 26 19:19:00 2011 > @@ -1118,6 +1118,10 @@ public class ModelViewEntity extends Mod > newList.addAll(this.keyMaps); > return newList; > } > + > + public ViewEntityCondition getViewEntityCondition() { > + return this.viewEntityCondition; > + } > } > > public final class ModelConversion implements Serializable { > > |
Free forum by Nabble | Edit this page |