public static ItemDefinition findItemDefinition(ItemPath parentPath, ComplexTypeDefinition complexTypeDefinition) { ItemDefinition itemDef = complexTypeDefinition.findItemDefinition(parentPath); if (itemDef == null) { throw new IllegalStateException("No definition for item " + parentPath + " in complex type definition " + complexTypeDefinition); } return itemDef; }
@Override public S_ValuesEntry item(ItemPath path) { ItemDefinition definition = containerCTD.findItemDefinition(path); if (definition == null) { throw new IllegalArgumentException("Undefined or dynamic path: " + path + " in: " + containerCTD); } return item(path, definition); }
default boolean containsItemDefinition(QName itemName) { return findItemDefinition(ItemName.fromQName(itemName)) != null; }
private <ID extends ItemDefinition> ID resolveItemPath(ItemPath itemPath, Class<ID> type) { Validate.notNull(type, "type"); ComplexTypeDefinition ctd = queryBuilder.getPrismContext().getSchemaRegistry().findComplexTypeDefinitionByCompileTimeClass(currentClass); if (ctd == null) { throw new IllegalArgumentException("Definition for " + currentClass + " couldn't be found."); } ID definition = ctd.findItemDefinition(itemPath, type); if (definition == null) { throw new IllegalArgumentException("Item path of '" + itemPath + "' in " + currentClass + " does not point to a valid " + type.getSimpleName()); } return definition; }
if (!rest.isEmpty() && ctd.findItemDefinition(rest) == null) { continue;
public static void assertItemDefinitionDisplayOrder(ComplexTypeDefinition containerDef, QName propertyName, Integer expectedDisplayOrder) { ItemDefinition definition = containerDef.findItemDefinition(ItemName.fromQName(propertyName), ItemDefinition.class); assert equals(expectedDisplayOrder, definition.getDisplayOrder()) : "Wrong display order for item "+propertyName+", expected " + expectedDisplayOrder + ", was " + definition.getDisplayOrder(); }
public static void assertItemDefinitionDisplayName(ComplexTypeDefinition containerDef, QName propertyName, String expectedDisplayName) { ItemDefinition definition = containerDef.findItemDefinition(ItemName.fromQName(propertyName), ItemDefinition.class); assert equals(expectedDisplayName, definition.getDisplayName()) : "Wrong display name for item "+propertyName+", expected " + expectedDisplayName + ", was " + definition.getDisplayName(); }
public <ID extends ItemDefinition> ID findItemDefinition(@NotNull ItemPath path, @NotNull Class<ID> clazz) { for (;;) { if (path.isEmpty()) { if (clazz.isAssignableFrom(PrismContainerDefinition.class)) { return (ID) this; } else { return null; } } Object first = path.first(); if (ItemPath.isName(first)) { return findNamedItemDefinition(ItemPath.toName(first), path.rest(), clazz); } else if (ItemPath.isId(first)) { path = path.rest(); } else if (ItemPath.isParent(first)) { ItemPath rest = path.rest(); ComplexTypeDefinition parent = getSchemaRegistry().determineParentDefinition(getComplexTypeDefinition(), rest); if (rest.isEmpty()) { // requires that the parent is defined as an item (container, object) return (ID) getSchemaRegistry().findItemDefinitionByType(parent.getTypeName()); } else { return parent.findItemDefinition(rest, clazz); } } else if (ItemPath.isObjectReference(first)) { throw new IllegalStateException("Couldn't use '@' path segment in this context. PCD=" + getTypeName() + ", path=" + path); } else { throw new IllegalStateException("Unexpected path segment: " + first + " in " + path); } } }
return parent.findItemDefinition(rest, clazz);
definition = (PrismReferenceDefinitionImpl) containingCtd.findItemDefinition(ItemName.fromQName(primaryElementName), PrismReferenceDefinition.class);
assertFalse("Construction is runtime", constructionContainer.isRuntimeSchema()); PrismReferenceDefinition accountRefDef = complexTypeDefinition.findItemDefinition(UserType.F_LINK_REF, PrismReferenceDefinition.class); PrismAsserts.assertDefinition(accountRefDef, UserType.F_LINK_REF, ObjectReferenceType.COMPLEX_TYPE, 0, -1); assertEquals("Wrong target type in accountRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName()); assertEquals("Metadata size", 23, metadataContainer.getDefinitions().size()); PrismReferenceDefinition tenantRefDef = complexTypeDefinition.findItemDefinition(UserType.F_TENANT_REF, PrismReferenceDefinition.class); PrismAsserts.assertDefinition(tenantRefDef, UserType.F_TENANT_REF, ObjectReferenceType.COMPLEX_TYPE, 0, 1); assertEquals("Wrong target type in tenantRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());