use of com.evolveum.midpoint.prism.PrismValue 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.prism.PrismValue in project midpoint by Evolveum.
the class ValueTupleTransformation method dumpValueCombinationToTrace.
private void dumpValueCombinationToTrace() {
Iterator<SourceTriple<?, ?>> sourceTriplesIterator = combinatorialEvaluation.sourceTripleList.iterator();
for (PrismValue pval : valuesTuple) {
SourceTriple<?, ?> sourceTriple = sourceTriplesIterator.next();
trace.getInput().add(TraceUtil.toNamedValueType(pval, sourceTriple.getName(), combinatorialEvaluation.prismContext));
}
trace.setInputOrigin(sets.stream().map(this::toChar).collect(Collectors.joining()));
}
use of com.evolveum.midpoint.prism.PrismValue in project midpoint by Evolveum.
the class ValueTupleTransformation method createStaticVariablesFromSources.
/**
* @return Final form of static (delta-less) variables derived from the sources.
* Also sets hasPlus/hasZero/hasMinus flags.
*/
@NotNull
private VariablesMap createStaticVariablesFromSources() {
VariablesMap staticVariables = new VariablesMap();
for (int sourceIndex = 0; sourceIndex < numberOfSources; sourceIndex++) {
// This strange casting is needed because of presentInPlusSet/MinusSet/ZeroSet calls
// that expect the same type as the SourceTriple has.
// noinspection unchecked
SourceTriple<PrismValue, ?> sourceTriple = (SourceTriple<PrismValue, ?>) sourceTripleList.get(sourceIndex);
PrismValue value = valuesTuple.get(sourceIndex);
String name = sourceTriple.getName().getLocalPart();
ItemDefinition definition = sourceTriple.getSource().getDefinition();
if (definition == null) {
// TODO reconsider @NotNull annotation on getDefinition
throw new IllegalArgumentException("Source '" + name + "' without a definition");
}
staticVariables.put(name, getRealContent(value, sourceTriple.getResidualPath()), definition);
// }
if (context.getVariableProducer() != null) {
context.getVariableProducer().processSourceValue(sourceTriple.getSource(), value, context.getVariables());
}
}
return staticVariables;
}
use of com.evolveum.midpoint.prism.PrismValue 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