public ItemDefinition getDefinition() { Item<V,D> anyItem = getAnyItem(); if (anyItem != null) { return anyItem.getDefinition(); } if (delta != null) { return delta.getDefinition(); } return null; }
private String formatPath(ItemDelta itemDelta) { if (itemDelta.getDefinition() != null && itemDelta.getDefinition().getDisplayName() != null) { return itemDelta.getDefinition().getDisplayName(); } StringBuilder sb = new StringBuilder(); for (Object segment : itemDelta.getPath().getSegments()) { if (ItemPath.isName(segment)) { if (sb.length() > 0) { sb.append("/"); } sb.append(ItemPath.toName(segment).getLocalPart()); } } return sb.toString(); }
private PrismValue toPrismValue(ItemDelta<?,?> currentDelta, @NotNull Object v) { ItemDefinition definition = currentDelta.getDefinition(); if (definition instanceof PrismPropertyDefinition) { return new PrismPropertyValueImpl<>(v); } else if (definition instanceof PrismContainerDefinition) { return ((Containerable) v).asPrismContainerValue(); } else if (definition instanceof PrismReferenceDefinition) { if (v instanceof Referencable) { return ((Referencable) v).asReferenceValue(); } else { throw new IllegalStateException("Expected Referencable, got: " + v); } } else { throw new IllegalStateException("Unsupported definition type: " + definition); } }
private String getItemDeltaLabel(ItemDelta itemDelta, PrismObjectDefinition objectDefinition) { return getItemPathLabel(itemDelta.getPath(), itemDelta.getDefinition(), objectDefinition); }
private boolean isOperationResult(ItemDelta delta) throws SchemaException { ItemDefinition def = delta.getDefinition(); if (def == null) { throw new SchemaException("No definition in delta for item " + delta.getPath()); } return OperationResultType.COMPLEX_TYPE.equals(def.getTypeName()); }
List<QName> noDefinition = new ArrayList<>(); for (ItemDelta itemDelta: objectDelta.getModifications()) { if (itemDelta.getDefinition() != null) { if ((showOperationalAttributes || !itemDelta.getDefinition().isOperational()) && !NotificationFunctionsImpl .isAmongHiddenPaths(itemDelta.getPath(), hiddenPaths)) { toBeDisplayed.add(itemDelta); Integer order1 = delta1.getDefinition().getDisplayOrder(); Integer order2 = delta2.getDefinition().getDisplayOrder(); if (order1 != null && order2 != null) { return order1 - order2;
private ItemDelta createNewDelta(FactorOutResultMulti<O> rv, ItemDelta<?, ?> modification) throws SchemaException { ObjectDeltaImpl<O> offspring = createOffspring(); ItemDelta delta = modification.getDefinition().instantiate().createDelta(modification.getPath()); offspring.addModification(delta); rv.offsprings.add(offspring); return delta; }
processAnyExtensionDeltaValues(delta.getValuesToReplace(), object, objectOwnerType, assignmentExtension, assignmentExtensionType, (existing, fromDelta) -> { ItemDefinition def = delta.getDefinition(); Collection<RAnyValue> filtered = filterRAnyValues(existing, def, objectOwnerType, assignmentExtensionType);
first = false; String label = getItemPathLabel(pathToExplain, itemDelta.getDefinition(), objectDefinition);
private static XNode toXNode(ItemDelta delta, @NotNull PrismValue value, DeltaConversionOptions options) throws SchemaException{ return delta.getPrismContext().xnodeSerializer() .definition(delta.getDefinition()) .options(DeltaConversionOptions.isSerializeReferenceNames(options) ? SerializationOptions.createSerializeReferenceNames() : null) .serialize(value) .getSubnode(); }
ItemDelta delta = createDelta(); if (other == null) { if (delta.getDefinition() == null && this.getDefinition() != null) { delta.setDefinition(this.getDefinition().clone()); if (delta.getDefinition() == null && other.getDefinition() != null) { delta.setDefinition(other.getDefinition().clone());
if (attrDef != null) { attributeModification.setMatchingRuleQName(attrDef.getMatchingRuleQName()); if (itemDelta.getDefinition() == null) { itemDelta.setDefinition(attrDef);
@SuppressWarnings("unchecked") private <V extends PrismValue, D extends ItemDefinition> SceneDeltaItemImpl createSceneDeltaItemCommon(ItemDelta<V, D> itemDelta, SceneImpl owningScene) throws SchemaException { String simpleName = itemDelta.getElementName() != null ? itemDelta.getElementName().getLocalPart() : ""; NameImpl name = new NameImpl(simpleName); if (itemDelta.getDefinition() != null) { name.setDisplayName(itemDelta.getDefinition().getDisplayName()); } name.setId(simpleName); name.setNamesAreResourceKeys(true); SceneDeltaItemImpl si = new SceneDeltaItemImpl(name); si.setSourceDelta(itemDelta); D def = itemDelta.getDefinition(); if (def != null) { Item<V,D> item = def.instantiate(); if (itemDelta.getEstimatedOldValues() != null) { item.addAll(CloneUtil.cloneCollectionMembers(itemDelta.getEstimatedOldValues())); } si.setSourceItem(item); si.setOperational(def.isOperational()); } ItemPath remainder = itemDelta.getPath().remainder(owningScene.getSourceRelPath()); if (remainder.startsWithNullId()) { remainder = remainder.rest(); } si.setSourceRelPath(remainder); return si; }
@Test public void test120AddExtensionProperty() throws Exception { OperationResult result = new OperationResult("test120AddExtensionProperty"); ObjectDelta<?> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid ); delta.addModificationReplaceProperty(ItemPath.create(UserType.F_EXTENSION, WEAPON), "weapon1", "weapon2"); queryCountInterceptor.startCounter(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); if (baseHelper.getConfiguration().isUsingH2()) { AssertJUnit.assertEquals(5, queryCountInterceptor.getQueryCount()); } Session session = factory.openSession(); try { RUser u = session.get(RUser.class, userOid); RExtItem extItemDef = extItemDictionary.findItemByDefinition(delta.getModifications().iterator().next().getDefinition()); assertAnyValues(u.getStrings(), extItemDef.getId(), "weapon1", "weapon2"); } finally { session.close(); } }
@Test public void test110ReplaceNonIndexedExtensionProperty() throws Exception { OperationResult result = new OperationResult("test110ReplaceExtensionProperty"); ObjectDelta<?> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid ); delta.addModificationReplaceProperty(ItemPath.create(UserType.F_EXTENSION, LOOT), 34); queryCountInterceptor.startCounter(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); if (baseHelper.getConfiguration().isUsingH2()) { AssertJUnit.assertEquals(2, queryCountInterceptor.getQueryCount()); } Session session = factory.openSession(); try { //RUser u = session.get(RUser.class, userOid); RExtItem extItemDef = extItemDictionary .findItemByDefinition(delta.getModifications().iterator().next().getDefinition()); assertNull("ext item definition for loot exists", extItemDef); } finally { session.close(); } }
private <V extends PrismValue, D extends ItemDefinition> void applyItemDefinition(ItemDelta<V,D> itemDelta, PrismContainerDefinition<ConnectorConfigurationType> configContainerDef, OperationResult objectResult) throws SchemaException { if (itemDelta.getParentPath() == null){ LOGGER.trace("No parent path defined for item delta {}", itemDelta); return; } QName first = itemDelta.getParentPath().firstToNameOrNull(); if (first == null) { return; } if (itemDelta.getDefinition() == null && (ResourceType.F_CONNECTOR_CONFIGURATION.equals(first) || ResourceType.F_SCHEMA.equals(first))){ ItemPath path = itemDelta.getPath().rest(); D itemDef = configContainerDef.findItemDefinition(path); if (itemDef == null){ LOGGER.warn("No definition found for item {}. Check your namespaces?", path); objectResult.recordWarning("No definition found for item delta: " + itemDelta +". Check your namespaces?" ); // throw new SchemaException("No definition found for item " + path+ ". Check your namespaces?" ); return; } itemDelta.applyDefinition(itemDef); } }
private <V extends PrismValue, D extends ItemDefinition> void applyAttributeDefinition( ProvisioningContext ctx, ObjectDelta<ShadowType> delta, ItemDelta<V, D> itemDelta) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { if (!SchemaConstants.PATH_ATTRIBUTES.equivalent(itemDelta.getParentPath())) { // just to be sure return; } D itemDef = itemDelta.getDefinition(); if (itemDef == null || !(itemDef instanceof ResourceAttributeDefinition)) { QName attributeName = itemDelta.getElementName(); ResourceAttributeDefinition attributeDefinition = ctx.getObjectClassDefinition() .findAttributeDefinition(attributeName); if (attributeDefinition == null) { throw new SchemaException( "No definition for attribute " + attributeName + " in object delta " + delta); } if (itemDef != null) { // We are going to rewrite the definition anyway. Let's just do // some basic checks first if (!QNameUtil.match(itemDef.getTypeName(), attributeDefinition.getTypeName())) { throw new SchemaException("The value of type " + itemDef.getTypeName() + " cannot be applied to attribute " + attributeName + " which is of type " + attributeDefinition.getTypeName()); } } itemDelta.applyDefinition((D) attributeDefinition); } }