@Override
public void appendLinks(LinkableRepresentation<?> representation) {
if(!(representation instanceof Identifiable)) {
return;
}
Identifiable sourceIdentifiable = (Identifiable)representation;
Collection<RelationMatch> matches = service.getMatchingRelations(representation.getSourceType());
for(RelationMatch target: matches) {
UriBuilder buidler = representation.getUriInfo().getBaseUriBuilder().segment(
"rel",
getTypeName(target.getSourceModel()),
sourceIdentifiable.getId(),
target.getSource().getType(),
getTypeName(target.getTargetModel()));
representation.addLink(
new ResourceLink(
target.getSource().getName(),
buidler.build(),
RelationResource.BASE_JSON_MEDIA_TYPE + "; type=" + getMediaTypeName(target.getTargetModel())));
}
}