JpaAnyItemLinkDefinition(ItemDefinition<?> itemDefinition, String jpaName, CollectionSpecification collectionSpecification, RObjectExtensionType ownerType, JpaDataNodeDefinition targetDefinition) { super(itemDefinition.getName(), jpaName, collectionSpecification, false, targetDefinition); this.ownerType = ownerType; this.itemDefinition = itemDefinition; }
public QName getItemName() { if (outputDefinition != null) { return outputDefinition.getName(); } return null; }
protected ItemDeltaImpl(D itemDefinition, PrismContext prismContext) { if (itemDefinition == null) { throw new IllegalArgumentException("Attempt to create item delta without a definition"); } //checkPrismContext(prismContext, itemDefinition); this.prismContext = prismContext; this.elementName = itemDefinition.getName(); this.parentPath = ItemPath.EMPTY_PATH; this.definition = itemDefinition; }
@Override public void add(@NotNull Definition def) { definitions.add(def); if (def instanceof ItemDefinition) { ItemDefinition<?> itemDef = (ItemDefinition<?>) def; itemDefinitionMap.put(itemDef.getName(), itemDef); } }
public <IV extends PrismValue,ID extends ItemDefinition, I extends Item<IV,ID>> I findItem(ItemDefinition itemDefinition, Class<I> type) { if (itemDefinition == null) { throw new IllegalArgumentException("No item definition"); } return findItem(itemDefinition.getName(), type); }
public <IV extends PrismValue,ID extends ItemDefinition> Item<IV,ID> getParsedItem(ID itemDefinition) throws SchemaException { Validate.notNull(itemDefinition); return getParsedItem(itemDefinition, itemDefinition.getName()); }
@Override public void replaceDefinition(QName itemName, ItemDefinition newDefinition) { for (int i=0; i<itemDefinitions.size(); i++) { ItemDefinition itemDef = itemDefinitions.get(i); if (itemDef.getName().equals(itemName)) { if (!itemDef.getClass().isAssignableFrom(newDefinition.getClass())) { throw new IllegalArgumentException("The provided definition of class "+newDefinition.getClass().getName()+" does not match existing definition of class "+itemDef.getClass().getName()); } if (!itemDef.getName().equals(newDefinition.getName())) { newDefinition = newDefinition.clone(); ((ItemDefinitionImpl) newDefinition).setName(itemName); } // Make sure this is set, not add. set will keep correct ordering itemDefinitions.set(i, newDefinition); return; } } throw new IllegalArgumentException("The definition with name "+ itemName +" was not found in complex type "+getTypeName()); }
@NotNull protected StringBuilder debugDumpCommon(int indent) { StringBuilder sb = new StringBuilder(); DebugUtil.indentDebugDump(sb, indent); sb.append("Item: ").append(name).append(" [rel-path: ").append(sourceRelPath).append("]"); if (sourceItem != null) { sb.append(" ITEM"); final ItemDefinition def = sourceItem.getDefinition(); if (def != null) { sb.append(" DEF(").append(def.getName().getLocalPart()).append("/").append(def.getDisplayName()).append(":").append(def.getDisplayOrder()).append(")"); } } if (operational) { sb.append(" OPER"); } return sb; }
private String getMappingDisplayName() { if (mappingQName != null) { return SchemaDebugUtil.prettyPrint(mappingQName); } if (outputDefinition == null) { return null; } return SchemaDebugUtil.prettyPrint(outputDefinition.getName()); }
@NotNull public ItemName getElementName() { if (definition != null) { return definition.getName(); // this is more precise, as the name in path can be unqualified } if (fullPath.isEmpty()) { throw new IllegalStateException("Empty full path in filter "+this); } Object last = fullPath.last(); if (ItemPath.isName(last)) { return ItemPath.toName(last); } else { throw new IllegalStateException("Got "+last+" as a last path segment in value filter "+this); } }
private boolean shouldPutTypeInExportMode(SerializationContext ctx, ItemDefinition definition) { if (!SerializationContext.isSerializeForExport(ctx) || definition == null || !definition.isRuntimeSchema()) { return false; } QName itemName = definition.getName(); if (StringUtils.isEmpty(itemName.getNamespaceURI())) { return true; // ambiguous item name - let's put xsi:type, to be on the safe side } // we assume that all runtime elements which are part of the schema registry are retrievable by element name // (might not be the case for sub-items of custom extension containers! we hope providing xsi:type there will cause no harm) List<ItemDefinition> definitionsInRegistry = getSchemaRegistry() .findItemDefinitionsByElementName(itemName, ItemDefinition.class); return definitionsInRegistry.isEmpty(); // no definition in registry => xsi:type should be put }
@Override public void trimTo(@NotNull Collection<ItemPath> paths) { if (shared) { // TODO switch this to warning before releasing this code (3.6.1 or 3.7) throw new IllegalStateException("Couldn't trim shared definition: " + this); } for (Iterator<ItemDefinition> iterator = itemDefinitions.iterator(); iterator.hasNext(); ) { ItemDefinition<?> itemDef = iterator.next(); ItemPath itemPath = itemDef.getName(); if (!ItemPathCollectionsUtil.containsSuperpathOrEquivalent(paths, itemPath)) { iterator.remove(); } else if (itemDef instanceof PrismContainerDefinition) { PrismContainerDefinition<?> itemPcd = (PrismContainerDefinition<?>) itemDef; if (itemPcd.getComplexTypeDefinition() != null) { itemPcd.getComplexTypeDefinition().trimTo(ItemPathCollectionsUtil.remainder(paths, itemPath, false)); } } } }
@Override public ValuePolicyType resolve() { if (!outputDefinition.getName().equals(PasswordType.F_VALUE)) { return null; } ValuePolicyType passwordPolicy = credentialsProcessor.determinePasswordPolicy(context.getFocusContext(), task, result); if (passwordPolicy == null) { return null; } return passwordPolicy; } };
private void assertDefinitionOrder(List<? extends ItemDefinition> definitions, QName elementName, int i) { assertEquals("Wrong definition, expected that "+PrettyPrinter.prettyPrint(elementName)+" definition will be at index " + i + " but there was a "+definitions.get(i).getName()+" instead", elementName, definitions.get(i).getName()); }
public static RExtItem.Key createKeyFromDefinition(ItemDefinition<?> definition) { String name = RUtil.qnameToString(definition.getName()); String type = RUtil.qnameToString(definition.getTypeName()); RItemKind kind = RItemKind.getTypeFromItemDefinitionClass(definition.getClass()); return new Key(name, type, kind); }
/** * 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()); } } }
@Override public <ID extends ItemDefinition> ID findNamedItemDefinition(@NotNull QName firstName, @NotNull ItemPath rest, @NotNull Class<ID> clazz) { for (ItemDefinition def : getDefinitions()) { if (QNameUtil.match(firstName, def.getName())) { return (ID) def.findItemDefinition(rest, clazz); } } if (complexTypeDefinition != null && complexTypeDefinition.isXsdAnyMarker()) { SchemaRegistry schemaRegistry = getSchemaRegistry(); if (schemaRegistry != null) { ItemDefinition def = schemaRegistry.findItemDefinitionByElementName(firstName); if (def != null) { return (ID) def.findItemDefinition(rest, clazz); } } } return null; }
@Override public void adoptElementDefinitionFrom(ItemDefinition otherDef) { if (otherDef == null) { return; } setName(otherDef.getName()); setMinOccurs(otherDef.getMinOccurs()); setMaxOccurs(otherDef.getMaxOccurs()); }
public static void assertEqualsFilter(ObjectFilter objectFilter, QName expectedFilterDef, QName expectedTypeName, ItemPath path) { assertTrue("Wrong filter class: " + objectFilter.getClass(), objectFilter instanceof EqualFilter); EqualFilter filter = (EqualFilter) objectFilter; //we don't have definition in all situation..this is almost OK..it will be computed dynamicaly if (filter.getDefinition() != null){ assertEquals("Wrong filter definition element name", expectedFilterDef, filter.getDefinition().getName()); assertEquals("Wrong filter definition type", expectedTypeName, filter.getDefinition().getTypeName()); } assertPathEquivalent("Wrong filter path", path, filter.getFullPath()); }
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); } } }