<tool id="entities_template" name="Make entities templates for raster, vector and other entities files" version="0.1.1+galaxy0" profile="22.05">
    <description>for EML metadata creation</description>
    <requirements>
        <container type="docker">outils-patrinat.mnhn.fr/metashark:latest</container>
    </requirements>
    <command detect_errors="exit_code"><![CDATA[
    
    mkdir output_template &&
    #for $input in $templates
        ln -s '$input' 'output_template/${input.element_identifier}';
    #end for
    
    #set $table = ""
    mkdir data_files && 
    #for $indata in $inputdata
        ln -s '$indata' 'data_files/${indata.element_identifier}';
        #set $table += $indata.element_identifier + " ";
    #end for
    
    Rscript 
         '$__tool_directory__/entities_templates.R'
         '$table'
         
    ]]></command>
    <inputs>
         <param name="templates" type="data_collection"  collection_type="list" label="Upload EAL attributes templates (with if exist catvars and custom units files)" help= "Input a data collection" />
         <param name="inputdata" type="data_collection"  collection_type="list"  label="Upload all data files wich are raster and/or vector and/or other entities files" help= "Input a data collection."/>
    </inputs>
    <outputs>
       <data name="output" from_work_dir="output_template/entities.txt" format="txt" label="entities.txt"/>
    </outputs>
    <tests>
        <test>
           <param name="templates">
              <collection type="list">
                 <element name="attributes_data_7.txt" value="attributes_data_7.txt" />
                 <element name="catvars_data_7.txt" value="catvars_data_7.txt" />
                 <element name="custom_units.txt" value="custom_units.txt" />
              </collection>
           </param>
           <param name="inputdata">
              <collection type="list">
                 <element name="data_7.GeoJSON" value="data_7.GeoJSON" />
              </collection>
           </param>          
           <output name="output" value="entities.txt"/>
        </test>
    </tests>
    <help><![CDATA[
    
**What it does?**
--------------------

This tool is used to produce EAL templates call entities for raster, vector and other entities files used to build EML metadata. It produces the following eal files: 

- entities.txt (it describe some variables)

After that, this file can be edited to add information about your data and then be used in the make eml tool to produce EML metadata.   

**How to use it?**
--------------------
To use this tool, you need to select, in your history a data collection with all your EAL attributes templates (with if exist catvars and custom units files). To do so, you can select the **Upload file** tool, select the *Collection* tab, upload all your templates, click on the *Start* button to integrate the files to Galaxy and then click on *Build*. You will need to choose a name and select *Create collection* to build a collection with your templates. You also can upload your files to Galaxy, select them in the history by clicking the *Select items* button, click on the newly appeared box on the right and select *Build dataset list*.
You need also to input all your data files Upload all data files wich are raster and/or vector and/or other entities files.
    ]]></help>
    <citations>
       <citation type="bibtex">@Manual{,
       title = {EMLassemblyline: A tool kit for building EML metadata workflows},
       author = {Colin Smith},
       year = {2022},
       note = {https://github.com/EDIorg/EMLassemblyline,
       https://ediorg.github.io/EMLassemblyline/},
       }</citation>
    </citations>
</tool>

