Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.Schema


    Surrogate s = schema.getSurrogate();
    MongoDatabase database = (MongoDatabase) s.getDatabase();
    try {
      check(Permission.MODIFY, schema);
      UpdatableSchema original = database.getReadMethodsForSchema().getSchema(s);
      Schema base = schema.getBase();
      if (base != null && !base.equals(original.getBase()))
        check(Permission.READ, base);
      DBCollection coll = getMongoDB(s).getSchemas();
      // full replace (no need to set _id in full update)
      com.mongodb.DBObject operation = mongoObject(
          MongoDatabase.FLD_SCHEMA_NAME, schema.getName(),
View Full Code Here


      cursor = getMongoDB(db).getAttributes().find(mongoObject(
          MongoDatabase.FLD_ATTR_PROP, getId(property)));
      while (cursor.hasNext()) {
        ObjectId chrOid = ((BasicDBObject) cursor.next()).getObjectId(MongoDatabase.FLD_ATTR_CHRON);
        Surrogate entityKey = makeSurrogate(db, DBObjectType.CHRONICLE, chrOid);
        Schema s = db.getChronicle(entityKey).getSchema(true);
        if (s.dependsOnSchema(schema)) {
          result = entityKey;
          break;
        }
      }
    } catch (Exception e) {
View Full Code Here

        cursor2 = getMongoDB(db).getSeries().find(mongoObject(
            MongoDatabase.FLD_SER_CHRON, chronicleOid,
            MongoDatabase.FLD_SER_NUM, ss.getNumber()));
        while (cursor2.hasNext()) {
          Surrogate entityKey = makeSurrogate(db, DBObjectType.CHRONICLE, chronicleOid);
          Schema s = db.getChronicle(entityKey).getSchema(true);
          if (s.dependsOnSchema(schema)) {
            result = entityKey;
            break OUTER;
          }
        }
      }
View Full Code Here

      chronicle.getSurrogate().getDatabase().getNamingPolicy().checkSimpleName(name, false); // defensive
      String description = chronicle.getDescription(false);
      if (description == null)
        description = "";
      Chronicle collection = chronicle.getCollection();
      Schema schema = chronicle.getSchema(false);
      if (collection != null) {
        check(Permission.MODIFY, collection);
        if (schema != null && schema.equals(collection.getSchema(true)))
          schema = null; // don't repeat yourself
      }
      if (schema != null)
        check(Permission.READ, schema);
      DBObjectId ox = insert(chronicle);
View Full Code Here

        if (!origAttrDef.isErasing())
          policy.willDeleteOrErase(schema, seriesDef, origAttrDef);
        // deleting an erasing attribute is like adding the series
      } else {
        if (attrDef.isErasing()) {
          Schema resolved = schema.resolve();
          AttributeDefinition<?> def = resolved.getAttributeDefinition(attrDef.getNumber(), false);
          if (def != null)
            policy.willDeleteOrErase(schema, seriesDef, def);
        } else {
          // schema should have been resolved so don't check for completeness
          if (origAttrDef != null)
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

    return result;
  }

  @Override
  public Schema getSchema(boolean effective) throws T2DBException {
    Schema result = null;
    if (schema != null)
      result = schema;
    else {
      if (getSurrogate().inConstruction()) {
        if (effective && collection != null)
View Full Code Here

   *
   * @param attributes a collection of attributes
   * @throws T2DBException
   */
  public void updateAttributes(Collection<Attribute<?>> attributes) throws T2DBException {
    Schema schema = getSchema(true);
    if (schema == null)
      throw T2DBMsg.exception(D.D30115);
    for (Attribute<?> attribute : attributes) {
      Property<?> property = attribute.getProperty();
      ValueType<?> type = property.getValueType();
      AttributeDefinition<?> def = schema.getAttributeDefinition(property.getName(), true);
      if (def == null)
        throw T2DBMsg.exception(D.D30114, property.getName());
      String value = type.toString(attribute.get());
      if (value == null || value.length() == 0) {
        getDatabase().deleteAttributeValue(this, def);
View Full Code Here

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

   * @param rawData a raw data object
   * @throws T2DBException
   */
  public ChronicleImpl(RawData rawData) throws T2DBException {
    super(rawData.getSurrogate());
    Schema schema = null;
    if (rawData.getSchema() != null)
      schema = getDatabase().getSchema(rawData.getSchema());
    data = new Data();
    data.name = rawData.getName();
    data.description = rawData.getDescription();
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.