use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class TestUserTemplate method test245ModifyUserRappLocalityUnderReconcile.
/**
* Similar to test244, but also use reconcile option.
* MID-3040
*/
@Test
public void test245ModifyUserRappLocalityUnderReconcile() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = getTestOperationResult();
PrismObject<UserType> userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result);
display("User before", userBefore);
ObjectDelta<UserType> objectDelta = createModifyUserReplaceDelta(USER_RAPP_OID, UserType.F_LOCALITY, PrismTestUtil.createPolyString("Six feet under"));
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
ModelExecuteOptions options = executeOptions().reconcile();
// WHEN
modelService.executeChanges(deltas, options, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result);
display("User after", userAfter);
assertAssignedAccount(userAfter, RESOURCE_DUMMY_BLUE_OID);
assertAssignedRole(userAfter, ROLE_RASTAMAN_OID);
assertAssignments(userAfter, 2);
UserType userAfterType = userAfter.asObjectable();
assertLiveLinks(userAfter, 1);
// There is a mapping "locality->timezone" in the object template (plus: High Seas/Six feet under)
// but also a mapping "()->timezone" in Rastaman role (zero: Caribbean/Whatever)
// Because the normal mapping is source-less, it is evaluated and its result is taken into account.
assertEquals("Wrong timezone", "Caribbean/Whatever", userAfterType.getTimezone());
assertEquals("Wrong locale", "WE", userAfterType.getLocale());
assertEquals("Unexpected value of employeeNumber", "D3ADB33F", userAfterType.getEmployeeNumber());
assertEquals("Wrong costCenter", "CC-RAPP", userAfterType.getCostCenter());
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class MainObjectListPanel method deleteConfirmedPerformed.
private void deleteConfirmedPerformed(AjaxRequestTarget target, O objectToDelete) {
List<O> objects = isAnythingSelected(target, objectToDelete);
if (objects.isEmpty()) {
return;
}
OperationResult result = new OperationResult(objects.size() == 1 ? OPERATION_DELETE_OBJECT : OPERATION_DELETE_OBJECTS);
for (O object : objects) {
OperationResult subResult = result.createSubresult(OPERATION_DELETE_OBJECT);
try {
Task task = getPageBase().createSimpleTask(OPERATION_DELETE_OBJECT);
ObjectDelta delta = getPrismContext().deltaFactory().object().create(objectToDelete.getClass(), ChangeType.DELETE);
delta.setOid(object.getOid());
ExecuteChangeOptionsDto executeOptions = getExecuteOptions();
ModelExecuteOptions options = executeOptions.createOptions(getPrismContext());
LOGGER.debug("Using options {}.", executeOptions);
getPageBase().getModelService().executeChanges(MiscUtil.createCollection(delta), options, task, subResult);
subResult.computeStatus();
} catch (Exception ex) {
subResult.recomputeStatus();
subResult.recordFatalError(getString("PageUsers.message.delete.fatalError"), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete user", ex);
}
}
result.computeStatusComposite();
clearCache();
getPageBase().showResult(result);
target.add(getFeedbackPanel());
refreshTable(target);
clearCache();
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class ExecuteChangeOptionsDto method createOptions.
@NotNull
public ModelExecuteOptions createOptions(PrismContext prismContext) {
ModelExecuteOptions options = new ModelExecuteOptions(prismContext);
options.force(isForce());
options.reconcile(isReconcile());
options.executeImmediatelyAfterApproval(!isExecuteAfterAllApprovals());
options.tracingProfile(tracing);
return options;
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class MappingImpl method determinePushChangesRequested.
@Override
protected boolean determinePushChangesRequested() {
ModelContext<ObjectType> lensContext = ModelExpressionThreadLocalHolder.getLensContext();
ModelExecuteOptions options = lensContext != null ? lensContext.getOptions() : null;
return ModelExecuteOptions.isPushChanges(options);
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class TestMiscellaneous method test250SkippingApprovals.
@Test
public void test250SkippingApprovals() throws Exception {
login(userAdministrator);
Task task = getTestTask();
OperationResult result = getTestOperationResult();
given();
setDefaultUserTemplate(null);
unassignAllRoles(userJackOid);
assertNotAssignedRole(userJackOid, ROLE_CAPTAIN.oid, result);
when();
ObjectDelta<? extends ObjectType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).add(ObjectTypeUtil.createAssignmentTo(ROLE_CAPTAIN.oid, ObjectTypes.ROLE, prismContext)).asObjectDelta(userJackOid);
ModelExecuteOptions options = executeOptions().partialProcessing(new PartialProcessingOptionsType().approvals(PartialProcessingTypeType.SKIP));
modelService.executeChanges(singletonList(delta), options, task, result);
then();
result.computeStatus();
TestUtil.assertSuccess(result);
assertAssignedRole(userJackOid, ROLE_CAPTAIN.oid, result);
}
Aggregations