当前位置: 首页>>代码示例>>Java>>正文


Java BasicDBObject.append方法代码示例

本文整理汇总了Java中com.mongodb.BasicDBObject.append方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDBObject.append方法的具体用法?Java BasicDBObject.append怎么用?Java BasicDBObject.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mongodb.BasicDBObject的用法示例。


在下文中一共展示了BasicDBObject.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNextId

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
public int getNextId(GridFS destDatabase) {
	DBCollection countersCollection = destDatabase.getDB().getCollection("counters");

	DBObject record = countersCollection.findOne(new BasicDBObject("_id", "package"));
	if (record == null) {
		BasicDBObject dbObject = new BasicDBObject("_id", "package");
		dbObject.append("seq", 0);
		countersCollection.insert(dbObject);
		record = dbObject;
	}
	int oldID = (int) record.get("seq");
	int newID = oldID + 1;
	record.put("seq", newID);
	countersCollection.update(new BasicDBObject("_id", "package"), record);
	
	return newID;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:18,代码来源:DataManager.java

示例2: parse

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
/**
 * 解析
 * @param group
 * @param parser
 * @return
 */
@Override
public Object parse(IGroup group, JsonRuleParser parser) {
    // rules
    BasicDBList operates = new BasicDBList();
    for (JsonRule jsonRule : group.getRules()) {
        operates.add(parser.parse(jsonRule));
    }

    // AND or OR
    BasicDBObject andOrObj = new BasicDBObject();
    andOrObj.append(EnumCondition.AND.equals(group.getCondition()) ? "$and" : "$or", operates);

    // Not
    if (group.getNot() != null && group.getNot()) {
        BasicDBList list = new BasicDBList();
        list.add(andOrObj);
        return new BasicDBObject("$nor", list);
    }
    return andOrObj;
}
 
开发者ID:itfsw,项目名称:QueryBuilder,代码行数:27,代码来源:DefaultGroupParser.java

示例3: updateUserChangeNameAndSurnametoName

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
/**
 * update 6: {@link UserDocument} has changed; 'name' and 'surname' will be concat to 'name'.
 * for each every user document get 'name' and 'surname', concat them, update 'name', remove field surname and update document.
 *
 * @since V7
 */
@ChangeSet(order = "008", id = "updateUserChangeNameAndSurnameToName", author = "admin")
public void updateUserChangeNameAndSurnametoName(final MongoTemplate template) {
  final DBCollection userCollection = template.getCollection("user");

  final Iterator<DBObject> cursor = userCollection.find();
  while (cursor.hasNext()) {
    final DBObject current = cursor.next();

    final Object nameObj = current.get("name");
    final Object surnameObj = current.get("surname");
    final String updateName = (nameObj != null ? nameObj.toString() : "") + " " + (surnameObj != null ? surnameObj.toString() : "");

    final BasicDBObject updateQuery = new BasicDBObject();
    updateQuery.append("$set", new BasicDBObject("name", updateName));
    updateQuery.append("$unset", new BasicDBObject("surname", ""));

    final BasicDBObject searchQuery = new BasicDBObject();
    searchQuery.put("_id", current.get("_id"));

    userCollection.update(searchQuery, updateQuery);
  }
}
 
开发者ID:nkolytschew,项目名称:mongobee_migration_example,代码行数:29,代码来源:DatabaseChangeLog.java

示例4: setMonitored

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
public AgentFull setMonitored(String agentId, boolean monitored){
	AgentFull agent = getAgentByAgentId(agentId);
	if (agent != null){
		agent.setMonitored(monitored);
		
		 //Preparing to insert new field
        BasicDBObject updateMonitored = new BasicDBObject();
        updateMonitored.append("$set", new BasicDBObject().append("monitored", monitored));
 
        //Find the register with the specified ID
        BasicDBObject searchById = new BasicDBObject();
        searchById.append("agentId", agentId);
 
        //Launch the update
        getAgentTable().updateMulti(searchById, updateMonitored);
        
        return getAgentByAgentId(agentId);
		
	}
	else {
		return null;
	}
}
 
开发者ID:elastest,项目名称:elastest-instrumentation-manager,代码行数:24,代码来源:AgentRepository.java

示例5: getDBObject

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
/** Return an object suitable to create a new user in MongoDB. */
public BasicDBObject getDBObject(boolean includeId) {
  BasicDBObject user = new BasicDBObject();
  if (includeId) {
    user.append(DB_ID, new ObjectId(id));
  }
  user.append(JSON_KEY_USER_FIRST_NAME, firstName);
  user.append(JSON_KEY_USER_LAST_NAME, lastName);
  user.append(JSON_KEY_USER_NAME, userName);
  user.append(JSON_KEY_USER_TWITTER_HANDLE, twitterHandle);
  user.append(JSON_KEY_USER_WISH_LIST_LINK, wishListLink);
  user.append(JSON_KEY_USER_PASSWORD_HASH, passwordHash);
  user.append(JSON_KEY_USER_PASSWORD_SALT, passwordSalt);
  user.append(JSON_KEY_USER_TWITTER_LOGIN, isTwitterLogin);

  return user;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:18,代码来源:User.java

示例6: getDBObjectForModify

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
/**
 * Return a DBObject that can be used for updating the user in the mongo database. We only include
 * the fields that the client should be changing (leave out the internal fields).
 */
public DBObject getDBObjectForModify() {
  BasicDBObject user = new BasicDBObject();
  user.append(JSON_KEY_USER_FIRST_NAME, firstName);
  user.append(JSON_KEY_USER_LAST_NAME, lastName);
  user.append(JSON_KEY_USER_WISH_LIST_LINK, wishListLink);

  // If the user logs in with Twitter, don't let them change their
  // twitter handle, username, or password.
  if (isTwitterLogin == false) {
    user.append(JSON_KEY_USER_TWITTER_HANDLE, twitterHandle);
    if (userName != null) {
      user.append(JSON_KEY_USER_NAME, userName);
    }
    if (passwordHash != null) {
      user.append(JSON_KEY_USER_PASSWORD_HASH, passwordHash);
    }
    if (passwordSalt != null) {
      user.append(JSON_KEY_USER_PASSWORD_SALT, passwordSalt);
    }
  }
  return user;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:27,代码来源:User.java

示例7: getDBObject

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
/**
 * Create a Mongo DB Object baed on the content of this group
 *
 * @param id The Mongo Object id to assign to this DB Object. If null, a new Object id will be
 *     created
 * @return - The Mongo DB Object based on the content of this group
 */
public BasicDBObject getDBObject(boolean includeId) {
  BasicDBObject group = new BasicDBObject();
  if (includeId) {
    group.append(DB_ID, new ObjectId(id));
  }
  group.append(JSON_KEY_GROUP_NAME, name);

  BasicDBList membersArray = new BasicDBList();
  for (int i = 0; i < members.length; i++) {
    membersArray.add(members[i]);
  }
  group.append(JSON_KEY_MEMBERS_LIST, membersArray);

  return group;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:23,代码来源:Group.java

示例8: getDBObject

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
/**
 * Create a Mongo DB Object baed on the content of this group
 *
 * @param id The Mongo Object id to assign to this DB Object. If null, a new Object id will be
 *     created
 * @return - The Mongo DB Object based on the content of this group
 */
public BasicDBObject getDBObject(boolean includeId) {
  BasicDBObject group = new BasicDBObject();

  if (includeId) {
    group.append(DB_ID, new ObjectId(id));
  }

  group.append(JSON_KEY_GROUP_NAME, name);

  BasicDBList membersArray = new BasicDBList();
  for (int i = 0; i < members.length; i++) {
    membersArray.add(members[i]);
  }
  group.append(JSON_KEY_MEMBERS_LIST, membersArray);

  return group;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:25,代码来源:Group.java

示例9: insertReportTest

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@Test
public void insertReportTest()
{
    Report.Builder rBuilder = new Report.Builder();
    rBuilder.reportDate(new Date());
    rBuilder.resolveDate(new Date());
    rBuilder.resolved(true);
    rBuilder.comment("comment99");
    rBuilder.priority("high");

    Report report = new Report();
    report = rBuilder.build();
    CityItemDAO.insertReport(report);

    BasicDBObject query = new BasicDBObject();
    query.append("report.comment","comment99");
    Document result = Configurator.INSTANCE.getDatabase().getCollection("city_items").find().first();
    Assert.assertTrue("Result should not be null",result != null);
}
 
开发者ID:Labas-Vakaras,项目名称:Smart_City,代码行数:20,代码来源:CityItemDAOTest.java

示例10: getBasicDBObject

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
private BasicDBObject getBasicDBObject(HttpServletRequest request, JoinPoint joinPoint) {
    // 基本信息
    BasicDBObject r = new BasicDBObject();
    r.append("requestURL", request.getRequestURL().toString());
    r.append("requestURI", request.getRequestURI());
    r.append("queryString", request.getQueryString());
    r.append("remoteAddr", request.getRemoteAddr());
    r.append("remoteHost", request.getRemoteHost());
    r.append("remotePort", request.getRemotePort());
    r.append("localAddr", request.getLocalAddr());
    r.append("localName", request.getLocalName());
    r.append("method", request.getMethod());
    r.append("headers", getHeadersInfo(request));
    r.append("parameters", request.getParameterMap());
    r.append("classMethod", joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
    r.append("args", Arrays.toString(joinPoint.getArgs()));
    return r;
}
 
开发者ID:nellochen,项目名称:springboot-start,代码行数:19,代码来源:WebLogAspect.java

示例11: concretProcessor

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@Override
public void concretProcessor(Object expKey, Map expValue, BasicDBObject set) {

    Map expressions = (Map) expValue.get(expKey);
    Set keys = expressions.keySet();
    Iterator iter = keys.iterator();
    while (iter.hasNext()) {
        String key = (String) iter.next();
        Object value = expressions.get(key);

        if (value instanceof Map) {
            KVStrategy kv = new KVStrategy();
            kv.concretProcessor(key, expressions, set);
        }
        else {
            set.append(key, value);
            log.info(this, "@key: " + key + "@value:" + value);
        }
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:21,代码来源:MongodbImplStrategy.java

示例12: parse

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
public DBObject parse(IRule rule, JsonRuleParser parser) {
    List<Object> values = (List<Object>) rule.getValue();
    BasicDBObject operate = new BasicDBObject();
    operate.append("$gte", values.get(0));
    operate.append("$lte", values.get(1));
    return new BasicDBObject(rule.getField(), operate);
}
 
开发者ID:itfsw,项目名称:QueryBuilder,代码行数:8,代码来源:BetweenRuleParser.java

示例13: parse

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
public BasicDBObject parse(IRule rule, JsonRuleParser parser) {
    List<Object> values = (List<Object>) rule.getValue();
    BasicDBObject operate = new BasicDBObject();
    operate.append("$lt", values.get(0));
    operate.append("$gt", values.get(1));
    return new BasicDBObject(rule.getField(), operate);
}
 
开发者ID:itfsw,项目名称:QueryBuilder,代码行数:8,代码来源:NotBetweenRuleParser.java

示例14: getDBObject

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
public BasicDBObject getDBObject(boolean includeId) {
  BasicDBObject user = new BasicDBObject();
  if (includeId) {
    user.append(DB_ID, new ObjectId(id));
  }

  user.append(JSON_KEY_USER_FIRST_NAME, firstName);
  user.append(JSON_KEY_USER_LAST_NAME, lastName);
  user.append(JSON_KEY_USER_NAME, userName);
  user.append(JSON_KEY_USER_TWITTER_HANDLE, twitterHandle);
  user.append(JSON_KEY_USER_WISH_LIST_LINK, wishListLink);
  user.append(JSON_KEY_USER_PASSWORD, password);

  return user;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:16,代码来源:User.java

示例15: cityItemExistsTest

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@Test
public void cityItemExistsTest()
{
    BasicDBObject query1 = new BasicDBObject();
    query1.append("type","lamp4");
    BasicDBObject doc1 = collection.find(query1).first();
    BasicDBObject result1 = collection.find(doc1).first();
    Assert.assertTrue("Document should exist",result1 != null);

    BasicDBObject query2 = new BasicDBObject();
    query2.append("type","test"); // not type as test
    result1 = collection.find(query2).first();
    Assert.assertTrue("Document should not exist",result1 == null);
}
 
开发者ID:Labas-Vakaras,项目名称:Smart_City,代码行数:15,代码来源:CityItemDAOTest.java


注:本文中的com.mongodb.BasicDBObject.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。