Search in sources :

Example 1 with RelationshipTypeImplementationResource

use of org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationResource 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)

Aggregations

QName (javax.xml.namespace.QName)1 NodeTypeImplementationResource (org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationResource)1 RelationshipTypeImplementationResource (org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationResource)1 EntityTypeResource (org.eclipse.winery.repository.rest.resources.entitytypes.EntityTypeResource)1