Changes for page Groovy Script
Last modified by Erik Bakker on 2024/09/05 13:53
From version 12.1
edited by Erik Bakker
on 2022/07/28 09:18
on 2022/07/28 09:18
Change comment:
There is no comment for this version
To version 8.1
edited by Erik Bakker
on 2022/07/26 12:49
on 2022/07/26 12:49
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - Groovy Script1 +Image Transformations - Default language
-
... ... @@ -1,1 +1,0 @@ 1 -en - Content
-
... ... @@ -1,5 +1,5 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 -In a low-codeplatformlike eMagiz, you wanttoprevent usingcustomscripting as muchaspossible. However, sometimesinpractice,youencountersituationsthatcannot berealizedwith thestandardtoolbox providedwithin the platform. Asaresult, we offer the optiontoseaGroovyscriptin thesesituations to achievethedesiredsolution.Inthismicrolearning,wewilllookatwhereyoucanuse a GroovyscriptscussthekeyconsiderationswhenimplementingaGroovyscriptwithin yourmodel.2 +In most cases, you will transform XML messages to other XML messages, or you will transform JSON or EDI messages in another of these formats. However, sometimes you want to perform an image transformation. With this image transformation you can transform images in certain formats to another format (i.e. png). This can come in handy when you want to standardize the image format before using it further downstream in your business application(s). 3 3 4 4 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]]. 5 5 ... ... @@ -9,72 +9,51 @@ 9 9 10 10 == 2. Key concepts == 11 11 12 -This microlearning focuses on groovy scripts. A groovy script is a piece ofcode writtenin thegroovylanguage that allows you to extend the platform's functionality beyond the mere useof the componentssupplied viathe flow designer.12 +This microlearning focuses on performing image transformations in eMagiz. 13 13 14 -* Groovy scripts should be viewed as an extension that can be used in fringe cases, not as a standard best practice 15 -* When a groovy script becomes so complex that you are programming, you should consider alternatives to the solution 16 -* Groovy scripts can be used in a filter, transformation, and as part of a standard executor 17 -* Groovy scripts should be well documented as they are though to read for most of our community members 18 -* There is no guarantee from eMagiz that Groovy scripts within models keep working in newer versions of the platform 14 +With image transformation, we mean transforming the raw data that represents an image to another image format. 19 19 20 -== 3. Groovy script == 16 +* Read the helptext of the component to understand which formats are supported 17 +* Ensure the input image is supplied in the correct format 18 +* Ensure you wrap the output image in something if you want to do additional transformations on the data further downstream 21 21 22 - Inalow-code platformlike eMagiz, you want to preventusing custom scriptingas much as possible. However, sometimes inpractice, you encountersituations that cannot be realized with the standard toolbox provided within the platform. Asaresult, we offer the optionto use a Groovy script in these situations to achieve the desired solution. In this microlearning, we will look at where you can use a Groovy script and discuss the key considerations when implementing a Groovy script within your model.20 +== 3. Image Transformation == 23 23 24 - ===3.1Implementation inCreate===22 +In most cases, you will transform XML messages to other XML messages, or you will transform JSON or EDI messages in another of these formats. However, sometimes you want to perform an image transformation. With this image transformation you can transform images in certain formats to another format (i.e. png). This can come in handy when you want to standardize the image format before using it further downstream in your business application(s). 25 25 26 -To implement a groovy script in Create you first need to consider what your Groovy script should do. Within the flow designer there are five components available that can handle a Groovy script. 27 - 28 -* In case you want the Groovy script to filter out messages you should implement the Groovy script in a "standard filter" component. 29 -* If you want your Groovy script to always transform your message from a certain format into another format you should consider using a "standard transformer" component. 30 -* In case you need an optional output the "standard service activator" is your friend. So for example, when you want to do some transformation and do a check whether a message can continue you can use the "standard service activator" and have an optional output. 31 -* When you want to split your message based on a Groovy script you should use the "standard splitter" 32 -* If you want to route messsages based on a Groovy script you should use the "standard router" 24 +Before we dive into the specifics of how to configure this let us first consider the following: 33 33 34 -{{warning}}Note, that in practice we mainly see use cases for the "standard service activator" and the "standard transformation".{{/warning}} 26 +* Read the helptext of the component to understand which formats are supported 27 +* Ensure the input image is supplied in the correct format 28 +* Ensure you wrap the output image in something if you want to do additional transformations on the data further downstream 35 35 36 - [[image:Main.Images.Microlearning.WebHome@expert-data-handling-groovy-script-available-components.png]]30 +{{warning}}The focus of this microlearning lies on the image transformer component. Ensuring that the input is useful and the output fits the remainder of the process is highly depending on the use case and will therefore not be discussed in this microlearning{{/warning}} 37 37 38 - Regardlessofthecomponentyou chooseyoualwaysneed toselectthe optioncalled"Groovyscript"andreferencetheGroovyresourceavailableonflowlevelthatyouwanttouse withinthecomponent.32 +When turning to the Create phase of eMagiz, we need to open the flow and enter "Start Editing" mode to add the component we need. For example, in the left panel, you can search for "Image". This will yield the following result. 39 39 40 -[[image:Main.Images.Microlearning.WebHome@expert- data-handling-groovy-script-groovy-configuration.png]]34 +[[image:Main.Images.Microlearning.WebHome@expert-create-your-transformations-image-transformation-image-transformation-component.png]] 41 41 42 -{{info}}As you can see in the help text when selecting the "resource" attribute you need to make sure that the Groovy script is uploaded within the context of your flow.{{/info}} 43 - 44 -After you have the component in such a way that the correct Groovy script is called you are done with the configuration of the component and can test the flow using flow testing. 45 - 46 -=== 3.2 Key considerations === 47 - 48 -* To make some groovy scripts work you need to upload (third-party) Java libraries that are not packaged on default by eMagiz 49 -* To make some groovy scripts work you need to reference Java libraries via a standard header enricher or as a dummy variable 50 -* The store consists of several groovy scripts that might be of use to you 51 -* Groovy scripts should be viewed as an extension that can be used in fringe cases, not as a standard best practice 52 -* When a groovy script becomes so complex that you are programming, you should consider alternatives to the solution 53 -* Groovy scripts can be used in a filter, transformation, and as part of a standard executor 54 -* Groovy scripts should be well documented as they are though to read for most of our community members 55 -* There is no guarantee from eMagiz that Groovy scripts within models keep working in newer versions of the platform 56 - 57 57 == 4. Assignment == 58 58 59 - TrytoimplementacomponentthatreferencesaGroovyscript andseewhether the flowcan be tested.60 -This assignment can be completed with the help of the(Academy) projectthatyouhavecreated/used in the previous assignment.38 +Check out which of the XPaths we have discussed today can be found within your project. 39 +This assignment can be completed within the (Academy) project you created/used in the previous assignment. 61 61 62 62 == 5. Key takeaways == 63 63 64 -* To make some groovy scripts work you need to upload (third-party) Java libraries that are not packaged on default by eMagiz 65 -* To make some groovy scripts work you need to reference Java libraries via a standard header enricher or as a dummy variable 66 -* The store consists of several groovy scripts that might be of use to you 67 -* Groovy scripts should be viewed as an extension that can be used in fringe cases, not as a standard best practice 68 -* When a groovy script becomes so complex that you are programming, you should consider alternatives to the solution 69 -* Groovy scripts can be used in a filter, transformation, and as part of a standard executor 70 -* Groovy scripts should be well documented as they are though to read for most of our community members 71 -* There is no guarantee from eMagiz that Groovy scripts within models keep working in newer versions of the platform 43 +Some of the very complex XPath options are: 72 72 45 +* matches 46 +* replace 47 +* tokenize 48 + 73 73 == 6. Suggested Additional Readings == 74 74 75 -If you are interested in this topic and want more information, please read the help text provided by eMagiz and read the following link: 76 -* https://www.tutorialspoint.com/groovy/index.htm 51 +If you are interested in this topic and want more information on it, please read the help text provided by eMagiz and read more information on the following links: 77 77 53 +* http://www.xsltfunctions.com/xsl/fn_matches.html 54 +* http://www.xsltfunctions.com/xsl/fn_replace.html 55 +* http://www.xsltfunctions.com/xsl/fn_tokenize.html 56 + 78 78 == 7. Silent demonstration video == 79 79 80 80 As this is more of theoretical microlearning, there is no video accompanying the microlearning.)))((({{toc/}}))){{/container}}{{/container}}