*/
Set<ComponentReference<?>> ownedComponents = new HashSet<ComponentReference<?>>();
for (OwnedComponentDeclaration ownDeclaration : getComposite().getOwnedComponents()) {
ComponentDeclaration owned = getComponent(ownDeclaration.getComponent(),true);
if (owned == null) {
error("invalid own expression, unknown component " + ownDeclaration.getComponent().getName());
continue;
}
/*
* Verify the property used to optionally filter owned components is declared, and is an enumeration
* that contains the specified values
*/
if (ownDeclaration.getProperty() != null) {
String propertyName = ownDeclaration.getProperty().getIdentifier();
PropertyDefinition property = owned.getPropertyDefinition(propertyName);
if (property == null) {
error("invalid own expression, undefined property "+ quoted(propertyName) +" in component "+ owned.getName());
continue;
}
Type propertyType = getType(property);
if (propertyType == null || !(propertyType instanceof EnumerationType)) {
error("invalid own expression, property "+ quoted(propertyName) + " of component " + owned.getName() + " is not an enumeration");
continue;
}
if (ownDeclaration.getValues().isEmpty()) {
error("invalid own expression, values not specified for property "+ quoted(propertyName) + " of component " + owned.getName());
continue;
}
for (String value : ownDeclaration.getValues()) {
if (propertyType.value(value) == null) {
error("invalid own expression, value "+quoted(value)+" is not valid for property "+ quoted(propertyName) + " of component " + owned.getName());
}
}
}
/*
* Check that a single own clause applies for the same component and its members. At execution, it must also
* be checked that if there are other grant clauses in other composites for the same component, they must
* specify the same property and different values.
*/
if (ownedComponents.contains(owned.getReference())) {
error("invalid own expression, another own clause exists for "+ owned.getName()+ " in this composite declaration");
continue;
}
ownedComponents.add(owned.getReference());
if (owned.getGroup() != null) {
ownedComponents.add(owned.getGroup());
}
validateGrant(owned,ownDeclaration,stateType);
}
}