private static void addToPrismValues(List<PrismPropertyValue<?>> pVals, PrismContext prismContext, Object value) { if (value == null) { return; } if (value instanceof Collection) { for (Object o : (Collection) value) { addToPrismValues(pVals, prismContext, o); } return; } if (value.getClass().isArray()) { throw new IllegalStateException("Array within array in filter creation: " + value); } PrismPropertyValue<?> pVal; if (value instanceof PrismPropertyValue) { pVal = (PrismPropertyValue<?>) value; if (pVal.getParent() != null) { pVal = pVal.clone(); } } else { pVal = new PrismPropertyValueImpl<>(value); } PrismUtil.recomputePrismPropertyValue(pVal, prismContext); pVals.add(pVal); }
private <T> PrismPropertyValue<T> filterValue(PrismPropertyValue<T> propertyValue, List<ValueFilterType> filters) { PrismPropertyValue<T> filteredValue = propertyValue.clone(); filteredValue.setOriginType(OriginType.INBOUND); if (filters == null || filters.isEmpty()) { return filteredValue; } for (ValueFilterType filter : filters) { Filter filterInstance = filterManager.getFilterInstance(filter.getType(), filter.getAny()); filterInstance.apply(filteredValue); } return filteredValue; }
@Override protected ItemDelta fixupDelta(ItemDelta delta, Item otherItem) { PrismPropertyDefinition def = getDefinition(); if (def != null && def.isSingleValue() && !delta.isEmpty()) { // Drop the current delta (it was used only to detect that something has changed // Generate replace delta instead of add/delete delta PrismProperty<T> other = (PrismProperty<T>)otherItem; PropertyDelta<T> propertyDelta = (PropertyDelta<T>)delta; delta.clear(); Collection<PrismPropertyValue<T>> replaceValues = new ArrayList<>(other.getValues().size()); for (PrismPropertyValue<T> value : other.getValues()) { replaceValues.add(value.clone()); } propertyDelta.setValuesToReplace(replaceValues); return propertyDelta; } else { return super.fixupDelta(delta, otherItem); } }
private <T> List<PrismPropertyValue<T>> getNormalizedValue(PrismProperty<T> attr, RefinedObjectClassDefinition rObjClassDef) throws SchemaException { RefinedAttributeDefinition<T> refinedAttributeDefinition = rObjClassDef.findAttributeDefinition(attr.getElementName()); QName matchingRuleQName = refinedAttributeDefinition.getMatchingRuleQName(); MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(matchingRuleQName, refinedAttributeDefinition.getTypeName()); List<PrismPropertyValue<T>> normalized = new ArrayList<>(); for (PrismPropertyValue<T> origPValue : attr.getValues()){ T normalizedValue = matchingRule.normalize(origPValue.getValue()); PrismPropertyValue<T> normalizedPValue = origPValue.clone(); normalizedPValue.setValue(normalizedValue); normalized.add(normalizedPValue); } return normalized; }
if (currentProperty != null) { for (PrismPropertyValue currentValue : currentProperty.getValues()) { currentValues.add(currentValue.clone()); for (PrismPropertyValue valueToAdd : propertyDelta.getValuesToAdd()) { if (!PrismValueCollectionsUtil.containsValue(currentValues, valueToAdd, comparator)) { currentValues.add(valueToAdd.clone()); } else { LOGGER.warn("Attempting to add a value of {} that is already present in {}: {}",
if (!PrismValueCollectionsUtil.containsRealValue(hasValues, shouldHaveValue)) { if (targetItemDefinition.isSingleValue()) { targetItemDelta.setValueToReplace(shouldHaveValue.clone()); } else { targetItemDelta.addValueToAdd(shouldHaveValue.clone()); for (PrismPropertyValue<T> hasValue: hasValues) { if (!PrismValueCollectionsUtil.containsRealValue(shouldHaveValues, hasValue)) { targetItemDelta.addValueToDelete(hasValue.clone());
for (PrismPropertyValue<T> ppval : eqFilter.getValues()) { T normalizedRealValue = matchingRule.normalize(ppval.getValue()); PrismPropertyValue<T> newPPval = ppval.clone(); newPPval.setValue(normalizedRealValue); newValues.add(newPPval);
static ResourceAttributeContainer convertFromContainer(PrismContainer<?> origAttrContainer, ObjectClassComplexTypeDefinition objectClassDefinition) throws SchemaException { if (origAttrContainer == null || origAttrContainer.getValue() == null) { return null; } QName elementName = origAttrContainer.getElementName(); ResourceAttributeContainer attributesContainer = createEmptyContainer(elementName, objectClassDefinition); for (Item item: origAttrContainer.getValue().getItems()) { if (item instanceof PrismProperty) { PrismProperty<?> property = (PrismProperty)item; QName attributeName = property.getElementName(); ResourceAttributeDefinition attributeDefinition = objectClassDefinition.findAttributeDefinition(attributeName); if (attributeDefinition == null) { throw new SchemaException("No definition for attribute "+attributeName+" in object class "+objectClassDefinition); } ResourceAttribute attribute = new ResourceAttributeImpl(attributeName, attributeDefinition , property.getPrismContext()); for(PrismPropertyValue pval: property.getValues()) { attribute.add(pval.clone()); } attributesContainer.add(attribute); attribute.applyDefinition(attributeDefinition); } else { throw new SchemaException("Cannot process item of type "+item.getClass().getSimpleName()+", attributes can only be properties"); } } return attributesContainer; }
throw new IllegalStateException("Secondary identifier has more than one value: " + secondaryIdentifier.getValues()); } else if (secondaryIdentifierValues.size() == 1) { secondaryIdentifierValue = secondaryIdentifierValues.get(0).clone(); } else { secondaryIdentifierValue = null;
private ObjectDelta<? extends ObjectType> createDelta(ObjectType objectType, PipelineData deltaData) throws ScriptExecutionException { if (deltaData.getData().size() != 1) { throw new ScriptExecutionException("Expected exactly one delta to apply, found " + deltaData.getData().size() + " instead."); } @SuppressWarnings({"unchecked", "raw"}) ObjectDeltaType deltaType = ((PrismPropertyValue<ObjectDeltaType>) deltaData.getData().get(0).getValue()).clone().getRealValue(); if (deltaType.getChangeType() == null) { deltaType.setChangeType(ChangeTypeType.MODIFY); } if (deltaType.getOid() == null && deltaType.getChangeType() != ChangeTypeType.ADD) { deltaType.setOid(objectType.getOid()); } if (deltaType.getObjectType() == null) { if (objectType.asPrismObject().getDefinition() == null) { throw new ScriptExecutionException("No definition for prism object " + objectType); } deltaType.setObjectType(objectType.asPrismObject().getDefinition().getTypeName()); } try { return DeltaConvertor.createObjectDelta(deltaType, prismContext); } catch (SchemaException e) { throw new ScriptExecutionException("Couldn't process delta due to schema exception", e); } } }
valueAttribute.add(assocAttrPVal.clone());
for (PrismPropertyValue val : values){ if ("A".equals(val.getValue())){ deleteDelta.addValueToDelete(val.clone());