public static ItemDefinition findItemDefinition(ItemPath itemPath, PrismContainerDefinition<? extends Containerable> containerDef) { ItemDefinition itemDef = containerDef.findItemDefinition(itemPath); if (itemDef == null) { throw new IllegalStateException("No definition for item " + itemPath + " in container definition " + containerDef); } return itemDef; }
@Override public S_ConditionEntry item(PrismContainerDefinition containerDefinition, ItemPath itemPath) { ItemDefinition itemDefinition = containerDefinition.findItemDefinition(itemPath); if (itemDefinition == null) { throw new IllegalArgumentException("No definition of " + itemPath + " in " + containerDefinition); } return item(itemPath, itemDefinition); }
@NotNull public static List<Item<?, ?>> mapToExtensionItems(Map<QName, Object> values, PrismContainerDefinition<?> extensionDefinition, PrismContext prismContext) throws SchemaException { List<Item<?, ?>> extensionItems = new ArrayList<>(); for (Map.Entry<QName, Object> entry : values.entrySet()) { ItemDefinition<Item<PrismValue, ItemDefinition>> def = extensionDefinition != null ? extensionDefinition.findItemDefinition(ItemName.fromQName(entry.getKey())) : null; if (def == null) { //noinspection unchecked def = prismContext.getSchemaRegistry().findItemDefinitionByElementName(entry.getKey()); // a bit of hack here if (def == null) { throw new SchemaException("No definition of " + entry.getKey() + " in task extension"); } } Item<PrismValue, ItemDefinition> extensionItem = def.instantiate(); if (entry.getValue() != null) { if (entry.getValue() instanceof Collection) { for (Object value : (Collection) entry.getValue()) { addRealValue(extensionItem, value, prismContext); } } else { addRealValue(extensionItem, entry.getValue(), prismContext); } } extensionItems.add(extensionItem); } return extensionItems; }
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! }
public static void assertItemDefinitionDisplayName(PrismContainerDefinition<?> containerDef, QName propertyName, String expectedDisplayName) { ItemDefinition definition = containerDef.findItemDefinition(ItemName.fromQName(propertyName)); assert equals(expectedDisplayName, definition.getDisplayName()) : "Wrong display name for item "+propertyName+", expected " + expectedDisplayName + ", was " + definition.getDisplayName(); }
public static void assertItemDefinitionHelp(PrismContainerDefinition<?> containerDef, QName propertyName, String expectedHelp) { ItemDefinition definition = containerDef.findItemDefinition(ItemName.fromQName(propertyName)); assert equals(expectedHelp, definition.getHelp()) : "Wrong help for item "+propertyName+", expected " + expectedHelp + ", was " + definition.getHelp(); }
public static void assertItemDefinitionDisplayOrder(PrismContainerDefinition<?> containerDef, QName propertyName, Integer expectedDisplayOrder) { ItemDefinition definition = containerDef.findItemDefinition(ItemName.fromQName(propertyName)); assert equals(expectedDisplayOrder, definition.getDisplayOrder()) : "Wrong display order for item "+propertyName+", expected " + expectedDisplayOrder + ", was " + definition.getDisplayOrder(); }
private <T extends Containerable> ItemDefinition locateItemDefinition( PrismContainerDefinition<T> containerDefinition, QName elementQName, Object valueElements) throws SchemaException { ItemDefinition def = containerDefinition.findItemDefinition(ItemName.fromQName(elementQName)); if (def != null) { return def;
ItemDefinition itemDefinition = definition.findItemDefinition(ItemName.fromQName(elementName));
private <C extends Containerable> ItemDefinition locateItemDefinition(XNodeImpl valueXnode, ItemPath itemPath, PrismContainerDefinition<C> pcd) throws SchemaException{ ItemDefinition itemDefinition = null; if (pcd != null) { itemDefinition = pcd.findItemDefinition(itemPath); if (itemDefinition == null) { ItemPath rest = itemPath.rest(); QName first = itemPath.firstToName(); itemDefinition = ((PrismContextImpl) prismContext).getPrismUnmarshaller().locateItemDefinition(pcd, first, valueXnode); if (rest.isEmpty()) { return itemDefinition; } else{ if (itemDefinition instanceof PrismContainerDefinition){ //noinspection unchecked return locateItemDefinition(valueXnode, rest, (PrismContainerDefinition) itemDefinition); } } } } return itemDefinition; }
public CanonicalItemPathImpl(ItemPath path, Class<? extends Containerable> clazz, PrismContext prismContext) { ItemDefinition def = clazz != null && prismContext != null ? prismContext.getSchemaRegistry().findContainerDefinitionByCompileTimeClass(clazz) : null; while (!ItemPath.isEmpty(path)) { Object first = path.first(); if (ItemPath.isName(first)) { ItemName name = ItemPath.toName(first); if (def instanceof PrismContainerDefinition) { def = ((PrismContainerDefinition) def).findItemDefinition(name); if (def != null && !QNameUtil.hasNamespace(name)) { name = def.getName(); } } addToSegments(name); } else if (ItemPath.isId(first)) { // ignored (for now) } else { throw new UnsupportedOperationException("Canonicalization of non-name/non-ID segments is not supported: " + first); } path = path.rest(); } }
public static void applyConfigurationDefinition(PrismObject<ReportType> report, ObjectDelta delta, PrismContext prismContext) throws SchemaException { PrismSchema schema = ReportTypeUtil.parseReportConfigurationSchema(report, prismContext); PrismContainerDefinition<ReportConfigurationType> definition = ReportTypeUtil.findReportConfigurationDefinition(schema); if (definition == null) { //no definition found for container throw new SchemaException("Couldn't find definitions for report type " + report + "."); } Collection<ItemDelta> modifications = delta.getModifications(); for (ItemDelta itemDelta : modifications){ if (itemDelta.hasCompleteDefinition()){ continue; } ItemDefinition def = definition.findItemDefinition(itemDelta.getPath().rest()); if (def != null){ itemDelta.applyDefinition(def); } } } }
ItemDefinition subItemDef = subitem.getDefinition(); if (subItemDef == null && itemDef != null) { subItemDef = ((PrismContainerDefinition)itemDef).findItemDefinition(subitem.getElementName());
return ((PrismObjectDefinition<?>) root).findItemDefinition(relativePath); } else if (root instanceof PrismContainerDefinition<?>) { return ((PrismContainerDefinition<?>) root).findItemDefinition(relativePath); } else if (root instanceof ItemDefinition) {
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); } }
@Override public ItemDelta<?,?> getSubDelta(ItemPath path) { if (path.isEmpty()) { return this; } Long id = null; if (path.startsWithId()) { id = path.firstToIdOrNull(); path = path.rest(); } ItemDefinition itemDefinition = getDefinition().findItemDefinition(path); if (itemDefinition == null) { throw new IllegalStateException("No definition of " + path + " in " + getDefinition()); } ItemDelta<?,?> itemDelta = itemDefinition.createEmptyDelta(getPath().append(path)); itemDelta.addValuesToAdd(findItemValues(id, path, getValuesToAdd())); itemDelta.addValuesToDelete(findItemValues(id, path, getValuesToDelete())); itemDelta.setValuesToReplace(findItemValues(id, path, getValuesToReplace())); if (itemDelta.isEmpty()) { return null; } return itemDelta; }
itemDefinition = pcd.findItemDefinition(itemPath); if (itemDefinition == null && !preliminaryParsingOnly) { throw new SchemaException("No definition for item "+itemPath+" in "+pcd);
ItemDefinition containingPcd = pcDef.findItemDefinition(parentPath); PrismContainerDefinition containerDef = null; if (containingPcd == null) {
public static void recordEventInTask(CaseEventType event, ObjectDeltaType additionalDelta, String taskOid, OperationResult result) { RepositoryService cacheRepositoryService = getCacheRepositoryService(); PrismContext prismContext = getPrismContext(); try { S_ItemEntry deltaBuilder = getPrismContext().deltaFor(TaskType.class) .item(F_WORKFLOW_CONTEXT, F_EVENT).add(event); if (additionalDelta != null) { PrismObject<TaskType> task = cacheRepositoryService.getObject(TaskType.class, taskOid, null, result); WfPrimaryChangeProcessorStateType state = WfContextUtil .getPrimaryChangeProcessorState(task.asObjectable().getWorkflowContext()); ObjectTreeDeltasType updatedDelta = ObjectTreeDeltas.mergeDeltas(state.getDeltasToProcess(), additionalDelta, prismContext); ItemPath deltasToProcessPath = ItemPath.create(F_WORKFLOW_CONTEXT, F_PROCESSOR_SPECIFIC_STATE, WfPrimaryChangeProcessorStateType.F_DELTAS_TO_PROCESS); // assuming it already exists! ItemDefinition<?> deltasToProcessDefinition = getPrismContext().getSchemaRegistry() .findContainerDefinitionByCompileTimeClass(WfPrimaryChangeProcessorStateType.class) .findItemDefinition(WfPrimaryChangeProcessorStateType.F_DELTAS_TO_PROCESS); deltaBuilder = deltaBuilder.item(deltasToProcessPath, deltasToProcessDefinition) .replace(updatedDelta); } cacheRepositoryService.modifyObject(TaskType.class, taskOid, deltaBuilder.asItemDeltas(), result); } catch (ObjectNotFoundException | SchemaException | ObjectAlreadyExistsException e) { throw new SystemException("Couldn't record decision to the task " + taskOid + ": " + e.getMessage(), e); } }
return null; } else { ItemDefinition rightSideDefinition = pcd != null ? pcd.findItemDefinition(rightSidePath) : null; if (isEq) {