Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.Schema


  }

  @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

        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())
      throw T2DBMsg.exception(D.D30142, baseSchemaName);
    if (current.getSeriesDefinitions().size() > edited.getSeriesDefinitions().size())
      throw T2DBMsg.exception(D.D30143, baseSchemaName);
    for (AttributeDefinition<?> def : current.getAttributeDefinitions()) {
      if (!def.equals(edited.getAttributeDefinition(def.getNumber(), false)))
        throw T2DBMsg.exception(D.D30144, baseSchemaName, def.getNumber());
    }
    for (SeriesDefinition ss : current.getSeriesDefinitions()) {
      for (AttributeDefinition<?> def : current.getAttributeDefinitions()) {
        if (!def.equals(edited.getAttributeDefinition(def.getNumber(), false)))
          throw T2DBMsg.exception(D.D30145, baseSchemaName, def.getNumber(), ss.getNumber());
      }
    }
  }
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

  @Override
  public Attribute<?> getAttribute(String attrName, boolean mustExist) throws T2DBException {
    Attribute<?> result = attributesUpdate == null ? null : attributesUpdate.get(attrName);
    if (result == null) {
      if (getSurrogate().inConstruction()) {
        Schema esch = getSchema(true);
        if (esch == null) {
          if (mustExist)
            throw T2DBMsg.exception(D.D40114, getName(true));
        } else {
          AttributeDefinition<?> def = getSchema(true).getAttributeDefinition(attrName, mustExist);
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.