public Collection<NamedRelation> match(ResourceMetadata source) { List<NamedRelation> relations = new ArrayList<NamedRelation>(); for(NamedRelation sourceRel : source.outgoing) { for(Relation targetRel : this.incoming) { if(targetRel.getType().equals(sourceRel.getType())) { relations.add(sourceRel); } } } return relations; }
@Override public void appendLinks(LinkableRepresentation<?> representation) { if(!(representation instanceof Identifiable)) { return; } Identifiable sourceIdentifiable = (Identifiable)representation; // TODO: Remove need for cast 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())); // TODO: Dynamically lookup MediaType representation.addLink( new ResourceLink( target.getSource().getName(), buidler.build(), RelationResource.BASE_JSON_MEDIA_TYPE + "; type=" + getMediaTypeName(target.getTargetModel()))); } }
@Override public ResourceMetadata getResourceMetadata() { return new ResourceMetadata(Conference.class) .outgoing(new NamedRelation("attachments", "attached_to")) .outgoing(new NamedRelation("trackers", "tracked_by")) .outgoing(new NamedRelation("attendees", "attended_by")) .outgoing(new NamedRelation("locations", "located_at")); }
@Override public ResourceMetadata getResourceMetadata() { return new ResourceMetadata(SourceObject.class) .outgoing(new NamedRelation("connections", "connected_to")) .outgoing(new NamedRelation("notdeployed", "no_matching_relation")); }
@Override public ResourceMetadata getResourceMetadata() { return new ResourceMetadata(User.class) .incoming(new Relation("presented_by")) .incoming(new Relation("tracked_by")) .incoming(new Relation("attended_by")) .outgoing(new NamedRelation("attachments", "attached_to")) .outgoing(new NamedRelation("sessions", "presented_by")); } }
@Override public ResourceMetadata getResourceMetadata() { return new ResourceMetadata(Session.class) .incoming(new Relation("presented_by")) .outgoing(new NamedRelation("attachments", "attached_to")) .outgoing(new NamedRelation("speakers", "presented_by")) .outgoing(new NamedRelation("attendees", "attended_by")) .outgoing(new NamedRelation("locations", "located_in")); } }