<workflow-app name="Usage Graph Stats" xmlns="uri:oozie:workflow:0.5">
    <parameters>
        <property>
            <name>hiveMetastoreUris</name>
            <description>Hive server metastore URIs</description>
        </property>
        <property>
            <name>hiveJdbcUrl</name>
            <description>Hive server jdbc url</description>
        </property>
        <property>
            <name>impalaJdbcUrl</name>
            <description>Impala server jdbc url</description>
        </property>
    </parameters>

    <global>
        <job-tracker>${jobTracker}</job-tracker>
        <name-node>${nameNode}</name-node>
        <configuration>
            <property>
                <name>hive.metastore.uris</name>
                <value>${hiveMetastoreUris}</value>
            </property>
            <property>
                <name>mapreduce.job.queuename</name>
                <value>${queueName}</value>
            </property>
            <property>
                <name>oozie.launcher.mapred.job.queue.name</name>
                <value>${oozieLauncherQueueName}</value>
            </property>
        </configuration>
    </global>

    <start to="Step1"/>

    <kill name="Kill">
        <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>

    <action name='Step1'>
        <java>
          	<main-class>eu.dnetlib.oa.graph.usagerawdata.export.ExecuteWorkflow</main-class>
          	<arg>--matomoAuthToken</arg><arg>${matomoAuthToken}</arg>
            <arg>--matomoBaseURL</arg><arg>${matomoBaseURL}</arg>
            <arg>--repoLogPath</arg><arg>${repoLogPath}</arg>
            <arg>--portalLogPath</arg><arg>${portalLogPath}</arg>
            <arg>--portalMatomoID</arg><arg>${portalMatomoID}</arg>
            <arg>--irusUKBaseURL</arg><arg>${irusUKBaseURL}</arg>
            <arg>--irusUKReportPath</arg><arg>${irusUKReportPath}</arg>
            <arg>--sarcsReportPathArray</arg><arg>${sarcsReportPathArray}</arg>
            <arg>--sarcsReportPathNonArray</arg><arg>${sarcsReportPathNonArray}</arg>
            <arg>--lareferenciaLogPath</arg><arg>${lareferenciaLogPath}</arg>
            <arg>--lareferenciaBaseURL</arg><arg>${lareferenciaBaseURL}</arg>
            <arg>--lareferenciaAuthToken</arg><arg>${lareferenciaAuthToken}</arg>
            <arg>--dbHiveUrl</arg><arg>${hiveJdbcUrl}</arg>
            <arg>--dbImpalaUrl</arg><arg>${impalaJdbcUrl}</arg>
            <arg>--usageStatsDBSchema</arg><arg>${usageStatsDBSchema}</arg>
            <arg>--statsDBSchema</arg><arg>${statsDBSchema}</arg>
            <arg>--recreateDbAndTables</arg><arg>${recreateDbAndTables}</arg>
            <arg>--piwikEmptyDirs</arg><arg>${piwikEmptyDirs}</arg>
            <arg>--downloadPiwikLogs</arg><arg>${downloadPiwikLogs}</arg>
            <arg>--processPiwikLogs</arg><arg>${processPiwikLogs}</arg>
            <arg>--startingLogPeriod</arg><arg>${startingLogPeriod}</arg>
            <arg>--numberOfPiwikIdsToDownload</arg><arg>${numberOfPiwikIdsToDownload}</arg>
            <arg>--numberOfSiteIdsToDownload</arg><arg>${numberOfSiteIdsToDownload}</arg>
            <arg>--laReferenciaEmptyDirs</arg><arg>${laReferenciaEmptyDirs}</arg>
            <arg>--downloadLaReferenciaLogs</arg><arg>${downloadLaReferenciaLogs}</arg>
            <arg>--processLaReferenciaLogs</arg><arg>${processLaReferenciaLogs}</arg>
            <arg>--irusCreateTablesEmptyDirs</arg><arg>${irusCreateTablesEmptyDirs}</arg>
            <arg>--irusDownloadReports</arg><arg>${irusDownloadReports}</arg>
            <arg>--irusProcessStats</arg><arg>${irusProcessStats}</arg>
            <arg>--irusNumberOfOpendoarsToDownload</arg><arg>${irusNumberOfOpendoarsToDownload}</arg>
            <arg>--sarcCreateTablesEmptyDirs</arg><arg>${sarcCreateTablesEmptyDirs}</arg>
            <arg>--sarcDownloadReports</arg><arg>${sarcDownloadReports}</arg>
            <arg>--sarcProcessStats</arg><arg>${sarcProcessStats}</arg>
            <arg>--sarcNumberOfIssnToDownload</arg><arg>${sarcNumberOfIssnToDownload}</arg>
            <arg>--finalizeStats</arg><arg>${finalizeStats}</arg>
            <arg>--numberOfDownloadThreads</arg><arg>${numberOfDownloadThreads}</arg>
            <capture-output/>
        </java>
        <ok to="End" />
        <error to="Kill" />
    </action>
    
    <end name="End"/>
</workflow-app>
