Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-9447

Improve groovy DSL : resolve automatic pk field for entity one

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Trunk
    • Fix Version/s: Upcoming Release
    • Component/s: framework
    • Labels:
      None

      Description

      Like the element entity-one on mini-lang that can resolve automatically the pk field from context, I propose like explain on the thread https://lists.apache.org/thread.html/5d2c0ac2e0e6a3a8ce13050e9b2d573e82adabbf0067428d087e48c1@%3Cdev.ofbiz.apache.org%3E to use the following syntax :

      GenericValue product = from('Product').where(context).queryOne()
      

      This issue provides two solution to extend the EntityQuery class linked to the from groovy dsl syntax

      1. OFBIZ-9447.patch
        2 kB
        Deepak Dixit
      2. OFBIZ-9447-sol2.patch
        3 kB
        Nicolas Malin
      3. OFBIZ-9447-sol1.patch
        3 kB
        Nicolas Malin

        Activity

        Hide
        taher Taher Alkhateeb added a comment -

        Nice work Nicolas. I didn't review this patch thoroughly, but at a first glance I think patch 2 seems to provide a better logic (less state).

        I note empty generics brackets -> new HashMap<>(); .. probably just a typo?

        Show
        taher Taher Alkhateeb added a comment - Nice work Nicolas. I didn't review this patch thoroughly, but at a first glance I think patch 2 seems to provide a better logic (less state). I note empty generics brackets -> new HashMap<>(); .. probably just a typo?
        Hide
        soledad Nicolas Malin added a comment -

        Ok I commit the second solutionon trunk at revision 1802660.

        for new HashMap<>();, it's intellij that autocomplete like that. I didn't know if it good or not, I found it's simple to read but no worries I correct it on my commit.

        Thanks Jacopo and Taher for the sharing

        Show
        soledad Nicolas Malin added a comment - Ok I commit the second solutionon trunk at revision 1802660. for new HashMap<>();, it's intellij that autocomplete like that. I didn't know if it good or not, I found it's simple to read but no worries I correct it on my commit. Thanks Jacopo and Taher for the sharing
        Hide
        deepak.dixit Deepak Dixit added a comment -

        java8 provide type interface for generic class instantiation,
        https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html

        {info}
        You can substitute the parameterized type of the constructor with an empty set of type parameters (<>):

        Map<String, List<String>> myMap = new HashMap<>();
        Note that to take advantage of type inference during generic class instantiation, you must use the diamond. I
        {info}
        Show
        deepak.dixit Deepak Dixit added a comment - java8 provide type interface for generic class instantiation, https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html {info} You can substitute the parameterized type of the constructor with an empty set of type parameters (<>): Map<String, List<String>> myMap = new HashMap<>(); Note that to take advantage of type inference during generic class instantiation, you must use the diamond. I {info}
        Hide
        deepak.dixit Deepak Dixit added a comment -

        Here is the patch that include code improvement only.
        Instead of iterating fileds, used GenericPk class object to get the PK fileds from parameters/fieldMap.

        Show
        deepak.dixit Deepak Dixit added a comment - Here is the patch that include code improvement only. Instead of iterating fileds, used GenericPk class object to get the PK fileds from parameters/fieldMap.
        Hide
        taher Taher Alkhateeb added a comment -

        Ahhhh, much better, +1

        Show
        taher Taher Alkhateeb added a comment - Ahhhh, much better, +1
        Hide
        soledad Nicolas Malin added a comment -

        Hey! GG Deepak!
        I committed your patch on trunk at 1802684
        Thanks a lots.
        (PS: GG is an abbreviation for Good Game for Gamer )

        Show
        soledad Nicolas Malin added a comment - Hey! GG Deepak! I committed your patch on trunk at 1802684 Thanks a lots. (PS: GG is an abbreviation for Good Game for Gamer )
        Hide
        deepak.dixit Deepak Dixit added a comment -

        Thanks Nicolas

        Show
        deepak.dixit Deepak Dixit added a comment - Thanks Nicolas

          People

          • Assignee:
            soledad Nicolas Malin
            Reporter:
            soledad Nicolas Malin
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development