Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.UpdatableSchema


    }
  }
 
  public void test_delete_chronicle_attribute_with_actual_values() {
    try {
      UpdatableSchema schema = db.getUpdatableSchemas("schema1a").iterator().next();

      // use the attribute
      UpdatableChronicle chro = db.getChronicle("bt.schema1achro", true).edit();
      assertEquals("t1v1", chro.getAttribute("prop1", true).get().toString());
      Attribute<?> a = chro.getAttribute("prop1", true);
      a.scan("t1v2");
      assertEquals("t1v2", a.get().toString());
      chro.setAttribute(a);
      chro.applyUpdates();
      assertEquals("t1v2", chro.getAttribute("prop1", true).get().toString());
      schema.deleteAttribute(1);
      schema.applyUpdates();
      expectException();
    } catch (Exception e) {
      assertException(e, null, D.D30146);
    }
  }
View Full Code Here


      assertEquals("t1v3", a.get().toString());
      chro.setAttribute(a);
      chro.applyUpdates();
      assertEquals("t1v3", chro.getAttribute("prop1", true).get().toString());
      // remove the attribute from the base schema of schema3 (should fail)
      UpdatableSchema schema1 = db.getUpdatableSchemas("schema1a").iterator().next();
      schema1.deleteAttribute(1);
      schema1.applyUpdates();
      expectException();
    } catch (Exception e) {
      assertException(e, null, D.D30146);
    }
  }
View Full Code Here

  public void test_erase_attribute_in_use() {
    try {
      // erase attribute
      Chronicle chro = db.getChronicle("bt.schema3chro", true);
      assertEquals("t1v3", chro.getAttribute("prop1", true).get().toString());
      UpdatableSchema schema3 = db.getUpdatableSchemas("schema3").iterator().next();
      schema3.addAttribute(1);
      schema3.eraseAttribute(1);
      schema3.applyUpdates();
      assertEquals(null, schema3.getAttributeDefinition("prop1", false));
      expectException();
    } catch (Exception e) {
      assertException(e, D.D30105, D.D30146);
    }
  }
View Full Code Here

      a.reset();
      chro.setAttribute(a);
      chro.applyUpdates();
      assertEquals("t1v2", chro.getAttribute("prop1", true).get().toString());
     
      UpdatableSchema schema3 = db.getUpdatableSchemas("schema3").iterator().next();
      schema3.addAttribute(1);
      schema3.eraseAttribute(1);
      schema3.applyUpdates();
      assertEquals(null, schema3.getAttributeDefinition("prop1", false));
      // value still here because it's the default value, which is not in the chronicle
      assertEquals("t1v2", chro.getAttribute("prop1", true).get().toString());
    } catch (Exception e) {
      fail(e.getMessage());
    }
View Full Code Here

    }
  }
 
  public void test_delete_schema_in_use() {
    try {
      UpdatableSchema schema1 = db.getSchemas("schema1a").iterator().next().edit();
      schema1.destroy();
      schema1.applyUpdates();
      expectException();
    } catch (Exception e) {
      assertException(e, D.D30140);
    }
  }
View Full Code Here

      a.scan("t1v1");
      chro.setAttribute(a);
      chro.applyUpdates();
      assertEquals("t1v1", chro.getAttribute("prop1", true).get().toString());
      // now change the default
      UpdatableSchema uschema1 = schema1.edit();
      uschema1.setAttributeDefault(1, "t1v2");
      uschema1.applyUpdates();
      // expect that the attribute value has changed because t1v1 above was not set, being the default
      Chronicle c = db.getChronicle("bt.schema1achro2", true);
      assertEquals("t1v1", c.getAttribute("prop1", true).get().toString());
    } catch (Exception e) {
      fail(e.getMessage());
View Full Code Here

    // create "Ticker" property
    UpdatableProperty<String> p = db.createProperty("Ticker", vt, true);
    p.applyUpdates();
     
    // create "Stocks" schema, with a "Ticker" property and a "price" series
    UpdatableSchema schema = db.createSchema("Stocks", null);
    schema.addAttribute(2);
    schema.setAttributeProperty(2, p);
    schema.addSeries(1);
    schema.setSeriesName(1, "price");
    schema.setSeriesType(1, "numeric");
    schema.setSeriesTimeDomain(1, Day.DOMAIN);
    schema.applyUpdates();
     
    db.commit();
  }
View Full Code Here

  private static final String SERIES = "bt.t040.test";

  @Override
  protected void firstSetUp() throws Exception {
    db = getContext().getDatabase();
    UpdatableSchema s = db.createSchema("t040", null);
    s.addSeries(1);
    s.setSeriesName(1, "test");
    s.setSeriesType(1, "numeric");
    s.setSeriesTimeDomain(1, Day.DOMAIN);
    s.applyUpdates();
    String split[] = db.getNamingPolicy().split("bt.t040");
    UpdatableChronicle c = db.getTopChronicle().edit().createChronicle(split[1], false, "test entity", null, s.resolve());
    c.applyUpdates();
    db.commit();
  }
View Full Code Here

  }

  private void listSchemas(String pattern) throws Exception {
    Collection<UpdatableSchema> schemas = db.getUpdatableSchemas(pattern);
    for (UpdatableSchema schema : schemas) {
      UpdatableSchema base = schema.getBase();
      if (base == null)
        System.out.println(schema.getName());
      else
        System.out.println(schema.getName() + "--->" + schema.getBase().getName());
    }
View Full Code Here

    }
  }
 
  public void test_create_schema_failure_series_name_used_twice () {
    try {
      UpdatableSchema schema = db.createSchema("schema1", null);
      schema.addSeries(1);
      schema.setSeriesName(1, "x25");
      schema.addSeries(2);
      // name already used
      schema.setSeriesName(2, "x25");
      expectException();
    } catch (Exception e) {
      assertException(e, D.D30153);
    }
  }
View Full Code Here

TOP

Related Classes of ch.agent.crnickl.api.UpdatableSchema

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.