Search in sources :

Example 1 with IndicatorsElement

use of com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorsElement 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)

Aggregations

IndicatorElement (com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement)1 IndicatorsElement (com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorsElement)1 XmlAgentException (com.hack23.cia.service.external.common.api.XmlAgentException)1 DataFailureException (com.hack23.cia.service.external.worldbank.api.DataFailureException)1 ArrayList (java.util.ArrayList)1