Package net.sf.esims.exception

Examples of net.sf.esims.exception.BusinessRuleException


  //enforces all the mandatory conditions
  private void enforceBusinessRules(){
    EsimsUtils.validateStrings(this.schoolName,64);
    EsimsUtils.validateStrings(this.schoolCode,3);
    if(schoolCode.length()<3)
      throw new BusinessRuleException("The school code must be 3 characters in length");
    EsimsUtils.validateStrings(this.addressLine1,64);
    EsimsUtils.validateStrings(this.addressLine2,64);
    EsimsUtils.validateNullableStrings(this.addressLine3,64);
   
    EsimsUtils.validateStrings(this.district,32);
    EsimsUtils.validateStrings(this.state,32);
   
    //can be only India
    EsimsUtils.validateStrings(this.country,5);
    EsimsUtils.validateStrings(this.pincode, 6);
    EsimsUtils.validateStrings(this.phone1, 10);
      if(! this.phone1.matches("[0-9]*"))
        throw new BusinessRuleException("Phone no: can be only numbers");
    EsimsUtils.validateNullableStrings(this.phone2, 10);
    if(this.phone2 !=null)
      if (! this.phone2.matches("[0-9]*"))
        throw new BusinessRuleException("Phone no: can be only numbers");
    EsimsUtils.validateNullableStrings(this.phone3, 10);
    if (this.phone3 !=null)
        if (! this.phone3.matches("[0-9]*"))
        throw new BusinessRuleException("Phone no: can be only numbers");
    EsimsUtils.validateNullableStrings(this.email, 32);
    if (this.email != null)
      if(! this.email.matches("^.+@[^\\.].*\\.[a-z]{2,}$"))
        throw new BusinessRuleException("Invalid email address");
    EsimsUtils.validateNullableStrings(this.fax, 10);
    EsimsUtils.validateStrings(this.management, 64);
    EsimsUtils.validateStrings(this.principalFirstName, 32);
    EsimsUtils.validateNullableStrings(this.principalMiddleName, 32);
    EsimsUtils.validateStrings(this.principalLastName, 32);
    EsimsUtils.validateNullableStrings(this.vicePrincipalFirstName, 32);
    EsimsUtils.validateNullableStrings(this.vicePrincipalMiddleName, 32);
    EsimsUtils.validateNullableStrings(this.vicePrincipalLastName, 32);
    EsimsUtils.validateStrings(this.boardOfEducation, 64);
    if(this.isActive == null)
      throw new BusinessRuleException("Activity status found null");
  }
View Full Code Here


    this.name = name;
  }

  public void setStandard(Standard standard) {
    if (standard == null)
      throw new BusinessRuleException(
      "A division has to be associated with a standard, the Standard provided was found null");
    if (standard.getStandardId() == null)
      throw new BusinessRuleException(
      "The Standard was not initialized properly, The ID of the Standard was missing");
    this.standard = standard;
  }
View Full Code Here

    this.standardId = id;
  }

  public void setAcademicYear(AcademicYear academicYear) {
    if (academicYear == null)
      throw new BusinessRuleException(
          "A Standard cannot be created without a valid Academic Year associated with it");
    else if (academicYear.getAcademicYearId() == null)
      throw new BusinessRuleException(
          "The Id of the academic year supplied was found null");
    this.academicYear = academicYear;
  }
View Full Code Here

    try {
      // this method was used since India doesnt use DST :-)
      days = (endDate.getTime() - startDate.getTime()) / 1000 / 60 / 60
          / 24;
      if (days > 365)
        throw new BusinessRuleException(
            "An academic year cannot be more than 365 days");
    } catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("endDate", new LocalizableError(
          "/admin/academicyear/tooLong"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
    try {
      if (days < 279)
        throw new BusinessRuleException(
            "An academic year cannot be less than 279 days");

    } catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("endDate", new LocalizableError(
View Full Code Here

    try {
      // this method was used since India doesnt use DST :-)
      days = (endDate.getTime() - startDate.getTime()) / 1000 / 60 / 60
          / 24;
      if (days > 365)
        throw new BusinessRuleException(
            "An academic year cannot be more than 365 days");
    } catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("endDate", new LocalizableError(
          "/admin/academicyear/tooLong"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
    try {
      if (days < 279)
        throw new BusinessRuleException(
            "An academic year cannot be less than 279 days");

    } catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("endDate", new LocalizableError(
View Full Code Here

  public Resolution showStudentDetailsPage() {
   
    //Check for valid dates on the previous page
    try{
      if(EsimsUtils.compareDates(new Date(), this.formIssuedOn)== -1)
        throw new BusinessRuleException("The date of issuing the form cannot be in the future");
    }
    catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("formIssuedOn", new LocalizableError("/officestaff/applicationforms/futureFormIssuedDate"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
    try{
      if(EsimsUtils.compareDates(new Date(), this.formReceivedOn)== -1)
        throw new BusinessRuleException("The date of receiving the form cannot be in the future");
    }
    catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("formReceivedOn", new LocalizableError("/officestaff/applicationforms/futureFormReceivedDate"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
    try{
      if(EsimsUtils.compareDates(this.formFilledOn, this.formIssuedOn)== -1)
        throw new BusinessRuleException("The date of filling the form cannot be earlier than the issual date");
    }
    catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("formReceivedOn", new LocalizableError("/officestaff/applicationforms/previousFormFillingDate"));
      getContext().setValidationErrors(errors);
      return getContext().getSourcePageResolution();
    }
    try{
      if(EsimsUtils.compareDates(this.formIssuedOn, this.formReceivedOn)> 0)
        throw new BusinessRuleException("The date of receving the form cannot be earlier than issuance");
    }
    catch (BusinessRuleException businessRuleException) {
      ValidationErrors errors = new ValidationErrors();
      errors.add("formReceivedOn", new LocalizableError("/officestaff/applicationforms/earlierFormReceivedDate"));
      getContext().setValidationErrors(errors);
View Full Code Here

    return syllabus;
  }

  public void setIsActive(Boolean isActive) {
    if (isActive == null)
      throw new BusinessRuleException("The activity status of a subject cannot be null");
    this.isActive = isActive;
  }
View Full Code Here

    this.isActive = isActive;
  }

  public void setName(String name) {
    if(name == null || name.length()==0)
      throw new BusinessRuleException("The name of a Subject cannot be null");
    this.name = name;
  }
View Full Code Here

    this.name = name;
  }

  public void setStandard(Standard standard) {
    if (standard == null)
      throw new BusinessRuleException(
      "The standard cannot be null for a Subject");
    else if (standard.getStandardId() == null)
      throw new BusinessRuleException(
      "The standard was not instantiated properly, the Id was found null");
    this.standard = standard;
  }
View Full Code Here

 
 
  //  validate non nullable strings
  public static void validateStrings(String str,int len) throws BusinessRuleException{
    if(StringUtils.isEmpty(str))
      throw new BusinessRuleException("Arg was found null/empty");
    if(str.length()>len)
      throw new BusinessRuleException(str+ " can be only a maximum of "+ len +" characters in length");
  }
View Full Code Here

TOP

Related Classes of net.sf.esims.exception.BusinessRuleException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.