Search in sources :

Example 1 with ComplexContent

use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexContent 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 ComplexContent

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

the class ObjectTypeSchemaDelegate method declarePojoAsType.

private ComplexType declarePojoAsType(ObjectType metadataType, QName base, String description, Collection<ObjectFieldType> fields) {
    final TopLevelComplexType complexType = new TopLevelComplexType();
    registeredComplexTypesHolders.put(getId(metadataType), new ComplexTypeHolder(complexType, metadataType));
    complexType.setName(sanitizeName(getId(metadataType)));
    complexType.setAnnotation(builder.createDocAnnotation(description));
    ComplexContent complexContent = new ComplexContent();
    complexType.setComplexContent(complexContent);
    final ExtensionType extension = new ExtensionType();
    extension.setBase(base);
    complexContent.setExtension(extension);
    DslElementSyntax typeDsl = dsl.resolve(metadataType).get();
    List<TopLevelElement> childElements = new LinkedList<>();
    fields.forEach(field -> {
        String fieldName = field.getKey().getName().getLocalPart();
        DslElementSyntax fieldDsl = typeDsl.getContainedElement(fieldName).orElse(null);
        if (isFlattenedParameterGroup(field)) {
            declareGroupedFields(extension, childElements, field);
        } else {
            declareObjectField(fieldDsl, field, extension, childElements);
        }
    });
    if (!childElements.isEmpty()) {
        final ExplicitGroup all = new ExplicitGroup();
        all.setMaxOccurs(MAX_ONE);
        boolean requiredChilds = childElements.stream().anyMatch(builder::isRequired);
        all.setMinOccurs(requiredChilds ? ONE : ZERO);
        childElements.forEach(p -> all.getParticle().add(objectFactory.createElement(p)));
        extension.setSequence(all);
    }
    return complexType;
}
Also used : TopLevelComplexType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelComplexType) TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) ExtensionType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) ComplexContent(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexContent) LinkedList(java.util.LinkedList) ExplicitGroup(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup)

Example 3 with ComplexContent

use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexContent 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)

Example 4 with ComplexContent

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

the class ExecutableTypeSchemaDelegate method createExecutableType.

protected ExtensionType createExecutableType(String name, QName base, DslElementSyntax dslSyntax, boolean hasImplicitConfig) {
    TopLevelComplexType complexType = new TopLevelComplexType();
    complexType.setName(name);
    ComplexContent complexContent = new ComplexContent();
    complexType.setComplexContent(complexContent);
    final ExtensionType complexContentExtension = new ExtensionType();
    complexContentExtension.setBase(base);
    complexContent.setExtension(complexContentExtension);
    if (dslSyntax.requiresConfig()) {
        Attribute configAttr = builder.createAttribute(CONFIG_ATTRIBUTE_NAME, CONFIG_ATTRIBUTE_DESCRIPTION, hasImplicitConfig, SUBSTITUTABLE_NAME);
        complexContentExtension.getAttributeOrAttributeGroup().add(configAttr);
    }
    this.builder.getSchema().getSimpleTypeOrComplexTypeOrGroup().add(complexType);
    return complexContentExtension;
}
Also used : TopLevelComplexType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelComplexType) Attribute(org.mule.runtime.module.extension.internal.capability.xml.schema.model.Attribute) ExtensionType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType) ComplexContent(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexContent)

Example 5 with ComplexContent

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

the class ObjectTypeSchemaDelegate method createTypeExtension.

LocalComplexType createTypeExtension(QName base) {
    final LocalComplexType complexType = new LocalComplexType();
    ComplexContent complexContent = new ComplexContent();
    complexType.setComplexContent(complexContent);
    final ExtensionType extension = new ExtensionType();
    extension.setBase(base);
    complexContent.setExtension(extension);
    return complexType;
}
Also used : 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

ComplexContent (org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexContent)5 ExtensionType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType)5 LocalComplexType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType)3 TopLevelElement (org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement)3 Element (org.mule.runtime.module.extension.internal.capability.xml.schema.model.Element)2 ExplicitGroup (org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup)2 TopLevelComplexType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelComplexType)2 LinkedList (java.util.LinkedList)1 DslElementSyntax (org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax)1 Attribute (org.mule.runtime.module.extension.internal.capability.xml.schema.model.Attribute)1