/** Create a rating for the node with id 'nodeId'. */ @Override @WebApiDescription(title = "Rate a node for 'nodeId'.") @WebApiParam( name = "ratingEntity", title = "A single rating", description = "A single node rating, multiple ratings are not supported.", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT, allowMultiple = false) public List<NodeRating> create( String nodeId, List<NodeRating> ratingEntity, Parameters parameters) { // There will always be 1 value because allowMultiple=false NodeRating rating = ratingEntity.get(0); String ratingSchemeId = rating.getScheme(); nodeRatings.addRating(nodeId, ratingSchemeId, rating.getMyRating()); return Collections.singletonList(nodeRatings.getNodeRating(nodeId, ratingSchemeId)); }
@Override @WebApiDescription(title = "A paged list of ratings for node 'nodeId'.") @WebApiParam( name = "nodeId", title = "The unique id of the Node being addressed", description = "A single node id") public CollectionWithPagingInfo<NodeRating> readAll(String nodeId, Parameters parameters) { return nodeRatings.getNodeRatings(nodeId, parameters.getPaging()); }
/** Returns the rating with id 'schemeName' for node with id 'nodeId'. */ @Override @WebApiDescription(title = "Get the rating with id 'ratingSchemeId' for node 'nodeId'.") @WebApiParameters({ @WebApiParam( name = "nodeId", title = "The unique id of the Node being addressed", description = "A single node id"), @WebApiParam( name = "ratingSchemeId", title = "The rating scheme type", description = "Possible values are likesRatingScheme.") }) public NodeRating readById(String nodeId, String ratingSchemeId, Parameters parameters) { return nodeRatings.getNodeRating(nodeId, ratingSchemeId); }
@Override @WebApiDescription(title = "Deletes a node rating") public void delete(String nodeId, String ratingSchemeId, Parameters parameters) { nodeRatings.removeRating(nodeId, ratingSchemeId); }