use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class ReferenceWrapper method createAddedValue.
@Override
public ValueWrapper createAddedValue() {
PrismReferenceValue prv = new PrismReferenceValue();
ValueWrapper wrapper = new ValueWrapper(this, prv, ValueStatus.ADDED);
return wrapper;
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class ReferenceWrapper method createValues.
private List<ValueWrapper> createValues() {
List<ValueWrapper> values = new ArrayList<ValueWrapper>();
for (PrismReferenceValue prismValue : item.getValues()) {
values.add(new ValueWrapper(this, prismValue, prismValue, ValueStatus.NOT_CHANGED));
}
int minOccurs = getItemDefinition().getMinOccurs();
while (values.size() < minOccurs) {
values.add(createAddedValue());
}
if (values.isEmpty()) {
values.add(createAddedValue());
}
return values;
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class OrgMemberPanel method createManagerQuery.
private ObjectQuery createManagerQuery() {
String oid = getModelObject().getOid();
PrismReferenceValue referenceFilter = new PrismReferenceValue();
referenceFilter.setOid(oid);
referenceFilter.setRelation(SchemaConstants.ORG_MANAGER);
ObjectQuery query = QueryBuilder.queryFor(FocusType.class, getPageBase().getPrismContext()).item(FocusType.F_PARENT_ORG_REF).ref(referenceFilter).build();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Searching members of org {} with query:\n{}", oid, query.debugDump());
}
return query;
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class AccCertReviewersHelper method getAssignees.
private List<ObjectReferenceType> getAssignees(AbstractRoleType role, QName relation, Task task, OperationResult result) throws SchemaException {
List<ObjectReferenceType> rv = new ArrayList<>();
if (SchemaConstants.ORG_OWNER.equals(relation)) {
CollectionUtils.addIgnoreNull(rv, role.getOwnerRef());
} else if (SchemaConstants.ORG_APPROVER.equals(relation)) {
rv.addAll(role.getApproverRef());
} else {
throw new AssertionError(relation);
}
// TODO in theory, we could look for approvers/owners of UserType, right?
PrismReferenceValue ref = new PrismReferenceValue(role.getOid());
ref.setRelation(relation);
ObjectQuery query = QueryBuilder.queryFor(FocusType.class, prismContext).item(FocusType.F_ROLE_MEMBERSHIP_REF).ref(ref).build();
List<PrismObject<FocusType>> assignees = repositoryService.searchObjects(FocusType.class, query, null, result);
LOGGER.trace("Looking for '{}' of {} using {}: found: {}", relation.getLocalPart(), role, query, assignees);
assignees.forEach(o -> rv.add(ObjectTypeUtil.createObjectRef(o)));
return rv;
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class AssignmentProcessor method setReferences.
private <F extends ObjectType> void setReferences(LensFocusContext<F> focusContext, QName itemName, Collection<PrismReferenceValue> targetState) throws SchemaException {
PrismObject<F> focusOld = focusContext.getObjectOld();
if (focusOld == null) {
if (targetState.isEmpty()) {
return;
}
} else {
PrismReference existingState = focusOld.findReference(itemName);
if (existingState == null || existingState.isEmpty()) {
if (targetState.isEmpty()) {
return;
}
} else {
// we don't use QNameUtil.match here, because we want to ensure we store qualified values there
// (and newValues are all qualified)
Comparator<PrismReferenceValue> comparator = (a, b) -> 2 * a.getOid().compareTo(b.getOid()) + (Objects.equals(a.getRelation(), b.getRelation()) ? 0 : 1);
if (MiscUtil.unorderedCollectionCompare(targetState, existingState.getValues(), comparator)) {
return;
}
}
}
PrismReferenceDefinition itemDef = focusContext.getObjectDefinition().findItemDefinition(itemName, PrismReferenceDefinition.class);
ReferenceDelta itemDelta = new ReferenceDelta(itemName, itemDef, focusContext.getObjectDefinition().getPrismContext());
itemDelta.setValuesToReplace(targetState);
focusContext.swallowToSecondaryDelta(itemDelta);
}
Aggregations