service.external.riksdagen/src/main/java/com/hack23/cia/service/external/riksdagen/impl/RiksdagenBallotApiImpl.java
@Override
	public List<VoteData> getBallot(final String id) throws DataFailureException {
		final String url = BALLOT.replace(ID_KEY, id);

		try {
			final BallotContainer ballotContainer = ((JAXBElement<BallotContainer>) xmlAgent.unmarshallXml(
					riksdagenBallotMarshaller, url,
					HTTP_VOTERING_RIKSDAGEN_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL,null,null))
					.getValue();

			final List<VoteData> result = new ArrayList<>();
			if (ballotContainer != null && ballotContainer.getBallotDocumentData() != null) {
				
				final List<VoteDataDto> voteDataList = ballotContainer.getBallotDocumentData().getVoteDataList();				
				final Date ballotDate=riksdagenDateUtil.tryToFindValidVoteDate(ballotContainer, voteDataList);
				
				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);
		}



	}
@Override
	public List<VoteData> getBallot(final String id) throws DataFailureException {
		final String url = BALLOT.replace(ID_KEY, id);

		try {
			final BallotContainer ballotContainer = ((JAXBElement<BallotContainer>) xmlAgent.unmarshallXml(
					riksdagenBallotMarshaller, url,
					HTTP_VOTERING_RIKSDAGEN_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL,null,null))
					.getValue();

			final List<VoteData> result = new ArrayList<>();
			if (ballotContainer != null && ballotContainer.getBallotDocumentData() != null) {
				
				final List<VoteDataDto> voteDataList = ballotContainer.getBallotDocumentData().getVoteDataList();				
				final Date ballotDate=riksdagenDateUtil.tryToFindValidVoteDate(ballotContainer, voteDataList);
				
				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);
		}



	}
@ Override public List < VoteData > getBallot ( final String id ) throws DataFailureException { final String url = BALLOT . replace ( ID_KEY , id ) ; try { final BallotContainer ballotContainer = ( ( JAXBElement < BallotContainer > ) xmlAgent . unmarshallXml ( riksdagenBallotMarshaller , url , HTTP_VOTERING_RIKSDAGEN_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL , null , null ) ) . getValue ( ) ; final List < VoteData > result = new ArrayList <> ( ) ; if ( ballotContainer != null && ballotContainer . getBallotDocumentData ( ) != null ) { final List < VoteDataDto > voteDataList = ballotContainer . getBallotDocumentData ( ) . getVoteDataList ( ) ; final Date ballotDate = riksdagenDateUtil . tryToFindValidVoteDate ( ballotContainer , voteDataList ) ; 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 ) ; } }
/* (non-Javadoc)
@see com.hack23.cia.service.external.riksdagen.api.RiksdagenBallotApi#getBallot(java.lang.String)
/ * ( non - Javadoc )