[
https://issues.apache.org/jira/browse/OFBIZ-9893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16494866#comment-16494866 ]
Nicolas Malin commented on OFBIZ-9893:
--------------------------------------
Hello Gareth,
I saw your patch and I have some remarks :) . I passed some time to understand the function *getFieldMap(final String keyFieldName, final String valueFieldName)* , I supposed it's to get a value hashed by an id like ["GIZMO-111": "GIZMO INTERNAL NAME"] I thinks it's nice feature the problem that I see, it return only the lastest value from a list and It surcharge the EntityQuery operation search. Maybe the name would be queryFieldMap.
I propose two improvements :
* move this function to EntityUtil because it's more closer than getFieldListFromEntityList function instead a query action
* Increase the signature like {code}Map<Object, Object> getFieldListHashedByFieldValue(List<GenericValue> genericValueList, String keyFieldName, List<String> fieldNames) {code}
We can use this like {code}
List selectedFields = ['productId', 'internalName']
Map internalNameByProductId = EntityUtil.getFieldListHashedByFieldValue(from('Product').select(selectedFields).where(parameters).queryList(), 'productId', selectedFields))
{code}
But we can also imagine to resolve directly all productId by productTypeId, this function can be analyse to cover different functional case to help the data preparation.
For the function *forEach* we can't do it already in java 8 or groovy ?
{code}EntityQuery.use(delegator).from("Product").queryList().forEach(item -> Debug.logInfo(item.toString(), module); ); {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)