public boolean deleteRawElement(Object element) throws SchemaException { checkMutability(); PrismContainerDefinition<C> definition = getDefinition(); if (definition == null) { throw new UnsupportedOperationException("Definition-less containers are not supported any more."); } else { // We have definition here, we can parse it right now Item<?,?> subitem = parseRawElement(element, definition); return subtract(subitem); } }
public boolean addRawElement(Object element) throws SchemaException { checkMutability(); PrismContainerDefinition<C> definition = getDefinition(); if (definition == null) { throw new UnsupportedOperationException("Definition-less containers are not supported any more."); } else { // We have definition here, we can parse it right now Item<?,?> subitem = parseRawElement(element, definition); return merge(subitem); } }
@Override public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope) { ItemPath myPath = getPath(); if (getDefinition() == null) { throw new IllegalStateException("Definition-less container value " + this +" ("+myPath+" in "+rootItem+")"); } if (items != null) { for (Item<?,?> item: items) { if (scope.isThorough()) { if (item == null) { throw new IllegalStateException("Null item in container value "+this+" ("+myPath+" in "+rootItem+")"); } if (item.getParent() == null) { throw new IllegalStateException("No parent for item "+item+" in container value "+this+" ("+myPath+" in "+rootItem+")"); } if (item.getParent() != this) { throw new IllegalStateException("Wrong parent for item "+item+" in container value "+this+" ("+myPath+" in "+rootItem+"), " + "bad parent: "+ item.getParent()); } } item.checkConsistenceInternal(rootItem, requireDefinitions, prohibitRaw, scope); } } }
public <X> PrismProperty<X> createProperty(QName propertyName) throws SchemaException { checkMutability(); PrismPropertyDefinition propertyDefinition = determineItemDefinition(propertyName, getComplexTypeDefinition()); if (propertyDefinition == null) { // container has definition, but there is no property definition. This is either runtime schema // or an error if (getParent() != null && getDefinition() != null && !getDefinition().isRuntimeSchema()) { // TODO clean this up throw new IllegalArgumentException("No definition for property "+propertyName+" in "+complexTypeDefinition); } } PrismProperty<X> property; if (propertyDefinition == null) { property = new PrismPropertyImpl<>(propertyName, prismContext); // Definitionless } else { property = propertyDefinition.instantiate(); } add(property, false); return property; }
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! }
@SuppressWarnings("Duplicates") private boolean representsSameValue(PrismContainerValue<C> other, boolean lax) { if (lax && getParent() != null) { PrismContainerDefinition definition = getDefinition(); if (definition != null) { if (definition.isSingleValue()) { // There is only one value, therefore it always represents the same thing return true; } } } if (lax && other.getParent() != null) { PrismContainerDefinition definition = other.getDefinition(); if (definition != null) { if (definition.isSingleValue()) { // There is only one value, therefore it always represents the same thing return true; } } } return this.getId() != null && other.getId() != null && this.getId().equals(other.getId()); }