Search in sources :

Example 1 with NodeTypesResource

use of org.eclipse.winery.repository.rest.resources.entitytypes.nodetypes.NodeTypesResource 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;
}
Also used : RelationshipTypeResource(org.eclipse.winery.repository.rest.resources.entitytypes.relationshiptypes.RelationshipTypeResource) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) NodeTypeImplementationResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationResource) NodeTypeResource(org.eclipse.winery.repository.rest.resources.entitytypes.nodetypes.NodeTypeResource) RelationshipTypesResource(org.eclipse.winery.repository.rest.resources.entitytypes.relationshiptypes.RelationshipTypesResource) NodeTypesResource(org.eclipse.winery.repository.rest.resources.entitytypes.nodetypes.NodeTypesResource) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 QName (javax.xml.namespace.QName)1 NodeTypeImplementationResource (org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationResource)1 NodeTypeResource (org.eclipse.winery.repository.rest.resources.entitytypes.nodetypes.NodeTypeResource)1 NodeTypesResource (org.eclipse.winery.repository.rest.resources.entitytypes.nodetypes.NodeTypesResource)1 RelationshipTypeResource (org.eclipse.winery.repository.rest.resources.entitytypes.relationshiptypes.RelationshipTypeResource)1 RelationshipTypesResource (org.eclipse.winery.repository.rest.resources.entitytypes.relationshiptypes.RelationshipTypesResource)1