Quantcast
Channel: SCN : Document List - Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 571

DeepFCCBean - The better FCC at meeting your deep (structure) needs! (Part 2 - Flat File to Deep XML)

$
0
0

Update 22 Jan 2016: New parameters missingLastFields and additionalLastFields to handle structure deviations between configured parameters and actual file content.

Update 26 May 2015: New parameter genericRecordType to cater for records with no key field value as shown in scenario 3. Previous scenario 3 renamed to Scenario 4.

Update 25 Mar 2015: DeepFCCBean has been refactored to be part of FormatConversionBean. Parameter conversionType replaced with converterClass. Note that some of the screenshots are not updated to reflect the new parameter converterClass.

Update 17 Mar 2015: Parameter indentXML replaced by indentFactor.

 

Introduction

This is the second part of the two-part series on achieving file content conversion (FCC) for deep structure with a reusable custom adapter module. The first part covered the conversion of deep XML to flat file at a receiver channel.

 

This second part will focus on conversion of flat file to deep XML at a sender channel.

 

 

Source Code

Refer to following blog on location of source code and/or EAR deployment file.

FormatConversionBean - One Bean to rule them all!

 

 

Prerequisite

  • Each substructure type must contain a field containing the key value to enable the parser to identify lines of this substructure type
  • Each substructure type must belong to one and only one parent substructure type. The parent can be either the root element or other substructure types defined

 

 

Usage of Module in Communication Channel

Module Processing Sequence

NumberModule NameTypeModule Key

<Depending on position of module in chain>

1) Asynchronous scenario,

Normally before the last module in channels

2) Synchronous scenario,

Before last module to convert request payload

After last module to convert response payload

Custom_AF_Modules/FormatConversionBeanLocal Enterprise Bean<Any Arbitrary Value>

 

 

Module Parameter Reference

Below are the parameters for configuration of the module for flat file to deep XML conversion (converterClass = 'com.equalize.xpi.af.modules.deepfcc.DeepPlain2XMLConverter'). Certain parameters will automatically inherit the default values if it is not configured.

 

The parameters are separated into parameters that are common for this conversion type, and also parameters that are specific for field separator based or fixed length based conversion.

 

1) Common Parameters

 

Parameter NameAllowed valuesDefault valueRemarks
conversionTypeDeepPlain2XMLRequired field. Determines conversion type
converterClasscom.equalize.xpi.af.modules.deepfcc.DeepPlain2XMLConverterRequired field. Determines conversion class
encodingUTF-8Defines encoding of output plain text file
documentNameRequired field. Document name of root element of XML output
documentNamespaceRequired field. Namespace of root element of XML output
recordsetStructureRequired field. List of substructure names separated by comma
genericRecordTypeName of substructure used as generic type. If configured, any lines that cannot be determined via key field determination will be treated as this generic type.
keyFieldNameRequired field. Name of the key field that must occur in all substructures
indentXMLY, NNDetermines if XML output will be indented or not
indentFactorInteger values beginning from 10Determines the number of indentation spaces for each level in the XML output
rowOffsetInteger values beginning from 10Starting row to begin extracting content from (i.e. 0 = start from first row, 1 = start from second row)
trimContentsY, NYDetermines if all the leading and subsequent blanks for a field will be trimmed or not
<StructureName>.fieldNamesRequired field. Names of fields in this substructure
<StructureName>.keyFieldValueRequired field. Key field value to identify this substructure
<StructureName>.parent

Required field. Specifies the parent of this substructure. Value should correspond to a substructure in recordsetStructure or the value 'Root' to indicate that it belongs directly under the root element

<StructureName>.missingLastFieldsignore,add,errorignoreBehavior of conversion when there are less fields in content compared to configured fields in <StructureName>.fieldNames
  • ignore = missing fields not included in output
  • add = missing fields included with blank value in output
  • error = conversion terminated with error due to incomplete input
<StructureName>.additionalLastFieldsignore,errorignoreBehavior of conversion when there are more fields in content compared to configured fields in <StructureName>.fieldNames
  • ignore = additional fields not included in output
  • error = conversion terminated with error due to extraneous input
debug

Displays audit log messages of substructure and parent-child determination of each line.

WARNING: Use this only for debugging in non-productive systems

messageLog

pre, post

Saves a log version of the message that is viewable in Message Monitor
  • pre = saves payload before conversion
  • post = saves payload after conversion
logLocationName of log version when messageLog is populated. Location defaulted to value in messageLog if logLocation not populated

 

2) Field Separator Conversion Parameters

 

Parameter NameAllowed valuesDefault valueRemarks
defaultFieldSeparator

Defines a default field separator for all substructures that do not have <StructureName>.fieldSeparator explicitly configured

<StructureName>.fieldSeparatorEither <StructureName>.fieldFixedLengths or <StructureName>.fieldSeparator must be populated
<StructureName>.enclosureSignBeginSpecify a string that acts as a text delimiter. Field separators within such texts are ignored
<StructureName>.enclosureSignEndIf the text delimiters for the beginning and end of the text are different, specify the text delimiter for the end of the text here. If it is not populated, it uses value specified in <StructureName>.enclosureSignBegin
<StructureName>.enclosureSignBeginEscapeSpecify a string that replaces the text delimiter if it occurs within a text that it delimits. When the text is transferred the string is replaced by the value specified in <StructureName>.enclosureSignBegin
<StructureName>.enclosureSignEndEscapeSpecify a string that replaces the text delimiter for the end of the text if it occurs within a text that it delimits. When the text is transferred the string is replaced by the value specified in <StructureName>.enclosureSignEnd. If it is not populated, it uses value soecified in <StructureName>.enclosureSignBeginEscape
<StructureName>.enclosureConversionY, NY
  • Y = the text delimiter is to be removed and/or the escape character is to be replaced when the files are transferred
  • N = the character is to be transferred unchanged

 

