Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.UpdatableSchema


  public void test_420_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_440_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

    Collection<Schema> schemas = db.getSchemas(SCHEMA);
    switch (schemas.size()) {
    case 1:
      return schemas.iterator().next();
    case 0:
      UpdatableSchema s = db.createSchema(SCHEMA, null);
      s.addSeries(1);
      s.setSeriesName(1, db.getNamingPolicy().split(SERIES)[1]);
      s.setSeriesType(1, SERIES_TYPE);
      s.setSeriesTimeDomain(1, SERIES_DOMAIN);
      s.setSeriesSparsity(1, isSparse());
      s.applyUpdates();
      return s.resolve();
    default:
      throw new IllegalArgumentException(SCHEMA + ": " + schemas.size());
    }
  }
View Full Code Here

    }
  }

  public void test_rename_schema1_schema1a() {
    try {
      UpdatableSchema schema1 = db.getSchemas("schema1").iterator().next().edit();
      schema1.setName("schema1a");
      schema1.applyUpdates();
      assertEquals(1, db.getSchemas("schema1a").size());
    } catch (Exception e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

    }
  }
 
  public void test_create_schema3_for_base_of_schema1a() {
    try {
      UpdatableSchema schema3 = db.createSchema("schema3", null);
      schema3.applyUpdates();
      UpdatableSchema schema1 = db.getSchemas("schema1a").iterator().next().edit();
      schema1.setBase(schema3);
      schema1.applyUpdates();
      assertEquals(schema3, schema1.getBase());
    } catch (Exception e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

    }
  }
 
  public void test_reset_base_of_schema1a() {
    try {
      UpdatableSchema schema1 = db.getSchemas("schema1a").iterator().next().edit();
      schema1.setBase(null);
      schema1.applyUpdates();
      assertEquals(null, schema1.getBase());
    } catch (Exception e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

    }
  }
 
  public void test_cannot_set_base_to_schema_in_construction() {
    try {
      UpdatableSchema schema4 = db.createSchema("schema4", null);
      schema4.addAttribute(1);
      schema4.setAttributeProperty(1, db.getProperty("prop1", true));
      schema4.setAttributeDefault(1, "t1v1");
//      schema4.applyUpdates();
      UpdatableSchema schema1 = db.getSchemas("schema1a").iterator().next().edit();
      schema1.setBase(schema4);
      expectException();
    } catch (Exception e) {
      assertException(e, D.D30128);
    }
  }
View Full Code Here

      assertException(e, D.D30128);
    }
  }

  public void test_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);
      schema1.applyUpdates();
      expectException();
    } catch (Exception e) {
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.