Calendar today = Calendar.getInstance();
int currentYear = today.get(Calendar.YEAR);
int applicantBirthYear;
if(this.academicYear == null || this.academicYear.getAcademicYearId()==null)
throw new BusinessRuleException("The academic year cannot be empty/null");
EsimsUtils.validateStrings(this.formNumber,32);
if(this.formIssuedOn == null)
throw new BusinessRuleException("The date of issuance of the form cannot be null");
if(this.formFilledOn == null)
throw new BusinessRuleException("The date of issuance of the form cannot be null");
if(this.formReceivedOn == null)
throw new BusinessRuleException("The date of receving the form cannot be null");
/*moved the date validations to the UI ot prevent hte data migration tool from failing.
*the data migration toll will be handling historical data, so we should be able to
* provide dates in the previous periods also
*/
EsimsUtils.validateStrings(this.firstName, 32);
EsimsUtils.validateStrings(this.lastName, 32);
if(this.dateOfBirth == null)
throw new BusinessRuleException("The date of birth of the applicant cannot be empty");
EsimsUtils.validateStrings(this.placeOfBirth, 32);
if(StringUtils.isEmpty(this.gender))
throw new BusinessRuleException("The gender of the applicant cannot be empty/null");
if(this.gender.length() > 1)
throw new BusinessRuleException("The gender of the applicant cannot exced 1 charcter");
if(! (this.gender.equalsIgnoreCase("m")|| this.gender.equalsIgnoreCase("f")) )
throw new BusinessRuleException("The gender of the applicant can be only M/F");
EsimsUtils.validateStrings(nationality, 32);
EsimsUtils.validateStrings(motherTounge, 32);
EsimsUtils.validateStrings(religion, 32);
EsimsUtils.validateNullableStrings(caste, 32);
EsimsUtils.validateNullableStrings(subcaste, 32);
if(this.scheduledCasteOrTribe ==null)
throw new BusinessRuleException("You must specify if the applicant is a scheduled cast or not");
if(this.otherBackwardCaste ==null)
throw new BusinessRuleException("You must specify if the applicant is an OBC candidate or not");
if( (this.scheduledCasteOrTribe == Boolean.TRUE && this.otherBackwardCaste == Boolean.TRUE ) )
throw new BusinessRuleException("A candidate cant be SCST and OBC at the same time");
EsimsUtils.validateStrings(this.fatherFirstName, 32);
EsimsUtils.validateNullableStrings(this.fatherMiddleName, 32);
EsimsUtils.validateStrings(this.fatherLastName, 32);
EsimsUtils.validateStrings(this.motherFirstName, 32);
EsimsUtils.validateNullableStrings(this.motherMiddleName, 32);
EsimsUtils.validateStrings(this.motherLastName, 32);
EsimsUtils.validateStrings(this.permanentHouseNameOrNumber, 32);
EsimsUtils.validateStrings(this.motherLastName, 32);
EsimsUtils.validateStrings(this.permanentStreet, 32);
EsimsUtils.validateStrings(this.permanentVillageOrTownOrCity, 32);
EsimsUtils.validateStrings(this.permanentState, 32);
EsimsUtils.validateStrings(this.permanentPinCode, 6);
EsimsUtils.validateNullableStrings(this.permanentPhoneNumber, 15);
if( (grossHouseHoldIncome == null || grossHouseHoldIncome.floatValue()<= 0.0f) )
throw new BusinessRuleException("The Gross house hold income cannot be null , negative or 0");
if(belowPovertyLine == null)
throw new BusinessRuleException("It must be indicated if the applicant is below the poverty line or not");
EsimsUtils.validateNullableStrings(this.previousSchoolIfAny, 64);
}