public static void assertDefinition(Item item, QName type, int minOccurs, int maxOccurs) { ItemDefinition definition = item.getDefinition(); assertDefinition(definition, item.getElementName(), type, minOccurs, maxOccurs); }
static boolean hasNoValues(Item<?, ?> item) { return item == null || item.getValues().isEmpty(); }
List<QName> noDefinition = new ArrayList<>(); for (Item item : items) { if (item.getDefinition() != null) { boolean isHidden = NotificationFunctionsImpl.isAmongHiddenPaths(item.getPath(), hiddenPaths); if (!isHidden && (showOperationalAttributes || !item.getDefinition().isOperational()) && !item.isEmpty()) { toBeDisplayed.add(item); noDefinition.add(item.getElementName()); Integer order1 = item1.getDefinition().getDisplayOrder(); Integer order2 = item2.getDefinition().getDisplayOrder(); if (order1 != null && order2 != null) { return order1 - order2;
private boolean hasNoValue(Item aPrioriTargetItem) { return aPrioriTargetItem == null || (aPrioriTargetItem.isEmpty() && !aPrioriTargetItem.isIncomplete()); }
private V getSingleValue(Item<V, D> item) { if (item == null || item.isEmpty()) { return null; } else if (item.size() == 1) { return item.getAnyValue(); } else { throw new IllegalStateException("Multiple values where single one was expected: " + item); } }
public static <V extends PrismValue, D extends ItemDefinition> ItemDelta<V, D> createAddDeltaFor(Item<V, D> item) { ItemDelta<V, D> rv = item.createDelta(item.getPath()); rv.addValuesToAdd(item.getClonedValues()); return rv; }
shouldBeItem.add(LensUtil.cloneAndApplyMetadata(itemWithOrigin.getItemValue(), isAssignment, shouldBeItemValues)); if (targetFocusItem != null && targetFocusItem.contains(value, EquivalenceStrategy.REAL_VALUE)) { continue; if (targetFocusItem != null && !targetFocusItem.getDefinition().isMultiValue() && !targetFocusItem.isEmpty()) { Collection<V> replace = new ArrayList<>(); replace.add(LensUtil.cloneAndApplyMetadata(value, isAssignment, originMapping.getMappingType())); if (targetFocusItem == null || targetFocusItem.contains(value, EquivalenceStrategy.REAL_VALUE)) { if (!outputFocusItemDelta.isReplace()) { ItemDelta diffDelta = targetFocusItem.diff(shouldBeItem); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Comparing focus item:\n{}\nto should be item:\n{}\ndiff:\n{} ", for (Object shouldBeValueObj : shouldBeItem.getValues()) { PrismValue shouldBeValue = (PrismValue) shouldBeValueObj; if (!PrismValueCollectionsUtil.containsRealValue(diffDelta.getValuesToReplace(), shouldBeValue)) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Adding user property because inbound say so (account doesn't contain that value):\n{}", shouldBeItem.getValues()); outputFocusItemDelta.addValuesToAdd(shouldBeItem.getClonedValues());
Item otherItem = other.findItem(thisItem.getElementName()); if (!strategy.isConsideringOperationalData()) { ItemDefinition itemDef = thisItem.getDefinition(); if (itemDef == null && other.getDefinition() != null) { itemDef = other.getDefinition().findLocalItemDefinition(thisItem.getElementName()); Item thisItem = thisValue.findItem(otherItem.getElementName()); if (thisItem != null) { ItemDefinition itemDef = otherItem.getDefinition(); if (itemDef == null && thisValue.getDefinition() != null) { itemDef = thisValue.getDefinition().findLocalItemDefinition(otherItem.getElementName()); ItemDelta itemDelta = otherItem.createDelta(); itemDelta.addValuesToAdd(otherItem.getClonedValues()); if (!itemDelta.isEmpty()) { ((Collection)deltas).add(itemDelta);
public static String prettyPrint(Item<?, ?> item) { String values = item.getValues().stream() .map(value -> PrettyPrinter.prettyPrint(value)) .collect(Collectors.joining(", ")); return PrettyPrinter.prettyPrint(item.getElementName()) + "={" + values + "}"; }
ItemPath itemPath = item.getPath(); if (itemPath.isEmpty()) { return; if (item.getDefinition().isSingleValue()) {
private boolean hasMetadata(PrismContainerValue<R> cVal) { for (Item<?, ?> item : cVal.getItems()) { QName itemName = item.getElementName(); if (itemName.equals(AbstractCredentialType.F_METADATA)) { return true; } } return false; }
return true; if (item.isEmpty()) { return false; if (subitems != null) { for (Item<?, ?> subitem: subitems) { ItemDefinition subItemDef = subitem.getDefinition(); if (subItemDef == null && itemDef != null) { subItemDef = ((PrismContainerDefinition)itemDef).findItemDefinition(subitem.getElementName());
public ItemDefinition<?> getSourceDefinition() { return sourceItem != null ? sourceItem.getDefinition() : null; }
/** * Marshals everything from the item except for the root node. * Separated from marshalItemAsRoot in order to be reusable. */ @NotNull private XNodeImpl marshalItemContent(@NotNull Item<?, ?> item, ItemDefinition itemDefinition, SerializationContext context) throws SchemaException { if (item.size() == 1) { return marshalItemValue(item.getAnyValue(), itemDefinition, null, context); } else { ListXNodeImpl xlist = new ListXNodeImpl(); for (PrismValue val : item.getValues()) { xlist.add(marshalItemValue(val, itemDefinition, null, context)); } return xlist; } }
private <IV extends PrismValue,ID extends ItemDefinition, I extends Item<IV,ID>> void deepCloneDefinitionItem(I item, boolean ultraDeep, PrismContainerDefinition<C> clonedContainerDef, Consumer<ItemDefinition> postCloneAction) { PrismContainerDefinition<C> oldContainerDef = getDefinition(); ItemName itemName = item.getElementName(); ID oldItemDefFromContainer = oldContainerDef.findItemDefinition(itemName); ID oldItemDef = item.getDefinition(); ID clonedItemDef; if (oldItemDefFromContainer == oldItemDef) { clonedItemDef = clonedContainerDef.findItemDefinition(itemName); } else { clonedItemDef = (ID) oldItemDef.deepClone(ultraDeep, postCloneAction); } ((ItemImpl) item).propagateDeepCloneDefinition(ultraDeep, clonedItemDef, postCloneAction); // propagate to items in values item.setDefinition(clonedItemDef); // sets CTD in values only if null! }
@Override public Long getAssignmentId() { Item<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> any = assignmentIdi.getAnyItem(); return any != null && !any.getValues().isEmpty() ? any.getAnyValue().getId() : null; }
while (iterator.hasNext()) { Item<?,?> item = iterator.next(); ItemPath itemPath = item.getPath(); ItemDefinition<?> itemDef = item.getDefinition(); if (itemDef != null && itemDef.isElaborate()) { LOGGER.trace("applySecurityConstraints(item): {}: skip (elaborate)", itemPath); boolean itemWasEmpty = item.isEmpty(); // to prevent removal of originally empty items List<? extends PrismContainerValue<?>> values = ((PrismContainer<?>)item).getValues(); Iterator<? extends PrismContainerValue<?>> vi = values.iterator(); if (!itemWasEmpty && item.isEmpty()) { iterator.remove();
private FactorOutResultMulti<O> factorOutValuesForAddDelta(ItemPath path, boolean cloneDelta) { Item<?, ?> item = objectToAdd.findItem(path); if (item == null || item.isEmpty()) { return new FactorOutResultMulti<>(this); } ObjectDeltaImpl<O> remainder = cloneIfRequested(cloneDelta); remainder.getObjectToAdd().remove(item); FactorOutResultMulti<O> rv = new FactorOutResultMulti<>(remainder); for (PrismValue value : item.getValues()) { ObjectDeltaImpl<O> offspring = createOffspring(); offspring.addModification(ItemDeltaUtil.createAddDeltaFor(item, value)); rv.offsprings.add(offspring); } return rv; }
@SuppressWarnings("unchecked") public void mergeContent(PrismContainerValue<?> other, List<QName> overwrite) throws SchemaException { List<ItemName> remainingToOverwrite = overwrite.stream().map(ItemName::fromQName).collect(Collectors.toList()); if (other.getItems() != null) { for (Item<?, ?> otherItem : other.getItems()) { Item<?, ?> existingItem = findItem(otherItem.getElementName()); if (QNameUtil.remove(remainingToOverwrite, otherItem.getElementName()) || existingItem != null && existingItem.isSingleValue()) { remove(existingItem); } merge(otherItem.clone()); } } remainingToOverwrite.forEach(name -> removeItem(name, Item.class)); }
public static <IV extends PrismValue,ID extends ItemDefinition> List<JAXBElement<RawType>> serializeValueElements(Item<IV,ID> item, String contextDescription) throws SchemaException { if (item == null) { return null; } List<JAXBElement<RawType>> elements = new ArrayList<>(item.size()); for (PrismValue value : item.getValues()) { RootXNode xnode = item.getPrismContext().xnodeSerializer().serialize(value); RawType rawType = new RawType(xnode.getSubnode(), item.getPrismContext()); JAXBElement<RawType> jaxbElement = new JAXBElement<>(SchemaConstants.C_VALUE, RawType.class, rawType); elements.add(jaxbElement); } return elements; }