Search in sources :

Example 1 with IndicatorElement

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);
            }
        }
    }
}
Also used : ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration) IndicatorElement(com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement)

Example 2 with IndicatorElement

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);
    }
}
Also used : DataFailureException(com.hack23.cia.service.external.worldbank.api.DataFailureException) IndicatorElement(com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement)

Example 3 with IndicatorElement

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;
}
Also used : IndicatorsElement(com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorsElement) DataFailureException(com.hack23.cia.service.external.worldbank.api.DataFailureException) ArrayList(java.util.ArrayList) IndicatorElement(com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement) XmlAgentException(com.hack23.cia.service.external.common.api.XmlAgentException)

Example 4 with IndicatorElement

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();
}
Also used : ObjectMessage(javax.jms.ObjectMessage) IndicatorElement(com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement) Test(org.junit.Test) AbstractServiceComponentAgentFunctionalIntegrationTest(com.hack23.cia.service.component.agent.impl.AbstractServiceComponentAgentFunctionalIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IndicatorElement (com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement)4 DataFailureException (com.hack23.cia.service.external.worldbank.api.DataFailureException)2 IndicatorsElement (com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorsElement)1 ApplicationConfiguration (com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)1 AbstractServiceComponentAgentFunctionalIntegrationTest (com.hack23.cia.service.component.agent.impl.AbstractServiceComponentAgentFunctionalIntegrationTest)1 XmlAgentException (com.hack23.cia.service.external.common.api.XmlAgentException)1 ArrayList (java.util.ArrayList)1 ObjectMessage (javax.jms.ObjectMessage)1 Test (org.junit.Test)1 Transactional (org.springframework.transaction.annotation.Transactional)1