public static <IV extends PrismValue,ID extends ItemDefinition,I extends Item<IV,ID>> I createItem(PrismContainerValue parentValue, QName name, Class<I> type) { Validate.notNull(parentValue, "Parent container value must not be null."); Validate.notNull(name, "QName must not be null."); try { return (I) parentValue.findOrCreateItem(name, type); } catch (SchemaException ex) { throw new SystemException(ex.getMessage(), ex); } }
public void applyTo(PrismContainerValue containerValue, ParameterizedEquivalenceStrategy strategy) throws SchemaException { ItemPath deltaPath = getPath(); if (ItemPath.isEmpty(deltaPath)) { throw new IllegalArgumentException("Cannot apply empty-path delta " + this + " directly to a PrismContainerValue " + containerValue); } Item subItem = containerValue.findOrCreateItem(deltaPath, getItemClass(), getDefinition()); applyToMatchingPath(subItem, strategy); }
@Test public void testAssignmentExtensionValueItem() throws Exception { System.out.println("===[ testAssignmentExtensionValueItem ]==="); // GIVEN PrismContainer<AssignmentType> assignmentExtensionContainer = parseUserAssignmentContainer(); PrismContainerValue<AssignmentType> assignmentExtensionContainerValue = assignmentExtensionContainer.getValue(); // WHEN PrismProperty<String> assignmentExtensionStringProperty = assignmentExtensionContainerValue.findOrCreateItem( EXTENSION_STRING_TYPE_ELEMENT, PrismProperty.class); // THEN assertNotNull("stringType is null", assignmentExtensionStringProperty); assertNotNull("stringType has no definition", assignmentExtensionStringProperty.getDefinition()); PrismAsserts.assertDefinition(assignmentExtensionStringProperty.getDefinition(), EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); }
reference = parentValue.findOrCreateItem(referenceName, PrismReferenceImpl.class); } catch (SchemaException e) {
@Test public void testExtensionTypeConstruction() throws Exception { System.out.println("\n\n ===[ testExtensionTypeConstruction ]===\n"); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); GenericObjectType object = new GenericObjectType(); prismContext.adopt(object.asPrismObject(), GenericObjectType.class); ExtensionType extension = new ExtensionType(); object.setExtension(extension); PrismContainerValue extValue = extension.asPrismContainerValue(); assertNotNull("No extension definition", extValue.getParent().getDefinition()); // WHEN Item item = extValue.findOrCreateItem(SchemaTestConstants.EXTENSION_STRING_TYPE_ELEMENT); // THEN assertNotNull(item); object.asPrismObject().checkConsistence(); }
private void checkExtension(ExtensionType extension, String sourceDescription) throws SchemaException { PrismContainerValue<ExtensionType> extensionValueFromJaxb = extension.asPrismContainerValue(); assertNotNull("No extension container in "+sourceDescription+" (jaxb)", extensionValueFromJaxb); assertNotNull("No extension definition in "+sourceDescription+" (jaxb)", extensionValueFromJaxb.getParent().getDefinition()); assertTrue("Not runtime in definition in "+sourceDescription+" (jaxb)", extensionValueFromJaxb.getParent().getDefinition().isRuntimeSchema()); PrismProperty<Integer> intProperty = extensionValueFromJaxb.findOrCreateProperty(EXTENSION_INT_TYPE_ELEMENT); PrismAsserts.assertDefinition(intProperty.getDefinition(), EXTENSION_INT_TYPE_ELEMENT, DOMUtil.XSD_INT, 0, -1); intProperty.setRealValue(15); PrismProperty<String> stringProperty = extensionValueFromJaxb.findOrCreateItem(EXTENSION_STRING_TYPE_ELEMENT, PrismProperty.class); PrismAsserts.assertDefinition(stringProperty.getDefinition(), EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); stringProperty.setRealValue("fifteen men on a dead man chest"); }
intProperty.setRealValue(15); PrismProperty<String> stringProperty = assignmentExtensionValueFromJaxb.findOrCreateItem(EXTENSION_STRING_TYPE_ELEMENT, PrismProperty.class); stringProperty.setRealValue("fifteen men on a dead man chest");