Package net.sf.chellow.monad

Examples of net.sf.chellow.monad.InternalException


    } else if (contractUrl.contains("hhdc-contracts")) {
      report = "203";
    } else if (contractUrl.contains("mop-contracts")) {
      report = "193";
    } else {
      throw new InternalException("Unkown contract type.");
    }
    try {
      return new URI("/reports/" + report + "/output/?batch-id=" + getId());
    } catch (URISyntaxException e) {
      throw new InternalException(e);
    }
  }
View Full Code Here


        try {
          stmt = con
              .prepareStatement("INSERT INTO hh_datum VALUES (nextval('hh_datum_id_sequence'), ?, ?, ?, ?)");
          Statement st = con.createStatement();
        st.executeUpdate("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE READ WRITE");        } 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, channel.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) {
              channel.addSnag(ChannelSnag.SNAG_NEGATIVE, datumRaw.getStartDate(),
                  datumRaw.getStartDate());
            } else if (altered && originalDatumValue.doubleValue() < 0) {
              channel.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) {
              channel.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();
              Statement st = con.createStatement();
              st.executeUpdate("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE READ WRITE");   
              // 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));
            channel.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));
            channel.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));
            channel.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();
            Statement st = con.createStatement();
            st.executeUpdate("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE READ WRITE");
          } 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 ChannelSnag copy() throws InternalException {
    ChannelSnag cloned;
    try {
      cloned = (ChannelSnag) super.clone();
    } catch (CloneNotSupportedException e) {
      throw new InternalException(e);
    }
    cloned.setId(null);
    return cloned;
  }
View Full Code Here

  public Snag copy() throws InternalException {
    Snag cloned;
    try {
      cloned = (Snag) super.clone();
    } catch (CloneNotSupportedException e) {
      throw new InternalException(e);
    }
    cloned.setId(null);
    return cloned;
  }
View Full Code Here

  public SiteSnag copy() throws InternalException {
    SiteSnag cloned;
    try {
      cloned = (SiteSnag) super.clone();
    } catch (CloneNotSupportedException e) {
      throw new InternalException(e);
    }
    cloned.setId(null);
    return cloned;
  }
View Full Code Here

  public HhDatum(Channel channel, HhDatumRaw datumRaw) throws HttpException {
    setChannel(channel);
    HhStartDate startDate = datumRaw.getStartDate();
    if (startDate == null) {
      throw new InternalException(
          "The value 'startDate' must not be null.");
    }
    setStartDate(startDate);
    update(datumRaw.getValue(), datumRaw.getStatus());
  }
View Full Code Here

  public void update(String llfcCode, String core, SupplierContract supplierContract,
      String supplierAccount, Integer agreedSupplyCapacity)
      throws HttpException {
    if (agreedSupplyCapacity == null) {
      throw new InternalException("agreedSupplyCapacity can't be null");
    }
    MpanCore mpanCore = MpanCore.findMpanCore(core);
    if (mpanCore == null) {
      mpanCore = supplyGeneration.getSupply().addMpanCore(core);
    }
View Full Code Here

    this(new MonadDate(dateStr).getDate());
  }

  public HhStartDate(Date date) throws HttpException {
    if (date == null) {
      throw new InternalException("Date can't be null I'm afraid.");
    }
    Calendar cal = MonadDate.getCalendar();
    cal.setTime(date);
    int minute = cal.get(Calendar.MINUTE);
    int second = cal.get(Calendar.SECOND);
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.