Author: doogie
Date: Thu Mar 11 18:58:13 2010 New Revision: 921989 URL: http://svn.apache.org/viewvc?rev=921989&view=rev Log: Pass the delegator into any create/init methods that end up setting any field data. Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=921989&r1=921988&r2=921989&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Thu Mar 11 18:58:13 2010 @@ -544,9 +544,7 @@ public class GenericDelegator implements if (entity == null) { throw new IllegalArgumentException("[GenericDelegator.makeValue] could not find entity for entityName: " + entityName); } - GenericValue value = GenericValue.create(entity, fields); - value.setDelegator(this); - return value; + return GenericValue.create(this, entity, fields); } /* (non-Javadoc) @@ -557,9 +555,7 @@ public class GenericDelegator implements if (entity == null) { throw new IllegalArgumentException("[GenericDelegator.makeValue] could not find entity for entityName: " + entityName); } - GenericValue value = GenericValue.create(entity, singlePkValue); - value.setDelegator(this); - return value; + return GenericValue.create(this, entity, singlePkValue); } /* (non-Javadoc) @@ -578,9 +574,9 @@ public class GenericDelegator implements throw new IllegalArgumentException("[GenericDelegator.makeValidValue] could not find entity for entityName: " + entityName); } GenericValue value = GenericValue.create(entity); + value.setDelegator(this); value.setPKFields(fields, true); value.setNonPKFields(fields, true); - value.setDelegator(this); return value; } @@ -606,10 +602,7 @@ public class GenericDelegator implements if (entity == null) { throw new IllegalArgumentException("[GenericDelegator.makePK] could not find entity for entityName: " + entityName); } - GenericPK pk = GenericPK.create(entity, fields); - - pk.setDelegator(this); - return pk; + return GenericPK.create(this, entity, fields); } /* (non-Javadoc) @@ -620,10 +613,7 @@ public class GenericDelegator implements if (entity == null) { throw new IllegalArgumentException("[GenericDelegator.makePKSingle] could not find entity for entityName: " + entityName); } - GenericPK pk = GenericPK.create(entity, singlePkValue); - - pk.setDelegator(this); - return pk; + return GenericPK.create(this, entity, singlePkValue); } /* (non-Javadoc) @@ -659,7 +649,7 @@ public class GenericDelegator implements return null; } ModelEntity entity = this.getModelReader().getModelEntity(entityName); - GenericValue genericValue = GenericValue.create(entity, fields); + GenericValue genericValue = GenericValue.create(this, entity, fields); return this.create(genericValue, true); } @@ -672,7 +662,7 @@ public class GenericDelegator implements return null; } ModelEntity entity = this.getModelReader().getModelEntity(entityName); - GenericValue genericValue = GenericValue.create(entity, singlePkValue); + GenericValue genericValue = GenericValue.create(this, entity, singlePkValue); return this.create(genericValue, true); } @@ -1374,8 +1364,7 @@ public class GenericDelegator implements } else { // don't send fields that are the same, and if no fields have changed, update nothing ModelEntity modelEntity = value.getModelEntity(); - GenericValue toStore = GenericValue.create(modelEntity, (Map<String, ? extends Object>) value.getPrimaryKey()); - toStore.setDelegator(this); + GenericValue toStore = GenericValue.create(this, modelEntity, (Map<String, ? extends Object>) value.getPrimaryKey()); boolean atLeastOneField = false; Iterator<ModelField> nonPksIter = modelEntity.getNopksIterator(); while (nonPksIter.hasNext()) { @@ -2397,9 +2386,7 @@ public class GenericDelegator implements fields.put(keyMap.getRelFieldName(), value.get(keyMap.getFieldName())); } - GenericPK dummyPK = GenericPK.create(relatedEntity, fields); - dummyPK.setDelegator(this); - return dummyPK; + return GenericPK.create(this, relatedEntity, fields); } /* (non-Javadoc) @@ -2521,8 +2508,7 @@ public class GenericDelegator implements //if never cached, then don't bother clearing if (entity.getNeverCache()) return; - GenericValue dummyValue = GenericValue.create(entity, fields); - dummyValue.setDelegator(this); + GenericValue dummyValue = GenericValue.create(this, entity, fields); this.clearCacheLineFlexible(dummyValue); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=921989&r1=921988&r2=921989&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Thu Mar 11 18:58:13 2010 @@ -121,13 +121,13 @@ public class GenericEntity extends Obser } /** Creates new GenericEntity from existing Map */ - public static GenericEntity createGenericEntity(ModelEntity modelEntity, Map<String, ? extends Object> fields) { + public static GenericEntity createGenericEntity(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fields) { if (modelEntity == null) { throw new IllegalArgumentException("Cannot create a GenericEntity with a null modelEntity parameter"); } GenericEntity newEntity = new GenericEntity(); - newEntity.init(modelEntity, fields); + newEntity.init(delegator, modelEntity, fields); return newEntity; } @@ -157,12 +157,14 @@ public class GenericEntity extends Obser } /** Creates new GenericEntity from existing Map */ - protected void init(ModelEntity modelEntity, Map<String, ? extends Object> fields) { + protected void init(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fields) { if (modelEntity == null) { throw new IllegalArgumentException("Cannot create a GenericEntity with a null modelEntity parameter"); } this.modelEntity = modelEntity; this.entityName = modelEntity.getEntityName(); + this.delegatorName = delegator.getDelegatorName(); + this.internalDelegator = delegator; setFields(fields); // check some things @@ -172,7 +174,7 @@ public class GenericEntity extends Obser } /** Creates new GenericEntity from existing Map */ - protected void init(ModelEntity modelEntity, Object singlePkValue) { + protected void init(Delegator delegator, ModelEntity modelEntity, Object singlePkValue) { if (modelEntity == null) { throw new IllegalArgumentException("Cannot create a GenericEntity with a null modelEntity parameter"); } @@ -181,6 +183,8 @@ public class GenericEntity extends Obser } this.modelEntity = modelEntity; this.entityName = modelEntity.getEntityName(); + this.delegatorName = delegator.getDelegatorName(); + this.internalDelegator = delegator; set(modelEntity.getOnlyPk().getName(), singlePkValue); // check some things @@ -816,9 +820,7 @@ public class GenericEntity extends Obser ModelField curField = iter.next(); pkNames.add(curField.getName()); } - GenericPK newPK = GenericPK.create(getModelEntity(), this.getFields(pkNames)); - newPK.setDelegator(this.getDelegator()); - return newPK; + return GenericPK.create(this.getDelegator(), getModelEntity(), this.getFields(pkNames)); } /** go through the pks and for each one see if there is an entry in fields to set */ Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java?rev=921989&r1=921988&r2=921989&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java Thu Mar 11 18:58:13 2010 @@ -47,16 +47,16 @@ public class GenericPK extends GenericEn } /** Creates new GenericPK from existing Map */ - public static GenericPK create(ModelEntity modelEntity, Map<String, ? extends Object> fields) { + public static GenericPK create(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fields) { GenericPK newPK = genericPKFactory.object(); - newPK.init(modelEntity, fields); + newPK.init(delegator, modelEntity, fields); return newPK; } /** Creates new GenericPK from existing Map */ - public static GenericPK create(ModelEntity modelEntity, Object singlePkValue) { + public static GenericPK create(Delegator delegator, ModelEntity modelEntity, Object singlePkValue) { GenericPK newPK = genericPKFactory.object(); - newPK.init(modelEntity, singlePkValue); + newPK.init(delegator, modelEntity, singlePkValue); return newPK; } @@ -72,8 +72,6 @@ public class GenericPK extends GenericEn */ @Override public Object clone() { - GenericPK newEntity = GenericPK.create(this); - newEntity.setDelegator(internalDelegator); - return newEntity; + return GenericPK.create(this); } } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java?rev=921989&r1=921988&r2=921989&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java Thu Mar 11 18:58:13 2010 @@ -77,16 +77,16 @@ public class GenericValue extends Generi } /** Creates new GenericValue from existing Map */ - public static GenericValue create(ModelEntity modelEntity, Map<String, ? extends Object> fields) { + public static GenericValue create(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fields) { GenericValue newValue = genericValueFactory.object(); - newValue.init(modelEntity, fields); + newValue.init(delegator, modelEntity, fields); return newValue; } /** Creates new GenericValue from existing Map */ - public static GenericValue create(ModelEntity modelEntity, Object singlePkValue) { + public static GenericValue create(Delegator delegator, ModelEntity modelEntity, Object singlePkValue) { GenericValue newValue = genericValueFactory.object(); - newValue.init(modelEntity, singlePkValue); + newValue.init(delegator, modelEntity, singlePkValue); return newValue; } @@ -495,9 +495,7 @@ public class GenericValue extends Generi */ @Override public Object clone() { - GenericValue newEntity = GenericValue.create(this); - newEntity.setDelegator(internalDelegator); - return newEntity; + return GenericValue.create(this); } protected static class NullGenericValue extends GenericValue implements NULL { |
Free forum by Nabble | Edit this page |