dnet-hadoop/dhp-workflows/dhp-usage-stats-update/src/main/java/eu/dnetlib/oa/graph/usagestats/export/UsageStatsExporter.java

95 lines
3.6 KiB
Java
Raw Normal View History

2020-05-12 19:38:31 +02:00
package eu.dnetlib.oa.graph.usagestats.export;
import java.sql.ResultSet;
import java.sql.Statement;
2020-10-01 22:24:40 +02:00
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Main class for downloading and processing Usage statistics
*
* @author D. Pierrakos, S. Zoupanos
*/
public class UsageStatsExporter {
2020-10-01 22:24:40 +02:00
private static final Logger logger = LoggerFactory.getLogger(UsageStatsExporter.class);
public void runImpalaQuery() throws Exception {
Statement stmt = ConnectDB.getImpalaConnection().createStatement();
ConnectDB.getImpalaConnection().setAutoCommit(false);
logger.info("Executing Impala query");
Statement statement = ConnectDB.getImpalaConnection().createStatement();
ResultSet rs = statement
.executeQuery(
// "CREATE TABLE usagestats_20200913.spyros_tmp5 AS\n" +
// "SELECT s.source, d.id AS repository_id, ro.id as result_id, s.count, '0' \n" +
// "FROM usagestats_20200913.sarc_sushilogtmp2 s, \n" +
// "openaire_prod_stats_shadow_20200821.datasource_oids d, \n" +
// "openaire_prod_stats_shadow_20200821.datasource_results dr, \n" +
// "openaire_prod_stats_shadow_20200821.result_pids ro \n" +
// "WHERE d.oid LIKE CONCAT('%', s.repository, '%') AND dr.id=d.id AND dr.result=ro.id \n" +
// "AND s.rid=ro.pid AND ro.type='doi' AND metric_type='ft_total' AND s.source='SARC-OJS' ");
"CREATE TABLE usagestats_20200913.spyros_tmp6 AS\n" +
"SELECT * \n" +
"FROM usagestats_20200913.sarc_sushilogtmp2");
stmt.close();
}
public void export() throws Exception {
// runImpalaQuery();
2020-08-31 22:19:15 +02:00
// Create DB tables - they are also needed to download the statistics too
logger.info("Creating database and tables");
2020-10-01 22:24:40 +02:00
PiwikStatsDB piwikstatsdb = new PiwikStatsDB(ExecuteWorkflow.repoLogPath, ExecuteWorkflow.portalLogPath);
2020-07-22 18:22:04 +02:00
//
// // Download the statistics - The following 2 lines are not needed after the download - Commenting them out for
// // the moment
logger.info("Initializing the download logs module");
2020-10-01 22:24:40 +02:00
PiwikDownloadLogs piwd = new PiwikDownloadLogs(ExecuteWorkflow.matomoBaseURL, ExecuteWorkflow.matomoAuthToken);
logger.info("Downloading piwik logs");
// piwd.GetOpenAIRELogs(repoLogPath, portalLogPath, portalMatomoID);
logger.info("Downloaded piwik logs");
2020-08-31 22:19:15 +02:00
// Create DB tables, insert/update statistics
// String cRobotsUrl = properties.getProperty("COUNTER_robots_Url");
String cRobotsUrl = "https://raw.githubusercontent.com/atmire/COUNTER-Robots/master/COUNTER_Robots_list.json";
piwikstatsdb.setCounterRobotsURL(cRobotsUrl);
logger.info("Processing logs");
piwikstatsdb.processLogs();
2020-10-01 22:24:40 +02:00
// log.info("process logs done");
2020-07-22 18:22:04 +02:00
logger.info("Creating LaReferencia tables");
2020-10-01 22:24:40 +02:00
LaReferenciaDownloadLogs lrf = new LaReferenciaDownloadLogs(ExecuteWorkflow.lareferenciaBaseURL,
ExecuteWorkflow.lareferenciaAuthToken);
logger.info("Downloading LaReferencia logs");
// lrf.GetLaReferenciaRepos(lareferenciaLogPath);
logger.info("Downloaded LaReferencia logs");
2020-10-01 22:24:40 +02:00
LaReferenciaStats lastats = new LaReferenciaStats(ExecuteWorkflow.lareferenciaLogPath);
logger.info("Processing LaReferencia logs");
// lastats.processLogs();
2020-09-19 23:00:59 +02:00
// log.info("LaReferencia logs done");
2020-09-19 23:59:33 +02:00
// IrusStats irusstats = new IrusStats(irusUKBaseURL);
2020-09-13 15:00:40 +02:00
// irusstats.getIrusRRReport(irusUKReportPath);
2020-07-22 18:22:04 +02:00
2020-09-14 19:10:53 +02:00
// irusstats.processIrusStats();
2020-07-22 18:22:04 +02:00
// log.info("irus done");
2020-09-19 23:59:33 +02:00
// SarcStats sarcStats = new SarcStats();
2020-09-19 22:43:07 +02:00
// sarcStats.getAndProcessSarc(sarcsReportPathArray, sarcsReportPathNonArray);
2020-09-19 23:59:33 +02:00
// sarcStats.finalizeSarcStats();
2020-09-19 22:43:07 +02:00
// log.info("sarc done");
2020-07-22 18:22:04 +02:00
// // finalize usagestats
// piwikstatsdb.finalizeStats();
// log.info("finalized stats");
}
}