Skip to content

Commit 6168edf

Browse files
Pull from WORKING_CUSTOM_CHECK_COLLECTION until Check Publishing is finalized.
1 parent a09b6e5 commit 6168edf

File tree

5 files changed

+53
-54
lines changed

5 files changed

+53
-54
lines changed

builder-api/src/main/java/org/acme/controller/DecisionResource.java

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.acme.auth.AuthUtils;
1212
import org.acme.enums.OptionalBoolean;
1313
import org.acme.model.domain.Benefit;
14+
import org.acme.model.domain.CheckConfig;
1415
import org.acme.model.domain.EligibilityCheck;
1516
import org.acme.model.domain.Screener;
1617
import org.acme.persistence.EligibilityCheckRepository;
@@ -126,50 +127,48 @@ private Map<String, Object> evaluateBenefit(Benefit benefit, Map<String, Object>
126127
List<OptionalBoolean> checkResultsList = new ArrayList<>();
127128
Map<String, Object> checkResults = new HashMap<>();
128129

129-
Map<String, Object> result = new HashMap<>();
130-
return result;
131-
//TODO: update implementation here
132-
// for (EligibilityCheck check : checks) {
133-
// Optional<CheckConfig> matchingCheckConfig = benefit.getChecks().stream().filter(
134-
// checkConfig -> checkConfig.getCheckId().equals(check.getId())
135-
// ).findFirst();
136-
// if (matchingCheckConfig.isEmpty()) {
137-
// throw new Exception("Could not find CheckConfig for check " + check.getId());
138-
// }
139-
//
140-
// String dmnFilepath = storageService.getCheckDmnModelPath(
141-
// check.getModule(), check.getId(), check.getVersion()
142-
// );
143-
// String dmnModelName = check.getId();
144-
//
145-
// OptionalBoolean result = dmnService.evaluateSimpleDmn(
146-
// dmnFilepath, dmnModelName, inputData, matchingCheckConfig.get().getParameters()
147-
// );
148-
// checkResultsList.add(result);
149-
// checkResults.put(check.getId(), Map.of("name", check.getName(), "result", result));
150-
// }
151-
//
152-
// // Determine overall Benefit result
153-
// Boolean allChecksTrue = checkResultsList.stream().allMatch(result -> result == OptionalBoolean.TRUE);
154-
// Boolean anyChecksFalse = checkResultsList.stream().anyMatch(result -> result == OptionalBoolean.FALSE);
155-
// Log.info("All True: " + allChecksTrue + " Any False: " + anyChecksFalse);
156-
//
157-
// OptionalBoolean benefitResult;
158-
// if (allChecksTrue) {
159-
// benefitResult = OptionalBoolean.TRUE;
160-
// } else if (anyChecksFalse) {
161-
// benefitResult = OptionalBoolean.FALSE;
162-
// } else {
163-
// benefitResult = OptionalBoolean.UNABLE_TO_DETERMINE;
164-
// }
165-
//
166-
// return new HashMap<String, Object>(
167-
// Map.of(
168-
// "name", benefit.getName(),
169-
// "result", benefitResult,
170-
// "check_results", checkResults
171-
// )
172-
// );
130+
// TODO: update implementation here
131+
for (EligibilityCheck check : checks) {
132+
Optional<CheckConfig> matchingCheckConfig = benefit.getChecks().stream().filter(
133+
checkConfig -> checkConfig.getCheckId().equals(check.getId())
134+
).findFirst();
135+
if (matchingCheckConfig.isEmpty()) {
136+
throw new Exception("Could not find CheckConfig for check " + check.getId());
137+
}
138+
139+
String dmnFilepath = storageService.getCheckDmnModelPath(
140+
check.getOwnerId(), check.getId()
141+
);
142+
String dmnModelName = check.getId();
143+
144+
OptionalBoolean result = dmnService.evaluateSimpleDmn(
145+
dmnFilepath, dmnModelName, inputData, matchingCheckConfig.get().getParameters()
146+
);
147+
checkResultsList.add(result);
148+
checkResults.put(check.getId(), Map.of("name", check.getName(), "result", result));
149+
}
150+
151+
// Determine overall Benefit result
152+
Boolean allChecksTrue = checkResultsList.stream().allMatch(result -> result == OptionalBoolean.TRUE);
153+
Boolean anyChecksFalse = checkResultsList.stream().anyMatch(result -> result == OptionalBoolean.FALSE);
154+
Log.info("All True: " + allChecksTrue + " Any False: " + anyChecksFalse);
155+
156+
OptionalBoolean benefitResult;
157+
if (allChecksTrue) {
158+
benefitResult = OptionalBoolean.TRUE;
159+
} else if (anyChecksFalse) {
160+
benefitResult = OptionalBoolean.FALSE;
161+
} else {
162+
benefitResult = OptionalBoolean.UNABLE_TO_DETERMINE;
163+
}
164+
165+
return new HashMap<String, Object>(
166+
Map.of(
167+
"name", benefit.getName(),
168+
"result", benefitResult,
169+
"check_results", checkResults
170+
)
171+
);
173172
}
174173
}
175174

