Search in sources :

Example 1 with ValidSource

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);
}
Also used : ValidSource(org.eclipse.winery.model.tosca.TRelationshipType.ValidSource) QName(javax.xml.namespace.QName) ValidTarget(org.eclipse.winery.model.tosca.TRelationshipType.ValidTarget) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 2 with ValidSource

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;
}
Also used : ValidSource(org.eclipse.winery.model.tosca.TRelationshipType.ValidSource) ValidEndingsApiDataSet(org.eclipse.winery.repository.rest.resources.apiData.ValidEndingsApiDataSet) ValidEndingsApiData(org.eclipse.winery.repository.rest.resources.apiData.ValidEndingsApiData) ValidTarget(org.eclipse.winery.model.tosca.TRelationshipType.ValidTarget) Select2DataItem(org.eclipse.winery.repository.rest.datatypes.select2.Select2DataItem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Path (javax.ws.rs.Path)2 ValidSource (org.eclipse.winery.model.tosca.TRelationshipType.ValidSource)2 ValidTarget (org.eclipse.winery.model.tosca.TRelationshipType.ValidTarget)2 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1 Produces (javax.ws.rs.Produces)1 QName (javax.xml.namespace.QName)1 Select2DataItem (org.eclipse.winery.repository.rest.datatypes.select2.Select2DataItem)1 ValidEndingsApiData (org.eclipse.winery.repository.rest.resources.apiData.ValidEndingsApiData)1 ValidEndingsApiDataSet (org.eclipse.winery.repository.rest.resources.apiData.ValidEndingsApiDataSet)1