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


Java Document.getInteger方法代码示例

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


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

示例1: getPageViews

import org.bson.Document; //导入方法依赖的package包/类
/**
 * Return pageViews of a bed
 * @param gardenLocation
 * @param uploadId
 * @return
 */
public int getPageViews(String gardenLocation, String uploadId)
{
    Document filterDoc = new Document();
    filterDoc.append("gardenLocation", gardenLocation);
    filterDoc.append("uploadId", uploadId);

    Iterator<Document> bedItr = bedCollection.find(filterDoc).iterator();

    try {
        if(bedItr.hasNext()) {
            Document bed = bedItr.next();
            Document bedMetadata = (Document)bed.get("metadata");

            return bedMetadata.getInteger("pageViews");
        }
        else throw new RuntimeException("No bed found for gardenLocation=" + gardenLocation + " uploadId=" + uploadId);
    }
    catch(Exception e)
    {
        e.printStackTrace();
        throw e;
    }

}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-revolverenguardia-1,代码行数:31,代码来源:BedController.java

示例2: getProductStatusByAgentId

import org.bson.Document; //导入方法依赖的package包/类
/**
 * 获取 产品 是否被激活
 * 激活的定义为:旗下采集器至少有一个被激活
 *
 * @param agentId
 * @return True 被激活
 */
