@Test public void saveLoadDocument() throws IOException, SQLException { Path tempDir = Files.createTempDirectory("foo"); CorpusDb storage = new CorpusDb(tempDir); Map<Integer, CorpusDocument> docMap = saveDocuments(storage); for (Integer key : docMap.keySet()) { CorpusDocument expected = docMap.get(key); CorpusDocument actual = storage.loadDocumentByKey(key); Assert.assertEquals(expected.id, actual.id); Assert.assertEquals(expected.content, actual.content); } IOUtil.deleteTempDir(tempDir); }
public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); }
CorpusDb { public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); } }
CorpusDb { public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); } CorpusDb(Path dbRoot); private  CorpusDb(JdbcConnectionPool connectionPool); }
CorpusDb { public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); } CorpusDb(Path dbRoot); private  CorpusDb(JdbcConnectionPool connectionPool); void addAll(List<CorpusDocument> docs); void generateTables(); void saveSentences(int docKey, List<String> sentences); List<SentenceSearchResult> search(String text); CorpusDocument loadDocumentByKey(int key); void addDocs(Path corpusFile); }
CorpusDb { public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); } CorpusDb(Path dbRoot); private  CorpusDb(JdbcConnectionPool connectionPool); void addAll(List<CorpusDocument> docs); void generateTables(); void saveSentences(int docKey, List<String> sentences); List<SentenceSearchResult> search(String text); CorpusDocument loadDocumentByKey(int key); void addDocs(Path corpusFile);  }