本文整理汇总了Java中com.mongodb.BasicDBObjectBuilder.get方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDBObjectBuilder.get方法的具体用法?Java BasicDBObjectBuilder.get怎么用?Java BasicDBObjectBuilder.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mongodb.BasicDBObjectBuilder
的用法示例。
在下文中一共展示了BasicDBObjectBuilder.get方法的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();
}
示例2: toDBObject
import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
/**
* Serializes {@link RyaDetails} to mongo {@link DBObject}.
* @param details - The details to be serialized.
* @return The mongo {@link DBObject}.
*/
public static BasicDBObject toDBObject(final RyaDetails details) {
Preconditions.checkNotNull(details);
final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start()
.add(INSTANCE_KEY, details.getRyaInstanceName())
.add(VERSION_KEY, details.getRyaVersion())
.add(ENTITY_DETAILS_KEY, details.getEntityCentricIndexDetails().isEnabled())
//RYA-215 .add(GEO_DETAILS_KEY, details.getGeoIndexDetails().isEnabled())
.add(PCJ_DETAILS_KEY, toDBObject(details.getPCJIndexDetails()))
.add(TEMPORAL_DETAILS_KEY, details.getTemporalIndexDetails().isEnabled())
.add(FREETEXT_DETAILS_KEY, details.getFreeTextIndexDetails().isEnabled());
if(details.getProspectorDetails().getLastUpdated().isPresent()) {
builder.add(PROSPECTOR_DETAILS_KEY, details.getProspectorDetails().getLastUpdated().get());
}
if(details.getJoinSelectivityDetails().getLastUpdated().isPresent()) {
builder.add(JOIN_SELECTIVITY_DETAILS_KEY, details.getJoinSelectivityDetails().getLastUpdated().get());
}
return (BasicDBObject) builder.get();
}
示例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();
}
示例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();
}
示例5: createNewFolder
import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
/**
* Create a new folder entry with the given data
*/
public void createNewFolder(FolderData data)
{
BasicDBObjectBuilder insertObjBuilder = BasicDBObjectBuilder.start()
.add(FIELD_ID, data.getId())
.add(FIELD_CONTEXT, data.getContext())
.add(FIELD_PATH, data.getPath())
.add(FIELD_LEVEL, data.getLevel())
.add(FIELD_PARENT_PATH, data.getParentPath())
.add(FIELD_NAME, data.getName())
.add(FIELD_FOLDER_COUNT, data.getFolderCount())
.add(FIELD_FILE_COUNT, data.getFileCount());
DBObject insertObj = insertObjBuilder.get();
try
{
collection.insert(insertObj);
}
catch (DuplicateKeyException e)
{
// We just rethrow as per the API
throw e;
}
}
示例6: log
import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
@Override
public void log(String driverId, String test, String testRun, LogLevel level, String msg)
{
BasicDBObjectBuilder insertObjBuilder = BasicDBObjectBuilder.start()
.add(FIELD_TIME, new Date())
.add(FIELD_LEVEL, level.getLevel())
.add(FIELD_MSG, msg);
if (driverId != null)
{
insertObjBuilder.add(FIELD_DRIVER_ID, driverId);
}
if (test != null)
{
insertObjBuilder.add(FIELD_TEST, test);
}
if (testRun != null)
{
insertObjBuilder.add(FIELD_TEST_RUN, testRun);
}
DBObject insertObj = insertObjBuilder.get();
collection.insert(insertObj);
}
示例7: 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();
}
示例8: getRandomUserFromDomains
import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
@Override
public UserData getRandomUserFromDomains(List<String> domains)
{
Range range = getRandomizerRange(domains);
int upper = range.getMax();
int lower = range.getMin();
int random = lower + (int) (Math.random() * (double) (upper - lower));
BasicDBObjectBuilder queryObjBuilder = BasicDBObjectBuilder.start()
.add(FIELD_CREATION_STATE, DataCreationState.Created.toString())
.push(FIELD_RANDOMIZER)
.add("$gte", random)
.pop();
if (domains.size() > 0)
{
queryObjBuilder
.push(FIELD_DOMAIN)
.add("$in", domains)
.pop();
}
DBObject queryObj = queryObjBuilder.get();
DBObject userDataObj = collection.findOne(queryObj);
return fromDBObject(userDataObj);
}
示例9: ensureIndex
import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
/**
* Ensures (creating if necessary) the index including the field(s) + directions; eg fields = "field1, -field2" ({field1:1, field2:-1})
*/
public void ensureIndex(String collName, String name, String fields, boolean unique, boolean dropDupsOnCreate) {
BasicDBObject dbFields = parseFieldsString(fields);
final BasicDBObjectBuilder keyOpts = new BasicDBObjectBuilder();
if (name != null && name.length() != 0) {
keyOpts.add("name", name);
}
if (unique) {
keyOpts.add("unique", true);
if (dropDupsOnCreate) {
keyOpts.add("dropDups", true);
}
}
final DBCollection dbColl = getCollection(getCollName(collName));
final BasicDBObject opts = (BasicDBObject) keyOpts.get();
if (opts.isEmpty()) {
LOGGER.debug("Ensuring index for " + dbColl.getName() + " with keys:" + dbFields);
dbColl.createIndex(dbFields);
} else {
LOGGER.debug("Ensuring index for " + dbColl.getName() + " with keys:" + fields + " and opts:" + opts);
dbColl.createIndex(dbFields, opts);
}
}
示例10: 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();
}
示例11: 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();
}
示例12: serialize
import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
/**
* Serializes the {@link MergeParentMetadata} into a mongoDB object.
* @param metadata - The {@link MergeParentMetadata} to serialize.
* @return The MongoDB object
*/
public DBObject serialize(final MergeParentMetadata metadata) {
final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start()
.add(RYANAME_KEY, metadata.getRyaInstanceName())
.add(TIMESTAMP_KEY, metadata.getTimestamp())
.add(FILTER_TIMESTAMP_KEY, metadata.getFilterTimestamp())
.add(PARENT_TIME_OFFSET_KEY, metadata.getParentTimeOffset());
return builder.get();
}
示例13: getDBObjectForInput
import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
@Override
public DBObject getDBObjectForInput(Tuple input) {
BasicDBObjectBuilder dbObjectBuilder = new BasicDBObjectBuilder();
for (String field : input.getFields()) {
Object value = input.getValueByField(field);
if (isValidDBObjectField(value)) {
dbObjectBuilder.append(field, value);
}
}
return dbObjectBuilder.get();
}
示例14: 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();
}
示例15: copyDBObject
import com.mongodb.BasicDBObjectBuilder; //导入方法依赖的package包/类
/**
* Does a deep copy of an object to allow for subsequent modification
*/
public static DBObject copyDBObject(DBObject dbObject)
{
DBObject orig = dbObject;
BasicDBObjectBuilder dbObjectBuilder = BasicDBObjectBuilder.start();
for (String field : orig.keySet())
{
Object value = orig.get(field);
dbObjectBuilder.add(field, value);
}
return dbObjectBuilder.get();
}