public Integer getProductStatusByAgentId(String agentId) {
    Integer status = null;
    if (!ObjectId.isValid(agentId)) {
        return null;
    }
    Document agentDocument = this.database.getCollection("agents")
            .find(eq("_id", new ObjectId(agentId)))
            .first();
    if (agentDocument != null) {
        ObjectId productId = agentDocument.getObjectId("product_id");
        if (productId != null) {
            Document productDocument = this.database.getCollection("products")
                    .find(eq("_id", productId))
                    .first();
            if (productDocument != null) {
                status = productDocument.getInteger("status");
            }
        }
    }

    return status;
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:30,代码来源:MongoStorage.java

示例3: aggregatedResourceStatusFromDocument

import org.bson.Document; //导入方法依赖的package包/类
public static AggregatedResourceStatus aggregatedResourceStatusFromDocument(Document document) {
  Document id = (Document) document.get("_id");
  Resource resource = resourceFromStatusRef((Document) id.get("resource"));

  long totalCount = document.getInteger("count");

  List<Document> statuses = (List<Document>) document.get("statuses");

  List<AggregatedStatus> aggregatedStatuses = statuses
      .stream()
      .map(DocumentMapper::aggregatedStatusFromDocument)
      .collect(Collectors.toList());

  AggregatedResourceStatus status = new AggregatedResourceStatus();
  status.setCount(totalCount);
  status.setResource(resource);
  status.setResourceStatuses(aggregatedStatuses);


  return status;
}
 
开发者ID:YagelNasManit,项目名称:environment.monitor,代码行数:22,代码来源:DocumentMapper.java

示例4: getFeatreFromRowInternal

import org.bson.Document; //导入方法依赖的package包/类
public Object getFeatreFromRowInternal(Document row, String feature, String type) {

        if (type.startsWith(athenaFeatureField.varintType)) {
            return row.getInteger(feature);
        } else if (type.startsWith(athenaFeatureField.bigintType)) {
            Long l = row.getLong(feature);
            return l;
        } else if (type.startsWith(athenaFeatureField.doubleType)) {
            Double d = row.getDouble(feature);
            return d;
        } else if (type.startsWith(athenaFeatureField.timestampType)) {
            return row.getDate(feature);
        } else {
            log.warn("[getFeatreFromRowInternal] Not supported type :{}", type);
            return null;
        }

    }
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:FeatureDatabaseMgmtManager.java

示例5: load

import org.bson.Document; //导入方法依赖的package包/类
@Override
public Supplement load(String key) {
    log.info("Load {}", key);
    Document document = (Document) collection.find(eq("_id", key)).first();
    String name = (String) document.get("name");
    Integer price = document.getInteger("price");
    return new Supplement(name, price);
}
 
开发者ID:gAmUssA,项目名称:testcontainers-hazelcast,代码行数:9,代码来源:MongoMapStore.java

示例6: loadAll

import org.bson.Document; //导入方法依赖的package包/类
@Override
public Map<String, Supplement> loadAll(Collection keys) {
    log.info("LoadAll {}", keys);
    HashMap<String, Supplement> result = new HashMap<String, Supplement>();

    FindIterable<Document> id = collection.find(in("_id", keys));
    for (Document document : id) {
        String name = (String) document.get("name");
        Integer price = document.getInteger("price");
        result.put(document.get("_id").toString(), new Supplement(name, price));
    }
    return result;
}
 
开发者ID:gAmUssA,项目名称:testcontainers-hazelcast,代码行数:14,代码来源:MongoMapStore.java

示例7: writeToBedMetadataSheet

import org.bson.Document; //导入方法依赖的package包/类
/**
 * Write Bed metadata to the bed metadata sheet
 * @param feedbackWriter
 * @param uploadId
 * @return
 */
public boolean writeToBedMetadataSheet(FeedbackWriter feedbackWriter, String uploadId)
{
    if (!ExcelParser.isValidUploadId(db, uploadId))
        return false;

    FindIterable iter = bedCollection.find(
            eq("uploadId", uploadId)

    );
    Iterator iterator = iter.iterator();

    while (iterator.hasNext()) {
        Document onBed = (Document) iterator.next();

        try {
            String[] dataToWrite = new String[COL_BED_FIELDS];
            Document metadata = (Document) onBed.get("metadata");
            //Document stuff = Document.parse(getGardenLocationsJSON(onBed.getString("id")));


            Integer pageViews = metadata.getInteger("pageViews");
            Integer qrScans = metadata.getInteger("qrScans");

            dataToWrite[COL_BED_GRDNLOC] = onBed.getString("gardenLocation");
            dataToWrite[COL_BED_PAGEVIEWS] = pageViews.toString();
            dataToWrite[COL_BED_QRSCANS] = qrScans.toString();

            feedbackWriter.writeToSheet(dataToWrite, FeedbackWriter.SHEET_BEDMETADATA);
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.err.println("ERROR ON BED " + onBed);
        }
    }
    return true;
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-revolverenguardia-1,代码行数:44,代码来源:PlantController.java

示例8: aggregatedStatusFromDocument

import org.bson.Document; //导入方法依赖的package包/类
private static AggregatedStatus aggregatedStatusFromDocument(Document document) {

    Status status = Status.fromSerialNumber(document.getInteger("statusOrdinal"));
    long count = document.getInteger("count");

    AggregatedStatus aggregatedStatus = new AggregatedStatus();
    aggregatedStatus.setStatus(status);
    aggregatedStatus.setCount(count);

    return aggregatedStatus;
  }
 
开发者ID:YagelNasManit,项目名称:environment.monitor,代码行数:12,代码来源:DocumentMapper.java

示例9: raffle

import org.bson.Document; //导入方法依赖的package包/类
public String raffle(boolean mock) {
	FindIterable<Document> docs = playData.find();
	ArrayList<String> playBag = new ArrayList<String>();
	for (Document doc : docs) {
		String name = doc.getString("name");
		int tickets = doc.getInteger("tickets");
		for (int i=0; i < tickets; i++) {
			playBag.add(name);
		}
		if (!mock) {
			playData.updateOne(eq("name",name),set("tickets",0));
			playData.updateOne(eq("name",name),set("gold",100));
		}
	}
	if (playBag.size() > 0) {
		Collections.shuffle(playBag);
		return playBag.get(0);
	}
	else return null;
}
 
开发者ID:JohnChernoff,项目名称:BingoChess,代码行数:21,代码来源:BingoChess.java

示例10: writeToPlantMetadataSheet

import org.bson.Document; //导入方法依赖的package包/类
/**
 * Write plant metadata to the plant metadata sheet
 * @param feedbackWriter
 * @param uploadId
 * @return
 */
public boolean writeToPlantMetadataSheet(FeedbackWriter feedbackWriter, String uploadId)
{
    if (!ExcelParser.isValidUploadId(db, uploadId))
        return false;

    //Loop through all plants
    FindIterable iter = plantCollection.find(
            eq("uploadId", uploadId)

    );
    Iterator iterator = iter.iterator();

    while (iterator.hasNext()) {
        Document onPlant = (Document) iterator.next();

        try {
            String[] dataToWrite = new String[COL_PLANT_FIELDS];
            Document metadata = (Document) onPlant.get("metadata");
            Document feedback = Document.parse(getPlantFeedbackByPlantIdJSON(onPlant.getString("id"), uploadId));


            Integer likeCount = feedback.getInteger("likeCount");
            Integer dislikeCount = feedback.getInteger("dislikeCount");
            Integer commentCount = feedback.getInteger("commentCount");
            Integer pageViews = metadata.getInteger("pageViews");

            dataToWrite[COL_PLANT_PLANTID] = onPlant.getString("id");
            dataToWrite[COL_PLANT_COMMONNAME] = onPlant.getString("commonName");
            dataToWrite[COL_PLANT_CULTIVAR] = onPlant.getString("cultivar");
            dataToWrite[COL_PLANT_GRDNLOC] = onPlant.getString("gardenLocation");


            dataToWrite[COL_PLANT_LIKES] = likeCount.toString();
            dataToWrite[COL_PLANT_DISLIKES] = dislikeCount.toString();
            dataToWrite[COL_PLANT_COMMENTS] = commentCount.toString();
            dataToWrite[COL_PLANT_PAGEVIEWS] = pageViews.toString();

            feedbackWriter.writeToSheet(dataToWrite, FeedbackWriter.SHEET_METADATA);
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.err.println("ERROR ON PLANT " + onPlant);
        }
    }
    return true;
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-revolverenguardia-1,代码行数:54,代码来源:PlantController.java


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