Search in sources :

Example 1 with NodeTypeImplementationResource

use of org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationResource in project winery by eclipse.

the class AbstractComponentInstanceResourceWithNameDerivedFromAbstractFinal method putInheritance.

/**
 * @return Response
 */
protected Response putInheritance(InheritanceResourceApiData json) {
    HasType derivedFrom = null;
    // If (none) is selected, derivedFrom needs to be null in order to have valid XML in ALL cases!
    if (!json.derivedFrom.endsWith("(none)")) {
        QName qname = QName.valueOf(json.derivedFrom);
        if (this instanceof EntityTypeResource) {
            derivedFrom = new TEntityType.DerivedFrom();
        } else if (this instanceof RelationshipTypeImplementationResource) {
            derivedFrom = new TRelationshipTypeImplementation.DerivedFrom();
        } else if (this instanceof NodeTypeImplementationResource) {
            derivedFrom = new TNodeTypeImplementation.DerivedFrom();
        } else {
            return Response.status(Response.Status.BAD_REQUEST).entity("Type does not support inheritance!").build();
        }
        derivedFrom.setType(qname);
    }
    HasInheritance element = (HasInheritance) this.getElement();
    element.setDerivedFrom(derivedFrom);
    element.setAbstract(TBoolean.fromValue(json.isAbstract));
    element.setFinal(TBoolean.fromValue(json.isFinal));
    return RestUtils.persist(this);
}
Also used : EntityTypeResource(org.eclipse.winery.repository.rest.resources.entitytypes.EntityTypeResource) RelationshipTypeImplementationResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationResource) QName(javax.xml.namespace.QName) NodeTypeImplementationResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationResource)

Example 2 with NodeTypeImplementationResource

use of org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationResource 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

QName (javax.xml.namespace.QName)2 NodeTypeImplementationResource (org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationResource)2 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 RelationshipTypeImplementationResource (org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationResource)1 EntityTypeResource (org.eclipse.winery.repository.rest.resources.entitytypes.EntityTypeResource)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