Search in sources :

Example 1 with PropertiesDefinitionResourceApiData

use of org.eclipse.winery.repository.rest.resources.apiData.PropertiesDefinitionResourceApiData in project winery by eclipse.

the class PropertiesDefinitionResource method getInheritedPropertiesDefinitionResource.

/**
 * Returns a list of properties definition of each parent.
 *
 * Only self-defined properties definition are considered.
 * Properties definition of a parent's parent are not merged into the properties definition of the parent.
 */
@GET
@Path("inherited")
@Produces(MediaType.APPLICATION_JSON)
public List<InheritedPropertiesDefinitionsResourceApiData> getInheritedPropertiesDefinitionResource() {
    ArrayList<TEntityType> parents = RepositoryFactory.getRepository().getParents(this.parentRes.getEntityType());
    ArrayList<InheritedPropertiesDefinitionsResourceApiData> list = new ArrayList<>();
    for (TEntityType parent : parents) {
        // Add winerys properties definition of parent if defined to list
        WinerysPropertiesDefinition winerysPropertiesDefinition = parent.getWinerysPropertiesDefinition();
        if (winerysPropertiesDefinition != null) {
            // Add derived from information
            List<PropertyDefinitionKV> propertyDefinitions = winerysPropertiesDefinition.getPropertyDefinitions();
            if (propertyDefinitions != null) {
                for (PropertyDefinitionKV propertyDefinition : propertyDefinitions) {
                    propertyDefinition.setDerivedFromType(parent.getQName());
                    propertyDefinition.setDerivedFromStatus("SELF");
                }
            }
            // Add winerys properties definition to list
            PropertiesDefinitionResourceApiData propertiesDefinitionResourceApiData = new PropertiesDefinitionResourceApiData(parent.getProperties(), winerysPropertiesDefinition);
            list.add(new InheritedPropertiesDefinitionsResourceApiData(parent.getQName(), propertiesDefinitionResourceApiData));
        }
    }
    return list;
}
Also used : PropertyDefinitionKV(org.eclipse.winery.model.tosca.extensions.kvproperties.PropertyDefinitionKV) PropertiesDefinitionResourceApiData(org.eclipse.winery.repository.rest.resources.apiData.PropertiesDefinitionResourceApiData) TEntityType(org.eclipse.winery.model.tosca.TEntityType) InheritedPropertiesDefinitionsResourceApiData(org.eclipse.winery.repository.rest.resources.apiData.InheritedPropertiesDefinitionsResourceApiData) ArrayList(java.util.ArrayList) WinerysPropertiesDefinition(org.eclipse.winery.model.tosca.extensions.kvproperties.WinerysPropertiesDefinition) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with PropertiesDefinitionResourceApiData

use of org.eclipse.winery.repository.rest.resources.apiData.PropertiesDefinitionResourceApiData in project winery by eclipse.

the class PropertiesDefinitionResource method getMerged.

/**
 * Merge properties definitions with inherited definitions.
 */
@GET
@Path("merged")
@Produces(MediaType.APPLICATION_JSON)
public PropertiesDefinitionResourceApiData getMerged() {
    // Get complete inheritance hierarchy
    List<TEntityType> hierarchy = RepositoryFactory.getRepository().getParentsAndChild(this.getEntityType());
    // Merge properties definitions
    List<PropertyDefinitionKV> propertyDefinitions = ModelUtilities.mergePropertiesDefinitions(hierarchy);
    // Create new WPD
    WinerysPropertiesDefinition winerysPropertiesDefinition = new WinerysPropertiesDefinition();
    winerysPropertiesDefinition.setElementName(this.getEntityType().getName());
    winerysPropertiesDefinition.setNamespace(this.getEntityType().getTargetNamespace());
    winerysPropertiesDefinition.setPropertyDefinitions(propertyDefinitions);
    return new PropertiesDefinitionResourceApiData(this.getEntityType().getProperties(), winerysPropertiesDefinition);
}
Also used : PropertyDefinitionKV(org.eclipse.winery.model.tosca.extensions.kvproperties.PropertyDefinitionKV) PropertiesDefinitionResourceApiData(org.eclipse.winery.repository.rest.resources.apiData.PropertiesDefinitionResourceApiData) TEntityType(org.eclipse.winery.model.tosca.TEntityType) WinerysPropertiesDefinition(org.eclipse.winery.model.tosca.extensions.kvproperties.WinerysPropertiesDefinition) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 TEntityType (org.eclipse.winery.model.tosca.TEntityType)2 PropertyDefinitionKV (org.eclipse.winery.model.tosca.extensions.kvproperties.PropertyDefinitionKV)2 WinerysPropertiesDefinition (org.eclipse.winery.model.tosca.extensions.kvproperties.WinerysPropertiesDefinition)2 PropertiesDefinitionResourceApiData (org.eclipse.winery.repository.rest.resources.apiData.PropertiesDefinitionResourceApiData)2 ArrayList (java.util.ArrayList)1 InheritedPropertiesDefinitionsResourceApiData (org.eclipse.winery.repository.rest.resources.apiData.InheritedPropertiesDefinitionsResourceApiData)1