Example usage for com.mongodb.client MongoCollection find

List of usage examples for com.mongodb.client MongoCollection find

Introduction

In this page you can find the example usage for com.mongodb.client MongoCollection find.

Prototype

FindIterable<TDocument> find(ClientSession clientSession);

Source Link

Document

Finds all documents in the collection.

Usage

From source file:com.sitewhere.device.persistence.mongodb.MongoDeviceManagement.java

License:Open Source License

/**
 * Return the {@link Document} for a device status based on device type id and
 * status code./*  ww  w .j av a2 s . com*/
 * 
 * @param deviceTypeId
 * @param code
 * @return
 * @throws SiteWhereException
 */
protected Document getDeviceStatusDocument(UUID deviceTypeId, String code) throws SiteWhereException {
    MongoCollection<Document> statuses = getMongoClient().getDeviceStatusesCollection();
    Document query = new Document(MongoDeviceStatus.PROP_DEVICE_TYPE_ID, deviceTypeId)
            .append(MongoDeviceStatus.PROP_CODE, code);
    return statuses.find(query).first();
}

From source file:com.sitewhere.device.persistence.mongodb.MongoDeviceManagement.java

License:Open Source License

/**
 * Get the {@link Document} containing device information that matches the given
 * token./* w  w  w.  ja v  a 2  s.c  om*/
 * 
 * @param token
 * @return
 * @throws SiteWhereException
 */
protected Document getDeviceDocumentByToken(String token) throws SiteWhereException {
    MongoCollection<Document> devices = getMongoClient().getDevicesCollection();
    Document query = new Document(MongoDevice.PROP_TOKEN, token);
    return devices.find(query).first();
}

From source file:com.sitewhere.device.persistence.mongodb.MongoDeviceManagement.java

License:Open Source License

/**
 * Get the {@link Document} containing device information that matches the given
 * id.//from   w  w  w.java  2  s .  com
 * 
 * @param token
 * @return
 * @throws SiteWhereException
 */
protected Document getDeviceDocumentById(UUID id) throws SiteWhereException {
    MongoCollection<Document> devices = getMongoClient().getDevicesCollection();
    Document query = new Document(MongoDevice.PROP_ID, id);
    return devices.find(query).first();
}

From source file:com.sitewhere.device.persistence.mongodb.MongoDeviceManagement.java

License:Open Source License

/**
 * Find the {@link Document} for a device assignment based on unique token.
 * /*from   ww w.  ja  v a  2 s  . c o  m*/
 * @param token
 * @return
 * @throws SiteWhereException
 */
protected Document getDeviceAssignmentDocumentByToken(String token) throws SiteWhereException {
    MongoCollection<Document> assignments = getMongoClient().getDeviceAssignmentsCollection();
    Document query = new Document(MongoDeviceAssignment.PROP_TOKEN, token);
    return assignments.find(query).first();
}

From source file:com.sitewhere.device.persistence.mongodb.MongoDeviceManagement.java

License:Open Source License

/**
 * Find the {@link Document} for a device assignment based on unique id.
 * //from   w  w  w  . ja v  a  2 s  .c  o m
 * @param token
 * @return
 * @throws SiteWhereException
 */
protected Document getDeviceAssignmentDocumentById(UUID id) throws SiteWhereException {
    MongoCollection<Document> assignments = getMongoClient().getDeviceAssignmentsCollection();
    Document query = new Document(MongoDeviceAssignment.PROP_ID, id);
    return assignments.find(query).first();
}

From source file:com.sitewhere.device.persistence.mongodb.MongoDeviceManagement.java

License:Open Source License

/**
 * Get the DBObject containing area type information that matches the given
 * token.//from  ww w  .ja va2s.c  o  m
 * 
 * @param token
 * @return
 * @throws SiteWhereException
 */
protected Document getAreaTypeDocumentByToken(String token) throws SiteWhereException {
    MongoCollection<Document> types = getMongoClient().getAreaTypesCollection();
    Document query = new Document(MongoAreaType.PROP_TOKEN, token);
    return types.find(query).first();
}

From source file:com.sitewhere.device.persistence.mongodb.MongoDeviceManagement.java

License:Open Source License

/**
 * Get the DBObject containing area type information that matches the given id.
 * //  w w w. j  a  va2s  .c  o  m
 * @param token
 * @return
 * @throws SiteWhereException
 */
protected Document getAreaTypeDocumentById(UUID id) throws SiteWhereException {
    MongoCollection<Document> types = getMongoClient().getAreaTypesCollection();
    Document query = new Document(MongoAreaType.PROP_ID, id);
    return types.find(query).first();
}

From source file:com.sitewhere.device.persistence.mongodb.MongoDeviceManagement.java

License:Open Source License

/**
 * Get the DBObject containing area information that matches the given token.
 * //  ww w  .j  av a  2 s  . c  o  m
 * @param token
 * @return
 * @throws SiteWhereException
 */
protected Document getAreaDocumentByToken(String token) throws SiteWhereException {
    MongoCollection<Document> sites = getMongoClient().getAreasCollection();
    Document query = new Document(MongoArea.PROP_TOKEN, token);
    return sites.find(query).first();
}

From source file:com.sitewhere.device.persistence.mongodb.MongoDeviceManagement.java

License:Open Source License

/**
 * Get the DBObject containing area information that matches the given id.
 * //from  w ww  . ja va 2 s .  c  o m
 * @param token
 * @return
 * @throws SiteWhereException
 */
protected Document getAreaDocumentById(UUID id) throws SiteWhereException {
    MongoCollection<Document> areas = getMongoClient().getAreasCollection();
    Document query = new Document(MongoArea.PROP_ID, id);
    return areas.find(query).first();
}

From source file:com.sitewhere.device.persistence.mongodb.MongoDeviceManagement.java

License:Open Source License

/**
 * Return the {@link Document} for the zone with the given token.
 * /*  ww  w  .ja  v  a  2  s .co  m*/
 * @param token
 * @return
 * @throws SiteWhereException
 */
protected Document getZoneDocumentByToken(String token) throws SiteWhereException {
    try {
        MongoCollection<Document> zones = getMongoClient().getZonesCollection();
        Document query = new Document(MongoZone.PROP_TOKEN, token);
        return zones.find(query).first();
    } catch (MongoClientException e) {
        throw MongoPersistence.handleClientException(e);
    }
}