Examples of DBObject


Examples of com.mongodb.DBObject

    if ( storageStrategy == AssociationStorageStrategy.IN_ENTITY ) {
      throw new AssertionFailure( MongoHelpers.class.getName()
          + ".associationKeyToObject should not be called for associations embedded in entity documents");
    }
    Object[] columnValues = key.getColumnValues();
    DBObject columns = new BasicDBObject( columnValues.length );

    int i = 0;
    for ( String name : key.getColumnNames() ) {
      columns.put( name, columnValues[i++] );
    }

    BasicDBObject idObject = new BasicDBObject( 1 );

    if ( storageStrategy == AssociationStorageStrategy.GLOBAL_COLLECTION ) {
      columns.put( MongoDBDialect.TABLE_FIELDNAME, key.getTable() );
    }
    idObject.put( MongoDBDialect.ID_FIELDNAME, columns );
    return idObject;
  }
View Full Code Here

Examples of com.mongodb.DBObject

  }

  private void prepareForInsert(Map<DBCollection, BatchInsertionTask> inserts, MongoDBTupleSnapshot snapshot, EntityKey entityKey, Tuple tuple, WriteConcern writeConcern) {
    DBCollection collection = getCollection( entityKey );
    BatchInsertionTask batchInsertion = getOrCreateBatchInsertionTask( inserts, collection, writeConcern );
    DBObject document = getCurrentDocument( snapshot, batchInsertion, entityKey );
    DBObject newDocument = objectForInsert( tuple, document );
    inserts.get( collection ).put( entityKey, newDocument );
  }
View Full Code Here

Examples of com.mongodb.DBObject

    DBObject newDocument = objectForInsert( tuple, document );
    inserts.get( collection ).put( entityKey, newDocument );
  }

  private DBObject getCurrentDocument(MongoDBTupleSnapshot snapshot, BatchInsertionTask batchInsert, EntityKey entityKey) {
    DBObject fromBatchInsertion = batchInsert.get( entityKey );
    return fromBatchInsertion != null ? fromBatchInsertion : snapshot.getDbObject();
  }
View Full Code Here

Examples of com.mongodb.DBObject

      return cursor.hasNext();
    }

    @Override
    public Tuple next() {
      DBObject dbObject = cursor.next();
      return new Tuple( new MongoDBTupleSnapshot( dbObject, metadata, UPDATE ) );
    }
View Full Code Here

Examples of com.mongodb.DBObject

      String[] path = DOT_SEPARATOR_PATTERN.split( column );
      Object field = entity;
      int size = path.length;
      for (int index = 0 ; index < size ; index++) {
        String node = path[index];
        DBObject parent = (DBObject) field;
        field = parent.get( node );
        if ( field == null ) {
          if ( index == size - 1 ) {
            field = value;
          }
          else {
            field = new BasicDBObject();
          }
          parent.put( node, field );
        }
      }
    }
  }
View Full Code Here

Examples of com.mongodb.DBObject

    this.dbObject = document;
  }

  //not for embedded
  public DBObject getQueryObject() {
    DBObject query = new BasicDBObject();
    query.put( MongoDBDialect.ID_FIELDNAME, dbObject.get( MongoDBDialect.ID_FIELDNAME ) );
    return query;
  }
View Full Code Here

Examples of com.mongodb.DBObject

   *
   * @see com.sissi.persistent.PersistentElementBox#pull(com.sissi.context.JID)
   */
  @Override
  public Collection<Element> pull(JID jid) {
    DBObject query = BasicDBObjectBuilder.start().add(Dictionary.FIELD_TO, jid.asStringWithBare()).add("$or", this.activate).add(Dictionary.FIELD_CLASS, this.support).add(Dictionary.FIELD_RESEND, BasicDBObjectBuilder.start("$lt", this.resend).get()).get();
    Elements elements = new Elements(this.config.collection().find(query), this.elements);
    // {"$set:{"activate":false,"$inc":{"resend":1}}}
    this.config.collection().update(query, BasicDBObjectBuilder.start().add("$set", BasicDBObjectBuilder.start(Dictionary.FIELD_ACTIVATE, false).get()).add("$inc", BasicDBObjectBuilder.start(Dictionary.FIELD_RESEND, 1).get()).get(), false, true);
    return elements;
  }
