Package net.sf.chellow.monad

Examples of net.sf.chellow.monad.InternalException


        .createQuery(
            "from MpanCore mpanCore where mpanCore.supply = :supply and mpanCore.dno.code.string || mpanCore.uniquePart.string || mpanCore.checkDigit.character = :core")
        .setEntity("supply", this)
        .setString("core", core.toStringNoSpaces()).uniqueResult();
    if (mpanCore == null) {
      throw new InternalException("Mpan isn't attached to this supply.");
    }
    return mpanCore;
  }
View Full Code Here


          .getResource("/WEB-INF/dno-contracts.xml").openStream(),
          "xml");
      process.run();
      List<MonadMessage> errors = process.getErrors();
      if (!errors.isEmpty()) {
        throw new InternalException(errors.get(0).getDescription());
      }
    } catch (UnsupportedEncodingException e) {
      throw new InternalException(e);
    } catch (IOException e) {
      throw new InternalException(e);
    }
  }
View Full Code Here

      GeneralImport process = new GeneralImport(null, context
          .getResource("/WEB-INF/reports.xml").openStream(), "xml");
      process.run();
      List<MonadMessage> errors = process.getErrors();
      if (!errors.isEmpty()) {
        throw new InternalException(errors.get(0).getDescription());
      }
    } catch (UnsupportedEncodingException e) {
      throw new InternalException(e);
    } catch (IOException e) {
      throw new InternalException(e);
    }
  }
View Full Code Here

    try {
      MessageDigest md = MessageDigest.getInstance("SHA-256");
      md.update(password.getBytes("UTF-8"));
      return Base64.encodeToString(md.digest());
    } catch (NoSuchAlgorithmException e) {
      throw new InternalException(e.getMessage());
    } catch (UnsupportedEncodingException e) {
      throw new InternalException(e.getMessage());
    }
  }
