use of com.mongodb.client.model.UpdateOptions in project zeppelin by apache.
the class MongoNotebookRepo method saveNote.
private void saveNote(Note note) {
Document doc = noteToDocument(note);
notes.replaceOne(eq(Fields.ID, note.getId()), doc, new UpdateOptions().upsert(true));
}
use of com.mongodb.client.model.UpdateOptions in project zeppelin by apache.
the class MongoNotebookRepo method completeFolder.
/**
* create until parent folder if not exists.
*
* @param splitPath path to completed.
* @return direct parent folder id
*/
private String completeFolder(String[] splitPath) {
String pId = "0";
for (String currentPath : splitPath) {
Document query = new Document(Fields.PID, pId).append(Fields.IS_DIR, true).append(Fields.NAME, currentPath);
String cId = new ObjectId().toString();
Document doc = new Document("$setOnInsert", new Document(Fields.ID, cId).append(Fields.PID, pId).append(Fields.IS_DIR, true).append(Fields.NAME, currentPath));
Document exist = folders.find(query).first();
if (exist == null) {
folders.updateOne(query, doc, new UpdateOptions().upsert(true));
pId = cId;
} else {
pId = exist.getString(Fields.ID);
}
}
return pId;
}
use of com.mongodb.client.model.UpdateOptions in project zeppelin by apache.
the class MongoNotebookRepo method saveNotePath.
/**
* save note to path.
*
* @param noteId note id
* @param pId note parent folder id
*/
private void saveNotePath(String noteId, String noteName, String pId) {
Document filter = new Document(Fields.ID, noteId);
Document doc = new Document(Fields.ID, noteId).append(Fields.PID, pId).append(Fields.IS_DIR, false).append(Fields.NAME, noteName);
folders.replaceOne(filter, doc, new UpdateOptions().upsert(true));
}
Aggregations