use of org.eclipse.winery.model.tosca.TRelationshipType.ValidSource in project winery by eclipse.
the class RelationshipTypeResource method putValidEnding.
@Path("validsourcesandtargets/")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public Response putValidEnding(ValidEndingsApiData validEndings) {
if (validEndings.validSource == null || validEndings.validSource.validDataSet == null || validEndings.validSource.validEndingsSelectionType == null) {
this.getRelationshipType().setValidSource(null);
} else {
ValidSource vs = new ValidSource();
QName qname = QName.valueOf(validEndings.validSource.validDataSet.getId());
vs.setTypeRef(qname);
this.getRelationshipType().setValidSource(vs);
}
if (validEndings.validTarget == null || validEndings.validTarget.validDataSet == null || validEndings.validTarget.validEndingsSelectionType == null) {
this.getRelationshipType().setValidTarget(null);
} else {
ValidTarget vt = new ValidTarget();
QName qnameVT = QName.valueOf(validEndings.validTarget.validDataSet.getId());
vt.setTypeRef(qnameVT);
this.getRelationshipType().setValidTarget(vt);
}
return RestUtils.persist(this);
}
use of org.eclipse.winery.model.tosca.TRelationshipType.ValidSource in project winery by eclipse.
the class RelationshipTypeResource method getValidEndings.
/*
* Select2DataItem used to send valid source as json to frontend.
* Mapping from Select2DataItem.Id as ValidSource.namespace and
* from Select2DataItem.Text as Validsource.localname
*/
@Path("validsourcesandtargets/")
@GET
@Produces(MediaType.APPLICATION_JSON)
public ValidEndingsApiData getValidEndings() {
ValidEndingsApiData validEndingsData = new ValidEndingsApiData();
// ToDo enable validSource as RequirementType (not-yet-implemented)
ValidSource validSource;
if (((validSource = this.getRelationshipType().getValidSource()) == null) || (validSource.getTypeRef() == null)) {
validEndingsData.validSource = null;
} else {
validSource = this.getRelationshipType().getValidSource();
validEndingsData.validSource = new ValidEndingsApiDataSet("nodeType", new Select2DataItem(validSource.getTypeRef().toString(), validSource.getTypeRef().getLocalPart()));
}
// ToDo enable validTarget as CapabilityType (not-yet-implemented)
ValidTarget validTarget;
if (((validTarget = this.getRelationshipType().getValidTarget()) == null) || (validTarget.getTypeRef() == null)) {
validEndingsData.validTarget = null;
} else {
validTarget = this.getRelationshipType().getValidTarget();
validEndingsData.validTarget = new ValidEndingsApiDataSet("nodeType", new Select2DataItem(validTarget.getTypeRef().toString(), validTarget.getTypeRef().getLocalPart()));
}
return validEndingsData;
}
Aggregations