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
|
|
11
|
public UsageStatsExporter() {
|
12
|
}
|
13
|
|
14
|
//public void export() throws Exception {
|
15
|
public void export() throws Exception {
|
16
|
|
17
|
//read workdflow parameters
|
18
|
Properties prop = new Properties();
|
19
|
InputStream propertiesInputStream = executeWorkflowNew.class.getClassLoader().getResourceAsStream("usagestats.properties");
|
20
|
prop.load(propertiesInputStream);
|
21
|
String matomoAuthToken = prop.getProperty("matomo.AuthToken");
|
22
|
String matomoBaseURL = prop.getProperty("matomo.BaseUrl");
|
23
|
String repoLogPath = prop.getProperty("repo.LogPath");
|
24
|
String portalLogPath = prop.getProperty("portal.LogPath");
|
25
|
String portalMatomoID = prop.getProperty("portal.MatomoID");
|
26
|
String irusUKBaseURL = prop.getProperty("IRUS_UK.BaseUrl");
|
27
|
|
28
|
propertiesInputStream.close();
|
29
|
|
30
|
//connect to DB
|
31
|
ConnectDB connectDB = new ConnectDB();
|
32
|
|
33
|
PiwikDownloadLogs piwd = new PiwikDownloadLogs(matomoBaseURL, matomoAuthToken);
|
34
|
piwd.GetOpenAIRELogs(repoLogPath, portalLogPath, portalMatomoID);
|
35
|
|
36
|
/*
|
37
|
* Create DB tables, insert/update statistics
|
38
|
*/
|
39
|
PiwikStatsDB piwikstatsdb = new PiwikStatsDB(repoLogPath, portalLogPath);
|
40
|
piwikstatsdb.setCounterRobotsURL(prop.getProperty("COUNTER.robots.Url"));
|
41
|
piwikstatsdb.processLogs();
|
42
|
piwikstatsdb.usageStats();
|
43
|
|
44
|
IrusStats irusstats = new IrusStats(irusUKBaseURL);
|
45
|
irusstats.processIrusRRReport();
|
46
|
irusstats.irusStats();
|
47
|
|
48
|
SarcStats sarcStats = new SarcStats();
|
49
|
sarcStats.processSarc();
|
50
|
sarcStats.sarcStats();
|
51
|
|
52
|
//finalize stats
|
53
|
piwikstatsdb.finalizeStats();
|
54
|
|
55
|
}
|
56
|
|
57
|
}
|