Search in sources :

Example 1 with Mapper

use of com.evolveum.midpoint.repo.sql.helpers.mapper.Mapper 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 Mapper

use of com.evolveum.midpoint.repo.sql.helpers.mapper.Mapper 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)

Aggregations

PrismValue (com.evolveum.midpoint.prism.PrismValue)2 Mapper (com.evolveum.midpoint.repo.sql.helpers.mapper.Mapper)2 MapperContext (com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext)2 ROperationResult (com.evolveum.midpoint.repo.sql.data.common.ROperationResult)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1