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);
}
Aggregations