Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/simulations'
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jan 28, 2023
2 parents 6632b11 + bd0dffe commit 4408989
Show file tree
Hide file tree
Showing 18 changed files with 535 additions and 344 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,6 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="domain" type="tns:SimulationObjectPredicateType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Domain of the metric. It denotes objects that should be considered by the metric.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<!--<xsd:element name="defaultDimension" type="xsd:QName" minOccurs="0" maxOccurs="unbounded">-->
<!-- <xsd:annotation>-->
<!-- <xsd:documentation>-->
Expand Down Expand Up @@ -272,7 +265,23 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="expression" type="tns:ExpressionType" minOccurs="0">
<xsd:element name="domain" type="tns:SimulationObjectPredicateType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Domain of the metric. It denotes objects that should be considered by the metric.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="selection" type="tns:SimulationObjectPredicateType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Determines whether the object is "selected" by the metric.

Default (if the value is computed): true if value greater than 0, false otherwise.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="valueExpression" type="tns:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
An expression providing the value for the metric.
Expand All @@ -282,6 +291,8 @@

Output:
- any number: the output

Default (if the expression is not present but selection criteria is): 1 if selected, 0 otherwise.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down Expand Up @@ -320,10 +331,17 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="selection" type="tns:SimulationObjectPredicateType" minOccurs="0">
<xsd:element name="domainRestriction" type="tns:SimulationObjectPredicateType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Denotes the "selection" object set. Relevant for some aggregation functions.
Restriction of the domain of original metric.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="selectionRestriction" type="tns:SimulationObjectPredicateType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Restriction of the "selection" predicate of original metric.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down Expand Up @@ -1068,6 +1086,13 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="selected" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
Is the object "selected" in regard to this metric?
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="value" type="xsd:decimal" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,5 @@ default PrismObject<O> getObjectOldOrCurrent() {
@NotNull ModelContext<?> getModelContext();

/** Returns OIDs of event tags determined for this focus/projection context. */
@NotNull Collection<String> getEventTags();
@NotNull Collection<String> getMatchingEventTags();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public interface ProcessedObject<O extends ObjectType> extends DebugDumpable {
@NotNull Class<O> getType();
@Nullable PolyStringType getName();
@NotNull ObjectProcessingStateType getState();
@NotNull Collection<String> getEventTags();
@NotNull Collection<String> getMatchingEventTags();
@Nullable Map<String, TagType> getEventTagsMap();

default boolean isAddition() {
Expand All @@ -65,8 +65,10 @@ default boolean isNoChange() {
O getAfter();
@Nullable ObjectDelta<O> getDelta();
O getAfterOrBefore();
boolean matches(SimulationObjectPredicateType predicate, Task task, OperationResult result)

boolean matches(@NotNull SimulationObjectPredicateType predicate, @NotNull Task task, @NotNull OperationResult result)
throws CommonException;
void resolveEventTags(OperationResult result);

interface Factory {
<O extends ObjectType> ProcessedObject<O> create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ public static ModelCommonBeans get() {
@Autowired public CacheConfigurationManager cacheConfigurationManager;
@Autowired public ModelService modelService;
@Autowired public ModelInteractionService modelInteractionService;
@Autowired public TagManager tagManager;
}
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,17 @@ public void setCount(int value) {
count = value;
}

@NotNull Collection<String> getEventTags() {
@NotNull Collection<String> getTriggeredEventTags() {
if (isTriggered()) {
return policyRuleBean.getTagRef().stream()
.map(AbstractReferencable::getOid)
.collect(Collectors.toSet());
return getAllEventTags();
} else {
return Set.of();
}
}

@NotNull Collection<String> getAllEventTags() {
return policyRuleBean.getTagRef().stream()
.map(AbstractReferencable::getOid)
.collect(Collectors.toSet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,12 @@ public void resolveTemporaryContainerIds(ObjectDelta<O> objectDelta) throws Sche

@Override
@NotNull
public Collection<String> getEventTags() {
return policyRulesContext.getEventTags();
public Collection<String> getMatchingEventTags() {
return policyRulesContext.getTriggeredEventTags();
}

public @NotNull Collection<String> getAllConsideredEventTags() {
return policyRulesContext.getAllConsideredEventTags();
}
//endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;

import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
Expand Down Expand Up @@ -129,7 +130,12 @@ public String debugDump(int indent) {

LensContext.dumpRules(sb, "Object policy rules", indent, getObjectPolicyRules());
sb.append("\n");
DebugUtil.debugDumpWithLabel(sb, "Event tags", getEventTags(), indent);

Set<String> allEventTags = getAllConsideredEventTags();
Set<String> triggeredEventTags = getTriggeredEventTags();
DebugUtil.debugDumpWithLabelLn(sb, "Triggered event tags", triggeredEventTags, indent);
DebugUtil.debugDumpWithLabel(
sb, "Other (non-triggered) event tags", Sets.difference(allEventTags, triggeredEventTags), indent);
return sb.toString();
}

Expand All @@ -149,9 +155,16 @@ void copyFrom(@NotNull PolicyRulesContext other) {
}

// TEMPORARY IMPLEMENTATION
@NotNull Collection<String> getEventTags() {
@NotNull Set<String> getTriggeredEventTags() {
return objectPolicyRules.stream()
.flatMap(rule -> rule.getTriggeredEventTags().stream())
.collect(Collectors.toSet());
}

// TEMPORARY IMPLEMENTATION
@NotNull Set<String> getAllConsideredEventTags() {
return objectPolicyRules.stream()
.flatMap(rule -> rule.getEventTags().stream())
.flatMap(rule -> rule.getAllEventTags().stream())
.collect(Collectors.toSet());
}
}

0 comments on commit 4408989

Please sign in to comment.