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

Improve groovy DSL : runService call makeValidContext

    Details

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

      Description

      When you call run service with groovy, you need to be sure that all parametes are good for the service call.

      I propose to simplify this dsl with an automatic parameters check so you can call directly like that

      run service : createProduct, with: context
      
      1. OFBIZ-9523.patch
        2 kB
        Nicolas Malin

        Activity

        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        But (for now?) the autocompletion is not as convenient as what we had with minilang, and that counts for adoption.

        Like trying to autocomplete "run service:", maybe I miss something?

        Show
        jacques.le.roux Jacques Le Roux added a comment - But (for now?) the autocompletion is not as convenient as what we had with minilang, and that counts for adoption. Like trying to autocomplete "run service:", maybe I miss something?
        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        Mmm, after reviewing the "Groovy DSL for OFBiz business logic" page and the link to GroovyBaseScript.groovy I think it's only a matter of presentation and adding some subtleties if nothing has changed since.

        Show
        jacques.le.roux Jacques Le Roux added a comment - Mmm, after reviewing the "Groovy DSL for OFBiz business logic" page and the link to GroovyBaseScript.groovy I think it's only a matter of presentation and adding some subtleties if nothing has changed since.
        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        Thanks Nicolas,

        I actually did not follow recent changes on Groovy DSL and did not know this new syntax.

        One thing which begins to worry me, if we want to switch from minilang to Groovy DSL, is the lack of API documentation in wiki, like we have for minilang. I don't think a wiki page with examples will fly... BTW what about OfbizDslDescriptorForEclipse.dsld? http://svn.apache.org/viewvc?view=revision&revision=1643183

        Show
        jacques.le.roux Jacques Le Roux added a comment - Thanks Nicolas, I actually did not follow recent changes on Groovy DSL and did not know this new syntax. One thing which begins to worry me, if we want to switch from minilang to Groovy DSL, is the lack of API documentation in wiki, like we have for minilang. I don't think a wiki page with examples will fly... BTW what about OfbizDslDescriptorForEclipse.dsld? http://svn.apache.org/viewvc?view=revision&revision=1643183
        Hide
        soledad Nicolas Malin added a comment -

        Hi Jacques,
        It's right
        If you apply this diff on the current RateService.groovy

        Index: applications/accounting/groovyScripts/rate/RateServices.groovy
        @@ -104,7 +104,7 @@
                 }
             }
             if (parameters.rateAmount) {
        -        result = run service: 'updateRateAmount', with: parameters
        +        result = run service: 'updateRateAmount', with: context
                 if (ServiceUtil.isError(result)) return result
             }
             return success()
        @@ -119,7 +119,7 @@
                 lookedUpValue.store()
         
                 //expire related rate amount
        -        result = run service: 'expireRateAmount', with: parameters
        +        result = run service: 'expireRateAmount', with: context
                 if (ServiceUtil.isError(result)) return result
             }
        

        and run

        ./gradlew 'ofbiz --test component=accounting --test suitename=ratetests '
        

        This works also.

        I will update the wiki page with example

        Show
        soledad Nicolas Malin added a comment - Hi Jacques, It's right If you apply this diff on the current RateService.groovy Index: applications/accounting/groovyScripts/rate/RateServices.groovy @@ -104,7 +104,7 @@ } } if (parameters.rateAmount) { - result = run service: 'updateRateAmount', with: parameters + result = run service: 'updateRateAmount', with: context if (ServiceUtil.isError(result)) return result } return success() @@ -119,7 +119,7 @@ lookedUpValue.store() //expire related rate amount - result = run service: 'expireRateAmount', with: parameters + result = run service: 'expireRateAmount', with: context if (ServiceUtil.isError(result)) return result } and run ./gradlew 'ofbiz --test component=accounting --test suitename=ratetests ' This works also. I will update the wiki page with example
        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        Hi Nicolas,

        I guess the right syntax is not

        run service : createProduct, with: context

        ?
        Anyway more on that later at "Groovy DSL for OFBiz business logic" wiki page...

        Show
        jacques.le.roux Jacques Le Roux added a comment - Hi Nicolas, I guess the right syntax is not run service : createProduct, with: context ? Anyway more on that later at "Groovy DSL for OFBiz business logic" wiki page...
        Hide
        soledad Nicolas Malin added a comment -

        yes nice catch,
        I commit this on trunk at 1802798

        Thanks Jacopo

        Show
        soledad Nicolas Malin added a comment - yes nice catch, I commit this on trunk at 1802798 Thanks Jacopo
        Hide
        jacopoc Jacopo Cappellato added a comment -

        Thank you Nicolas, it looks really good to me!
        One minor detail: when we call runSync we can probably reuse the local variable "dispatcher" rather then calling again binding.getVariable(...).

        Show
        jacopoc Jacopo Cappellato added a comment - Thank you Nicolas, it looks really good to me! One minor detail: when we call runSync we can probably reuse the local variable "dispatcher" rather then calling again binding.getVariable(...).

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development