View Full Code Here

Examples of com.mongodb.DBObject

   * @param bare
   * @return
   */
  protected MongoMucRelationContext remove(JID from, JID to, boolean bare) {
    // {"roles":bare == true ? jid:from.bare : path:from}
    DBObject remove = BasicDBObjectBuilder.start(Dictionary.FIELD_ROLES, bare ? BasicDBObjectBuilder.start(Dictionary.FIELD_JID, from.asStringWithBare()).get() : BasicDBObjectBuilder.start(Dictionary.FIELD_PATH, from.asString()).get()).get();
    if (ItemAffiliation.NONE.equals(this.ourRelation(from, to).cast(MucRelation.class).affiliation())) {
      // {"affiliations.jid":from.bare}
      // {"informaitons.jid":from.bare}
      remove.put(Dictionary.FIELD_AFFILIATIONS, BasicDBObjectBuilder.start(Dictionary.FIELD_JID, from.asStringWithBare()).get());
      remove.put(Dictionary.FIELD_INFORMATIONS, BasicDBObjectBuilder.start(Dictionary.FIELD_JID, from.asStringWithBare()).get());
    }
    // {"jid":to.bare,"role.path":from}, {"$inc":{"configs.maxusers":-1}, "$pull":...remove...}
    this.config.collection().update(BasicDBObjectBuilder.start().add(Dictionary.FIELD_JID, to.asStringWithBare()).add(Dictionary.FIELD_ROLES + "." + Dictionary.FIELD_PATH, from.asString()).get(), BasicDBObjectBuilder.start().add("$inc", this.countDecMaxUsers).add("$pull", remove).get(), false, false, WriteConcern.SAFE);
    return this;
  }
View Full Code Here

Examples of com.mongodb.DBObject

      }
    } catch (MongoException e) {
      String role = ItemRole.toString(this.mapping[this.vcardContext.exists(this.jidBuilder.build(relation.jid())) ? ItemAffiliation.parse(relation.cast(MucRelation.class).affiliation()).ordinal() : ItemAffiliation.OWNER.ordinal()]);
      // 如果已存在岗位(新增用户)
      if (this.affiliation(from, this.jidBuilder.build(relation.jid()), null) != null) {
        DBObject query = this.buildQuery(relation.jid());
        query.put(Dictionary.FIELD_AFFILIATIONS + "." + Dictionary.FIELD_JID, from.asStringWithBare());
        // {"jid":jid,"affiliations.jid":from.bare}, {"$inc":{"configs.maxusers":1},"$set":{"affiliations.nick":relation.name,"$addToSet":{"roles":全部属性}}
        this.config.collection().update(query, BasicDBObjectBuilder.start().add("$inc", this.countIncMaxUsers).add("$set", BasicDBObjectBuilder.start(Dictionary.FIELD_AFFILIATIONS + ".$." + Dictionary.FIELD_NICK, relation.name()).get()).add("$addToSet", BasicDBObjectBuilder.start().add(Dictionary.FIELD_ROLES, BasicDBObjectBuilder.start().add(Dictionary.FIELD_JID, from.asStringWithBare()).add(Dictionary.FIELD_PATH, from.asString()).add(Dictionary.FIELD_RESOURCE, from.resource()).add(Dictionary.FIELD_NICK, relation.name()).add(Dictionary.FIELD_ROLE, role).add(Dictionary.FIELD_ACTIVATE, System.currentTimeMillis()).get()).get()).get(), true, false, WriteConcern.SAFE);
      } else {
       
        // {"jid":jid}, {"$setOnInsert", {...plus...,"configs.activate":true,"creator":from.bare,"$inc":{"configs.maxusers":1},"$addToSet":{"affiliations":...全部属性...,"roles":...全部属性...}
View Full Code Here

Examples of com.mongodb.DBObject

    protected JIDGroup(List<?> db) {
      if (db == null) {
        return;
      }
      for (Object each : db) {
        DBObject jid = DBObject.class.cast(each);
        super.add(MongoMucRelationContext.this.jidBuilder.build(MongoUtils.asString(jid, Dictionary.FIELD_JID)).resource(MongoUtils.asString(jid, Dictionary.FIELD_RESOURCE)));
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.