@Test public void testGetAndTagDocumentDatabaseQueryString() { MemoryQuery mdq = new MemoryQuery(); mdq.requireContentFieldExists("name"); Document<MemoryType> d = io.getAndTag(mdq, "tag"); if(d==null) { fail("Get and tag could not find any document"); } if(d.getID()==null) { fail("Get and tag didn't get a document with a set ID"); } if(d.getContentFields().size()==0) { fail("Get and tag didn't get any contents in the document"); } if(d.getMetadataMap().size()==0) { fail("Get and tag didn't get any metadata in the document"); } io.getAndTag(new MemoryQuery(), "tag"); io.getAndTag(new MemoryQuery(), "tag"); d = io.getAndTag(new MemoryQuery(), "tag"); if(d!=null) { fail("Expected all documents to be tagged, but found "+d); } }
@Override public MemoryDocument getAndTag(DatabaseQuery<MemoryType> query, String ... tag) { for(String t : tag) { ((MemoryQuery) query).requireNotFetchedByStage(t); } MemoryDocument d = getDocument(query); if (d != null) { for(String t : tag) { d.tag(Document.FETCHED_METADATA_TAG, t); } } return d; }
MemoryDocumentIO implements DocumentWriter<MemoryType>,
		DocumentReader<MemoryType> { @Override public MemoryDocument getAndTag(DatabaseQuery<MemoryType> query, String ... tag) { for(String t : tag) { ((MemoryQuery) query).requireNotFetchedByStage(t); } MemoryDocument d = getDocument(query); if (d != null) { for(String t : tag) { d.tag(Document.FETCHED_METADATA_TAG, t); } } return d; } }
MemoryDocumentIO implements DocumentWriter<MemoryType>,
		DocumentReader<MemoryType> { @Override public MemoryDocument getAndTag(DatabaseQuery<MemoryType> query, String ... tag) { for(String t : tag) { ((MemoryQuery) query).requireNotFetchedByStage(t); } MemoryDocument d = getDocument(query); if (d != null) { for(String t : tag) { d.tag(Document.FETCHED_METADATA_TAG, t); } } return d; } MemoryDocumentIO(); }
MemoryDocumentIO implements DocumentWriter<MemoryType>,
		DocumentReader<MemoryType> { @Override public MemoryDocument getAndTag(DatabaseQuery<MemoryType> query, String ... tag) { for(String t : tag) { ((MemoryQuery) query).requireNotFetchedByStage(t); } MemoryDocument d = getDocument(query); if (d != null) { for(String t : tag) { d.tag(Document.FETCHED_METADATA_TAG, t); } } return d; } MemoryDocumentIO(); @Override MemoryDocument getDocument(DatabaseQuery<MemoryType> q); @Override MemoryDocument getDocumentById(DocumentID<MemoryType> id); @Override DatabaseDocument<MemoryType> getDocumentById(DocumentID<MemoryType> id,
			boolean includeInactive); @Override TailableIterator<MemoryType> getInactiveIterator(); @SuppressWarnings("unchecked") @Override List<DatabaseDocument<MemoryType>> getDocuments(
			DatabaseQuery<MemoryType> q, int limit, int skip); @Override List<DatabaseDocument<MemoryType>> getDocuments(
			DatabaseQuery<MemoryType> q, int limit); @Override long getNumberOfDocuments(DatabaseQuery<MemoryType> q); @Override DocumentFile<MemoryType> getDocumentFile(
			DatabaseDocument<MemoryType> d, String fileName); @Override boolean deleteDocumentFile(DatabaseDocument<MemoryType> d,
			String fileName); @Override List<String> getDocumentFileNames(DatabaseDocument<MemoryType> d); @Override long getActiveDatabaseSize(); @Override long getInactiveDatabaseSize(); @Override MemoryDocument getAndTag(DatabaseQuery<MemoryType> query, String ... tag); @Override Collection<DatabaseDocument<MemoryType>> getAndTag(
			DatabaseQuery<MemoryType> query, int n, String ... tag); @Override boolean markTouched(DocumentID<MemoryType> id, String tag); @Override boolean markProcessed(DatabaseDocument<MemoryType> d, String stage); @Override boolean markDiscarded(DatabaseDocument<MemoryType> d, String stage); @Override boolean markFailed(DatabaseDocument<MemoryType> d, String stage); @Override boolean markPending(DatabaseDocument<MemoryType> d, String stage); @Override boolean insert(DatabaseDocument<MemoryType> d); @Override boolean insert(DatabaseDocument<MemoryType> d, List<DocumentFile<MemoryType>> attachments); @Override boolean update(DatabaseDocument<MemoryType> d); @Override void delete(DatabaseDocument<MemoryType> d); @Override void deleteAll(); @Override void write(DocumentFile<MemoryType> df); @Override void prepare(); @Override DocumentID<MemoryType> toDocumentId(Object jsonPrimitive); @Override DocumentID<MemoryType> toDocumentIdFromJson(String json); @Override TailableIterator<MemoryType> getInactiveIterator(
			DatabaseQuery<MemoryType> query); }
