Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.Schema


    return result;
  }

  @Override
  public Schema getSchema(boolean effective) throws T2DBException {
    Schema result = null;
    if (schema != null)
      result = schema;
    else {
      if (getSurrogate().inConstruction()) {
        if (effective && collection != null)
View Full Code Here


   *
   * @param attributes a collection of attributes
   * @throws T2DBException
   */
  public void updateAttributes(Collection<Attribute<?>> attributes) throws T2DBException {
    Schema schema = getSchema(true);
    if (schema == null)
      throw T2DBMsg.exception(D.D30115);
    for (Attribute<?> attribute : attributes) {
      Property<?> property = attribute.getProperty();
      ValueType<?> type = property.getValueType();
      AttributeDefinition<?> def = schema.getAttributeDefinition(property.getName(), true);
      if (def == null)
        throw T2DBMsg.exception(D.D30114, property.getName());
      String value = type.toString(attribute.get());
      if (value == null || value.length() == 0) {
        getDatabase().deleteAttributeValue(this, def);
View Full Code Here

    boolean anything = false;
    String name = getName(false);
    String description = getDescription(false);
    Chronicle current = getDatabase().getChronicle(this);
    Chronicle collection = getCollection();
    Schema schema = getSchema(false);
    if (!equals(name, current.getName(false))) {
      getDatabase().getNamingPolicy().checkSimpleName(name, false);
      anything = true;
    }
    if (!equals(description, current.getDescription(false))) {
View Full Code Here

    }
  }
 
  public void test032_create_entity() {
    try {
      Schema schema = db.getSchemas("foo schema").iterator().next();
      UpdatableChronicle ent = db.getTopChronicle().edit().createChronicle("fooent", false, "foo entity", null, schema);
      ent.getAttribute("foo property", true);
      ent.applyUpdates();
      assertNotNull(ent.getAttribute("foo property", false));
      assertNull(ent.getAttribute("bar property", false));
View Full Code Here

 
  public void test_20() {
    try {
      Chronicle chronicle = db.getChronicle(CHRONICLE, true);
      assertEquals(1, chronicle.getSchema(true).getSeriesDefinitions().size());
      Schema s0 = chronicle.getSchema(true);
      UpdatableSchema usch = s0.edit();
      usch.addSeries(4);
      usch.setSeriesName(4, "test4");
      usch.setSeriesType(4, "numeric");
      usch.setSeriesTimeDomain(4, Day.DOMAIN);
      assertEquals(2, usch.getSeriesDefinitions().size());
View Full Code Here

  }
 
  public void test_190_create_chronicle_with_empty_schema_okay() {
    try {
      // creating a chronicle with an empty schema should be possible
      Schema schema = db.getSchemas("schema5").iterator().next();
      UpdatableChronicle chro = db.getTopChronicle().edit().createChronicle("schema5chro", false, "test chronicle", null, schema);
      chro.applyUpdates();
    } catch (Exception e) {
      fail(e.getMessage());
    }
View Full Code Here

    }
  }
 
  public void test_200_create_sub_chronicle_with_schema_inherited() {
    try {
      Schema schema = db.getSchemas("schema5").iterator().next();
      UpdatableChronicle chro = db.getChronicle("bt.schema5chro", true).edit();
      assertEquals(schema, chro.getSchema(false));
      chro.createChronicle("sub", false, "sub test", null, null).applyUpdates();
      Chronicle sub = db.getChronicle("bt.schema5chro.sub", true);
      assertEquals(schema, sub.getSchema(true));
View Full Code Here

  }
 
  public void test_230_define_series_in_schema1() {
    try {
      UpdatableSchema schema1 = db.getSchemas("schema1").iterator().next().edit();
      Schema schema2 = db.getSchemas("schema2").iterator().next();
      schema1.addSeries(1);
      schema1.setSeriesName(1, "foo");
      schema1.setSeriesDescription(1, "foo series");
      schema1.setSeriesTimeDomain(1, Workday.DOMAIN);
      schema1.setSeriesType(1, db.getValueType("numeric"));
      schema1.addAttribute(1, 6);
      schema1.setAttributeProperty(1, 6, db.getProperty("prop2", true));
      schema1.setAttributeDefault(1, 6, "t2v2");
      schema1.applyUpdates();
      assertEquals("foo", schema1.getSeriesDefinition(1, true).getName());
      assertEquals("foo series", schema1.getSeriesDefinition(1, true).getDescription());
      assertEquals(null, schema2.getSeriesDefinition(1, false));
    } catch (Exception e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

  public void test_290_create_schema4_based_on_schema1a_and_override_attribute() {
    UpdatableSchema schema1 = null;
    try {
      UpdatableSchema schema4 = db.createSchema("schema4", "schema1a");
      Schema s = schema4.resolve();
      assertEquals("prop1", s.getAttributeDefinition(1, true).getName());
      schema4.addAttribute(1);
      schema4.eraseAttribute(1);
      assertEquals(true, schema4.getAttributeDefinition(1, true).isErasing());
      assertEquals("fou", s.getSeriesDefinition(1, true).getName());
      schema4.setAttributeProperty(1, db.getProperty("prop1", true));
      schema4.setAttributeDefault(1, "t1v1");
      schema4.applyUpdates();
      schema1 = db.getSchemas("schema1a").iterator().next().edit();
      schema1.setBase(schema4);
View Full Code Here

  }
 
  public void test_300_add_series_to_schema4_but_dont_apply() {
    try {
      UpdatableSchema schema4 = db.getUpdatableSchemas("schema4").iterator().next();
      Schema s = schema4.resolve();
      assertEquals("fou", s.getSeriesDefinition(1, true).getName());
      schema4.addSeries(1);
      schema4.eraseSeries(1);
    } catch (Exception e) {
      fail(e.getMessage());
    }
View Full Code Here

TOP

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

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.