@Test(threadPoolSize = 3, invocationCount = 10, timeOut = 500000) public void testXmiDBMultiplierReader() throws Exception { DataBaseConnector dbc = DBTestUtils.getDataBaseConnector(postgres); String xmisubset; synchronized (XmiDBMultiplierDifferentNsSchemaTest.class) { xmisubset = "xmisubset" + subsetCounter++; } dbc.setActiveTableSchema("xmi_text"); dbc.reserveConnection(); dbc.createSubsetTable(xmisubset, "_data.documents", "Test XMI subset"); dbc.initSubset(xmisubset, "_data.documents"); dbc.close(); CollectionReader xmiReader = CollectionReaderFactory.createReader(XmiDBMultiplierReader.class, XmiDBReader.PARAM_COSTOSYS_CONFIG_NAME, costosysConfig, XmiDBReader.PARAM_READS_BASE_DOCUMENT, true, XmiDBReader.PARAM_ANNOTATIONS_TO_LOAD, new String[]{Token.class.getCanonicalName(), Sentence.class.getCanonicalName()}, XmiDBReader.PARAM_TABLE, xmisubset, XmiDBReader.PARAM_RESET_TABLE, true ); final AnalysisEngine multiplier = AnalysisEngineFactory.createEngine(XmiDBMultiplier.class); JCas jCas = XmiDBSetupHelper.getJCasWithRequiredTypes(); List<String> tokenText = new ArrayList<>(); List<String> sentenceText = new ArrayList<>(); assertTrue(xmiReader.hasNext()); while (xmiReader.hasNext()) { xmiReader.getNext(jCas.getCas()); final JCasIterator jCasIterator = multiplier.processAndOutputNewCASes(jCas); while (jCasIterator.hasNext()) { final JCas multiplierCas = jCasIterator.next(); JCasUtil.selectSingle(multiplierCas, Header.class); JCasUtil.select(multiplierCas, Token.class).stream().map(Annotation::getCoveredText).forEach(tokenText::add); JCasUtil.select(multiplierCas, Sentence.class).stream().map(Annotation::getCoveredText).forEach(sentenceText::add); assertTrue(JCasUtil.selectSingle(multiplierCas, DBProcessingMetaData.class) != null); jCasIterator.release(); } jCas.reset(); } assertFalse(tokenText.isEmpty()); assertFalse(sentenceText.isEmpty()); }
@Override public AbstractCas next() throws AnalysisEngineProcessException { JCas jCas = getEmptyJCas(); try { if (documentDataIterator.hasNext()) { log.trace("Returning next CAS"); try { initializer.initializeAnnotationTableNames(jCas); } catch (ResourceInitializationException e) { throw new AnalysisEngineProcessException(e); } populateCas(jCas); } } catch (Throwable throwable) { log.error("Error while reading document from the database: ", throwable); throw throwable; } return jCas; }
XmiDBMultiplier extends DBMultiplier implements Initializable { @Override public AbstractCas next() throws AnalysisEngineProcessException { JCas jCas = getEmptyJCas(); try { if (documentDataIterator.hasNext()) { log.trace("Returning next CAS"); try { initializer.initializeAnnotationTableNames(jCas); } catch (ResourceInitializationException e) { throw new AnalysisEngineProcessException(e); } populateCas(jCas); } } catch (Throwable throwable) { log.error("Error while reading document from the database: ", throwable); throw throwable; } return jCas; } }
XmiDBMultiplier extends DBMultiplier implements Initializable { @Override public AbstractCas next() throws AnalysisEngineProcessException { JCas jCas = getEmptyJCas(); try { if (documentDataIterator.hasNext()) { log.trace("Returning next CAS"); try { initializer.initializeAnnotationTableNames(jCas); } catch (ResourceInitializationException e) { throw new AnalysisEngineProcessException(e); } populateCas(jCas); } } catch (Throwable throwable) { log.error("Error while reading document from the database: ", throwable); throw throwable; } return jCas; }  }
XmiDBMultiplier extends DBMultiplier implements Initializable { @Override public AbstractCas next() throws AnalysisEngineProcessException { JCas jCas = getEmptyJCas(); try { if (documentDataIterator.hasNext()) { log.trace("Returning next CAS"); try { initializer.initializeAnnotationTableNames(jCas); } catch (ResourceInitializationException e) { throw new AnalysisEngineProcessException(e); } populateCas(jCas); } } catch (Throwable throwable) { log.error("Error while reading document from the database: ", throwable); throw throwable; } return jCas; }  @Override void initialize(UimaContext aContext); @Override void process(JCas aJCas); @Override AbstractCas next(); @Override String[] getAdditionalTableNames(); @Override String[] getTables(); @Override void collectionProcessComplete(); }
XmiDBMultiplier extends DBMultiplier implements Initializable { @Override public AbstractCas next() throws AnalysisEngineProcessException { JCas jCas = getEmptyJCas(); try { if (documentDataIterator.hasNext()) { log.trace("Returning next CAS"); try { initializer.initializeAnnotationTableNames(jCas); } catch (ResourceInitializationException e) { throw new AnalysisEngineProcessException(e); } populateCas(jCas); } } catch (Throwable throwable) { log.error("Error while reading document from the database: ", throwable); throw throwable; } return jCas; }  @Override void initialize(UimaContext aContext); @Override void process(JCas aJCas); @Override AbstractCas next(); @Override String[] getAdditionalTableNames(); @Override String[] getTables(); @Override void collectionProcessComplete(); static final String PARAM_LOG_FINAL_XMI; }