Package com.mongodb

Examples of com.mongodb.DBObject


   * @see com.sissi.ucenter.relation.RelationContext#iSubscribedWho(com.sissi.context.JID)
   */
  @SuppressWarnings("deprecation")
  public Set<JID> iSubscribedWho(JID from) {
    // {"$match":{"affiliations.jid",from.bare,"affiliations.nick":{"$exists":true}}}
    DBObject match = BasicDBObjectBuilder.start("$match", BasicDBObjectBuilder.start().add(MongoConfig.FIELD_AFFILIATIONS + "." + MongoConfig.FIELD_JID, from.asStringWithBare()).add(MongoConfig.FIELD_AFFILIATIONS + "." + MongoConfig.FIELD_NICK, BasicDBObjectBuilder.start("$exists", true).get()).get()).get();
    return new JIDGroup(MongoUtils.asList(this.config.collection().aggregate(this.matchPersistent, match, super.unwindAffiliation, match, this.projectSubscribed).getCommandResult(), Dictionary.FIELD_RESULT));
  }
View Full Code Here


    private static final long serialVersionUID = 1L;

    private AffiliationRelations(List<?> affiliations) {
      for (Object each : affiliations) {
        DBObject affiliation = MongoUtils.asDBObject(DBObject.class.cast(each), Dictionary.FIELD_AFFILIATION);
        super.add(new NoneRelation(MongoMucRelation4AffiliationContext.this.jidBuilder.build(MongoUtils.asString(affiliation, Dictionary.FIELD_JID)), ItemAffiliation.parse(MongoUtils.asString(affiliation, Dictionary.FIELD_AFFILIATION))));
      }
    }
View Full Code Here

   * @param jid
   * @param status
   * @return
   */
  private DBObject buildQueryWithStates(String role, String jid, DBObject[] status) {
    DBObject query = this.buildQueryWithRole(role, jid);
    query.put("$or", status);
    return query;
  }
View Full Code Here

    this.config = config;
    this.groups = groups;
  }

  public Relation ourRelation(JID from, JID to) {
    DBObject db = this.config.collection().findOne(this.buildQuery(from.asStringWithBare(), to.asStringWithBare()));
    return db != null ? new MongoRosterRelation(db, Dictionary.FIELD_SLAVE, this.groups, this.plus) : new DefaultRelation(to, RosterSubscription.NONE.toString());
  }
View Full Code Here

   * 1,符合条件唯一JIDContext</p>2,不存在则</p>2.1,使用离线JIDContext</p>2.2,使用Find(All)
   *
   * @see com.sissi.addressing.Addressing#findOne(com.sissi.context.JID, boolean, boolean)
   */
  public JIDContext findOne(JID jid, boolean usingResource, boolean offline) {
    DBObject entity = this.config.collection().findOne(this.buildQueryWithSmartResource(jid, usingResource), this.filterIndex);
    return entity != null ? this.contexts.get(MongoUtils.asLong(entity, Dictionary.FIELD_INDEX)) : offline ? this.offline.build(jid, this.nothing) : this.find(jid);
  }
View Full Code Here

   *
   * @see com.sissi.ucenter.user.block.BlockContext#isBlock(com.sissi.context.JID, com.sissi.context.JID)
   */
  @Override
  public boolean isBlock(JID from, JID to) {
    DBObject query = this.buildQuery(from);
    query.put(this.blocks, to.user());
    return this.config.collection().findOne(query, this.filterId) != null;
  }
View Full Code Here

   *
   * @see com.sissi.ucenter.relation.muc.request.RequestContext#request(com.sissi.context.JID, com.sissi.context.JID, com.sissi.field.Fields)
   */
  @Override
  public boolean apply(JID invoker, JID group, Fields fields) {
    DBObject entity = super.entities(fields, BasicDBObjectBuilder.start());
    try {
      // {"jid":to.bare,"informations.jid":from.bare},{"$set":{"infomrations.$.information":..entity..}}
      this.config.collection().update(BasicDBObjectBuilder.start().add(Dictionary.FIELD_JID, group.asStringWithBare()).add(Dictionary.FIELD_INFORMATIONS + "." + Dictionary.FIELD_JID, invoker.asStringWithBare()).get(), BasicDBObjectBuilder.start("$set", BasicDBObjectBuilder.start(Dictionary.FIELD_INFORMATIONS + ".$." + Dictionary.FIELD_INFORMATION, entity).get()).get(), true, false, WriteConcern.SAFE);
    } catch (MongoException e) {
      // {"jid":to.bare},{"$addToSet"{"informations":{"jid":from.bare,"activate":当前时间,"information":...entity...}}}
View Full Code Here

   *
   * @see com.sissi.ucenter.relation.muc.room.RoomBuilder#build(com.sissi.context.JID)
   */
  @Override
  public Room build(JID group) {
    DBObject db = this.config.collection().findOne(BasicDBObjectBuilder.start(Dictionary.FIELD_JID, group.asStringWithBare()).get(), this.filter);
    return new MongoRoom(group, this.jidBuilder.build(MongoUtils.asString(db, Dictionary.FIELD_CREATOR)), MongoUtils.asDBObject(db, Dictionary.FIELD_CONFIGS));
  }
View Full Code Here

   */
  @SuppressWarnings("deprecation")
  @Override
  public Set<JID> iSubscribedWho(JID from) {
    // {"$match":{"roles.jid":from.bare,"roles.resource":from.resource}}
    DBObject match = BasicDBObjectBuilder.start("$match", BasicDBObjectBuilder.start().add(Dictionary.FIELD_ROLES + "." + Dictionary.FIELD_JID, from.asStringWithBare()).add(Dictionary.FIELD_ROLES + "." + Dictionary.FIELD_RESOURCE, from.resource()).get()).get();
    // match, {"$unwind":"$roles"}, match, {"$project":{"jid":"$jid","resource":"$roles.nick"}}
    return new JIDGroup(MongoUtils.asList(this.config.collection().aggregate(match, super.unwindRoles, match, this.projectSubscribed).getCommandResult(), Dictionary.FIELD_RESULT));
  }
View Full Code Here

    @Override
    public List<SystemMessage> all(int page) {
        List<SystemMessage> messages = Lists.newArrayList();

        DBObject sort = new BasicDBObject();
        sort.put("timestamp", -1);

        List<DBObject> results = query(SystemMessageImpl.class, new BasicDBObject(), sort, PER_PAGE, PER_PAGE * page);
        for (DBObject o : results) {
            messages.add(new SystemMessageImpl(new ObjectId(o.get("_id").toString()), o.toMap()));
        }
View Full Code Here

TOP

Related Classes of com.mongodb.DBObject

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.