use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class ObjectDeltaWaves method toObjectDeltaWavesType.
public ObjectDeltaWavesType toObjectDeltaWavesType() throws SchemaException {
ObjectDeltaWavesType objectDeltaWavesType = new ObjectDeltaWavesType();
for (int i = 0; i < waves.size(); i++) {
ObjectDelta wave = waves.get(i);
if (wave != null) {
ObjectDeltaWaveType objectDeltaWaveType = new ObjectDeltaWaveType();
objectDeltaWaveType.setNumber(i);
objectDeltaWaveType.setDelta(DeltaConvertor.toObjectDeltaType(wave));
objectDeltaWavesType.getWave().add(objectDeltaWaveType);
}
}
return objectDeltaWavesType;
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class LensFocusContext method fromLensFocusContextType.
public static LensFocusContext fromLensFocusContextType(LensFocusContextType focusContextType, LensContext lensContext, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException {
String objectTypeClassString = focusContextType.getObjectTypeClass();
if (StringUtils.isEmpty(objectTypeClassString)) {
throw new SystemException("Object type class is undefined in LensFocusContextType");
}
LensFocusContext lensFocusContext;
try {
lensFocusContext = new LensFocusContext(Class.forName(objectTypeClassString), lensContext);
} catch (ClassNotFoundException e) {
throw new SystemException("Couldn't instantiate LensFocusContext because object type class couldn't be found", e);
}
lensFocusContext.retrieveFromLensElementContextType(focusContextType, task, result);
lensFocusContext.secondaryDeltas = ObjectDeltaWaves.fromObjectDeltaWavesType(focusContextType.getSecondaryDeltas(), lensContext.getPrismContext());
// fixing provisioning type in delta (however, this is not usually needed, unless primary object is shadow or resource
Objectable object;
if (lensFocusContext.getObjectNew() != null) {
object = lensFocusContext.getObjectNew().asObjectable();
} else if (lensFocusContext.getObjectOld() != null) {
object = lensFocusContext.getObjectOld().asObjectable();
} else {
object = null;
}
for (Object o : lensFocusContext.secondaryDeltas) {
ObjectDelta<? extends ObjectType> delta = (ObjectDelta<? extends ObjectType>) o;
if (delta != null) {
lensFocusContext.fixProvisioningTypeInDelta(delta, object, task, result);
}
}
return lensFocusContext;
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class WebModelServiceUtils method createActivationAdminStatusDelta.
public static <T extends ObjectType> ObjectDelta<T> createActivationAdminStatusDelta(Class<T> type, String oid, boolean enabled, PrismContext context) {
ItemPath path = new ItemPath(FocusType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS);
ActivationStatusType status = enabled ? ActivationStatusType.ENABLED : ActivationStatusType.DISABLED;
ObjectDelta objectDelta = ObjectDelta.createModificationReplaceProperty(type, oid, path, context, status);
return objectDelta;
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class PageAssignmentsList method prepareDelta.
private ObjectDelta prepareDelta(OperationResult result) {
ObjectDelta delta = null;
try {
delta = ObjectDelta.createModificationAddContainer(UserType.class, "fakeOid", FocusType.F_ASSIGNMENT, getPrismContext(), getAddAssignmentContainerValues(assignmentsModel.getObject()));
if (!getSessionStorage().getRoleCatalog().isMultiUserRequest()) {
List<PrismObject<UserType>> usersList = getSessionStorage().getRoleCatalog().getTargetUserList();
PrismObject<UserType> user = getSessionStorage().getRoleCatalog().isSelfRequest() ? loadUserSelf(PageAssignmentsList.this) : usersList.get(0);
delta.addModificationDeleteContainer(FocusType.F_ASSIGNMENT, getDeleteAssignmentContainerValues(user.asObjectable()));
}
} catch (SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to prepare delta for operation " + OPERATION_REQUEST_ASSIGNMENTS, e);
result.recordFatalError("Failed to prepare delta for operation " + OPERATION_REQUEST_ASSIGNMENTS, e);
}
return delta;
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class ObjectWrapperTest method testEmptyPolyString.
@Test
public void testEmptyPolyString() throws Exception {
PrismObject<UserType> user = prismContext.parseObject(new File("./src/test/resources/wrapper/user.xml"));
Task task = taskManager.createTaskInstance("testEmptyPolyString");
ObjectWrapperFactory owf = new ObjectWrapperFactory(null);
ObjectWrapper<UserType> wrapper = owf.createObjectWrapper(null, null, user, ContainerStatus.MODIFYING, task);
//simulate change on honorific prefix
ContainerWrapper containerWrapper = null;
for (ContainerWrapper container : wrapper.getContainers()) {
if (container.isMain()) {
containerWrapper = container;
break;
}
}
PropertyWrapper propertyWrapper = (PropertyWrapper) containerWrapper.findPropertyWrapper(UserType.F_HONORIFIC_SUFFIX);
ValueWrapper valueWrapper = (ValueWrapper) propertyWrapper.getValues().get(0);
PolyString value = (PolyString) ((PrismPropertyValue) valueWrapper.getValue()).getValue();
Field orig = PolyString.class.getDeclaredField("orig");
orig.setAccessible(true);
orig.set(value, null);
orig.setAccessible(false);
ObjectDelta delta = wrapper.getObjectDelta();
AssertJUnit.assertNotNull(delta);
}
Aggregations