Search in sources :

Example 1 with ValidEndingsApiDataSet

use of org.eclipse.winery.repository.rest.resources.apiData.ValidEndingsApiDataSet 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)

Aggregations

ValidSource (org.eclipse.winery.model.tosca.TRelationshipType.ValidSource)1 ValidTarget (org.eclipse.winery.model.tosca.TRelationshipType.ValidTarget)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