Search in sources :

Example 16 with TopLevelElement

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

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

the class ConfigurationSchemaDelegate method addConnectionProviderElement.

private Optional<TopLevelElement> addConnectionProviderElement(ConfigurationModel configurationModel) {
    ExtensionModel extensionModel = builder.getExtensionModel();
    if (!extensionModel.getConnectionProviders().isEmpty() || !configurationModel.getConnectionProviders().isEmpty()) {
        TopLevelElement objectElement = new TopLevelElement();
        boolean hasImplicitConnection = getFirstImplicit(extensionModel.getConnectionProviders()) != null || getFirstImplicit(configurationModel.getConnectionProviders()) != null;
        objectElement.setMinOccurs(hasImplicitConnection ? ZERO : ONE);
        objectElement.setMaxOccurs(MAX_ONE);
        objectElement.setRef(MULE_CONNECTION_PROVIDER_ELEMENT);
        return Optional.of(objectElement);
    }
    return empty();
}
Also used : TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel)

Example 18 with TopLevelElement

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

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

the class ExecutableTypeSchemaDelegate method registerParameters.

protected ExtensionType registerParameters(ExtensionType type, List<ParameterModel> parameterModels) {
    List<TopLevelElement> childElements = new LinkedList<>();
    parameterModels.forEach(parameter -> {
        DslElementSyntax paramDsl = dsl.resolve(parameter);
        MetadataType parameterType = parameter.getType();
        boolean shouldDeclare = true;
        if (parameter.getModelProperty(QNameModelProperty.class).isPresent() && !parameter.getDslConfiguration().allowsReferences()) {
            shouldDeclare = false;
        }
        if (shouldDeclare) {
            this.builder.declareAsParameter(parameterType, type, parameter, paramDsl, childElements);
        }
    });
    appendToSequence(type, childElements);
    return type;
}
Also used : TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax) MetadataType(org.mule.metadata.api.model.MetadataType) LinkedList(java.util.LinkedList)

Example 20 with TopLevelElement

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

the class ExecutableTypeSchemaDelegate method generateNestedProcessorElement.

private void generateNestedProcessorElement(ExtensionType type, NestedChainModel chainModel) {
    final ExplicitGroup choice = new ExplicitGroup();
    choice.setMinOccurs(chainModel.isRequired() ? ONE : ZERO);
    choice.setMaxOccurs(UNBOUNDED);
    chainModel.getAllowedStereotypes().forEach(stereotype -> {
        // We need this to support both message-processor and mixed-content-message-processor
        if (stereotype.equals(PROCESSOR)) {
            NamedGroup group = builder.createGroup(MULE_MESSAGE_PROCESSOR_TYPE, true);
            choice.getParticle().add(objectFactory.createGroup(group));
        } else {
            TopLevelElement localAbstractElementRef = builder.createRefElement(getSubstitutionGroup(stereotype), true);
            choice.getParticle().add(objectFactory.createElement(localAbstractElementRef));
        }
    });
    type.getSequence().getParticle().add(objectFactory.createChoice(choice));
    if (chainModel.isRequired()) {
        type.getSequence().setMinOccurs(ONE);
    }
}
Also used : NamedGroup(org.mule.runtime.module.extension.internal.capability.xml.schema.model.NamedGroup) TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) ExplicitGroup(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup)

Aggregations

TopLevelElement (org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement)30 ExplicitGroup (org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup)11 QName (javax.xml.namespace.QName)10 DslElementSyntax (org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax)10 LocalComplexType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType)10 ExtensionType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType)5 BigInteger (java.math.BigInteger)4 LinkedList (java.util.LinkedList)4 MetadataType (org.mule.metadata.api.model.MetadataType)4 Element (org.mule.runtime.module.extension.internal.capability.xml.schema.model.Element)4 Optional (java.util.Optional)3 ObjectType (org.mule.metadata.api.model.ObjectType)3 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)3 ComplexContent (org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexContent)3 ArrayType (org.mule.metadata.api.model.ArrayType)2 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)2 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)2 String.format (java.lang.String.format)1 ONE (java.math.BigInteger.ONE)1 ZERO (java.math.BigInteger.ZERO)1