Search in sources :

Example 1 with F_ACTIVATION

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType.F_ACTIVATION in project midpoint by Evolveum.

the class FocusValidityScannerTaskHandler method createQuery.

@Override
protected ObjectQuery createQuery(AbstractScannerResultHandler<UserType> handler, TaskRunResult runResult, Task coordinatorTask, OperationResult opResult) throws SchemaException {
    initProcessedOids(coordinatorTask);
    ObjectQuery query = new ObjectQuery();
    ObjectFilter filter;
    PrismObjectDefinition<UserType> focusObjectDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
    XMLGregorianCalendar lastScanTimestamp = handler.getLastScanTimestamp();
    XMLGregorianCalendar thisScanTimestamp = handler.getThisScanTimestamp();
    if (lastScanTimestamp == null) {
        filter = QueryBuilder.queryFor(FocusType.class, prismContext).item(F_ACTIVATION, F_VALID_FROM).le(thisScanTimestamp).or().item(F_ACTIVATION, F_VALID_TO).le(thisScanTimestamp).or().exists(F_ASSIGNMENT).block().item(AssignmentType.F_ACTIVATION, F_VALID_FROM).le(thisScanTimestamp).or().item(AssignmentType.F_ACTIVATION, F_VALID_TO).le(thisScanTimestamp).endBlock().buildFilter();
    } else {
        filter = QueryBuilder.queryFor(FocusType.class, prismContext).item(F_ACTIVATION, F_VALID_FROM).gt(lastScanTimestamp).and().item(F_ACTIVATION, F_VALID_FROM).le(thisScanTimestamp).or().item(F_ACTIVATION, F_VALID_TO).gt(lastScanTimestamp).and().item(F_ACTIVATION, F_VALID_TO).le(thisScanTimestamp).or().exists(F_ASSIGNMENT).block().item(AssignmentType.F_ACTIVATION, F_VALID_FROM).gt(lastScanTimestamp).and().item(AssignmentType.F_ACTIVATION, F_VALID_FROM).le(thisScanTimestamp).or().item(AssignmentType.F_ACTIVATION, F_VALID_TO).gt(lastScanTimestamp).and().item(AssignmentType.F_ACTIVATION, F_VALID_TO).le(thisScanTimestamp).endBlock().buildFilter();
    }
    query.setFilter(filter);
    return query;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 2 with F_ACTIVATION

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType.F_ACTIVATION in project midpoint by Evolveum.

the class TestAbstractAssignmentEvaluator method test200DisableEngineerEmployeeInducement.

/**
	 * Disable Engineer -> Employee inducement.
	 */
@Test(enabled = false)
public void test200DisableEngineerEmployeeInducement() throws Exception {
    final String TEST_NAME = "test200DisableEngineerEmployeeInducement";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // disable Engineer->Employee inducement
    ObjectDelta disableInducementDelta = DeltaBuilder.deltaFor(RoleType.class, prismContext).item(RoleType.F_INDUCEMENT, 3, F_ACTIVATION, F_ADMINISTRATIVE_STATUS).replace(ActivationStatusType.DISABLED).asObjectDelta(ROLE_CORP_ENGINEER_OID);
    modelService.executeChanges(Collections.singletonList(disableInducementDelta), null, task, result);
    AssignmentEvaluator<UserType> assignmentEvaluator = createAssignmentEvaluator();
    PrismAsserts.assertParentConsistency(userTypeJack.asPrismObject());
    AssignmentType assignmentType = getAssignmentType(ASSIGNMENT_ROLE_ENGINEER_FILE);
    ObjectDeltaObject<UserType> userOdo = new ObjectDeltaObject<>(userTypeJack.asPrismObject(), null, null);
    userOdo.recompute();
    ItemDeltaItem<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> assignmentIdi = new ItemDeltaItem<>();
    assignmentIdi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(assignmentType));
    assignmentIdi.recompute();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    EvaluatedAssignmentImpl<UserType> evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", task, result);
    evaluatedAssignment.evaluateConstructions(userOdo, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertNotNull(evaluatedAssignment);
    display("Evaluated assignment", evaluatedAssignment.debugDump());
// TODO
//		assertEquals(2, evaluatedAssignment.getConstructions().size());
//		PrismAsserts.assertParentConsistency(userTypeJack.asPrismObject());
//
//		assertConstruction(evaluatedAssignment, ZERO, "title", ZERO, "Engineer");
//		assertConstruction(evaluatedAssignment, ZERO, "title", PLUS);
//		assertConstruction(evaluatedAssignment, ZERO, "title", MINUS);
//		assertNoConstruction(evaluatedAssignment, PLUS, "title");
//		assertNoConstruction(evaluatedAssignment, MINUS, "title");
//
//		assertConstruction(evaluatedAssignment, ZERO, "location", ZERO, "Caribbean");
//		assertConstruction(evaluatedAssignment, ZERO, "location", PLUS);
//		assertConstruction(evaluatedAssignment, ZERO, "location", MINUS);
//		assertNoConstruction(evaluatedAssignment, PLUS, "location");
//		assertNoConstruction(evaluatedAssignment, MINUS, "location");
//
//		assertEquals("Wrong number of admin GUI configs", 1, evaluatedAssignment.getAdminGuiConfigurations().size());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDeltaObject(com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject) ItemDeltaItem(com.evolveum.midpoint.repo.common.expression.ItemDeltaItem) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 3 with F_ACTIVATION

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType.F_ACTIVATION in project midpoint by Evolveum.

the class TestAbstractAssignmentEvaluator method test299ReenableEngineerEmployeeInducement.

@Test(enabled = false)
public void test299ReenableEngineerEmployeeInducement() throws Exception {
    final String TEST_NAME = "test299ReenableEngineerEmployeeInducement";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // disable Engineer->Employee inducement
    ObjectDelta enableInducementDelta = DeltaBuilder.deltaFor(RoleType.class, prismContext).item(RoleType.F_INDUCEMENT, 3, F_ACTIVATION, F_ADMINISTRATIVE_STATUS).replace(ActivationStatusType.DISABLED).asObjectDelta(ROLE_CORP_ENGINEER_OID);
    modelService.executeChanges(Collections.singletonList(enableInducementDelta), null, task, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test)

Aggregations

ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 Test (org.testng.annotations.Test)2 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 ItemDeltaItem (com.evolveum.midpoint.repo.common.expression.ItemDeltaItem)1 ObjectDeltaObject (com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject)1 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1