Data Flow - From Petals to a Job using Attachments

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (19)

View Page History
h1. Rationale

Send a CSV file as an attachment through Petals to a Talend job.
The job loads the content of the attached file and inserts its content into a database.
In the scope of this use case, we could imagine, even if it is not shown, that the file's content is transformed before being inserted.
This job has one context variable, pointing to the location of the file whose content must be loaded.

\\
{info}
In the scope of this use case, it is assumed there is a database *formationtalend* on the localhost, having a table named *customers*.
The schema of the *customers* table includes two columns named *CustomerName* and *CustomerAddress*, both being of type varchar(255).
{info}

h2. Creating the job

The job is made up of two components:
# The tFileInputDelimited reads the CSV file's content.
# The tMySqlOutput writes the data into the database.

Here is the overall aspect of the job.

!PetalsToJob_file_job.jpg!

\\
Here is the schema of the tFileInputDelimited component.

!PetalsToJob_file_tfidschema.jpg!

\\
Here are the properties of the tFileInputDelimited component.

!PetalsToJob_file_tfidsproperties.jpg!

\\
Here are the properties of the tMySqlOutput component.

!PetalsToJob_file_tmoproperties.jpg!


h2. Exporting the job


Click *Edit the exposed contexts*.
A dialog shows up. Export the _outputLocation_ context as an *Out-Attachment*.
A dialog shows up. Click the *Export mode* column, and select *Parameter* in the combo box. Click *OK*.

You should have the following dialog:

!PetalsToJob_file_export.jpg!



Click the *Export mode* column, and select *Parameter* in the combo box. Click *OK*.
The link label should be updated and indicate the number of exported contexts.



Click *Finish*.


\\
The input message's description requires empty parameters.
The input message's description only expects the input attachment.

{code:lang=xml}
<xs:element name="executeJob" type="tns:executeJob" />
<xs:complexType name="executeJob">
<xs:sequence>
<xs:element minOccurs="0" name="contexts" type="tns:talendContexts" />
<xs:element minOccurs="0" name="in-attachments" type="tns:inAttachments" />
<xs:element maxOccurs="unbounded" minOccurs="0" name="in-data-bean" type="tns:inRow" />
<xs:element maxOccurs="unbounded" minOccurs="0" name="talend-option" type="xs:string" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="talendContexts">
<xs:sequence>
</xs:sequence>
</xs:complexType>

<xs:complexType name="inAttachments">
<xs:sequence>
<xs:element name="outputLocation" nillable="true" type="tns:attachment" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="inRow">
<xs:sequence>
</xs:sequence>
</xs:complexType>
{code}


\\
And the output message includes the job's result and the output attachment.
And the output message only includes the job's result.

{code:lang=xml}
<xs:element name="executeJobResponse" type="tns:executeJobResponse" />
<xs:complexType name="executeJobResponse">
<xs:sequence>
<xs:element minOccurs="0" name="talend-job-output" type="tns:talendJobOutput" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="talendJobOutput">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="executionResult" nillable="true" type="ns1:stringArray" />
<xs:element minOccurs="0" name="outAttachment" type="tns:outAttachments" />
<xs:element maxOccurs="unbounded" minOccurs="0" name="outDataBean" nillable="true" type="tns:outRow" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="outAttachments">
<xs:sequence>
</xs:sequence>
</xs:complexType>

<xs:complexType name="outRow">
<xs:sequence>
</xs:sequence>
</xs:complexType>
{code}