Package net.sf.chellow.monad

Examples of net.sf.chellow.monad.UserException


    super.update(uriString);
    URI uri;
    try {
      uri = toUri();
    } catch (InternalException e) {
      throw new UserException(e.getMessage());
    }
    if (uri.isAbsolute()) {
      throw new UserException(
          "The URI path element must be a relative URI.");
    }
    if (uri.getPath().split("/").length > 1) {
      throw new UserException(
          "The URI path element can only consist of a single element.");
    }
  }
View Full Code Here


    Hiber.setReadWrite();
    Long participantId = inv.getLong("participant-id");
    String name = inv.getString("name");
    Date startDate = inv.getDateTime("start");
    if (!inv.isValid()) {
      throw new UserException(document());
    }
    try {
      SupplierContract contract = SupplierContract
          .insertSupplierContract(null,
              Participant.getParticipant(participantId), name,
View Full Code Here

      if (importMpanStr != null && importMpanStr.length() != 0) {
        try {
          importAgreedSupplyCapacity = new Integer(
              importAgreedSupplyCapacityStr);
        } catch (NumberFormatException e) {
          throw new UserException(
              "The import supply capacity must be an integer."
                  + e.getMessage());
        }
        importSupplierContract = SupplierContract
            .getSupplierContract(importSupplierContractName);
      }
      SupplierContract exportSupplierContract = null;
      Integer exportAgreedSupplyCapacity = null;
      String exportLlfcCode = null;
      String exportMpanStr = null;
      String exportSupplierAccount = null;
      if (values.length > 25) {
        exportMpanStr = GeneralImport.addField(csvElement,
            "Export MPAN Core", values, 25);
        if (exportMpanStr != null && exportMpanStr.trim().length() != 0) {
          exportLlfcCode = GeneralImport.addField(csvElement,
              "Export LLFC", values, 26);
          String exportAgreedSupplyCapacityStr = GeneralImport
              .addField(csvElement,
                  "Export Agreed Supply Capacity", values, 27);
          try {
            exportAgreedSupplyCapacity = new Integer(
                exportAgreedSupplyCapacityStr);
          } catch (NumberFormatException e) {
            throw new UserException(
                "The export agreed supply capacity must be an integer."
                    + e.getMessage());
          }
          String exportSupplierContractName = GeneralImport.addField(
              csvElement, "Export Supplier Contract", values, 28);
View Full Code Here

  }

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

        .session()
        .createQuery(
            "select distinct mpan.supplyGeneration.supply from Mpan mpan where mpan.dno.code.string || mpan.uniquePart.string || mpan.checkDigit.character = :core")
        .setString("core", core.toStringNoSpaces()).uniqueResult();
    if (supply == null) {
      throw new UserException("The MPAN core " + core
          + " is not set up in Chellow.");
    }
    return supply;
  }
View Full Code Here

    if (name == null) {
      throw new InternalException("The supply name " + "cannot be null.");
    }
    name = name.trim();
    if (name.length() == 0) {
      throw new UserException("The supply name can't be blank.");
    }
    setName(name);
    setSource(source);
    if ((source.getCode().equals(Source.GENERATOR_CODE) || source.getCode()
        .equals(Source.GENERATOR_NETWORK_CODE))
        && generatorType == null) {
      throw new UserException(
          "If the source is 'gen' or 'gen-net', there must be a generator type.");
    }
    setGeneratorType(generatorType);
    setGspGroup(gspGroup);
  }
View Full Code Here

    try {
      Hiber.session().save(core);
      mpanCores.add(core);
      Hiber.flush();
    } catch (ConstraintViolationException e) {
      throw new UserException("This MPAN core already exists.");
    }
    return core;
  }
View Full Code Here

        .session()
        .createQuery(
            "from SupplyGeneration generation where generation.supply = :supply and generation.id = :id")
        .setEntity("supply", this).setLong("id", generation.getId())
        .uniqueResult() == null) {
      throw new UserException(
          "The generation doesn't belong to this supply.");
    }
    SupplyGeneration previousGeneration = (SupplyGeneration) Hiber
        .session()
        .createQuery(
View Full Code Here

  }

  public SupplyGeneration insertGeneration(HhStartDate startDate)
      throws HttpException {
    if (generations.isEmpty()) {
      throw new UserException(
          "Can't insert generation as there aren't any existing generations");
    }
    if (startDate.after(getGenerationLast().getFinishDate())) {
      throw new UserException(
          "One can't add a generation that starts after the supply has finished.");
    }

    SupplyGeneration firstGeneration = getGenerationFirst();
    SupplyGeneration templateGeneration = null;
View Full Code Here

    HhStartDate finishDate = null;
    SupplyGeneration coveredGeneration = null;

    if (!generations.isEmpty()) {
      if (startDate.after(getGenerationLast().getFinishDate())) {
        throw new UserException(
            "One can't add a generation that starts after the supply has finished.");
      }

      SupplyGeneration firstGeneration = getGenerationFirst();

      if (startDate.before(firstGeneration.getStartDate())) {
        finishDate = firstGeneration.getStartDate().getPrevious();
      } else {
        coveredGeneration = getGeneration(startDate);
        if (startDate.equals(coveredGeneration.getStartDate())) {
          throw new UserException(
              "There's already a generation with that start date.");
        }
        finishDate = coveredGeneration.getFinishDate();
      }
    }
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.