Skip to content

Commit

Permalink
Merge master into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 28, 2021
2 parents 5a205f8 + 34d3500 commit 8af5cb8
Show file tree
Hide file tree
Showing 13 changed files with 365 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ ModelAndView getPage(
}
} else {
pageToRender = "formPage";
model.put("pageDatasources", pagesData.getDatasourcePagesBy(pageWorkflow.getDatasources()));
model.put("pageDatasources", pagesData.getDatasourcePagesBy(pageWorkflow.getDatasources()).mergeDatasourcePages(pagesData.getDatasourceGroupBy(pageWorkflow.getDatasources(), applicationData.getSubworkflows())));
model.put("data", pagesData.getPageDataOrDefault(pageTemplate.getName(), pageConfiguration));
}
return new ModelAndView(pageToRender, model);
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/codeforamerica/shiba/pages/PageUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.codeforamerica.shiba.pages;

import org.codeforamerica.shiba.pages.data.*;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
Expand All @@ -8,6 +10,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;


public class PageUtils {
private static final String WEB_INPUT_ARRAY_TOKEN = "[]";

Expand Down Expand Up @@ -46,4 +49,16 @@ public static List<String> householdMemberSort(Collection<String> householdMembe

return Stream.concat(applicant, nonApplicantHouseholdMembers).collect(Collectors.toList());
}

public static Boolean isCCAPEligible(DatasourcePages datasourcePages) {
List<String> applicantPrograms = datasourcePages.get("choosePrograms").get("programs").getValue();
boolean applicantHasCCAP = applicantPrograms.contains("CCAP");
boolean hasHousehold = !datasourcePages.get("householdMemberInfo").isEmpty();
boolean householdHasCCAP = false;
if (hasHousehold) {
householdHasCCAP = datasourcePages.get("householdMemberInfo").get("programs").getValue().stream().anyMatch(iteration ->
iteration.contains("CCAP"));
}
return applicantHasCCAP || householdHasCCAP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ public Boolean satisfies(CompositeCondition compositeCondition) {
case OR -> conditionStream.anyMatch(this::satisfies);
};
}

public DatasourcePages mergeDatasourcePages(DatasourcePages datasourcePages) {
datasourcePages.forEach((key, value) -> {
PageData current = this.get(key);
if(current != null)
current.mergeInputDataValues(value);
});
return this;
}
}
14 changes: 14 additions & 0 deletions src/main/java/org/codeforamerica/shiba/pages/data/PagesData.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ public DatasourcePages getDatasourcePagesBy(List<PageDatasource> datasources) {
.collect(toMap(Entry::getKey, Entry::getValue)));
}

public DatasourcePages getDatasourceGroupBy(List<PageDatasource> datasources, Subworkflows subworkflows) {
Map<String, PageData> pages = new HashMap<>();
datasources.stream()
.filter(datasource -> datasource.getGroupName() != null && subworkflows.containsKey(datasource.getGroupName()))
.forEach(datasource -> {
PageData value = new PageData();
subworkflows.get(datasource.getGroupName()).stream()
.map(iteration -> iteration.getPagesData().getPage(datasource.getPageName()))
.forEach(value::mergeInputDataValues);
pages.put(datasource.getPageName(), value);
});
return new DatasourcePages(pages);
}

public List<String> safeGetPageInputValue(String pageName, String inputName) {
return Optional.ofNullable(get(pageName))
.flatMap(pageData -> Optional.ofNullable(pageData.get(inputName)))
Expand Down
18 changes: 6 additions & 12 deletions src/main/resources/dev-pages-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -928,12 +928,6 @@ pageDefinitions:
type: YES_NO
- &expeditedDetermination
name: expeditedDetermination
- &importantToKnow
name: importantToKnow
pageTitle:
value: important-to-know.title
headerKey:
value: important-to-know.important-stuff-to-know-about
- &legalStuff
name: legalStuff
pageTitle:
Expand Down Expand Up @@ -2383,7 +2377,7 @@ workflow:
nextPages:
- pageName: doYouLiveAloneExpedited
flow: EXPEDITED
- pageName: importantToKnow
- pageName: legalStuff
flow: MINIMUM
doYouLiveAloneExpedited:
pageConfiguration: *doYouLiveAlone
Expand Down Expand Up @@ -2446,19 +2440,19 @@ workflow:
expeditedDetermination:
pageConfiguration: *expeditedDetermination
nextPages:
- pageName: importantToKnow
- pageName: legalStuff
additionalInfo:
pageConfiguration: *additionalInfo
nextPages:
- pageName: importantToKnow
importantToKnow:
pageConfiguration: *importantToKnow
nextPages:
- pageName: legalStuff
legalStuff:
pageConfiguration: *legalStuff
nextPages:
- pageName: signThisApplication
datasources:
- pageName: choosePrograms
- groupName: household
pageName: householdMemberInfo
signThisApplication:
pageConfiguration: *signThisApplication
nextPages:
Expand Down
Loading

0 comments on commit 8af5cb8

Please sign in to comment.