3) Fixed Length Conversion Parameters

 

Parameter NameAllowed valuesDefault valueRemarks
<StructureName>.fieldFixedLengthsInteger separated by commas

Either <StructureName>.fieldFixedLengths or <StructureName>.fieldSeparator must be populated. The number of lengths must match the number of fields listed in <StructureName>.fieldNames

 

Similar to standard FCC functionality, fieldSeparator parameter supports non-printable ASCII characters as follows:

  • characters encoded as hexadecimal values in the form of '0xHH' (including quotation marks)

 

 

Example Scenarios

Here are some example scenarios of the behavior of the conversion based on different configuration options.

 

Scenario 1

3 substructures with 3 level deep structure

Field separator based conversion

Field separator - Order and Item using default comma. Delivery using tab (specified in hexadecimal)

Order uses " as enclosure sign, and "" as enclosure escape

Item uses " as enclosure sign but enclosure sign is not removed when transferred

Row offset provided to skip first line

Output XML indented

 

Module parameters

Parameter NameParameter Value
converterClasscom.equalize.xpi.af.modules.deepfcc.DeepPlain2XMLConverter
documentNameMT_DeepPlain2XML
documentNamespaceurn:equalize:com
recordsetStructureDelivery,Order,Item
keyFieldNameType
Delivery.fieldNamesType,DeliveryNo
Order.fieldNamesType,DeliveryNo,OrderNo
Item.fieldNamesType,OrderNo,ItemNo,Quantity
Delivery.keyFieldValueD
Order.keyFieldValueO
Item.keyFieldValueI
Delivery.parentRoot
Order.parentDelivery
Item.parentOrder
Delivery.fieldSeparator'0x09'
defaultFieldSeparator,
Order.enclosureSignBegin"
Order.enclosureSignBeginEscape""
Item.enclosureConversionN
Item.enclosureSignBegin"
rowOffset1
indentFactor4

 

Result

Inputin1.png
Outputout1.png

 

 

Scenario 2

4 substructures with 3 level deep structure

Fixed length based conversion

Leading and trailing whitespaces are not trimmed

Missing fields are automatically populated with blank

Output XML indented

 

Module parameters

Parameter NameParameter Value
converterClasscom.equalize.xpi.af.modules.deepfcc.DeepPlain2XMLConverter
documentNameMT_DeepPlain2XML
documentNamespaceurn:equalize:com
recordsetStructureHeader,Delivery,Order,Item
keyFieldNameType
Header.fieldNamesType,FileName
Delivery.fieldNamesType,DeliveryNo
Order.fieldNamesType,DeliveryNo,OrderNo
Item.fieldNamesType,OrderNo,ItemNo,Quantity
Header.keyFieldValueH
Delivery.keyFieldValueD
Order.keyFieldValueO
Item.keyFieldValueI
Header.parentRoot
Delivery.parentRoot
Order.parentDelivery
Item.parentOrder
Header.fieldFixedLengths5,20
Delivery.fieldFixedLengths5,10
Order.fieldFixedLengths5,10,10
Item.fieldFixedLengths5,10,10,10
trimContentsN
indentFactor4

 

Result

Inputin2.png
Outputout2.png

 

 

Scenario 3

Conversion where one and only one substructure type does not have key field to identify the type of record

Substructure Detail is configured as the generic record type

Sample test data for this scenario is from the following thread File Content Conversion - No Key Field in Detail Structure

 

Module parameters

Parameter NameParameter Value
converterClasscom.equalize.xpi.af.modules.deepfcc.DeepPlain2XMLConverter
documentNameMT_DeepPlain2XML
documentNamespaceurn:equalize:com
recordsetStructureHeader,Detail,Footer
genericRecordTypeDetail
keyFieldNameType
Header.fieldNamesType,HeaderField
Detail.fieldNamesField1,Field2,Field3,Field4,Field5
Footer.fieldNamesType,TrailerField
Header.keyFieldValueHDR
Footer.keyFieldValueTRL
Header.parentRoot
Detail.parentRoot
Footer.parentRoot
Header.fieldFixedLengths3,11
Detail.fieldSeparator,
Footer.fieldFixedLengths3,9
indentFactor2

 

Result

Input

HDRXXXYYY12345

MM8100422373,M631530008  ,1530008,031615,17

MN8100424411,M631530008  ,1530008,031615,22

XY8100422373,M631530008  ,1530008,031615,17

TRLXXZZZ4321

Outputscenario3.png

 

 

Scenario 4

Finally for the fourth scenario, we will use the same input file that was used in the XSLT approach. Actual configuration and testing screenshots are shown.

Default field separator for all substructures is used.

A log version of the message payload before conversion is saved.

 

Module configuration on an SFTP sender channel.

module.png

 

The 'plain' log version shows the flat file before conversion.

pre.png

The converted payload is sent to a receiver proxy without further mapping. As shown below, the target payload has been converted to a deeply nested XML structure.

proxy.png

 

The audit log shows the trace of steps being executed by the module.

log.png

 

 

Conclusion

With the completion of this second part for DeepFCCBean, we now have a generic, reusable and highly configurable custom adapter module that is able to handle conversion of flat file to deep XML and vice versa!


Viewing all articles
Browse latest Browse all 571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>