Improved: General refactoring and code improvements, package
org.apache.ofbiz.entity.finder. (OFBIZ-9953) Thanks Dennis Balkir for reporting and providing the patches. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1818474 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -96,7 +96,6 @@ public final class EntityFinderUtil {
|
||||
}
|
||||
|
||||
public static void expandFieldMapToContext(Map<FlexibleMapAccessor<Object>, Object> fieldMap, Map<String, Object> context, Map<String, Object> outContext) {
|
||||
//Debug.logInfo("fieldMap: " + fieldMap, module);
|
||||
if (fieldMap != null) {
|
||||
for (Map.Entry<FlexibleMapAccessor<Object>, Object> entry: fieldMap.entrySet()) {
|
||||
FlexibleMapAccessor<Object> serviceContextFieldAcsr = entry.getKey();
|
||||
@@ -226,7 +225,9 @@ public final class EntityFinderUtil {
|
||||
value = modelEntity.convertFieldValue(modelEntity.getField(fieldName), value, modelFieldTypeReader, context);
|
||||
}
|
||||
|
||||
if (Debug.verboseOn()) Debug.logVerbose("Got value for fieldName [" + fieldName + "]: " + value, module);
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Got value for fieldName [" + fieldName + "]: " + value, module);
|
||||
}
|
||||
|
||||
if (this.ignoreIfEmpty && ObjectType.isEmpty(value)) {
|
||||
return null;
|
||||
|
||||
@@ -39,7 +39,9 @@ public abstract class Finder implements Serializable {
|
||||
public String getEntityName() {
|
||||
String entName = this.entityNameExdr.getOriginal();
|
||||
// if there is expansion syntax
|
||||
if (entName.indexOf("${") >= 0) return null;
|
||||
if (entName.indexOf("${") >= 0) {
|
||||
return null;
|
||||
}
|
||||
return entName;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class ListFinder extends Finder {
|
||||
// process order-by
|
||||
List<? extends Element> orderByElementList = UtilXml.childElementList(element, "order-by");
|
||||
if (orderByElementList.size() > 0) {
|
||||
orderByExpanderList = new ArrayList<FlexibleStringExpander>(orderByElementList.size());
|
||||
orderByExpanderList = new ArrayList<>(orderByElementList.size());
|
||||
for (Element orderByElement: orderByElementList) {
|
||||
orderByExpanderList.add(FlexibleStringExpander.getInstance(orderByElement.getAttribute("field-name")));
|
||||
}
|
||||
@@ -132,8 +132,9 @@ public abstract class ListFinder extends Finder {
|
||||
boolean filterByDate = "true".equals(filterByDateStr);
|
||||
boolean distinct = "true".equals(distinctStr);
|
||||
int resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE;
|
||||
if ("forward".equals(resultSetTypeString))
|
||||
if ("forward".equals(resultSetTypeString)) {
|
||||
resultSetType = ResultSet.TYPE_FORWARD_ONLY;
|
||||
}
|
||||
|
||||
if (UtilValidate.isNotEmpty(delegatorName)) {
|
||||
delegator = DelegatorFactory.getDelegator(delegatorName);
|
||||
@@ -213,7 +214,7 @@ public abstract class ListFinder extends Finder {
|
||||
}
|
||||
EntityListIterator eli = delegator.find(entityName, whereEntityCondition, havingEntityCondition, fieldsToSelect, orderByFields, options);
|
||||
this.outputHandler.handleOutput(eli, context, listAcsr);
|
||||
// NOTE: the eli EntityListIterator is not closed here. It SHOULD be closed later after the returned list will be used (eg see EntityAnd.getChildren() in ModelTree.java)
|
||||
// NOTE: the eli EntityListIterator is not closed here. It SHOULD be closed later after the returned list will be used (eg see EntityAnd.getChildren() in ModelTree.java)
|
||||
} catch (GenericEntityException e) {
|
||||
String errMsg = "Failure in by " + label + " find operation, rolling back transaction";
|
||||
Debug.logError(e, errMsg, module);
|
||||
|
||||
@@ -86,8 +86,6 @@ public class PrimaryKeyFinder extends Finder {
|
||||
|
||||
GenericValue valueOut = runFind(modelEntity, context, delegator, useCacheBool, autoFieldMapBool, this.fieldMap, this.selectFieldExpanderList);
|
||||
|
||||
//Debug.logInfo("PrimaryKeyFinder: valueOut=" + valueOut, module);
|
||||
//Debug.logInfo("PrimaryKeyFinder: going into=" + this.valueNameAcsr.getOriginalName(), module);
|
||||
if (!valueNameAcsr.isEmpty()) {
|
||||
this.valueNameAcsr.put(context, valueOut);
|
||||
} else {
|
||||
@@ -122,7 +120,6 @@ public class PrimaryKeyFinder extends Finder {
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -156,7 +153,9 @@ public class PrimaryKeyFinder extends Finder {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Debug.infoOn()) Debug.logInfo("Returning null because found incomplete primary key in find: " + entityPK, module);
|
||||
if (Debug.infoOn()) {
|
||||
Debug.logInfo("Returning null because found incomplete primary key in find: " + entityPK, module);
|
||||
}
|
||||
}
|
||||
|
||||
return valueOut;
|
||||
|
||||
Reference in New Issue
Block a user