Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.Schema


    }
  }
 
  public void test_delete_chronicle_attribute_via_base_with_actual_values() {
    try {
      Schema schema3 = db.getSchemas("schema3").iterator().next();
      UpdatableChronicle chro = db.getTopChronicle().edit().createChronicle("schema3chro", false, "test chronicle", null, schema3);
      chro.applyUpdates();
      // use the attribute
      Attribute<?> a = chro.getAttribute("prop1", true);
      a.scan("t1v3");
View Full Code Here


    }
  }

  public void test_set_chronicle_attribute_with_value_same_as_default() {
    try {
      Schema schema1 = db.getSchemas("schema1a").iterator().next();
      UpdatableChronicle chro = db.getTopChronicle().edit().createChronicle("schema1achro2", false, "test chronicle", null, schema1);
      chro.applyUpdates();
      // use the attribute
      Attribute<?> a = chro.getAttribute("prop1", true);
      assertEquals("t1v1", schema1.getAttributeDefinition("prop1", false).getValue().toString());
      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());
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 createSchema(UpdatableSchema schema) throws T2DBException {
    Surrogate surrogate = null;
    Throwable cause = null;
    try {
      check(Permission.CREATE, schema);
      Schema base = schema.getBase();
      if (base != null)
        check(Permission.READ, base);
      create_schema = open(CREATE_SCHEMA, schema, create_schema);
      create_schema.setInt(1, getIdOrZero(base));
      create_schema.setString(2, schema.getName());
View Full Code Here

    RawSchema rawSchema = getRawSchema(schema.getSurrogate());
    boolean nameEdited = nameEdited(schema, rawSchema);
    boolean baseEdited = baseEdited(schema, rawSchema);
    if (nameEdited || baseEdited) {
      try {
        Schema base = schema.getBase();
        check(Permission.MODIFY, schema);
        if (baseEdited && base != null)
          check(Permission.READ, base);
        update_schema = open(UPDATE_SCHEMA, schema, update_schema);
        update_schema.setString(1, schema.getName());
View Full Code Here

      find_entity_with_property = open(FIND_ENTITY_WITH_PROPERTY, property, find_entity_with_property);
      find_entity_with_property.setInt(1, getId(property));
      ResultSet rs = find_entity_with_property.executeQuery();
      while(rs.next()) {
        Surrogate entityKey = makeSurrogate(database, DBObjectType.CHRONICLE, rs.getInt(1));
        Schema s = database.getChronicle(entityKey).getSchema(true);
        if (s.dependsOnSchema(schema)) {
          result = entityKey;
          break;
        }
      }
    } catch (Exception e) {
View Full Code Here

      find_entity_with_series = open(FIND_ENTITY_WITH_SERIES, database, find_entity_with_series);
      find_entity_with_series.setInt(1, ss.getNumber());
      ResultSet rs = find_entity_with_series.executeQuery();
      while (rs.next()) {
        Surrogate entityKey = makeSurrogate(database, DBObjectType.CHRONICLE, rs.getInt(1));
        Schema s = database.getChronicle(entityKey).getSchema(true);
        if (s.dependsOnSchema(schema)) {
          result = entityKey;
          break;
        }
      }
    } catch (Exception e) {
View Full Code Here

      ((DatabaseBackend)chronicle.getSurrogate().getDatabase()).getNamingPolicy().checkSimpleName(name, false); // redundant but bugs exist
      String description = chronicle.getDescription(false);
      if (description == null)
        description = "";
      Chronicle collection = chronicle.getCollection();
      Schema schema = chronicle.getSchema(false);
      if (collection != null) {
        check(Permission.MODIFY, collection);
        if (schema != null && schema.equals(collection.getSchema(true)))
          schema = null; // don't repeat yourself
      }
      if (schema != null)
        check(Permission.READ, schema);
      create_entity = open(CREATE_ENTITY, chronicle, create_entity);
View Full Code Here

  public void createSchema(UpdatableSchema schema) throws T2DBException {
    Surrogate surrogate = null;
    Throwable cause = null;
    try {
      check(Permission.CREATE, schema);
      Schema base = schema.getBase();
      if (base != null)
        check(Permission.READ, base);
      DBObjectId ox = insert(schema);
      surrogate = makeSurrogate(schema, ox);
    } catch (Exception e) {
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.