Search in sources :

Example 6 with TopLevelElement

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

the class ObjectTypeSchemaDelegate method registerPojoGlobalElements.

private void registerPojoGlobalElements(DslElementSyntax typeDsl, ObjectType type, ObjectType baseType, String description) {
    if (registeredGlobalElementTypes.containsKey(globalTypeKey(typeDsl))) {
        return;
    }
    QName typeQName = getTypeQName(typeDsl, type);
    TopLevelElement abstractElement = registerAbstractElement(type, typeQName, typeDsl, baseType);
    if (typeDsl.supportsTopLevelDeclaration() || (typeDsl.supportsChildDeclaration() && typeDsl.isWrapped()) || getSubstitutionGroup(type).isPresent() || !builder.getTypesMapping().getSuperTypes(type).isEmpty()) {
        registerConcreteGlobalElement(typeDsl, description, abstractElement.getName(), typeQName);
    }
}
Also used : TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) QName(javax.xml.namespace.QName)

Example 7 with TopLevelElement

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

the class ObjectTypeSchemaDelegate method registerAbstractElement.

private TopLevelElement registerAbstractElement(MetadataType type, QName typeQName, DslElementSyntax typeDsl, ObjectType baseType) {
    TopLevelElement element = registeredGlobalElementTypes.get(typeDsl.getPrefix() + getAbstractElementName(typeDsl));
    if (element != null) {
        return element;
    }
    Optional<DslElementSyntax> baseDsl = builder.getDslResolver().resolve(baseType);
    if (typeDsl.isWrapped()) {
        createGlobalMuleExtensionAbstractElement(typeQName, typeDsl, baseDsl);
    }
    TopLevelElement abstractElement = new TopLevelElement();
    abstractElement.setName(getAbstractElementName(typeDsl));
    abstractElement.setAbstract(true);
    if (!typeDsl.supportsTopLevelDeclaration()) {
        abstractElement.setType(typeQName);
    }
    if (baseDsl.isPresent() || typeDsl.supportsTopLevelDeclaration()) {
        QName substitutionGroup = getAbstractElementSubstitutionGroup(typeDsl, baseDsl);
        abstractElement.setSubstitutionGroup(substitutionGroup);
    }
    // If user defined, substitutionGroup will be overridden
    getSubstitutionGroup(type).ifPresent((substitutionGroup) -> abstractElement.setSubstitutionGroup(builder.resolveSubstitutionGroup(substitutionGroup)));
    builder.getSchema().getSimpleTypeOrComplexTypeOrGroup().add(abstractElement);
    registeredGlobalElementTypes.put(typeDsl.getPrefix() + getAbstractElementName(typeDsl), abstractElement);
    return abstractElement;
}
Also used : TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) QName(javax.xml.namespace.QName) DslElementSyntax(org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax)

Example 8 with TopLevelElement

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

the class ObjectTypeSchemaDelegate method registerConcreteGlobalElement.

void registerConcreteGlobalElement(DslElementSyntax typeDsl, String description, String abstractElementName, QName typeQName) {
    if (registeredGlobalElementTypes.containsKey(globalTypeKey(typeDsl))) {
        return;
    }
    TopLevelElement objectElement = new TopLevelElement();
    objectElement.setName(typeDsl.getElementName());
    objectElement.setSubstitutionGroup(new QName(typeDsl.getNamespace(), abstractElementName, typeDsl.getPrefix()));
    objectElement.setAnnotation(builder.createDocAnnotation(description));
    objectElement.setComplexType(createTypeExtension(typeQName));
    if (typeDsl.supportsTopLevelDeclaration()) {
        objectElement.getComplexType().getComplexContent().getExtension().getAttributeOrAttributeGroup().add(builder.createNameAttribute(false));
    }
    builder.getSchema().getSimpleTypeOrComplexTypeOrGroup().add(objectElement);
    registeredGlobalElementTypes.put(globalTypeKey(typeDsl), objectElement);
}
Also used : TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) QName(javax.xml.namespace.QName)

Example 9 with TopLevelElement

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

the class ObjectTypeSchemaDelegate method addAbstractTypeRef.

private void addAbstractTypeRef(DslElementSyntax paramDsl, String description, MetadataType metadataType, List<TopLevelElement> all, boolean required) {
    BigInteger minOccurs = !paramDsl.supportsAttributeDeclaration() && required ? ONE : ZERO;
    TopLevelElement objectElement = builder.createTopLevelElement(paramDsl.getElementName(), minOccurs, MAX_ONE);
    objectElement.setAnnotation(builder.createDocAnnotation(description));
    objectElement.setComplexType(createComplexTypeWithAbstractElementRef(metadataType));
    all.add(objectElement);
}
Also used : TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) BigInteger(java.math.BigInteger)

Example 10 with TopLevelElement

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

the class OperationSchemaDelegate method registerProcessorElement.

void registerProcessorElement(ComponentModel componentModel, String typeName, DslElementSyntax dslSyntax) {
    Element element = new TopLevelElement();
    element.setName(dslSyntax.getElementName());
    element.setType(new QName(builder.getSchema().getTargetNamespace(), typeName));
    element.setAnnotation(builder.createDocAnnotation(componentModel.getDescription()));
    element.setSubstitutionGroup(getOperationSubstitutionGroup(componentModel));
    builder.getSchema().getSimpleTypeOrComplexTypeOrGroup().add(element);
}
Also used : TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) QName(javax.xml.namespace.QName) TopLevelElement(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelElement) Element(org.mule.runtime.module.extension.internal.capability.xml.schema.model.Element)

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