public DefaultReferencableImpl clone() { DefaultReferencableImpl clone; try { clone = (DefaultReferencableImpl) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException(e); } if (referenceValue != null) { clone.referenceValue = referenceValue.clone(); } return clone; }
private <O extends ObjectType> void addLinkDelta(ObjectDelta<O> objectDelta, PrismReferenceValue linkRef) { objectDelta.addModificationAddReference(FocusType.F_LINK_REF, linkRef.clone()); }
private <O extends ObjectType> void addUnlinkDelta(ObjectDelta<O> objectDelta, PrismReferenceValue linkRef) { objectDelta.addModificationDeleteReference(FocusType.F_LINK_REF, linkRef.clone()); }
public static List<ObjectReferenceType> getAsObjectReferenceTypeList(PrismReference prismReference) throws SchemaException { List<ObjectReferenceType> rv = new ArrayList<>(); for (PrismReferenceValue prv : prismReference.getValues()) { rv.add(createObjectRef(prv.clone())); } return rv; }
@NotNull public static Collection<PrismReferenceValue> getDelegatorReferences(@NotNull UserType user, @NotNull RelationRegistry relationRegistry) { return user.getDelegatedRef().stream() .filter(ref -> relationRegistry.isDelegation(ref.getRelation())) .map(ref -> ref.asReferenceValue().clone()) .collect(Collectors.toList()); }
public ObjectReferenceType clone() { ObjectReferenceType object = new ObjectReferenceType(); PrismReferenceValue value = asReferenceValue().clone(); object.setupReferenceValue(value); return object; }
@SuppressWarnings("unchecked") private PrismReferenceValue createRefValueWithObject(PrismReferenceValue refValue, VisualizationContext context, Task task, OperationResult result) { if (refValue.getObject() != null) { return refValue; } PrismObject<? extends ObjectType> object = getObject(refValue.getOid(), (Class) refValue.getTargetTypeCompileTimeClass(prismContext), context, task, result); if (object == null) { return refValue; } refValue = refValue.clone(); refValue.setObject(object); return refValue; }
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 void addUserParent(UserType user, ObjectReferenceType parentOrgRef, OperationResult opResult) throws Exception { List<ItemDelta> modifications = new ArrayList<>(); PrismReferenceValue existingValue = parentOrgRef.asReferenceValue(); ItemDelta readdParent = prismContext.deltaFactory().reference().createModificationAdd(UserType.class, UserType.F_PARENT_ORG_REF, existingValue.clone()); modifications.add(readdParent); repositoryService.modifyObject(UserType.class, user.getOid(), modifications, opResult); }
protected void addOrgParent(OrgType org, ObjectReferenceType parentOrgRef, boolean useReplace, OperationResult opResult) throws Exception { List<ItemDelta> modifications = new ArrayList<>(); PrismReferenceValue existingValue = parentOrgRef.asReferenceValue(); ItemDelta itemDelta; if (!useReplace) { itemDelta = prismContext.deltaFactory().reference().createModificationAdd(OrgType.class, OrgType.F_PARENT_ORG_REF, existingValue.clone()); } else { List<PrismReferenceValue> newValues = new ArrayList<>(); for (ObjectReferenceType ort : org.getParentOrgRef()) { newValues.add(ort.asReferenceValue().clone()); } newValues.add(existingValue.clone()); PrismObjectDefinition objectDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class); itemDelta = prismContext.deltaFactory().reference().createModificationReplace(OrgType.F_PARENT_ORG_REF, objectDefinition, newValues); } modifications.add(itemDelta); repositoryService.modifyObject(OrgType.class, org.getOid(), modifications, opResult); orgGraph.addEdge(org.getOid(), existingValue.getOid()); }
if (reference.isEmpty()) { if (value.getParent() != null) { value = value.clone();
protected void removeObjectParent(ObjectType object, ObjectReferenceType parentOrgRef, boolean useReplace, OperationResult opResult) throws Exception { List<ItemDelta> modifications = new ArrayList<>(); if (!useReplace) { // standard case PrismReferenceValue existingValue = parentOrgRef.asReferenceValue(); ItemDelta removeParent = prismContext.deltaFactory().reference().createModificationDelete(object.getClass(), OrgType.F_PARENT_ORG_REF, existingValue.clone()); modifications.add(removeParent); } else { // using REPLACE modification List<PrismReferenceValue> newValues = new ArrayList<>(); for (ObjectReferenceType ort : object.getParentOrgRef()) { if (!ort.getOid().equals(parentOrgRef.getOid())) { newValues.add(ort.asReferenceValue().clone()); } } PrismObjectDefinition objectDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(object.getClass()); ItemDelta replaceParent = prismContext.deltaFactory().reference().createModificationReplace(OrgType.F_PARENT_ORG_REF, objectDefinition, newValues); modifications.add(replaceParent); } repositoryService.modifyObject(object.getClass(), object.getOid(), modifications, opResult); if (object instanceof OrgType) { orgGraph.removeEdge(object.getOid(), parentOrgRef.getOid()); } }
PrismReferenceValue prv = ((Referencable) value).asReferenceValue(); if (!prv.isImmutable()) { PrismReferenceValue clone = prv.clone(); Referencable referencableClone = clone.asReferencable(); clone.setImmutable(true); // must be called after first asReferencable on clone
OperationResult result = parentResult.createSubresult(OPERATION_UNLINK_ACCOUNT); Collection<? extends ItemDelta> accountRefDeltas = prismContext.deltaFactory().reference().createModificationDeleteCollection( FocusType.F_LINK_REF, getUserDefinition(), accountRef.clone());
FocusType.F_LINK_REF, focusContext.getObjectDefinition(), linkRef.asReferenceValue().clone()); focusContext.swallowToSecondaryDelta(unlinkDelta); continue;
PrismReference connectorRef = resourceDummyFake.findReference(ResourceType.F_CONNECTOR_REF); ReferenceDelta connectorRefDeltaDel = prismContext.deltaFactory().reference().createModificationDelete(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorRef.getValue().clone()); resourceDelta.addModification(connectorRefDeltaDel); ReferenceDelta connectorRefDeltaAdd = prismContext.deltaFactory().reference().createModificationAdd(ResourceType.F_CONNECTOR_REF,