if (def != null) { sb.append(" def("); sb.append(PrettyPrinter.prettyPrint(def.getTypeName())); if (def.isRuntimeSchema()) { sb.append(",runtime");
private void assertConfigurationPropertyDefinition(PrismContainerDefinition<Containerable> containerDefinition, String propertyLocalName, QName expectedType, int expectedMinOccurs, int expectedMaxOccurs, String expectedDisplayName, String expectedHelp) { ItemName propName = new ItemName(containerDefinition.getTypeName().getNamespaceURI(),propertyLocalName); PrismPropertyDefinition propDef = containerDefinition.findPropertyDefinition(propName); assertConfigurationPropertyDefinition(propDef, expectedType, expectedMinOccurs, expectedMaxOccurs, expectedDisplayName, expectedHelp); }
private void assertConfigurationPropertyDefinition(PrismContainer container, String propertyLocalName, QName expectedType, int expectedMinOccurs, int expectedMaxOccurs, String expectedDisplayName, String expectedHelp) { QName propName = new QName(container.getDefinition().getTypeName().getNamespaceURI(),propertyLocalName); PrismProperty prop = container.findProperty(ItemName.fromQName(propName)); assertNotNull("No property "+propName, prop); PrismPropertyDefinition propDef = prop.getDefinition(); assertNotNull("No definition for property "+prop, propDef); assertConfigurationPropertyDefinition(propDef, expectedType, expectedMinOccurs, expectedMaxOccurs, expectedDisplayName, expectedHelp); }
/** * Adds XSD definitions from PropertyContainerDefinition. This is complexType and element. * If the property container is an ResourceObjectDefinition, it will add only annotated * complexType definition. * * @param definition PropertyContainerDefinition to process * @param parent element under which the XSD definition will be added */ private void addContainerDefinition(PrismContainerDefinition definition, Element elementParent, Element complexTypeParent) { ComplexTypeDefinition complexTypeDefinition = definition.getComplexTypeDefinition(); if (complexTypeDefinition != null && // Check if the complex type is a top-level complex type. If it is then it was already processed and we can skip it schema.findComplexTypeDefinition(complexTypeDefinition.getTypeName()) == null && // If the definition is not in this schema namespace then skip it. It is only a "ref" getNamespace().equals(complexTypeDefinition.getTypeName().getNamespaceURI()) ) { addComplexTypeDefinition(complexTypeDefinition,complexTypeParent); } Element elementElement = addElementDefinition(definition.getName(), definition.getTypeName(), definition.getMinOccurs(), definition.getMaxOccurs(), elementParent); if (complexTypeDefinition == null || !complexTypeDefinition.isContainerMarker()) { // Need to add a:container annotation to the element as the complex type does not have it addAnnotationToDefinition(elementElement, A_PROPERTY_CONTAINER); } }
/** * Test if a schema directory can be loaded to the schema registry. This contains definition of * user extension, therefore check if it is applied to the user definition. */ @Test public void testTypeOverride() throws SAXException, IOException, SchemaException { System.out.println("===[ testTypeOverride ]==="); PrismContext context = constructPrismContext(); SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry(); reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR); context.initialize(); PrismSchema schema = reg.getPrismSchema(NS_ROOT); System.out.println("Parsed root schema:"); System.out.println(schema.debugDump()); PrismContainerDefinition rootContDef = schema.findContainerDefinitionByElementName(new QName(NS_ROOT,"root")); assertNotNull("Not <root> definition", rootContDef); PrismContainerDefinition extensionContDef = rootContDef.findContainerDefinition(new ItemName(NS_FOO, "extension")); assertNotNull("Not <extension> definition", extensionContDef); assertEquals("Wrong <extension> type", new QName(NS_ROOT, "MyExtensionType"), extensionContDef.getTypeName()); }
return; // there's a definition already if (!complexTypeDefinition.getTypeName().equals(containerDef.getTypeName())) {
assertTrue("Wrong extension type "+extDef.getTypeName(), USER_EXTENSION_TYPE_QNAME.equals(extDef.getTypeName()) || USER_2_EXTENSION_TYPE_QNAME.equals(extDef.getTypeName())); assertEquals("Wrong extension displayOrder", (Integer)1000, extDef.getDisplayOrder());
assertEquals(new ItemName(SCHEMA_NS,"ContainerType"),newContainerDef.getTypeName());