|
Author: jleroux
Date: Sun Mar 31 10:27:41 2013 New Revision: 1462912 URL: http://svn.apache.org/r1462912 Log: Revert r1462902, there are 3 tests failing and I have not the time to look at it yet Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java?rev=1462912&r1=1462911&r2=1462912&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java Sun Mar 31 10:27:41 2013 @@ -18,7 +18,6 @@ */ package org.ofbiz.entity.finder; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -27,6 +26,8 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilGenerics; +import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; @@ -35,7 +36,6 @@ import org.ofbiz.entity.GenericEntityExc import org.ofbiz.entity.GenericPK; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.model.ModelEntity; -import org.ofbiz.entity.model.ModelField; import org.w3c.dom.Element; /** @@ -103,32 +103,28 @@ public class PrimaryKeyFinder extends Fi // assemble the field map Map<String, Object> entityContext = FastMap.newInstance(); if (autoFieldMap) { + GenericValue tempVal = delegator.makeValue(modelEntity.getEntityName()); + // try a map called "parameters", try it first so values from here are overridden by values in the main context Object parametersObj = context.get("parameters"); if (parametersObj != null && parametersObj instanceof Map<?, ?>) { - // only need PK fields - Iterator<ModelField> iter = modelEntity.getPksIterator(); - while (iter != null && iter.hasNext()) { - ModelField curField = iter.next(); - String fieldName = curField.getName(); - Object fieldValue = ((Map<?, ?>) parametersObj).get(fieldName); - if (context.containsKey(fieldName)) { - fieldValue = context.get(fieldName); - } - entityContext.put(fieldName, fieldValue); - } + Map<String, Object> parameters = UtilMisc.<String, Object>toMap(UtilGenerics.checkMap(parametersObj)); + // need the timeZone and locale for conversion, so add here and remove after + parameters.put("locale", context.get("locale")); + parameters.put("timeZone", context.get("timeZone")); + modelEntity.convertFieldMapInPlace(parameters, delegator); + parameters.remove("timeZone"); + parameters.remove("locale"); + tempVal.setAllFields(parameters, true, null, Boolean.TRUE); } + + // just get the primary keys, and hopefully will get all of them, if not they must be manually filled in below in the field-maps + modelEntity.convertFieldMapInPlace(context, delegator); + tempVal.setAllFields(context, true, null, Boolean.TRUE); + + entityContext.putAll(tempVal); } EntityFinderUtil.expandFieldMapToContext(fieldMap, context, entityContext); - //Debug.logInfo("PrimaryKeyFinder: entityContext=" + entityContext, module); - // then convert the types... - - // need the timeZone and locale for conversion, so add here and remove after - entityContext.put("locale", context.get("locale")); - entityContext.put("timeZone", context.get("timeZone")); - modelEntity.convertFieldMapInPlace(entityContext, delegator); - entityContext.remove("locale"); - entityContext.remove("timeZone"); // get the list of fieldsToSelect from selectFieldExpanderList Set<String> fieldsToSelect = EntityFinderUtil.makeFieldsToSelect(selectFieldExpanderList, context); @@ -165,3 +161,4 @@ public class PrimaryKeyFinder extends Fi } } } + |
| Free forum by Nabble | Edit this page |
