Search in sources :

Example 6 with DataFailureException

use of com.hack23.cia.service.external.riksdagen.api.DataFailureException 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

DataFailureException (com.hack23.cia.service.external.riksdagen.api.DataFailureException)3 DataFailureException (com.hack23.cia.service.external.worldbank.api.DataFailureException)3 IndicatorElement (com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement)2 XmlAgentException (com.hack23.cia.service.external.common.api.XmlAgentException)2 ArrayList (java.util.ArrayList)2 PersonElement (com.hack23.cia.model.external.riksdagen.personlista.impl.PersonElement)1 BallotContainer (com.hack23.cia.model.external.riksdagen.votering.impl.BallotContainer)1 VoteData (com.hack23.cia.model.external.riksdagen.votering.impl.VoteData)1 VoteDataDto (com.hack23.cia.model.external.riksdagen.votering.impl.VoteDataDto)1 VoteDataEmbeddedId (com.hack23.cia.model.external.riksdagen.votering.impl.VoteDataEmbeddedId)1 BallotDocumentElement (com.hack23.cia.model.external.riksdagen.voteringlista.impl.BallotDocumentElement)1 CountryElement (com.hack23.cia.model.external.worldbank.countries.impl.CountryElement)1 IndicatorsElement (com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorsElement)1 ParseException (java.text.ParseException)1 Date (java.util.Date)1