-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement preparer for applicant education schedule
- Loading branch information
Shawn Tabai
committed
May 9, 2024
1 parent
fd644e3
commit c809fa2
Showing
4 changed files
with
195 additions
and
3 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/main/java/org/ilgcc/app/pdf/ApplicantEducationSchedulePreparer.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,54 @@ | ||
package org.ilgcc.app.pdf; | ||
|
||
import formflow.library.data.Submission; | ||
import formflow.library.pdf.PdfMap; | ||
import formflow.library.pdf.SubmissionField; | ||
import formflow.library.pdf.SubmissionFieldPreparer; | ||
import org.ilgcc.app.utils.DayOfWeekOption; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.format.DateTimeFormatter; | ||
import java.util.*; | ||
|
||
import static org.ilgcc.app.utils.SubmissionUtilities.*; | ||
|
||
@Component | ||
public class ApplicantEducationSchedulePreparer implements SubmissionFieldPreparer { | ||
private final DateTimeFormatter CLOCK_TIME_OF_AM_PM = DateTimeFormatter.ofPattern("hh:mm"); | ||
private final DateTimeFormatter AM_PM_OF_DAY = DateTimeFormatter.ofPattern("a"); | ||
|
||
@Override | ||
public Map<String, SubmissionField> prepareSubmissionFields(Submission submission, PdfMap pdfMap) { | ||
var results = new HashMap<String, SubmissionField>(); | ||
|
||
Optional<HourlySchedule> activitiesClassSchedule = | ||
getHourlySchedule(submission, "activitiesClass", "weeklySchedule[]"); | ||
if (activitiesClassSchedule.isPresent()) { | ||
var dayMap = activitiesClassSchedule.get().toDayMap(); | ||
for (var day : DayOfWeekOption.values()) { | ||
var schedule = dayMap.get(day); | ||
if (schedule == null) { | ||
continue; | ||
} | ||
String fieldPrefix = "applicantEducationSchedule" + day.name(); | ||
putSingleFieldResult( | ||
results, | ||
fieldPrefix + "Start", | ||
schedule.startTime().format(CLOCK_TIME_OF_AM_PM)); | ||
putSingleFieldResult( | ||
results, | ||
fieldPrefix + "StartAmPm", | ||
schedule.startTime().format(AM_PM_OF_DAY)); | ||
putSingleFieldResult( | ||
results, | ||
fieldPrefix + "End", | ||
schedule.endTime().format(CLOCK_TIME_OF_AM_PM)); | ||
putSingleFieldResult( | ||
results, | ||
fieldPrefix + "EndAmPm", | ||
schedule.endTime().format(AM_PM_OF_DAY)); | ||
} | ||
} | ||
return results; | ||
} | ||
} |
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.