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