use of com.hack23.cia.model.external.riksdagen.votering.impl.VoteData in project cia by Hack23.
the class RiksdagenBallotApiImpl method checkSameDate.
/**
* Check same date.
*
* @param voteList
* the vote list
* @return the date
* @throws ParseException
* the parse exception
*/
private static Date checkSameDate(final List<VoteDataDto> voteList) throws ParseException {
final Set<String> set = new HashSet<>();
Date result = null;
for (final VoteDataDto voteData : voteList) {
final String voteDate = voteData.getVoteDate();
if (voteDate != null && voteDate.length() >= YYYY_MM_DD.length()) {
set.add(voteData.getVoteDate());
}
}
if (set.size() == CONTAINS_ONE) {
final String dateString = set.iterator().next();
result = new SimpleDateFormat(YYYY_MM_DD, Locale.ENGLISH).parse(dateString);
}
return result;
}
use of com.hack23.cia.model.external.riksdagen.votering.impl.VoteData 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);
}
}
use of com.hack23.cia.model.external.riksdagen.votering.impl.VoteData in project cia by Hack23.
the class RiksdagenBallotApiImplITest method getBallotTest.
/**
* Gets the ballot test.
*
* @return the ballot test
* @throws Exception
* the exception
*/
@Test
public void getBallotTest() throws Exception {
final List<VoteData> votering = riksdagenApi.getBallot("E0B34EE1-3FD3-474A-81D7-781B04BB241E");
assertNotNull(votering);
final VoteData voteData = votering.iterator().next();
assertNotNull(voteData.getEmbeddedId());
assertNotNull(voteData.getEmbeddedId().getBallotId());
assertNotNull(voteData.getEmbeddedId().getIntressentId());
assertNotNull(voteData.getEmbeddedId().getIssue());
}
Aggregations