本文整理汇总了Java中org.bson.Document.append方法的典型用法代码示例。如果您正苦于以下问题:Java Document.append方法的具体用法?Java Document.append怎么用?Java Document.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bson.Document
的用法示例。
在下文中一共展示了Document.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeColumn
import org.bson.Document; //导入方法依赖的package包/类
private Document encodeColumn(OracleColumn column) {
Document document = new Document();
document.append(SyncAttrs.COLUMN_NAME, column.getColumnName());
document.append(SyncAttrs.COLUMN_ALIAS, column.getColumnAlias());
document.append(SyncAttrs.COLUMN_TYPE, column.getColumnType());
document.append(SyncAttrs.TABLE_ALIAS, column.getTableAlias());
if (column.isParentColumn()) {
document.append(SyncAttrs.IS_PARENT_COLUMN, column.isParentColumn());
}
if (column.getPrecision() != 0) {
document.append(SyncAttrs.PRECISION, column.getPrecision());
}
if (column.isNullable()) {
document.append(SyncAttrs.IS_NULLABLE, column.isNullable());
}
return document;
}
示例2: encodeJoinedTable
import org.bson.Document; //导入方法依赖的package包/类
private Document encodeJoinedTable(JoinedTable joinedTable) {
Document document = new Document();
document.append(SyncAttrs.JOIN_TYPE, String.valueOf(joinedTable.getJoinType()));
document.append(SyncAttrs.FILTERS, encodeFilters(joinedTable.getFilters()));
OracleTable innerJoinedTable = joinedTable.getTable();
document.append(SyncAttrs.TABLE_NAME, innerJoinedTable.getTableName());
document.append(SyncAttrs.TABLE_ALIAS, innerJoinedTable.getTableAlias());
if (innerJoinedTable.getJoinedTables() != null) {
List<Document> nestedJoinedTableList = new ArrayList<Document>();
for (JoinedTable nestedJoinedTable : innerJoinedTable.getJoinedTables()) {
nestedJoinedTableList.add(encodeJoinedTable(nestedJoinedTable));
}
document.append(SyncAttrs.JOINED_TABLES, nestedJoinedTableList);
}
return document;
}
示例3: insertReport
import org.bson.Document; //导入方法依赖的package包/类
/**
* Inserts a new report to the DB
*
* @param report contains all data for insertion
*/
public static void insertReport(Report report) {
Document newDocument = new Document();
newDocument.append("priority", report.getPriority())
.append("comment", report.getComment())
.append("resolved", report.isResolved())
.append("city_item_id", report.getCityItemId());
if (report.getReportDate() != null) {
newDocument.append("report_date", report.getReportDate().getTime());
}
if (report.getResolveDate() != null) {
newDocument.append("resolve_date", report.getResolveDate().getTime());
}
MongoDatabase db = Configurator.INSTANCE.getDatabase();
MongoCollection collection = db.getCollection(COLLECTION);
collection.insertOne(newDocument); //TODO check if succeeds
}
示例4: incrementMetadata
import org.bson.Document; //导入方法依赖的package包/类
@Test
public void incrementMetadata() {
//This method is called from inside of getPlantByPlantId();
boolean myPlant = plantController.
incrementMetadata("58d1c36efb0cac4e15afd278", "pageViews");
assertFalse(myPlant);
boolean myPlant2 = plantController.incrementMetadata("16001.0","pageViews");
assertTrue(myPlant2);
//This is necessary to test the data separately from getPlantByPlantId();
Document searchDocument = new Document();
searchDocument.append("id", "16001.0");
MongoClient mongoClient = new MongoClient();
MongoDatabase db = mongoClient.getDatabase(databaseName);
MongoCollection<Document> plantCollection = db.getCollection("plants");
String before = JSON.serialize(plantCollection.find(searchDocument));
plantController.incrementMetadata("16001.0","pageViews");
String after = JSON.serialize(plantCollection.find(searchDocument));
assertFalse(before.equals(after));
}
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-3-sixguysburgers-fries,代码行数:23,代码来源:UnorganizedTests.java
示例5: encodeColumnAttrMapper
import org.bson.Document; //导入方法依赖的package包/类
private Document encodeColumnAttrMapper(ColumnAttrMapper mapper) {
Document document = new Document();
if (mapper.getColumn() != null) {
document.append(SyncAttrs.COLUMN_DATA, encodeColumn(mapper.getColumn()));
}
if (mapper.isParentColumn()) {
document.append(SyncAttrs.IS_PARENT_COLUMN, mapper.isParentColumn());
}
if (mapper.isSeqGenerated()) {
document.append(SyncAttrs.IS_SEQ_GENERATED, mapper.isSeqGenerated());
document.append(SyncAttrs.SEQ_NAME, mapper.getSeqName());
}
if (mapper.getIgnoreList() != null && !mapper.getIgnoreList().isEmpty()) {
document.append(SyncAttrs.IGNORE_LIST, mapper.getIgnoreList());
}
if (mapper.getLiteralValueForColumn() != null) {
document.append(SyncAttrs.LITERAL_VALUE_FOR_COLUMN, encodeLiteral(mapper.getLiteralValueForColumn()));
}
if (mapper.getAttribute() != null) {
document.append(SyncAttrs.ATTRIBUTE, encodeMongoAttribute(mapper.getAttribute()));
}
if (mapper.isParentAttribute()) {
document.append(SyncAttrs.IS_PARENT_ATTRIBUTE, mapper.isParentAttribute());
document.append(SyncAttrs.PARENT_ATTRIBUTE_NODE, mapper.getParentAttributeNode());
}
if (mapper.isChildAttribute()) {
document.append(SyncAttrs.IS_CHILD_ATTRIBUTE, mapper.isChildAttribute());
document.append(SyncAttrs.CHILD_ATTRIBUTE_NODE, mapper.getChildAttributeNode());
}
if (mapper.getReplacementMap() != null && !mapper.getReplacementMap().isEmpty()) {
document.append(SyncAttrs.REPLACEMENT_MAP, mapper.getReplacementMap());
}
return document;
}
示例6: setRSVPExclusivity
import org.bson.Document; //导入方法依赖的package包/类
/**
* Sets whether or not a schedule should allow users to RSVP for multiple group
*/
public void setRSVPExclusivity(String cId, Boolean bool)
{
Document doc = Main.getDBDriver().getScheduleCollection().find(eq("_id", cId)).first();
if(!doc.containsKey("rsvp_exclusivity"))
{
doc.append("rsvp_exclusivity", bool);
Main.getDBDriver().getScheduleCollection().replaceOne(eq("_id", cId), doc);
} else
{
Main.getDBDriver().getScheduleCollection().updateOne(eq("_id", cId), set("rsvp_exclusivity", bool));
}
}
示例7: saveVote
import org.bson.Document; //导入方法依赖的package包/类
public Vote saveVote(Vote vote) {
Document doc = new Document();
doc.append("userId", vote.getUserId());
doc.append("linkId", vote.getLinkId());
doc.append("createdAt", Scalars.dateTime.getCoercing().serialize(vote.getCreatedAt()));
votes.insertOne(doc);
return new Vote(
doc.get("_id").toString(),
vote.getCreatedAt(),
vote.getUserId(),
vote.getLinkId());
}
示例8: listFlowers
import org.bson.Document; //导入方法依赖的package包/类
public String listFlowers(Map<String, String[]> queryParams) {
Document filterDoc = new Document();
if (queryParams.containsKey("cultivar")) {
String targetCultivar = queryParams.get("cultivar")[0];
filterDoc = filterDoc.append("cultivar", targetCultivar);
}
if (queryParams.containsKey("source")) {
String targetSource = queryParams.get("source")[0];
filterDoc = filterDoc.append("source", targetSource);
}
if (queryParams.containsKey("gardenLocation")) {
String targetLocation = queryParams.get("gardenLocation")[0];
filterDoc = filterDoc.append("gardenLocation", targetLocation);
}
if (queryParams.containsKey("year")) {
int targetYear = Integer.parseInt(queryParams.get("year")[0]);
filterDoc = filterDoc.append("year", targetYear);
}
FindIterable<Document> matchingFlowers = flowerCollection.find(filterDoc);
return JSON.serialize(matchingFlowers);
}
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-2-spraguesanborn,代码行数:28,代码来源:FlowerController.java
示例9: addBedVisit
import org.bson.Document; //导入方法依赖的package包/类
/**
* When a user views a web page a Bed page a Bed Visit is added.
* By that we mean that bed's pageViews field is incremented and a new {visit : ObjectId()} is added to visits
* @param gardenLocation
* @param uploadId
* @return
*/
public boolean addBedVisit(String gardenLocation, String uploadId) {
Document filterDoc = new Document();
filterDoc.append("gardenLocation", gardenLocation);
filterDoc.append("uploadId", uploadId);
Document visit = new Document();
visit.append("visit", new ObjectId());
incrementBedMetadata(gardenLocation, "pageViews", uploadId);
return null != bedCollection.findOneAndUpdate(filterDoc, push("metadata.bedVisits", visit));
}
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-revolverenguardia-1,代码行数:21,代码来源:BedController.java
示例10: getGardenLocations
import org.bson.Document; //导入方法依赖的package包/类
/**
* Takes `uploadID` and returns all bed names as an array of Strings
* @param uploadID - - the year that the data was uploaded
* @return an array of strings
*/
public String[] getGardenLocations(String uploadID){
Document filter = new Document();
filter.append("uploadID", uploadID);
DistinctIterable<String> bedIterator = plantCollection.distinct("gardenLocation", filter, String.class);
List<String> beds = new ArrayList<String>();
for(String s : bedIterator)
{
beds.add(s);
}
return beds.toArray(new String[beds.size()]);
}
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-dorfner-v2,代码行数:17,代码来源:PlantController.java
示例11: encodeMongoAttribute
import org.bson.Document; //导入方法依赖的package包/类
private Document encodeMongoAttribute(MongoAttribute mongoAttribute) {
logger.debug("Encode called for MongoAttribute");
Document document = new Document();
document.append(SyncAttrs.ATTRIBUTE_NAME, mongoAttribute.getAttributeName());
document.append(SyncAttrs.ATTRIBUTE_TYPE, String.valueOf(mongoAttribute.getAttributeType()));
document.append(SyncAttrs.IS_IDENTIFIER, mongoAttribute.isIdentifier());
if (mongoAttribute.getMappedOracleColumn() != null) {
document.append(SyncAttrs.COLUMN_DATA, encodeColumn(mongoAttribute.getMappedOracleColumn()));
}
document.append(SyncAttrs.DEFAULT_VALUE, mongoAttribute.getDefaultValue());
logger.debug("Encoded Document : " + document);
return document;
}
示例12: setRSVPLoggingChannel
import org.bson.Document; //导入方法依赖的package包/类
/**
* Sets a schedule's channel to be used for RSVP logging
*/
public void setRSVPLoggingChannel(String cId, String channelIdentifier)
{
Document doc = Main.getDBDriver().getScheduleCollection().find(eq("_id", cId)).first();
if(!doc.containsKey("rsvp_logging"))
{
doc.append("rsvp_logging", channelIdentifier);
Main.getDBDriver().getScheduleCollection().replaceOne(eq("_id", cId), doc);
} else
{
Main.getDBDriver().getScheduleCollection().updateOne(eq("_id", cId), set("rsvp_logging", channelIdentifier));
}
}
示例13: listPlantIDs
import org.bson.Document; //导入方法依赖的package包/类
/**
* Returns a list of all distinct plantIds in the plants collection and with the current uploadId
* @param uploadID
* @return
*/
public String[] listPlantIDs(String uploadID){
Document filter = new Document();
filter.append("uploadId", uploadID);
DistinctIterable<String> idIterator = plantCollection.distinct("id", filter, String.class);
List<String> id = new ArrayList<String>();
for(String s : idIterator)
{
id.add(s);
}
return id.toArray(new String[id.size()]);
}
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-revolverenguardia-1,代码行数:18,代码来源:PlantController.java
示例14: aggregatedListFromAdvancedOption
import org.bson.Document; //导入方法依赖的package包/类
private Document aggregatedListFromAdvancedOption(AdvancedFeatureConstraint object) {
Document aggregatedList = new Document();
AthenaFeatureField fn = new AthenaFeatureField();
AthenaIndexField in = new AthenaIndexField();
for (int i = 0; i < object.getAdvancedOptions().size(); i++) {
if (object.getAdvancedOptions().containsKey(AdvancedFeatureConstraintType.AGGREGATE)) {
AdvancedFeatureConstraintValue value =
object.getAdvancedOptions().get(AdvancedFeatureConstraintType.AGGREGATE);
Iterator<String> params = value.getValue();
while (params.hasNext()) {
String element = params.next();
if (fn.isElements(element)) {
aggregatedList.append(element, "$" + AthenaFeatureField.FEATURE + "." + element);
} else {
aggregatedList.append(element, "$" + element);
}
}
}
}
return aggregatedList;
}
示例15: setRSVPOptions
import org.bson.Document; //导入方法依赖的package包/类
/**
* Sets the mapping of emoji->rsvp_groups for a schedule
*/
public void setRSVPOptions(String cId, Map<String, String> options)
{
Document doc = Main.getDBDriver().getScheduleCollection().find(eq("_id", cId)).first();
if(!doc.containsKey("rsvp_options"))
{
doc.append("rsvp_options", options);
Main.getDBDriver().getScheduleCollection().replaceOne(eq("_id", cId), doc);
} else
{
Main.getDBDriver().getScheduleCollection().updateOne(eq("_id", cId), set("rsvp_options", options));
}
}