Search in sources :

Example 6 with ObjectClassComplexTypeDefinition

use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.

the class TestRefinedSchema method test122DetermineObjectClassKindIntentModel.

@Test
public void test122DetermineObjectClassKindIntentModel() throws Exception {
    final String TEST_NAME = "test122DetermineObjectClassKindIntentModel";
    TestUtil.displayTestTile(this, TEST_NAME);
    OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);
    importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE);
    Task task = taskManager.getTask(TASK_RECONCILE_DUMMY_KIND_INTENT_OID, result);
    display("Task", task);
    // WHEN
    ObjectClassComplexTypeDefinition objectClass = Utils.determineObjectClass(refinedSchemaModel, task);
    // THEN
    display("Object class", objectClass);
    display("Object class (toString)", objectClass.toString());
    deleteObject(TaskType.class, TASK_RECONCILE_DUMMY_KIND_INTENT_OID);
    assertLayerRefinedObjectClass(objectClass, RESOURCE_DUMMY_PRIVILEGE_OBJECTCLASS_QNAME, ShadowKindType.ENTITLEMENT, "privilege", LayerType.MODEL);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Test(org.testng.annotations.Test)

Example 7 with ObjectClassComplexTypeDefinition

use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.

the class TestRefinedSchema method test110DetermineObjectClassObjectClass.

@Test
public void test110DetermineObjectClassObjectClass() throws Exception {
    final String TEST_NAME = "test110DetermineObjectClassObjectClass";
    TestUtil.displayTestTile(this, TEST_NAME);
    OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);
    importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE);
    Task task = taskManager.getTask(TASK_RECONCILE_DUMMY_OBJECTCLASS_OID, result);
    display("Task", task);
    // WHEN
    ObjectClassComplexTypeDefinition objectClass = Utils.determineObjectClass(refinedSchema, task);
    // THEN
    display("Object class", objectClass);
    deleteObject(TaskType.class, TASK_RECONCILE_DUMMY_OBJECTCLASS_OID);
    assertObjectClass(objectClass, RESOURCE_DUMMY_ACCOUNT_OBJECTCLASS_QNAME);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Test(org.testng.annotations.Test)

Example 8 with ObjectClassComplexTypeDefinition

use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.

the class TestRefinedSchema method test120DetermineObjectClassObjectClassModel.

@Test
public void test120DetermineObjectClassObjectClassModel() throws Exception {
    final String TEST_NAME = "test120DetermineObjectClassObjectClassModel";
    TestUtil.displayTestTile(this, TEST_NAME);
    OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME);
    importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE);
    Task task = taskManager.getTask(TASK_RECONCILE_DUMMY_OBJECTCLASS_OID, result);
    display("Task", task);
    // WHEN
    ObjectClassComplexTypeDefinition objectClass = Utils.determineObjectClass(refinedSchemaModel, task);
    // THEN
    display("Object class", objectClass);
    display("Object class (toString)", objectClass.toString());
    deleteObject(TaskType.class, TASK_RECONCILE_DUMMY_OBJECTCLASS_OID);
    assertObjectClass(objectClass, RESOURCE_DUMMY_ACCOUNT_OBJECTCLASS_QNAME);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Test(org.testng.annotations.Test)

Example 9 with ObjectClassComplexTypeDefinition

use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.

the class ResourceDetailsTabPanel method getTaskFor.

