Search in sources :

Example 1 with InheritedPropertiesDefinitionsResourceApiData

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

Aggregations

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