/** * @param aggregatedVoteE * @return */ public static Vote aggregatedVoteEntityToVoteMessage(AggregatedVoteE aggregatedVoteE) { // basic mapping for general vote entities Vote vote = voteEntityToVoteMessage(aggregatedVoteE); // map additional specific base attributes vote.setAggregation(true); if (aggregatedVoteE.getAggregationType() != null) { vote.setAggregationType(aggregatedVoteE.getAggregationType()); } else { log.error("Required attribute 'aggregationType' missing"); return null; } if (aggregatedVoteE.getClusterId() != null) { vote.setClusterId(aggregatedVoteE.getClusterId()); } else { log.error("Required attribute 'clusterId' missing"); return null; } // generate url links vote.setConfigurationUrl(genConfigUrl(aggregatedVoteE)); vote.setVoteUrl(genUrl(aggregatedVoteE)); vote.setEvaluationUrl(EvaluationMapper.genUrl(aggregatedVoteE.getAggregatorEvaluation())); return vote; }
/** * @param singleVoteE is an single vote entity * @return the url of the single vote resource */ public static String genUrl(AggregatedVoteE aggregatedVote) { String url = CVSrvContext.getInstance().getValuationServerUrlBase() + CVSrvContext.VOTE_BASE_URL_PREFIX + CVSrvContext.AGGREGATED_VOTE_URL_PREFIX + String.valueOf(aggregatedVote.getAggregatorEvaluation().getId()) + "/" + String.valueOf(aggregatedVote.getId()); return url; }
/** * @param voteEList * @return */ public static Votes aggregatedVoteEntitiesToVotes(List<AggregatedVoteE> voteEList) { if (voteEList == null) { log.error("Mapping request FOR null object"); return null; } Votes votes = new Votes(); for (AggregatedVoteE aggregatedVoteE : voteEList) { Votes.VoteEntry voteEntry = new Votes.VoteEntry(); voteEntry.setVoteId(String.valueOf(aggregatedVoteE.getId())); voteEntry.setVoteUrl(genUrl(aggregatedVoteE)); votes.getVoteEntry().add(voteEntry); } return votes; }