Search in sources :

Example 1 with GovernmentBodyAnnualSummary

use of com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary in project cia by Hack23.

the class GovernmentBodyChartDataManagerImpl method createMinistryGovernmentBodyHeadcountSummaryChart.

@Override
public void createMinistryGovernmentBodyHeadcountSummaryChart(final AbstractOrderedLayout content) {
    final Map<Integer, List<GovernmentBodyAnnualSummary>> map = esvApi.getData();
    final List<String> ministryNames = esvApi.getMinistryNames();
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    for (final String ministryName : ministryNames) {
        series.addSeries(new XYseries().setLabel(ministryName));
        dataSeries.newSeries();
        for (final Entry<Integer, List<GovernmentBodyAnnualSummary>> entry : map.entrySet()) {
            final List<GovernmentBodyAnnualSummary> item = entry.getValue();
            final Integer totalHeadcount = item.stream().filter((final GovernmentBodyAnnualSummary p) -> p.getMinistry().equalsIgnoreCase(ministryName)).mapToInt(GovernmentBodyAnnualSummary::getHeadCount).sum();
            if (entry.getKey() != null && totalHeadcount > 0) {
                dataSeries.add(FIRST_OF_JAN + entry.getKey(), totalHeadcount);
            }
        }
    }
    addChart(content, ANNUAL_HEADCOUNT_ALL_MINISTRIES, new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) List(java.util.List) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) GovernmentBodyAnnualSummary(com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary) DCharts(org.dussan.vaadin.dcharts.DCharts) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries)

Example 2 with GovernmentBodyAnnualSummary

use of com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary in project cia by Hack23.

the class EsvApiTest method getDataFinanceMinistry2016SuccessTest.

/**
 * Gets the data finance ministry 2016 success test.
 *
 * @return the data finance ministry 2016 success test
 */
@Test
public void getDataFinanceMinistry2016SuccessTest() {
    final List<GovernmentBodyAnnualSummary> list = esvApi.getDataPerMinistryAndYear("Finansdepartementet", 2016);
    assertNotNull(list);
    assertEquals(45, list.size());
    for (final GovernmentBodyAnnualSummary governmentBodyAnnualSummary : list) {
        assertNotNull(governmentBodyAnnualSummary);
    }
}
Also used : GovernmentBodyAnnualSummary(com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary) Test(org.junit.Test)

Example 3 with GovernmentBodyAnnualSummary

use of com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary in project cia by Hack23.

the class EsvApiTest method getDataPerGovernmentBodySuccessTest.

/**
 * Gets the data per government body success test.
 *
 * @return the data per government body success test
 */
@Test
public void getDataPerGovernmentBodySuccessTest() {
    final Map<Integer, GovernmentBodyAnnualSummary> governmentBodyAnnualSummaryData = esvApi.getDataPerGovernmentBody("Exportkreditnämnden");
    assertNotNull(governmentBodyAnnualSummaryData);
    assertEquals(20, governmentBodyAnnualSummaryData.size());
    for (final GovernmentBodyAnnualSummary governmentBodyAnnualSummary : governmentBodyAnnualSummaryData.values()) {
        assertNotNull(governmentBodyAnnualSummary);
    }
}
Also used : GovernmentBodyAnnualSummary(com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary) Test(org.junit.Test)

Example 4 with GovernmentBodyAnnualSummary

use of com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary in project cia by Hack23.

the class EsvApiTest method getDataSuccessTest.

/**
 * Gets the data success test.
 *
 * @return the data success test
 */
@Test
public void getDataSuccessTest() {
    final Map<Integer, List<GovernmentBodyAnnualSummary>> governmentBodyAnnualSummaryData = esvApi.getData();
    assertNotNull(governmentBodyAnnualSummaryData);
    assertEquals(20, governmentBodyAnnualSummaryData.size());
    for (final List<GovernmentBodyAnnualSummary> list : governmentBodyAnnualSummaryData.values()) {
        // assertTrue(list.size() > 200);
        for (final GovernmentBodyAnnualSummary governmentBodyAnnualSummary : list) {
            assertNotNull(governmentBodyAnnualSummary);
        }
    }
}
Also used : List(java.util.List) GovernmentBodyAnnualSummary(com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary) Test(org.junit.Test)

Example 5 with GovernmentBodyAnnualSummary

use of com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary in project cia by Hack23.

the class EsvApiTest method getDataFinanceMinistrySuccessTest.

/**
 * Gets the data finance ministry success test.
 *
 * @return the data finance ministry success test
 */
@Test
public void getDataFinanceMinistrySuccessTest() {
    final Map<Integer, List<GovernmentBodyAnnualSummary>> governmentBodyAnnualSummaryData = esvApi.getDataPerMinistry("Finansdepartementet");
    assertNotNull(governmentBodyAnnualSummaryData);
    assertEquals(20, governmentBodyAnnualSummaryData.size());
    for (final List<GovernmentBodyAnnualSummary> list : governmentBodyAnnualSummaryData.values()) {
        for (final GovernmentBodyAnnualSummary governmentBodyAnnualSummary : list) {
            assertNotNull(governmentBodyAnnualSummary);
        }
    }
}
Also used : List(java.util.List) GovernmentBodyAnnualSummary(com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary) Test(org.junit.Test)

Aggregations

GovernmentBodyAnnualSummary (com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary)14 List (java.util.List)9 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 DCharts (org.dussan.vaadin.dcharts.DCharts)2 XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)2 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)2 Series (org.dussan.vaadin.dcharts.options.Series)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 HSSFSheet (org.apache.poi.hssf.usermodel.HSSFSheet)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1