use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType in project mule by mulesoft.
the class ConfigurationSchemaDelegate method registerConfigElement.
void registerConfigElement(Schema schema, final ConfigurationModel configurationModel, DslElementSyntax dslConfigElement) {
this.schema = schema;
ExtensionType config = registerExtension(dslConfigElement.getElementName());
config.getAttributeOrAttributeGroup().add(builder.createNameAttribute(true));
config.setAnnotation(builder.createDocAnnotation(configurationModel.getDescription()));
Optional<TopLevelElement> connectionElement = addConnectionProviderElement(configurationModel);
if (connectionElement.isPresent() || !configurationModel.getParameterGroupModels().isEmpty()) {
final ExplicitGroup sequence = new ExplicitGroup();
sequence.setMinOccurs(ZERO);
sequence.setMaxOccurs(MAX_ONE);
connectionElement.ifPresent(connection -> {
sequence.getParticle().add(objectFactory.createElement(connection));
if (builder.isRequired(connection)) {
sequence.setMinOccurs(ONE);
}
});
builder.addInfrastructureParameters(config, configurationModel, sequence);
configurationModel.getParameterGroupModels().forEach(group -> {
if (!group.isShowInDsl()) {
List<TopLevelElement> parameters = builder.registerParameters(config, group.getParameterModels());
builder.addParameterToSequence(parameters, sequence);
} else {
builder.addInlineParameterGroup(group, sequence);
}
});
config.setSequence(sequence);
}
}
use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType 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);
}
use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType 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;
}
use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType in project mule by mulesoft.
the class OperationSchemaDelegate method registerOperationType.
ExtensionType registerOperationType(String name, ComponentModel operationModel, DslElementSyntax dslSyntax, boolean hasImplicitConfig) {
ExtensionType componentType = createExecutableType(name, MULE_ABSTRACT_OPERATOR_TYPE, dslSyntax, hasImplicitConfig);
initialiseSequence(componentType);
ExplicitGroup sequence = componentType.getSequence();
builder.addInfrastructureParameters(componentType, operationModel, sequence);
operationModel.getParameterGroupModels().forEach(group -> registerParameterGroup(componentType, group));
return componentType;
}
use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExtensionType in project mule by mulesoft.
the class OperationSchemaDelegate method registerOperation.
public void registerOperation(ComponentModel componentModel, DslElementSyntax dslSyntax, boolean hasImplicitConfig) {
String typeName = capitalize(componentModel.getName()) + TYPE_SUFFIX;
registerProcessorElement(componentModel, typeName, dslSyntax);
ExtensionType extensionType = registerOperationType(typeName, componentModel, dslSyntax, hasImplicitConfig);
registerNestedComponents(extensionType, componentModel.getNestedComponents());
}
Aggregations