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 2011/06/26 20:09:32 UTC

svn commit: r1139870 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity: condition/EntityExpr.java model/ModelViewEntity.java

Author: doogie
Date: Sun Jun 26 18:09:32 2011
New Revision: 1139870

URL: http://svn.apache.org/viewvc?rev=1139870&view=rev
Log:
FIX: EntityFieldValue has a helper method for fetching the
ModelField; use that instead of fetching the ModelField directly from
the entity.  This is a fix for view-conditions, as the EntityFieldValue
has an internal ModelViewEntity that it uses to fetch the field;
fetching the raw fieldName was not correct in these cases.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java

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=1139870&r1=1139869&r2=1139870&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 Sun Jun 26 18:09:32 2011
@@ -219,15 +219,16 @@ public class EntityExpr extends EntityCo
         }
 
         String fieldName = null;
+        ModelField curField;
         if (this.lhs instanceof EntityFieldValue) {
             EntityFieldValue efv = (EntityFieldValue) this.lhs;
             fieldName = efv.getFieldName();
+            curField = efv.getModelField(modelEntity);
         } else {
             // nothing to check
             return;
         }
 
-        ModelField curField = modelEntity.getField(fieldName);
         if (curField == null) {
             throw new IllegalArgumentException("FieldName " + fieldName + " not found for entity: " + modelEntity.getEntityName());
         }
@@ -263,7 +264,7 @@ public class EntityExpr extends EntityCo
         } else if (value instanceof EntityFieldValue) {
             EntityFieldValue efv = (EntityFieldValue) this.lhs;
             String rhsFieldName = efv.getFieldName();
-            ModelField rhsField = modelEntity.getField(rhsFieldName);
+            ModelField rhsField = efv.getModelField(modelEntity);
             if (rhsField == null) {
                 throw new IllegalArgumentException("FieldName " + rhsFieldName + " not found for entity: " + modelEntity.getEntityName());
             }

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=1139870&r1=1139869&r2=1139870&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 18:09:32 2011
@@ -1266,7 +1266,7 @@ public class ModelViewEntity extends Mod
             }
 
             EntityConditionValue lhs = EntityFieldValue.makeFieldValue(this.fieldName, this.entityAlias, entityAliasStack, this.viewEntityCondition.modelViewEntity);
-            ModelField lhsField = this.viewEntityCondition.modelViewEntity.getField(fieldName);
+            ModelField lhsField = lhs.getModelField(this.viewEntityCondition.modelViewEntity);
             if (lhsField == null) {
                 throw new IllegalArgumentException("Error in Entity Find: could not find field [" + fieldName + "] in entity with name [" + this.viewEntityCondition.modelViewEntity.getEntityName() + "]");
             }