private static String getReferredObjectInformation(PrismReferenceValue ref) { if (ref.getObject() != null) { return ref.getObject().toString(); } else { return (ref.getTargetType() != null ? ref.getTargetType().getLocalPart()+":" : "") + (ref.getTargetName() != null ? ref.getTargetName() : ref.getOid()); } } }
private void addReferences(Collection<PrismReferenceValue> extractedReferences, Collection<PrismReferenceValue> references) { for (PrismReferenceValue reference: references) { boolean found = false; for (PrismReferenceValue exVal: extractedReferences) { if (MiscUtil.equals(exVal.getOid(), reference.getOid()) && prismContext.relationsEquivalent(exVal.getRelation(), reference.getRelation())) { found = true; break; } } if (!found) { PrismReferenceValue ref = reference.cloneComplex(CloneStrategy.REUSE); // clone without full object instead of calling canonicalize() if (ref.getRelation() == null || QNameUtil.isUnqualified(ref.getRelation())) { ref.setRelation(relationRegistry.normalizeRelation(ref.getRelation())); } extractedReferences.add(ref); } } }
@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; }
private void distributeResourceValue(PrismReferenceValue resourceRefVal, PrismObject<ResourceType> resource) { if (resourceRefVal != null) { boolean immutable = resourceRefVal.isImmutable(); if (immutable) { resourceRefVal.setImmutable(false); } resourceRefVal.setObject(resource); resourceRefVal.setImmutable(immutable); } }
public AuditReferenceValue(@NotNull PrismReferenceValue prv) { this(prv.getOid(), prv.getTargetType(), prv.getTargetName()); }
private boolean matches(PrismReferenceValue refVal) throws ObjectNotFoundException, SchemaException { if (targetOid != null) { if (!targetOid.equals(refVal.getOid())) { return false; } } if (relation != null) { if (!QNameUtil.match(relation, refVal.getRelation())) { return false; } } if (targetType != null) { if (!QNameUtil.match(targetType, refVal.getTargetType())) { return false; } } return true; }
private void setReferenceObject(PrismReferenceValue refVal, PrismObject<Objectable> object) throws SchemaException { refVal.setObject(object); if (object.getOid() != null) { if (refVal.getOid() == null) { refVal.setOid(object.getOid()); } else { if (!refVal.getOid().equals(object.getOid())) { throw new SchemaException("OID in reference (" + refVal.getOid() + ") does not match OID in composite object (" + object.getOid() + ")"); } } } QName objectTypeName = object.getDefinition().getTypeName(); if (refVal.getTargetType() == null) { refVal.setTargetType(objectTypeName); } else { if (!refVal.getTargetType().equals(objectTypeName)) { throw new SchemaException("Target type in reference (" + refVal.getTargetType() + ") does not match type in composite object (" + objectTypeName + ")"); } } }
private List<SceneItemValueImpl> toSceneItemValuesRef(Collection<PrismReferenceValue> refValues, VisualizationContext context, Task task, OperationResult result) { List<SceneItemValueImpl> rv = new ArrayList<>(); if (refValues != null) { for (PrismReferenceValue refValue : refValues) { if (refValue != null) { refValue = createRefValueWithObject(refValue, context, task, result); String name; if (refValue.getObject() != null) { name = PolyString.getOrig(refValue.getObject().getName()); } else if (refValue.getTargetName() != null) { name = refValue.getTargetName().getOrig(); } else { name = refValue.getOid(); } String relation; if (refValue.getRelation() != null) { relation = "[" + refValue.getRelation().getLocalPart() + "]"; } else { relation = null; } SceneItemValueImpl itemValue = new SceneItemValueImpl(name, relation); itemValue.setSourceValue(refValue); rv.add(itemValue); } } } return rv; }
public static PrismObject<?> getPrismObjectFromReference(ObjectReferenceType ref) { if (ref == null) { return null; } return ref.asReferenceValue().getObject(); }
if (other.getOid() != null) return false; } else if (!this.getOid().equals(other.getOid())) return false; boolean bothOidsNull = this.oid == null && other.getOid() == null; if (bothOidsNull) { if (this.object != null || other.getObject() != null) { if (this.object == null || other.getObject() == null) { if (!this.object.equals(other.getObject())) { return false; return false; if (!relationsEquivalent(relation, other.getRelation(), strategy.isLiteralDomComparison())) { return false; if ((strategy.isConsideringReferenceFilters() || bothOidsNull) && !filtersEquivalent(filter, other.getFilter())) { return false;
public static List<String> referenceValueListToOidList(Collection<PrismReferenceValue> referenceValues) { List<String> oids = new ArrayList<>(referenceValues.size()); for (PrismReferenceValue referenceValue : referenceValues) { oids.add(referenceValue.getOid()); } return oids; }
public static void assertRefEquivalent(String message, PrismReferenceValue expected, PrismReferenceValue actual) { if (expected == null && actual == null) { return; } if (expected == null || actual == null) { fail(message + ": expected=" + expected + ", actual=" + actual); } assertEquals(message+": wrong target oid", expected.getOid(), actual.getOid()); assertEquals(message+": wrong target type", expected.getTargetType(), actual.getTargetType()); }
private static String getOrigName(PrismReferenceValue refval) { if (refval.getObject() != null) { return getOrigName(refval.getObject()); } PolyString name = refval.getTargetName(); return name != null ? name.getOrig() : null; }
protected PrismReferenceValue createPrismValue(String oid, QName targetTypeQName, List<ItemDelta<PrismReferenceValue, PrismReferenceDefinition>> additionalAttributeValues, ExpressionEvaluationContext params) { PrismReferenceValue refVal = getPrismContext().itemFactory().createReferenceValue(); refVal.setOid(oid); refVal.setTargetType(targetTypeQName); refVal.setRelation(((ReferenceSearchExpressionEvaluatorType)getExpressionEvaluatorType()).getRelation()); return refVal; }
private boolean matches(PrismReferenceValue refVal, PrismObject<OrgType> refTarget) throws ObjectNotFoundException, SchemaException { OrgType refTargetType = refTarget.asObjectable(); if (targetOid != null) { if (!targetOid.equals(refVal.getOid())) { return false; } } if (relation != null) { if (!QNameUtil.match(relation, refVal.getRelation())) { return false; } } // TODO: more criteria return true; }
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()); }
public static PrismReferenceValue objectReferenceTypeToReferenceValue(ObjectReferenceType refType, PrismContext prismContext) { if (refType == null) { return null; } PrismReferenceValue rval = prismContext.itemFactory().createReferenceValue(); rval.setOid(refType.getOid()); rval.setDescription(refType.getDescription()); rval.setFilter(refType.getFilter()); rval.setRelation(refType.getRelation()); rval.setTargetType(refType.getType()); return rval; }
private void collectMembership(AssignmentHolderType targetType, QName relation, EvaluationContext ctx) { PrismReferenceValue refVal = prismContext.itemFactory().createReferenceValue(); refVal.setObject(targetType.asPrismObject()); refVal.setTargetType(ObjectTypes.getObjectType(targetType.getClass()).getTypeQName()); refVal.setRelation(relation); refVal.setTargetName(targetType.getName().toPolyString()); collectMembershipRefVal(refVal, targetType.getClass(), relation, targetType, ctx); }
private void collectMembership(ObjectReferenceType targetRef, QName relation, EvaluationContext ctx) { PrismReferenceValue refVal = prismContext.itemFactory().createReferenceValue(); refVal.setOid(targetRef.getOid()); refVal.setTargetType(targetRef.getType()); refVal.setRelation(relation); refVal.setTargetName(targetRef.getTargetName()); Class<? extends ObjectType> targetClass = ObjectTypes.getObjectTypeFromTypeQName(targetRef.getType()).getClassDefinition(); collectMembershipRefVal(refVal, targetClass, relation, targetRef, ctx); }
protected ObjectDelta<UserType> createParametricAssignmentDelta(String userOid, String roleOid, String orgOid, String tenantOid, boolean adding) throws SchemaException { Collection<ItemDelta<?,?>> modifications = new ArrayList<>(); ContainerDelta<AssignmentType> assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); PrismContainerValue<AssignmentType> cval = prismContext.itemFactory().createContainerValue(); if (adding) { assignmentDelta.addValueToAdd(cval); } else { assignmentDelta.addValueToDelete(cval); } PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF); targetRef.getValue().setOid(roleOid); targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE); if (orgOid != null) { PrismReference orgRef = cval.findOrCreateReference(AssignmentType.F_ORG_REF); orgRef.getValue().setOid(orgOid); } if (tenantOid != null) { PrismReference tenantRef = cval.findOrCreateReference(AssignmentType.F_TENANT_REF); tenantRef.getValue().setOid(tenantOid); } modifications.add(assignmentDelta); return prismContext.deltaFactory().object().createModifyDelta(userOid, modifications, UserType.class ); }