use of com.hack23.cia.model.external.worldbank.data.impl.Indicator in project cia by Hack23.
the class PoliticianDataManagerImpl method addPoliticianIndicatorData.
/**
* Adds the politician indicator data.
*
* @param list
* the list
* @param dataSeries
* the data series
* @param simpleDateFormat
* the simple date format
*/
private static void addPoliticianIndicatorData(final List<ViewRiksdagenVoteDataBallotPoliticianSummaryDaily> list, final DataSeries dataSeries, final SimpleDateFormat simpleDateFormat) {
for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getWonPercentage());
}
}
dataSeries.newSeries();
for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getRebelPercentage());
}
}
dataSeries.newSeries();
for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getPoliticianPercentageAbsent());
}
}
dataSeries.newSeries();
for (final ViewRiksdagenVoteDataBallotPoliticianSummaryDaily viewRiksdagenVoteDataBallotPoliticianSummaryDaily : list) {
if (viewRiksdagenVoteDataBallotPoliticianSummaryDaily != null) {
dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPoliticianSummaryDaily.getNumberBallots());
}
}
}
use of com.hack23.cia.model.external.worldbank.data.impl.Indicator in project cia by Hack23.
the class WorldBankDataWorkGeneratorImpl method generateWorkOrders.
@Override
public void generateWorkOrders() {
final ApplicationConfiguration importDataForCountries = applicationConfigurationService.checkValueOrLoadDefault("Countries to import data from worldbank (isocode) alt comma separated list", "Load worldbank data for countries", ConfigurationGroup.AGENT, WorldBankCountryWorkGeneratorImpl.class.getSimpleName(), "Worldbank country data loading", "Responsible import worldlbank country data", "agent.worldbank.country.data.loadCountries", "SE,NO,DK,FI,GB,US");
final List<IndicatorElement> indicatorlist = getImportService().getAllIndicators();
final Map<String, String> currentSaved = getImportService().getWorldBankDataMap();
for (final String country : getImportService().getWorldBankCountryMap().keySet()) {
if (StringUtils.containsIgnoreCase(importDataForCountries.getPropertyValue(), country)) {
for (final IndicatorElement indicator : indicatorlist) {
sendCountryIndicatorWorkOrder(currentSaved, indicator, country);
}
}
}
}
use of com.hack23.cia.model.external.worldbank.data.impl.Indicator in project cia by Hack23.
the class CountryMenuItemFactoryImpl method addSourcesAndIndicatorsToMenu.
/**
* Adds the sources and indicators to menu.
*
* @param countryIndicators
* the country indicators
* @param sourceIndicatorMap
* the source indicator map
*/
private static void addSourcesAndIndicatorsToMenu(final MenuItem countryIndicators, final Map<String, List<ViewWorldbankIndicatorDataCountrySummary>> sourceIndicatorMap) {
final Map<String, List<ViewWorldbankIndicatorDataCountrySummary>> sortedIndicatorMap = sourceIndicatorMap.entrySet().stream().sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
for (final Entry<String, List<ViewWorldbankIndicatorDataCountrySummary>> entry : sortedIndicatorMap.entrySet()) {
final MenuItem sourceItems = countryIndicators.addItem(entry.getKey(), null, null);
final List<ViewWorldbankIndicatorDataCountrySummary> sortedEntries = entry.getValue().stream().sorted((e1, e2) -> e1.getIndicatorName().compareTo(e2.getIndicatorName())).collect(Collectors.toList());
for (final ViewWorldbankIndicatorDataCountrySummary indciatorSummary : sortedEntries) {
MenuItem addItem = sourceItems.addItem(indciatorSummary.getIndicatorName(), new PageModeMenuCommand(UserViews.COUNTRY_RANKING_VIEW_NAME, PageMode.INDICATORS, indciatorSummary.getEmbeddedId().getIndicatorId()));
addItem.setStyleName("RestrictedHeader");
}
}
}
use of com.hack23.cia.model.external.worldbank.data.impl.Indicator in project cia by Hack23.
the class UserRoleSystemTest method sitePoliticanIndicatorTest.
/**
* Site politican indicator test.
*
* @throws Exception
* the exception
*/
@Test
public void sitePoliticanIndicatorTest() throws Exception {
final WebDriver driver = getWebDriver();
assertNotNull(NO_WEBDRIVER_EXIST_FOR_BROWSER + browser, driver);
final UserPageVisit userPageVisit = new UserPageVisit(driver, browser);
userPageVisit.visitDirectPage(new PageModeMenuCommand(UserViews.POLITICIAN_VIEW_NAME, PageMode.INDICATORS.toString(), "0980681611418"));
}
use of com.hack23.cia.model.external.worldbank.data.impl.Indicator in project cia by Hack23.
the class WorldIndicatorsPageModContentFactoryImpl method createDataIndicatorSummaryChartPanel.
/**
* Creates the data indicator summary chart panel.
*
* @param verticalLayout
* the vertical layout
* @param indicator
* the indicator
*/
private void createDataIndicatorSummaryChartPanel(final VerticalLayout verticalLayout, final String indicator) {
final DataContainer<ViewWorldbankIndicatorDataCountrySummary, WorldbankIndicatorDataCountrySummaryEmbeddedId> indicatorDataCountrSummaryDailyDataContainer = getApplicationManager().getDataContainer(ViewWorldbankIndicatorDataCountrySummary.class);
final Optional<ViewWorldbankIndicatorDataCountrySummary> indicatorSummary = indicatorDataCountrSummaryDailyDataContainer.getAll().parallelStream().filter(t -> t != null && t.getEmbeddedId().getIndicatorId().equals(indicator)).findFirst();
ViewWorldbankIndicatorDataCountrySummary indicatorSummaryValue = null;
if (indicatorSummary.isPresent()) {
indicatorSummaryValue = indicatorSummary.get();
getFormFactory().addFormPanelTextFields(verticalLayout, indicatorSummaryValue, ViewWorldbankIndicatorDataCountrySummary.class, AS_LIST);
}
final DataContainer<WorldBankData, Serializable> dataContainer = getApplicationManager().getDataContainer(WorldBankData.class);
final List<WorldBankData> dataList = dataContainer.findListByEmbeddedProperty(WorldBankData.class, WorldBankData_.indicator, Indicator.class, Indicator_.id, indicator);
chartDataManager.createIndicatorChart(verticalLayout, dataList, indicatorSummaryValue);
}
Aggregations