Flat File Adapter
A flat file is a file that contains no information about the structure of the data. Any types of flat files can be read and parsed into a class structure using the Flat File Adapter. The structure of the flat file has to be defined in with classes and properties in the data model of your service. Any record definitions, separators and even dependencies between different records can be defined there.
For manipulating files and directories in general, have a look at the Filesystem Adapter.
General Approach
A flat file is a file that contains no information about the structure of the data. The most simple flat file is a position delimited file without header or trailing lines. More complex flat files can have a field delimiter, or can be of hierarchical structure, or can have a pattern to delimit the attributes. If you want to access such a file, you need information about the file structure, and build that structure in the data model of your Designer service.
The screenshot below shows the flat file used in the example. This file has a header line and the records are numbered.
The class diagram below shows the data structure that reflects the structure of the file. Refer to Defining a Flat File Data Structure for more information on how to build such a structure.
Flat files can be parsed to a data structure or composed from such a structure to a Blob or to the file system.
Limitations
When working with the Flat File adapter, please note the following limitations:
The size of one record within a flat file is limited to 4 MB. The size of the file itself is not limited.
Be aware, that the Flat File Adapter will parse the file all in once. If you need to process big files, it may be better to process them line by line to save resources during execution.
Do do this, use a combination of Filesystem Adapter (to read one record) and Flat File Adapter (to parse the record).
Adding a Flat File Adapter Operation to a Diagram
Expand the path to the Flat File adapter in the service panel (Base Types/Bridge Base/Base Components/Add Ons/FlatFile):
You can drag out operations from the data model to any diagram:
The example shows how to add a Flat File adapter operation to a BPMN execution diagram:
Configuring a Flat File Adapter Operation
Once a parse or compose operation has been added to a diagram, it needs to be configured as a Flat File adapter. Select the newly added adapter operation and switch to the Attributes panel. Depending on the diagram type you can see the following information (example BPMN execution diagram):
Attribute | Description | Allowed Values / Example |
---|---|---|
Name | The name of the Flat File adapter operation. | compose |
Symbol Type | Operations added to a execution diagram are execution steps. | Execution Step |
All this is predefined and cannot be changed. Click Add Stereotype to define the selected operation as to be a Flat File adapter:
Select Flat File Adapter from the list of available adapter stereotypes. Click Save:
The Attributes panel shows the added adapter stereotype. Now you still need to configure the adapter. Expand the stereotype by clicking the arrow on the right:
On the Flat File adapter, you have the following options:
resource: This option is not enabled yet, but will be available to you soon.
alias: You can add a file or directory alias to the adapter operation to specify the file to be parsed from or composed to.
Refer to Flat File Adapter Reference for detailed information. The adapter option action derives from the used operation. Do not configure this.
Click Plus to add an alias. Now, you can select an existing alias from the drop-down list, just click on the text Select alias:
If you want to remove an added alias, click the corresponding Minus on the right side or select None from the drop-down list:
You can also create and add a new alias using option Plus:
Refer to Aliases for more information on how to create a new alias.
A new dialog opens where you can choose an alias stereotype:
DirectoryAlias
FileAlias
Select the desired alias stereotype an click Save:
In the following dialog, name and configure the new file alias. Click Save to create and add the new alias:
Refer to Filesystem Adapter for more information on the configuration options of this adapter.
FlatFileAdapter_ProductExport_Example
Click here to download a simple example model that shows the usage of the Flat File adapter in Scheer PAS Designer.