Wiki source code of Filter

Last modified by Eva Torken on 2023/05/09 11:03

Show last authors
1 {{container}}{{container layoutStyle="columns"}}(((
2 In the crash course on the Platform level, we already discussed filtering in the transformation and highlighted the validating filter as that component is a standard in any flow that transforms data.
3 In this microlearning, we will take a closer look at the filter options in eMagiz while building a flow.
4
5 Should you have any questions, please contact [[academy@emagiz.com>>mailto:academy@emagiz.com]].
6
7 == 1. Prerequisites ==
8
9 * Basic knowledge of the eMagiz platform
10
11 == 2. Key concepts ==
12
13 This microlearning centers around filter options in eMagiz flows.
14 By filter we mean: The ability to determine on a **per-event** basis whether the event (i.e. message) is allowed to continue or not
15
16 == 3. Filter ==
17
18 In cases where you need to determine if a message (a piece of data) can continue or not you should use one of the filter options that eMagiz provides you.
19 eMagiz comes with three filter options:
20
21 * XML Validating Filter
22 * Standard Filter
23 * XPath Filter
24
25 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-filter--filter-options.png]]
26
27 The first option is already discussed in the Crash Course * Platform so we won't look into that option any further in this microlearning.
28
29 Below we will analyze the remaining two options to see how you can use these options to determine whether a message may continue or not
30
31 === 3.1 Standard Filter ===
32
33 The standard filter is the filter that is the most flexible and because it is the most flexible also the most complex to implement if you do not know what you are doing.
34
35 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-filter--standard-filter.png]]
36
37 With the standard filter, you have two options to determine your filter. You either use a SpEL expression.
38 A widely used example of such an implementation is the filter in the routing to control when data is allowed to travel to the offramp.
39
40 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-filter--standard-filter-filled-in-example.png]]
41
42 Or you use a Groovy script. A Groovy script is a piece of programming code that is executed for each incoming message, that can in turn use any third-party Java library.
43
44 {{warning}}This gives you a lot of flexibility but you are dependent on third-party Java libraries that are not maintained by eMagiz.
45 Therefore if they change chances are that your solution might not work anymore. In this phase of your learning, it is strongly recommended **not** use this option.{{/warning}}
46
47 In essence, this filter evaluates the SpEL expression or Groovy Script to see what the result is. If the result is true the message may continue. If not it will be dropped.
48
49 === 3.2 XPath Filter ===
50
51 The XPath filter can only be used to filter XML messages. As this filter is more narrow in scope it is also easier.
52 Think back to what we learned in the crash course * platform with regards to XPath. The same logic applies in this case.
53
54 With the help of this filter, you can filter messages based on the evaluation of an XPath expression
55
56 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-filter--xpath-filter.png]]
57
58 In this example, we want to validate that at least one Project is available in our CDM message
59
60 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-filter--cdm-structure.png]]
61
62 To do so we need to fill in the correct XPath and place the component at the correct place within the flow.
63
64 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-filter--xpath-filter-filled-in.png]]
65
66 Once again, don't forget about the namespace
67
68 == 4. Key takeaways ==
69
70 * eMagiz comes with three filter options:
71 ** XML Validating Filter
72 ** Standard Filter
73 ** XPath Filter
74 * Each option comes with a specific function
75
76 == 5. Suggested Additional Readings ==
77
78 If you are interested in this topic and want more information on it please read the help text provided by eMagiz when executing these actions and read the following links:
79
80 * [[SpEL Introduction>>https://docs.spring.io/spring-framework/docs/4.3.8.RELEASE/spring-framework-reference/html/expressions.html||target="blank"]]
81 * [[Groovy Introduction>>http://docs.groovy-lang.org/docs/groovy-2.4.15/html/documentation/||target="blank"]]
82
83
84 )))((({{toc/}}))){{/container}}{{/container}}