[jira] [Commented] (OFBIZ-9893) New methods for EntityQuery

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

[jira] [Commented] (OFBIZ-9893) New methods for EntityQuery

Nicolas Malin (Jira)

    [ 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}


> New methods for EntityQuery
> ---------------------------
>
>                 Key: OFBIZ-9893
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-9893
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Gareth Carter
>            Priority: Minor
>         Attachments: EntityQuery.patch, ForUpdate.patch
>
>
> [See discussion on devml|http://markmail.org/message/zyzswygu6jqkg4nb]
> New methods:
> - getFieldMap
> - forEach
> - forUpdate - to be decided



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)