Skip to content

Commit

Permalink
Multiaccounts: it compiles again! (MID-6242)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed May 4, 2020
1 parent 6434dda commit 6f3e34c
Show file tree
Hide file tree
Showing 26 changed files with 340 additions and 286 deletions.
Expand Up @@ -13,8 +13,10 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.common.ActivationComputer;
import com.evolveum.midpoint.common.Clock;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.model.impl.lens.construction.Construction;
import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl;
import com.evolveum.midpoint.model.impl.lens.construction.PersonaConstruction;
import com.evolveum.midpoint.model.impl.lens.projector.AssignmentOrigin;
import com.evolveum.midpoint.model.impl.lens.projector.ContextLoader;
import com.evolveum.midpoint.model.impl.lens.projector.mappings.AssignedFocusMappingEvaluationRequest;
Expand Down Expand Up @@ -580,7 +582,7 @@ private void collectConstruction(AssignmentPathSegmentImpl segment, PlusMinusZer

LOGGER.trace("Preparing construction '{}' in {}", constructionType.getDescription(), segment.source);

Construction<AH> construction = new Construction<>(constructionType, segment.source);
Construction<AH, EvaluatedConstructionImpl<AH>> construction = new Construction<>(constructionType, segment.source);
// We have to clone here as the path is constantly changing during evaluation
construction.setAssignmentPath(ctx.assignmentPath.clone());
construction.setFocusOdo(focusOdo);
Expand Down
Expand Up @@ -13,6 +13,9 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.model.impl.lens.construction.Construction;
import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl;
import com.evolveum.midpoint.model.impl.lens.construction.PersonaConstruction;
import com.evolveum.midpoint.model.impl.lens.projector.AssignmentOrigin;
import com.evolveum.midpoint.model.impl.lens.projector.mappings.AssignedFocusMappingEvaluationRequest;
import com.evolveum.midpoint.prism.*;
Expand Down Expand Up @@ -57,7 +60,7 @@ public class EvaluatedAssignmentImpl<AH extends AssignmentHolderType> implements

@NotNull private final ItemDeltaItem<PrismContainerValue<AssignmentType>,PrismContainerDefinition<AssignmentType>> assignmentIdi;
private final boolean evaluatedOld;
@NotNull private final DeltaSetTriple<Construction<AH>> constructionTriple;
@NotNull private final DeltaSetTriple<Construction<AH, EvaluatedConstructionImpl<AH>>> constructionTriple;
@NotNull private final DeltaSetTriple<PersonaConstruction<AH>> personaConstructionTriple;
@NotNull private final DeltaSetTriple<EvaluatedAssignmentTargetImpl> roles;
@NotNull private final Collection<PrismReferenceValue> orgRefVals = new ArrayList<>();
Expand Down Expand Up @@ -153,7 +156,7 @@ public QName getNormalizedRelation(RelationRegistry relationRegistry) {
}

@NotNull
public DeltaSetTriple<Construction<AH>> getConstructionTriple() {
public DeltaSetTriple<Construction<AH,EvaluatedConstructionImpl<AH>>> getConstructionTriple() {
return constructionTriple;
}

Expand All @@ -166,15 +169,15 @@ public DeltaSetTriple<Construction<AH>> getConstructionTriple() {
@NotNull
public DeltaSetTriple<EvaluatedConstruction> getEvaluatedConstructions(@NotNull Task task, @NotNull OperationResult result) {
DeltaSetTriple<EvaluatedConstructionImpl<AH>> rv = prismContext.deltaFactory().createDeltaSetTriple();
for (Construction<AH> construction : constructionTriple.getPlusSet()) {
for (Construction<AH,EvaluatedConstructionImpl<AH>> construction : constructionTriple.getPlusSet()) {
for (EvaluatedConstructionImpl<AH> evaluatedConstruction : construction.getEvaluatedConstructionTriple().getNonNegativeValues()) {
rv.addToPlusSet(evaluatedConstruction);
}
}
for (Construction<AH> construction : constructionTriple.getZeroSet()) {
for (Construction<AH,EvaluatedConstructionImpl<AH>> construction : constructionTriple.getZeroSet()) {
rv.merge(construction.getEvaluatedConstructionTriple());
}
for (Construction<AH> construction : constructionTriple.getMinusSet()) {
for (Construction<AH,EvaluatedConstructionImpl<AH>> construction : constructionTriple.getMinusSet()) {
for (EvaluatedConstructionImpl<AH> evaluatedConstruction : construction.getEvaluatedConstructionTriple().getNonPositiveValues()) {
rv.addToPlusSet(evaluatedConstruction);
}
Expand All @@ -183,7 +186,7 @@ public DeltaSetTriple<EvaluatedConstruction> getEvaluatedConstructions(@NotNull
return (DeltaSetTriple)rv;
}

Collection<Construction<AH>> getConstructionSet(PlusMinusZero whichSet) {
Collection<Construction<AH,EvaluatedConstructionImpl<AH>>> getConstructionSet(PlusMinusZero whichSet) {
switch (whichSet) {
case ZERO: return getConstructionTriple().getZeroSet();
case PLUS: return getConstructionTriple().getPlusSet();
Expand All @@ -192,7 +195,7 @@ Collection<Construction<AH>> getConstructionSet(PlusMinusZero whichSet) {
}
}

void addConstruction(Construction<AH> construction, PlusMinusZero whichSet) {
void addConstruction(Construction<AH,EvaluatedConstructionImpl<AH>> construction, PlusMinusZero whichSet) {
addToTriple(construction, constructionTriple, whichSet);
}

Expand Down Expand Up @@ -341,7 +344,7 @@ public void evaluateConstructions(ObjectDeltaObject<AH> focusOdo, PrismObject<Sy
Consumer<ResourceType> resourceConsumer, Task task, OperationResult result) throws SchemaException,
ExpressionEvaluationException, ObjectNotFoundException, SecurityViolationException, ConfigurationException,
CommunicationException {
for (Construction<AH> construction : constructionTriple.getAllValues()) {
for (Construction<AH,EvaluatedConstructionImpl<AH>> construction : constructionTriple.getAllValues()) {
construction.setFocusOdo(focusOdo);
construction.setSystemConfiguration(systemConfiguration);
construction.setWasValid(wasValid);
Expand Down
Expand Up @@ -10,6 +10,7 @@
import java.util.Collection;

import com.evolveum.midpoint.model.common.mapping.PrismValueDeltaSetTripleProducer;
import com.evolveum.midpoint.model.impl.lens.construction.Construction;
import com.evolveum.midpoint.model.impl.lens.projector.ValueMatcher;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismContext;
Expand Down
Expand Up @@ -19,6 +19,8 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.common.refinery.*;
import com.evolveum.midpoint.model.impl.lens.construction.Construction;
import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
Expand Down Expand Up @@ -173,7 +175,7 @@ public class LensProjectionContext extends LensElementContext<ShadowType> implem
* Source: AssignmentProcessor
* Target: ConsolidationProcessor / ReconciliationProcessor (via squeezed structures)
*/
private transient PrismValueDeltaSetTriple<PrismPropertyValue<Construction>> constructionDeltaSetTriple;
private transient DeltaSetTriple<EvaluatedConstructionImpl<?>> constructionDeltaSetTriple;

/**
* Triples for outbound mappings; similar to the above.
Expand Down Expand Up @@ -581,13 +583,13 @@ public ShadowKindType getKind() {
return ShadowKindType.ACCOUNT;
}

public <AH extends AssignmentHolderType> PrismValueDeltaSetTriple<PrismPropertyValue<Construction<AH>>> getConstructionDeltaSetTriple() {
public <AH extends AssignmentHolderType> DeltaSetTriple<EvaluatedConstructionImpl<AH>> getConstructionDeltaSetTriple() {
//noinspection unchecked
return (PrismValueDeltaSetTriple)constructionDeltaSetTriple;
return (DeltaSetTriple)constructionDeltaSetTriple;
}

public void setConstructionDeltaSetTriple(PrismValueDeltaSetTriple<PrismPropertyValue<Construction>> constructionDeltaSetTriple) {
this.constructionDeltaSetTriple = constructionDeltaSetTriple;
public <AH extends AssignmentHolderType> void setConstructionDeltaSetTriple(DeltaSetTriple<EvaluatedConstructionImpl<AH>> evaluatedConstructionDeltaSetTriple) {
this.constructionDeltaSetTriple = (DeltaSetTriple)evaluatedConstructionDeltaSetTriple;
}

public Construction getOutboundConstruction() {
Expand Down
Expand Up @@ -100,7 +100,7 @@ public static <F extends ObjectType> ResourceType getResourceReadOnly(LensContex
}

@NotNull
static <F extends ObjectType> ResourceType getResourceReadOnly(LensContext<F> context, String resourceOid, ObjectResolver objectResolver,
public static <F extends ObjectType> ResourceType getResourceReadOnly(LensContext<F> context, String resourceOid, ObjectResolver objectResolver,
Task task, OperationResult result) throws ObjectNotFoundException,
CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
ResourceType resourceFromContext = context.getResource(resourceOid);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Evolveum and contributors
* Copyright (c) 2017-2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand All @@ -13,8 +13,13 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionPack;
import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedPersonaConstructionImpl;
import com.evolveum.midpoint.model.impl.lens.construction.PersonaConstruction;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -46,11 +51,6 @@
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PersonaConstructionType;

/**
* Runs persona-related changes after the primary operation is all done. Executed directly from clockwork.
Expand Down Expand Up @@ -115,7 +115,7 @@ public <F extends FocusType> HookOperationMode processPersonaChangesFocus(LensCo

DeltaSetTriple<PersonaKey> activePersonaKeyTriple = context.getPrismContext().deltaFactory().createDeltaSetTriple();

ComplexConstructionConsumer<PersonaKey,PersonaConstruction<F>> consumer = new ComplexConstructionConsumer<PersonaKey,PersonaConstruction<F>>() {
ComplexConstructionConsumer<PersonaKey, EvaluatedPersonaConstructionImpl<F>> consumer = new ComplexConstructionConsumer<PersonaKey,EvaluatedPersonaConstructionImpl<F>>() {

@Override
public boolean before(PersonaKey key) {
Expand Down Expand Up @@ -144,16 +144,16 @@ public void onUnassigned(PersonaKey key, String desc) {

@Override
public void after(PersonaKey key, String desc,
DeltaMapTriple<PersonaKey, EvaluatedConstructionPack<PersonaConstruction<F>>> constructionMapTriple) {
DeltaMapTriple<PersonaKey, EvaluatedConstructionPack<EvaluatedPersonaConstructionImpl<F>>> constructionMapTriple) {
}


};

DeltaMapTriple<PersonaKey, EvaluatedConstructionPack<PersonaConstruction<F>>> constructionMapTriple =
DeltaMapTriple<PersonaKey, EvaluatedConstructionPack<EvaluatedPersonaConstructionImpl<F>>> constructionMapTriple =
constructionProcessor.processConstructions(context, evaluatedAssignmentTriple,
evaluatedAssignment -> evaluatedAssignment.getPersonaConstructionTriple(),
construction -> new PersonaKey(construction.getConstructionType()),
evaluatedConstruction -> new PersonaKey(((PersonaConstruction<F>)evaluatedConstruction.getConstruction()).getConstructionType()),
consumer);

LOGGER.trace("activePersonaKeyTriple:\n{}", activePersonaKeyTriple.debugDumpLazily());
Expand All @@ -165,18 +165,18 @@ public void after(PersonaKey key, String desc,
FocusType existingPersona = findPersona(existingPersonas, key);
LOGGER.trace("existingPersona: {}", existingPersona);
// TODO: add ability to merge several constructions
EvaluatedConstructionPack<PersonaConstruction<F>> pack = constructionMapTriple.getPlusMap().get(key);
EvaluatedConstructionPack<EvaluatedPersonaConstructionImpl<F>> pack = constructionMapTriple.getPlusMap().get(key);
if (pack == null) {
pack = constructionMapTriple.getZeroMap().get(key);
}
Collection<PrismPropertyValue<PersonaConstruction<F>>> constructions = pack.getEvaluatedConstructions();
if (constructions.isEmpty()) {
Collection<EvaluatedPersonaConstructionImpl<F>> evaluatedConstructions = pack.getEvaluatedConstructions();
if (evaluatedConstructions.isEmpty()) {
continue;
}
if (constructions.size() > 1) {
if (evaluatedConstructions.size() > 1) {
throw new UnsupportedOperationException("Merging of multiple persona constructions is not supported yet");
}
PersonaConstruction<F> construction = constructions.iterator().next().getValue();
PersonaConstruction<F> construction = evaluatedConstructions.iterator().next().getConstruction();
LOGGER.trace("construction:\n{}", construction.debugDumpLazily());
if (existingPersona == null) {
personaAdd(context, key, construction, task, result);
Expand Down
Expand Up @@ -4,10 +4,12 @@
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.model.impl.lens;
package com.evolveum.midpoint.model.impl.lens.construction;

import java.io.Serializable;

import com.evolveum.midpoint.model.impl.lens.AssignmentPathImpl;
import com.evolveum.midpoint.model.impl.lens.LensContext;
import com.evolveum.midpoint.prism.OriginType;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.delta.DeltaSetTriple;
Expand All @@ -25,7 +27,7 @@
/**
* @author Radovan Semancik
*/
public abstract class AbstractConstruction<AH extends AssignmentHolderType, ACT extends AbstractConstructionType, EC extends EvaluatedConstructionImpl<AH>> implements DebugDumpable, Serializable {
public abstract class AbstractConstruction<AH extends AssignmentHolderType, ACT extends AbstractConstructionType, EC extends EvaluatedConstructible<AH>> implements DebugDumpable, Serializable {

private static final Trace LOGGER = TraceManager.getTrace(AbstractConstruction.class);

Expand Down
Expand Up @@ -4,7 +4,7 @@
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.model.impl.lens;
package com.evolveum.midpoint.model.impl.lens.construction;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -13,6 +13,9 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.model.impl.lens.AssignmentPathVariables;
import com.evolveum.midpoint.model.impl.lens.LensProjectionContext;
import com.evolveum.midpoint.model.impl.lens.LensUtil;
import com.evolveum.midpoint.model.impl.lens.projector.ContextLoader;
import com.evolveum.midpoint.model.impl.lens.projector.mappings.NextRecompute;
import com.evolveum.midpoint.prism.delta.DeltaSetTriple;
Expand Down Expand Up @@ -91,7 +94,7 @@ public Construction(ConstructionType constructionType, ObjectType source) {
this.expressionProfile = MiscSchemaUtil.getExpressionProfile();
}

void setOrderOneObject(ObjectType orderOneObject) {
public void setOrderOneObject(ObjectType orderOneObject) {
this.orderOneObject = orderOneObject;
}

Expand Down Expand Up @@ -151,7 +154,7 @@ public void setSystemConfiguration(PrismObject<SystemConfigurationType> systemCo
this.systemConfiguration = systemConfiguration;
}

RefinedObjectClassDefinition getRefinedObjectClassDefinition() {
public RefinedObjectClassDefinition getRefinedObjectClassDefinition() {
return refinedObjectClassDefinition;
}

Expand Down Expand Up @@ -328,7 +331,7 @@ public NextRecompute evaluate(Task task, OperationResult parentResult)
assignmentPathVariables = LensUtil.computeAssignmentPathVariables(getAssignmentPath());
ResourceType resource = resolveResource(task, result);
if (resource != null) {
evaluateKindIntentObjectClass(resource, task, result);
evaluateObjectClassDefinition(resource, task, result);
createEvaluatedConstructions(task, result);
evaluateConstructions(task, result);
result.recordSuccess();
Expand All @@ -348,7 +351,7 @@ public NextRecompute evaluate(Task task, OperationResult parentResult)
return null;
}

private void evaluateKindIntentObjectClass(ResourceType resource, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
private void evaluateObjectClassDefinition(ResourceType resource, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
if (getConstructionType().getResourceRef() != null) {
String resourceOid = getConstructionType().getResourceRef().getOid();
if (resourceOid != null && !resource.getOid().equals(resourceOid)) {
Expand Down
Expand Up @@ -4,7 +4,7 @@
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.model.impl.lens.projector;
package com.evolveum.midpoint.model.impl.lens.construction;

import java.util.Collection;
import java.util.Map;
Expand All @@ -13,9 +13,6 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractConstructionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.evolveum.midpoint.model.impl.lens.*;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.delta.DeltaMapTriple;
Expand All @@ -25,15 +22,14 @@
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;

/**
* Collects evaluated constructions from evaluatedAssignmentTriple into a single-level triple.
* The collected evaluated constructions are neatly sorted by "key", which is usually ResourceShadowDiscriminator.
*
* @author Radovan Semancik
*/
public class ConstructionCollector<AH extends AssignmentHolderType, K extends HumanReadableDescribable, ACT extends AbstractConstructionType, AC extends AbstractConstruction<AH,ACT,EC>, EC extends EvaluatedConstructionImpl<AH>> {
public class ConstructionCollector<AH extends AssignmentHolderType, K extends HumanReadableDescribable, ACT extends AbstractConstructionType, AC extends AbstractConstruction<AH,ACT,EC>, EC extends EvaluatedConstructible<AH>> {

private DeltaMapTriple<K, EvaluatedConstructionPack<EC>> evaluatedConstructionMapTriple;

Expand Down

0 comments on commit 6f3e34c

Please sign in to comment.