use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class TaskQuartzImpl method addExtensionPropertyAndPrepareDelta.
private ItemDelta<?, ?> addExtensionPropertyAndPrepareDelta(QName itemName, PrismPropertyDefinition definition, Collection<? extends PrismPropertyValue> values) throws SchemaException {
ItemDelta delta = new PropertyDelta(new ItemPath(TaskType.F_EXTENSION, itemName), definition, getPrismContext());
delta.addValuesToAdd(values);
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>(1);
modifications.add(delta);
// i.e. here we apply changes only locally (in memory)
PropertyDelta.applyTo(modifications, taskPrism);
return isPersistent() ? delta : null;
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class TaskQuartzImpl method storeExtensionDeltas.
private void storeExtensionDeltas(List<ItemDeltaType> result, Collection<ItemDelta<?, ?>> extensionDeltas) {
for (ItemDelta itemDelta : extensionDeltas) {
Collection<ItemDeltaType> deltaTypes = null;
try {
deltaTypes = DeltaConvertor.toItemDeltaTypes(itemDelta);
} catch (SchemaException e) {
throw new SystemException("Unexpected SchemaException when converting extension ItemDelta to ItemDeltaType", e);
}
result.addAll(deltaTypes);
}
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class AddGetObjectTest method addGetCompare.
private void addGetCompare(File file) throws Exception {
List<PrismObject<? extends Objectable>> elements = prismContext.parserFor(file).parseObjects();
List<String> oids = new ArrayList<String>();
OperationResult result = new OperationResult("Simple Add Get Test");
long time = System.currentTimeMillis();
for (int i = 0; i < elements.size(); i++) {
PrismObject object = elements.get(i);
LOGGER.info("Adding object {}, type {}", new Object[] { (i + 1), object.getCompileTimeClass().getSimpleName() });
oids.add(repositoryService.addObject(object, null, result));
}
LOGGER.info("Time to add objects ({}): {}", new Object[] { elements.size(), (System.currentTimeMillis() - time) });
int count = 0;
elements = prismContext.parserFor(file).parseObjects();
for (int i = 0; i < elements.size(); i++) {
try {
PrismObject object = elements.get(i);
object.asObjectable().setOid(oids.get(i));
Class<? extends ObjectType> clazz = object.getCompileTimeClass();
Collection o = null;
if (UserType.class.equals(clazz)) {
o = SelectorOptions.createCollection(UserType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
} else if (LookupTableType.class.equals(clazz)) {
o = SelectorOptions.createCollection(LookupTableType.F_ROW, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
} else if (AccessCertificationCampaignType.class.equals(clazz)) {
o = SelectorOptions.createCollection(AccessCertificationCampaignType.F_CASE, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
}
PrismObject<? extends ObjectType> newObject = repositoryService.getObject(clazz, oids.get(i), o, result);
LOGGER.info("Old\n{}\nnew\n{}", new Object[] { object.debugDump(3), newObject.debugDump(3) });
checkContainersSize(newObject, object);
System.out.println("OLD: " + object.findProperty(ObjectType.F_NAME).getValue());
System.out.println("NEW: " + newObject.findProperty(ObjectType.F_NAME).getValue());
ObjectDelta delta = object.diff(newObject);
if (delta == null) {
continue;
}
count += delta.getModifications().size();
if (delta.getModifications().size() > 0) {
if (delta.getModifications().size() == 1) {
ItemDelta d = (ItemDelta) delta.getModifications().iterator().next();
if (ShadowType.F_DEAD.equals(d.getElementName())) {
count -= delta.getModifications().size();
continue;
}
}
LOGGER.error(">>> {} Found {} changes for {}\n{}", new Object[] { (i + 1), delta.getModifications().size(), newObject.toString(), delta.debugDump(3) });
ItemDelta id = (ItemDelta) delta.getModifications().iterator().next();
if (id.isReplace()) {
System.out.println(id.getValuesToReplace().iterator().next());
}
LOGGER.error("{}", prismContext.serializeObjectToString(newObject, PrismContext.LANG_XML));
}
} catch (Exception ex) {
LOGGER.error("Exception occurred", ex);
throw ex;
}
}
AssertJUnit.assertEquals("Found changes during add/get test " + count, 0, count);
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class CertificationTest method test210ModifyCaseProperties.
@Test
public void test210ModifyCaseProperties() throws Exception {
OperationResult result = new OperationResult("test210ModifyCaseProperties");
List<ItemDelta<?, ?>> modifications = new ArrayList<>();
ItemPath case1 = new ItemPath(F_CASE).subPath(new IdItemPathSegment(1L));
modifications.add(createModificationReplaceProperty(case1.subPath(F_CURRENT_STAGE_OUTCOME), campaignDef, SchemaConstants.MODEL_CERTIFICATION_OUTCOME_REDUCE));
modifications.add(createModificationReplaceProperty(case1.subPath(AccessCertificationCaseType.F_STAGE_NUMBER), campaignDef, 300));
executeAndCheckModification(modifications, result, 0);
checksCountsStandard(result);
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class CertificationTest method test200ModifyCampaignProperties.
@Test
public void test200ModifyCampaignProperties() throws Exception {
OperationResult result = new OperationResult("test200ModifyCampaignProperties");
List<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add(createModificationReplaceProperty(F_NAME, campaignDef, new PolyString("Campaign 1+", "campaign 1")));
modifications.add(createModificationReplaceProperty(F_STATE, campaignDef, IN_REVIEW_STAGE));
executeAndCheckModification(modifications, result, 1);
checksCountsStandard(result);
}
Aggregations