Package net.sf.chellow.monad

Examples of net.sf.chellow.monad.UserException


  }

  static public Dno getDno(String code) throws HttpException {
    Dno dno = findDno(code);
    if (dno == null) {
      throw new UserException("There is no DNO with the code '" + code
          + "'.");
    }
    return dno;
  }
View Full Code Here


            "from Llfc llfc where llfc.dno = :dno and llfc.code = :code and llfc.validFrom <= :date and (llfc.validTo is null or llfc.validTo >= :date)")
        .setEntity("dno", this).setInteger("code",
            Integer.parseInt(code)).setTimestamp("date", date)
        .uniqueResult();
    if (llfc == null) {
      throw new UserException(
          "There is no line loss factor with the code " + code
              + " associated with the DNO '"
              + getCode().toString() + "' for the date "
              + date.toString() + ".");
    }
View Full Code Here

  public Llfc getLlfc(String code) throws HttpException {
    Integer llfcInt = null;
    try {
      llfcInt = Integer.parseInt(code);
    } catch (NumberFormatException e) {
      throw new UserException(
          "The LLFC must be an integer between 0 and 999.");
    }

    Llfc llfc = (Llfc) Hiber.session().createQuery(
        "from Llfc llfc where llfc.dno = :dno and llfc.code = :code")
        .setEntity("dno", this).setInteger("code", llfcInt)
        .uniqueResult();
    if (llfc == null) {
      throw new UserException("There is no LLFC with the code " + code
          + " associated with the DNO " + getCode() + ".");
    }
    return llfc;
  }
View Full Code Here

    DnoContract contract = findContract(name);
    if (contract == null) {
      contract = new DnoContract(this, id, name, startDate, finishDate,
          chargeScript);
    } else {
      throw new UserException(
          "There is already a DNO contract with this name.");
    }
    Hiber.session().save(contract);
    Hiber.flush();
    contract.insertFirstRateScript(rateScriptId, startDate, finishDate,
View Full Code Here

        .createQuery(
            "from Provider provider where provider.participant = :participant and provider.role = :role")
        .setEntity("participant", participant).setEntity("role", role)
        .uniqueResult();
    if (provider == null) {
      throw new UserException(
          "There isn't a provider with participant code "
              + participant.getCode() + " ("
              + participant.getName() + ") and role code "
              + role.getCode() + " (" + role.getDescription()
              + ").");
View Full Code Here

    try {
      Ssc ssc = (Ssc) Hiber.session().createQuery(
          "from Ssc ssc where ssc.code = :code").setInteger("code",
          Integer.parseInt(code)).uniqueResult();
      if (ssc == null) {
        throw new UserException("There isn't an SSC with code: " + code
            + ".");
      }
      return ssc;
    } catch (NumberFormatException e) {
      throw new UserException("An SSC code must be an integer. "
          + e.getMessage());
    }
  }
View Full Code Here

  }

  public static Ssc getSsc(long id) throws HttpException {
    Ssc ssc = (Ssc) Hiber.session().get(Ssc.class, id);
    if (ssc == null) {
      throw new UserException("There isn't an SSC with id: " + id + ".");
    }
    return ssc;
  }
View Full Code Here

    Comparable<Contract> {

  public static Contract getService(Long id) throws HttpException {
    Contract service = (Contract) Hiber.session().get(Contract.class, id);
    if (service == null) {
      throw new UserException("There isn't a service with that id.");
    }
    return service;
  }
View Full Code Here

  protected void internalUpdate(String name, String chargeScript)
      throws HttpException {
    name = name.trim();
    if (name.length() == 0) {
      throw new UserException("The contract name can't be blank.");
    }
    setName(name);
    PythonInterpreter interp = new PythonInterpreter();
    interp.set("contract", this);
    try {
      interp.compile(chargeScript);
    } catch (Throwable e) {
      throw new UserException(HttpException.getStackTraceString(e));
    }
    setChargeScript(chargeScript);
  }
View Full Code Here

  static public MeasurementRequirement getMeasurementRequirement(Long id)
      throws HttpException {
    MeasurementRequirement requirement = (MeasurementRequirement) Hiber
        .session().get(MeasurementRequirement.class, id);
    if (requirement == null) {
      throw new UserException(
          "There is no measurement requirement with that id.");
    }
    return requirement;
  }
View Full Code Here

TOP

Related Classes of net.sf.chellow.monad.UserException

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.