use of org.eclipse.winery.repository.rest.resources.entitytypes.relationshiptypes.RelationshipTypesResource in project winery by eclipse.
the class ImplementationArtifactsResource method getInterfacesOfAssociatedType.
/**
* Method to get all interfaces associated to a nodetype or relationshiptype
*
* @return a list of TInterface
*/
@Path("interfaces/")
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<?> getInterfacesOfAssociatedType() {
// TODO refactor this that IRepository offers this helper method
boolean isNodeTypeImplementation = this.res instanceof NodeTypeImplementationResource;
QName type = RestUtils.getType(this.res);
List<Object> interfaces = new ArrayList<>();
if (isNodeTypeImplementation) {
NodeTypeResource typeResource = (NodeTypeResource) new NodeTypesResource().getComponentInstaceResource(type);
interfaces.addAll(typeResource.getInterfaces().onGet("true"));
} else {
RelationshipTypeResource typeResource = (RelationshipTypeResource) new RelationshipTypesResource().getComponentInstaceResource(type);
interfaces.addAll(typeResource.getSourceInterfaces().onGet("true"));
interfaces.addAll(typeResource.getTargetInterfaces().onGet("true"));
}
return interfaces;
}
Aggregations