private void checkTableExists() throws ResourceInitializationException { // Check whether the table we are supposed to read from actually exists. if (!dbc.withConnectionQueryBoolean(c -> c.tableExists(tableName))) { throw new ResourceInitializationException( new IllegalArgumentException("The configured table \"" + tableName + "\" does not exist.")); } }
/** * Determines the data table. This may be the specified table itself or, if it is a subset, the first referenced data table. * * @throws ResourceInitializationException If an SQL exception occurs. */ private void determineDataTable() throws ResourceInitializationException { try { readDataTable = dbc.withConnectionQueryBoolean(c -> c.isDataTable(tableName)); dataTable = dbc.withConnectionQueryString(c -> c.getNextOrThisDataTable(tableName)); if (readDataTable) log.info("The table \"{}\" is a data table, documents will not be marked to be in process and no " + "synchronization of multiple DB readers will happen.", tableName); } catch (CoStoSysSQLRuntimeException e) { throw new ResourceInitializationException(e); } }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); // Check whether a subset table name or a data table name was given. if (readDataTable) { log.debug("Reading from data table {}", tableName); dataTableDocumentIds = dbc.query(tableName, Arrays.asList(dbc.getFieldConfiguration(dbc.getActiveTableSchema()).getPrimaryKey())); hasNext = dataTableDocumentIds.hasNext(); } else { log.debug("Reading from subset table {}", tableName); hasNext = dbc.withConnectionQueryBoolean(c -> c.hasUnfetchedRows(tableName)); } }
Integer tableRows = dbc.withConnectionQueryInteger(c -> c.countRowsOfDataTable(tableName, whereCondition)); totalDocumentCount = limitParameter != null ? Math.min(tableRows, limitParameter) : tableRows; hasNext = !dbc.withConnectionQueryBoolean(c -> c.isEmpty(tableName)); tables = new String[]{tableName}; schemas = new String[]{dbc.getActiveTableSchema()};