Search in sources :

Example 1 with ComplexTypeDefinition

use of com.evolveum.midpoint.prism.ComplexTypeDefinition in project midpoint by Evolveum.

the class FocusActivationProcessor method getActivationDefinition.

private PrismContainerDefinition<ActivationType> getActivationDefinition() {
    if (activationDefinition == null) {
        ComplexTypeDefinition focusDefinition = prismContext.getSchemaRegistry().findComplexTypeDefinitionByType(FocusType.COMPLEX_TYPE);
        activationDefinition = focusDefinition.findContainerDefinition(FocusType.F_ACTIVATION);
    }
    return activationDefinition;
}
Also used : ComplexTypeDefinition(com.evolveum.midpoint.prism.ComplexTypeDefinition)

Example 2 with ComplexTypeDefinition

use of com.evolveum.midpoint.prism.ComplexTypeDefinition in project midpoint by Evolveum.

the class OpNode method matchesTraceType.

private boolean matchesTraceType(QName traceType) {
    ComplexTypeDefinition ctd = prismContext.getSchemaRegistry().findComplexTypeDefinitionByType(traceType);
    if (ctd == null) {
        throw new IllegalStateException("No complex type definition for '" + traceType + "'");
    }
    Class<?> traceClass = ctd.getCompileTimeClass();
    if (traceClass == null) {
        throw new IllegalStateException("Trace type '" + traceType + "' has no compile time class: " + ctd);
    }
    for (TraceType trace : result.getTrace()) {
        if (traceClass.isAssignableFrom(trace.getClass())) {
            return true;
        }
    }
    return false;
}
Also used : ComplexTypeDefinition(com.evolveum.midpoint.prism.ComplexTypeDefinition)

Example 3 with ComplexTypeDefinition

use of com.evolveum.midpoint.prism.ComplexTypeDefinition in project midpoint by Evolveum.

the class SchemaDocMojo method renderSchema.

private void renderSchema(PrismSchema schema, PrismContext prismContext, VelocityEngine velocityEngine, PathGenerator pathGenerator) throws IOException {
    getLog().info("Processing schema: " + schema);
    VelocityContext velocityContext = new VelocityContext();
    populateVelocityContextBase(velocityContext, prismContext, pathGenerator, schema, "..");
    Template template = velocityEngine.getTemplate(TEMPLATE_SCHEMA_NAME);
    Writer writer = new FileWriter(pathGenerator.prepareSchemaOutputFile(schema));
    template.merge(velocityContext, writer);
    writer.close();
    // Object Definitions
    for (PrismObjectDefinition objectDefinition : schema.getObjectDefinitions()) {
        renderObjectDefinition(objectDefinition, schema, prismContext, velocityEngine, pathGenerator);
    }
    // Types
    for (ComplexTypeDefinition typeDefinition : schema.getComplexTypeDefinitions()) {
        renderComplexTypeDefinition(typeDefinition, schema, prismContext, velocityEngine, pathGenerator);
    }
}
Also used : VelocityContext(org.apache.velocity.VelocityContext) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ComplexTypeDefinition(com.evolveum.midpoint.prism.ComplexTypeDefinition) Template(org.apache.velocity.Template)

Example 4 with ComplexTypeDefinition

use of com.evolveum.midpoint.prism.ComplexTypeDefinition in project midpoint by Evolveum.

the class FocusProcessor method getActivationDefinition.

private PrismContainerDefinition<ActivationType> getActivationDefinition() {
    if (activationDefinition == null) {
        ComplexTypeDefinition focusDefinition = prismContext.getSchemaRegistry().findComplexTypeDefinition(FocusType.COMPLEX_TYPE);
        activationDefinition = focusDefinition.findContainerDefinition(FocusType.F_ACTIVATION);
    }
    return activationDefinition;
}
Also used : ComplexTypeDefinition(com.evolveum.midpoint.prism.ComplexTypeDefinition)

Example 5 with ComplexTypeDefinition

use of com.evolveum.midpoint.prism.ComplexTypeDefinition in project midpoint by Evolveum.

the class TestDummyHacks method test003Connection.

