Data Uploader supports only uploading XML files. However it also contains conversion plugins to convert into XML. Currently there is only one plugin - for conversion from CSV, so the following documentation reflects CSV plugin configuration.

Enabling plugins

If you want to use a plugin, you have to enable it on the configuration page. In the File converter plugins field, fill in the plugin identifier. In case of CSV plugin, the value is “com.tracetracker.slurp.upload.fileconverter.CSVFileConverterPlugin” (without quotation marks). In case of multiple plugins, use commas to separate them.

Structure of plugin directories

In .slurp/userdata/{datarepository}/uploads/{username}/data/ there may be several directories for conversion plugins. The structure in such case is:

.slurp
`-- {username}
`-- data
|-- dir_A
| |-- csv_template_A.vm
| |-- file-to-convert-1.csv
| `-- file-to-convert-2.csv
|-- dir_B
| |-- csv_template_B.vm
| |-- file-to-convert-3.csv
| `-- file-to-convert-4.csv
`-- 2010-02-19-Fish.xml

Each conversion plugin (currently we support only CSV plugin) handles one file extension (other than XML, which is the default format that does not need any plugin). You may have different variations of the same format, e.g. two different structures of CSV. In that case, you have to create two directories, e.g. data/incoming-shipments/ and data/outgoing-shipments/ (names do not matter) and into each of them you have to put conversion template file with .vm extension e.g. csv_template_A.vm Name itself does not matter but there can be only one such file per directory. Extensions are case insensitive. Ask TraceTracker AS for template files that are compatible with your file structure. Then, whenever you put a file with .csv extension to that directory, the plugin will convert your file according to csv_template_A.vm into the XML format. Resulting XML file (temporarily put into the {username}/temp/ directory) will be treated the same way as other XML files – i.e. uploaded to the data repository, and together with original CSV file it will be put into respective directory in archive or failed (e.g. archive/dir_A/file-to-convert-1.csv.xml).

CSV plugin template example

Example of simple velocity template used to convert CSV file into EPCIS XML

<?xml version="1.0" encoding="UTF-8"?>
<!-- Data file for ACME Goods, Inc. -->
<epcis:EPCISDocument schemaVersion="1" creationDate="2011-01-01T00:00:00.0Z" xsi:schemaLocation="urn:epcglobal:epcis:xsd:1
http://schema.tracetracker.com/EPCglobal-epcis-1_0.xsd" xmlns:tttrd="http://www.tracetracker.com/trd" xmlns:epcis="urn:epcglobal:epcis:xsd:1"
xmlns:gtnet="http://www.globaltraceability.net/schema/epcis" xmlns:ttdata="http://www.tracetracker.com/data" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EPCISBody trdRef="TRD-goods">
<EventList>
#foreach( $row in $rows )
<ObjectEvent>
<eventTime>$row.Date</eventTime>
<eventTimeZoneOffset>+02:00</eventTimeZoneOffset>
<epcList>
<epc>delivery-123456789</epc>
</epcList>
<action>ADD</action>
<gtnet:entityClass>Batch</gtnet:entityClass>
<gtnet:trdType>goodsdelivery</gtnet:trdType>
<ttdata:weight>$row.Weight</ttdata:weight>
<ttdata:buyingprice>$row.Price</ttdata:buyingprice>
<ttdata:handover>$row.Date</ttdata:handover>
<ttdata:farm>$row.FarmerCode</ttdata:farm>
<ttdata:vehicle>VC-123-456</ttdata:vehicle>
<ttdata:growingcenter>$row.CenterCode</ttdata:growingcenter>
<ttdata:currency>USD</ttdata:currency>
</ObjectEvent>
#end
</EventList>
</EPCISBody>
</epcis:EPCISDocument>

This template can be applied on CSV file such as this one (every row is processed via $row variable).

RegionCode;RegionName;CenterCode;CenterName;Date;FarmerCode;FarmerName;Weight;Price
01; Mt Kenya ;02; Nanyuki ;2010-11-05T10:20:58.298Z ;01; John Mensa ;50;35
03; Eastern ;04; Embu ;2010-11-05T11:20:38.231Z ;01; John Mensa ;50;55
02; Western ;05; Kakamega ;2010-11-05T10:30:58.198Z ;04; Karen Karenito ;1000;150
02; Western ;06; Busia ;2010-11-05T10:20:53.498Z ;05; Kabir Kafiro ;740;80

Date and Time Conversion

The Csv plugin allows date/time text input of any format. Under the .slurp directory there is dateformats.properties file that contains a number of date format regular expressions that Data Uploader can recognize and accept. The system system administrator is free to add any that is not there but care has to be taken not to add ambiguous formats; e.g if the format dd/MM/yyyy is added then MM/dd/yyyy cannot be added Data Uploader may not distinguish between the date and month representation in the text and the date/time uploaded might be wrong.

 Errors in a template

If the Velocity template (.vm file) contains errors which prevents it from being parsed, user gets error on the Dashboard page: “CSV conversion template contains errors. See Administration Guide for details.” In such case, user there is a file created in the same directory as the velocity template, just with .conversion.log extension – for example data/dir_A/csv_template.vm.conversion.log. Send this
file to the creator of conversion template.