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


Java BasicDBObjectBuilder.push方法代码示例

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


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

示例1: matches

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
private DBObject matches(StatisticsFilter request) {
    BasicDBObjectBuilder b = new BasicDBObjectBuilder();
    BasicDBObjectBuilder match = b.push(Ops.MATCH);
    if (request.hasTrack()) {
        DBRef track = mongoDB.ref(request.getTrack());
        match.add(MongoMeasurement.TRACK, track);
    }
    if (request.hasUser()) {
        DBRef user = mongoDB.ref(request.getUser());
        match.add(MongoMeasurement.USER, user);
    }
    if (request.hasSensor()) {
        MongoSensor sensor = (MongoSensor) request.getSensor();
        match.add(SENSOR_ID_PATH, sensor.getId());
    }
    return b.get();
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:18,代码来源:MongoStatisticsDao.java

示例2: getLogs

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
@Override
public DBCursor getLogs(String driverId, String test, String testRun, LogLevel level, Long minTime, Long maxTime, int skip, int limit)
{
    BasicDBObjectBuilder queryObjBuilder = BasicDBObjectBuilder.start();
    if (level != null)
    {
        queryObjBuilder.push(FIELD_LEVEL).add("$gte", level.getLevel()).pop();
    }
    if (driverId != null)
    {
        queryObjBuilder.add(FIELD_DRIVER_ID, driverId);
    }
    if (test != null)
    {
        queryObjBuilder.add(FIELD_TEST, test);
    }
    if (testRun != null)
    {
        queryObjBuilder.add(FIELD_TEST_RUN, testRun);
    }
    if (minTime != null || maxTime != null)
    {
        queryObjBuilder.push(FIELD_TIME);
        if (minTime != null)
        {
            queryObjBuilder.add("$gte", new Date(minTime));
        }
        if (maxTime != null)
        {
            queryObjBuilder.add("$lt", new Date(maxTime));
        }
        queryObjBuilder.pop();
    }
    DBObject queryObj = queryObjBuilder.get();
    DBObject sortObj = new BasicDBObject(FIELD_TIME, -1);
    DBObject fieldsObj = BasicDBObjectBuilder.start()
            .add(FIELD_ID, false)
            .add(FIELD_TIME, true)
            .add(FIELD_DRIVER_ID, true)
            .add(FIELD_TEST, true)
            .add(FIELD_TEST_RUN, true)
            .add(FIELD_LEVEL, true)
            .add(FIELD_MSG, true)
            .get();
    return collection.find(queryObj, fieldsObj).sort(sortObj).skip(skip).limit(limit);
}
 
开发者ID:AlfrescoBenchmark,项目名称:alfresco-benchmark,代码行数:47,代码来源:MongoLogService.java

示例3: getTestRuns

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
/**
 * @param test
 *        only fetch runs for this test or <tt>null</tt> to get all test
 *        runs
 * @param testRunStates
 *        optional states that the test runs must be in or empty for all
 * @return a cursor onto the test runs for the given test
 */
public DBCursor getTestRuns(String test, int skip, int count, TestRunState... testRunStates)
{
    BasicDBObjectBuilder queryObjBuilder = BasicDBObjectBuilder
            .start();
    if (test != null)
    {
        ObjectId testObjId = getTestId(test);
        if (testObjId == null)
        {
            // The test no longer exists, so the run effectively doesn't
            // either
            logger.warn("Test not found: " + test);
            // Use a ficticious ID that will never match
            testObjId = new ObjectId();
        }
        queryObjBuilder.add(FIELD_TEST, testObjId);
    }

    // Build query for the test run states
    if (testRunStates.length > 0)
    {
        List<String> stateStrs = new ArrayList<String>(testRunStates.length);
        for (int i = 0; i < testRunStates.length; i++)
        {
            stateStrs.add(testRunStates[i].toString());
        }
        queryObjBuilder.push(FIELD_STATE);
        queryObjBuilder.add("$in", stateStrs);
    }

    DBObject queryObj = queryObjBuilder.get();

    DBObject fieldsObj = BasicDBObjectBuilder
            .start()
            .add(FIELD_NAME, true)
            .add(FIELD_TEST, true)
            .add(FIELD_VERSION, true)
            .add(FIELD_DESCRIPTION, true)
            .add(FIELD_STATE, true)
            .add(FIELD_SCHEDULED, true)
            .add(FIELD_STARTED, true)
            .add(FIELD_STOPPED, true)
            .add(FIELD_COMPLETED, true)
            .add(FIELD_DURATION, true)
            .add(FIELD_PROGRESS, true)
            .add(FIELD_RESULTS_SUCCESS, true)
            .add(FIELD_RESULTS_FAIL, true)
            .add(FIELD_RESULTS_TOTAL, true)
            .add(FIELD_SUCCESS_RATE, true)
            .get();

    DBCursor dbCursor = testRuns.find(queryObj, fieldsObj).skip(skip).limit(count);

    // Done
    if (logger.isDebugEnabled())
    {
        logger.debug(
                "Fetched test runs: \n" +
                        "   Test:    " + test + "\n" +
                        "   Results: " + dbCursor.count());
    }
    return dbCursor;
}
 
开发者ID:AlfrescoBenchmark,项目名称:alfresco-benchmark,代码行数:72,代码来源:MongoTestDAO.java


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