/** * Convenience method. Works only on single-valued containers. */ public void add(Item<?,?> item) throws SchemaException { checkMutability(); this.getValue().add(item); }
@Override public boolean handle(PrismObject<ShadowType> entitlementShadow) { PrismContainerValue<ShadowAssociationType> associationCVal = associationContainer.createNewValue(); associationCVal.asContainerable().setName(associationName); Collection<ResourceAttribute<?>> entitlementIdentifiers = ShadowUtil.getAllIdentifiers(entitlementShadow); try { ResourceAttributeContainer identifiersContainer = ObjectFactory.createResourceAttributeContainer( ShadowAssociationType.F_IDENTIFIERS, entitlementDef.toResourceAttributeContainerDefinition(), prismContext); associationCVal.add(identifiersContainer); identifiersContainer.getValue().addAll(Item.cloneCollection(entitlementIdentifiers)); // Remember the full shadow in user data. This is used later as an optimization to create the shadow in repo identifiersContainer.setUserData(ResourceObjectConverter.FULL_SHADOW_KEY, entitlementShadow); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Processed entitlement-to-subject association for account {} and entitlement {}", ShadowUtil.getHumanReadableName(resourceObject), ShadowUtil.getHumanReadableName(entitlementShadow)); } } catch (SchemaException e) { throw new TunnelException(e); } return true; } };
@Override public boolean addAll(Collection<? extends T> ts) { Validate.notNull(ts, "Collection must not be null."); if (ts.isEmpty()) { return false; } try { if (property.getParent() == null) { parent.add(property); } } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } for (T jaxbObject : ts) { Object propertyRealValue = JaxbTypeConverter.mapJaxbToPropertyRealValue(jaxbObject); property.addValue(new PrismPropertyValueImpl(propertyRealValue, null, null)); } return true; }
if (containerCVal != null) { for (Item<?,?> containerItem: containerCVal.getItems()) { deltaCVal.add(containerItem.clone());
public static void mergeExtension(PrismContainerValue<?> dstExtensionContainerValue, PrismContainerValue<?> srcExtensionContainerValue) throws SchemaException { for (Item<?,?> srcExtensionItem: emptyIfNull(srcExtensionContainerValue.getItems())) { Item<?,?> magicItem = dstExtensionContainerValue.findItem(srcExtensionItem.getElementName()); if (magicItem == null) { //noinspection unchecked dstExtensionContainerValue.add(srcExtensionItem.clone()); } } }
@Override public boolean add(T t) { PrismContainerValue value = getValueFrom(t); try { if (container.getParent() == null) { parent.add(container); } return container.add(value); } catch (SchemaException ex) { throw new SystemException(ex.getMessage(), ex); } }
@Override public boolean add(T t) { PrismReferenceValue value = getValueFrom(t); if (reference.getParent() == null) { try { parent.add(reference); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } } return reference.merge(value); }
public static ResourceAttribute<?> fixAttributePath(ResourceAttribute<?> attribute) throws SchemaException { if (attribute == null) { return null; } if (attribute.getPath().startsWithName(ShadowType.F_ATTRIBUTES)) { return attribute; } ResourceAttribute<?> fixedAttribute = attribute.clone(); ResourceAttributeContainer container = ObjectFactory.createResourceAttributeContainer(ShadowType.F_ATTRIBUTES, null, attribute.getPrismContext()); container.createNewValue().add(fixedAttribute); return fixedAttribute; }
PrismProperty<String> workItemIdProp = workItemIdDef.instantiate(); workItemIdProp.addRealValue(workItemId); trigger.getExtension().asPrismContainerValue().add(workItemIdProp); PrismContainer<WorkItemActionsType> workItemActionsCont = workItemActionsDef.instantiate(); workItemActionsCont.add(actions.asPrismContainerValue().clone()); extension.asPrismContainerValue().add(workItemActionsCont); PrismContainer<AbstractWorkItemActionType> workItemActionCont = workItemActionDef.instantiate(); workItemActionCont.add(notifyInfo.getValue().asPrismContainerValue().clone()); extension.asPrismContainerValue().add(workItemActionCont); @SuppressWarnings("unchecked") @NotNull PrismPropertyDefinition<Duration> timeBeforeActionDef = PrismProperty<Duration> timeBeforeActionProp = timeBeforeActionDef.instantiate(); timeBeforeActionProp.addRealValue(notifyInfo.getKey()); extension.asPrismContainerValue().add(timeBeforeActionProp);
protected <F extends FocusType> ContainerDelta<AssignmentType> createAssignmentModification(Class<F> type, QName elementName, String roleOid, QName refType, QName relation, PrismContainer<?> extension, ActivationType activationType, boolean add) throws SchemaException { try { return createAssignmentModification(type, elementName, roleOid, refType, relation, assignment -> { if (extension != null) { try { assignment.asPrismContainerValue().add(extension.clone()); } catch (SchemaException e) { throw new TunnelException(e); } } assignment.setActivation(activationType); }, add); } catch (TunnelException te) { throw (SchemaException)te.getCause(); } }
private void transplantIdentifiers(PrismContainerValue<ShadowAssociationType> association, PrismObject<ShadowType> repoShadow) throws SchemaException { PrismContainer<Containerable> identifiersContainer = association .findContainer(ShadowAssociationType.F_IDENTIFIERS); if (identifiersContainer == null) { ResourceAttributeContainer origContainer = ShadowUtil.getAttributesContainer(repoShadow); identifiersContainer = ObjectFactory.createResourceAttributeContainer(ShadowAssociationType.F_IDENTIFIERS, origContainer.getDefinition(), prismContext); association.add(identifiersContainer); } Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getPrimaryIdentifiers(repoShadow); for (ResourceAttribute<?> identifier : identifiers) { identifiersContainer.add(identifier.clone()); } Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil .getSecondaryIdentifiers(repoShadow); for (ResourceAttribute<?> identifier : secondaryIdentifiers) { identifiersContainer.add(identifier.clone()); } }
private void toAssociation(PrismObject<ShadowType> shadow, ShadowAssociationType shadowAssociationType) { shadowAssociationType.setShadowRef(new ObjectReferenceType().oid(shadow.getOid()).type(ShadowType.COMPLEX_TYPE)); // We also need to add identifiers here. Otherwise the delta won't match the shadow association. // And therefore new values won't be computed correctly (MID-4948) // This is not a clean systemic solution. But there was no time for a better solution before 3.9 release. try { ResourceAttributeContainer shadowAttributesContainer = ShadowUtil.getAttributesContainer(shadow); ResourceAttributeContainer identifiersContainer = ObjectFactory.createResourceAttributeContainer( ShadowAssociationType.F_IDENTIFIERS, shadowAttributesContainer.getDefinition(), prismContext); shadowAssociationType.asPrismContainerValue().add(identifiersContainer); Collection<ResourceAttribute<?>> shadowIdentifiers = ShadowUtil.getAllIdentifiers(shadow); for (ResourceAttribute<?> shadowIdentifier : shadowIdentifiers) { identifiersContainer.add(shadowIdentifier.clone()); } } catch (SchemaException e) { // Should not happen throw new SystemException(e.getMessage(), e); } }
PrismProperty<String> loot = def1.instantiate(); loot.setRealValue("otherString"); extension.asPrismContainerValue().add(loot);
ResourceAttributeContainer identifiersContainer = ObjectFactory.createResourceAttributeContainer( ShadowAssociationType.F_IDENTIFIERS, entitlementDef.toResourceAttributeContainerDefinition(), prismContext); associationCVal.add(identifiersContainer); identifiersContainer.add(valueAttribute); LOGGER.trace("Assocciation attribute value resolved to valueAtrribute {} and identifiers container {}", valueAttribute, identifiersContainer);
@Test public static void testSerializeTask() throws Exception { ObjectQuery query = getPrismContext().queryFor(ShadowType.class) .item(ShadowType.F_KIND).eq(ShadowKindType.ACCOUNT) .build(); QueryType queryType = getPrismContext().getQueryConverter().createQueryType(query); PrismPropertyDefinition queryDef = getPrismContext().definitionFactory().createPropertyDefinition( SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.COMPLEX_TYPE); PrismProperty<QueryType> queryProp = queryDef.instantiate(); queryProp.setRealValue(queryType); TaskType taskType = getPrismContext().createObject(TaskType.class).asObjectable(); taskType.setExtension(new ExtensionType(getPrismContext())); taskType.getExtension().asPrismContainerValue().add(queryProp); taskType.setName(PolyStringType.fromOrig("Test task")); String xml = getPrismContext().xmlSerializer().serialize(taskType.asPrismObject()); System.out.println("Task serialized:\n" + xml); PrismObject<TaskType> taskParsed = getPrismContext().parserFor(xml).parse(); String xmlSerializedAgain = getPrismContext().xmlSerializer().serialize(taskParsed); System.out.println("Task serialized again:\n" + xmlSerializedAgain); }
PrismProperty<String> attr1 = def1.instantiate(); attr1.setRealValue("value1"); attributes.asPrismContainerValue().add(attr1);