use of com.evolveum.midpoint.prism.PrismValue in project midpoint by Evolveum.
the class LiteralExpressionEvaluator method parseAndConvert.
private Item<V, D> parseAndConvert(ExpressionEvaluationContext context) throws SchemaException {
// noinspection unchecked
Item<V, D> item = outputDefinition.instantiate();
List<Object> values = StaticExpressionUtil.parseValueElements(expressionEvaluatorBean, context.getContextDescription());
Function<Object, Object> convertor = context.getAdditionalConvertor();
for (Object value : values) {
PrismValue prismValue = prismContext.itemFactory().createValue(convertor.apply(value));
// noinspection unchecked
item.add((V) prismValue);
}
return item;
}
use of com.evolveum.midpoint.prism.PrismValue in project midpoint by Evolveum.
the class ExtensionItemDeltaProcessor method process.
@Override
public void process(ItemDelta<?, ?> modification) throws RepositoryException, SchemaException {
ItemPath itemPath = modification.getPath();
if (modification.getDefinition() instanceof PrismContainerDefinition<?>) {
// We do not index containers
return;
}
Item<PrismValue, ?> item = context.findValueOrItem(itemPath);
Collection<?> realValues = item != null ? item.getRealValues() : null;
ItemDefinition<?> definition = modification.getDefinition();
Objects.requireNonNull(definition, "Item '" + itemPath + "' without definition can't be saved.");
ExtensionProcessor extProcessor = new ExtensionProcessor(context.repositoryContext());
ExtensionProcessor.ExtItemInfo extItemInfo = extProcessor.findExtensionItem(definition, holderType);
if (extItemInfo == null) {
// not-indexed, no action
return;
}
// If the extension is single value (and we know it now, we should proceed with deletion of
// multivalue variant and vice-versa (this variants may be indroduced during raw import
// or changes in multiplicity of extension definition or resource definition
context.deleteItem(reverseCardinality(extProcessor, extItemInfo.item));
if (realValues == null || realValues.isEmpty()) {
context.deleteItem(extItemInfo.getId());
return;
}
// changed value
context.setChangedItem(extItemInfo.getId(), extProcessor.extItemValue(item, extItemInfo));
}
use of com.evolveum.midpoint.prism.PrismValue in project midpoint by Evolveum.
the class GeneralUpdate method updateBasicOrEmbedded.
private void updateBasicOrEmbedded(Attribute attribute) {
String attributeName = attribute.getName();
PrismValue prismValue;
if (delta.isAdd()) {
prismValue = getSingleValue(attribute, delta.getValuesToAdd());
} else if (delta.isReplace()) {
if (!delta.getValuesToReplace().isEmpty()) {
prismValue = getSingleValue(attribute, delta.getValuesToReplace());
} else {
prismValue = null;
}
} else if (delta.isDelete()) {
// No values to add nor to replace, only deletions. Because we narrowed the delta before, we know that this delete
// delta is relevant - i.e. after its application, the (single) value of property will be removed.
prismValue = null;
} else {
// This should not occur. The narrowing process eliminates empty deltas.
LOGGER.warn("Empty delta {} for attribute {} of {} -- skipping it", delta, attributeName, currentBean.getClass().getName());
return;
}
Object value = prismValue != null ? prismValue.getRealValue() : null;
Class attributeValueType = getAttributeValueType(attribute);
// noinspection unchecked
Object valueMapped = beans.prismEntityMapper.map(value, attributeValueType);
try {
LOGGER.trace("Setting simple property {} to {}", attributeName, valueMapped);
PropertyUtils.setSimpleProperty(currentBean, attributeName, valueMapped);
} catch (Exception ex) {
throw new SystemException("Couldn't set simple property for '" + attributeName + "'", ex);
}
}
use of com.evolveum.midpoint.prism.PrismValue 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.prism.PrismValue in project midpoint by Evolveum.
the class ExtensionUpdate method processExtensionDeltaValueSet.
private void processExtensionDeltaValueSet(Collection<? extends PrismValue> prismValuesFromDelta, Integer itemId, RAnyConverter.ValueType valueType, RepositoryUpdater repositoryUpdater) {
if (prismValuesFromDelta != null) {
RAnyConverter converter = new RAnyConverter(beans.prismContext, beans.extItemDictionary);
try {
Collection<PrismEntityPair<RAnyValue<?>>> rValuesFromDelta = new ArrayList<>();
for (PrismValue prismValueFromDelta : prismValuesFromDelta) {
RAnyValue<?> rValueFromDelta = convertToRValue(itemId, converter, prismValueFromDelta);
rValuesFromDelta.add(new PrismEntityPair<>(prismValueFromDelta, rValueFromDelta));
}
processExtensionValues(valueType, rValuesFromDelta, repositoryUpdater);
} catch (SchemaException ex) {
throw new SystemException("Couldn't process extension attributes", ex);
}
}
}
Aggregations