private List<TaskType> getTaskFor(List<PrismObject<TaskType>> tasks, ObjectSynchronizationType synchronizationPolicy, PrismObject<ResourceType> resource) throws SchemaException {
    List<TaskType> syncTasks = new ArrayList<TaskType>();
    for (PrismObject<TaskType> task : tasks) {
        PrismProperty<ShadowKindType> taskKind = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND));
        ShadowKindType taskKindValue = null;
        if (taskKind != null) {
            taskKindValue = taskKind.getRealValue();
        }
        PrismProperty<String> taskIntent = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT));
        String taskIntentValue = null;
        if (taskIntent != null) {
            taskIntentValue = taskIntent.getRealValue();
        }
        PrismProperty<QName> taskObjectClass = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.OBJECTCLASS_PROPERTY_NAME));
        QName taskObjectClassValue = null;
        if (taskObjectClass != null) {
            taskObjectClassValue = taskObjectClass.getRealValue();
        }
        // is not accessible in admin-gui)
        if (taskObjectClassValue == null) {
            ObjectClassComplexTypeDefinition taskObjectClassDef = null;
            RefinedResourceSchema schema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
            if (schema == null) {
                throw new SchemaException("No schema defined in resource. Possible configuration problem?");
            }
            if (taskKindValue == null && taskIntentValue == null) {
                taskObjectClassDef = schema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
            }
            if (taskKindValue != null) {
                if (StringUtils.isEmpty(taskIntentValue)) {
                    taskObjectClassDef = schema.findDefaultObjectClassDefinition(taskKindValue);
                } else {
                    taskObjectClassDef = schema.findObjectClassDefinition(taskKindValue, taskIntentValue);
                }
            }
            if (taskObjectClassDef != null) {
                taskObjectClassValue = taskObjectClassDef.getTypeName();
            }
        }
        if (SynchronizationUtils.isPolicyApplicable(taskObjectClassValue, taskKindValue, taskIntentValue, synchronizationPolicy, resource)) {
            syncTasks.add(task.asObjectable());
        }
    }
    return syncTasks;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 10 with ObjectClassComplexTypeDefinition

use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.

the class AbstractCsvTest method test005ParsedSchema.

@Test
public void test005ParsedSchema() throws Exception {
    final String TEST_NAME = "test005ParsedSchema";
    TestUtil.displayTestTile(TEST_NAME);
    // THEN
    // The returned type should have the schema pre-parsed
    assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType));
    // Also test if the utility method returns the same thing
    ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext);
    display("Parsed resource schema", resourceSchema);
    assertNotNull("No resource schema", resourceSchema);
    ObjectClassComplexTypeDefinition accountDef = resourceSchema.findObjectClassDefinition(RESOURCE_CSV_ACCOUNT_OBJECTCLASS);
    assertNotNull("Account definition is missing", accountDef);
    assertNotNull("Null identifiers in account", accountDef.getPrimaryIdentifiers());
    assertFalse("Empty identifiers in account", accountDef.getPrimaryIdentifiers().isEmpty());
    assertNotNull("No naming attribute in account", accountDef.getNamingAttribute());
    assertFalse("No nativeObjectClass in account", StringUtils.isEmpty(accountDef.getNativeObjectClass()));
    assertAccountDefinition(accountDef);
    ResourceAttributeDefinition<String> icfsNameDef = accountDef.findAttributeDefinition(SchemaConstants.ICFS_NAME);
    assertNull("ICFS NAME definition sneaked in", icfsNameDef);
    ResourceAttributeDefinition<String> icfsUidDef = accountDef.findAttributeDefinition(SchemaConstants.ICFS_UID);
    assertNull("ICFS UID definition sneaked in", icfsUidDef);
    // Check whether it is reusing the existing schema and not parsing it all over again
    // Not equals() but == ... we want to really know if exactly the same
    // object instance is returned
    assertTrue("Broken caching", resourceSchema == RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext));
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Test(org.testng.annotations.Test) AbstractProvisioningIntegrationTest(com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)

Aggregations

ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)53 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)18 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)17 Test (org.testng.annotations.Test)17 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)16 QName (javax.xml.namespace.QName)16 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ArrayList (java.util.ArrayList)11 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)8 Task (com.evolveum.midpoint.task.api.Task)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)5 Containerable (com.evolveum.midpoint.prism.Containerable)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)4 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)3 ResultHandler (com.evolveum.midpoint.provisioning.ucf.api.ResultHandler)3 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)3