uCosminexus Service Platform, Reception and Adapter Definition Guide
The sample for writing CSV data uses a file adapter to write data retrieved by a DB adapter to a file in CSV format.
The following table lists the items that are input and output:
Table D-55 Input and output items (sample for writing CSV data)
| Input or output item | Content |
|---|---|
| Output file of file adapter | service-platform-installation-directory\CSC\custom-adapter\File\sample\write_csv\write_csv_data.csv |
| Input table of DB adapter | ADMIN.CSAFF_SAMPLE_WC# |
To add and validate a file adapter:
Table D-56 Settings in Service adapter definition (standard) window (sample for writing CSV data)
| Category | Item | Value to set | Requires setting | |
|---|---|---|---|---|
| Service component control information | Service name | CSAFF_SAMPLE_WRITE_CSV | Y | |
| Service ID | CSAFF_WC | Y | ||
| Service type | File adapter | N | ||
| Address | -- | -- | ||
| Maximum instances | 0 | Y | ||
| Operation | Pattern: Binary file writing Operation name: CSAFF_SAMPLE_WRITE_CSV |
Y | ||
| Operation information | Operation name | CSAFF_SAMPLE_WRITE_CSV | N | |
| Communication model | Sync | Y | ||
| Request message | Standard | Use check box | Use (select the check box) | Y |
| Format ID | SAMPLE_WRITE_CSV_Standard | Y | ||
| Message format | csaff_sample_write_csv_standard.xsd | Y | ||
| Service component | Format ID | SAMPLE_WRITE_CSV_Request | Y | |
| Message format | csaff_sample_write_csv.fdx | Y | ||
| Data TransDefn File | SAMPLE_WRITE_CSV_DT | Y | ||
| Response message | Standard | Use check box | Do not use (leave the check box cleared) | Y |
| Service component | Format ID | SAMPLE_WRITE_CSV_Response | Y | |
| Message format | adpff_result.xsd | N | ||
The table below shows the items you need to set in the Service adapter definition (details) window when defining the file adapter for the sample for writing CSV data. You do not need to set items that do not appear in this table.
Table D-57 Settings in Service adapter definition (details) window (sample for writing CSV data)
| Category | Item | Value to set | Requires setting |
|---|---|---|---|
| Service adapter control information | Service adapter (EJB-JAR file) | cscmsg_adpejb.jar | N |
| Utility class (JAR file) | adpffpc.jar | N |
Set the data transformation definition. The following figure shows the data transformation definition you need to set:
Figure D-11 Data-conversion definition screen for file adapter (sample for writing CSV data)
To define this data transformation:
Table D-58 Function settings (sample for writing CSV data - File adapter)
| Function | Function name | Value to set | |
|---|---|---|---|
| loop | loop1 | Select Node | record |
| Set Node Condition | Do not set | ||
| loop | loop2 | Select Node | column |
| Set Node Condition | Do not set | ||
Table D-59 Mapping settings (sample for writing CSV data - File adapter)
| Source node | Function | Target node |
|---|---|---|
| -- | loop1 | record |
| -- | loop2 | data |
| filename | -- | filename |
| fileoption | -- | fileoption |
| data | -- | data |
To create the file adapter runtime-environment property file:
fileaccess.path1 = service-platform-installation-directory\\CSC\\custom-adapter\\File\\sample\\write_csv character.code = MS932 codetable.path = storage-path-for-code-conversion-table-(user-mapping-file)
service-platform-installation-directory\\CSC\\lib\\external\\table
service-platform-installation-directory\CSC\custom-adapter\File\config
The task of defining a business process involves adding a business process, defining the contents of the business process, and then validating the business process.
To add a business process:
Set the following variables:
To set the variables:
Table D-60 Settings for CSAFF_DB_ResponseMessage (sample for writing CSV data)
| Category | Item | Value to set |
|---|---|---|
| Service/Reception | Service name | CSAFF_SAMPLE_DB |
| Reception name | -- | |
| Target for take in | Operation name | CSAFF_SAMPLE_DB |
| Message type | Response message (Body) | |
| -- | Message format | csaff_sample_sqlformat |
Table D-61 Settings for CSAFF_RequestMessage (sample for writing CSV data)
| Category | Item | Value to set |
|---|---|---|
| Service/Reception | Service name | CSAFF_SAMPLE_WRITE_CSV |
| Reception name | -- | |
| Target for take in | Operation name | CSAFF_SAMPLE_WRITE_CSV |
| Message type | Request message (Body) | |
| -- | Message format | csaff_sample_write_csv_standard |
Table D-62 Settings for CSAFF_ResponseMessage (sample for writing CSV data)
| Category | Item | Value to set |
|---|---|---|
| Service/Reception | Service name | CSAFF_SAMPLE_WRITE_CSV |
| Reception name | -- | |
| Target for take in | Operation name | CSAFF_SAMPLE_WRITE_CSV |
| Message type | Response message (Body) | |
| -- | Message format | adpff_result |
The following describes how to arrange and define the activities in the figure below, define the data transformations, and connect the activities.
Figure D-12 Overall view of business process definition (sample for writing CSV data)
In the sample for writing CSV data, set up the activities shown in the following table.
Table D-63 List of activities (sample for writing CSV data)
| Activity | Activity name | Description |
|---|---|---|
| Reception | CSAFF_SAMPLE_BP_WRITE_CSV | Receives messages into the business process. |
| Reply | CSAFF_SAMPLE_BP_WRITE_CSV_RSP | Issues a response from the business process. |
| Invoke Service | InvokeFileAadapter | Invokes the file adapter. |
| Invoke Service | InvokeDBAdapter | Invokes the DB adapter. |
| Data transformation | CreateFileAdapterRequestMessage | Transforms a response message from the DB adapter to a request message for the file adapter. |
| Data transformation | CreateDBAdapterRequestMessage | Transforms the request message of the business process to a request message for the DB adapter. |
To position and set up an activity:
Table D-64 Settings for CSAFF_SAMPLE_BP_WRITE_CSV
| Item | Value to set |
|---|---|
| Activity name | CSAFF_SAMPLE_BP_WRITE_CSV |
| Operation name | CSAFF_SAMPLE_BP_WRITE_CSV |
| Body allocated variable | CSAFF_BP_RequestMessage |
| Communication model | Sync |
| Instance generation | Yes |
Table D-65 Settings for CSAFF_SAMPLE_BP_WRITE_CSV_RSP
| Item | Value to set |
|---|---|
| Activity name | CSAFF_SAMPLE_BP_WRITE_CSV_RSP |
| Operation name | CSAFF_SAMPLE_BP_WRITE_CSV |
| Body allocated variable | CSAFF_ResponseMessage |
Table D-66 Settings for InvokeFileAadapter (sample for writing CSV data)
| Item | Value to set | |
|---|---|---|
| Activity name | InvokeFileAadapter | |
| Service name | CSAFF_SAMPLE_WRITE_CSV | |
| Operation name | CSAFF_SAMPLE_WRITE_CSV | |
| Communication model | Sync | |
| Request message | Body allocated variable | CSAFF_RequestMessage |
| Response message | Body allocated variable | CSAFF_ResponseMessage |
Table D-67 Settings for InvokeDBAdapter (sample for writing CSV data)
| Item | Value to set | |
|---|---|---|
| Activity name | InvokeDBAdapter | |
| Service name | CSAFF_SAMPLE_DB | |
| Operation name | CSAFF_SAMPLE_DB | |
| Communication model | Sync | |
| Request message | Body allocated variable | CSAFF_DB_RequestMessage |
| Response message | Body allocated variable | CSAFF_DB_ResponseMessage |
Table D-68 Settings for CreateFileAdapterRequestMessage (sample for writing CSV data)
| Item | Value to set |
|---|---|
| Activity name | CreateFileAdapterRequestMessage |
| Source Variables | CSAFF_BP_RequestMessage |
| CSAFF_DB_ResponseMessage | |
| Destination Variable | CSAFF_RequestMessage |
| Data TransDefn File | SAMPLE_WRITE_CSV_DT2 |
Table D-69 Settings for CreateDBAdapterRequestMessage (sample for writing CSV data)
| Item | Value to set |
|---|---|
| Activity name | CreateDBAdapterRequestMessage |
| Source Variables | CSAFF_BP_RequestMessage |
| Destination Variable | CSAFF_DB_RequestMessage |
| Data TransDefn File | SAMPLE_WRITE_CSV_DT1 |
Set the data transformation definition for the CreateDBAdapterRequestMessage activity. The following figure shows the data transformation definition you need to set:
Figure D-13 Data conversion definition window for CreateDBAdapterRequestMessage activity (sample for writing CSV data)
To set the data transformation definition for the CreateDBAdapterRequestMessage activity:
Table D-70 Function settings (sample for writing CSV data - CreateDBAdapterRequestMessage activity)
| Function | Function name | Value to set | |
|---|---|---|---|
| const | const1 | Constant type | String |
| Value | PRODUCT_CODE | ||
| const | const2 | Constant type | String |
| Value | = | ||
Table D-71 Mapping settings (sample for writing CSV data - CreateDBAdapterRequestMessage activity)
| Source node | Function | Target node |
|---|---|---|
| -- | const1 | val1 |
| -- | const2 | val2 |
| PRODUCT_CODE | -- | val3 |
Set the data transformation definition for the CreateFileAdapterRequestMessage activity. The following figure shows the data transformation definition you need to set:
Figure D-14 Data conversion definition window for CreateFileAdapterRequestMessage activity (sample for writing CSV data)
To set the data transformation definition for the CreateFileAdapterRequestMessage activity:
Table D-72 Function settings (sample for writing CSV data - CreateFileAdapterRequestMessage activity)
| Function | Function name | Value to set | |
|---|---|---|---|
| loop | loop1 | Select Node | DBA_ResultSet# |
| Set Node Condition | Do not set | ||
| loop | loop2 | Select Node | DBA_ResultColumn# |
| Set Node Condition | Do not set | ||
Table D-73 Mapping settings (sample for writing CSV data - CreateFileAdapterRequestMessage activity)
| Source node | Function | Target node |
|---|---|---|
| -- | loop1 | record |
| -- | loop2 | column |
| filename | -- | filename |
| fileoption | -- | fileoption |
| DBA_ResultColumn# | -- | data |
In the sample for writing CSV data, connect the activities as shown in the following table.
Table D-74 Activity connections (sample for writing CSV data)
| Connection-source activity | Connection-target activity |
|---|---|
| Start | CSAFF_SAMPLE_BP_WRITE_CSV |
| CSAFF_SAMPLE_BP_WRITE_CSV | CreateDBAdapterRequestMessage |
| CreateDBAdapterRequestMessage | InvokeDBAdapter |
| InvokeDBAdapter | CreateFileAdapterRequestMessage |
| CreateFileAdapterRequestMessage | InvokeFileAadapter |
| InvokeFileAadapter | CSAFF_SAMPLE_BP_WRITE_CSV_RSP |
| CSAFF_SAMPLE_BP_WRITE_CSV_RSP | Finish |
To connect the activities:
To save and validate the business process:
Deploy the file adapter and business process and start them on the server.
To distribute the file adapter and business process deployment definitions:
Create the table the sample business process will access in the database.
Open HiRDB SQL Executer and execute the following SQL statement:
CREATE TABLE CSAFF_SAMPLE_WC (ORDER_NO INT, CUSTOMER_CODE CHAR(5), PRODUCT_CODE CHAR(4), ORDER_COUNT INT); INSERT INTO CSAFF_SAMPLE_WC VALUES(1001,'AA001','1001',5); INSERT INTO CSAFF_SAMPLE_WC VALUES(1002,'AB002','1001',1); INSERT INTO CSAFF_SAMPLE_WC VALUES(1003,'AA001','1102',3); INSERT INTO CSAFF_SAMPLE_WC VALUES(1004,'XA005','1103',1); INSERT INTO CSAFF_SAMPLE_WC VALUES(1005,'AA001','1105',1);
The following describes how to create a request message by editing the sample request message used when executing the business process.
<?xml version="1.0" encoding="UTF-8"?> <WriteData> <filename>service-platform-installation-directory\CSC\custom-adapter\File\sample\write_csv\write_csv_data.csv</filename> <fileoption>mode=new</fileoption> <PRODUCT_CODE>1001</PRODUCT_CODE> </WriteData>
To execute the sample, start the business process from the service requester.
The flow of service requester processing is as follows:
To execute the service requester:
request write_csv service-platform-installation-directory\CSC\custom-adapter\File\sample\write_csv\write_csv_message.xml
All Rights Reserved. Copyright (C) 2015, Hitachi, Ltd.