use of eu.esdihumboldt.hale.common.schema.model.constraint.DisplayName in project hale by halestudio.
the class SubstitutionGroupProperty method setProperty.
/**
* Set the property represented by the group. The property must have been
* created with this group as parent and the {@link Cardinality} constraint
* must have been already set.
*
* @param property the property to set
*/
public void setProperty(DefaultPropertyDefinition property) {
Preconditions.checkArgument(property.getDeclaringGroup() == this);
this.property = property;
// apply cardinality to group
setConstraint(property.getConstraint(Cardinality.class));
// set cardinality to exactly one for the property
property.setConstraint(Cardinality.CC_EXACTLY_ONCE);
// set display name to property name
setConstraint(new DisplayName(property.getDisplayName()));
}
use of eu.esdihumboldt.hale.common.schema.model.constraint.DisplayName in project hale by halestudio.
the class CustomTypeContentHelper method applyElementsMode.
private static void applyElementsMode(PropertyDefinition propDef, DefinitionGroup propParent, CustomTypeContent config, XmlIndex index) {
// build new property type based on config
DefaultTypeDefinition type = new DefaultTypeDefinition(new QName(propDef.getIdentifier(), "customElementsContentType"), false);
type.setConstraint(MappableFlag.DISABLED);
DefaultGroupPropertyDefinition choice = new DefaultGroupPropertyDefinition(new QName(propDef.getIdentifier(), "customElementsContentChoice"), type, false);
choice.setConstraint(new DisplayName("elements"));
choice.setConstraint(ChoiceFlag.ENABLED);
choice.setConstraint(Cardinality.CC_ANY_NUMBER);
for (QName elementName : config.getElements()) {
XmlElement element = index.getElements().get(elementName);
if (element != null) {
DefaultPropertyDefinition elementProp = new DefaultPropertyDefinition(elementName, choice, element.getType());
elementProp.setConstraint(Cardinality.CC_EXACTLY_ONCE);
elementProp.setConstraint(NillableFlag.DISABLED);
} else {
log.error("Element {} could not be found when creating custom type content", elementName);
}
}
replaceTypeForProperty(propDef, propParent, type);
}
Aggregations