generated from codeforamerica/form-flow-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filling in more fields after clarifications
- Loading branch information
Showing
6 changed files
with
89 additions
and
68 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/main/java/org/ladocuploader/app/preparers/ApplicantDetailsPreparer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.ladocuploader.app.preparers; | ||
|
||
import formflow.library.data.Submission; | ||
import formflow.library.pdf.PdfMap; | ||
import formflow.library.pdf.SingleField; | ||
import formflow.library.pdf.SubmissionField; | ||
import formflow.library.pdf.SubmissionFieldPreparer; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
import static org.ladocuploader.app.utils.SubmissionUtilities.EDUCATION_MAP; | ||
|
||
@Component | ||
public class ApplicantDetailsPreparer implements SubmissionFieldPreparer { | ||
|
||
@Override | ||
public Map<String, SubmissionField> prepareSubmissionFields(Submission submission, PdfMap pdfMap) { | ||
Map<String, SubmissionField> results = new HashMap<>(); | ||
|
||
Map<String, Object> inputData = submission.getInputData(); | ||
|
||
// Convert "who does this apply to" responses to a boolean indicator | ||
Map.of("students[]", "applicantStudentInd", | ||
"nonCitizens[]", "applicantNonCitizenInd", | ||
"homeless[]", "applicantHomelessInd") | ||
.forEach((key, value) -> { | ||
var inputs = (List<String>) inputData.getOrDefault(key, new ArrayList<>()); | ||
var ind = inputs != null && inputs.contains("you") ? "Yes" : "No"; | ||
results.put(value, new SingleField(value, ind, null)); | ||
}); | ||
|
||
// Format birthday | ||
var birthday = Stream.of("birthMonth", "birthDay", "birthYear") | ||
.map(inputData::get) | ||
.reduce((e, c) -> e + "/" + c) | ||
.get(); | ||
results.put("applicantBirthday", new SingleField("applicantBirthdayFormatted", (String) birthday, null)); | ||
|
||
var educationStatus = inputData.get("highestEducation"); | ||
results.put("highestEducation", new SingleField("highestEducationFormatted", EDUCATION_MAP.get(educationStatus), null)); | ||
|
||
return results; | ||
} | ||
} |
34 changes: 0 additions & 34 deletions
34
src/main/java/org/ladocuploader/app/preparers/ApplicantIndicatorsPreparer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.