use of com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement 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.indicators.impl.IndicatorElement in project cia by Hack23.
the class WorldBankIndicatorWorkGeneratorImpl method generateWorkOrders.
@Override
public void generateWorkOrders() {
try {
final List<IndicatorElement> list = worldbankIndicatorApi.getIndicators();
final Map<String, String> currentSaved = getImportService().getWorldBankIndicatorElementMap();
for (final IndicatorElement element : list) {
if (!currentSaved.containsKey(element.getId())) {
getJmsSender().send(indicatorElementWorkdestination, element);
}
}
} catch (final DataFailureException exception) {
LOGGER.warn("jms", exception);
}
}
use of com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement in project cia by Hack23.
the class WorldbankIndicatorApiImpl method getIndicators.
/* (non-Javadoc)
* @see com.hack23.cia.service.external.worldbank.api.WorldBankIndicatorApi#getIndicators()
*/
@Override
public List<IndicatorElement> getIndicators() throws DataFailureException {
final List<IndicatorElement> result = new ArrayList<>();
try {
final IndicatorsElement firstPage = (IndicatorsElement) getXmlAgent().unmarshallXml(indicatorsUnmarshaller, INDICATORS, null, XMLNS_WB_HTTP_WWW_WORLDBANK_ORG, XMLNS_WB_HTTP_INDICATORS_WORLDBANK_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL);
result.addAll(firstPage.getIndicator());
for (int pageNumber = SECOND_PAGE; pageNumber < firstPage.getPages().intValue(); pageNumber++) {
final IndicatorsElement otherPageResult = (IndicatorsElement) getXmlAgent().unmarshallXml(indicatorsUnmarshaller, INDICATORS + PAGE_NUMBER + pageNumber, null, XMLNS_WB_HTTP_WWW_WORLDBANK_ORG, XMLNS_WB_HTTP_INDICATORS_WORLDBANK_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL);
result.addAll(otherPageResult.getIndicator());
}
} catch (final XmlAgentException e) {
LOGGER.warn(PROBLEM_GETTING_WORLDBANK_INDICATOR_LIST);
throw new DataFailureException(e);
}
return result;
}
use of com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement in project cia by Hack23.
the class WorldbankIndicatorElementWorkConsumerImplITest method onMessageSuccessTest.
/**
* On message success test.
*
* @throws JMSException
* the JMS exception
*/
@Test
@Transactional
public void onMessageSuccessTest() throws JMSException {
final ObjectMessage message = mock(ObjectMessage.class);
when(message.getObject()).thenReturn(new IndicatorElement());
messsageListener.onMessage(message);
verify(message, atLeastOnce()).getObject();
}
Aggregations