Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.Chronicle


    return result;
  }

  @Override
  public Chronicle getCollection() throws T2DBException {
    Chronicle result = null;
    if (collection != null)
      result = collection;
    else if (!getSurrogate().inConstruction())
      result = super.getCollection();
    return result;
View Full Code Here


   
    if (schema instanceof UpdatableSchema)
      throw T2DBMsg.exception(D.D40104, getName(true), schema.getName());
   
    String name = getDatabase().getNamingPolicy().checkSimpleName(orig,  tweakable);
    Chronicle current = getChronicle(name, false);
    if (current != null) {
      if (tweakable) {
        name = findNextAvailableName(name, 2, 9);
        if (name == null)
          throw T2DBMsg.exception(D.D40127, name, getName(true));
View Full Code Here

 
  private boolean updateIfModified() throws T2DBException {
    boolean anything = false;
    String name = getName(false);
    String description = getDescription(false);
    Chronicle current = getDatabase().getChronicle(this);
    Chronicle collection = getCollection();
    Schema schema = getSchema(false);
    if (!equals(name, current.getName(false))) {
      getDatabase().getNamingPolicy().checkSimpleName(name, false);
      anything = true;
    }
View Full Code Here

  public Chronicle getChronicle(Surrogate s) throws T2DBException {
    DBObject obj = getObject(s, false);
    Throwable cause = null;
    if (obj != null)
      try {
        Chronicle chronicle = unpack(s.getDatabase(), (BasicDBObject) obj);
        check(Permission.READ, chronicle);
        return chronicle;
      } catch (Exception e) {
        cause = e;
      }
View Full Code Here

      Database database = parent.getDatabase();
      DBObject obj = getMongoDB(database).getChronicles().findOne(
          mongoObject(MongoDatabase.FLD_CHRON_PARENT, getIdOrZero(parent),
          MongoDatabase.FLD_CHRON_NAME, name));
      if (obj != null) {
        Chronicle chronicle = unpack(database, (BasicDBObject) obj);
        check(Permission.READ, chronicle);
        return chronicle;
      } else
        return null;
    } catch (Exception e) {
View Full Code Here

        Database db = parent.getDatabase();
        DBCursor cursor = getMongoDB(db).getChronicles().find(
            mongoObject(MongoDatabase.FLD_CHRON_PARENT, getIdOrZero(parent)));
        try {
          while (cursor.hasNext()) {
            Chronicle chronicle = unpack(db, (BasicDBObject) cursor.next());
            check(Permission.READ, chronicle);
            result.add(chronicle);
          }
        } finally {
          cursor.close();
View Full Code Here

    Throwable cause = null;
    if (obj != null)
      try {
        ObjectId chrOid = obj.getObjectId(MongoDatabase.FLD_SER_CHRON);
        int serNum = obj.getInt(MongoDatabase.FLD_SER_NUM);
        Chronicle chronicle = new ChronicleImpl(
            makeSurrogate(s.getDatabase(), DBObjectType.CHRONICLE, chrOid));
        check(Permission.READ, chronicle);
        Series<T> series = new SeriesImpl<T>(chronicle, null, serNum, s);
        return series;
      } catch (Exception e) {
View Full Code Here

      ObjectId parentId = obj.getObjectId(MongoDatabase.FLD_CHRON_PARENT);
      data.setCollection(parentId == null ? db.getTopChronicle() :
        new ChronicleImpl(makeSurrogate(db, DBObjectType.CHRONICLE, parentId)));
      ObjectId schemaId = obj.getObjectId(MongoDatabase.FLD_CHRON_SCHEMA);
      data.setSchema(schemaId == null ? null : makeSurrogate(db, DBObjectType.SCHEMA, schemaId));
      Chronicle chronicle = new ChronicleImpl(data);
      return chronicle;
    } catch (ClassCastException e) {
      throw T2DBMMsg.exception(e, J.J81010, obj.toString());
    }
  }
View Full Code Here

  private static final String SIMPLENAME_UPDATED = "entitytest2";
 
  @Override
  protected void firstSetUp() throws Exception {
    db = getContext().getDatabase();
    Chronicle testData = db.getChronicle(FULLNAME, false);
    if (testData != null) {
      Util.deleteChronicleCollection(testData);
      UpdatableChronicle upd = testData.edit();
      upd.destroy();
      upd.applyUpdates();
      db.commit();
    }
  }
View Full Code Here

    }
  }

  public void test052_get_attribute() {
    try {
      Chronicle ent = db.getChronicle("bt.fooent", true);
      Attribute<String> attr = ent.getAttribute("foo property", true).typeCheck(String.class);
      assertEquals("baz", attr.get());
      assertEquals("this is baz", attr.getDescription(true));
      assertEquals(null, attr.getDescription(false));
      assertEquals("this is baz", attr.getProperty().getValueType().getValueDescriptions().get("baz"));
      AttributeDefinition<String> def = ent.getSchema(true).getAttributeDefinition("foo property", true).typeCheck(String.class);
      assertEquals("bar", def.getAttribute().get());
      assertEquals("it's bar", def.getAttribute().getDescription(true));
      assertEquals(null, def.getAttribute().getDescription(false));
    } catch (Exception e) {
      fail(e.getMessage());
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.