Search in sources :

Example 1 with SchemaRegistryImpl

use of com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl in project midpoint by Evolveum.

the class TestSchemaRegistry method testReferenceInExtension.

@Test
public void testReferenceInExtension() throws SchemaException, SAXException, IOException {
    MidPointPrismContextFactory factory = getContextFactory();
    PrismContext context = factory.createInitializedPrismContext();
    SchemaRegistry schemaRegistry = context.getSchemaRegistry();
    // Common schema should be parsed during creation of the context
    ((SchemaRegistryImpl) schemaRegistry).loadPrismSchemaResource("schema/extension.xsd");
    // Check that the extension schema was loaded
    PrismSchema extensionSchema = schemaRegistry.findSchemaByNamespace(EXTENSION_SCHEMA_NAMESPACE);
    assertNotNull("Extension schema not parsed", extensionSchema);
    ItemDefinition itemDefinition = schemaRegistry.findItemDefinitionByElementName(TestConstants.EXTENSION_USER_REF_ELEMENT);
    assertNotNull("userRef element definition was not found", itemDefinition);
    System.out.println("UserRef definition:");
    System.out.println(itemDefinition.debugDump());
    assertTrue("Wrong userRef definition class: " + itemDefinition.getClass(), itemDefinition instanceof PrismReferenceDefinition);
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) SchemaRegistryImpl(com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest)

Example 2 with SchemaRegistryImpl

use of com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl in project midpoint by Evolveum.

the class MidPointPrismContextFactory method createSchemaRegistry.

@NotNull
private SchemaRegistryImpl createSchemaRegistry() throws SchemaException, IOException {
    SchemaRegistryImpl schemaRegistry = new AxiomEnabledSchemaRegistry();
    schemaRegistry.setDefaultNamespace(SchemaConstantsGenerated.NS_COMMON);
    schemaRegistry.setNamespacePrefixMapper(new GlobalDynamicNamespacePrefixMapper());
    registerBuiltinSchemas(schemaRegistry);
    registerExtensionSchemas(schemaRegistry);
    registerAxiomSchemas(schemaRegistry);
    schemaRegistry.setValueMetadataTypeName(ValueMetadataType.COMPLEX_TYPE);
    return schemaRegistry;
}
Also used : SchemaRegistryImpl(com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl) AxiomEnabledSchemaRegistry(com.evolveum.midpoint.prism.impl.schema.axiom.AxiomEnabledSchemaRegistry) GlobalDynamicNamespacePrefixMapper(com.evolveum.midpoint.prism.impl.xml.GlobalDynamicNamespacePrefixMapper) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with SchemaRegistryImpl

use of com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl in project midpoint by Evolveum.

the class MidPointPrismContextFactory method createEmptyPrismContext.

public PrismContext createEmptyPrismContext() throws SchemaException, IOException {
    SchemaRegistryImpl schemaRegistry = createSchemaRegistry();
    PrismContextImpl context = PrismContextImpl.createEmptyContext(schemaRegistry);
    context.setDefinitionFactory(createDefinitionFactory());
    context.setDefaultRelation(SchemaConstants.ORG_DEFAULT);
    context.setObjectsElementName(SchemaConstants.C_OBJECTS);
    context.setDefaultReferenceTypeName(ObjectReferenceType.COMPLEX_TYPE);
    context.setExtensionContainerTypeName(ExtensionType.COMPLEX_TYPE);
    return context;
}
Also used : PrismContextImpl(com.evolveum.midpoint.prism.impl.PrismContextImpl) SchemaRegistryImpl(com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl)

Example 4 with SchemaRegistryImpl

use of com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl in project midpoint by Evolveum.

the class MidPointPrismContextFactory method createPrismContext.

@Override
public PrismContext createPrismContext() throws SchemaException, IOException {
    SchemaRegistryImpl schemaRegistry = createSchemaRegistry();
    PrismContextImpl context = PrismContextImpl.create(schemaRegistry);
    context.setDefinitionFactory(createDefinitionFactory());
    context.setDefaultRelation(SchemaConstants.ORG_DEFAULT);
    context.setObjectsElementName(SchemaConstants.C_OBJECTS);
    context.setDefaultReferenceTypeName(ObjectReferenceType.COMPLEX_TYPE);
    context.setExtensionContainerTypeName(ExtensionType.COMPLEX_TYPE);
    if (InternalsConfig.isPrismMonitoring()) {
        context.setMonitor(new InternalMonitor());
    }
    context.setParsingMigrator(new MidpointParsingMigrator());
    context.setValueMetadataFactory(new MidpointValueMetadataFactory(context));
    context.setProvenanceEquivalenceStrategy(MidpointProvenanceEquivalenceStrategy.INSTANCE);
    context.registerQueryExpressionFactory(new PrismQueryExpressionSupport());
    return context;
}
Also used : InternalMonitor(com.evolveum.midpoint.schema.internals.InternalMonitor) MidpointValueMetadataFactory(com.evolveum.midpoint.schema.metadata.MidpointValueMetadataFactory) PrismContextImpl(com.evolveum.midpoint.prism.impl.PrismContextImpl) SchemaRegistryImpl(com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl)

Aggregations

SchemaRegistryImpl (com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl)4 PrismContextImpl (com.evolveum.midpoint.prism.impl.PrismContextImpl)2 AxiomEnabledSchemaRegistry (com.evolveum.midpoint.prism.impl.schema.axiom.AxiomEnabledSchemaRegistry)1 GlobalDynamicNamespacePrefixMapper (com.evolveum.midpoint.prism.impl.xml.GlobalDynamicNamespacePrefixMapper)1 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)1 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)1 InternalMonitor (com.evolveum.midpoint.schema.internals.InternalMonitor)1 MidpointValueMetadataFactory (com.evolveum.midpoint.schema.metadata.MidpointValueMetadataFactory)1 AbstractUnitTest (com.evolveum.midpoint.tools.testng.AbstractUnitTest)1 NotNull (org.jetbrains.annotations.NotNull)1 Test (org.testng.annotations.Test)1