1
|
package eu.dnetlib.usagestats.export;
|
2
|
|
3
|
import java.io.InputStream;
|
4
|
import java.util.Properties;
|
5
|
import org.apache.log4j.Logger;
|
6
|
|
7
|
public class UsageStatsExporter {
|
8
|
|
9
|
private Logger log = Logger.getLogger(this.getClass());
|
10
|
private Properties properties;
|
11
|
|
12
|
public UsageStatsExporter(Properties properties) {
|
13
|
this.properties = properties;
|
14
|
}
|
15
|
|
16
|
//public void export() throws Exception {
|
17
|
public void export() throws Exception {
|
18
|
|
19
|
//read workdflow parameters
|
20
|
String matomoAuthToken = properties.getProperty("matomo_AuthToken");
|
21
|
String matomoBaseURL = properties.getProperty("matomo_BaseUrl");
|
22
|
String repoLogPath = properties.getProperty("repo_LogPath");
|
23
|
String portalLogPath = properties.getProperty("portal_LogPath");
|
24
|
String portalMatomoID = properties.getProperty("portal_MatomoID");
|
25
|
String irusUKBaseURL = properties.getProperty("IRUS_UK_BaseUrl");
|
26
|
|
27
|
//connect to DB
|
28
|
ConnectDB.init(properties);
|
29
|
|
30
|
PiwikDownloadLogs piwd = new PiwikDownloadLogs(matomoBaseURL, matomoAuthToken);
|
31
|
piwd.GetOpenAIRELogs(repoLogPath, portalLogPath, portalMatomoID);
|
32
|
|
33
|
/*
|
34
|
* Create DB tables, insert/update statistics
|
35
|
*/
|
36
|
PiwikStatsDB piwikstatsdb = new PiwikStatsDB(repoLogPath, portalLogPath);
|
37
|
piwikstatsdb.setCounterRobotsURL(properties.getProperty("COUNTER_robots_Url"));
|
38
|
piwikstatsdb.processLogs();
|
39
|
log.info("process logs done");
|
40
|
|
41
|
IrusStats irusstats = new IrusStats(irusUKBaseURL);
|
42
|
irusstats.processIrusRRReport();
|
43
|
irusstats.irusStats();
|
44
|
log.info("irus done");
|
45
|
|
46
|
SarcStats sarcStats = new SarcStats();
|
47
|
sarcStats.processSarc();
|
48
|
sarcStats.sarcStats();
|
49
|
log.info("sarc done");
|
50
|
|
51
|
//finalize usagestats
|
52
|
piwikstatsdb.finalizeStats();
|
53
|
log.info("finalized stats");
|
54
|
}
|
55
|
}
|