Search in sources :

Example 46 with PrismValue

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);
    }
}
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 47 with PrismValue

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

Example 48 with PrismValue

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;
}
Also used : ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) PrismValue(com.evolveum.midpoint.prism.PrismValue) NotNull(org.jetbrains.annotations.NotNull)

Example 49 with PrismValue

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

PrismValue (com.evolveum.midpoint.prism.PrismValue)49 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)15 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)9 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)8 Item (com.evolveum.midpoint.prism.Item)7 ArrayList (java.util.ArrayList)7 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)6 QName (javax.xml.namespace.QName)6 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 PipelineItem (com.evolveum.midpoint.model.api.PipelineItem)4 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)4 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)4 MapperContext (com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext)4 SystemException (com.evolveum.midpoint.util.exception.SystemException)4 PipelineData (com.evolveum.midpoint.model.impl.scripting.PipelineData)2 Objectable (com.evolveum.midpoint.prism.Objectable)2 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)2