@Override public List<? extends ResourceAttributeDefinition> getAttributeDefinitions() { List<ResourceAttributeDefinition> attrs = new ArrayList<>(); for (ItemDefinition def: complexTypeDefinition.getDefinitions()) { if (def instanceof ResourceAttributeDefinition) { attrs.add((ResourceAttributeDefinition)def); } else { throw new IllegalStateException("Found "+def+" in resource attribute container, only attribute definitions are expected here"); } } return attrs; }
/** * Returns set of property definitions. * <p> * WARNING: This may return definitions from the associated complex type. * Therefore changing the returned set may influence also the complex type definition. * <p> * The set contains all property definitions of all types that were parsed. * Order of definitions is insignificant. * * @return set of definitions */ @Override public List<? extends ItemDefinition> getDefinitions() { if (complexTypeDefinition == null) { // e.g. for xsd:any containers // FIXME return new ArrayList<>(); } return complexTypeDefinition.getDefinitions(); }
/** * Returns set of property definitions. * <p> * The set contains all property definitions of all types that were parsed. * Order of definitions is insignificant. * <p> * The returned set is immutable! All changes may be lost. * * @return set of definitions */ @Override public List<PrismPropertyDefinition> getPropertyDefinitions() { List<PrismPropertyDefinition> props = new ArrayList<>(); for (ItemDefinition def : complexTypeDefinition.getDefinitions()) { if (def instanceof PrismPropertyDefinition) { props.add((PrismPropertyDefinition) def); } } return props; }
for (ItemDefinition item : ctd.getDefinitions()) { if (!(item instanceof PrismContainerDefinition)) { continue;
containingElement.appendChild(sequence); Collection<? extends ItemDefinition> definitions = definition.getDefinitions(); for (ItemDefinition def : definitions) { if (def instanceof PrismPropertyDefinition) {
/** * Merge provided definition into this definition. */ @Override public void merge(ComplexTypeDefinition otherComplexTypeDef) { for (ItemDefinition otherItemDef: otherComplexTypeDef.getDefinitions()) { ItemDefinition existingItemDef = findItemDefinition(otherItemDef.getName()); if (existingItemDef != null) { LOGGER.warn("Overwriting existing definition {} by {} (in {})", existingItemDef, otherItemDef, this); replaceDefinition(otherItemDef.getName(), otherItemDef.clone()); } else { add(otherItemDef.clone()); } } }
assertEquals("Unexpected number of definitions in weaponTypeDef", 5, weaponTypeDef.getDefinitions().size()); Iterator<? extends ItemDefinition> weaponTypeDefIter = weaponTypeDef.getDefinitions().iterator(); PrismPropertyDefinition kindPropertyDef = (PrismPropertyDefinition) weaponTypeDefIter.next(); PrismAsserts.assertDefinition(kindPropertyDef, WEAPON_KIND_QNAME, DOMUtil.XSD_STRING, 1, 1);
private void changeDefinition(QName piracyShip, QName piracyShipBroken) { PrismObjectDefinition<UserType> userDef = prismContext.getSchemaRegistry() .findObjectDefinitionByCompileTimeClass(UserType.class); PrismContainerDefinition<?> extensionDefinition = userDef.getExtensionDefinition(); List<? extends ItemDefinition> extensionDefs = extensionDefinition.getComplexTypeDefinition().getDefinitions(); for (ItemDefinition itemDefinition : extensionDefs) { if (itemDefinition.getName().equals(piracyShip)) { //iterator.remove(); // not possible as the collection is unmodifiable itemDefinition.toMutable().setName(piracyShipBroken); } } }