Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.UpdatableSchema


  public void willDelete(UpdatableSchema schema, SeriesDefinition ss) throws T2DBException {
    Set<UpdatableSchema> schemas = findDependentSchemas(schema);
    // remove those schemas where the series was "erased"
    Iterator<UpdatableSchema> it = schemas.iterator();
    while(it.hasNext()) {
      UpdatableSchema s = it.next();
      if (s.getSeriesDefinition(ss.getNumber(), false) == null)
        it.remove();
    }
   
    Collection<Surrogate> entities = database.findChronicles(ss, schemas);
    if (entities.size() > 0)
View Full Code Here


 
  @Override
  public UpdatableSchema createSchema(String name, String nameOfBase) throws T2DBException {
    if (getSchemas(name).size() > 0)
      throw T2DBMsg.exception(D.D30108, name);
    UpdatableSchema base = null;
    if (nameOfBase != null && nameOfBase.length() > 0) {
      Collection<UpdatableSchema> list = getUpdatableSchemas(nameOfBase);
      if (list.size() != 1)
        throw T2DBMsg.exception(D.D30109, name, nameOfBase);
      base = list.iterator().next();
View Full Code Here

   * additional series, and additional series attributes.
   */
  @Override
  public void willUpdate(UpdatableSchema s) throws T2DBException {
    UpdatableSchemaImpl schema = (UpdatableSchemaImpl) s;
    UpdatableSchema base = schema.getBase();
    UpdatableSchema previousBase = schema.getPreviousBase();
    boolean baseEdited = false;
    if (base != null)
      baseEdited = !base.equals(previousBase);
    else if (previousBase != null)
      baseEdited = true;
View Full Code Here

   * Invoke only when base and edited base differ.
   */
  private void willUpdateBase(UpdatableSchema s) throws T2DBException {
    UpdatableSchemaImpl schema = (UpdatableSchemaImpl) s;
    String baseSchemaName = schema.getBase() == null ? null : schema.getBase().getName();
    UpdatableSchema currentUES = new UpdatableSchemaImpl(schema.getName(),
        schema.getPreviousBase(), schema.getAttributeDefinitions(), schema.getSeriesDefinitions(),
        schema.getSurrogate());
    UpdatableSchema editedUES = new UpdatableSchemaImpl(schema.getName(),
        schema.getBase(), schema.getAttributeDefinitions(), schema.getSeriesDefinitions(),
        schema.getSurrogate());
    Schema current = database.resolve(currentUES);
    Schema edited = database.resolve(editedUES);
    if (current.getAttributeDefinitions().size() > edited.getAttributeDefinitions().size())
View Full Code Here

   
    Set<UpdatableSchema> schemas = findDependentSchemas(schema);
    // remove those schemas where the attribute was "erased"
    Iterator<UpdatableSchema> it = schemas.iterator();
    while(it.hasNext()) {
      UpdatableSchema s = it.next();
      if (s.getAttributeDefinition(def.getNumber(), false) == null)
        it.remove();
    }
   
    Collection<Surrogate> entities = database.findChronicles(def.getProperty(), schemas);
    if (entities.size() > 0)
View Full Code Here

    String name = schema.getName();
    Set<UpdatableSchema> result = new HashSet<UpdatableSchema>();
    result.add(schema);
    Set<String> cycleDetector = new LinkedHashSet<String>();
    for (UpdatableSchema s : schemas) {
      UpdatableSchema base = s.getBase();
      cycleDetector.clear();
      cycleDetector.add(s.getName());
      while (base != null) {
        if (base.getName().equals(name)) {
          if (!cycleDetector.add(base.getName()))
            throw T2DBMsg.exception(D.D30147, schema.getName(), cycleDetector.toString());
          result.add(s);
          break;
        } else
          base = base.getBase();
      }
    }
    return result;
  }
View Full Code Here

 
  @Override
  public UpdatableSchema createSchema(String name, String nameOfBase) throws T2DBException {
    if (getSchemas(name).size() > 0)
      throw T2DBMsg.exception(D.D30108, name);
    UpdatableSchema base = null;
    if (nameOfBase != null && nameOfBase.length() > 0) {
      Collection<UpdatableSchema> list = getUpdatableSchemas(nameOfBase);
      if (list.size() != 1)
        throw T2DBMsg.exception(D.D30109, name, nameOfBase);
      base = list.iterator().next();
View Full Code Here

    return getReadMethodsForSchema().getSchemaSurrogateList(this, pattern);
  }

  @Override
  public UpdatableSchema getUpdatableSchema(Surrogate surrogate) throws T2DBException {
    UpdatableSchema schema = getReadMethodsForSchema().getSchema(surrogate);
    if (schema == null)
      throw T2DBMsg.exception(E.E30109, surrogate.toString());
    return schema;
  }
View Full Code Here

    }
  }
 
  public void test028_create_schema() {
    try {
      UpdatableSchema schema = db.createSchema("foo schema", null);
      schema.addAttribute(2);
      schema.setAttributeProperty(2, db.getProperty("foo property", true));
      schema.setAttributeDefault(2, "bar");
      schema.addSeries(1);
      schema.setSeriesName(1, "fooser");
      schema.setSeriesType(1, "numeric");
      schema.setSeriesTimeDomain(1, Day.DOMAIN);
      schema.applyUpdates();
      assertEquals("foo property", db.getSchemas("foo schema").iterator().next().
          getAttributeDefinition(2, true).getName());
    } catch (Exception e) {
      fail(e.getMessage());
    }
View Full Code Here

  private static final String SERIES2 = CHRONICLE + ".seriestest.test";

  @Override
  protected void firstSetUp() throws Exception {
    db = getContext().getDatabase();
    UpdatableSchema s = db.createSchema(SCHEMA, null);
    s.addSeries(1);
    s.setSeriesName(1, "test");
    s.setSeriesType(1, "numeric");
    s.setSeriesTimeDomain(1, Day.DOMAIN);
    s.applyUpdates();
    String split[] = db.getNamingPolicy().split(CHRONICLE);
    UpdatableChronicle c = db.getTopChronicle().edit()
        .createChronicle(split[1], false, "test entity", null, s.resolve());
    c.applyUpdates();
    db.commit();
  }
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.