use of com.hack23.cia.service.external.worldbank.api.DataFailureException in project cia by Hack23.
the class RiksdagenPersonsWorkGeneratorImpl method generateWorkOrders.
@Override
public void generateWorkOrders() {
try {
final List<PersonElement> personList = riksdagenApi.getPersonList().getPerson();
final Map<String, String> currentSaved = getImportService().getPersonMap();
for (final PersonElement personElement : personList) {
if (!currentSaved.containsKey(personElement.getId())) {
LOGGER.info("Send Load Order:{}", personElement.getPersonUrlXml());
getJmsSender().send(personElementWorkdestination, personElement);
currentSaved.put(personElement.getId(), personElement.getId());
}
}
for (final String personId : readMissingPersonList()) {
if (!currentSaved.containsKey(personId)) {
LOGGER.info("Send Load Order:{}{}", "https://data.riksdagen.se/person/", personId);
getJmsSender().send(personElementWorkdestination, new PersonElement().withId(personId));
}
}
} catch (final DataFailureException exception) {
LOGGER.warn("Problem during generate work orders", exception);
}
}
use of com.hack23.cia.service.external.worldbank.api.DataFailureException in project cia by Hack23.
the class WorldBankCountryWorkGeneratorImpl method generateWorkOrders.
@Override
public void generateWorkOrders() {
try {
final List<CountryElement> countryList = worldbankCountryApi.getCountries();
final Map<String, String> currentSaved = getImportService().getWorldBankCountryMap();
for (final CountryElement countryElement : countryList) {
if (countryElement.getCapitalCity() != null && countryElement.getCapitalCity().length() > 0 && !currentSaved.containsKey(countryElement.getIso2Code())) {
getJmsSender().send(countryElementWorkdestination, countryElement);
}
}
} catch (final DataFailureException exception) {
LOGGER.warn("jms", exception);
}
}
use of com.hack23.cia.service.external.worldbank.api.DataFailureException 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.service.external.worldbank.api.DataFailureException in project cia by Hack23.
the class RiksdagenBallotListWorkGeneratorImpl method generateWorkOrders.
@Override
public void generateWorkOrders() {
try {
final List<BallotDocumentElement> ballotList = riksdagenApi.getBallotList();
final Map<String, String> alreadySavedIdMap = getImportService().getLoadedBallotIdMap();
for (final BallotDocumentElement ballotDocument : ballotList) {
if (!alreadySavedIdMap.containsKey(ballotDocument.getBallotId())) {
getJmsSender().send(voteDataWorkdestination, ballotDocument.getBallotId());
LOGGER.info("Load : https://data.riksdagen.se/votering/{}", ballotDocument.getBallotId());
}
}
} catch (final DataFailureException e) {
LOGGER.warn("Loadin ballots", e);
}
}
use of com.hack23.cia.service.external.worldbank.api.DataFailureException in project cia by Hack23.
the class RiksdagenBallotApiImpl method getBallot.
@Override
public List<VoteData> getBallot(final String id) throws DataFailureException {
final String url = BALLOT.replace(ID_KEY, id);
final BallotContainer ballotContainer;
try {
ballotContainer = ((JAXBElement<BallotContainer>) xmlAgent.unmarshallXml(riksdagenBallotMarshaller, url, HTTP_VOTERING_RIKSDAGEN_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL, null, null)).getValue();
final List<VoteDataDto> voteDataList = ballotContainer.getBallotDocumentData().getVoteDataList();
final Date ballotDate = tryToFindValidVoteDate(ballotContainer, voteDataList);
final List<VoteData> result = new ArrayList<>();
for (final VoteDataDto voteDataDto : voteDataList) {
final VoteData voteData = new VoteData().withEmbeddedId(new VoteDataEmbeddedId().withBallotId(voteDataDto.getBallotId()).withIntressentId(voteDataDto.getIntressentId()).withIssue(voteDataDto.getIssue()).withConcern(voteDataDto.getConcern()));
voteData.setBankNumber(voteDataDto.getBankNumber());
voteData.setLabel(voteDataDto.getLabel());
voteData.setLastName(voteDataDto.getLastName());
voteData.setBornYear(voteDataDto.getBornYear());
voteData.setFirstName(voteDataDto.getFirstName());
voteData.setPlace(voteDataDto.getPlace());
voteData.setGender(voteDataDto.getGender());
voteData.setFullName(voteDataDto.getFullName());
voteData.setParty(voteDataDto.getParty().toUpperCase(Locale.ENGLISH));
voteData.setRm(voteDataDto.getRm());
voteData.setVote(voteDataDto.getVote());
voteData.setBallotType(voteDataDto.getBallotType());
voteData.setElectoralRegionNumber(voteDataDto.getElectoralRegionNumber());
voteData.setElectoralRegion(voteDataDto.getElectoralRegion());
voteData.setVoteDate(ballotDate);
result.add(voteData);
}
return result;
} catch (final XmlAgentException | ParseException e) {
LOGGER.warn(PROBLEM_GETTING_BALLOT_ID_S_FROM_DATA_RIKSDAGEN_SE, id);
throw new DataFailureException(e);
}
}
Aggregations