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