applicant-facing-gdo/src/main/java/com/girlsdayout/applicationform/controller/MainController.java
@PostMapping(path="application/submit")
    public String addNewApplicant (@RequestParam String lName, @RequestParam String fName,
                                        @RequestParam String address, @RequestParam String city,
                                        @RequestParam String state, @RequestParam String zipCode,
                                        @RequestParam String phoneNumber, @RequestParam String dateOfBirth,
                                        @RequestParam String email, @RequestParam(value = "checkbox[]", required = false)int[] checkboxValue,
                                        @RequestParam String allergies, @RequestParam String medications,
                                        @RequestParam(required = false) String parentsCollege, @RequestParam(required = false) String militaryRelatives,
                                        @RequestParam(required = false) String militaryBranch, @RequestParam(required = false) String writeInSchool,
                                        @RequestParam(required = false) String eduLevel,
                                        @RequestParam String fallSchool, @RequestParam String risingGradeLevel,
                                        @RequestParam String collegeOfInterest, @RequestParam String shirtSize,
                                        @RequestParam String altParentFName, @RequestParam String altParentLName,
                                        @RequestParam String altParentEMail, @RequestParam String altParentAddress,
                                        @RequestParam String altParentCity, @RequestParam String altParentState,
                                        @RequestParam String altParentZipCode, @RequestParam String altParentPrimaryPhone,
                                        @RequestParam String altParentAltPhone, @RequestParam String priParentFName,
                                        @RequestParam String priParentEMail, @RequestParam String priParentAddress,
                                        @RequestParam String priParentCity, @RequestParam String priParentState,
                                        @RequestParam String priParentZipCode, @RequestParam String priParentPrimaryPhone,
                                        @RequestParam String priParentAltPhone, @RequestParam String priParentLName,
                                        @RequestParam String contactName, @RequestParam String relationship,
                                        @RequestParam String contactAddress, @RequestParam String contactCity,
                                        @RequestParam String contactState, @RequestParam String contactZipCode,
                                        @RequestParam String contactPrimaryPhone, @RequestParam String contactAltPhone) throws MessagingException {

        //creates new applicant object
        Applicant a = new Applicant();

        //setting all of the applicant's variables
        a.setfName(fName);
        a.setlName(lName);
        a.setEmail(email);
        a.setAddress(address);
        a.setCity(city);
        a.setState(state);
        a.setZipCode(zipCode);
        a.setPhoneNumber(phoneNumber);
        a.setDateOfBirth(dateOfBirth);
        a.setAge(dateOfBirth);
        a.setAllergies(allergies);
        a.setMedications(medications);

        if (parentsCollege != null){
            if (parentsCollege.equals("Yes")){
                a.setParentsCollege(parentsCollege + ": " + eduLevel);
            }
            else{
                a.setParentsCollege(parentsCollege);
            }
        }

        a.setMilitaryRelatives(militaryRelatives);
        a.setMilitaryBranch(militaryBranch);

        //current value of school when "other" is chosen in the school dropdown. Passed through fallSchool.
        String otherSchool = "Other (list in details column)";

        /*if passed fallSchool value = otherSchool AKA user chose other for school dropdown:
        *   change fallSchool to "Other: x" where x = writeInSchool (value entered in other school textbox).
        */
        if (fallSchool.equals(otherSchool)) {
            fallSchool = "Other: " + writeInSchool;
        }

        a.setFallSchool(fallSchool);
        a.setRisingGradeLevel(risingGradeLevel);
        a.setCollegeOfInterest(collegeOfInterest);
        a.setShirtSize(shirtSize);
        a.setRecordId(applicantRepository.findAll());
        a.setWaiverStatus("Not Submitted");
        a.setAppStatus(applicantRepository.findAll());
        a.setCampGroup();
        a.setDeniedReason();
        a.setApplicationNotes();
        a.setYearSubmitted();

        //setting applicant interest variables
        String scienceInt = "No";
        String techInt = "No";
        String engInt = "No";
        String mathInt = "No";

        if (checkboxValue != null){
            for (int i = 0; i < checkboxValue.length; i++){
                switch (checkboxValue[i]){
                    case 1:
                        scienceInt = "Yes";
                        break;
                    case 2:
                        techInt = "Yes";
                        break;
                    case 3:
                        engInt = "Yes";
                        break;
                    case 4:
                        mathInt = "Yes";
                        break;
                }
            }
        }


        a.setScienceInterest(scienceInt);
        a.setTechInterest(techInt);
        a.setEngInterest(engInt);
        a.setMathInterest(mathInt);
        //end of all applicant variables

        //setting all the parent's variables
        a.setPriParentFName(priParentFName);
        a.setPriParentLName(priParentLName);
        a.setPriParentEMail(priParentEMail);
        a.setPriParentAddress(priParentAddress);
        a.setPriParentCity(priParentCity);
        a.setPriParentState(priParentState);
        a.setPriParentZipCode(priParentZipCode);
        a.setPriParentPrimaryPhone(priParentPrimaryPhone);
        a.setPriParentAltPhone(priParentAltPhone);
        a.setAltParentFName(altParentFName);
        a.setAltParentLName(altParentLName);
        a.setAltParentEMail(altParentEMail);
        a.setAltParentAddress(altParentAddress);
        a.setAltParentCity(altParentCity);
        a.setAltParentState(altParentState);
        a.setAltParentZipCode(altParentZipCode);
        a.setAltParentPrimaryPhone(altParentPrimaryPhone);
        a.setAltParentAltPhone(altParentAltPhone);
        //end of all parent variables

        //setting all the emergency contact variables
        a.setContactName(contactName);
        a.setRelationship(relationship);
        a.setContactAddress(contactAddress);
        a.setContactCity(contactCity);
        a.setContactState(contactState);
        a.setContactZipCode(contactZipCode);
        a.setContactPrimaryPhone(contactPrimaryPhone);
        a.setContactAltPhone(contactAltPhone);
        //end of em contact variables

        //setting waiver variables to empty strings
        a.setBoschWaiver("");
        a.setConsentWaiver("");
        a.setCofcWaiver("");

        //saves the applicant object to the database
        applicantRepository.save(a);

        // sends confirmation e-mail to applicant after application data is sent to the db
        notificationService.emailApplicant(a);

        //passes all admins, type string, and the applicant object to the method that e-mails approvers of a new application
        notificationService.emailApprovers(adminRepository.findAll(), "application", a);
 
        //the return statement redirects to the application/submit/recordID page.
        return "redirect:/application/submit/" + a.getRecordId();

    }
