Search in sources :

Example 1 with MapperContext

use of com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext in project midpoint by Evolveum.

the class OperationResultUpdate method handleItemDelta.

void handleItemDelta() {
    if (!(object instanceof ROperationResult)) {
        throw new SystemException("Bean is not instance of " + ROperationResult.class + ", shouldn't happen");
    }
    PrismValue value;
    if (delta.isDelete()) {
        value = null;
    } else {
        value = delta.getAnyValue();
    }
    MapperContext context = new MapperContext();
    context.setRepositoryContext(beans.createRepositoryContext());
    context.setDelta(delta);
    context.setOwner(object);
    if (value != null) {
        beans.prismEntityMapper.mapPrismValue(value, ROperationResult.class, context);
    } else {
        // todo clean this up
        // we know that mapper supports mapping null value, but still this code smells
        Mapper mapper = beans.prismEntityMapper.getMapper(OperationResultType.class, ROperationResult.class);
        // noinspection unchecked
        mapper.map(null, context);
    }
}
Also used : Mapper(com.evolveum.midpoint.repo.sql.helpers.mapper.Mapper) MapperContext(com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext) SystemException(com.evolveum.midpoint.util.exception.SystemException) ROperationResult(com.evolveum.midpoint.repo.sql.data.common.ROperationResult) PrismValue(com.evolveum.midpoint.prism.PrismValue)

Example 2 with MapperContext

use of com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext in project midpoint by Evolveum.

the class PasswordMetadataUpdate method handlePropertyDelta.

public void handlePropertyDelta() throws SchemaException {
    if (!(object instanceof RFocus)) {
        throw new SystemException("Bean is not instance of " + RFocus.class + ", shouldn't happen");
    }
    RFocus focus = (RFocus) object;
    if (isDelete()) {
        focus.setPasswordCreateTimestamp(null);
        focus.setModifyTimestamp(null);
        return;
    }
    PrismValue value = delta.getAnyValue();
    MapperContext context = new MapperContext();
    context.setRepositoryContext(beans.createRepositoryContext());
    context.setDelta(delta);
    context.setOwner(object);
    beans.prismEntityMapper.mapPrismValue(value, RFocus.class, context);
}
Also used : MapperContext(com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext) SystemException(com.evolveum.midpoint.util.exception.SystemException) RFocus(com.evolveum.midpoint.repo.sql.data.common.RFocus) PrismValue(com.evolveum.midpoint.prism.PrismValue)

Example 3 with MapperContext

use of com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext in project midpoint by Evolveum.

the class CollectionUpdate method mapToRepo.

private R mapToRepo(V value, boolean trans) {
    MapperContext context = new MapperContext();
    context.setRepositoryContext(ctx.beans.createRepositoryContext());
    context.setDelta(delta);
    context.setOwner(collectionOwner);
    R repo = ctx.beans.prismEntityMapper.mapPrismValue(value, attributeValueType, context);
    if (repo instanceof EntityState) {
        ((EntityState) repo).setTransient(trans);
    }
    return repo;
}
Also used : MapperContext(com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext) EntityState(com.evolveum.midpoint.repo.sql.util.EntityState)

Example 4 with MapperContext

use of com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext in project midpoint by Evolveum.

the class MetadataUpdate method handleWholeContainerDelta.

void handleWholeContainerDelta() {
    PrismValue value;
    if (delta.isDelete()) {
        value = null;
    } else {
        value = delta.getAnyValue();
    }
    MapperContext context = new MapperContext();
    context.setRepositoryContext(beans.createRepositoryContext());
    context.setDelta(delta);
    context.setOwner(metadataHolder);
    if (value != null) {
        beans.prismEntityMapper.mapPrismValue(value, Metadata.class, context);
    } else {
        // todo clean this up
        // we know that mapper supports mapping null value, but still this code smells
        Mapper mapper = beans.prismEntityMapper.getMapper(MetadataType.class, Metadata.class);
        // noinspection unchecked
        mapper.map(null, context);
    }
}
Also used : Mapper(com.evolveum.midpoint.repo.sql.helpers.mapper.Mapper) MapperContext(com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext) PrismValue(com.evolveum.midpoint.prism.PrismValue)

Example 5 with MapperContext

use of com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext in project midpoint by Evolveum.

the class PhotoUpdate method handlePropertyDelta.

public void handlePropertyDelta() throws SchemaException {
    if (!(object instanceof RFocus)) {
        throw new SystemException("Bean is not instance of " + RFocus.class + ", shouldn't happen");
    }
    RFocus focus = (RFocus) object;
    Set<RFocusPhoto> photos = focus.getJpegPhoto();
    if (isDelete()) {
        photos.clear();
        return;
    }
    MapperContext context = new MapperContext();
    context.setRepositoryContext(beans.createRepositoryContext());
    context.setDelta(delta);
    context.setOwner(object);
    PrismValue value = delta.getAnyValue();
    RFocusPhoto photo = beans.prismEntityMapper.map(value.getRealValue(), RFocusPhoto.class, context);
    if (delta.isAdd()) {
        if (!photos.isEmpty()) {
            throw new SchemaException("Object '" + focus.getOid() + "' already contains photo");
        }
        photo.setTransient(true);
        photos.add(photo);
        return;
    }
    if (photos.isEmpty()) {
        photo.setTransient(true);
        photos.add(photo);
        return;
    }
    RFocusPhoto oldPhoto = photos.iterator().next();
    oldPhoto.setPhoto(photo.getPhoto());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) MapperContext(com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext) SystemException(com.evolveum.midpoint.util.exception.SystemException) RFocusPhoto(com.evolveum.midpoint.repo.sql.data.common.RFocusPhoto) RFocus(com.evolveum.midpoint.repo.sql.data.common.RFocus) PrismValue(com.evolveum.midpoint.prism.PrismValue)

Aggregations

MapperContext (com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext)5 PrismValue (com.evolveum.midpoint.prism.PrismValue)4 SystemException (com.evolveum.midpoint.util.exception.SystemException)3 RFocus (com.evolveum.midpoint.repo.sql.data.common.RFocus)2 Mapper (com.evolveum.midpoint.repo.sql.helpers.mapper.Mapper)2 RFocusPhoto (com.evolveum.midpoint.repo.sql.data.common.RFocusPhoto)1 ROperationResult (com.evolveum.midpoint.repo.sql.data.common.ROperationResult)1 EntityState (com.evolveum.midpoint.repo.sql.util.EntityState)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1