/** * * @param id * @param rev * @return * @throws DocumentNotFoundException if the document was not found. * @deprecated use get(String id, Options options) */ public T get(String id, String rev) { return db.get(type, id, rev); }
/** * * @param id * @return * @throws DocumentNotFoundException if the document was not found. */ public T get(String id) { return db.get(type, id); } /**
/** * * @param id * @param options * @return * @throws DocumentNotFoundException if the document was not found. */ public T get(String id, Options options) { return db.get(type, id, options); } /**
public PhoneCall findBySessionId(String sessionId) { return db.get(PhoneCall.class, sessionId); } }
@Override public DesignDocument getFromDatabase(CouchDbConnector db, String designDocumentId) { return db.get(DesignDocument.class, designDocumentId); }
/** * Returns a document identified by the docId from the database. * * @param docId document id. * @return document in the database in JsonNode format. */ @Nullable public <T> T getDocument(String docId, Class<T> docType) { return dbConnector.get(docType, docId); }
/** * Returns a document identified by the docId from the database. * * @param docId document id. * @return document in the database in JsonNode format. */ @Nullable public <T> T getDocument(String docId, Class<T> docType) { return dbConnector.get(docType, docId); }
public static JsonNode fetchDocument(String docId) { return connector.get(JsonNode.class, docId); }
private static List<Map<String, Object>> loadDocuments(List<String> allDocIds, CouchDbConnector couchDb) { List<Map<String, Object>> loadedDocuments = new ArrayList<Map<String, Object>>(); for (String id : allDocIds) { Map<String, Object> element = couchDb.get(Map.class, id); removeIdTag(element); removeRevisionTag(element); loadedDocuments.add(element); } return loadedDocuments; }
private static List<Map<String, Object>> loadDocuments(List<String> allDocIds, CouchDbConnector couchDb) { List<Map<String, Object>> loadedDocuments = new ArrayList<Map<String, Object>>(); for (String id : allDocIds) { Map<String, Object> element = couchDb.get(Map.class, id); removeIdTag(element); removeRevisionTag(element); loadedDocuments.add(element); } return loadedDocuments; }
/** * Retrieve an entry from the store with only selected fields. * * @param key identifier of the document in the database * @param fields list of fields to be loaded from the database */ @Override public T get(final K key, final String[] fields) { final Map<String, Object> result; try { result = db.get(Map.class, key.toString()); return newInstance(result, getFieldsToQuery(fields)); } catch (Exception e) { LOG.info(e.getMessage(), e); return null; } }
private boolean designDocContainsAllView() { if (db.contains(stdDesignDocumentId)) { DesignDocument dd = db.get(DesignDocument.class, stdDesignDocumentId); return dd.containsView("all"); } return false; }
public void removeAll() { try { for (CouchDbTrigger doc : getAll()) { db.delete(db.get(CouchDbTrigger.class, doc.getId())); } } catch (Exception e) { logger.error(e.getMessage(), e); } } }
public void removeAll() { try { for (CouchDbJobDetail doc : getAll()) { db.delete(db.get(CouchDbJobDetail.class, doc.getId())); } } catch (Exception e) { logger.error(e.getMessage(), e); } } }
public void removeAll() { try { for (CouchDbCalendar doc : getAll()) { db.delete(db.get(CouchDbCalendar.class, doc.getId())); } } catch (Exception e) { logger.error(e.getMessage(), e); } } }
/** * Deletes the object with the given key * * @param key the key of the object * @return whether the object was successfully deleted */ @Override public boolean delete(K key) { if (key == null) { deleteSchema(); createSchema(); return true; } final String keyString = key.toString(); final Map<String, Object> referenceData = db.get(Map.class, keyString); return StringUtils.isNotEmpty(db.delete(keyString, referenceData.get("_rev").toString())); }
/** * Deletes the object with the given key * * @param key the key of the object * @return whether the object was successfully deleted */ @Override public boolean delete(K key) throws GoraException { if (key == null) { deleteSchema(); createSchema(); return true; } try { final String keyString = key.toString(); final Map<String, Object> referenceData = db.get(Map.class, keyString); return StringUtils.isNotEmpty(db.delete(keyString, referenceData.get("_rev").toString())); } catch (Exception e) { throw new GoraException(e); } }
/** * Retrieve an entry from the store with only selected fields. * * @param key identifier of the document in the database * @param fields list of fields to be loaded from the database */ @Override public T get(final K key, final String[] fields) throws GoraException { final Map<String, Object> result; try { result = db.get(Map.class, key.toString()); return newInstance(result, getFieldsToQuery(fields)); } catch (DocumentNotFoundException e) { return null ; } catch (GoraException e) { throw e; } catch (Exception e) { throw new GoraException(e); } }
private static void checkDocument(CouchDbConnector couchDb, Map<String, Object> expectedDocument, String expectedId) throws Error { // Element must be in database Map<String, Object> element = couchDb.get(Map.class, expectedId); // We remove rev because it is impossible to know by the end // user removeRevisionTag(element); if (!deepEquals(element, expectedDocument)) { throw FailureHandler.createFailure( "Expected element # %s # is not found but # %s # was found.", jsonStringify(expectedDocument), jsonStringify(element)); } }
private static void checkDocument(CouchDbConnector couchDb, Map<String, Object> expectedDocument, String expectedId) throws Error { // Element must be in database Map<String, Object> element = couchDb.get(Map.class, expectedId); // We remove rev because it is impossible to know by the end // user removeRevisionTag(element); if (!deepEquals(element, expectedDocument)) { throw FailureHandler.createFailure( "Expected element # %s # is not found but # %s # was found.", jsonStringify(expectedDocument), jsonStringify(element)); } }