Search in sources :

Example 1 with DisplayName

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()));
}
Also used : Cardinality(eu.esdihumboldt.hale.common.schema.model.constraint.property.Cardinality) DisplayName(eu.esdihumboldt.hale.common.schema.model.constraint.DisplayName)

Example 2 with DisplayName

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);
}
Also used : DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) DefaultPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition) DefaultGroupPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultGroupPropertyDefinition) QName(javax.xml.namespace.QName) DisplayName(eu.esdihumboldt.hale.common.schema.model.constraint.DisplayName) XmlElement(eu.esdihumboldt.hale.io.xsd.model.XmlElement)

Aggregations

DisplayName (eu.esdihumboldt.hale.common.schema.model.constraint.DisplayName)2 Cardinality (eu.esdihumboldt.hale.common.schema.model.constraint.property.Cardinality)1 DefaultGroupPropertyDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultGroupPropertyDefinition)1 DefaultPropertyDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition)1 DefaultTypeDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition)1 XmlElement (eu.esdihumboldt.hale.io.xsd.model.XmlElement)1 QName (javax.xml.namespace.QName)1