Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion sdk/src/main/java/com/reforge/sdk/config/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@ public class Match {
private final int rowIndex;
private final int conditionalValueIndex;
private final Optional<Integer> weightedValueIndex;
private final Optional<Long> envId;

public Match(
Prefab.ConfigValue configValue,
ConfigElement configElement,
List<EvaluatedCriterion> evaluatedCriterion,
int rowIndex,
int conditionalValueIndex,
Optional<Integer> weightedValueIndex
Optional<Integer> weightedValueIndex,
Optional<Long> envId
) {
this.configValue = configValue;
this.configElement = configElement;
this.evaluatedCriterion = evaluatedCriterion;
this.rowIndex = rowIndex;
this.conditionalValueIndex = conditionalValueIndex;
this.weightedValueIndex = weightedValueIndex;
this.envId = envId;
}

public int getRowIndex() {
Expand All @@ -42,6 +45,10 @@ public Optional<Integer> getWeightedValueIndex() {
return weightedValueIndex;
}

public Optional<Long> getEnvId() {
return envId;
}

public Prefab.ConfigValue getConfigValue() {
return configValue;
}
Expand Down Expand Up @@ -74,6 +81,7 @@ public String toString() {
.add("rowIndex", rowIndex)
.add("conditionalValueIndex", conditionalValueIndex)
.add("weightedValueIndex", weightedValueIndex)
.add("envId", envId)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ private Match reify(Match match, LookupContext lookupContext) {
match.getEvaluatedCriterion(),
match.getRowIndex(),
match.getConditionalValueIndex(),
match.getWeightedValueIndex()
match.getWeightedValueIndex(),
match.getEnvId()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ private Optional<Match> getMatch(
conditionalValueIndex,
lookupContext,
rowPropertiesStack,
configElement
configElement,
configRow
);

if (optionalMatch.isPresent()) {
Expand Down Expand Up @@ -145,7 +146,8 @@ private Optional<Match> evaluateConditionalValue(
int conditionalValueIndex,
LookupContext lookupContext,
Deque<Map<String, Prefab.ConfigValue>> rowProperties,
ConfigElement configElement
ConfigElement configElement,
Prefab.ConfigRow configRow
) {
List<EvaluatedCriterion> evaluatedCriteria = new ArrayList<>();
for (Prefab.Criterion criterion : conditionalValue.getCriteriaList()) {
Expand All @@ -167,7 +169,8 @@ private Optional<Match> evaluateConditionalValue(
conditionalValueIndex,
configElement,
lookupContext,
evaluatedCriteria
evaluatedCriteria,
configRow
)
);
}
Expand All @@ -181,8 +184,13 @@ private Match simplifyToMatch(
int conditionalValueIndex,
ConfigElement configElement,
LookupContext lookupContext,
List<EvaluatedCriterion> evaluatedCriteria
List<EvaluatedCriterion> evaluatedCriteria,
Prefab.ConfigRow configRow
) {
Optional<Long> envId = configRow.hasProjectEnvId()
? Optional.of(configRow.getProjectEnvId())
: Optional.empty();

if (selectedConditionalValue.getValue().hasWeightedValues()) {
WeightedValueEvaluator.Result result = weightedValueEvaluator.toResult(
selectedConditionalValue.getValue().getWeightedValues(),
Expand All @@ -195,7 +203,8 @@ private Match simplifyToMatch(
evaluatedCriteria,
(int) rowIndex,
conditionalValueIndex,
Optional.of(result.getIndex())
Optional.of(result.getIndex()),
envId
);
} else {
return new Match(
Expand All @@ -204,7 +213,8 @@ private Match simplifyToMatch(
evaluatedCriteria,
(int) rowIndex,
conditionalValueIndex,
Optional.empty()
Optional.empty(),
envId
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ Match match(Prefab.ConfigValue configValue, Prefab.Config config) {
Collections.emptyList(),
0,
0,
Optional.empty(),
Optional.empty()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void itAggregates() {
Collections.emptyList(),
0,
2,
Optional.empty(),
Optional.empty()
),
101
Expand All @@ -81,6 +82,7 @@ void itAggregates() {
Collections.emptyList(),
0,
2,
Optional.empty(),
Optional.empty()
),
102
Expand All @@ -93,6 +95,7 @@ void itAggregates() {
Collections.emptyList(),
0,
2,
Optional.empty(),
Optional.empty()
),
102
Expand All @@ -108,6 +111,7 @@ void itAggregates() {
Collections.emptyList(),
0,
3,
Optional.empty(),
Optional.empty()
),
107
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ private static void reportSomeMatches(TelemetryManager telemetryManager) {
Collections.emptyList(),
1,
2,
Optional.empty(),
Optional.empty()
),
new LookupContext(
Expand All @@ -379,6 +380,7 @@ private static void reportSomeMatches(TelemetryManager telemetryManager) {
Collections.emptyList(),
1,
2,
Optional.empty(),
Optional.empty()
),
new LookupContext(
Expand All @@ -400,6 +402,7 @@ private static void reportSomeMatches(TelemetryManager telemetryManager) {
Collections.emptyList(),
1,
2,
Optional.empty(),
Optional.empty()
),
new LookupContext(
Expand All @@ -418,6 +421,7 @@ private static void reportSomeMatches(TelemetryManager telemetryManager) {
Collections.emptyList(),
0,
0,
Optional.empty(),
Optional.empty()
),
new LookupContext(
Expand All @@ -436,6 +440,7 @@ private static void reportSomeMatches(TelemetryManager telemetryManager) {
Collections.emptyList(),
0,
0,
Optional.empty(),
Optional.empty()
),
new LookupContext(
Expand Down