use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup 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.ExplicitGroup in project mule by mulesoft.
the class SchemaBuilder method addInlineParameterGroup.
void addInlineParameterGroup(ParameterGroupModel group, ExplicitGroup parentSequence) {
DslElementSyntax groupDsl = dslResolver.resolveInline(group);
LocalComplexType complexType = objectTypeDelegate.createTypeExtension(MULE_ABSTRACT_EXTENSION_TYPE);
ExplicitGroup groupSequence = new ExplicitGroup();
List<ParameterModel> groupParameters = group.getParameterModels();
List<TopLevelElement> parameterElements = registerParameters(complexType.getComplexContent().getExtension(), groupParameters);
addParameterToSequence(parameterElements, groupSequence);
BigInteger minOccurs = ExtensionModelUtils.isRequired(group) ? ONE : ZERO;
TopLevelElement groupElement = createTopLevelElement(groupDsl.getElementName(), minOccurs, MAX_ONE);
groupElement.setComplexType(complexType);
complexType.getComplexContent().getExtension().setSequence(groupSequence);
parentSequence.getParticle().add(objectFactory.createElement(groupElement));
}
use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup in project mule by mulesoft.
the class SchemaBuilder method createTypeRefChoiceLocalOrGlobal.
/**
* Creates a {@link ExplicitGroup Choice} group that supports {@code refs} to both the {@code global} and {@code local} abstract
* elements for the given {@code type}. This is required in order to allow subtypes that support top-level declaration along
* with other subtypes that support only local declarations as childs.
* <p/>
* For example, a resulting choice group for a type of name {@code TypeName} will look like:
* <p>
* <xs:complexType> <xs:choice minOccurs="1" maxOccurs="1">
* <xs:element minOccurs="0" maxOccurs="1" ref="ns:abstract-type-name"></xs:element>
* <xs:element minOccurs="0" maxOccurs="1" ref="ns:global-abstract-type-name"></xs:element> </xs:choice> </xs:complexType>
* <p/>
*
* @param typeDsl {@link DslElementSyntax} of the referenced type
* @param type the {@link MetadataType type} of the base element that will be referenced
* @param minOccurs {@link BigInteger#ZERO} if the {@code group} is optional or {@link BigInteger#ONE} if required
* @param maxOccurs the maximum number of occurrences for this group
* @return a {@link ExplicitGroup Choice} group with the necessary options for this case
*/
ExplicitGroup createTypeRefChoiceLocalOrGlobal(DslElementSyntax typeDsl, MetadataType type, BigInteger minOccurs, String maxOccurs) {
if (!isImported(type) && !OBJECT_STORE_TYPE.equals(type)) {
objectTypeDelegate.registerPojoType(type, EMPTY);
objectTypeDelegate.registerAbstractElement(type, typeDsl);
if (typeDsl.supportsTopLevelDeclaration() || (typeDsl.supportsChildDeclaration() && typeDsl.isWrapped())) {
objectTypeDelegate.registerConcreteGlobalElement(typeDsl, EMPTY, getAbstractElementName(typeDsl), objectTypeDelegate.getTypeQName(typeDsl, type));
}
}
final ExplicitGroup choice = new ExplicitGroup();
choice.setMinOccurs(minOccurs);
choice.setMaxOccurs(maxOccurs);
List<String> options = new LinkedList<>();
if (type.equals(OBJECT_STORE_TYPE)) {
QName refInternal = PRIVATE_OBJECT_STORE_ELEMENT;
TopLevelElement internalAbstractElementRef = createRefElement(refInternal, true);
choice.getParticle().add(objectFactory.createElement(internalAbstractElementRef));
options.add(refInternal.toString());
} else {
QName refAbstract = new QName(typeDsl.getNamespace(), getAbstractElementName(typeDsl), typeDsl.getPrefix());
TopLevelElement localAbstractElementRef = createRefElement(refAbstract, true);
choice.getParticle().add(objectFactory.createElement(localAbstractElementRef));
options.add(refAbstract.toString());
QName refGlobal = new QName(typeDsl.getNamespace(), format(GLOBAL_ABSTRACT_ELEMENT_MASK, getAbstractElementName(typeDsl)), typeDsl.getPrefix());
TopLevelElement topLevelElementRef = createRefElement(refGlobal, true);
choice.getParticle().add(objectFactory.createElement(topLevelElementRef));
options.add(refGlobal.toString());
}
typesMapping.getSubTypes((ObjectType) type).stream().filter(subtype -> dslResolver.resolve(subtype).map(DslElementSyntax::supportsChildDeclaration).orElse(false)).map(ExtensionMetadataTypeUtils::getSubstitutionGroup).filter(Optional::isPresent).map(Optional::get).forEach(customGroup -> {
QName qName = resolveSubstitutionGroup(customGroup);
if (!options.contains(qName.toString())) {
TopLevelElement customGroupRef = createRefElement(qName, true);
choice.getParticle().add(objectFactory.createElement(customGroupRef));
options.add(customGroupRef.toString());
}
});
return choice;
}
use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup 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);
}
}
use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ExplicitGroup in project mule by mulesoft.
the class ExecutableTypeSchemaDelegate method generateNestedRouteElement.
private void generateNestedRouteElement(ExtensionType type, DslElementSyntax routeDsl, NestedRouteModel routeModel) {
NestedChainModel chain = (NestedChainModel) routeModel.getNestedComponents().get(0);
LocalComplexType complexType = builder.getObjectSchemaDelegate().createTypeExtension(MULE_ABSTRACT_EXTENSION_TYPE);
ExplicitGroup routeSequence = new ExplicitGroup();
complexType.getComplexContent().getExtension().setSequence(routeSequence);
generateNestedProcessorElement(complexType.getComplexContent().getExtension(), chain);
registerParameters(complexType.getComplexContent().getExtension(), routeModel.getAllParameterModels());
TopLevelElement routeElement = builder.createTopLevelElement(routeDsl.getElementName(), BigInteger.valueOf(routeModel.getMinOccurs()), MAX_ONE);
routeElement.setComplexType(complexType);
type.getSequence().getParticle().add(objectFactory.createElement(routeElement));
if (routeModel.getMinOccurs() > 0) {
type.getSequence().setMinOccurs(ONE);
}
}
Aggregations