forked from D-Net/dnet-hadoop
100 lines
3.2 KiB
Java
100 lines
3.2 KiB
Java
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
|
|
package eu.dnetlib.oa.graph.usagestats.export;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.apache.log4j.BasicConfigurator;
|
|
|
|
import eu.dnetlib.dhp.application.ArgumentApplicationParser;
|
|
|
|
/**
|
|
* @author D. Pierrakos, S. Zoupanos
|
|
*/
|
|
public class ExecuteWorkflow {
|
|
|
|
static String matomoAuthToken;
|
|
static String matomoBaseURL;
|
|
static String repoLogPath;
|
|
static String portalLogPath;
|
|
static String portalMatomoID;
|
|
static String irusUKBaseURL;
|
|
static String irusUKReportPath;
|
|
static String sarcsReportPathArray;
|
|
static String sarcsReportPathNonArray;
|
|
static String lareferenciaLogPath;
|
|
static String lareferenciaBaseURL;
|
|
static String lareferenciaAuthToken;
|
|
static String dbHiveUrl;
|
|
static String dbImpalaUrl;
|
|
static String usageStatsDBSchema;
|
|
static String statsDBSchema;
|
|
static boolean downloadLogs;
|
|
static Calendar startingLogPeriod;
|
|
static Calendar endingLogPeriod;
|
|
|
|
public static void main(String args[]) throws Exception {
|
|
|
|
// Sending the logs to the console
|
|
BasicConfigurator.configure();
|
|
|
|
final ArgumentApplicationParser parser = new ArgumentApplicationParser(
|
|
IOUtils
|
|
.toString(
|
|
UsageStatsExporter.class
|
|
.getResourceAsStream(
|
|
"/eu/dnetlib/dhp/oa/graph/usagestats/export/usagestats_parameters.json")));
|
|
parser.parseArgument(args);
|
|
|
|
// Setting up the initial parameters
|
|
matomoAuthToken = parser.get("matomoAuthToken");
|
|
matomoBaseURL = parser.get("matomoBaseURL");
|
|
repoLogPath = parser.get("repoLogPath");
|
|
portalLogPath = parser.get("portalLogPath");
|
|
portalMatomoID = parser.get("portalMatomoID");
|
|
irusUKBaseURL = parser.get("irusUKBaseURL");
|
|
irusUKReportPath = parser.get("irusUKReportPath");
|
|
sarcsReportPathArray = parser.get("sarcsReportPathArray");
|
|
sarcsReportPathNonArray = parser.get("sarcsReportPathNonArray");
|
|
lareferenciaLogPath = parser.get("lareferenciaLogPath");
|
|
lareferenciaBaseURL = parser.get("lareferenciaBaseURL");
|
|
lareferenciaAuthToken = parser.get("lareferenciaAuthToken");
|
|
|
|
dbHiveUrl = parser.get("dbHiveUrl");
|
|
dbImpalaUrl = parser.get("dbImpalaUrl");
|
|
usageStatsDBSchema = parser.get("usageStatsDBSchema");
|
|
statsDBSchema = parser.get("statsDBSchema");
|
|
|
|
if (parser.get("downloadLogs").toLowerCase().equals("true"))
|
|
downloadLogs = true;
|
|
else
|
|
downloadLogs = false;
|
|
|
|
String startingLogPeriodStr = parser.get("startingLogPeriod");
|
|
Date startingLogPeriodDate = new SimpleDateFormat("MM/yyyy").parse(startingLogPeriodStr);
|
|
startingLogPeriod = startingLogPeriodStr(startingLogPeriodDate);
|
|
|
|
String endingLogPeriodStr = parser.get("endingLogPeriod");
|
|
Date endingLogPeriodDate = new SimpleDateFormat("MM/yyyy").parse(endingLogPeriodStr);
|
|
endingLogPeriod = startingLogPeriodStr(endingLogPeriodDate);
|
|
|
|
UsageStatsExporter usagestatsExport = new UsageStatsExporter();
|
|
usagestatsExport.export();
|
|
}
|
|
|
|
private static Calendar startingLogPeriodStr(Date date) {
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
calendar.setTime(date);
|
|
return calendar;
|
|
|
|
}
|
|
}
|