@Override public <X> ResourceAttribute<X> findOrCreateAttribute(ResourceAttributeDefinition attributeDefinition) throws SchemaException { return (ResourceAttribute<X>) getValue().findOrCreateProperty(attributeDefinition); }
@Override public <X> ResourceAttribute<X> findOrCreateAttribute(QName attributeName) throws SchemaException { return (ResourceAttribute<X>) getValue().findOrCreateProperty(ItemName.fromQName(attributeName)); }
public static <T> void setPropertyValue(PrismContainerValue<?> container, ItemName name, T value) { Validate.notNull(container, "Container must not be null."); Validate.notNull(name, "QName must not be null."); if (value == null) { container.removeProperty(name); } else { PrismProperty<?> property; try { property = container.findOrCreateProperty(name); } 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); } Object propertyRealValue = JaxbTypeConverter.mapJaxbToPropertyRealValue(value); if (propertyRealValue == null) { container.removeProperty(name); } else { property.setValue(new PrismPropertyValueImpl(propertyRealValue)); } } }
public static void setPasswordIncomplete(ShadowType shadowType) throws SchemaException { CredentialsType credentialsType = shadowType.getCredentials(); if (credentialsType == null) { credentialsType = new CredentialsType(); shadowType.setCredentials(credentialsType); } PasswordType passwordType = credentialsType.getPassword(); if (passwordType == null) { passwordType = new PasswordType(); credentialsType.setPassword(passwordType); } PrismContainerValue<PasswordType> passwordContainer = passwordType.asPrismContainerValue(); PrismProperty<ProtectedStringType> valueProperty = passwordContainer.findOrCreateProperty(PasswordType.F_VALUE); valueProperty.setIncomplete(true); }
@Test public void testAssignmentExtensionValueProperty() throws Exception { System.out.println("===[ testAssignmentExtensionValueProperty ]==="); // GIVEN PrismContainer<AssignmentType> assignmentExtensionContainer = parseUserAssignmentContainer(); PrismContainerValue<AssignmentType> assignmentExtensionContainerValue = assignmentExtensionContainer.getValue(); // WHEN PrismProperty<String> assignmentExtensionStringProperty = assignmentExtensionContainerValue.findOrCreateProperty(EXTENSION_STRING_TYPE_ELEMENT); // 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); }
PrismProperty<String> descriptionProperty = newValue.findOrCreateProperty(AssignmentType.F_DESCRIPTION);
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"); }
PrismProperty<Integer> intProperty = assignmentExtensionValueFromJaxb.findOrCreateProperty(EXTENSION_INT_TYPE_ELEMENT); intProperty.setRealValue(15);
PrismProperty<String> assCyanDescriptionProperty = assCyanContainerValue.findOrCreateProperty(USER_DESCRIPTION_QNAME); assCyanDescriptionProperty.addRealValue("Assignment created out of the cyan"); assignmentContainer.mergeValue(assCyanContainerValue); PrismProperty<String> assRedDescriptionProperty = assRedContainerValue.findOrCreateProperty(USER_DESCRIPTION_QNAME); assRedDescriptionProperty.addRealValue("Assignment created out of the red"); assertEquals("Wrong number of assignment values (after red)", 3, assignmentContainer.getValues().size());