Search in sources :

Example 1 with PrismReferenceValue

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;
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue)

Example 2 with PrismReferenceValue

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;
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ArrayList(java.util.ArrayList)

Example 3 with PrismReferenceValue

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;
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 4 with PrismReferenceValue

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;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 5 with PrismReferenceValue

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);
}
Also used : PrismValue(com.evolveum.midpoint.prism.PrismValue) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) Construction(com.evolveum.midpoint.model.impl.lens.Construction) Autowired(org.springframework.beans.factory.annotation.Autowired) ObjectResolver(com.evolveum.midpoint.schema.util.ObjectResolver) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) ConstructionPack(com.evolveum.midpoint.model.impl.lens.ConstructionPack) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) MappingFactory(com.evolveum.midpoint.model.common.mapping.MappingFactory) QNameUtil(com.evolveum.midpoint.util.QNameUtil) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) ModelUtils(com.evolveum.midpoint.model.impl.controller.ModelUtils) PrismValueDeltaSetTriple(com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Mapping(com.evolveum.midpoint.model.common.mapping.Mapping) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ActivationComputer(com.evolveum.midpoint.common.ActivationComputer) MiscUtil(com.evolveum.midpoint.util.MiscUtil) Task(com.evolveum.midpoint.task.api.Task) Objects(java.util.Objects) PlusMinusZero(com.evolveum.midpoint.prism.delta.PlusMinusZero) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) EvaluatedAssignmentImpl(com.evolveum.midpoint.model.impl.lens.EvaluatedAssignmentImpl) SystemObjectCache(com.evolveum.midpoint.model.common.SystemObjectCache) ProvisioningService(com.evolveum.midpoint.provisioning.api.ProvisioningService) Entry(java.util.Map.Entry) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) QName(javax.xml.namespace.QName) NotNull(org.jetbrains.annotations.NotNull) FocusTypeUtil(com.evolveum.midpoint.schema.util.FocusTypeUtil) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) java.util(java.util) ObjectDeltaObject(com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) Trace(com.evolveum.midpoint.util.logging.Trace) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) DeltaSetTriple(com.evolveum.midpoint.prism.delta.DeltaSetTriple) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) SchemaDebugUtil(com.evolveum.midpoint.schema.util.SchemaDebugUtil) PrismContext(com.evolveum.midpoint.prism.PrismContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) ItemValueWithOrigin(com.evolveum.midpoint.model.impl.lens.ItemValueWithOrigin) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) LensUtil(com.evolveum.midpoint.model.impl.lens.LensUtil) DeltaMapTriple(com.evolveum.midpoint.prism.delta.DeltaMapTriple) AssignmentEvaluator(com.evolveum.midpoint.model.impl.lens.AssignmentEvaluator) PrismObject(com.evolveum.midpoint.prism.PrismObject) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) SynchronizationPolicyDecision(com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Component(org.springframework.stereotype.Component) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) LensFocusContext(com.evolveum.midpoint.model.impl.lens.LensFocusContext) PrismReference(com.evolveum.midpoint.prism.PrismReference) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismReference(com.evolveum.midpoint.prism.PrismReference) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition)

Aggregations

PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)126 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)64 Test (org.testng.annotations.Test)47 Task (com.evolveum.midpoint.task.api.Task)45 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)32 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)27 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)26 PrismObject (com.evolveum.midpoint.prism.PrismObject)25 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)24 ArrayList (java.util.ArrayList)22 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)20 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)16 PrismReference (com.evolveum.midpoint.prism.PrismReference)15 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)12 Collection (java.util.Collection)12 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)11