svn commit: r795024 [5/6] - in /ofbiz/branches/executioncontext20090716: ./ applications/content/src/org/ofbiz/content/content/ applications/order/src/org/ofbiz/order/order/ applications/party/src/org/ofbiz/party/party/ applications/product/src/org/ofb...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r795024 [5/6] - in /ofbiz/branches/executioncontext20090716: ./ applications/content/src/org/ofbiz/content/content/ applications/order/src/org/ofbiz/order/order/ applications/party/src/org/ofbiz/party/party/ applications/product/src/org/ofb...

jonesde
Copied: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericPKImpl.java (from r793049, ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java)
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericPKImpl.java?p2=ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericPKImpl.java&p1=ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java&r1=793049&r2=795024&rev=795024&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericPKImpl.java Fri Jul 17 09:56:47 2009
@@ -22,22 +22,24 @@
 
 import javolution.context.ObjectFactory;
 
+import org.ofbiz.context.entity.GenericPK;
 import org.ofbiz.entity.model.ModelEntity;
 
 /**
  * Generic Entity Primary Key Object
  *
  */
-public class GenericPK extends GenericEntity {
+@SuppressWarnings("serial")
+public class GenericPKImpl extends GenericEntityImpl implements GenericPK {
 
     protected static final ObjectFactory<GenericPK> genericPKFactory = new ObjectFactory<GenericPK>() {
         @Override
         protected GenericPK create() {
-            return new GenericPK();
+            return new GenericPKImpl();
         }
     };
 
-    protected GenericPK() { }
+    protected GenericPKImpl() { }
 
     /** Creates new GenericPK */
     public static GenericPK create(ModelEntity modelEntity) {

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericResultSetClosedException.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericResultSetClosedException.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericResultSetClosedException.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericResultSetClosedException.java Fri Jul 17 09:56:47 2009
@@ -18,10 +18,13 @@
  *******************************************************************************/
 package org.ofbiz.entity;
 
+import org.ofbiz.context.entity.GenericEntityException;
+
 /**
  * GenericResultSetClosedException
  *
  */
+@SuppressWarnings("serial")
 public class GenericResultSetClosedException extends GenericEntityException {
 
     public GenericResultSetClosedException() {

Copied: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericValueImpl.java (from r793049, ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java)
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericValueImpl.java?p2=ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericValueImpl.java&p1=ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java&r1=793049&r2=795024&rev=795024&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/GenericValueImpl.java Fri Jul 17 09:56:47 2009
@@ -25,17 +25,19 @@
 import java.util.Map;
 
 import javolution.context.ObjectFactory;
-import javolution.lang.Reusable;
 import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.context.entity.GenericEntityException;
+import org.ofbiz.context.entity.GenericPK;
+import org.ofbiz.context.entity.GenericValue;
+import org.ofbiz.context.entity.ModelKeyMapInterface;
+import org.ofbiz.context.entity.ModelRelationInterface;
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.condition.EntityFieldMap;
 import org.ofbiz.entity.model.ModelEntity;
-import org.ofbiz.entity.model.ModelKeyMap;
-import org.ofbiz.entity.model.ModelRelation;
 import org.ofbiz.entity.util.EntityUtil;
 
 
@@ -44,14 +46,14 @@
  *
  */
 @SuppressWarnings("serial")
-public class GenericValue extends GenericEntity implements Reusable {
+public class GenericValueImpl extends GenericEntityImpl implements GenericValue {
 
     public static final GenericValue NULL_VALUE = new NullGenericValue();
 
-    protected static final ObjectFactory<GenericValue> genericValueFactory = new ObjectFactory<GenericValue>() {
+    protected static final ObjectFactory<GenericValueImpl> genericValueFactory = new ObjectFactory<GenericValueImpl>() {
         @Override
-        protected GenericValue create() {
-            return new GenericValue();
+        protected GenericValueImpl create() {
+            return new GenericValueImpl();
         }
     };
 
@@ -67,39 +69,39 @@
      */
     protected Map<String, Object> originalDbValues = null;
 
-    protected GenericValue() { }
+    protected GenericValueImpl() { }
 
     /** Creates new GenericValue */
     public static GenericValue create(ModelEntity modelEntity) {
-        GenericValue newValue = genericValueFactory.object();
+        GenericValueImpl newValue = genericValueFactory.object();
         newValue.init(modelEntity);
         return newValue;
     }
 
     /** Creates new GenericValue from existing Map */
     public static GenericValue create(ModelEntity modelEntity, Map<String, ? extends Object> fields) {
-        GenericValue newValue = genericValueFactory.object();
+        GenericValueImpl newValue = genericValueFactory.object();
         newValue.init(modelEntity, fields);
         return newValue;
     }
 
     /** Creates new GenericValue from existing Map */
     public static GenericValue create(ModelEntity modelEntity, Object singlePkValue) {
-        GenericValue newValue = genericValueFactory.object();
+        GenericValueImpl newValue = genericValueFactory.object();
         newValue.init(modelEntity, singlePkValue);
         return newValue;
     }
 
     /** Creates new GenericValue from existing GenericValue */
     public static GenericValue create(GenericValue value) {
-        GenericValue newValue = genericValueFactory.object();
+        GenericValueImpl newValue = genericValueFactory.object();
         newValue.init(value);
         return newValue;
     }
 
     /** Creates new GenericValue from existing GenericValue */
     public static GenericValue create(GenericPK primaryKey) {
-        GenericValue newValue = genericValueFactory.object();
+        GenericValueImpl newValue = genericValueFactory.object();
         newValue.init(primaryKey);
         return newValue;
     }
@@ -440,14 +442,14 @@
      */
     public boolean checkFks(boolean insertDummy) throws GenericEntityException {
         ModelEntity model = this.getModelEntity();
-        Iterator<ModelRelation> relItr = model.getRelationsIterator();
+        Iterator<ModelRelationInterface> relItr = model.getRelationsIterator();
         while (relItr.hasNext()) {
-            ModelRelation relation = relItr.next();
+            ModelRelationInterface relation = relItr.next();
             if ("one".equalsIgnoreCase(relation.getType())) {
                 // see if the related value exists
                 Map<String, Object> fields = FastMap.newInstance();
                 for (int i = 0; i < relation.getKeyMapsSize(); i++) {
-                    ModelKeyMap keyMap = relation.getKeyMap(i);
+                    ModelKeyMapInterface keyMap = relation.getKeyMap(i);
                     fields.put(keyMap.getRelFieldName(), this.get(keyMap.getFieldName()));
                 }
                 EntityFieldMap ecl = EntityCondition.makeCondition(fields);
@@ -456,10 +458,10 @@
                     if (insertDummy) {
                         // create the new related value (dummy)
                         GenericValue newValue = this.getDelegator().makeValue(relation.getRelEntityName());
-                        Iterator<ModelKeyMap> keyMapIter = relation.getKeyMapsIterator();
+                        Iterator<ModelKeyMapInterface> keyMapIter = relation.getKeyMapsIterator();
                         boolean allFieldsSet = true;
                         while (keyMapIter.hasNext()) {
-                            ModelKeyMap mkm = keyMapIter.next();
+                            ModelKeyMapInterface mkm = keyMapIter.next();
                             if (this.get(mkm.getFieldName()) != null) {
                                 newValue.set(mkm.getRelFieldName(), this.get(mkm.getFieldName()));
                                 if (Debug.infoOn()) Debug.logInfo("Set [" + mkm.getRelFieldName() + "] to - " + this.get(mkm.getFieldName()), module);
@@ -495,12 +497,12 @@
      */
     @Override
     public Object clone() {
-        GenericValue newEntity = GenericValue.create(this);
+        GenericValue newEntity = GenericValueImpl.create(this);
         newEntity.setDelegator(internalDelegator);
         return newEntity;
     }
 
-    protected static class NullGenericValue extends GenericValue implements NULL {
+    protected static class NullGenericValue extends GenericValueImpl implements org.ofbiz.context.entity.GenericEntity.NULL {
         @Override
         public String getEntityName() {
             return "[null-entity-value]";

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java Fri Jul 17 09:56:47 2009
@@ -19,7 +19,8 @@
 package org.ofbiz.entity.cache;
 
 import org.ofbiz.base.util.cache.UtilCache;
-import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.context.entity.GenericDelegator;
+import org.ofbiz.entity.GenericDelegatorImpl;
 
 public abstract class AbstractCache<K, V> {
 
@@ -31,7 +32,7 @@
     }
 
     public GenericDelegator getDelegator() {
-        return GenericDelegator.getGenericDelegator(delegatorName);
+        return GenericDelegatorImpl.getGenericDelegator(delegatorName);
     }
 
     public void remove(String entityName) {

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java Fri Jul 17 09:56:47 2009
@@ -27,9 +27,10 @@
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.cache.UtilCache;
-import org.ofbiz.entity.GenericEntity;
-import org.ofbiz.entity.GenericPK;
-import org.ofbiz.entity.GenericValue;
+import org.ofbiz.context.entity.GenericEntity;
+import org.ofbiz.context.entity.GenericPK;
+import org.ofbiz.entity.GenericEntityImpl;
+import org.ofbiz.entity.GenericValueImpl;
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.model.ModelEntity;
 import org.ofbiz.entity.model.ModelViewEntity;
@@ -50,7 +51,7 @@
     }
 
     protected V put(String entityName, EntityCondition condition, K key, V value) {
-        ModelEntity entity = this.getDelegator().getModelEntity(entityName);
+        ModelEntity entity = (ModelEntity) this.getDelegator().getModelEntity(entityName);
         if (entity.getNeverCache()) {
             Debug.logWarning("Tried to put a value of the " + entityName + " entity in the cache but this entity has never-cache set to true, not caching.", module);
             return null;
@@ -110,20 +111,20 @@
     }
 
     protected static final boolean isNull(Map value) {
-        return value == null || value == GenericEntity.NULL_ENTITY || value == GenericValue.NULL_VALUE;
+        return value == null || value == GenericEntityImpl.NULL_ENTITY || value == GenericValueImpl.NULL_VALUE;
     }
 
     protected ModelEntity getModelCheckValid(GenericEntity oldEntity, GenericEntity newEntity) {
         ModelEntity model;
         if (!isNull(newEntity)) {
-            model = newEntity.getModelEntity();
+            model = (ModelEntity) newEntity.getModelEntity();
             String entityName = model.getEntityName();
             if (oldEntity != null && !entityName.equals(oldEntity.getEntityName())) {
                 throw new IllegalArgumentException("internal error: storeHook called with 2 different entities(old=" + oldEntity.getEntityName() + ", new=" + entityName + ")");
             }
         } else {
             if (!isNull(oldEntity)) {
-                model = oldEntity.getModelEntity();
+                model = (ModelEntity) oldEntity.getModelEntity();
             } else {
                 throw new IllegalArgumentException("internal error: storeHook called with 2 null arguments");
             }
@@ -149,10 +150,11 @@
 
     protected List<? extends Map<String, Object>> convert(boolean isPK, String targetEntityName, GenericEntity entity) {
         if (isNull(entity)) return null;
+        ModelEntity modelEntity = (ModelEntity) entity.getModelEntity();
         if (isPK) {
-            return entity.getModelEntity().convertToViewValues(targetEntityName, (GenericPK) entity);
+            return modelEntity.convertToViewValues(targetEntityName, (GenericPK) entity);
         } else {
-            return entity.getModelEntity().convertToViewValues(targetEntityName, entity);
+            return modelEntity.convertToViewValues(targetEntityName, entity);
         }
     }
 

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/Cache.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/Cache.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/Cache.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/Cache.java Fri Jul 17 09:56:47 2009
@@ -22,9 +22,9 @@
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilGenerics;
-import org.ofbiz.entity.GenericEntity;
-import org.ofbiz.entity.GenericValue;
-import org.ofbiz.entity.GenericPK;
+import org.ofbiz.context.entity.GenericEntity;
+import org.ofbiz.context.entity.GenericPK;
+import org.ofbiz.context.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
 
 public class Cache {

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/EntityCache.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/EntityCache.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/EntityCache.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/EntityCache.java Fri Jul 17 09:56:47 2009
@@ -21,10 +21,11 @@
 import java.util.Iterator;
 
 import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.cache.UtilCache;
 import org.ofbiz.base.util.cache.CacheLine;
-import org.ofbiz.entity.GenericValue;
-import org.ofbiz.entity.GenericPK;
+import org.ofbiz.base.util.cache.UtilCache;
+import org.ofbiz.context.entity.GenericPK;
+import org.ofbiz.context.entity.GenericValue;
+import org.ofbiz.entity.GenericValueImpl;
 import org.ofbiz.entity.condition.EntityCondition;
 
 public class EntityCache extends AbstractCache<GenericPK, GenericValue> {
@@ -52,7 +53,7 @@
         }
 
         if (entity == null) {
-            entity = GenericValue.NULL_VALUE;
+            entity = GenericValueImpl.NULL_VALUE;
         } else {
             // before going into the cache, make this value immutable
             entity.setImmutable();

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/EntityListCache.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/EntityListCache.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/EntityListCache.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/cache/EntityListCache.java Fri Jul 17 09:56:47 2009
@@ -22,7 +22,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.ofbiz.entity.GenericValue;
+import org.ofbiz.context.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.util.EntityUtil;
 

Added: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java?rev=795024&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java (added)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java Fri Jul 17 09:56:47 2009
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.entity.condition;
+
+import static org.ofbiz.base.util.UtilGenerics.cast;
+
+import java.util.List;
+import java.util.Map;
+
+import javolution.lang.Reusable;
+import javolution.util.FastList;
+
+import org.ofbiz.context.entity.EntityConditionInterface;
+import org.ofbiz.context.entity.GenericDelegator;
+import org.ofbiz.context.entity.GenericEntity;
+import org.ofbiz.context.entity.ModelEntityInterface;
+import org.ofbiz.entity.GenericModelException;
+import org.ofbiz.entity.config.DatasourceInfo;
+import org.ofbiz.entity.model.ModelEntity;
+
+/**
+ * Represents the conditions to be used to constrain a query
+ * <br/>An EntityCondition can represent various type of constraints, including:
+ * <ul>
+ *  <li>EntityConditionList: a list of EntityConditions, combined with the operator specified
+ *  <li>EntityExpr: for simple expressions or expressions that combine EntityConditions
+ *  <li>EntityFieldMap: a map of fields where the field (key) equals the value, combined with the operator specified
+ * </ul>
+ * These can be used in various combinations using the EntityConditionList and EntityExpr objects.
+ *
+ */
+@SuppressWarnings("serial")
+public abstract class EntityCondition extends EntityConditionBase implements EntityConditionInterface, Reusable {
+
+    public static EntityExpr makeCondition(Object lhs, EntityComparisonOperator operator, Object rhs) {
+        EntityExpr expr = EntityExpr.entityExprFactory.object();
+        expr.init(lhs, operator, rhs);
+        return expr;
+    }
+
+    public static EntityExpr makeCondition(String fieldName, Object value) {
+        EntityExpr expr = EntityExpr.entityExprFactory.object();
+        expr.init(fieldName, EntityOperator.EQUALS, value);
+        return expr;
+    }
+
+    public static EntityExpr makeCondition(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) {
+        EntityExpr expr = EntityExpr.entityExprFactory.object();
+        expr.init(lhs, operator, rhs);
+        return expr;
+    }
+
+    public static <T extends EntityCondition> EntityConditionList<T> makeCondition(EntityJoinOperator operator, T... conditionList) {
+        EntityConditionList<T> ecl = cast(EntityConditionList.entityConditionListFactory.object());
+        ecl.init(operator, conditionList);
+        return ecl;
+    }
+
+    public static <T extends EntityCondition> EntityConditionList<T> makeCondition(T... conditionList) {
+        EntityConditionList<T> ecl = cast(EntityConditionList.entityConditionListFactory.object());
+        ecl.init(EntityOperator.AND, conditionList);
+        return ecl;
+    }
+
+    public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList, EntityJoinOperator operator) {
+        EntityConditionList<T> ecl = cast(EntityConditionList.entityConditionListFactory.object());
+        ecl.init(conditionList, operator);
+        return ecl;
+    }
+
+    public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList) {
+        EntityConditionList<T> ecl = cast(EntityConditionList.entityConditionListFactory.object());
+        ecl.init(conditionList, EntityOperator.AND);
+        return ecl;
+    }
+
+    public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityComparisonOperator compOp, EntityJoinOperator joinOp) {
+        EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object();
+        efm.init(fieldMap, compOp, joinOp);
+        return efm;
+    }
+
+    public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityJoinOperator joinOp) {
+        EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object();
+        efm.init(fieldMap, EntityOperator.EQUALS, joinOp);
+        return efm;
+    }
+
+    public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap) {
+        EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object();
+        efm.init(fieldMap, EntityOperator.EQUALS, EntityOperator.AND);
+        return efm;
+    }
+
+    public static EntityFieldMap makeCondition(EntityComparisonOperator compOp, EntityJoinOperator joinOp, Object... keysValues) {
+        EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object();
+        efm.init(compOp, joinOp, keysValues);
+        return efm;
+    }
+
+    public static EntityFieldMap makeCondition(EntityJoinOperator joinOp, Object... keysValues) {
+        EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object();
+        efm.init(EntityOperator.EQUALS, joinOp, keysValues);
+        return efm;
+    }
+
+    public static EntityFieldMap makeConditionMap(Object... keysValues) {
+        EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object();
+        efm.init(EntityOperator.EQUALS, EntityOperator.AND, keysValues);
+        return efm;
+    }
+
+    public static EntityDateFilterCondition makeConditionDate(String fromDateName, String thruDateName) {
+        EntityDateFilterCondition edfc = EntityDateFilterCondition.entityDateFilterConditionFactory.object();
+        edfc.init(fromDateName, thruDateName);
+        return edfc;
+    }
+
+    public static EntityWhereString makeConditionWhere(String sqlString) {
+        EntityWhereString ews = EntityWhereString.entityWhereStringFactory.object();
+        ews.init(sqlString);
+        return ews;
+    }
+
+    @Override
+    public String toString() {
+        return makeWhereString(null, FastList.<EntityConditionParam>newInstance(), null);
+    }
+
+    public void accept(EntityConditionVisitor visitor) {
+        throw new IllegalArgumentException(getClass().getName() + ".accept not implemented");
+    }
+
+    abstract public String makeWhereString(ModelEntityInterface modelEntity, List<EntityConditionParam> entityConditionParams, DatasourceInfo datasourceInfo);
+
+    abstract public void checkCondition(ModelEntity modelEntity) throws GenericModelException;
+
+    public boolean entityMatches(GenericEntity entity) {
+        return mapMatches(entity.getDelegator(), entity);
+    }
+
+    public Boolean eval(GenericEntity entity) {
+        return eval(entity.getDelegator(), entity);
+    }
+
+    public Boolean eval(GenericDelegator delegator, Map<String, ? extends Object> map) {
+        return mapMatches(delegator, map) ? Boolean.TRUE : Boolean.FALSE;
+    }
+
+    abstract public boolean mapMatches(GenericDelegator delegator, Map<String, ? extends Object> map);
+
+    abstract public EntityCondition freeze();
+
+    abstract public void encryptConditionFields(ModelEntity modelEntity, GenericDelegator delegator);
+
+    public void visit(EntityConditionVisitor visitor) {
+        throw new IllegalArgumentException(getClass().getName() + ".visit not implemented");
+    }
+}

Added: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java?rev=795024&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java (added)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionBase.java Fri Jul 17 09:56:47 2009
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.entity.condition;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
+import org.ofbiz.context.entity.EntityConditionInterface;
+import org.ofbiz.entity.config.DatasourceInfo;
+import org.ofbiz.entity.jdbc.SqlJdbcUtil;
+import org.ofbiz.entity.model.ModelEntity;
+import org.ofbiz.entity.model.ModelField;
+import org.ofbiz.entity.model.ModelViewEntity;
+import org.ofbiz.entity.model.ModelViewEntity.ModelAlias;
+
+/**
+ * Represents the conditions to be used to constrain a query
+ * <br/>An EntityCondition can represent various type of constraints, including:
+ * <ul>
+ *  <li>EntityConditionList: a list of EntityConditions, combined with the operator specified
+ *  <li>EntityExpr: for simple expressions or expressions that combine EntityConditions
+ *  <li>EntityFieldMap: a map of fields where the field (key) equals the value, combined with the operator specified
+ * </ul>
+ * These can be used in various combinations using the EntityConditionList and EntityExpr objects.
+ *
+ */
+@SuppressWarnings("serial")
+public abstract class EntityConditionBase implements Serializable {
+
+    public static final List emptyList = Collections.unmodifiableList(FastList.newInstance());
+    public static final Map _emptyMap = Collections.unmodifiableMap(FastMap.newInstance());
+    public static final Map<String, String> emptyAliases = Collections.unmodifiableMap(FastMap.<String, String>newInstance());
+
+    protected ModelField getField(ModelEntity modelEntity, String fieldName) {
+        ModelField modelField = null;
+        if (modelEntity != null) {
+            modelField = modelEntity.getField(fieldName);
+        }
+        return modelField;
+    }
+
+    protected String getColName(Map<String, String> tableAliases, ModelEntity modelEntity, String fieldName, boolean includeTableNamePrefix, DatasourceInfo datasourceInfo) {
+        if (modelEntity == null) return fieldName;
+        return getColName(tableAliases, modelEntity, getField(modelEntity, fieldName), fieldName, includeTableNamePrefix, datasourceInfo);
+    }
+
+    protected String getColName(ModelField modelField, String fieldName) {
+        String colName = null;
+        if (modelField != null) {
+            colName = modelField.getColName();
+        } else {
+            colName = fieldName;
+        }
+        return colName;
+    }
+
+    protected String getColName(Map<String, String> tableAliases, ModelEntity modelEntity, ModelField modelField, String fieldName, boolean includeTableNamePrefix, DatasourceInfo datasourceInfo) {
+        if (modelEntity == null || modelField == null) return fieldName;
+
+        // if this is a view entity and we are configured to alias the views, use the alias here instead of the composite (ie table.column) field name
+        if (datasourceInfo != null && datasourceInfo.aliasViews && modelEntity instanceof ModelViewEntity) {
+            ModelViewEntity modelViewEntity = (ModelViewEntity) modelEntity;
+            ModelAlias modelAlias = modelViewEntity.getAlias(fieldName);
+            if (modelAlias != null) {
+                return modelAlias.getColAlias();
+            }
+        }
+
+        String colName = getColName(modelField, fieldName);
+        if (includeTableNamePrefix && datasourceInfo != null) {
+            String tableName = modelEntity.getTableName(datasourceInfo);
+            if (tableAliases.containsKey(tableName)) {
+                tableName = tableAliases.get(tableName);
+            }
+            colName = tableName + "." + colName;
+        }
+        return colName;
+    }
+
+    protected void addValue(StringBuilder buffer, ModelField field, Object value, List<EntityConditionParam> params) {
+        SqlJdbcUtil.addValue(buffer, params == null ? null : field, value, params);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        throw new UnsupportedOperationException("equals:" + getClass().getName());
+    }
+
+    @Override
+    public int hashCode() {
+        throw new UnsupportedOperationException("hashCode: " + getClass().getName());
+    }
+
+    protected static boolean equals(Object o1, Object o2) {
+        return o1 == null ? o2 == null : o1.equals(o2);
+    }
+
+    protected static int hashCode(Object o) {
+        return o != null ? o.hashCode() : 0;
+    }
+
+    public static Boolean castBoolean(boolean result) {
+        return result ? Boolean.TRUE : Boolean.FALSE;
+    }
+}

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionParam.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionParam.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionParam.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionParam.java Fri Jul 17 09:56:47 2009
@@ -26,6 +26,7 @@
  * Represents a single parameter to be used in the preparedStatement
  *
  */
+@SuppressWarnings("serial")
 public class EntityConditionParam implements Serializable {
     protected ModelField modelField;
     protected Object fieldValue;

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java Fri Jul 17 09:56:47 2009
@@ -22,8 +22,10 @@
 import java.util.Map;
 
 import org.ofbiz.base.util.Debug;
-import org.ofbiz.entity.GenericDelegator;
-import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.context.entity.GenericDelegator;
+import org.ofbiz.context.entity.GenericEntityException;
+import org.ofbiz.context.entity.ModelEntityInterface;
+import org.ofbiz.context.entity.ModelFieldInterface;
 import org.ofbiz.entity.GenericModelException;
 import org.ofbiz.entity.config.DatasourceInfo;
 import org.ofbiz.entity.jdbc.SqlJdbcUtil;
@@ -31,10 +33,11 @@
 import org.ofbiz.entity.model.ModelField;
 import org.ofbiz.entity.model.ModelViewEntity;
 
+@SuppressWarnings("serial")
 public class EntityConditionSubSelect extends EntityConditionValue {
     public static final String module = EntityConditionSubSelect.class.getName();
 
-    protected ModelEntity localModelEntity = null;
+    protected ModelEntityInterface localModelEntity = null;
     protected String keyFieldName = null;
     protected EntityCondition whereCond = null;
     protected Boolean requireAll = null;
@@ -44,7 +47,7 @@
     public EntityConditionSubSelect(String entityName, String keyFieldName, EntityCondition whereCond, boolean requireAll, GenericDelegator delegator) {
         this(delegator.getModelEntity(entityName), keyFieldName, whereCond, requireAll);
     }
-    public EntityConditionSubSelect(ModelEntity localModelEntity, String keyFieldName, EntityCondition whereCond, boolean requireAll) {
+    public EntityConditionSubSelect(ModelEntityInterface localModelEntity, String keyFieldName, EntityCondition whereCond, boolean requireAll) {
         this.localModelEntity = localModelEntity;
         this.keyFieldName = keyFieldName;
         this.whereCond = whereCond;
@@ -59,7 +62,7 @@
         }
         try {
             // add select and where and such, based on local entity not on the main entity
-            ModelField localModelField = localModelEntity.getField(this.keyFieldName);
+            ModelFieldInterface localModelField = localModelEntity.getField(this.keyFieldName);
 
             if (this.requireAll) {
                 sql.append(" ALL(");

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionValue.java Fri Jul 17 09:56:47 2009
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -15,15 +15,15 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *******************************************************************************/
+ */
 package org.ofbiz.entity.condition;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import org.ofbiz.entity.GenericDelegator;
-import org.ofbiz.entity.GenericEntity;
+import org.ofbiz.context.entity.GenericDelegator;
+import org.ofbiz.context.entity.GenericEntity;
 import org.ofbiz.entity.GenericModelException;
 import org.ofbiz.entity.config.DatasourceInfo;
 import org.ofbiz.entity.model.ModelEntity;

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionVisitor.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionVisitor.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionVisitor.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/EntityConditionVisitor.java Fri Jul 17 09:56:47 2009
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -15,23 +15,12 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *******************************************************************************/
+ */
 
 package org.ofbiz.entity.condition;
 
 import java.util.List;
 
-/**
- * Represents the conditions to be used to constrain a query
- * <br/>An EntityCondition can represent various type of constraints, including:
- * <ul>
- *  <li>EntityConditionList: a list of EntityConditions, combined with the operator specified
- *  <li>EntityExpr: for simple expressions or expressions that combine EntityConditions
- *  <li>EntityFieldMap: a map of fields where the field (key) equals the value, combined with the operator specified
- * </ul>
- * These can be used in various combinations using the EntityConditionList and EntityExpr objects.
- *
- */
 public interface EntityConditionVisitor {
     void visit(Object obj);
     void accept(Object obj);

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/OrderByItem.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/OrderByItem.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/OrderByItem.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/OrderByItem.java Fri Jul 17 09:56:47 2009
@@ -22,7 +22,7 @@
 import java.util.Comparator;
 
 import org.ofbiz.base.util.UtilGenerics;
-import org.ofbiz.entity.GenericEntity;
+import org.ofbiz.context.entity.GenericEntity;
 import org.ofbiz.entity.GenericModelException;
 import org.ofbiz.entity.config.DatasourceInfo;
 import org.ofbiz.entity.model.ModelEntity;

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/condition/OrderByList.java Fri Jul 17 09:56:47 2009
@@ -20,13 +20,11 @@
 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;
 import java.util.List;
 
-import org.ofbiz.entity.GenericEntity;
+import org.ofbiz.context.entity.GenericEntity;
 import org.ofbiz.entity.GenericModelException;
 import org.ofbiz.entity.config.DatasourceInfo;
 import org.ofbiz.entity.model.ModelEntity;

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/connection/ConnectionFactoryInterface.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/connection/ConnectionFactoryInterface.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/connection/ConnectionFactoryInterface.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/connection/ConnectionFactoryInterface.java Fri Jul 17 09:56:47 2009
@@ -3,8 +3,8 @@
 import java.sql.Connection;
 import java.sql.SQLException;
 
+import org.ofbiz.context.entity.GenericEntityException;
 import org.w3c.dom.Element;
-import org.ofbiz.entity.GenericEntityException;
 
 /**
  * ConnectionFactoryInterface

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/datasource/GenericHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/datasource/GenericHelper.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/datasource/GenericHelper.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/datasource/GenericHelper.java Fri Jul 17 09:56:47 2009
@@ -25,14 +25,14 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.ofbiz.entity.GenericEntityException;
-import org.ofbiz.entity.GenericPK;
-import org.ofbiz.entity.GenericValue;
+import org.ofbiz.context.entity.EntityFindOptions;
+import org.ofbiz.context.entity.EntityListIterator;
+import org.ofbiz.context.entity.GenericEntityException;
+import org.ofbiz.context.entity.GenericPK;
+import org.ofbiz.context.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.model.ModelEntity;
 import org.ofbiz.entity.model.ModelRelation;
-import org.ofbiz.entity.util.EntityFindOptions;
-import org.ofbiz.entity.util.EntityListIterator;
 
 
 /**

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java Fri Jul 17 09:56:47 2009
@@ -18,19 +18,19 @@
  *******************************************************************************/
 package org.ofbiz.entity.jdbc;
 
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.entity.GenericEntityException;
-import org.ofbiz.entity.config.EntityConfigUtil;
-import org.ofbiz.entity.connection.ConnectionFactoryInterface;
-import org.ofbiz.entity.transaction.TransactionFactory;
-import org.w3c.dom.Element;
-
 import java.sql.Connection;
 import java.sql.Driver;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.Properties;
 
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.context.entity.GenericEntityException;
+import org.ofbiz.entity.config.EntityConfigUtil;
+import org.ofbiz.entity.connection.ConnectionFactoryInterface;
+import org.ofbiz.entity.transaction.TransactionFactory;
+import org.w3c.dom.Element;
+
 /**
  * ConnectionFactory - central source for JDBC connections
  *

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java Fri Jul 17 09:56:47 2009
@@ -26,10 +26,10 @@
 import java.math.BigDecimal;
 import java.nio.ByteBuffer;
 import java.sql.Blob;
+import java.sql.Clob;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
-import java.sql.Clob;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -46,12 +46,15 @@
 import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.context.entity.GenericEntity;
+import org.ofbiz.context.entity.GenericEntityException;
+import org.ofbiz.context.entity.GenericValue;
+import org.ofbiz.context.entity.ModelEntityInterface;
+import org.ofbiz.context.entity.ModelFieldInterface;
 import org.ofbiz.entity.GenericDataSourceException;
-import org.ofbiz.entity.GenericEntity;
-import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericEntityImpl;
 import org.ofbiz.entity.GenericModelException;
 import org.ofbiz.entity.GenericNotImplementedException;
-import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityConditionParam;
 import org.ofbiz.entity.condition.OrderByList;
 import org.ofbiz.entity.config.DatasourceInfo;
@@ -73,7 +76,7 @@
     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(ModelEntityInterface modelEntity, DatasourceInfo datasourceInfo) throws GenericEntityException {
         StringBuilder sql = new StringBuilder(" FROM ");
 
         if (modelEntity instanceof ModelViewEntity) {
@@ -224,24 +227,24 @@
                 throw new GenericModelException("The join-style " + datasourceInfo.joinStyle + " is not yet supported");
             }
         } else {
-            sql.append(modelEntity.getTableName(datasourceInfo));
+            sql.append(((ModelEntity) modelEntity).getTableName(datasourceInfo));
         }
         return sql.toString();
     }
 
     /** Makes a WHERE clause String with "<col name>=?" if not null or "<col name> IS null" if null, all AND separated */
-    public static String makeWhereStringFromFields(List modelFields, Map<String, Object> fields, String operator) {
+    public static String makeWhereStringFromFields(List<Object> modelFields, Map<String, Object> fields, String operator) {
         return makeWhereStringFromFields(modelFields, fields, operator, null);
     }
 
     /** Makes a WHERE clause String with "<col name>=?" if not null or "<col name> IS null" if null, all AND separated */
-    public static String makeWhereStringFromFields(List modelFields, Map<String, Object> fields, String operator, List<EntityConditionParam> entityConditionParams) {
+    public static String makeWhereStringFromFields(List<Object> modelFields, Map<String, Object> fields, String operator, List<EntityConditionParam> entityConditionParams) {
         if (modelFields.size() < 1) {
             return "";
         }
 
         StringBuilder returnString = new StringBuilder();
-        Iterator iter = modelFields.iterator();
+        Iterator<Object> iter = modelFields.iterator();
         while (iter.hasNext()) {
             Object item = iter.next();
             Object name = null;
@@ -256,7 +259,7 @@
             }
 
             Object fieldValue = fields.get(name);
-            if (fieldValue != null && fieldValue != GenericEntity.NULL_FIELD) {
+            if (fieldValue != null && fieldValue != GenericEntityImpl.NULL_FIELD) {
                 returnString.append('=');
                 addValue(returnString, modelField, fieldValue, entityConditionParams);
             } else {
@@ -273,7 +276,7 @@
         return returnString.toString();
     }
 
-    public static String makeWhereClause(ModelEntity modelEntity, List modelFields, Map<String, Object> fields, String operator, String joinStyle) throws GenericEntityException {
+    public static String makeWhereClause(ModelEntity modelEntity, List<Object> modelFields, Map<String, Object> fields, String operator, String joinStyle) throws GenericEntityException {
         StringBuilder whereString = new StringBuilder("");
 
         if (UtilValidate.isNotEmpty(modelFields)) {
@@ -299,7 +302,7 @@
         return "";
     }
 
-    public static String makeViewWhereClause(ModelEntity modelEntity, String joinStyle) throws GenericEntityException {
+    public static String makeViewWhereClause(ModelEntityInterface modelEntity, String joinStyle) throws GenericEntityException {
         if (modelEntity instanceof ModelViewEntity) {
             StringBuilder whereString = new StringBuilder();
             ModelViewEntity modelViewEntity = (ModelViewEntity) modelEntity;
@@ -387,9 +390,9 @@
     public static String makeViewTable(ModelEntity modelEntity, DatasourceInfo datasourceInfo) throws GenericEntityException {
         if (modelEntity instanceof ModelViewEntity) {
             StringBuilder sql = new StringBuilder("(SELECT ");
-            Iterator<ModelField> fieldsIter = modelEntity.getFieldsIterator();
+            Iterator<ModelFieldInterface> fieldsIter = modelEntity.getFieldsIterator();
             if (fieldsIter.hasNext()) {
-                ModelField curField = fieldsIter.next();
+                ModelFieldInterface curField = fieldsIter.next();
                 String colname = curField.getColName();
                 sql.append(colname);
                 sql.append(" AS ");
@@ -476,9 +479,9 @@
      * @throws GenericEntityException
      */
     public static void setPkValues(SQLProcessor sqlP, ModelEntity modelEntity, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException {
-        Iterator<ModelField> pksIter = modelEntity.getPksIterator();
+        Iterator<ModelFieldInterface> pksIter = modelEntity.getPksIterator();
         while (pksIter.hasNext()) {
-            ModelField curField = pksIter.next();
+            ModelFieldInterface curField = pksIter.next();
 
             // for where clause variables only setValue if not null...
             if (entity.dangerousGetNoCheckButFast(curField) != null) {
@@ -705,13 +708,13 @@
         return null;
     }
 
-    public static void setValue(SQLProcessor sqlP, ModelField modelField, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException {
+    public static void setValue(SQLProcessor sqlP, ModelFieldInterface modelField, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException {
         Object fieldValue = entity.dangerousGetNoCheckButFast(modelField);
 
         setValue(sqlP, modelField, entity.getEntityName(), fieldValue, modelFieldTypeReader);
     }
 
-    public static void setValue(SQLProcessor sqlP, ModelField modelField, String entityName, Object fieldValue, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException {
+    public static void setValue(SQLProcessor sqlP, ModelFieldInterface modelField, String entityName, Object fieldValue, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException {
         ModelFieldType mft = modelFieldTypeReader.getModelFieldType(modelField.getType());
 
         if (mft == null) {
@@ -720,7 +723,7 @@
         }
 
         // if the value is the GenericEntity.NullField, treat as null
-        if (fieldValue == GenericEntity.NULL_FIELD) {
+        if (fieldValue == GenericEntityImpl.NULL_FIELD) {
             fieldValue = null;
         }
 

Added: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java?rev=795024&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java (added)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java Fri Jul 17 09:56:47 2009
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.entity.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.ofbiz.context.entity.DynamicViewEntityInterface;
+import org.ofbiz.context.entity.GenericDelegator;
+import org.ofbiz.context.entity.ModelKeyMapInterface;
+import org.ofbiz.entity.GenericDelegatorImpl;
+import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasMember;
+import org.ofbiz.entity.model.ModelViewEntity.ModelAlias;
+import org.ofbiz.entity.model.ModelViewEntity.ModelAliasAll;
+import org.ofbiz.entity.model.ModelViewEntity.ModelMemberEntity;
+import org.ofbiz.entity.model.ModelViewEntity.ModelViewLink;
+/**
+ * This class is used for declaring Dynamic View Entities, to be used and thrown away.
+ * A special method exists on the GenericDelegator to accept a DynamicViewEntity instead
+ * of an entity-name.
+ *
+ */
+public class DynamicViewEntity implements DynamicViewEntityInterface {
+    public static final String module = DynamicViewEntity.class.getName();
+
+    /** The entity-name of the Entity */
+    protected String entityName = "DynamicViewEntity";
+
+    /** The package-name of the Entity */
+    protected String packageName = "org.ofbiz.dynamicview";
+
+    /** The default-resource-name of the Entity, used with the getResource call to check for a value in a resource bundle */
+    protected String defaultResourceName = "";
+
+    /** The title for documentation purposes */
+    protected String title = "";
+
+    /** Contains member-entity alias name definitions: key is alias, value is ModelMemberEntity */
+    protected Map<String, ModelMemberEntity> memberModelMemberEntities = new HashMap<String, ModelMemberEntity>();
+
+    /** List of alias-alls which act as a shortcut for easily pulling over member entity fields */
+    protected List<ModelAliasAll> aliasAlls = new ArrayList<ModelAliasAll>();
+
+    /** List of aliases with information in addition to what is in the standard field list */
+    protected List<ModelAlias> aliases = new ArrayList<ModelAlias>();
+
+    /** List of view links to define how entities are connected (or "joined") */
+    protected List<ModelViewLink> viewLinks = new ArrayList<ModelViewLink>();
+
+    /** relations defining relationships between this entity and other entities */
+    protected List<ModelRelation> relations = new ArrayList<ModelRelation>();
+
+    public DynamicViewEntity() {
+    }
+
+    public ModelViewEntity makeModelViewEntity(GenericDelegator delegator) {
+        ModelViewEntity modelViewEntity = new ModelViewEntity(this, ((GenericDelegatorImpl) delegator).getModelReader());
+        return modelViewEntity;
+    }
+
+    public String getOneRealEntityName() {
+        // return first entity name for memberModelMemberEntities Map
+        if (this.memberModelMemberEntities.size() == 0) {
+            return null;
+        }
+
+        ModelMemberEntity modelMemberEntity = this.memberModelMemberEntities.entrySet().iterator().next().getValue();
+        return modelMemberEntity.getEntityName();
+    }
+
+    /** Getter for property entityName.
+     * @return Value of property entityName.
+     *
+     */
+    public String getEntityName() {
+        return entityName;
+    }
+
+    /** Setter for property entityName.
+     * @param entityName New value of property entityName.
+     *
+     */
+    public void setEntityName(String entityName) {
+        this.entityName = entityName;
+    }
+
+    /** Getter for property packageName.
+     * @return Value of property packageName.
+     *
+     */
+    public String getPackageName() {
+        return packageName;
+    }
+
+    /** Setter for property packageName.
+     * @param packageName New value of property packageName.
+     *
+     */
+    public void setPackageName(String packageName) {
+        this.packageName = packageName;
+    }
+
+    /** Getter for property defaultResourceName.
+     * @return Value of property defaultResourceName.
+     *
+     */
+    public String getDefaultResourceName() {
+        return defaultResourceName;
+    }
+
+    /** Setter for property defaultResourceName.
+     * @param defaultResourceName New value of property defaultResourceName.
+     *
+     */
+    public void setDefaultResourceName(String defaultResourceName) {
+        this.defaultResourceName = defaultResourceName;
+    }
+
+    /** Getter for property title.
+     * @return Value of property title.
+     *
+     */
+    public String getTitle() {
+        return title;
+    }
+
+    /** Setter for property title.
+     * @param title New value of property title.
+     *
+     */
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public void addMemberEntity(String entityAlias, String entityName) {
+        ModelMemberEntity modelMemberEntity = new ModelMemberEntity(entityAlias, entityName);
+        this.memberModelMemberEntities.put(entityAlias, modelMemberEntity);
+    }
+
+    public Iterator<Map.Entry<String, ModelMemberEntity>> getModelMemberEntitiesEntryIter() {
+        return this.memberModelMemberEntities.entrySet().iterator();
+    }
+
+    public void addAliasAll(String entityAlias, String prefix) {
+        ModelAliasAll aliasAll = new ModelAliasAll(entityAlias, prefix);
+        this.aliasAlls.add(aliasAll);
+    }
+
+    public void addAllAliasAllsToList(List<ModelAliasAll> addList) {
+        addList.addAll(this.aliasAlls);
+    }
+
+    public void addAlias(String entityAlias, String name) {
+        this.addAlias(entityAlias, name, null, null, null, null, null);
+    }
+
+    /** Add an alias, full detail. All parameters can be null except entityAlias and name. */
+    public void addAlias(String entityAlias, String name, String field, String colAlias, Boolean primKey, Boolean groupBy, String function) {
+        addAlias(entityAlias, name, field, colAlias, primKey, groupBy, function, null);
+    }
+
+    public void addAlias(String entityAlias, String name, String field, String colAlias, Boolean primKey, Boolean groupBy, String function, ComplexAliasMember complexAliasMember) {
+        if (entityAlias == null && complexAliasMember == null) {
+            throw new IllegalArgumentException("entityAlias cannot be null if this is not a complex alias in call to DynamicViewEntity.addAlias");
+        }
+        if (name == null) {
+            throw new IllegalArgumentException("name cannot be null in call to DynamicViewEntity.addAlias");
+        }
+
+        ModelAlias alias = new ModelAlias(entityAlias, name, field, colAlias, primKey, groupBy, function);
+        if (complexAliasMember != null) {
+            alias.setComplexAliasMember(complexAliasMember);
+        }
+        this.aliases.add(alias);
+    }
+
+    public void addAllAliasesToList(List<ModelAlias> addList) {
+        addList.addAll(this.aliases);
+    }
+
+    public void addViewLink(String entityAlias, String relEntityAlias, Boolean relOptional, List<ModelKeyMapInterface> modelKeyMaps) {
+        ModelViewLink modelViewLink = new ModelViewLink(entityAlias, relEntityAlias, relOptional, (List) modelKeyMaps);
+        this.viewLinks.add(modelViewLink);
+    }
+
+    public void addAllViewLinksToList(List<ModelViewLink> addList) {
+        addList.addAll(this.viewLinks);
+    }
+
+    public void addRelation(String type, String title, String relEntityName, List<ModelKeyMapInterface> modelKeyMaps) {
+        ModelRelation relation = new ModelRelation(type, title, relEntityName, null, (List) modelKeyMaps);
+        this.relations.add(relation);
+    }
+
+    public void addAllRelationsToList(List<ModelRelation> addList) {
+        addList.addAll(this.relations);
+    }
+}

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java Fri Jul 17 09:56:47 2009
@@ -19,7 +19,6 @@
 package org.ofbiz.entity.model;
 
 import java.io.PrintWriter;
-import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -41,10 +40,16 @@
 import org.ofbiz.base.util.UtilTimer;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
-import org.ofbiz.entity.GenericDelegator;
-import org.ofbiz.entity.GenericEntity;
-import org.ofbiz.entity.GenericEntityException;
-import org.ofbiz.entity.GenericValue;
+import org.ofbiz.context.entity.GenericDelegator;
+import org.ofbiz.context.entity.GenericEntity;
+import org.ofbiz.context.entity.GenericEntityException;
+import org.ofbiz.context.entity.ModelEntityInterface;
+import org.ofbiz.context.entity.ModelFieldInterface;
+import org.ofbiz.context.entity.ModelKeyMapInterface;
+import org.ofbiz.context.entity.ModelRelationInterface;
+import org.ofbiz.entity.GenericDelegatorImpl;
+import org.ofbiz.entity.GenericEntityImpl;
+import org.ofbiz.entity.GenericValueImpl;
 import org.ofbiz.entity.config.DatasourceInfo;
 import org.ofbiz.entity.config.EntityConfigUtil;
 import org.ofbiz.entity.jdbc.DatabaseUtil;
@@ -56,7 +61,7 @@
  *
  */
 @SuppressWarnings("serial")
-public class ModelEntity extends ModelInfo implements Comparable<ModelEntity>, Serializable {
+public class ModelEntity extends ModelInfo implements ModelEntityInterface {
 
     public static final String module = ModelEntity.class.getName();
 
@@ -276,9 +281,9 @@
     }
 
     public boolean containsAllPkFieldNames(Set<String> fieldNames) {
-        Iterator<ModelField> pksIter = this.getPksIterator();
+        Iterator<ModelFieldInterface> pksIter = this.getPksIterator();
         while (pksIter.hasNext()) {
-            ModelField pkField = pksIter.next();
+            ModelFieldInterface pkField = pksIter.next();
             if (!fieldNames.contains(pkField.getName())) {
                 return false;
             }
@@ -467,15 +472,7 @@
         return this.pks.size();
     }
 
-    /**
-     * @deprecated
-     */
-    @Deprecated
-    public ModelField getPk(int index) {
-        return this.pks.get(index);
-    }
-
-    public ModelField getOnlyPk() {
+    public ModelFieldInterface getOnlyPk() {
         if (this.pks.size() == 1) {
             return this.pks.get(0);
         } else {
@@ -483,22 +480,16 @@
         }
     }
 
-    public Iterator<ModelField> getPksIterator() {
-        return this.pks.iterator();
-    }
-
-    /**
-     * @deprecated Use getPkFieldsUnmodifiable instead.
-     */
-    @Deprecated
-    public List<ModelField> getPksCopy() {
-        List<ModelField> newList = FastList.newInstance();
-        newList.addAll(this.pks);
-        return newList;
+    public Iterator<ModelFieldInterface> getPksIterator() {
+        List<ModelFieldInterface> mfList = FastList.newInstance();
+        mfList.addAll(this.pks);
+        return mfList.iterator();
     }
 
-    public List<ModelField> getPkFieldsUnmodifiable() {
-        return Collections.unmodifiableList(this.pks);
+    public List<ModelFieldInterface> getPkFieldsUnmodifiable() {
+        List<ModelFieldInterface> mfList = FastList.newInstance();
+        mfList.addAll(this.pks);
+        return Collections.unmodifiableList(mfList);
     }
 
     public String getFirstPkFieldName() {
@@ -514,20 +505,14 @@
         return this.nopks.size();
     }
 
-    /**
-     * @deprecated
-     */
-    @Deprecated
-    public ModelField getNopk(int index) {
-        return this.nopks.get(index);
-    }
-
-    public Iterator<ModelField> getNopksIterator() {
-        return this.nopks.iterator();
+    public Iterator<ModelFieldInterface> getNopksIterator() {
+        List<ModelFieldInterface> mfList = FastList.newInstance();
+        mfList.addAll(this.nopks);
+        return mfList.iterator();
     }
 
-    public List<ModelField> getNopksCopy() {
-        List<ModelField> newList = FastList.newInstance();
+    public List<ModelFieldInterface> getNopksCopy() {
+        List<ModelFieldInterface> newList = FastList.newInstance();
         newList.addAll(this.nopks);
         return newList;
     }
@@ -536,30 +521,16 @@
         return this.fields.size();
     }
 
-    /**
-     * @deprecated
-     */
-    @Deprecated
-    public ModelField getField(int index) {
-        return this.fields.get(index);
-    }
-
-    public Iterator<ModelField> getFieldsIterator() {
-        return this.fields.iterator();
-    }
-
-    /**
-     * @deprecated Use getFieldsUnmodifiable instead.
-     */
-    @Deprecated
-    public List<ModelField> getFieldsCopy() {
-        List<ModelField> newList = FastList.newInstance();
-        newList.addAll(this.fields);
-        return newList;
+    public Iterator<ModelFieldInterface> getFieldsIterator() {
+        List<ModelFieldInterface> mfList = FastList.newInstance();
+        mfList.addAll(this.fields);
+        return mfList.iterator();
     }
 
-    public List<ModelField> getFieldsUnmodifiable() {
-        return Collections.unmodifiableList(this.fields);
+    public List<ModelFieldInterface> getFieldsUnmodifiable() {
+        List<ModelFieldInterface> mfList = FastList.newInstance();
+        mfList.addAll(this.fields);
+        return Collections.unmodifiableList(mfList);
     }
 
     /** The col-name of the Field, the alias of the field if this is on a view-entity */
@@ -672,9 +643,9 @@
 
     public int getRelationsOneSize() {
         int numRels = 0;
-        Iterator<ModelRelation> relationsIter = this.getRelationsIterator();
+        Iterator<ModelRelationInterface> relationsIter = this.getRelationsIterator();
         while (relationsIter.hasNext()) {
-            ModelRelation modelRelation = relationsIter.next();
+            ModelRelationInterface modelRelation = relationsIter.next();
             if ("one".equals(modelRelation.getType())) {
                 numRels++;
             }
@@ -686,15 +657,17 @@
         return this.relations.get(index);
     }
 
-    public Iterator<ModelRelation> getRelationsIterator() {
-        return this.relations.iterator();
+    public Iterator<ModelRelationInterface> getRelationsIterator() {
+        List<ModelRelationInterface> mrList = FastList.newInstance();
+        mrList.addAll(this.relations);
+        return mrList.iterator();
     }
 
-    public List<ModelRelation> getRelationsList(boolean includeOne, boolean includeOneNoFk, boolean includeMany) {
-        List<ModelRelation> relationsList = FastList.newInstance();
-        Iterator<ModelRelation> allIter = this.getRelationsIterator();
+    public List<ModelRelationInterface> getRelationsList(boolean includeOne, boolean includeOneNoFk, boolean includeMany) {
+        List<ModelRelationInterface> relationsList = FastList.newInstance();
+        Iterator<ModelRelationInterface> allIter = this.getRelationsIterator();
         while (allIter.hasNext()) {
-            ModelRelation modelRelation = allIter.next();
+            ModelRelationInterface modelRelation = allIter.next();
             if (includeOne && "one".equals(modelRelation.getType())) {
                 relationsList.add(modelRelation);
             } else if (includeOneNoFk && "one-nofk".equals(modelRelation.getType())) {
@@ -706,11 +679,11 @@
         return relationsList;
     }
 
-    public List<ModelRelation> getRelationsOneList() {
+    public List<ModelRelationInterface> getRelationsOneList() {
         return getRelationsList(true, true, false);
     }
 
-    public List<ModelRelation> getRelationsManyList() {
+    public List<ModelRelationInterface> getRelationsManyList() {
         return getRelationsList(false, false, true);
     }
 
@@ -777,7 +750,7 @@
     }
 
     public List<? extends Map<String, Object>> convertToViewValues(String viewEntityName, GenericEntity entity) {
-        if (entity == null || entity == GenericEntity.NULL_ENTITY || entity == GenericValue.NULL_VALUE) return UtilMisc.toList(entity);
+        if (entity == null || entity == GenericEntityImpl.NULL_ENTITY || entity == GenericValueImpl.NULL_VALUE) return UtilMisc.toList(entity);
         ModelViewEntity view = this.viewEntities.get(viewEntityName);
         return view.convert(getEntityName(), entity);
     }
@@ -1259,16 +1232,16 @@
     }
 
     public void convertFieldMapInPlace(Map<String, Object> inContext, GenericDelegator delegator) {
-        convertFieldMapInPlace(inContext, delegator.getModelFieldTypeReader(this));
+        convertFieldMapInPlace(inContext, ((GenericDelegatorImpl) delegator).getModelFieldTypeReader(this));
     }
     public void convertFieldMapInPlace(Map<String, Object> inContext, ModelFieldTypeReader modelFieldTypeReader) {
-        Iterator<ModelField> modelFields = this.getFieldsIterator();
+        Iterator<ModelFieldInterface> modelFields = this.getFieldsIterator();
         while (modelFields.hasNext()) {
-            ModelField modelField = modelFields.next();
+            ModelFieldInterface modelField = modelFields.next();
             String fieldName = modelField.getName();
             Object oldValue = inContext.get(fieldName);
             if (oldValue != null) {
-                inContext.put(fieldName, this.convertFieldValue(modelField, oldValue, modelFieldTypeReader, inContext));
+                inContext.put(fieldName, this.convertFieldValue((ModelField) modelField, oldValue, modelFieldTypeReader, inContext));
             }
         }
     }
@@ -1283,12 +1256,12 @@
     }
 
     public Object convertFieldValue(ModelField modelField, Object value, GenericDelegator delegator) {
-        if (value == null || value == GenericEntity.NULL_FIELD) {
+        if (value == null || value == GenericEntityImpl.NULL_FIELD) {
             return null;
         }
         String fieldJavaType = null;
         try {
-            fieldJavaType = delegator.getEntityFieldType(this, modelField.getType()).getJavaType();
+            fieldJavaType = ((GenericDelegatorImpl) delegator).getEntityFieldType(this, modelField.getType()).getJavaType();
         } catch (GenericEntityException e) {
             String errMsg = "Could not convert field value: could not find Java type for the field: [" + modelField.getName() + "] on the [" + this.getEntityName() + "] entity: " + e.toString();
             Debug.logError(e, errMsg, module);
@@ -1309,7 +1282,7 @@
      * @return the converted value
      */
     public Object convertFieldValue(ModelField modelField, Object value, GenericDelegator delegator, Map<String, ? extends Object> context) {
-        ModelFieldTypeReader modelFieldTypeReader = delegator.getModelFieldTypeReader(this);
+        ModelFieldTypeReader modelFieldTypeReader = ((GenericDelegatorImpl) delegator).getModelFieldTypeReader(this);
         return this.convertFieldValue(modelField, value, modelFieldTypeReader, context);
     }
     /** Convert a field value from one Java data type to another. This is the preferred method -
@@ -1318,7 +1291,7 @@
      * @return the converted value
      */
     public Object convertFieldValue(ModelField modelField, Object value, ModelFieldTypeReader modelFieldTypeReader, Map<String, ? extends Object> context) {
-        if (value == null || value == GenericEntity.NULL_FIELD) {
+        if (value == null || value == GenericEntityImpl.NULL_FIELD) {
             return null;
         }
         String fieldJavaType = modelFieldTypeReader.getModelFieldType(modelField.getType()).getJavaType();
@@ -1414,36 +1387,35 @@
         }
 
         // append field elements
-        Iterator<ModelField> fieldIter = this.getFieldsIterator();
+        Iterator<ModelFieldInterface> fieldIter = this.getFieldsIterator();
         while (fieldIter != null && fieldIter.hasNext()) {
-            ModelField field = fieldIter.next();
+            ModelFieldInterface field = fieldIter.next();
             if (!field.getIsAutoCreatedInternal()) {
                 root.appendChild(field.toXmlElement(document));
             }
         }
 
         // append PK elements
-        Iterator<ModelField> pkIter = this.getPksIterator();
+        Iterator<ModelFieldInterface> pkIter = this.getPksIterator();
         while (pkIter != null && pkIter.hasNext()) {
-            ModelField pk = pkIter.next();
+            ModelFieldInterface pk = pkIter.next();
             Element pkey = document.createElement("prim-key");
             pkey.setAttribute("field", pk.getName());
             root.appendChild(pkey);
         }
 
         // append relation elements
-        Iterator relIter = this.getRelationsIterator();
+        Iterator<ModelRelationInterface> relIter = this.getRelationsIterator();
         while (relIter != null && relIter.hasNext()) {
             ModelRelation rel = (ModelRelation) relIter.next();
-
+            root.appendChild(rel.toXmlElement(document));
         }
 
         // append index elements
-        Iterator idxIter = this.getIndexesIterator();
+        Iterator<ModelIndex> idxIter = this.getIndexesIterator();
         while (idxIter != null && idxIter.hasNext()) {
             ModelIndex idx = (ModelIndex) idxIter.next();
             root.appendChild(idx.toXmlElement(document));
-
         }
 
         return root;
@@ -1573,7 +1545,7 @@
 
                 List<Map<String, Object>> joinsMapList = FastList.newInstance();
                 relationshipMap.put("joins", joinsMapList);
-                for (ModelKeyMap keyMap: relationship.getKeyMapsClone()) {
+                for (ModelKeyMapInterface keyMap: relationship.getKeyMapsClone()) {
                     Map<String, Object> joinsMap = FastMap.newInstance();
                     joinsMapList.add(joinsMap);
 

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelEntityChecker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelEntityChecker.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelEntityChecker.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelEntityChecker.java Fri Jul 17 09:56:47 2009
@@ -28,8 +28,8 @@
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.entity.GenericDelegator;
-import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.context.entity.GenericDelegator;
+import org.ofbiz.context.entity.GenericEntityException;
 
 /**
  * Generic Entity - Entity Definition Checker

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelField.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelField.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelField.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelField.java Fri Jul 17 09:56:47 2009
@@ -23,12 +23,14 @@
 
 import org.ofbiz.entity.jdbc.*;
 import org.ofbiz.base.util.*;
+import org.ofbiz.context.entity.ModelFieldInterface;
 
 /**
  * Generic Entity - Field model class
  *
  */
-public class ModelField extends ModelChild {
+@SuppressWarnings("serial")
+public class ModelField extends ModelChild implements ModelFieldInterface {
 
     /** The name of the Field */
     protected String name = "";

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelKeyMap.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelKeyMap.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelKeyMap.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelKeyMap.java Fri Jul 17 09:56:47 2009
@@ -20,18 +20,19 @@
 
 import java.util.List;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilXml;
+import org.ofbiz.context.entity.ModelKeyMapInterface;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 
 /**
  * Generic Entity - KeyMap model class
  *
  */
-public class ModelKeyMap implements java.io.Serializable {
+@SuppressWarnings("serial")
+public class ModelKeyMap implements ModelKeyMapInterface {
 
     /** name of the field in this entity */
     protected String fieldName = "";
@@ -74,17 +75,17 @@
     }
 
     // ======= Some Convenience Oriented Factory Methods =======
-    public static List<ModelKeyMap> makeKeyMapList(String fieldName1) {
-        return UtilMisc.toList(new ModelKeyMap(fieldName1, null));
+    public static List<ModelKeyMapInterface> makeKeyMapList(String fieldName1) {
+        return UtilMisc.<ModelKeyMapInterface>toList(new ModelKeyMap(fieldName1, null));
     }
-    public static List<ModelKeyMap> makeKeyMapList(String fieldName1, String relFieldName1) {
-        return UtilMisc.toList(new ModelKeyMap(fieldName1, relFieldName1));
+    public static List<ModelKeyMapInterface> makeKeyMapList(String fieldName1, String relFieldName1) {
+        return UtilMisc.<ModelKeyMapInterface>toList(new ModelKeyMap(fieldName1, relFieldName1));
     }
-    public static List<ModelKeyMap> makeKeyMapList(String fieldName1, String relFieldName1, String fieldName2, String relFieldName2) {
-        return UtilMisc.toList(new ModelKeyMap(fieldName1, relFieldName1), new ModelKeyMap(fieldName2, relFieldName2));
+    public static List<ModelKeyMapInterface> makeKeyMapList(String fieldName1, String relFieldName1, String fieldName2, String relFieldName2) {
+        return UtilMisc.<ModelKeyMapInterface>toList(new ModelKeyMap(fieldName1, relFieldName1), new ModelKeyMap(fieldName2, relFieldName2));
     }
-    public static List<ModelKeyMap> makeKeyMapList(String fieldName1, String relFieldName1, String fieldName2, String relFieldName2, String fieldName3, String relFieldName3) {
-        return UtilMisc.toList(new ModelKeyMap(fieldName1, relFieldName1), new ModelKeyMap(fieldName2, relFieldName2), new ModelKeyMap(fieldName3, relFieldName3));
+    public static List<ModelKeyMapInterface> makeKeyMapList(String fieldName1, String relFieldName1, String fieldName2, String relFieldName2, String fieldName3, String relFieldName3) {
+        return UtilMisc.<ModelKeyMapInterface>toList(new ModelKeyMap(fieldName1, relFieldName1), new ModelKeyMap(fieldName2, relFieldName2), new ModelKeyMap(fieldName3, relFieldName3));
     }
 
     @Override

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelReader.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelReader.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelReader.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelReader.java Fri Jul 17 09:56:47 2009
@@ -39,8 +39,8 @@
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.base.util.cache.UtilCache;
+import org.ofbiz.context.entity.GenericEntityException;
 import org.ofbiz.entity.GenericEntityConfException;
-import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericModelException;
 import org.ofbiz.entity.config.DelegatorInfo;
 import org.ofbiz.entity.config.EntityConfigUtil;
@@ -53,6 +53,7 @@
  * Generic Entity - Entity Definition Reader
  *
  */
+@SuppressWarnings("serial")
 public class ModelReader implements Serializable {
 
     public static final String module = ModelReader.class.getName();
@@ -359,10 +360,12 @@
                                                     orderedMessages.add(message);
                                                 }
                                             } else {
-                                                String message = "Existing relationship with the same name, but different specs found from what would be auto-created for Entity [" + relatedEnt.getEntityName() + "] ant relationship to entity [" +
-                                                        curModelEntity.getEntityName() + "] title [" + targetTitle + "]; would auto-create: type [" +
-                                                        newRel.getType() + "] and fields [" + newRel.keyMapString(",", "") + "]";
-                                                //Debug.logInfo(message, module);
+                                                if (Debug.infoOn()) {
+                                                    String message = "Existing relationship with the same name, but different specs found from what would be auto-created for Entity [" + relatedEnt.getEntityName() + "] ant relationship to entity [" +
+                                                    curModelEntity.getEntityName() + "] title [" + targetTitle + "]; would auto-create: type [" +
+                                                    newRel.getType() + "] and fields [" + newRel.keyMapString(",", "") + "]";
+                                                    Debug.logInfo(message, module);
+                                                }
                                             }
                                         }
                                     } else {
@@ -539,7 +542,7 @@
         if (entityName == null) {
             return null;
         }
-        Set allEntities = this.getEntityNames();
+        Set<String> allEntities = this.getEntityNames();
         while (!allEntities.contains(entityName) && entityName.length() > 0) {
             entityName = entityName.substring(1);
         }

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/model/ModelRelation.java Fri Jul 17 09:56:47 2009
@@ -29,6 +29,8 @@
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
+import org.ofbiz.context.entity.ModelKeyMapInterface;
+import org.ofbiz.context.entity.ModelRelationInterface;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -37,7 +39,8 @@
  * Generic Entity - Relation model class
  *
  */
-public class ModelRelation extends ModelChild {
+@SuppressWarnings("serial")
+public class ModelRelation extends ModelChild implements ModelRelationInterface {
 
     /** the title, gives a name/description to the relation */
     protected String title;
@@ -161,12 +164,14 @@
     }
 
     /** keyMaps defining how to lookup the relatedTable using columns from this table */
-    public Iterator<ModelKeyMap> getKeyMapsIterator() {
-        return this.keyMaps.iterator();
+    public Iterator<ModelKeyMapInterface> getKeyMapsIterator() {
+        List<ModelKeyMapInterface> kmList = FastList.newInstance();
+        kmList.addAll(this.keyMaps);
+        return kmList.iterator();
     }
 
-    public List<ModelKeyMap> getKeyMapsClone() {
-        List<ModelKeyMap> kmList = FastList.newInstance();
+    public List<ModelKeyMapInterface> getKeyMapsClone() {
+        List<ModelKeyMapInterface> kmList = FastList.newInstance();
         kmList.addAll(this.keyMaps);
         return kmList;
     }
@@ -305,9 +310,9 @@
             root.setAttribute("fk-name", this.getFkName());
         }
 
-        Iterator<ModelKeyMap> kmIter = this.getKeyMapsIterator();
+        Iterator<ModelKeyMapInterface> kmIter = this.getKeyMapsIterator();
         while (kmIter != null && kmIter.hasNext()) {
-            ModelKeyMap km = kmIter.next();
+            ModelKeyMapInterface km = kmIter.next();
             root.appendChild(km.toXmlElement(document));
         }
 

Modified: ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/transaction/GenericTransactionException.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/transaction/GenericTransactionException.java?rev=795024&r1=795023&r2=795024&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/transaction/GenericTransactionException.java (original)
+++ ofbiz/branches/executioncontext20090716/framework/entity/src/org/ofbiz/entity/transaction/GenericTransactionException.java Fri Jul 17 09:56:47 2009
@@ -18,11 +18,12 @@
  *******************************************************************************/
 package org.ofbiz.entity.transaction;
 
-import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.context.entity.GenericEntityException;
 
 /**
  * GenericTransactionException
  */
+@SuppressWarnings("serial")
 public class GenericTransactionException extends GenericEntityException {
 
     public GenericTransactionException() {