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


Java BasicDBObjectBuilder.start方法代码示例

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


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

示例1: createBetweenFilter

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
private DBObject createBetweenFilter(Object value) {
    JSONObject dateRange = parseDateRange(value);

    org.joda.time.format.DateTimeFormatter parser = ISODateTimeFormat.dateTime();

    BasicDBObjectBuilder start = BasicDBObjectBuilder.start();

    if (dateRange.get("startDate") != null) {
        DateTime startDate = parser.parseDateTime((String) dateRange.get("startDate"));
        start.add(QueryOperators.GTE, startDate.toDate());
    }

    if (dateRange.get("endDate") != null) {
        DateTime endDate = parser.parseDateTime((String) dateRange.get("endDate"));
        start.add(QueryOperators.LTE, endDate.toDate());
    }

    return start.get();
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:20,代码来源:AbstractMongoDao.java

示例2: toDBObject

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
private static DBObject toDBObject(final PCJIndexDetails pcjIndexDetails) {
    requireNonNull(pcjIndexDetails);

    final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();

    // Is Enabled
    builder.add(PCJ_ENABLED_KEY, pcjIndexDetails.isEnabled());

    // Add the PCJDetail objects.
    final List<DBObject> pcjDetailsList = new ArrayList<>();
    for(final PCJDetails pcjDetails : pcjIndexDetails.getPCJDetails().values()) {
        pcjDetailsList.add( toDBObject( pcjDetails ) );
    }
    builder.add(PCJ_PCJS_KEY, pcjDetailsList.toArray());

    return builder.get();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:MongoDetailsAdapter.java

示例3: toDBObject

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
/**
 * Serializes a {@link DocumentVisibility} to a MongoDB {@link DBObject}.
 * @param documentVisibility the {@link DocumentVisibility} to be
 * serialized.
 * @return The MongoDB {@link DBObject}.
 */
public static BasicDBObject toDBObject(final DocumentVisibility documentVisibility) {
    DocumentVisibility dv;
    if (documentVisibility == null) {
        dv = MongoDbRdfConstants.EMPTY_DV;
    } else {
        dv = documentVisibility;
    }
    Object[] dvArray = null;
    try {
        dvArray = DocumentVisibilityUtil.toMultidimensionalArray(dv);
    } catch (final DocumentVisibilityConversionException e) {
        log.error("Unable to convert document visibility");
    }

    final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
    builder.add(DOCUMENT_VISIBILITY_KEY, dvArray);
    return (BasicDBObject) builder.get();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:DocumentVisibilityAdapter.java

示例4: serialize

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
@Override
public DBObject serialize(final RyaStatement ryaStatement) {
    final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start("_id", ryaStatement.getSubject().hashCode());
    final URI obj = ryaStatement.getObject().getDataType();


    if(obj.equals(GeoConstants.GEO_AS_WKT) || obj.equals(GeoConstants.GEO_AS_GML) ||
       obj.equals(GeoConstants.XMLSCHEMA_OGC_GML) || obj.equals(GeoConstants.XMLSCHEMA_OGC_WKT)) {
        try {
            final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
            final Geometry geo = GeoParseUtils.getGeometry(statement, new GmlParser());
            if (geo.getNumPoints() > 1) {
                builder.add(GEO_KEY, geoStrategy.getCorrespondingPoints(geo));
            } else {
                builder.add(GEO_KEY, geoStrategy.getDBPoint(geo));
            }
        } catch (final ParseException e) {
            LOG.error("Could not create geometry for statement " + ryaStatement, e);
            return null;
        }
    } else {
        builder.add(TIME_KEY, temporalStrategy.getTimeValue(ryaStatement.getObject().getData()));
    }
    return builder.get();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:GeoTemporalMongoDBStorageStrategy.java

示例5: initialize

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void initialize() {
    // Make sure the fields we want to query are indexed
    DBCollection assets = db.getCollection(ASSETS_COLLECTION);
    DBCollection attachments = db.getCollection(ATTACHMENTS_COLLECTION);

    // Add text index
    BasicDBObjectBuilder textIndex = BasicDBObjectBuilder.start();
    for (String indexField : searchIndexFields) {
        textIndex.add(indexField, "text");
    }
    assets.ensureIndex(textIndex.get());

    // Add Attachment(assetId) index
    attachments.ensureIndex(new BasicDBObject("assetId", 1));
}
 
开发者ID:WASdev,项目名称:tool.lars,代码行数:18,代码来源:PersistenceBean.java

示例6: getData

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
@Override
public DBCursor getData(String driverId, String test, String testRun, String sheetName)
{
    // check params
    checkMandatoryString(test, "test");
    checkMandatoryString(testRun, "testRun");
    checkMandatoryString(sheetName, "sheetName");

    // create query
    BasicDBObjectBuilder queryObjBuilder = BasicDBObjectBuilder.start();
    if (null != driverId && !driverId.isEmpty())
    {
        queryObjBuilder.add(FIELD_DRIVER_ID, driverId);
    }
    queryObjBuilder.add(FIELD_TEST, test).add(FIELD_TEST_RUN, testRun).add(FIELD_SHEET_NAME, sheetName);
    DBObject queryObj = queryObjBuilder.get();

    
    // sort and return cursor
    DBCursor dbCursor = this.collectionExtraData.find(queryObj);
    
    return dbCursor;
}
 
开发者ID:AlfrescoBenchmark,项目名称:alfresco-benchmark,代码行数:24,代码来源:DataReportServiceImpl.java

示例7: countUsers

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
@Override
public long countUsers(String domain, DataCreationState creationState)
{
    BasicDBObjectBuilder queryObjBuilder = BasicDBObjectBuilder.start();
    if (domain != null)
    {
        queryObjBuilder.add(FIELD_DOMAIN, domain);
    }
    if (creationState != null)
    {
        queryObjBuilder.add(FIELD_CREATION_STATE, creationState.toString());
    }
    DBObject queryObj = queryObjBuilder.get();
    
    return collection.count(queryObj);
}
 
开发者ID:AlfrescoBenchmark,项目名称:alfresco-benchmark,代码行数:17,代码来源:UserDataServiceImpl.java

示例8: addTo

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
@Override
public void addTo(final DBObject obj) {
    BasicDBObjectBuilder query;
    FilterOperator operator = getOperator();

    switch (operator) {
        case NEAR:
            if (maxDistanceMeters != null) {
                geometryAsDBObject.put("$maxDistance", maxDistanceMeters);
            }
            query = BasicDBObjectBuilder.start(NEAR.val(), geometryAsDBObject);
            break;
        case GEO_WITHIN:
        case INTERSECTS:
            query = BasicDBObjectBuilder.start(operator.val(), geometryAsDBObject);
            if (crs != null) {
                ((DBObject) geometryAsDBObject.get("$geometry")).put("crs", new NamedCoordinateReferenceSystemConverter().encode(crs));
            }
            break;
        default:
            throw new UnsupportedOperationException(String.format("Operator %s not supported for geo-query", operator.val()));
    }

    obj.put(getField(), query.get());
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:26,代码来源:StandardGeoFieldCriteria.java

示例9: parseFieldsString

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
private BasicDBObject parseFieldsString(final String fields) {
    BasicDBObjectBuilder ret = BasicDBObjectBuilder.start();
    final String[] parts = fields.split(",");
    for (String s : parts) {
        s = s.trim();
        int dir = 1;
        if (s.startsWith("-")) {
            dir = -1;
            s = s.substring(1).trim();
        }
        ret = ret.add(s, dir);
    }
    return (BasicDBObject) ret.get();
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:15,代码来源:MongoTemplate.java

示例10: getTimeValue

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
public DBObject getTimeValue(final String timeData) {
    final Matcher match = TemporalInstantRfc3339.PATTERN.matcher(timeData);
    final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
    if(match.find()) {
        final TemporalInterval date = TemporalInstantRfc3339.parseInterval(timeData);
        builder.add(INTERVAL_START, date.getHasBeginning().getAsDateTime().toDate());
        builder.add(INTERVAL_END, date.getHasEnd().getAsDateTime().toDate());
    } else {
        builder.add(INSTANT, TemporalInstantRfc3339.FORMATTER.parseDateTime(timeData).toDate());
    }
    return builder.get();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:13,代码来源:TemporalMongoDBStorageStrategy.java

示例11: search

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
@Override
public Collection<Event> search(final Optional<RyaURI> subject, final Optional<Collection<IndexingExpr>> geoFilters, final Optional<Collection<IndexingExpr>> temporalFilters) throws EventStorageException {
    requireNonNull(subject);

    try {
        final Collection<IndexingExpr> geos = (geoFilters.isPresent() ? geoFilters.get() : new ArrayList<>());
        final Collection<IndexingExpr> tempos = (temporalFilters.isPresent() ? temporalFilters.get() : new ArrayList<>());
        final DBObject filterObj = queryAdapter.getFilterQuery(geos, tempos);

        final BasicDBObjectBuilder builder = BasicDBObjectBuilder
        .start(filterObj.toMap());
        if(subject.isPresent()) {
            builder.append(EventDocumentConverter.SUBJECT, subject.get().getData());
        }
        final MongoCursor<Document> results = mongo.getDatabase(ryaInstanceName)
            .getCollection(COLLECTION_NAME)
            .find( BsonDocument.parse(builder.get().toString()) )
            .iterator();

        final List<Event> events = new ArrayList<>();
        while(results.hasNext()) {
            events.add(EVENT_CONVERTER.fromDocument(results.next()));
        }
        return events;
    } catch(final MongoException | DocumentConverterException | GeoTemporalIndexException e) {
        throw new EventStorageException("Could not get the Event.", e);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:29,代码来源:MongoEventStorage.java

示例12: apply

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
@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...}}}
		this.config.collection().update(BasicDBObjectBuilder.start().add(Dictionary.FIELD_JID, group.asStringWithBare()).get(), BasicDBObjectBuilder.start().add("$addToSet", BasicDBObjectBuilder.start(Dictionary.FIELD_INFORMATIONS, BasicDBObjectBuilder.start().add(Dictionary.FIELD_JID, invoker.asStringWithBare()).add(Dictionary.FIELD_ACTIVATE, System.currentTimeMillis()).add(Dictionary.FIELD_INFORMATION, entity).get()).get()).get());
	}
	return true;
}
 
开发者ID:KimShen,项目名称:sissi,代码行数:13,代码来源:MongoRegisterSubmitContext.java

示例13: push

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
public Room push(Fields fields) {
	BasicDBObjectBuilder update = BasicDBObjectBuilder.start();
	for (Field<?> field : fields) {
		RoomConfigParser parser = MongoRoomBuilder.this.parsers.get(field.getName());
		if (parser != null) {
			update.add(Dictionary.FIELD_CONFIGS + "." + parser.field(), parser.parse(field));
		}
	}
	if (!update.isEmpty()) {
		MongoRoomBuilder.this.config.collection().update(this.build(), BasicDBObjectBuilder.start("$set", update.get()).get());
	}
	return this;
}
 
开发者ID:KimShen,项目名称:sissi,代码行数:14,代码来源:MongoRoomBuilder.java

示例14: buildQueryWithSmartResource

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
/**
 * For FindXxx</p>{"jid",Xxx,"resource":Xxx(如果使用资源)}
 * 
 * @param jid
 * @param usingResource
 * @return
 */
private DBObject buildQueryWithSmartResource(JID jid, boolean usingResource) {
	// JID,Resource
	BasicDBObjectBuilder query = BasicDBObjectBuilder.start(Dictionary.FIELD_JID, jid.asStringWithBare());
	if (usingResource && !jid.isBare()) {
		query.add(Dictionary.FIELD_RESOURCE, jid.resource());
	}
	return query.get();
}
 
开发者ID:KimShen,项目名称:sissi,代码行数:16,代码来源:MongoAddressing.java

示例15: build

import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
/**
 * {"host":host,"date":Xxx}
 * 
 * @param host
 * @param date
 * @return
 */
private DBObject build(String host, boolean date) {
	BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(Dictionary.FIELD_HOST, host);
	if (date) {
		builder.add(this.date, System.currentTimeMillis());
	}
	return builder.get();
}
 
开发者ID:KimShen,项目名称:sissi,代码行数:15,代码来源:BridgeExchangerContext.java


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