use of com.evolveum.midpoint.prism.delta.ReferenceDelta in project midpoint by Evolveum.
the class ContainerWrapper method computeReferenceDeltas.
private ReferenceDelta computeReferenceDeltas(ReferenceWrapper referenceWrapper, ItemPath containerPath) {
PrismReferenceDefinition propertyDef = referenceWrapper.getItemDefinition();
ReferenceDelta pDelta = new ReferenceDelta(containerPath, propertyDef.getName(), propertyDef, propertyDef.getPrismContext());
addItemDelta(referenceWrapper, pDelta, propertyDef, containerPath.subPath(propertyDef.getName()));
return pDelta;
}
use of com.evolveum.midpoint.prism.delta.ReferenceDelta in project midpoint by Evolveum.
the class ContainerWrapper method collectModifications.
public <O extends ObjectType> void collectModifications(ObjectDelta<O> delta) throws SchemaException {
if (getItemDefinition().getName().equals(ShadowType.F_ASSOCIATION)) {
//create ContainerDelta for association container
//HACK HACK HACK create correct procession for association container data
//according to its structure
ContainerDelta<ShadowAssociationType> associationDelta = ContainerDelta.createDelta(ShadowType.F_ASSOCIATION, (PrismContainerDefinition<ShadowAssociationType>) getItemDefinition());
for (ItemWrapper itemWrapper : getItems()) {
AssociationWrapper associationItemWrapper = (AssociationWrapper) itemWrapper;
List<ValueWrapper> assocValueWrappers = associationItemWrapper.getValues();
for (ValueWrapper assocValueWrapper : assocValueWrappers) {
PrismContainerValue<ShadowAssociationType> assocValue = (PrismContainerValue<ShadowAssociationType>) assocValueWrapper.getValue();
if (!assocValue.isEmpty()) {
if (assocValueWrapper.getStatus() == ValueStatus.DELETED) {
associationDelta.addValueToDelete(assocValue.clone());
} else if (assocValueWrapper.getStatus().equals(ValueStatus.ADDED)) {
associationDelta.addValueToAdd(assocValue.clone());
}
}
}
}
if (!associationDelta.isEmpty()) {
delta.addModification(associationDelta);
}
} else {
if (!hasChanged()) {
return;
}
for (ItemWrapper itemWrapper : getItems()) {
if (!itemWrapper.hasChanged()) {
continue;
}
ItemPath containerPath = getPath() != null ? getPath() : new ItemPath();
if (itemWrapper instanceof PropertyWrapper) {
ItemDelta pDelta = computePropertyDeltas((PropertyWrapper) itemWrapper, containerPath);
if (!pDelta.isEmpty()) {
//HACK to remove a password replace delta is to be created
if (getName().equals(CredentialsType.F_PASSWORD)) {
if (pDelta.getValuesToDelete() != null) {
pDelta.resetValuesToDelete();
pDelta.setValuesToReplace(new ArrayList());
}
}
delta.addModification(pDelta);
}
} else if (itemWrapper instanceof ReferenceWrapper) {
ReferenceDelta pDelta = computeReferenceDeltas((ReferenceWrapper) itemWrapper, containerPath);
if (!pDelta.isEmpty()) {
delta.addModification(pDelta);
}
} else {
LOGGER.trace("Delta from wrapper: ignoring {}", itemWrapper);
}
}
}
}
use of com.evolveum.midpoint.prism.delta.ReferenceDelta in project midpoint by Evolveum.
the class PrismAsserts method assertReferenceReplace.
public static void assertReferenceReplace(ObjectDelta<?> objectDelta, QName refName, String... expectedOids) {
ReferenceDelta refDelta = objectDelta.findReferenceModification(refName);
assertNotNull("Reference delta for " + refName + " not found", refDelta);
assertOidSet("delta " + refDelta + " for " + refName, "replace", refDelta.getValuesToReplace(), expectedOids);
}
use of com.evolveum.midpoint.prism.delta.ReferenceDelta in project midpoint by Evolveum.
the class OperationalDataManager method createModifyMetadataDeltas.
public <F extends ObjectType, T extends ObjectType> Collection<? extends ItemDelta<?, ?>> createModifyMetadataDeltas(LensContext<F> context, ItemPath metadataPath, PrismObjectDefinition<T> def, XMLGregorianCalendar now, Task task) {
Collection<? extends ItemDelta<?, ?>> deltas = new ArrayList<>();
String channel = LensUtil.getChannel(context, task);
if (channel != null) {
PropertyDelta<String> delta = PropertyDelta.createModificationReplaceProperty(metadataPath.subPath(MetadataType.F_MODIFY_CHANNEL), def, channel);
((Collection) deltas).add(delta);
}
PropertyDelta<XMLGregorianCalendar> delta = PropertyDelta.createModificationReplaceProperty(metadataPath.subPath(MetadataType.F_MODIFY_TIMESTAMP), def, now);
((Collection) deltas).add(delta);
if (task.getOwner() != null) {
ReferenceDelta refDelta = ReferenceDelta.createModificationReplace(metadataPath.subPath(MetadataType.F_MODIFIER_REF), def, task.getOwner().getOid());
((Collection) deltas).add(refDelta);
}
return deltas;
}
use of com.evolveum.midpoint.prism.delta.ReferenceDelta in project midpoint by Evolveum.
the class TestModelServiceContract method test128ModifyUserDeleteAccountRef.
@Test
public void test128ModifyUserDeleteAccountRef() throws Exception {
TestUtil.displayTestTile(this, "test128ModifyUserDeleteAccountRef");
// GIVEN
Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test128ModifyUserDeleteAccountRef");
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
PrismObject<ShadowType> account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE);
ObjectDelta<UserType> userDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, USER_JACK_OID, prismContext);
PrismReferenceValue accountRefVal = new PrismReferenceValue();
accountRefVal.setObject(account);
ReferenceDelta accountDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountJackOid);
userDelta.addModification(accountDelta);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
assertShadowFetchOperationCountIncrement(0);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
assertUserJack(userJack);
// Check accountRef
assertUserNoAccountRefs(userJack);
// Check shadow (if it is unchanged)
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountJackOid, null, result);
assertDummyAccountShadowRepo(accountShadow, accountJackOid, "jack");
// Check account (if it is unchanged)
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountJackOid, null, task, result);
assertDummyAccountShadowModel(accountModel, accountJackOid, "jack", "Jack Sparrow");
// Check account in dummy resource (if it is unchanged)
assertDefaultDummyAccount("jack", "Jack Sparrow", true);
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(1);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionSuccess();
// Check notifications
notificationManager.setDisabled(true);
checkDummyTransportMessages("accountPasswordNotifier", 0);
checkDummyTransportMessages("userPasswordNotifier", 0);
checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 0);
checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 0);
checkDummyTransportMessages("simpleAccountNotifier-DELETE-SUCCESS", 0);
checkDummyTransportMessages("simpleUserNotifier", 0);
checkDummyTransportMessages("simpleUserNotifier-ADD", 0);
assertSteadyResources();
}
Aggregations