Search in sources :

Example 1 with LocalComplexType

use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType in project mule by mulesoft.

the class ConnectionProviderSchemaDelegate method registerConnectionProviderElement.

void registerConnectionProviderElement(ConnectionProviderModel providerModel, DslElementSyntax elementSyntax) {
    Element providerElement = new TopLevelElement();
    providerElement.setName(elementSyntax.getElementName());
    providerElement.setSubstitutionGroup(MULE_CONNECTION_PROVIDER_ELEMENT);
    LocalComplexType complexType = new LocalComplexType();
    providerElement.setComplexType(complexType);
    ExtensionType providerType = new ExtensionType();
    providerType.setBase(MULE_CONNECTION_PROVIDER_TYPE);
    ComplexContent complexContent = new ComplexContent();
    complexContent.setExtension(providerType);
    complexType.setComplexContent(complexContent);
    builder.getSchema().getSimpleTypeOrComplexTypeOrGroup().add(providerElement);
    final ExplicitGroup sequence = new ExplicitGroup();
    sequence.setMinOccurs(ZERO);
    sequence.setMaxOccurs(MAX_ONE);
    builder.addInfrastructureParameters(providerType, providerModel, sequence);
    providerModel.getParameterGroupModels().forEach(group -> {
        if (!group.isShowInDsl()) {
            builder.addParameterToSequence(builder.registerParameters(providerType, group.getParameterModels()), sequence);
        } else {
            builder.addInlineParameterGroup(group, sequence);
        }
    });
    providerType.setSequence(sequence);
}
Also used : TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) Element(org.mule.runtime.module.extension.internal.capability.xml.schema.model.Element) ExtensionType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType) LocalComplexType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType) ComplexContent(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexContent) ExplicitGroup(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup)

Example 2 with LocalComplexType

use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType in project mule by mulesoft.

the class ObjectTypeSchemaDelegate method createComplexTypeWithAbstractElementRef.

private LocalComplexType createComplexTypeWithAbstractElementRef(MetadataType type) {
    DslElementSyntax typeDsl = builder.getDslResolver().resolve(type).orElseThrow(() -> new IllegalArgumentException(format("No element ref can be created for the given type [%s]", getId(type))));
    LocalComplexType complexType = new LocalComplexType();
    if (typeDsl.isWrapped()) {
        complexType.setChoice(builder.createTypeRefChoiceLocalOrGlobal(typeDsl, type, ONE, MAX_ONE));
    } else {
        ExplicitGroup sequence = new ExplicitGroup();
        sequence.setMinOccurs(ONE);
        sequence.setMaxOccurs(MAX_ONE);
        sequence.getParticle().add(objectFactory.createElement(createRefToLocalElement(typeDsl, type)));
        complexType.setSequence(sequence);
    }
    return complexType;
}
Also used : DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) LocalComplexType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType) ExplicitGroup(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup)

Example 3 with LocalComplexType

use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType in project mule by mulesoft.

the class SchemaBuilder method addInlineParameterGroup.

void addInlineParameterGroup(ParameterGroupModel group, ExplicitGroup parentSequence) {
    DslElementSyntax groupDsl = dslResolver.resolveInline(group);
    LocalComplexType complexType = objectTypeDelegate.createTypeExtension(MULE_ABSTRACT_EXTENSION_TYPE);
    ExplicitGroup groupSequence = new ExplicitGroup();
    List<ParameterModel> groupParameters = group.getParameterModels();
    List<TopLevelElement> parameterElements = registerParameters(complexType.getComplexContent().getExtension(), groupParameters);
    addParameterToSequence(parameterElements, groupSequence);
    BigInteger minOccurs = ExtensionModelUtils.isRequired(group) ? ONE : ZERO;
    TopLevelElement groupElement = createTopLevelElement(groupDsl.getElementName(), minOccurs, MAX_ONE);
    groupElement.setComplexType(complexType);
    complexType.getComplexContent().getExtension().setSequence(groupSequence);
    parentSequence.getParticle().add(objectFactory.createElement(groupElement));
}
Also used : ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) BigInteger(java.math.BigInteger) LocalComplexType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType) ExplicitGroup(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup)

Example 4 with LocalComplexType

use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType in project mule by mulesoft.

the class CollectionSchemaDelegate method generateCollectionElement.

void generateCollectionElement(ArrayType metadataType, DslElementSyntax collectionDsl, String description, boolean required, List<TopLevelElement> all) {
    LocalComplexType collectionComplexType = generateCollectionComplexType(collectionDsl, metadataType);
    TopLevelElement collectionElement = builder.createTopLevelElement(collectionDsl.getElementName(), required ? ONE : ZERO, MAX_ONE);
    collectionElement.setAnnotation(builder.createDocAnnotation(description));
    collectionElement.setComplexType(collectionComplexType);
    all.add(collectionElement);
}
Also used : TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) LocalComplexType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType)

Example 5 with LocalComplexType

use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType in project mule by mulesoft.

the class ConfigurationSchemaDelegate method registerExtension.

private ExtensionType registerExtension(String name) {
    LocalComplexType complexType = new LocalComplexType();
    Element extension = new TopLevelElement();
    extension.setName(name);
    extension.setSubstitutionGroup(MULE_ABSTRACT_SHARED_EXTENSION);
    extension.setComplexType(complexType);
    ComplexContent complexContent = new ComplexContent();
    complexType.setComplexContent(complexContent);
    ExtensionType complexContentExtension = new ExtensionType();
    complexContentExtension.setBase(MULE_ABSTRACT_EXTENSION_TYPE);
    complexContent.setExtension(complexContentExtension);
    schema.getSimpleTypeOrComplexTypeOrGroup().add(extension);
    return complexContentExtension;
}
Also used : TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) Element(org.mule.runtime.module.extension.internal.capability.xml.schema.model.Element) ExtensionType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType) LocalComplexType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType) ComplexContent(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexContent)

Aggregations

LocalComplexType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType)11 TopLevelElement (org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement)9 ExplicitGroup (org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup)7 DslElementSyntax (org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax)5 ComplexContent (org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexContent)3 ExtensionType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType)3 BigInteger (java.math.BigInteger)2 MetadataType (org.mule.metadata.api.model.MetadataType)2 ObjectType (org.mule.metadata.api.model.ObjectType)2 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)2 Element (org.mule.runtime.module.extension.internal.capability.xml.schema.model.Element)2 Optional (java.util.Optional)1 QName (javax.xml.namespace.QName)1 ArrayType (org.mule.metadata.api.model.ArrayType)1 NestedChainModel (org.mule.runtime.api.meta.model.nested.NestedChainModel)1 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)1 Attribute (org.mule.runtime.module.extension.internal.capability.xml.schema.model.Attribute)1