Search in sources :

Example 1 with StatisticsSummary

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;
}
Also used : StatisticValuesEntity(org.orcid.statistics.jpa.entities.StatisticValuesEntity) StatisticsSummary(org.orcid.jaxb.model.statistics.StatisticsSummary) StatisticKeyEntity(org.orcid.statistics.jpa.entities.StatisticKeyEntity) TreeMap(java.util.TreeMap)

Example 2 with StatisticsSummary

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);
}
Also used : StatisticsSummary(org.orcid.jaxb.model.statistics.StatisticsSummary) Date(java.util.Date) Test(org.junit.Test)

Example 3 with StatisticsSummary

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);
}
Also used : StatisticsSummary(org.orcid.jaxb.model.statistics.StatisticsSummary) NumberFormat(java.text.NumberFormat)

Example 4 with StatisticsSummary

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();
}
Also used : StatsTimelineList(org.orcid.api.common.writer.stats.StatsTimelineList) StatisticsSummary(org.orcid.jaxb.model.statistics.StatisticsSummary) StatisticsTimeline(org.orcid.jaxb.model.statistics.StatisticsTimeline) AccessControl(org.orcid.core.security.visibility.aop.AccessControl)

Example 5 with StatisticsSummary

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;
}
Also used : StatisticsSummary(org.orcid.jaxb.model.statistics.StatisticsSummary) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

StatisticsSummary (org.orcid.jaxb.model.statistics.StatisticsSummary)6 NumberFormat (java.text.NumberFormat)1 Date (java.util.Date)1 TreeMap (java.util.TreeMap)1 Element (net.sf.ehcache.Element)1 Test (org.junit.Test)1 StatsTimelineList (org.orcid.api.common.writer.stats.StatsTimelineList)1 AccessControl (org.orcid.core.security.visibility.aop.AccessControl)1 StatisticsTimeline (org.orcid.jaxb.model.statistics.StatisticsTimeline)1 StatisticKeyEntity (org.orcid.statistics.jpa.entities.StatisticKeyEntity)1 StatisticValuesEntity (org.orcid.statistics.jpa.entities.StatisticValuesEntity)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1