Package ch.agent.t2.timeutil

Examples of ch.agent.t2.timeutil.JavaDateUtil


  public AccessMethodsForNumber() {
  }

  @Override
  public Range getRange(Series<Double> series) throws T2DBException {
    Range range = null;
    try {
      check(Permission.READ, series);
      Surrogate s = series.getSurrogate();
      BasicDBObject obj = (BasicDBObject) getObject(s, false);
      if (obj != null) {
        long first = obj.getLong(MongoDatabase.FLD_SER_FIRST);
        long last = obj.getLong(MongoDatabase.FLD_SER_LAST);
        range = new Range(series.getTimeDomain(), first, last);
      }
    } catch (Exception e) {
      throw T2DBMsg.exception(e, E.E50122, series.getName(true));
    }
    if (range == null)
      range = new Range(series.getTimeDomain());
    return range;
  }
View Full Code Here


    return count;
  }
 
  private <T>void update(Series<T> series, TimeAddressable<Double> values) throws T2DBException {
    com.mongodb.DBObject operation = null;
    Range range = values.getRange();
    Map<String, Double> data = new HashMap<String, Double>();
    for (Observation<Double> obs : values) {
      data.put(Long.toString(obs.getIndex()), obs.getValue());
    }
    operation = operation(Operator.SET,
        MongoDatabase.FLD_SER_FIRST, range.getFirstIndex(),
        MongoDatabase.FLD_SER_LAST, range.getLastIndex(),
        MongoDatabase.FLD_SER_VALUES, data);
   
    Surrogate s = series.getSurrogate();
    getMongoDB(s).getSeries().update(asQuery(s.getId()), operation);
  }
View Full Code Here

      if (DUMP)
        System.out.println(t.getTimeDomain() + " " + s.getRange());
      assertEquals(9, s.getRange().getSize());
      if (DUMP)
        System.out.println(s.getValues(null));
      boolean done = s.setRange(new Range(t.getTimeDomain(), "2011-03-12", "2011-03-17", Adjustment.NONE));
      if (DUMP)
        System.out.println(s.getValues(null));
      assertFalse(done);
      done = s.setRange(new Range(t.getTimeDomain(), "2011-03-12", "2011-03-16", Adjustment.NONE));
      s.applyUpdates();
      if (DUMP)
        System.out.println(s.getValues(null));
      assertEquals(3, s.getRange().getSize());
      done = s.setRange(null);
View Full Code Here

  }

  public void testEmptyRange() {
    try {
      UpdatableSeries<Double> s = db.getUpdatableSeries(SERIES, true);
      assertEquals(new Range(s.getTimeDomain()), s.getRange());
    } catch (Exception e) {
      fail(e.toString());
    }
  }
View Full Code Here

 
  public void testSubRangeHasNoMissingValuesAtTheBoundaries() {
    try {
      Series<Double> s = makeSeries(makeTimeSeries());
      TimeDomain dom = s.getTimeDomain();
      TimeAddressable<Double> ts = s.getValues(new Range(dom, "2011-05-15", "2011-07-15", Adjustment.NONE));
      assertEquals(new Range(dom, "2011-06-01", "2011-07-01", Adjustment.NONE), ts.getRange());
    } catch (Exception e) {
      fail(e.toString());
    }
  }
View Full Code Here

 
  public void testGetLastValue_1() {
    try {
      Series<Double> s = makeSeries(makeTimeSeries());
      TimeDomain dom = s.getTimeDomain();
      Range range = new Range(dom.time("2011-05-15"), dom.time("2011-07-15"));
      TimeAddressable<Double> ts = s.getValues(range);
      Observation<Double> obs = ts.getLast(dom.time("2011-06-01"));
      assertEquals("2011-06-01", obs.getTime().toString());
    } catch (Exception e) {
      fail(e.toString());
View Full Code Here

 
  public void testGetLastValue_3() {
    try {
      Series<Double> s = makeSeries(makeTimeSeries());
      TimeDomain dom = s.getTimeDomain();
      Range range = new Range(dom.time("2011-05-15"), dom.time("2011-07-15"));
      TimeAddressable<Double> ts = s.getValues(range);
      Observation<Double> obs = ts.getLast(dom.time("2011-05-31"));
      assertNull(obs);
    } catch (Exception e) {
      fail(e.toString());
View Full Code Here

  public void testMoreSeries() {
    try {
      UpdatableSeries<Double> s = makeSeries(makeTimeSeries2()).edit();
      TimeAddressable<Double> ts = s.getValues(null);
      Range range = new Range(s.getTimeDomain(), "2011-05-01", "2011-07-03", Adjustment.NONE);
      assertEquals(64, range.getSize());
      assertEquals(range, ts.getRange());
      assertEquals(range, s.getRange());
    } catch (Exception e) {
      fail(e.toString());
    }
View Full Code Here

   * Reduce range with setRange().
   */
  public void testGetSeries04() {
    try {
      UpdatableSeries<Double> s = db.getSeries(SERIES, true).typeCheck(Double.class).edit();
      s.setRange(new Range(Day.DOMAIN.time("2011-05-02"), Day.DOMAIN.time("2011-06-30")));
      assertEquals("[2011-05-02, 2011-06-30]", s.getRange().toString());
    } catch (Exception e) {
      fail(e.toString());
    }
  }
View Full Code Here

      if (DUMP)
        System.out.println(t.getTimeDomain() + " " + s.getRange());
      assertEquals(9, s.getRange().getSize());
      if (DUMP)
        System.out.println(s.getValues(null));
      boolean done = s.setRange(new Range(t.getTimeDomain(), "2011-03-12", "2011-03-17", Adjustment.NONE));
      if (DUMP)
        System.out.println(s.getValues(null));
      assertFalse(done);
      done = s.setRange(new Range(t.getTimeDomain(), "2011-03-12", "2011-03-16", Adjustment.NONE));
      s.applyUpdates();
      if (DUMP)
        System.out.println(s.getValues(null));
      assertEquals(3, s.getRange().getSize());
      done = s.setRange(null);
View Full Code Here

TOP

Related Classes of ch.agent.t2.timeutil.JavaDateUtil

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.