MemoryDocumentIO implements DocumentWriter<MemoryType>,
		DocumentReader<MemoryType> { @Override public MemoryDocument getAndTag(DatabaseQuery<MemoryType> query, String ... tag) { for(String t : tag) { ((MemoryQuery) query).requireNotFetchedByStage(t); } MemoryDocument d = getDocument(query); if (d != null) { for(String t : tag) { d.tag(Document.FETCHED_METADATA_TAG, t); } } return d; } MemoryDocumentIO(); @Override MemoryDocument getDocument(DatabaseQuery<MemoryType> q); @Override MemoryDocument getDocumentById(DocumentID<MemoryType> id); @Override DatabaseDocument<MemoryType> getDocumentById(DocumentID<MemoryType> id,
			boolean includeInactive); @Override TailableIterator<MemoryType> getInactiveIterator(); @SuppressWarnings("unchecked") @Override List<DatabaseDocument<MemoryType>> getDocuments(
			DatabaseQuery<MemoryType> q, int limit, int skip); @Override List<DatabaseDocument<MemoryType>> getDocuments(
			DatabaseQuery<MemoryType> q, int limit); @Override long getNumberOfDocuments(DatabaseQuery<MemoryType> q); @Override DocumentFile<MemoryType> getDocumentFile(
			DatabaseDocument<MemoryType> d, String fileName); @Override boolean deleteDocumentFile(DatabaseDocument<MemoryType> d,
			String fileName); @Override List<String> getDocumentFileNames(DatabaseDocument<MemoryType> d); @Override long getActiveDatabaseSize(); @Override long getInactiveDatabaseSize(); @Override MemoryDocument getAndTag(DatabaseQuery<MemoryType> query, String ... tag); @Override Collection<DatabaseDocument<MemoryType>> getAndTag(
			DatabaseQuery<MemoryType> query, int n, String ... tag); @Override boolean markTouched(DocumentID<MemoryType> id, String tag); @Override boolean markProcessed(DatabaseDocument<MemoryType> d, String stage); @Override boolean markDiscarded(DatabaseDocument<MemoryType> d, String stage); @Override boolean markFailed(DatabaseDocument<MemoryType> d, String stage); @Override boolean markPending(DatabaseDocument<MemoryType> d, String stage); @Override boolean insert(DatabaseDocument<MemoryType> d); @Override boolean insert(DatabaseDocument<MemoryType> d, List<DocumentFile<MemoryType>> attachments); @Override boolean update(DatabaseDocument<MemoryType> d); @Override void delete(DatabaseDocument<MemoryType> d); @Override void deleteAll(); @Override void write(DocumentFile<MemoryType> df); @Override void prepare(); @Override DocumentID<MemoryType> toDocumentId(Object jsonPrimitive); @Override DocumentID<MemoryType> toDocumentIdFromJson(String json); @Override TailableIterator<MemoryType> getInactiveIterator(
			DatabaseQuery<MemoryType> query); static final int inactiveSize; }