endlessdreams/fao-toolkit

FAO toolkit, to manage FAO services such as SMTA api and WIEWS code and organization data fetching

v1.0.1 2019-09-18 23:07 UTC

README

Intended use for Gene banks

FAO-toolkit is a toolkit to utilize FAO services from command line. To commands are att the moment implemented. The first from the fork of Easy smta toolkit, an HTTP POST utility, to register your institute's SMTAs (Standard Material Transfer Agreements). The second command is for look up information from the WIEWS project. At the momen you can get organisation information by WIEWS Institute code.

To make SMTA posting work, you need to have the following:

  1. An account at FAO's Planttreaty site.
  2. Two database tables or dataviews with SMTA and SMTA material data.
  3. Make the configuration in this application's config file.
  4. run bin/easysmta post command. The command uses parameters to limit which SMTAs you are intended to post/register.

Installation

In order to install this library via composer run the following command in the console:

composer require endlessdreams/fao-toolkit

or add the package manually to your composer.json file in the require section:

"endlessdreams/easy-smta-toolkit": "^1.0.0"

or globally:

composer global require endlessdreams/fao-toolkit

This will install fao-toolkit into the ~/.composer/vendor/ directory and, most importantly, the easysmta CLI tool are installed into ~/.composer/vendor/bin/.

Simply add this directory to your PATH in your ~/.bash_profile (or ~/.bashrc) like this:

export PATH=~/.composer/vendor/bin:$PATH

and easysmta is now available on your command line.

To keep your tools up to date, you simply do this:

composer global update
composer global install

To remove a package, you edit ~/.composer/composer.json and then run composer global update.

Configuration

Configuration file is located in easysmta application folder: config/local.php. In this file you will see the following structure:


return [
    'database' => [
        'driver' => getenv('EASYSMTA_DRIVER'),
        'database' => getenv('EASYSMTA_DATABASE'),
        'username' => getenv('EASYSMTA_USERNAME'),
        'password' => getenv('EASYSMTA_PASSWORD'),
        'hostname'  => getenv('EASYSMTA_HOSTNAME'),
    ],
    'map' => [
        'table_order' => 'easysmta',
        'table_item' => 'easysmtaitem',
        'columns_order' => [
            'id' => 'id',
            'symbole' => 'symbole',
            'date' => 'date',
            'type' => 'type',
            'language' => 'language',
            'shipName' => 'shipname',
            'recipient_type' => 'recipient_type',
            'recipient_pid' => 'recipient_pid',
            'recipient_name' => 'recipient_name',
            'recipient_address' => 'recipient_address',
            'recipient_country' => 'recipient_country',
            'document_location' => 'document_location',
            'document_retInfo' => 'document_retinfo'
        ],
        'columns_item' => [
            'crop' => 'crop',
            'sampleid' => 'sampleid',
            'pud' => 'pud',
            'ancestry' => 'ancestry'
        ],
    ],
    'provider' => [
        'type' => 'or',
        'pid' => getenv('PROVIDER_INSTITUTE_CODE') ?? 'YOUR INSTITUTE CODE',
        'name' => getenv('PROVIDER_INSTITUTE_NAME') ?? 'YOUR INSTITUTE NAME',
        'address' => getenv('PROVIDER_INSTITUTE_ADDRESS') ?? 'YOUR INSTITUTE ADDRESS',
        'country' => getenv('PROVIDER_INSTITUTE_COUNTRY_CODE') ?? 'XXX',
        'email' => getenv('PROVIDER_INSTITUTE_EMAIL') ?? 'contact@any.institute'
    ],
    'fao' => [
        'username' => getenv('EASYSMTA_FAO_USERNAME'),
        'password' => getenv('EASYSMTA_FAO_PASSWORD'),
        'testusername' => getenv('EASYSMTA_FAO_TEST_USERNAME'),
        'testpassword' => getenv('EASYSMTA_FAO_TEST_PASSWORD'),
    ],
];

To set database and FAO HTTPS API credentials in the config file or exporting environment variables in ~/.bash_profile (or ~/.bashrc).

Usage

The examples are written as if your working directory is bin or the application is globally installed.

To test generate xml to terminal.

fao-toolkit smta xml-dry-run

To test generate all smta xml to 2018-01-01. (No https credentials needed here, only to your database)

fao-toolkit smta xml-dry-run --to=2018-01-01

To test post all SMTA's until 2018-01-01.

fao-toolkit smta register --to=2018-01-01 -t

To test post all SMTA's from 2017-01-01 until 2018-01-01.

fao-toolkit smta register --from=2017-01-01 --to=2018-01-01 -t

To actual post all SMTA's until 2018-01-01. (No testing)

fao-toolkit smta register --to=2018-01-01

To get information of WIEWS intitute code registrated organisation

fao-toolkit wiews fetch NOR051

To get information of WIEWS intitute code registrated organisation and selecting output format like JSON.

fao-toolkit wiews fetch NOR051 --format=json

Credits

ir. R (Roel) Hoekstra and dr.ir. TJL (Theo) van Hintum at Centrum voor Genetische Bronnen Nederland for letting me look at their dos cmd toolkit.

Mr Marco Marsella at FAO, Climate, Biodiversity, Land and Water Department, IT for great support.

License

This command line program is licensed under AGPL. For more information follow the link. Click here.