public static <T> Collection<PrismPropertyValue<T>> createCollection(PrismContext prismContext, Collection<T> realValueCollection) { Collection<PrismPropertyValue<T>> pvalCol = new ArrayList<>(realValueCollection.size()); for (T realValue: realValueCollection) { pvalCol.add(prismContext.itemFactory().createPropertyValue(realValue)); } return pvalCol; }
@Override public <O extends Objectable> ObjectDelta<O> createModificationDeleteReference(Class<O> type, String oid, QName propertyName, String... targetOids) { PrismReferenceValue[] referenceValues = new PrismReferenceValue[targetOids.length]; for (int i=0; i < targetOids.length; i++) { referenceValues[i] = prismContext.itemFactory().createReferenceValue(targetOids[i]); } return createModificationDeleteReference(type, oid, propertyName, referenceValues); }
private void addToData(@NotNull Object outObject, @NotNull OperationResult result, PipelineData output) throws SchemaException { if (outObject instanceof Collection) { for (Object o : (Collection) outObject) { addToData(o, result, output); } } else { PrismValue value; if (outObject instanceof PrismValue) { value = (PrismValue) outObject; } else if (outObject instanceof Objectable) { value = prismContext.itemFactory().createObjectValue((Objectable) outObject); } else if (outObject instanceof Containerable) { value = prismContext.itemFactory().createContainerValue((Containerable) outObject); } else { value = prismContext.itemFactory().createPropertyValue(outObject); } output.add(new PipelineItem(value, result)); } }
/** * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to * existing user values. */ protected <F extends FocusType> void breakAssignmentDelta(ObjectDelta<F> userDelta) throws SchemaException { ContainerDelta<?> assignmentDelta = userDelta.findContainerDelta(UserType.F_ASSIGNMENT); PrismContainerValue<?> assignmentDeltaValue = null; if (assignmentDelta.getValuesToAdd() != null) { assignmentDeltaValue = assignmentDelta.getValuesToAdd().iterator().next(); } if (assignmentDelta.getValuesToDelete() != null) { assignmentDeltaValue = assignmentDelta.getValuesToDelete().iterator().next(); } PrismContainer<ActivationType> activationContainer = assignmentDeltaValue.findOrCreateContainer(AssignmentType.F_ACTIVATION); PrismContainerValue<ActivationType> emptyValue = prismContext.itemFactory().createContainerValue(); activationContainer.add(emptyValue); }
public static <T> PrismProperty<T> createRaw(@NotNull XNode node, @NotNull QName itemName, PrismContext prismContext) throws SchemaException { Validate.isTrue(!(node instanceof RootXNode)); PrismProperty<T> property = prismContext.itemFactory().createProperty(itemName); if (node instanceof ListXNode) { for (XNode subnode : ((ListXNode) node).asList()) { property.add(createRaw(subnode, prismContext)); } } else { property.add(createRaw(node, prismContext)); } return property; }
protected PrismReference ref(List<ObjectReferenceType> orts) { PrismReference rv = prismContext.itemFactory().createReference(new QName("dummy")); orts.forEach(ort -> { try { rv.add(ort.asReferenceValue().clone()); } catch (SchemaException e) { throw new IllegalStateException(e); } }); return rv; }
protected ContainerDelta<AssignmentType> createAssignmentModification(long id, boolean add) throws SchemaException { ContainerDelta<AssignmentType> assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); PrismContainerValue<AssignmentType> cval = prismContext.itemFactory().createContainerValue(); cval.setId(id); if (add) { assignmentDelta.addValueToAdd(cval); } else { assignmentDelta.addValueToDelete(cval); } return assignmentDelta; }
PrismContainer<Containerable> shadow2Attrs = shadow2.findOrCreateContainer(ShadowType.F_ATTRIBUTES); PrismProperty<String> attrEntryUuid = prismContext.itemFactory().createProperty(new QName(NS_TEST_RI, "entryUuid")); PrismPropertyDefinition<String> attrEntryUuidDef = prismContext.definitionFactory().createPropertyDefinition(new QName(NS_TEST_RI, "entryUuid"), DOMUtil.XSD_STRING); attrEntryUuid.addRealValue("1234-5678-8765-4321"); PrismProperty<String> attrDn = prismContext.itemFactory().createProperty(new QName(NS_TEST_RI, "dn")); PrismPropertyDefinition<String> attrDnDef = prismContext.definitionFactory().createPropertyDefinition(new QName(NS_TEST_RI, "dn"), DOMUtil.XSD_STRING);
private SceneDeltaItemImpl createSceneDeltaItem(ReferenceDelta delta, SceneImpl owningScene, VisualizationContext context, Task task, OperationResult result) throws SchemaException { SceneDeltaItemImpl di = createSceneDeltaItemCommon(delta, owningScene); di.setOldValues(toSceneItemValuesRef(delta.getEstimatedOldValues(), context, task, result)); PrismReference reference = prismContext.itemFactory().createReference(delta.getElementName()); try { if (delta.getEstimatedOldValues() != null) { reference.addAll(CloneUtil.cloneCollectionMembers(delta.getEstimatedOldValues())); } delta.applyToMatchingPath(reference, ParameterizedEquivalenceStrategy.DEFAULT_FOR_DELTA_APPLICATION); } catch (SchemaException e) { throw new SystemException("Couldn't visualize reference delta: " + delta + ": " + e.getMessage(), e); } computeAddedDeletedUnchangedRef(di, delta.getEstimatedOldValues(), reference.getValues(), context, task, result); di.setNewValues(toSceneItemValuesRef(reference.getValues(), context, task, result)); return di; }
public static <T> Collection<PrismPropertyValue<T>> createCollection(PrismContext prismContext, T[] realValueArray) { Collection<PrismPropertyValue<T>> pvalCol = new ArrayList<>(realValueArray.length); for (T realValue: realValueArray) { pvalCol.add(prismContext.itemFactory().createPropertyValue(realValue)); } return pvalCol; }
@Override public <O extends Objectable> ObjectDelta<O> createModificationAddReference(Class<O> type, String oid, QName propertyName, String... targetOids) { PrismReferenceValue[] referenceValues = new PrismReferenceValue[targetOids.length]; for(int i=0; i < targetOids.length; i++) { referenceValues[i] = prismContext.itemFactory().createReferenceValue(targetOids[i]); } return createModificationAddReference(type, oid, propertyName, referenceValues); }
protected PrismContainerValue<AssignmentType> createAssignmentValue(Long id, String description) throws SchemaException { PrismContainerDefinition<AssignmentType> assignmentDef = getUserTypeDefinition().findContainerDefinition(UserType.F_ASSIGNMENT); PrismContainerValue<AssignmentType> assignmentValue = getPrismContext().itemFactory().createContainerValue(); populateAssignmentValue(assignmentValue, id, description); return assignmentValue; }
@SuppressWarnings({ "unused", "unchecked" }) private SceneDeltaItemImpl createSceneDeltaItem(PropertyDelta<?> delta, SceneImpl owningScene, VisualizationContext context, Task task, OperationResult result) throws SchemaException { SceneDeltaItemImpl si = createSceneDeltaItemCommon(delta, owningScene); si.setOldValues(toSceneItemValues(delta.getEstimatedOldValues())); PrismProperty property = prismContext.itemFactory().createProperty(delta.getElementName()); if (delta.getEstimatedOldValues() != null) { property.addValues(CloneUtil.cloneCollectionMembers(delta.getEstimatedOldValues())); } try { delta.applyToMatchingPath(property, ParameterizedEquivalenceStrategy.DEFAULT_FOR_DELTA_APPLICATION); } catch (SchemaException e) { throw new SystemException("Couldn't visualize property delta: " + delta + ": " + e.getMessage(), e); } computeAddedDeletedUnchanged(si, delta.getEstimatedOldValues(), property.getValues()); si.setNewValues(toSceneItemValues(property.getValues())); return si; }
ref1Def.setTargetTypeName(ACCOUNT_TYPE_QNAME); PrismReference ref1a = prismContext.itemFactory().createReference(REF_QNAME, ref1Def); PrismReferenceValue val11 = new PrismReferenceValueImpl("oid1"); val11.setTargetType(ACCOUNT_TYPE_QNAME); assertFalse(ref1a.add(val12)); PrismReference ref1b = prismContext.itemFactory().createReference(REF_QNAME, ref1Def); PrismReferenceValue val13 = new PrismReferenceValueImpl("oid1"); PrismReference ref2a = prismContext.itemFactory().createReference(REF_QNAME, ref2Def); PrismReferenceValue val21 = new PrismReferenceValueImpl("oid1"); val21.setTargetType(ACCOUNT_TYPE_QNAME); assertFalse(ref2a.add(val22)); PrismReference ref2b = prismContext.itemFactory().createReference(REF_QNAME, ref2Def); PrismReferenceValue val23 = new PrismReferenceValueImpl("oid1");
public static <T> Collection<PrismPropertyValue<T>> wrap(PrismContext prismContext, @NotNull Collection<T> realValues) { return realValues.stream() .map(val -> prismContext.itemFactory().createPropertyValue(val)) .collect(Collectors.toList()); }
public static <T extends Objectable> ReferenceDeltaImpl createModificationAdd(Class<T> type, ItemName refName, PrismContext prismContext, PrismObject<?> refTarget) { PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(refTarget); return createModificationAdd(type, refName, prismContext, refValue); }
protected <F extends AssignmentHolderType> ContainerDelta<AssignmentType> createAssignmentModification(Class<F> type, QName elementName, String roleOid, QName refType, QName relation, Consumer<AssignmentType> modificationBlock, boolean add) throws SchemaException { ContainerDelta<AssignmentType> assignmentDelta = prismContext.deltaFactory().container().createDelta(ItemName.fromQName(elementName), getObjectDefinition(type)); PrismContainerValue<AssignmentType> cval = prismContext.itemFactory().createContainerValue(); if (add) { assignmentDelta.addValueToAdd(cval); } else { assignmentDelta.addValueToDelete(cval); } PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF); targetRef.getValue().setOid(roleOid); targetRef.getValue().setTargetType(refType); targetRef.getValue().setRelation(relation); if (modificationBlock != null) { modificationBlock.accept(cval.asContainerable()); } return assignmentDelta; }
PrismProperty<String> attrBazBefore = prismContext.itemFactory().createProperty(new QName(MidPointConstants.NS_RI, "baz")); MutablePrismPropertyDefinition<String> attrBazDefBefore = prismContext.definitionFactory().createPropertyDefinition(attrBazQName, DOMUtil.XSD_STRING); attrBazDefBefore.setMaxOccurs(-1);
@SafeVarargs public static <T> PrismPropertyValue<T>[] wrap(PrismContext prismContext, T... realValues) { //noinspection unchecked return Arrays.stream(realValues) .map(val -> prismContext.itemFactory().createPropertyValue(val)) .toArray(PrismPropertyValue[]::new); }
public static ReferenceDeltaImpl createModificationDelete(QName refName, PrismObjectDefinition<?> objectDefinition, PrismObject<?> refTarget, PrismContext prismContext) { PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(refTarget); return createModificationDelete(refName, objectDefinition, refValue); }