Search in sources :

Example 41 with ObjectDelta

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;
}
Also used : ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ObjectDeltaWavesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaWavesType) ObjectDeltaWaveType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaWaveType)

Example 42 with ObjectDelta

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;
}
Also used : Objectable(com.evolveum.midpoint.prism.Objectable) ObjectDeltaObject(com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 43 with ObjectDelta

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;
}
Also used : ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 44 with 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;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 45 with ObjectDelta

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);
}
Also used : Field(java.lang.reflect.Field) Task(com.evolveum.midpoint.task.api.Task) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) File(java.io.File) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)445 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)363 Task (com.evolveum.midpoint.task.api.Task)326 Test (org.testng.annotations.Test)303 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)242 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)218 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)148 ArrayList (java.util.ArrayList)126 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)103 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)55 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)47 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)42 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)41 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)38 ShadowDiscriminatorObjectDelta (com.evolveum.midpoint.common.refinery.ShadowDiscriminatorObjectDelta)32 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)31 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)31 Collection (java.util.Collection)31 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)31 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)26