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;
}
Aggregations