Page 1 of 1

Groovy & Funky

Posted: Wed Jan 16, 2019 2:37 pm
by Max Beermann
Hey Bernd,

maybe this is the wrong topic (if so > sorry), but I do not know where to put better:

I want to manipulate our common routing-behavior by using Groovy.
http://xserver.ptvgroup.com/fileadmin/f ... ght=groovy


My first aim is to avoid switzerland by using the function "EXCLUDE_COUNTRIES" :

Code: Select all

<ArrayOfRoutingOption_3>
  <ns6:RoutingOption xmlns:ns6=”http://xroute.xserver.ptvag.com” parameter=”EXCLUDE_COUNTRIES“ value=”41“ />
</ArrayOfRoutingOption_3>
Is there any chance to convert/translate the code into groovy?
Or is there any solution/example where anybody had a similar aim?

PS: I already have the folder (scripts) with the appropriate file (xroute.groovy).


Many thanks for any feedback
Max

Re: Groovy & Funky

Posted: Fri Jan 18, 2019 2:26 pm
by Bernd Welter
Hello Max,

if you apply GROOVY in this scenario each and every routing will ignore Switzerland and you can't override it via request anymore. How about changing the profiles on server side which would create a new standard behaviour but also enable you to override it?

Best regards,
Bernd

Re: Groovy & Funky

Posted: Mon Jan 21, 2019 10:51 am
by Max Beermann
Hello Bernd,

that sounds nice.
But (i think) I can not change these settings, because they have been configurated by an external service provider.
That is why I came across with Groovy.

My intended main-logic is the following:

Code: Select all

If [b]Start-Country[/b]  <> "CH" (iuCode: 41) and  [b]End-Country[/b] is <> "CH" (iuCode: 41) then 
<ArrayOfRoutingOption_3>
  <ns6:RoutingOption xmlns:ns6=”http://xroute.xserver.ptvag.com” parameter=”EXCLUDE_COUNTRIES“ value=”41“ />
</ArrayOfRoutingOption_3>
End If
Is such an if-then condition makeable on profile/server-side?

Thanks very much!
Max

Re: Groovy & Funky

Posted: Mon Jan 21, 2019 4:30 pm
by Bernd Welter
I'll forward this to Lars.
He knows Groovy much better than me.

But I still don't get the point.
Especially because Groovy would also require to reconfigure the server.

Not only would Groovy bypass the providers settings (there must be a reason for this). It is also more restrictive compared to my approach.

Furthermore the overloading of the function as described would not consider routes with more than 2 stops.

Re: Groovy & Funky

Posted: Mon Jan 21, 2019 5:14 pm
by LNM_PTV
Hi Max,

you can do such a if-else decision in a groovy script.
But you pass only coordinates into the request.

For the determination of the country codes of start and end points you need a reverse geocoding inside the script, or you have to pass that information via CallerContext.

Which way do you want to go?

Best regards,
Lars

Re: Groovy & Funky

Posted: Tue Jan 22, 2019 3:59 pm
by Max Beermann
Hey there,

first of all > thanks for your feedback.

@Bernd:
I am using a Standard-TransportManagementSystem which is based on xServer.
I do not have the permission to manipulate the code.

To achieve some individual routings (ExcludeCountries, AvoidFerries, etc.) > Groovy seems to be a good alternative(?).

@Lars: I do not really know because I do not have an actual "feeling" for Groovy.
It is new to me.
But I thing I am gonna use the reverse-geocoding. That´s what I used to do with codes I have written before.

_ _ _ _ _


At the moment > I do not know how to start/get in touch with Groovy.
I think I have to read some more instructions.

If you have any idea sometime > please let me know ;)

Best regards+Thanks
Max

Re: Groovy & Funky

Posted: Mon Jul 13, 2020 10:26 am
by Max Beermann
Hey Bernd,

I hope you all are doing fine :)
There is one topic.

On xServer1 - a Grooy-Script works really fine (for EXCLUDE_COUNTRIES).

Now I want to use xServer2.
Can I use the same Groovy-Script (maybe just adjust something here and there)?
Or do I need to solve EXCLUDE_COUNTRIES for xServer2 in a very different way?

Many Thanks!
Max

Re: Groovy & Funky

Posted: Mon Jul 13, 2020 10:31 am
by Bernd Welter
Hello Max,
the xserver 2 modules have been redesigned from scratch so the methods, signatures and parameters have changed. Nevertheless also the xroute 2 offers mechanisms that allow you to specify which countries are allowed or forbidden.
Check both the routing options and the request profile (bit tricky to find)

Bernd

Re: Groovy & Funky

Posted: Mon Jul 13, 2020 11:35 am
by Max Beermann
Hey Bernd,

thanks for your reply!
I will inform you - hopefully because I could do it on my own ;)

Best regards
Max