Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.Schema


  }

  @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);
    }
View Full Code Here


  }

  @Override
  public Attribute<?> getAttribute(String attrName, boolean mustExist) throws T2DBException {
    Attribute<?> attribute = null;
    Schema esch = getSchema(true);
    if (esch == null) {
      if (mustExist)
        throw T2DBMsg.exception(D.D40114, getName(true));
    } 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();
View Full Code Here

  }
 
  @Override
  public <T> Series<T>[] getSeries(String[] names, Class<T> type, boolean mustBeDefined) throws T2DBException {
    int[] seriesNr = new int[names.length];
    Schema es = getSchema(true);
    if (es == null)
      throw T2DBMsg.exception(D.D40114, getName(true));
    for (int i = 0; i < names.length; i++) {
      SeriesDefinition ss = es.getSeriesDefinition(names[i], mustBeDefined);
      seriesNr[i] = ss == null ? 0 : ss.getNumber();
    }
    Series<T>[] series = getDatabase().getSeries(this, names, seriesNr);
    if (type != null) {
      for (Series<T> s : series) {
View Full Code Here

  }

  @Override
  public Collection<Attribute<?>> getAttributes() throws T2DBException {
    Collection<Attribute<?>> result = new ArrayList<Attribute<?>>();
    Schema schema = getSchema(true);
    if (schema != null) {
      Collection<AttributeDefinition<?>> defs = schema.getAttributeDefinitions();
      for (AttributeDefinition<?> def : defs) {
        if (!def.isComplete())
          throw T2DBMsg.exception(D.D40115, getName(true), def.getNumber());
        result.add(getAttribute(def.getName(), true));
      }
View Full Code Here

  }

  @Override
  public Collection<Series<?>> getSeries() throws T2DBException {
    Collection<Series<?>> result = new ArrayList<Series<?>>();
    Schema schema = getSchema(true);
    if (schema != null) {
      Collection<SeriesDefinition> sss = schema.getSeriesDefinitions();
      String[] names = new String[sss.size()];
      int i = 0;
      for (SeriesDefinition ss : sss) {
        names[i++] = ss.getName();
      }
View Full Code Here

  @Override
  public ChronicleImpl store(ChronicleImpl entity) throws T2DBException {
    ChronicleImpl copy = null;
    if (!entity.isTopChronicle() && lookUpChronicle(entity.getSurrogate()) == null) {
      Schema schema = entity.getSchema(false);
      schema = ref((SchemaImpl) schema);
      copy = new ChronicleImpl(entity.getName(false), entity.getDescription(false),
          entity.getCollection(), schema, entity.getSurrogate());
      put(copy);
//      int log4j; message(Level.INFO, String.format("*** CACHE ADD: %s %s %d", entity.toString(), entity.getKey().toString(), size()));
View Full Code Here

    return copy;
  }

  private void remove(ChronicleImpl entity) {
    try {
      Schema schema = entity.getSchema(false);
      if (schema != null)
        unRef((SchemaImpl) schema);
      byNameCache.remove(entity.getName(true));
    } catch (T2DBException e) {
      // never happens since entity in cache has full info
View Full Code Here

    }
    List<Surrogate> keys = new ArrayList<Surrogate>(schemaList.size());
    for (Schema sch : schemaList) {
      keys.add(sch.getSurrogate());
    }
    Schema finalResult = result.consolidate(getName(), getSurrogate(), keys);
   
    // ensure all components are complete
    for (AttributeDefinition<?> ad : finalResult.getAttributeDefinitions()) {
      if (!ad.isComplete())
        throw T2DBMsg.exception(D.D30111, getName(), ad.getNumber());
    }
    for (SeriesDefinition sd : finalResult.getSeriesDefinitions()) {
      for (AttributeDefinition<?> ad : sd.getAttributeDefinitions()) {
        if (!ad.isComplete())
          throw T2DBMsg.exception(D.D30113, getName(), ad.getNumber(), sd.getNumber());
      }
      if (!sd.isComplete())
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.