builder-api/src/main/java/org/acme/persistence/GoogleStorageService.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,6 @@ public String getCheckDmnModelPath(String userId, String checkId){
144144
return "check/" + userId + "/" + checkId + ".dmn";
145145
}
146146

147-
@Override
148-
public String getCheckDmnModelPath(String userId, String module, String checkId, Integer version){
149-
return "check/" + userId + "/" + module + "/" + checkId + "/" + version.toString() + "/" + checkId + ".dmn";
150-
}
151-
152147
@Override
153148
public Map<String, Object> getFormSchemaFromStorage(String filePath) {
154149
try {

builder-api/src/main/java/org/acme/persistence/StorageService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public interface StorageService {
2525

2626
String getCheckDmnModelPath(String userId, String checkId);
2727

28-
String getCheckDmnModelPath(String userId, String module, String checkId, Integer version);
29-
3028
Map<String, Object> getFormSchemaFromStorage(String filePath);
3129

3230
void updatePublishedFormSchemaArtifact(String screenerId, String publishedScreenerId) throws Exception;

builder-api/src/main/java/org/acme/persistence/impl/EligibilityCheckRepositoryImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ public Optional<EligibilityCheck> getPublicCheck(String checkId){
5050
public List<EligibilityCheck> getChecksInBenefit(Benefit benefit){
5151
List<String> checkIds = benefit.getChecks().stream().map(checkConfig -> checkConfig.getCheckId()).toList();
5252
List<Map<String, Object>> customCheckMaps = FirestoreUtils.getFirestoreDocsByIds(
53-
CollectionNames.PUBLISHED_CUSTOM_CHECK_COLLECTION, checkIds);
53+
CollectionNames.WORKING_CUSTOM_CHECK_COLLECTION, checkIds);
54+
55+
// TODO: Replace with PUBLISHED_CUSTOM_CHECK_COLLECTION after implementing published checks
56+
// List<Map<String, Object>> customCheckMaps = FirestoreUtils.getFirestoreDocsByIds(
57+
// CollectionNames.PUBLISHED_CUSTOM_CHECK_COLLECTION, checkIds);
5458

5559
List<Map<String, Object>> publicCheckMaps = FirestoreUtils.getFirestoreDocsByIds(
5660
CollectionNames.PUBLIC_CHECK_COLLECTION, checkIds);
@@ -96,7 +100,7 @@ private Optional<EligibilityCheck> getCustomCheck(String userId, String checkId,
96100
ObjectMapper mapper = new ObjectMapper();
97101
EligibilityCheck check = mapper.convertValue(data, EligibilityCheck.class);
98102

99-
String dmnPath = storageService.getCheckDmnModelPath(userId, check.getModule(), checkId, check.getVersion());
103+
String dmnPath = storageService.getCheckDmnModelPath(userId, checkId);
100104
Optional<String> dmnModel = storageService.getStringFromStorage(dmnPath);
101105
dmnModel.ifPresent(check::setDmnModel);
102106

builder-api/src/main/java/org/acme/persistence/PublishedScreenerRepositoryImpl.java renamed to builder-api/src/main/java/org/acme/persistence/impl/PublishedScreenerRepositoryImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.acme.persistence;
1+
package org.acme.persistence.impl;
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
44
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -7,6 +7,9 @@
77
import org.acme.constants.CollectionNames;
88
import org.acme.model.domain.Benefit;
99
import org.acme.model.domain.Screener;
10+
import org.acme.persistence.FirestoreUtils;
11+
import org.acme.persistence.PublishedScreenerRepository;
12+
import org.acme.persistence.StorageService;
1013

1114
import java.util.List;
1215
import java.util.Map;

0 commit comments

Comments
 (0)