use of org.orcid.jaxb.model.statistics.StatisticsSummary in project ORCID-Source by ORCID.
the class StatisticsManagerReadOnlyImpl method getLatestStatisticsModel.
/**
* Get the list of the latest statistics as a domain model
*
* @return a list that contains the latest set of statistics
*/
@Override
public StatisticsSummary getLatestStatisticsModel() {
StatisticKeyEntity latestKey = statisticsDaoReadOnly.getLatestKey();
if (latestKey == null)
return null;
List<StatisticValuesEntity> list = statisticsDaoReadOnly.getStatistic(latestKey.getId());
if (list == null || list.size() == 0)
return null;
// convert to model
StatisticsSummary summary = new StatisticsSummary();
Map<String, Long> map = new TreeMap<String, Long>();
for (StatisticValuesEntity entry : list) {
map.put(entry.getStatisticName(), entry.getStatisticValue());
}
summary.setStatistics(map);
summary.setDate(latestKey.getGenerationDate());
return summary;
}
use of org.orcid.jaxb.model.statistics.StatisticsSummary in project ORCID-Source by ORCID.
the class StatsApiServiceBaseImplTest method testViewStatsSummary.
@Test
public void testViewStatsSummary() {
assertEquals(200, serviceDelegator.getStatsSummary().getStatus());
StatisticsSummary s = (StatisticsSummary) serviceDelegator.getStatsSummary().getEntity();
assertEquals(s.getDate(), new Date(2000, 1, 1));
assertEquals(s.getStatistics().size(), 2);
assertEquals((long) s.getStatistics().get(StatisticsEnum.KEY_LIVE_IDS.value()), 100l);
assertEquals((long) s.getStatistics().get(StatisticsEnum.KEY_NUMBER_OF_WORKS.value()), 102l);
}
use of org.orcid.jaxb.model.statistics.StatisticsSummary in project ORCID-Source by ORCID.
the class StatisticsCacheManagerImpl method retrieveLiveIds.
@Override
public String retrieveLiveIds(Locale locale) {
StatisticsSummary statisticsSummary = retrieve();
if (statisticsSummary == null || statisticsSummary.getStatistics() == null || statisticsSummary.getStatistics().get(StatisticsEnum.KEY_LIVE_IDS.value()) == null) {
return "0";
}
Long amount = statisticsSummary.getStatistics().get(StatisticsEnum.KEY_LIVE_IDS.value());
NumberFormat nf = NumberFormat.getInstance(locale);
return nf.format(amount);
}
use of org.orcid.jaxb.model.statistics.StatisticsSummary in project ORCID-Source by ORCID.
the class StatsApiServiceDelegatorImpl method getAllStatsTimelines.
@Override
@AccessControl(requiredScope = ScopePathType.READ_PUBLIC, enableAnonymousAccess = true)
public Response getAllStatsTimelines() {
StatisticsSummary summary = statisticsCacheManager.retrieve();
if (summary == null)
return Response.status(Status.NOT_FOUND).build();
StatsTimelineList statsTimelines = new StatsTimelineList();
for (String key : summary.getStatistics().keySet()) {
StatisticsTimeline timeline = statisticsCacheManager.getStatisticsTimelineModel(StatisticsEnum.fromString(key));
if (timeline != null)
statsTimelines.getTimelines().add(timeline);
}
return Response.ok(statsTimelines).build();
}
use of org.orcid.jaxb.model.statistics.StatisticsSummary in project ORCID-Source by ORCID.
the class StatisticsController method getStatistics.
@RequestMapping
public ModelAndView getStatistics() {
ModelAndView mav = new ModelAndView("statistics");
Map<String, Long> statisticsMap = null;
StatisticsSummary statisticsSummary = statisticsCacheManager.retrieve();
if (statisticsSummary != null) {
statisticsMap = statisticsSummary.getStatistics();
mav.addObject("statistics_date", formatStatisticsDate(statisticsSummary.getDate()));
}
if (statisticsMap == null) {
statisticsMap = new HashMap<String, Long>();
}
mav.addObject("statistics", statisticsMap);
return mav;
}
Aggregations