<workflow-app name="Gen Orcid Authors DOIs" xmlns="uri:oozie:workflow:0.5">
    <parameters>
        <property>
            <name>workingPath_activities</name>
            <description>the working dir base path</description>
        </property>
        <property>
            <name>shell_cmd_0</name>
            <value>wget -O /tmp/ORCID_2019_activites_0.tar.gz https://orcid.figshare.com/ndownloader/files/18017660 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_0.tar.gz /data/orcid_activities/ORCID_2019_activites_0.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file 0</description>
        </property>
        <property>
            <name>shell_cmd_1</name>
            <value>wget -O /tmp/ORCID_2019_activites_1.tar.gz https://orcid.figshare.com/ndownloader/files/18017675 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_1.tar.gz /data/orcid_activities/ORCID_2019_activites_1.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file 1</description>
        </property>
        <property>
            <name>shell_cmd_2</name>
            <value>wget -O /tmp/ORCID_2019_activites_2.tar.gz https://orcid.figshare.com/ndownloader/files/18017717 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_2.tar.gz /data/orcid_activities/ORCID_2019_activites_2.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file 2</description>
        </property>
        <property>
            <name>shell_cmd_3</name>
            <value>wget -O /tmp/ORCID_2019_activites_3.tar.gz https://orcid.figshare.com/ndownloader/files/18017765 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_3.tar.gz /data/orcid_activities/ORCID_2019_activites_3.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file 3</description>
        </property> 
        <property>
            <name>shell_cmd_4</name>
            <value>wget -O /tmp/ORCID_2019_activites_4.tar.gz https://orcid.figshare.com/ndownloader/files/18017831 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_4.tar.gz /data/orcid_activities/ORCID_2019_activites_4.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file 4</description>
        </property> 
        <property>
            <name>shell_cmd_5</name>
            <value>wget -O /tmp/ORCID_2019_activites_5.tar.gz https://orcid.figshare.com/ndownloader/files/18017987 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_5.tar.gz /data/orcid_activities/ORCID_2019_activites_5.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file 5</description>
        </property>  
        <property>
            <name>shell_cmd_6</name>
            <value>wget -O /tmp/ORCID_2019_activites_6.tar.gz https://orcid.figshare.com/ndownloader/files/18018053 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_6.tar.gz /data/orcid_activities/ORCID_2019_activites_6.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file 6</description>
        </property>
        <property>
            <name>shell_cmd_7</name>
            <value>wget -O /tmp/ORCID_2019_activites_7.tar.gz https://orcid.figshare.com/ndownloader/files/18018023 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_7.tar.gz /data/orcid_activities/ORCID_2019_activites_7.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file 7</description>
        </property>
        <property>
            <name>shell_cmd_8</name>
            <value>wget -O /tmp/ORCID_2019_activites_8.tar.gz https://orcid.figshare.com/ndownloader/files/18018248 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_8.tar.gz /data/orcid_activities/ORCID_2019_activites_8.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file 8</description>
        </property>
        <property>
            <name>shell_cmd_9</name>
            <value>wget -O /tmp/ORCID_2019_activites_9.tar.gz https://orcid.figshare.com/ndownloader/files/18018029 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_9.tar.gz /data/orcid_activities/ORCID_2019_activites_9.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file 9</description>
        </property> 
        <property>
            <name>shell_cmd_X</name>
            <value>wget -O /tmp/ORCID_2019_activites_X.tar.gz https://orcid.figshare.com/ndownloader/files/18018182 ; hdfs dfs -copyFromLocal /tmp/ORCID_2019_activites_X.tar.gz /data/orcid_activities/ORCID_2019_activites_X.tar.gz
            </value>
            <description>the shell command that downloads and puts to hdfs orcid activity file X</description>
        </property>  
    </parameters>
    
    <start to="ResetWorkingPath"/>
    
    
    <kill name="Kill">
        <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    
    <action name="ResetWorkingPath">
        <fs>
            <delete path='${workingPath_activities}/output'/>
            <mkdir path='${workingPath_activities}/output'/>
        </fs>
        <ok to="fork_gen_orcid_authors_dois"/>
        <error to="Kill"/>
    </action>
    
    <fork name = "fork_gen_orcid_authors_dois">
      <path start = "check_exist_on_hdfs_activities_0"/>
      <path start = "check_exist_on_hdfs_activities_1"/>
      <path start = "check_exist_on_hdfs_activities_2"/>
	  <path start = "check_exist_on_hdfs_activities_3"/>
	  <path start = "check_exist_on_hdfs_activities_4"/>
	  <path start = "check_exist_on_hdfs_activities_5"/>
	  <path start = "check_exist_on_hdfs_activities_6"/>
	  <path start = "check_exist_on_hdfs_activities_7"/>
	  <path start = "check_exist_on_hdfs_activities_8"/>
	  <path start = "check_exist_on_hdfs_activities_9"/>
	  <path start = "check_exist_on_hdfs_activities_X"/>
   	</fork>
   	
    <decision name="check_exist_on_hdfs_activities_0">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_0">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_0.tar.gz'))}
            </case>
            <default to="Download_0" />
         </switch>
	</decision>
	
    <action name="Download_0">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_0}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_0"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_0">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_0.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_0.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    <decision name="check_exist_on_hdfs_activities_1">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_1">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_1.tar.gz'))}
            </case>
            <default to="Download_1" />
         </switch>
	</decision>
	
    <action name="Download_1">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_1}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_1"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_1">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_1.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_1.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    <decision name="check_exist_on_hdfs_activities_2">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_2">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_2.tar.gz'))}
            </case>
            <default to="Download_2" />
         </switch>
	</decision>
	
    <action name="Download_2">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_2}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_2"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_2">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_2.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_2.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    <decision name="check_exist_on_hdfs_activities_3">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_3">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_3.tar.gz'))}
            </case>
            <default to="Download_3" />
         </switch>
	</decision>
	
    <action name="Download_3">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_3}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_3"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_3">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_3.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_3.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    <decision name="check_exist_on_hdfs_activities_4">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_4">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_4.tar.gz'))}
            </case>
            <default to="Download_4" />
         </switch>
	</decision>
	
    <action name="Download_4">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_4}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_4"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_4">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_4.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_4.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    <decision name="check_exist_on_hdfs_activities_5">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_5">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_5.tar.gz'))}
            </case>
            <default to="Download_5" />
         </switch>
	</decision>
	
    <action name="Download_5">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_5}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_5"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_5">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_5.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_5.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    <decision name="check_exist_on_hdfs_activities_6">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_6">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_6.tar.gz'))}
            </case>
            <default to="Download_6" />
         </switch>
	</decision>
	
    <action name="Download_6">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_6}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_6"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_6">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_6.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_6.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    
    <decision name="check_exist_on_hdfs_activities_7">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_7">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_7.tar.gz'))}
            </case>
            <default to="Download_7" />
         </switch>
	</decision>
	
    <action name="Download_7">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_7}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_7"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_7">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_7.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_7.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    <decision name="check_exist_on_hdfs_activities_8">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_8">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_8.tar.gz'))}
            </case>
            <default to="Download_8" />
         </switch>
	</decision>
	
    <action name="Download_8">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_8}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_8"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_8">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_8.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_8.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    <decision name="check_exist_on_hdfs_activities_9">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_9">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_9.tar.gz'))}
            </case>
            <default to="Download_9" />
         </switch>
	</decision>
	
    <action name="Download_9">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_9}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_9"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_9">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_9.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_9.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    <decision name="check_exist_on_hdfs_activities_X">
         <switch>
            <case to="Gen_Orcid_Authors_DOIs_X">
              ${fs:exists(concat(workingPath_activities,'/ORCID_2019_activites_X.tar.gz'))}
            </case>
            <default to="Download_X" />
         </switch>
	</decision>
	
    <action name="Download_X">
		<shell xmlns="uri:oozie:shell-action:0.1">
		<job-tracker>${jobTracker}</job-tracker>
		<name-node>${nameNode}</name-node>
		<exec>bash</exec>
	    <argument>-c</argument>
	    <argument>${shell_cmd_X}</argument>
		<capture-output/>
		</shell>
	<ok to="Gen_Orcid_Authors_DOIs_X"/>
	<error to="Kill"/>
	</action>
	
	<action name="Gen_Orcid_Authors_DOIs_X">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <main-class>eu.dnetlib.doiboost.orcid.OrcidAuthorsDOIsDataGen</main-class>
            <arg>-d</arg><arg>${workingPath_activities}/</arg>
            <arg>-n</arg><arg>${nameNode}</arg>
            <arg>-f</arg><arg>ORCID_2019_activites_X.tar.gz</arg>
            <arg>-o</arg><arg>output/authors_dois_X.seq</arg>
        </java>
        <ok to="join_node"/>
        <error to="Kill"/>
    </action>
    
    <join name = "join_node" to = "End"/>
    
   <end name="End"/>
</workflow-app>