//method that gets all information from user input and saves it to the database
method that gets all information from user input and saves it to the database
method that gets all information from user input and saves it to the database
@PostMapping(path="application/submit")
    public String addNewApplicant (@RequestParam String lName, @RequestParam String fName,
                                        @RequestParam String address, @RequestParam String city,
                                        @RequestParam String state, @RequestParam String zipCode,
                                        @RequestParam String phoneNumber, @RequestParam String dateOfBirth,
                                        @RequestParam String email, @RequestParam(value = "checkbox[]", required = false)int[] checkboxValue,
                                        @RequestParam String allergies, @RequestParam String medications,
                                        @RequestParam(required = false) String parentsCollege, @RequestParam(required = false) String militaryRelatives,
                                        @RequestParam(required = false) String militaryBranch, @RequestParam(required = false) String writeInSchool,
                                        @RequestParam(required = false) String eduLevel,
                                        @RequestParam String fallSchool, @RequestParam String risingGradeLevel,
                                        @RequestParam String collegeOfInterest, @RequestParam String shirtSize,
                                        @RequestParam String altParentFName, @RequestParam String altParentLName,
                                        @RequestParam String altParentEMail, @RequestParam String altParentAddress,
                                        @RequestParam String altParentCity, @RequestParam String altParentState,
                                        @RequestParam String altParentZipCode, @RequestParam String altParentPrimaryPhone,
                                        @RequestParam String altParentAltPhone, @RequestParam String priParentFName,
                                        @RequestParam String priParentEMail, @RequestParam String priParentAddress,
                                        @RequestParam String priParentCity, @RequestParam String priParentState,
                                        @RequestParam String priParentZipCode, @RequestParam String priParentPrimaryPhone,
                                        @RequestParam String priParentAltPhone, @RequestParam String priParentLName,
                                        @RequestParam String contactName, @RequestParam String relationship,
                                        @RequestParam String contactAddress, @RequestParam String contactCity,
                                        @RequestParam String contactState, @RequestParam String contactZipCode,
                                        @RequestParam String contactPrimaryPhone, @RequestParam String contactAltPhone) throws MessagingException {
        Applicant a = new Applicant();
        a.setfName(fName);
        a.setlName(lName);
        a.setEmail(email);
        a.setAddress(address);
        a.setCity(city);
        a.setState(state);
        a.setZipCode(zipCode);
        a.setPhoneNumber(phoneNumber);
        a.setDateOfBirth(dateOfBirth);
        a.setAge(dateOfBirth);
        a.setAllergies(allergies);
        a.setMedications(medications);
        if (parentsCollege != null){
            if (parentsCollege.equals("Yes")){
                a.setParentsCollege(parentsCollege + ": " + eduLevel);
            }
            else{
                a.setParentsCollege(parentsCollege);
            }
        }
        a.setMilitaryRelatives(militaryRelatives);
        a.setMilitaryBranch(militaryBranch);
        String otherSchool = "Other (list in details column)";
        /*if passed fallSchool value = otherSchool AKA user chose other for school dropdown:
        *   change fallSchool to "Other: x" where x = writeInSchool (value entered in other school textbox).
        */
        if (fallSchool.equals(otherSchool)) {
            fallSchool = "Other: " + writeInSchool;
        }
        a.setFallSchool(fallSchool);
        a.setRisingGradeLevel(risingGradeLevel);
        a.setCollegeOfInterest(collegeOfInterest);
        a.setShirtSize(shirtSize);
        a.setRecordId(applicantRepository.findAll());
        a.setWaiverStatus("Not Submitted");
        a.setAppStatus(applicantRepository.findAll());
        a.setCampGroup();
        a.setDeniedReason();
        a.setApplicationNotes();
        a.setYearSubmitted();
        String scienceInt = "No";
        String techInt = "No";
        String engInt = "No";
        String mathInt = "No";
        if (checkboxValue != null){
            for (int i = 0; i < checkboxValue.length; i++){
                switch (checkboxValue[i]){
                    case 1:
                        scienceInt = "Yes";
                        break;
                    case 2:
                        techInt = "Yes";
                        break;
                    case 3:
                        engInt = "Yes";
                        break;
                    case 4:
                        mathInt = "Yes";
                        break;
                }
            }
        }
        a.setScienceInterest(scienceInt);
        a.setTechInterest(techInt);
        a.setEngInterest(engInt);
        a.setMathInterest(mathInt);
        a.setPriParentFName(priParentFName);
        a.setPriParentLName(priParentLName);
        a.setPriParentEMail(priParentEMail);
        a.setPriParentAddress(priParentAddress);
        a.setPriParentCity(priParentCity);
        a.setPriParentState(priParentState);
        a.setPriParentZipCode(priParentZipCode);
        a.setPriParentPrimaryPhone(priParentPrimaryPhone);
        a.setPriParentAltPhone(priParentAltPhone);
        a.setAltParentFName(altParentFName);
        a.setAltParentLName(altParentLName);
        a.setAltParentEMail(altParentEMail);
        a.setAltParentAddress(altParentAddress);
        a.setAltParentCity(altParentCity);
        a.setAltParentState(altParentState);
        a.setAltParentZipCode(altParentZipCode);
        a.setAltParentPrimaryPhone(altParentPrimaryPhone);
        a.setAltParentAltPhone(altParentAltPhone);
        a.setContactName(contactName);
        a.setRelationship(relationship);
        a.setContactAddress(contactAddress);
        a.setContactCity(contactCity);
        a.setContactState(contactState);
        a.setContactZipCode(contactZipCode);
        a.setContactPrimaryPhone(contactPrimaryPhone);
        a.setContactAltPhone(contactAltPhone);
        a.setBoschWaiver("");
        a.setConsentWaiver("");
        a.setCofcWaiver("");
        applicantRepository.save(a);
        notificationService.emailApplicant(a);
        notificationService.emailApprovers(adminRepository.findAll(), "application", a);
        return "redirect:/application/submit/" + a.getRecordId();
    }
