Smooks milyn-edisax-parser

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Smooks milyn-edisax-parser

Tsjisse Tilma
Hi,

We're using Smooks for EDI and many messages are going very well, especially
the UNOC:3 related ones.
However, while I was trying to read UNOA:1 messages, I was running into
several problems, which I managed to fix, except for just 2 minor things.
They're both in the milyn-edisax-parser-1.5.jar.

So it's about a return message like (stripping all irrelevant other
segments, which are fine):
UNB+UNOA:1+sender+recipient+110616:1134+ref'
UNH+ref+CPD102:3'
UNT+9+ref'
UNZ+1+ref'

So largely it's the same as UNOC:3, except for the UNH. In UNOC:3 the
UNH.S009.0065/0052/0054/0051 are all mandatory by the UN, BUT in the UNOA,
we are using, they are still defined in exactly the same way, but then they
are optional, and typically never filled. So, I was able to set the
URN/version to "3" instead of something like "D:09A:UN".

But then the problem of org.milyn.edisax.EDIParser gives this nasty error
around line 760:
if (throwException) {
throw new EDIParseException(edifactModel.getEdimap(),
"Segment [" + segmentCode + "],
field " + (fieldIndex + 1) + " (" + expectedField.getXmltag() + ") expected
to contain " + expectedComponents.size() +
" components.  Actually contains " +
currentFieldComponents.length +
" components.  Currently at segment number " +
segmentReader.getCurrentSegmentNumber() + ".",
expectedField, segmentReader.getCurrentSegmentNumber(),
segmentReader.getCurrentSegmentFields());
  }

I simply outcommented this exception and we can go on.

Next issue is in org.milyn.edisax.registry. AbstractMappingsRegistry
Around line53:
// First 4 components are mandatory...we use those as the lookup...
for (int i = 0; i < 4; i++) {

Since obviously, in UNOA-land we (always) only have 2, so the assumption was
never met and we get ArrayOutOfBoundsException...

So, I changed that lines into:
for (int i = 0; i < nameComponents.length; i++) {

And then it all goes well!


However, then I get a problem for standard UNOC:3 messages like in:
UNB+UNOC:3+sender+recipient+110616:1134+ref'
UNH+ref+GOVCBR:D:09A:UN:144RES'
UNT+9+ref'
UNZ+1+ref'

Since here I used the URN: D:09A:UN
Caused by: org.milyn.edisax.EDIConfigurationException: Mapping Model
'GOVCBR:D:09A:UN:144RES' not found in supplied set of Mapping model.

So then it's understandable we need to filter the first 4, but skip the 5th
"144RES". Anyone have an idea for this?

Kind regards,

Tsjisse Tilma




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: Smooks milyn-edisax-parser

Tsjisse Tilma
The solution (for me) is pretty simple, and works for all my situations:
In AbstractMappingsRegistry around line 45:
        public EdifactModel getMappingModel(String messageName,
                        Delimiters delimiters) throws
EDIConfigurationException, SAXException, IOException {
                String[] nameComponents = EDIUtils.split(messageName,
                                delimiters.getComponent(),
delimiters.getEscape());
                StringBuilder lookupNameBuilder = new StringBuilder();
                // First 4 components are mandatory...we use those as the
lookup...
                // For UNOC:3 the above is true, but for UNOA:1 there are
just 2.
                int nComponents;
                if (nameComponents.length >= 4) {
                    nComponents = 4;
                } else {
                    nComponents = nameComponents.length;
                }
               
                for (int i = 0; i < nComponents; i++) {
// rest of the code

Tsjisse Tilma


-----Oorspronkelijk bericht-----
Van: Tsjisse Tilma [mailto:[hidden email]]
Verzonden: woensdag 24 juli 2013 11:34
Aan: [hidden email]
Onderwerp: [milyn-dev] Smooks milyn-edisax-parser

Hi,

We're using Smooks for EDI and many messages are going very well, especially
the UNOC:3 related ones.
However, while I was trying to read UNOA:1 messages, I was running into
several problems, which I managed to fix, except for just 2 minor things.
They're both in the milyn-edisax-parser-1.5.jar.

So it's about a return message like (stripping all irrelevant other
segments, which are fine):
UNB+UNOA:1+sender+recipient+110616:1134+ref'
UNH+ref+CPD102:3'
UNT+9+ref'
UNZ+1+ref'

So largely it's the same as UNOC:3, except for the UNH. In UNOC:3 the
UNH.S009.0065/0052/0054/0051 are all mandatory by the UN, BUT in the UNOA,
we are using, they are still defined in exactly the same way, but then they
are optional, and typically never filled. So, I was able to set the
URN/version to "3" instead of something like "D:09A:UN".

But then the problem of org.milyn.edisax.EDIParser gives this nasty error
around line 760:
if (throwException) {
throw new EDIParseException(edifactModel.getEdimap(),
"Segment [" + segmentCode + "],
field " + (fieldIndex + 1) + " (" + expectedField.getXmltag() + ") expected
to contain " + expectedComponents.size() + " components.  Actually contains
" + currentFieldComponents.length + " components.  Currently at segment
number " +
segmentReader.getCurrentSegmentNumber() + ".", expectedField,
segmentReader.getCurrentSegmentNumber(),
segmentReader.getCurrentSegmentFields());
  }

I simply outcommented this exception and we can go on.

Next issue is in org.milyn.edisax.registry. AbstractMappingsRegistry Around
line53:
// First 4 components are mandatory...we use those as the lookup...
for (int i = 0; i < 4; i++) {

Since obviously, in UNOA-land we (always) only have 2, so the assumption was
never met and we get ArrayOutOfBoundsException...

So, I changed that lines into:
for (int i = 0; i < nameComponents.length; i++) {

And then it all goes well!


However, then I get a problem for standard UNOC:3 messages like in:
UNB+UNOC:3+sender+recipient+110616:1134+ref'
UNH+ref+GOVCBR:D:09A:UN:144RES'
UNT+9+ref'
UNZ+1+ref'

Since here I used the URN: D:09A:UN
Caused by: org.milyn.edisax.EDIConfigurationException: Mapping Model
'GOVCBR:D:09A:UN:144RES' not found in supplied set of Mapping model.

So then it's understandable we need to filter the first 4, but skip the 5th
"144RES". Anyone have an idea for this?

Kind regards,

Tsjisse Tilma




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email