1 |
54525
|
panagiotis
|
package eu.dnetlib.repo.manager.service;
|
2 |
53003
|
panagiotis
|
|
3 |
54840
|
panagiotis
|
import eu.dnetlib.repo.manager.service.customHystrixCommands.*;
|
4 |
54745
|
panagiotis
|
import org.springframework.beans.factory.annotation.Autowired;
|
5 |
53003
|
panagiotis
|
import org.springframework.beans.factory.annotation.Value;
|
6 |
54525
|
panagiotis
|
import org.springframework.stereotype.Service;
|
7 |
53003
|
panagiotis
|
import org.springframework.web.client.RestTemplate;
|
8 |
|
|
|
9 |
|
|
import java.util.HashMap;
|
10 |
|
|
import java.util.Map;
|
11 |
|
|
|
12 |
54525
|
panagiotis
|
@Service("statsService")
|
13 |
54690
|
panagiotis
|
public class StatsServiceImpl implements StatsService {
|
14 |
53003
|
panagiotis
|
|
15 |
54840
|
panagiotis
|
@Autowired
|
16 |
|
|
RestTemplate restTemplate;
|
17 |
53003
|
panagiotis
|
|
18 |
|
|
@Value("${search.api.baseAddress}")
|
19 |
|
|
private String baseAddress;
|
20 |
53050
|
panagiotis
|
@Value("${search.api.usagestats}")
|
21 |
|
|
private String usagestatsBaseAddress;
|
22 |
53933
|
panagiotis
|
@Value("${search.api.usageEvents}")
|
23 |
|
|
private String usagestatsEvents;
|
24 |
|
|
|
25 |
53003
|
panagiotis
|
@Override
|
26 |
54840
|
panagiotis
|
public Map getStatistics() {
|
27 |
53003
|
panagiotis
|
|
28 |
54840
|
panagiotis
|
UsageStatsTotalHystrixCommand usageStatsTotalHystrixCommand = new UsageStatsTotalHystrixCommand(usagestatsEvents,restTemplate);
|
29 |
|
|
DataRepositoriesHystrixCommand dataRepositoriesHystrixCommand = new DataRepositoriesHystrixCommand(baseAddress,restTemplate);
|
30 |
|
|
AggregatorsHystrixCommand aggregatorsHystrixCommand = new AggregatorsHystrixCommand(baseAddress,restTemplate);
|
31 |
|
|
LiteratureHystrixCommand literatureHystrixCommand = new LiteratureHystrixCommand(baseAddress,restTemplate);
|
32 |
|
|
JournalHystrixCommand journalHystrixCommand = new JournalHystrixCommand(baseAddress,restTemplate);
|
33 |
|
|
PublicationHystrixCommand publicationHystrixCommand = new PublicationHystrixCommand(baseAddress,restTemplate);
|
34 |
|
|
DatasetsHystrixCommand datasetsHystrixCommand = new DatasetsHystrixCommand(baseAddress,restTemplate);
|
35 |
|
|
SoftwareHystrixCommand softwareHystrixCommand = new SoftwareHystrixCommand(baseAddress,restTemplate);
|
36 |
|
|
LastYearUsageStatsHystrixCommand lastYearUsageStatsHystrixCommand = new LastYearUsageStatsHystrixCommand(usagestatsBaseAddress,restTemplate);
|
37 |
53003
|
panagiotis
|
|
38 |
54745
|
panagiotis
|
Map<String,Object> stats = new HashMap<>();
|
39 |
54840
|
panagiotis
|
stats.put("aggregators",aggregatorsHystrixCommand.execute());
|
40 |
|
|
stats.put("dataRepositories",dataRepositoriesHystrixCommand.execute());
|
41 |
|
|
stats.put("literature",literatureHystrixCommand.execute());
|
42 |
|
|
stats.put("journal",journalHystrixCommand.execute());
|
43 |
|
|
stats.put("publications",publicationHystrixCommand.execute());
|
44 |
|
|
stats.put("datasets",datasetsHystrixCommand.execute());
|
45 |
|
|
stats.put("software",softwareHystrixCommand.execute());
|
46 |
|
|
stats.put("lastYearUsagestats", lastYearUsageStatsHystrixCommand.execute());
|
47 |
|
|
stats.put("usagestats",usageStatsTotalHystrixCommand.execute());
|
48 |
53003
|
panagiotis
|
return stats;
|
49 |
|
|
}
|
50 |
|
|
}
|