Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.Chronicle


  }
 
  @Override
  public Chronicle findChronicle(String fullName, boolean mustExist) throws T2DBException {
    DatabaseCache cache = getDatabase().getCache();
    Chronicle chronicle = cache.lookUpChronicle(fullName);
    if (chronicle == null) {
      String[] parts = getDatabase().getNamingPolicy().split(fullName);
      if (parts[0] == null) {
        chronicle = getDatabase().getTopChronicle();
        boolean isNameSpace = chronicle.getName(true).equals(fullName);
        if (getDatabase().isStrictNameSpaceMode()) {
          // it must be the name space itself
          if (!isNameSpace)
            throw T2DBMsg.exception(D.D40103, chronicle.getName(true), fullName);
        } else {
          // tolerate name space
          if (!isNameSpace) {
            chronicle = chronicle.getChronicle(parts[1], mustExist);
            // cache top level entities
            if (chronicle != null)
              cache.store((ChronicleImpl)chronicle);
          }
        }
      } else {
        chronicle = findChronicle(parts[0], true);
        // cache entities with children
        cache.store((ChronicleImpl)chronicle);
        chronicle = chronicle.getChronicle(parts[1], mustExist);
        // cache the chronicle if it has a schema ?
      }
    }
    return chronicle;
  }
View Full Code Here


  @Override
  public Schema getSchema(boolean effective) throws T2DBException {
    getData();
    Schema es = data.schema;
    if (effective && es == null) {
      Chronicle c = getCollection();
      if (c != null)
        es = c.getSchema(effective);
    }
    return es;
  }
View Full Code Here

  }
 
  @Override
  public List<String> getNames() throws T2DBException {
    List<String> names = null;
    Chronicle collection = getCollection();
    if (collection != null)
      names = collection.getNames();
    else {
      names = new ArrayList<String>();
      names.add(getDatabase().getTopChronicle().getName(false));
    }
    names.add(getName(false));
View Full Code Here

  }

  @Override
  public List<String> getDescriptions() throws T2DBException {
    List<String> descriptions = null;
    Chronicle collection = getCollection();
    if (collection != null)
      descriptions = collection.getDescriptions();
    else {
      descriptions = new ArrayList<String>();
      descriptions.add(getDatabase().getTopChronicle().getDescription(false));
    }
    descriptions.add(getDescription(false));
View Full Code Here

    } else {
      AttributeDefinition<?> def = esch.getAttributeDefinition(attrName, mustExist);
      if (def != null) {
        attribute = def.getAttribute();
        List<Chronicle> chronicles = new ArrayList<Chronicle>();
        Chronicle chronicle = this;
        int lastChronicleWithSchema = 0;
        while (chronicle != null && !chronicle.isTopChronicle()) {
          // if chronicle has schema and schema does not have the attribute then break
          Schema sch = chronicle.getSchema(false);
          if (sch != null) {
            if (sch.getAttributeDefinition(def.getNumber(), false) == null)
              break;
            lastChronicleWithSchema = chronicles.size();
          }
          chronicles.add(chronicle);
          chronicle = chronicle.getCollection();
        }
        chronicles = chronicles.subList(0, lastChronicleWithSchema + 1);
        getDatabase().getAttributeValue(chronicles, attribute);
       
      // if not found, the attribute has the default value already set, so do nothing
View Full Code Here

    return  id > 0 && id == other.id;
  }
  @Override
  public String toString() {
    if (string == null) {
      Chronicle top = db.getTopChronicle();
      string = String.format("%s-%d-%d", top == null ? null : top.toString() , dot.ordinal(), id);
    }
    return string;
  }
View Full Code Here

    String seriesName = es[1];
    UpdatableSeries<T> series = null;
    if (chronicleName == null) {
      throw T2DBMsg.exception(D.D50116, name);
    } else {
      Chronicle ent = getChronicle(chronicleName, mustExist);
      if (ent != null) {
        UpdatableChronicle updEnt = ent.edit();
        series = updEnt.updateSeries(seriesName);
        if (series == null && mustExist)
          series = updEnt.createSeries(seriesName);
      }
    }
View Full Code Here

  public <T> Series<T> getSeries(String name, boolean mustExist) throws T2DBException {
    Series<T> series = null;
    String[] split = getNamingPolicy().split(name);
    if (split[0] == null)
      throw T2DBMsg.exception(D.D50116, name);
    Chronicle chronicle = getChronicle(split[0], mustExist);
    if (chronicle != null) {
      Series<T>[] s = chronicle.getSeries(new String[]{split[1]}, null, mustExist);
      series = s[0];
    }
    if (series == null && mustExist)
      throw T2DBMsg.exception(D.D50106, name);
    return series;
View Full Code Here

  }

  @Override
  public Chronicle getChronicle(Surrogate surrogate) throws T2DBException {
    checkSurrogate(surrogate, DBObjectType.CHRONICLE);
    Chronicle chronicle = new ChronicleImpl(surrogate);
    chronicle.getName(false); // side-effect: make sure it exists
    return chronicle;
  }
View Full Code Here

 
 
  @Override
  public String toString() {
    if (string == null) {
      Chronicle top = db.getTopChronicle();
      string = String.format("%s-%d-%s", top == null ? null : top.toString() , dot.ordinal(),
          (id == null ? "null" : id.toString()));
    }
    return string;
  }
View Full Code Here

TOP

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

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.