Skip to content

Commit

Permalink
Merge branch 'master' into feature/commons-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Sep 4, 2020
2 parents ef5846a + 75e9cf0 commit 7bfa6f2
Show file tree
Hide file tree
Showing 31 changed files with 898 additions and 135 deletions.
Expand Up @@ -11,6 +11,7 @@
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.path.PathKeyedMap;
import com.evolveum.prism.xml.ns._public.types_3.DeltaSetTripleType;

import java.util.Collection;

Expand Down Expand Up @@ -71,4 +72,8 @@ public static <T> void putIntoOutputTripleMap(PathKeyedMap<DeltaSetTriple<T>> ou
}
}
}

public static boolean isEmpty(DeltaSetTripleType triple) {
return triple == null || (triple.getZero().isEmpty() && triple.getPlus().isEmpty() && triple.getMinus().isEmpty());
}
}
Expand Up @@ -13,6 +13,8 @@
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.schema.traces.operations.MappingEvaluationOpNode;

import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;
Expand All @@ -30,16 +32,17 @@ public class OpNode {

private final PrismContext prismContext;
protected final OperationResultType result;
private final List<OpNode> children = new ArrayList<>();
protected final List<OpNode> children = new ArrayList<>();
private final OpNode parent;
private final OpResultInfo info;
protected final OpResultInfo info;
private final TraceInfo traceInfo;
private OpNodePresentation presentation;

private TraceVisualizationInstructionsType visualizationInstructions;
private TraceVisualizationInstructionType visualizationInstruction;
private boolean stop = false;
private boolean visible = true;
private boolean disabled = false;

public OpNode(PrismContext prismContext, OperationResultType result, OpResultInfo info, OpNode parent, TraceInfo traceInfo) {
this.prismContext = prismContext;
Expand Down Expand Up @@ -74,6 +77,14 @@ public List<OpNode> getChildren() {
return children;
}

public <T extends OpNode> List<T> getChildren(Class<T> aClass) {
//noinspection unchecked
return children.stream()
.filter(child -> aClass.isAssignableFrom(child.getClass()))
.map(child -> (T) child)
.collect(Collectors.toList());
}

public OpNode getParent() {
return parent;
}
Expand Down Expand Up @@ -199,6 +210,21 @@ public <T> T getTraceDownwards(Class<T> aClass, int maxLevel) {
}
}

public <T extends OpNode> List<T> getNodesDownwards(Class<T> aClass, int maxLevel) {
List<T> nodes = new ArrayList<>();
if (aClass.isAssignableFrom(this.getClass())) {
//noinspection unchecked
nodes.add((T) this);
}

if (maxLevel > 0) {
for (OpNode child : children) {
nodes.addAll(child.getNodesDownwards(aClass, maxLevel-1));
}
}
return nodes;
}

public boolean isVisible() {
return visible;
}
Expand Down Expand Up @@ -602,7 +628,7 @@ public Integer getClickNumber() {

public int getMappingsCount() {
return (int) children.stream()
.filter(child -> child.getKind() == OperationKindType.MAPPING_EVALUATION)
.filter(child -> child instanceof MappingEvaluationOpNode)
.count();
}

Expand Down Expand Up @@ -643,4 +669,36 @@ public void setPresentation(OpNodePresentation presentation) {
public void resolveReferenceTargetNames(OpNodeTreeBuilder.NameResolver nameResolver) {
}

public boolean isDisabled() {
return disabled;
}

public void setDisabled(boolean disabled) {
this.disabled = disabled;
}

public final void postProcessRecursive() {
postProcess();
children.forEach(OpNode::postProcessRecursive);
}

protected void postProcess() {
// nothing to do at general level
}

@NotNull
public String getContext(String name) {
return TraceUtil.getContext(result, name);
}

@NotNull
public String getReturn(String name) {
return TraceUtil.getReturn(result, name);
}

@NotNull
public String getParameter(String name) {
return TraceUtil.getParameter(result, name);
}

}
Expand Up @@ -29,8 +29,18 @@ public static OpNode createOpNode(PrismContext prismContext, OperationResultType
return new MappingEvaluationOpNode(prismContext, result, info, parent, traceInfo);
case MAPPING_TIME_VALIDITY_EVALUATION:
return new MappingTimeValidityEvaluationOpNode(prismContext, result, info, parent, traceInfo);

case FOCUS_CHANGE_EXECUTION:
return new FocusChangeExecutionOpNode(prismContext, result, info, parent, traceInfo);
case PROJECTION_CHANGE_EXECUTION:
return new ProjectionChangeExecutionOpNode(prismContext, result, info, parent, traceInfo);
case CHANGE_EXECUTION_DELTA:
return new ChangeExecutionDeltaOpNode(prismContext, result, info, parent, traceInfo);
case UPDATE_SHADOW_SITUATION:
return new UpdateShadowSituationOpNode(prismContext, result, info, parent, traceInfo);
case LINK_UNLINK_SHADOW:
return new LinkUnlinkShadowOpNode(prismContext, result, info, parent, traceInfo);

case TRANSFORMATION_EXPRESSION_EVALUATION:
return new TransformationExpressionEvaluationOpNode(prismContext, result, info, parent, traceInfo);
case VALUE_TUPLE_TRANSFORMATION:
Expand All @@ -39,6 +49,10 @@ public static OpNode createOpNode(PrismContext prismContext, OperationResultType
return new ItemConsolidationOpNode(prismContext, result, info, parent, traceInfo);
case PROJECTOR_PROJECTION:
return new ProjectorProjectionOpNode(prismContext, result, info, parent, traceInfo);
case PROJECTION_ACTIVATION:
return new ProjectionActivationOpNode(prismContext, result, info, parent, traceInfo);
case PROJECTOR_FOCUS_POLICY_RULES:
return new FocusPolicyRulesOpNode(prismContext, result, info, parent, traceInfo);
case PROJECTOR_INBOUND:
case PROJECTOR_ASSIGNMENTS:
case PROJECTOR_TEMPLATE_BEFORE_ASSIGNMENTS:
Expand All @@ -49,6 +63,14 @@ public static OpNode createOpNode(PrismContext prismContext, OperationResultType
return new AssignmentEvaluationOpNode(prismContext, result, info, parent, traceInfo);
case ASSIGNMENT_SEGMENT_EVALUATION:
return new AssignmentSegmentEvaluationOpNode(prismContext, result, info, parent, traceInfo);
case POLICY_RULE_EVALUATION:
return new PolicyRuleEvaluationOpNode(prismContext, result, info, parent, traceInfo);
case POLICY_CONSTRAINT_EVALUATION:
return new PolicyConstraintEvaluationOpNode(prismContext, result, info, parent, traceInfo);
case FOCUS_REPOSITORY_LOAD:
return new FocusRepositoryLoadOpNode(prismContext, result, info, parent, traceInfo);
case FULL_PROJECTION_LOAD:
return new FullProjectionLoadOpNode(prismContext, result, info, parent, traceInfo);
}
}
return new OpNode(prismContext, result, info, parent, traceInfo);
Expand Down
Expand Up @@ -38,6 +38,8 @@ public List<OpNode> build(TracingOutputType tracingOutput) {
public List<OpNode> build(TracingOutputType tracingOutput, NameResolver nameResolver) {
List<OpNode> rv = new ArrayList<>();
addNode(null, rv, tracingOutput.getResult(), new TraceInfo(tracingOutput), nameResolver);

rv.forEach(OpNode::postProcessRecursive);
return rv;
}

Expand Down

0 comments on commit 7bfa6f2

Please sign in to comment.