public void setExtensionRealValues(PrismContainerValue<?> containerValue, Map<String, Object> map) throws SchemaException { PrismContainer<Containerable> ext = containerValue.findOrCreateContainer(ObjectType.F_EXTENSION); Map<QName, Object> qnameKeyedMap = new HashMap<>(); map.forEach((uri, value) -> qnameKeyedMap.put(QNameUtil.uriToQName(uri, true), value)); List<Item<?, ?>> items = ObjectTypeUtil.mapToExtensionItems(qnameKeyedMap, ext.getDefinition(), prismContext); for (Item<?, ?> item : items) { ext.getValue().addReplaceExisting(item); } }
public static <T extends Containerable> boolean setFieldContainerValue(PrismContainerValue<?> parent, ItemName fieldName, PrismContainerValue<T> fieldContainerValue) { Validate.notNull(parent, "Prism container value must not be null."); Validate.notNull(fieldName, "QName must not be null."); try { PrismContainer<T> fieldContainer = null; if (fieldContainerValue == null) { parent.removeContainer(fieldName); } else { if (fieldContainerValue.getParent() != null && fieldContainerValue.getParent() != parent) { // This value is already part of another prism. We need to clone it to add it here. fieldContainerValue = fieldContainerValue.clone(); } fieldContainer = new PrismContainerImpl<>(fieldName, parent.getPrismContext()); fieldContainer.add(fieldContainerValue); parent.addReplaceExisting(fieldContainer); } } catch (SchemaException e) { // This should not happen. Code generator and compiler should take care of that. throw new IllegalStateException("Internal schema error: "+e.getMessage(),e); } return true; }
attributesContainer.getDefinition().getComplexTypeDefinition(), resourceSchema); for (ResourceAttribute<?> identifier: identifiers) { attributesContainer.getValue().addReplaceExisting(identifier);