Mapping Multiple EDI Segments to a Single Java Class

70 views
Skip to first unread message

Jeff Bradley

unread,
May 5, 2021, 4:59:50 PM5/5/21
to Smooks Users
Reviewing the docs and Github examples it seems that when mapping to Java classes there must be a class for every EDI segment. For instance, in the Github example, there is a HDR segment, a CUS segment, and two ORD segments. Let's say that in our domain model the HDR and CUS data are contained in a single Java class named Order. How can we map both the HDR and CUS segment to the single Order Java class?

Claude

unread,
May 6, 2021, 3:13:31 AM5/6/21
to Smooks Users
I'd have to know more about the context. Although Smooks does support mapping like to POJO-to-POJO, there might be better tools for the job. Having said that, you could checkout the Java-to-Java example.

Claude

Jeff Bradley

unread,
May 6, 2021, 9:08:02 AM5/6/21
to Smooks Users
OK, so Smooks is good for one to one mapping, ie, our domain model would have to map exactly to the incoming data. That, of course, won't work for us, since the purpose of transforming incoming data is to map it to our domain model. Changing our domain model to match the incoming data would defeat the purpose.

I have worked with multiple commercial tools in the past, including IBM's Gentran, MuleSoft's Any Point Platform, and we are currently evaluating Altova MapForce along with Smooks, but hoping for an open source solution at this point.

I looked at the java to java example, and it seems to be the same problem: one to one mappings of objects (Order is mapped to LineOrder, and OrderItem is mapped to LineItem). Given that we receive data in many formats from many sources, all which must map to our domain model, this isn't realistic. If I might make a suggestion: your examples are far to simplistic to be helpful in a real-world scenario (at least from my perspective). It would be far more helpful to use real-world examples, or at least closer to real-world. Just a suggestion.

Given what you say and the examples, I am having trouble seeing a use case for Smooks in an enterprise integration engine. It seems like we would need to have another mapping tool in addition to this, which defeats the purpose, since another tool would be able to also do what Smooks does. 

Question for the forum: is anyone using Smooks in an enterprise environment, and if so, are you using it just to translate from one data format to the other, or are you using it to map incoming data to your domain model?

Thanks.



Claude Mamo

unread,
May 6, 2021, 10:20:23 AM5/6/21
to smook...@googlegroups.com
I understand what you mean. I've worked with some of the platforms you mentioned like Anypoint. There are different philosophies about this; Smooks is not meant to be an all-in-one integration solution but rather a piece of the solution. There are better, more sophisticated tools, for mapping data to a canonical model and these tools would complement a Smooks solution (an open-source candidate could be Dozer though it still might not be sophisticated enough for your requirements). Anything missing can be easily integrated with Smooks as far as Java goes.

Where Smooks shines is when you need to break down the message down into fragments, possibly in different formats, and route these fragments to any number of endpoints. Another great use case is proxying (e.g., as part of a cross-domain-solution). Indeed, platforms such as Anypoint also support these use cases but you be the judge of how well they support them compared to Smooks.

If I might make a suggestion: your examples are far to simplistic to be helpful in a real-world scenario (at least from my perspective). It would be far more helpful to use real-world examples, or at least closer to real-world. Just a suggestion.

We'll review the examples. Could you open a ticket? Perhaps we can combine Smooks with an open-source mapper like Dozer in one of the examples, or even better, offer a cartridge that readily integrates Dozer with Smooks.

Claude

--
You received this message because you are subscribed to a topic in the Google Groups "Smooks Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/smooks-user/9IbJeU6s11s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to smooks-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smooks-user/c0f20061-773f-48fb-8171-af114008d8een%40googlegroups.com.

Jeff Bradley

unread,
May 6, 2021, 10:49:21 AM5/6/21
to Smooks Users
Good points. Thank you for your help. I will open a ticket (also, some of the unit tests in the github examples do not pass, I'll open a ticket for that as well).
Reply all
Reply to author
Forward
0 new messages