[ 
https://issues.apache.org/jira/browse/OFBIZ-9992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16371395#comment-16371395
 ] 

Dennis Balkir commented on OFBIZ-9992:
--------------------------------------

I did two conversions of this file,

the first is a normal conversion of the CatalogServices.xml, the second one is 
nearly the same, I just made new methods for code which repeats itself over and 
over again.

There was a little problem, I first implemented the method {{imageUrlCheck}} 
like this:

 
{noformat}
def imageUrlCheck(prodOrCat, imageType, filesImageMap) {
    if (prodOrCat."${imageType}") {
        Map res = run service: "checkImageUrl", with: [imageUrl: 
prodOrCat."${imageType}"]
        String isExists = res.isExists
        filesImageMap."${imageType}Map" = [
            "${imageType}Map": prodOrCat."${imageType}",
            isExists: isExists
        ]
        if (isExists=="N") {
            prodOrCat."${imageType}" = null
        }
    }
}{noformat}
 

This made some problems, because I put one of the keys of 
{{filesImageMap."${imageType}Map"}} in as a GString, which resulted in an 
constant null return when trying to get the value of the key.
Because of this, I changed it, so it looks like this now:
{noformat}
def imageUrlCheck(prodOrCat, imageType, filesImageMap) {
    if (prodOrCat."${imageType}") {
        Map res = run service: "checkImageUrl", with: [imageUrl: 
prodOrCat."${imageType}"]
        String isExists = res.isExists
        filesImageMap."${imageType}Map" = [:]
        filesImageMap."${imageType}Map"."${imageType}" = 
prodOrCat."${imageType}"
        filesImageMap."${imageType}Map".isExists = isExists
        if (isExists=="N") {
            prodOrCat."${imageType}" = null
        }
    }
}{noformat}
I hope there will be no confusion about this.

 

All the services in this file were tested as good as I could test them, they 
seem to work and do what they should do.
I would appreciate if one of the involved people can give me a feedback on this 
file, thanks.

 

> Convert CatalogServices.xml mini lang to groovy
> -----------------------------------------------
>
>                 Key: OFBIZ-9992
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-9992
>             Project: OFBiz
>          Issue Type: Sub-task
>          Components: framework
>    Affects Versions: Trunk
>            Reporter: Dennis Balkir
>            Priority: Minor
>         Attachments: 
> OFBIZ-9992_org.apache.ofbiz.product.catalog.CatalogServices_convert.patch, 
> OFBIZ-9992_org.apache.ofbiz.product.catalog.CatalogServices_convert_short.patch
>
>
> Migration of the CatalogServices.xml to Groovy



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

Reply via email to