@Override public <C extends Containerable, O extends Objectable> void applyDefinition(PrismContainerValue<C> prismContainerValue, Class<O> compileTimeClass, ItemPath path, boolean force) throws SchemaException { PrismObjectDefinition<O> objectDefinition = determineDefinitionFromClass(compileTimeClass); PrismContainerDefinition<C> containerDefinition = objectDefinition.findContainerDefinition(path); prismContainerValue.applyDefinition(containerDefinition, force); }
@Override public <C extends Containerable> void applyDefinition(PrismContainerValue<C> prismContainerValue, QName typeName, ItemPath path, boolean force) throws SchemaException { PrismObjectDefinition objectDefinition = findObjectDefinitionByType(typeName); if (objectDefinition != null) { PrismContainerDefinition<C> containerDefinition = objectDefinition.findContainerDefinition(path); prismContainerValue.applyDefinition(containerDefinition, force); return; } PrismContainerDefinition typeDefinition = findContainerDefinitionByType(typeName); if (typeDefinition != null) { PrismContainerDefinition<C> containerDefinition = typeDefinition.findContainerDefinition(path); prismContainerValue.applyDefinition(containerDefinition, force); return; } ComplexTypeDefinition complexTypeDefinition = findComplexTypeDefinition(typeName); if (complexTypeDefinition != null) { PrismContainerDefinition<C> containerDefinition = complexTypeDefinition.findContainerDefinition(path); prismContainerValue.applyDefinition(containerDefinition, force); return; } throw new SchemaException("No definition for container "+path+" in type "+typeName); } //endregion
public void mergeValue(PrismContainerValue<C> otherValue) throws SchemaException { checkMutability(); Iterator<PrismContainerValue<C>> iterator = getValues().iterator(); while (iterator.hasNext()) { PrismContainerValue<C> thisValue = iterator.next(); if (thisValue.equals(otherValue)) { // Same values, nothing to merge return; } if (thisValue.getId() != null && thisValue.getId().equals(otherValue.getId())) { // Different value but same id. New value overwrites. iterator.remove(); } } PrismContainerValue<C> clonedOtherValue = otherValue.clone(); if (getDefinition() != null) { clonedOtherValue.applyDefinition(getDefinition()); } add(clonedOtherValue); }
private <T extends Containerable> PrismContainer<T> unmarshalSingleValueContainer(JAXBElement<T> element) throws JAXBException, SchemaException { if (element == null) { return null; } T value = element.getValue(); // this is a bit tricky - we have to create a container and put the newly obtained value into it PrismContainerValue<T> containerValue = value.asPrismContainerValue(); containerValue.revive(prismContext); PrismContainerDefinition<T> definition = prismContext.getSchemaRegistry().findContainerDefinitionByElementName(element.getName()); if (definition == null) { throw new IllegalStateException("There's no container definition for element name " + element.getName()); } containerValue.applyDefinition(definition, false); PrismContainer container = definition.instantiate(); container.add(containerValue); return container; }
try { prismContext.adopt((Containerable) value); ((Containerable) value).asPrismContainerValue().applyDefinition(definition); } catch (SchemaException e) { throw new ExpressionEvaluationException(e.getMessage() + " " + contextDescription, e); try { prismContext.adopt((PrismContainerValue) value); ((PrismContainerValue) value).applyDefinition(definition); } catch (SchemaException e) { throw new ExpressionEvaluationException(e.getMessage() + " " + contextDescription, e);
@Override public void configure(PrismContainerValue<?> configuration, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, SchemaException, ConfigurationException { OperationResult result = parentResult.createSubresult(ConnectorInstance.OPERATION_CONFIGURE); boolean immutable = configuration.isImmutable(); try { if (immutable) { configuration.setImmutable(false); } configuration.applyDefinition(getConfigurationContainerDefinition()); } finally { if (immutable) { configuration.setImmutable(true); } } setConnectorConfiguration(configuration); applyConfigurationToConfigurationClass(configuration); // TODO: transform configuration in a subclass result.recordSuccessIfUnknown(); }
configurationCloned.applyDefinition(getConfigurationContainerDefinition());