@ PostMapping ( path = "application/submit" ) public String addNewApplicant ( @ RequestParam String lName , @ RequestParam String fName , @ RequestParam String address , @ RequestParam String city , @ RequestParam String state , @ RequestParam String zipCode , @ RequestParam String phoneNumber , @ RequestParam String dateOfBirth , @ RequestParam String email , @ RequestParam ( value = "checkbox[]" , required = false ) int [ ] checkboxValue , @ RequestParam String allergies , @ RequestParam String medications , @ RequestParam ( required = false ) String parentsCollege , @ RequestParam ( required = false ) String militaryRelatives , @ RequestParam ( required = false ) String militaryBranch , @ RequestParam ( required = false ) String writeInSchool , @ RequestParam ( required = false ) String eduLevel , @ RequestParam String fallSchool , @ RequestParam String risingGradeLevel , @ RequestParam String collegeOfInterest , @ RequestParam String shirtSize , @ RequestParam String altParentFName , @ RequestParam String altParentLName , @ RequestParam String altParentEMail , @ RequestParam String altParentAddress , @ RequestParam String altParentCity , @ RequestParam String altParentState , @ RequestParam String altParentZipCode , @ RequestParam String altParentPrimaryPhone , @ RequestParam String altParentAltPhone , @ RequestParam String priParentFName , @ RequestParam String priParentEMail , @ RequestParam String priParentAddress , @ RequestParam String priParentCity , @ RequestParam String priParentState , @ RequestParam String priParentZipCode , @ RequestParam String priParentPrimaryPhone , @ RequestParam String priParentAltPhone , @ RequestParam String priParentLName , @ RequestParam String contactName , @ RequestParam String relationship , @ RequestParam String contactAddress , @ RequestParam String contactCity , @ RequestParam String contactState , @ RequestParam String contactZipCode , @ RequestParam String contactPrimaryPhone , @ RequestParam String contactAltPhone ) throws MessagingException { Applicant a = new Applicant ( ) ; a . setfName ( fName ) ; a . setlName ( lName ) ; a . setEmail ( email ) ; a . setAddress ( address ) ; a . setCity ( city ) ; a . setState ( state ) ; a . setZipCode ( zipCode ) ; a . setPhoneNumber ( phoneNumber ) ; a . setDateOfBirth ( dateOfBirth ) ; a . setAge ( dateOfBirth ) ; a . setAllergies ( allergies ) ; a . setMedications ( medications ) ; if ( parentsCollege != null ) { if ( parentsCollege . equals ( "Yes" ) ) { a . setParentsCollege ( parentsCollege + ": " + eduLevel ) ; } else { a . setParentsCollege ( parentsCollege ) ; } } a . setMilitaryRelatives ( militaryRelatives ) ; a . setMilitaryBranch ( militaryBranch ) ; String otherSchool = "Other (list in details column)" ; /*if passed fallSchool value = otherSchool AKA user chose other for school dropdown:
        *   change fallSchool to "Other: x" where x = writeInSchool (value entered in other school textbox).
        */ if ( fallSchool . equals ( otherSchool ) ) { fallSchool = "Other: " + writeInSchool ; } a . setFallSchool ( fallSchool ) ; a . setRisingGradeLevel ( risingGradeLevel ) ; a . setCollegeOfInterest ( collegeOfInterest ) ; a . setShirtSize ( shirtSize ) ; a . setRecordId ( applicantRepository . findAll ( ) ) ; a . setWaiverStatus ( "Not Submitted" ) ; a . setAppStatus ( applicantRepository . findAll ( ) ) ; a . setCampGroup ( ) ; a . setDeniedReason ( ) ; a . setApplicationNotes ( ) ; a . setYearSubmitted ( ) ; String scienceInt = "No" ; String techInt = "No" ; String engInt = "No" ; String mathInt = "No" ; if ( checkboxValue != null ) { for ( int i = 0 ; i < checkboxValue . length ; i ++ ) { switch ( checkboxValue [ i ] ) { case 1 : scienceInt = "Yes" ; break ; case 2 : techInt = "Yes" ; break ; case 3 : engInt = "Yes" ; break ; case 4 : mathInt = "Yes" ; break ; } } } a . setScienceInterest ( scienceInt ) ; a . setTechInterest ( techInt ) ; a . setEngInterest ( engInt ) ; a . setMathInterest ( mathInt ) ; a . setPriParentFName ( priParentFName ) ; a . setPriParentLName ( priParentLName ) ; a . setPriParentEMail ( priParentEMail ) ; a . setPriParentAddress ( priParentAddress ) ; a . setPriParentCity ( priParentCity ) ; a . setPriParentState ( priParentState ) ; a . setPriParentZipCode ( priParentZipCode ) ; a . setPriParentPrimaryPhone ( priParentPrimaryPhone ) ; a . setPriParentAltPhone ( priParentAltPhone ) ; a . setAltParentFName ( altParentFName ) ; a . setAltParentLName ( altParentLName ) ; a . setAltParentEMail ( altParentEMail ) ; a . setAltParentAddress ( altParentAddress ) ; a . setAltParentCity ( altParentCity ) ; a . setAltParentState ( altParentState ) ; a . setAltParentZipCode ( altParentZipCode ) ; a . setAltParentPrimaryPhone ( altParentPrimaryPhone ) ; a . setAltParentAltPhone ( altParentAltPhone ) ; a . setContactName ( contactName ) ; a . setRelationship ( relationship ) ; a . setContactAddress ( contactAddress ) ; a . setContactCity ( contactCity ) ; a . setContactState ( contactState ) ; a . setContactZipCode ( contactZipCode ) ; a . setContactPrimaryPhone ( contactPrimaryPhone ) ; a . setContactAltPhone ( contactAltPhone ) ; a . setBoschWaiver ( "" ) ; a . setConsentWaiver ( "" ) ; a . setCofcWaiver ( "" ) ; applicantRepository . save ( a ) ; notificationService . emailApplicant ( a ) ; notificationService . emailApprovers ( adminRepository . findAll ( ) , "application" , a ) ; return "redirect:/application/submit/" + a . getRecordId ( ) ; }
method that gets all information from user input and saves it to the database
method that gets all information from user input and saves it to the database
//creates new applicant object //setting all of the applicant's variables //current value of school when "other" is chosen in the school dropdown. Passed through fallSchool. //setting applicant interest variables //end of all applicant variables //setting all the parent's variables //end of all parent variables //setting all the emergency contact variables //end of em contact variables //setting waiver variables to empty strings //saves the applicant object to the database // sends confirmation e-mail to applicant after application data is sent to the db //passes all admins, type string, and the applicant object to the method that e-mails approvers of a new application //the return statement redirects to the application/submit/recordID page.