/**
	 * This should be the very first test that works with the resource.
	 * 
	 * The original repository object does not have resource schema. The schema
	 * should be generated from the resource on the first use. This is the test
	 * that executes testResource and checks whether the schema was generated.
	 */
@Test
public void test003Connection() throws Exception {
    final String TEST_NAME = "test003Connection";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    // Check that there is no schema before test (pre-condition)
    ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result).asObjectable();
    assertNotNull("No connector ref", resourceBefore.getConnectorRef());
    assertNotNull("No connector ref OID", resourceBefore.getConnectorRef().getOid());
    ConnectorType connector = repositoryService.getObject(ConnectorType.class, resourceBefore.getConnectorRef().getOid(), null, result).asObjectable();
    assertNotNull(connector);
    XmlSchemaType xmlSchemaTypeBefore = resourceBefore.getSchema();
    Element resourceXsdSchemaElementBefore = ResourceTypeUtil.getResourceXsdSchema(resourceBefore);
    AssertJUnit.assertNull("Found schema before test connection. Bad test setup?", resourceXsdSchemaElementBefore);
    // WHEN
    OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_OID, task);
    // THEN
    display("Test result", testResult);
    TestUtil.assertSuccess("Test resource failed (result)", testResult);
    PrismObject<ResourceType> resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result);
    ResourceType resourceTypeRepoAfter = resourceRepoAfter.asObjectable();
    display("Resource after test", resourceTypeRepoAfter);
    XmlSchemaType xmlSchemaTypeAfter = resourceTypeRepoAfter.getSchema();
    assertNotNull("No schema after test connection", xmlSchemaTypeAfter);
    Element resourceXsdSchemaElementAfter = ResourceTypeUtil.getResourceXsdSchema(resourceTypeRepoAfter);
    assertNotNull("No schema after test connection", resourceXsdSchemaElementAfter);
    String resourceXml = prismContext.serializeObjectToString(resourceRepoAfter, PrismContext.LANG_XML);
    display("Resource XML", resourceXml);
    CachingMetadataType cachingMetadata = xmlSchemaTypeAfter.getCachingMetadata();
    assertNotNull("No caching metadata", cachingMetadata);
    assertNotNull("No retrievalTimestamp", cachingMetadata.getRetrievalTimestamp());
    assertNotNull("No serialNumber", cachingMetadata.getSerialNumber());
    Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaTypeAfter);
    ResourceSchema parsedSchema = ResourceSchemaImpl.parse(xsdElement, resourceBefore.toString(), prismContext);
    assertNotNull("No schema after parsing", parsedSchema);
    display("Parsed schema", parsedSchema);
    ComplexTypeDefinition accountDef = parsedSchema.findComplexTypeDefinition(new QName(parsedSchema.getNamespace(), SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME));
    assertNotNull("No account definition in schema after parsing", accountDef);
    PrismAsserts.assertPropertyDefinition(accountDef, SchemaConstants.ICFS_NAME, DOMUtil.XSD_STRING, 1, 1);
    PrismAsserts.assertPropertyDefinition(accountDef, new QName(SchemaConstants.NS_ICF_SCHEMA, "description"), DOMUtil.XSD_STRING, 0, 1);
    // The useless configuration variables should be reflected to the resource now
    assertEquals("Wrong useless string", "Shiver me timbers!", dummyResource.getUselessString());
    assertEquals("Wrong guarded useless string", "Dead men tell no tales", dummyResource.getUselessGuardedString());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) ComplexTypeDefinition(com.evolveum.midpoint.prism.ComplexTypeDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) XmlSchemaType(com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType) CachingMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

ComplexTypeDefinition (com.evolveum.midpoint.prism.ComplexTypeDefinition)7 Test (org.testng.annotations.Test)2 PrismObjectDefinition (com.evolveum.midpoint.prism.PrismObjectDefinition)1 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)1 RootXNode (com.evolveum.midpoint.prism.xnode.RootXNode)1 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)1 CachingMetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType)1 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)1 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)1 XmlSchemaType (com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType)1 QName (javax.xml.namespace.QName)1 Template (org.apache.velocity.Template)1 VelocityContext (org.apache.velocity.VelocityContext)1 Element (org.w3c.dom.Element)1