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);
}
}
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);
}
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;
}
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);
}
}
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());
}
Aggregations