Code cleaning and re-organisation

This commit is contained in:
Spyros Zoupanos 2020-10-02 14:45:19 +03:00
parent c1257ac7c5
commit c6bbe215e1
2 changed files with 15 additions and 71 deletions

View File

@ -6,9 +6,6 @@
package eu.dnetlib.oa.graph.usagestats.export;
import java.io.InputStream;
import java.util.Properties;
import org.apache.commons.io.IOUtils;
import eu.dnetlib.dhp.application.ArgumentApplicationParser;
@ -33,21 +30,15 @@ public class ExecuteWorkflow {
public static void main(String args[]) throws Exception {
// Properties prop = new Properties();
// InputStream propertiesInputStream = UsageStatsExporter.class
// .getClassLoader()
// .getResourceAsStream("usagestats.properties");
// prop.load(propertiesInputStream);
final ArgumentApplicationParser parser = new ArgumentApplicationParser(
IOUtils
.toString(
UsageStatsExporter.class
.getResourceAsStream(
// "/eu/dnetlib/dhp/actionmanager/migration/migrate_actionsets_parameters.json")));
"/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");
@ -61,7 +52,20 @@ public class ExecuteWorkflow {
lareferenciaBaseURL = parser.get("lareferenciaBaseURL");
lareferenciaAuthToken = parser.get("lareferenciaAuthToken");
UsageStatsExporter usagestatsExport = new UsageStatsExporter(null);
System.out.println("====> Printing parsed variables");
System.out.println(ExecuteWorkflow.matomoAuthToken);
System.out.println(ExecuteWorkflow.matomoBaseURL);
System.out.println(ExecuteWorkflow.repoLogPath);
System.out.println(ExecuteWorkflow.portalLogPath);
System.out.println(ExecuteWorkflow.irusUKBaseURL);
System.out.println(ExecuteWorkflow.irusUKReportPath);
System.out.println(ExecuteWorkflow.sarcsReportPathArray);
System.out.println(ExecuteWorkflow.sarcsReportPathNonArray);
System.out.println(ExecuteWorkflow.lareferenciaLogPath);
System.out.println(ExecuteWorkflow.lareferenciaBaseURL);
System.out.println(ExecuteWorkflow.lareferenciaAuthToken);
UsageStatsExporter usagestatsExport = new UsageStatsExporter();
usagestatsExport.export();
}
}

View File

@ -2,11 +2,9 @@
package eu.dnetlib.oa.graph.usagestats.export;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -15,25 +13,6 @@ public class UsageStatsExporter {
private static final Logger logger = LoggerFactory.getLogger(UsageStatsExporter.class);
private Properties properties;
// static String matomoAuthToken = "703bd17d845acdaf795e01bb1e0895b9";
// static String matomoBaseURL = "analytics.openaire.eu";
// static String repoLogPath = "/user/spyros/logs/usage_stats_logs6/Repologs";
// static String portalLogPath = "/user/spyros/logs/usage_stats_logs6/Portallogs/";
// static String portalMatomoID = "109";
// static String irusUKBaseURL = "https://irus.jisc.ac.uk/api/sushilite/v1_7/";
//
// static String irusUKReportPath = "/user/spyros/logs/usage_stats_logs6/irusUKReports";
// static String sarcsReportPathArray = "/user/spyros/logs/usage_stats_logs6/sarcReports/Array";
// static String sarcsReportPathNonArray = "/user/spyros/logs/usage_stats_logs6/sarcReports/NonArray";
//
// static String lareferenciaLogPath = "/user/spyros/logs/usage_stats_logs6/lareferencia";
// static String lareferenciaBaseURL = "http://matomo.lareferencia.info";
// static String lareferenciaAuthToken = "484874b3655d5a831eb8db33695790c4";
public UsageStatsExporter(Properties properties) {
this.properties = properties;
}
public void runImpalaQuery() throws Exception {
Statement stmt = ConnectDB.getImpalaConnection().createStatement();
ConnectDB.getImpalaConnection().setAutoCommit(false);
@ -59,47 +38,8 @@ public class UsageStatsExporter {
stmt.close();
}
// public static void main(String[] args) throws Exception {
// final ArgumentApplicationParser parser = new ArgumentApplicationParser(
// IOUtils
// .toString(
// UsageStatsExporter.class
// .getResourceAsStream(
// "/eu/dnetlib/dhp/actionmanager/migration/migrate_actionsets_parameters.json")));
// parser.parseArgument(args);
//
// new UsageStatsExporter(null).run(parser);
// }
// private void run(ArgumentApplicationParser parser) throws Exception {
//
// final String isLookupUrl = parser.get("isLookupUrl");
// final String sourceNN = parser.get("sourceNameNode");
// final String targetNN = parser.get("targetNameNode");
// final String workDir = parser.get("workingDirectory");
// final Integer distcp_num_maps = Integer.parseInt(parser.get("distcp_num_maps"));
//
// final String distcp_memory_mb = parser.get("distcp_memory_mb");
// final String distcp_task_timeout = parser.get("distcp_task_timeout");
//
// final String transform_only_s = parser.get("transform_only");
// }
// public void export() throws Exception {
public void export() throws Exception {
System.out.println(ExecuteWorkflow.matomoAuthToken);
System.out.println(ExecuteWorkflow.matomoBaseURL);
System.out.println(ExecuteWorkflow.repoLogPath);
System.out.println(ExecuteWorkflow.portalLogPath);
System.out.println(ExecuteWorkflow.irusUKBaseURL);
System.out.println(ExecuteWorkflow.irusUKReportPath);
System.out.println(ExecuteWorkflow.sarcsReportPathArray);
System.out.println(ExecuteWorkflow.sarcsReportPathNonArray);
System.out.println(ExecuteWorkflow.lareferenciaLogPath);
System.out.println(ExecuteWorkflow.lareferenciaBaseURL);
System.out.println(ExecuteWorkflow.lareferenciaAuthToken);
logger.info("=====> Test of the logger (info)");
logger.debug("=====> Test of the logger (debug)");
logger.error("=====> Test of the logger (error)");