View Full Code Here

      List<String> mpanStrings, String reference, Date issueDate,
      HhStartDate startDate, HhStartDate finishDate, BigDecimal kwh, BigDecimal net,
      BigDecimal vat, BigDecimal gross, String breakdown, List<RawRegisterRead> registerReads)
      throws HttpException {
    if (type == null) {
      throw new InternalException("The type can't be null.");
    }
    this.type = type;
    if (issueDate == null) {
      throw new InternalException("The issue date can't be null.");
    }
    this.issueDate = issueDate;
    if (startDate == null) {
      throw new InternalException("The start date can't be null.");
    }
    this.startDate = startDate;
    if (finishDate == null) {
      throw new InternalException("The finish date can't be null.");
    }
    this.finishDate = finishDate;
    this.kwh = kwh;
    this.net = net;
    this.vat = vat;
    this.gross = gross;

    if (reference == null) {
      throw new InternalException(
          "The bill reference parameter is required.");
    }
    this.reference = reference;
    if (accountReference == null) {
      throw new UserException(
          "The accountReference parameter is required.");
    }
    this.accountReference = accountReference;
    if (mpanStrings == null) {
      throw new InternalException(
          "The mpanStrings parameter must not be null.");
    }
    this.breakdown = breakdown;
    this.mpanStrings = mpanStrings;
    if (registerReads != null) {
View Full Code Here

      Units units, String meterSerialNumber, String mpanStr,
      HhStartDate previousDate, BigDecimal previousValue,
      ReadType previousType, HhStartDate presentDate,
      BigDecimal presentValue, ReadType presentType) throws HttpException {
    if (bill == null) {
      throw new InternalException("The bill must not be null.");
    }
    setBill(bill);
    update(tpr, coefficient, units, meterSerialNumber, mpanStr,
        previousDate, previousValue, previousType, presentDate,
        presentValue, presentType);
View Full Code Here

  public URI toUri() throws InternalException {
    try {
      return new URI(toString());
    } catch (URISyntaxException e) {
      throw new InternalException(e);
    }
  }
View Full Code Here

        boolean isImport = message.charAt(message.lastIndexOf(',') - 1) == '0';
        throw new UserException("An MPAN with this "
            + (isImport ? "import" : "export")
            + " MPAN core already exists.");
      } else {
        throw new InternalException(e);
      }
    }
    SupplyGeneration generation = supply.insertGeneration(this,
        new ArrayList<Site>(), startDate, mopContract, mopAccount,
        hhdcContract, hhdcAccount, meterSerialNumber, pc, mtcCode, cop,
View Full Code Here

    PreparedStatement stmt;
    try {
      stmt = con
          .prepareStatement("INSERT INTO hh_datum VALUES (nextval('hh_datum_id_sequence'), ?, ?, ?, ?)");
    } catch (SQLException e1) {
      throw new InternalException(e1);
    }
    int batchSize = 0;
    for (int i = 0; i < dataRaw.size(); i++) {
      // Debug.print("Start processing hh: " + (System.currentTimeMillis()
      // - now));
      boolean added = false;
      boolean altered = false;
      HhDatumRaw datumRaw = dataRaw.get(i);
      HhDatum datum = null;

      if (i - missing < data.size()) {
        datum = data.get(i - missing);
        if (!datumRaw.getStartDate().equals(datum.getStartDate())) {
          datum = null;
        }
      }
      if (datum == null) {
        // Debug.print("About to save datum: "
        // + (System.currentTimeMillis() - now));
        try {
          stmt.setLong(1, getId());

          stmt.setTimestamp(2, new Timestamp(datumRaw.getStartDate()
              .getDate().getTime()));
          stmt.setBigDecimal(3, datumRaw.getValue());
          stmt.setString(4, Character.toString(datumRaw.getStatus()));
          stmt.addBatch();
          batchSize++;
        } catch (SQLException e) {
          throw new InternalException(e);
        }
        // Debug.print("Saved datum: "
        // + (System.currentTimeMillis() - now));
        // Hiber.flush();
        lastAdditionDate = datumRaw.getStartDate();
        added = true;
        missing++;
        if (deleteMissingFrom == null) {
          deleteMissingFrom = datumRaw.getStartDate();
        }
        deleteMissingTo = datumRaw.getStartDate();
        // Debug.print("Resolved missing: "
        // + (System.currentTimeMillis() - now));
      } else if (datumRaw.getValue().doubleValue() != datum.getValue()
          .doubleValue() || datumRaw.getStatus() != datum.getStatus()) {
        // Debug.print("About to update datum: " + datum + " with " +
        // datumRaw + " "
        // + (System.currentTimeMillis() - now));
        originalDatumValue = datum.getValue();
        originalDatumStatus = datum.getStatus();
        datum.update(datumRaw.getValue(), datumRaw.getStatus());
        Hiber.flush();
        altered = true;
      }
      // Debug.print("About to see if changed: "
      // + (System.currentTimeMillis() - now));
      if (added || altered) {
        if (siteCheckFrom == null) {
          siteCheckFrom = datumRaw.getStartDate();
        }
        siteCheckTo = datumRaw.getStartDate();
        if (datumRaw.getValue().doubleValue() < 0) {
          addSnag(ChannelSnag.SNAG_NEGATIVE, datumRaw.getStartDate(),
              datumRaw.getStartDate());
        } else if (altered && originalDatumValue.doubleValue() < 0) {
          deleteSnag(ChannelSnag.SNAG_NEGATIVE,
              datumRaw.getStartDate());
        }
        if (HhDatum.ACTUAL != datumRaw.getStatus()) {
          if (notActualFrom == null) {
            notActualFrom = datumRaw.getStartDate();
          }
          notActualTo = datumRaw.getStartDate();
        } else if (altered && originalDatumStatus != HhDatum.ACTUAL) {
          deleteSnag(ChannelSnag.SNAG_ESTIMATED,
              datumRaw.getStartDate());
        }
      }
      if (lastAdditionDate != null
          && (lastAdditionDate.equals(prevStartDate) || batchSize > 100)) {
        // Debug.print("About to execute batch "
        // + (System.currentTimeMillis() - now));
        try {
          stmt.executeBatch();
          // Debug.print("Added  lines.");
          batchSize = 0;
        } catch (SQLException e) {
          throw new InternalException(e);
        }
        lastAdditionDate = null;
      }
      if (siteCheckTo != null && siteCheckTo.equals(prevStartDate)) {
        // Debug.print("About to do site check: "
        // + (System.currentTimeMillis() - now));
        siteCheck(siteCheckFrom, siteCheckTo);
        siteCheckFrom = null;
        siteCheckTo = null;
        // Debug.print("Finished site check: "
        // + (System.currentTimeMillis() - now));
      }
      if (notActualTo != null && notActualTo.equals(prevStartDate)) {
        // Debug.print("Started not actual: "
        // + (System.currentTimeMillis() - now));
        addSnag(ChannelSnag.SNAG_ESTIMATED, notActualFrom, notActualTo);
        // Debug.print("Finished not actual: "
        // + (System.currentTimeMillis() - now));
        notActualFrom = null;
        notActualTo = null;
      }
      if (deleteMissingTo != null
          && deleteMissingTo.equals(prevStartDate)) {
        // Debug.print("Starting resolvedMissing: "
        // + (System.currentTimeMillis() - now));
        deleteSnag(ChannelSnag.SNAG_MISSING, deleteMissingFrom,
            deleteMissingTo);
        deleteMissingFrom = null;
        deleteMissingTo = null;
        // Debug.print("Finished resolveMissing: "
        // + (System.currentTimeMillis() - now));
      }
      prevStartDate = datumRaw.getStartDate();
    }
    if (lastAdditionDate != null && lastAdditionDate.equals(prevStartDate)) {
      // Debug.print("About to execute batch 2: "
      // + (System.currentTimeMillis() - now));
      try {
        stmt.executeBatch();
      } catch (SQLException e) {
        throw new InternalException(e);
      }
      lastAdditionDate = null;
    }
    if (siteCheckTo != null && siteCheckTo.equals(prevStartDate)) {
      // Debug.print("About to start site thing 2: "
View Full Code Here

  public static void deleteBatch(Batch batch) throws InternalException {
    try {
      Hiber.session().delete(batch);
      Hiber.flush();
    } catch (HibernateException e) {
      throw new InternalException(e);
    }
  }
View Full Code Here

TOP

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

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.