use of com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary in project cia by Hack23.
the class EsvApiImpl method getGovernmentBodyNames.
@Override
public List<String> getGovernmentBodyNames() {
final Set<String> governmentBodyNameSet = new HashSet<>();
final Map<Integer, List<GovernmentBodyAnnualSummary>> data = getData();
for (final List<GovernmentBodyAnnualSummary> list : data.values()) {
for (final GovernmentBodyAnnualSummary governmentBodyAnnualSummary : list) {
if (!governmentBodyNameSet.contains(governmentBodyAnnualSummary.getName()) && governmentBodyAnnualSummary.getHeadCount() > 0) {
governmentBodyNameSet.add(governmentBodyAnnualSummary.getName());
}
}
}
return new ArrayList<>(governmentBodyNameSet);
}
use of com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary in project cia by Hack23.
the class EsvApiImpl method getGovernmentBodyNames.
@Override
public List<String> getGovernmentBodyNames(final String ministry) {
Map<String, Set<String>> governmentBodyNameSetMinistryMap = new HashMap<>();
final Set<String> governmentBodyNameSetMapEntry = new HashSet<>();
governmentBodyNameSetMinistryMap.put(ministry, governmentBodyNameSetMapEntry);
final Map<Integer, List<GovernmentBodyAnnualSummary>> data = getData();
for (final List<GovernmentBodyAnnualSummary> list : data.values()) {
for (final GovernmentBodyAnnualSummary governmentBodyAnnualSummary : list) {
if (ministry.equalsIgnoreCase(governmentBodyAnnualSummary.getMinistry()) && !governmentBodyNameSetMapEntry.contains(governmentBodyAnnualSummary.getName()) && governmentBodyAnnualSummary.getHeadCount() > 0) {
governmentBodyNameSetMapEntry.add(governmentBodyAnnualSummary.getName());
}
}
}
return new ArrayList<>(governmentBodyNameSetMinistryMap.get(ministry));
}
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 String name) {
final Map<Integer, List<GovernmentBodyAnnualSummary>> map = esvApi.getDataPerMinistry(name);
final List<String> governmentBodyNames = esvApi.getGovernmentBodyNames(name);
final DataSeries dataSeries = new DataSeries();
final Series series = new Series();
for (final String govBodyName : governmentBodyNames) {
series.addSeries(new XYseries().setLabel(govBodyName));
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.getName().equalsIgnoreCase(govBodyName)).mapToInt(GovernmentBodyAnnualSummary::getHeadCount).sum();
if (entry.getKey() != null && totalHeadcount > 0) {
dataSeries.add(FIRST_OF_JAN + entry.getKey(), totalHeadcount);
}
}
}
addChart(content, name + ANNUAL_HEADCOUNT_SUMMARY_ALL_GOVERNMENT_BODIES, new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(), true);
}
use of com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary in project cia by Hack23.
the class EsvExcelReaderImpl method getDataPerGovernmentBody.
@Override
public Map<Integer, GovernmentBodyAnnualSummary> getDataPerGovernmentBody(final String name) {
final Map<Integer, GovernmentBodyAnnualSummary> map = new TreeMap<>();
try {
final HSSFWorkbook myWorkBook = createGovermentBodyWorkBook();
for (int sheetNr = 0; sheetNr < myWorkBook.getNumberOfSheets(); sheetNr++) {
final HSSFSheet mySheet = myWorkBook.getSheetAt(sheetNr);
addDataForYearToMap(name, map, mySheet);
}
myWorkBook.close();
} catch (final IOException e) {
LOGGER.warn("Problem loading", e);
}
return map;
}
use of com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary in project cia by Hack23.
the class EsvApiTest method getDataDefenceMinistrySuccessTest.
/**
* Gets the data defence ministry success test.
*
* @return the data defence ministry success test
*/
@Test
public void getDataDefenceMinistrySuccessTest() {
final Map<Integer, List<GovernmentBodyAnnualSummary>> governmentBodyAnnualSummaryData = esvApi.getDataPerMinistry("Försvarsdepartementet");
assertNotNull(governmentBodyAnnualSummaryData);
assertEquals(20, governmentBodyAnnualSummaryData.size());
for (final List<GovernmentBodyAnnualSummary> list : governmentBodyAnnualSummaryData.values()) {
for (final GovernmentBodyAnnualSummary governmentBodyAnnualSummary : list) {
assertNotNull(governmentBodyAnnualSummary);
}
}
}
Aggregations