/** * @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; }