Search in sources :

Example 1 with ComplexType

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

the class ObjectTypeSchemaDelegate method registerPojoComplexType.

/**
 * Registers the {@link TopLevelComplexType} associated to the given {@link ObjectType} in the current namespace
 *
 * @param type the {@link ObjectType} that will be represented by the registered {@link ComplexType}
 * @param baseType the {@code base} for the {@link ComplexType} {@code extension} declaration
 * @param description
 * @return a new {@link ComplexType} declaration for the given {@link ObjectType}
 */
private ComplexType registerPojoComplexType(ObjectType type, ObjectType baseType, String description) {
    String typeId = getId(type);
    if (registeredComplexTypesHolders.get(typeId) != null) {
        return registeredComplexTypesHolders.get(typeId).getComplexType();
    }
    QName base = getComplexTypeBase(type, baseType);
    Collection<ObjectFieldType> fields;
    if (baseType == null) {
        fields = type.getFields();
    } else {
        fields = type.getFields().stream().filter(field -> !baseType.getFields().stream().anyMatch(other -> other.getKey().getName().getLocalPart().equals(field.getKey().getName().getLocalPart()))).collect(toList());
    }
    ComplexType complexType = declarePojoAsType(type, base, description, fields);
    builder.getSchema().getSimpleTypeOrComplexTypeOrGroup().add(complexType);
    return complexType;
}
Also used : QName(javax.xml.namespace.QName) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) ComplexType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexType) TopLevelComplexType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelComplexType) LocalComplexType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType)

Aggregations

QName (javax.xml.namespace.QName)1 ObjectFieldType (org.mule.metadata.api.model.ObjectFieldType)1 ComplexType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexType)1 LocalComplexType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalComplexType)1 TopLevelComplexType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.TopLevelComplexType)1