/** * Creates a projection that includes all of the given fields. * * @param fieldNames the field names * @return the projection */ public static Bson include(final String... fieldNames) { return include(asList(fieldNames)); }
@Override public SessionData get(String sessionId) { Document doc = this.sessions .find(eq(SESSION_ID, sessionId)) .projection(include(SESSION_DATA)) .first(); if (doc == null) { return null; } String sessionStored = doc.getString(SESSION_DATA); SessionData sessionData = transcoder.decode(sessionStored); return sessionData; }
/** * Creates a projection that includes all of the given fields. * * @param fieldNames the field names * @return the projection */ public static Bson include(final String... fieldNames) { return include(asList(fieldNames)); }
@Override protected void recordBlobPath() { path.addLast(KEY_BLOB_DATA); binaryKeys.add(Projections.include(StringUtils.join(path, "."))); path.removeLast(); } }
@Override public Iterable<String> loadAllKeys() { System.out.println("LoadAllKeys"); List<String> keys = new LinkedList<String>(); FindIterable<Document> ids = collection.find().projection(Projections.include("_id")); for (Document document : ids) { keys.add(document.get("_id").toString()); } return keys; }
@Override public QueryResult startsWith(String id, QueryOptions options) { Bson regex = Filters.regex("ids", Pattern.compile("^" + id)); Bson include = Projections.include("ids", "chromosome", "start", "end"); return mongoDBCollection.find(regex, include, options); }
@Override public QueryResult startsWith(String id, QueryOptions options) { Bson regex = Filters.regex("ids", Pattern.compile("^" + id)); Bson include = Projections.include("ids", "chromosome", "start", "end"); return mongoDBCollection.find(regex, include, options); }
@Override public QueryResult startsWith(String id, QueryOptions options) { Bson regex = Filters.regex("transcripts.xrefs.id", Pattern.compile("^" + id)); Bson include = Projections.include("id", "name", "chromosome", "start", "end"); return mongoDBCollection.find(regex, include, options); }
@Override public QueryResult startsWith(String id, QueryOptions options) { Bson regex = Filters.regex("transcripts.xrefs.id", Pattern.compile("^" + id)); Bson include = Projections.include("id", "name", "chromosome", "start", "end"); return mongoDBCollection.find(regex, include, options); }
@Override public QueryResult startsWith(String id, QueryOptions options) { Bson regex = Filters.regex("transcripts.xrefs.id", Pattern.compile("^" + id)); Bson include = Projections.include("id", "name", "chromosome", "start", "end"); return mongoDBCollection.find(regex, include, options); }
@Override public QueryResult contains(String id, QueryOptions options) { Bson regex = Filters.regex("transcripts.xrefs.id", Pattern.compile("\\w*" + id + "\\w*")); Bson include = Projections.include("id", "name", "chromosome", "start", "end"); return mongoDBCollection.find(regex, include, options); }
@Override public long getStudyId(long familyId) throws CatalogDBException { Bson query = new Document(PRIVATE_UID, familyId); Bson projection = Projections.include(PRIVATE_STUDY_ID); QueryResult<Document> queryResult = familyCollection.find(query, projection, null); if (!queryResult.getResult().isEmpty()) { Object studyId = queryResult.getResult().get(0).get(PRIVATE_STUDY_ID); return studyId instanceof Number ? ((Number) studyId).longValue() : Long.parseLong(studyId.toString()); } else { throw CatalogDBException.uidNotFound("Family", familyId); } }
@Override public long getStudyId(long sampleId) throws CatalogDBException { Bson query = new Document(PRIVATE_UID, sampleId); Bson projection = Projections.include(PRIVATE_STUDY_ID); QueryResult<Document> queryResult = sampleCollection.find(query, projection, null); if (!queryResult.getResult().isEmpty()) { Object studyId = queryResult.getResult().get(0).get(PRIVATE_STUDY_ID); return studyId instanceof Number ? ((Number) studyId).longValue() : Long.parseLong(studyId.toString()); } else { throw CatalogDBException.uidNotFound("Sample", sampleId); } }
@Override public long getStudyId(long interpretationId) throws CatalogDBException { Bson query = new Document(PRIVATE_UID, interpretationId); Bson projection = Projections.include(PRIVATE_STUDY_ID); QueryResult<Document> queryResult = interpretationCollection.find(query, projection, null); if (!queryResult.getResult().isEmpty()) { Object studyId = queryResult.getResult().get(0).get(PRIVATE_STUDY_ID); return studyId instanceof Number ? ((Number) studyId).longValue() : Long.parseLong(studyId.toString()); } else { throw CatalogDBException.uidNotFound("Interpretation", interpretationId); } }
@Override public long getStudyId(long panelUid) throws CatalogDBException { Bson query = new Document(PRIVATE_UID, panelUid); Bson projection = Projections.include(PRIVATE_STUDY_ID); QueryResult<Document> queryResult = panelCollection.find(query, projection, null); if (!queryResult.getResult().isEmpty()) { Object studyId = queryResult.getResult().get(0).get(PRIVATE_STUDY_ID); return studyId instanceof Number ? ((Number) studyId).longValue() : Long.parseLong(studyId.toString()); } else { throw CatalogDBException.uidNotFound("Panel", panelUid); } }
/** * Return the status of EDGE node. * * @param user user name */ public String getEdgeStatus(String user) { Document d = findOne(USER_EDGE, eq(ID, user), fields(include(EDGE_STATUS), excludeId())).orElse(null); return (d == null ? "" : d.getString(EDGE_STATUS)); }
private Optional<Document> libDocument(String user, String imageFullName, LibStatus status) { return findOne(MongoCollections.IMAGES, imageLibraryCondition(user, imageFullName, status), fields(include(LIBRARIES), excludeId())); }
@Override public Set<String> findSagas(Class<?> sagaType, AssociationValue associationValue) { final BasicDBObject value = associationValueQuery(sagaType, associationValue); MongoCursor<Document> dbCursor = mongoTemplate.sagaCollection().find(value).projection(include("sagaIdentifier")).iterator(); Set<String> found = new TreeSet<>(); while (dbCursor.hasNext()) { found.add((String) dbCursor.next().get("sagaIdentifier")); } return found; }
private List<String> getKeys(Bson filter) { MongoCollection<Document> collection = collectionProvider.getCollection(); List<String> result = new ArrayList<>(); collection .find(filter) .projection(fields(Projections.include(RopertyMongoDbAttribute.KEY.getName()), excludeId())) .forEach((Block<Document>) doc -> result.add(doc.getString(RopertyMongoDbAttribute.KEY.getName()))); return result; }
/** * {@inheritDoc} */ @Override public final Source<ThingMetadata, NotUsed> getThingMetadata(final String thingId) { log.debug("Retrieving Thing Metadata for Thing: <{}>", thingId); final Bson filter = eq(FIELD_ID, thingId); return Source.fromPublisher(collection.find(filter) .projection(Projections.include(FIELD_REVISION, FIELD_POLICY_ID, FIELD_POLICY_REVISION))) .map(mapThingMetadataToModel()) .orElse(defaultThingMetadata()); }