private void determineDataInGzipFormat(String table) throws ResourceInitializationException { doGzip = true; dataTable = dbc.getNextOrThisDataTable(table); log.debug("Fetching a single row from data table {} in order to determine whether data is in GZIP format", dataTable); try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){ ResultSet rs = conn.createStatement().executeQuery(String.format("SELECT xmi FROM %s LIMIT 1", dataTable)); while (rs.next()) { byte[] xmiData = rs.getBytes("xmi"); try (GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(xmiData))) { gzis.read(); } catch (IOException e) { log.debug("Attempt to read XMI data in GZIP format failed. Assuming non-gzipped XMI data. Expected exception:", e); doGzip = false; } } } catch (SQLException e) { if (e.getMessage().contains("does not exist")) log.error("An exception occurred when trying to read the xmi column of the data table \"{}\". It seems the table does not contain XMI data and this is invalid to use with this reader.", dataTable); throw new ResourceInitializationException(e); } } }
private void determineDataInGzipFormat(String table) throws ResourceInitializationException { doGzip = true; dataTable = dbc.getNextOrThisDataTable(table); log.debug("Fetching a single row from data table {} in order to determine whether data is in GZIP format", dataTable); try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){ ResultSet rs = conn.createStatement().executeQuery(String.format("SELECT xmi FROM %s LIMIT 1", dataTable)); while (rs.next()) { byte[] xmiData = rs.getBytes("xmi"); try (GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(xmiData))) { gzis.read(); } catch (IOException e) { log.debug("Attempt to read XMI data in GZIP format failed. Assuming non-gzipped XMI data. Expected exception:", e); doGzip = false; } } } catch (SQLException e) { if (e.getMessage().contains("does not exist")) log.error("An exception occurred when trying to read the xmi column of the data table \"{}\". It seems the table does not contain XMI data and this is invalid to use with this reader.", dataTable); throw new ResourceInitializationException(e); } }
private void determineDataInGzipFormat(String table) throws ResourceInitializationException { doGzip = true; dataTable = dbc.getNextOrThisDataTable(table); log.debug("Fetching a single row from data table {} in order to determine whether data is in GZIP format", dataTable); try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()) { ResultSet rs = conn.createStatement().executeQuery(String.format("SELECT xmi FROM %s LIMIT 1", dataTable)); while (rs.next()) { byte[] xmiData = rs.getBytes("xmi"); try (GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(xmiData))) { gzis.read(); } catch (IOException e) { log.debug("Attempt to read XMI data in GZIP format failed. Assuming non-gzipped XMI data. Expected exception:", e); doGzip = false; } } } catch (SQLException e) { if (e.getMessage().contains("does not exist")) log.error("An exception occurred when trying to read the xmi column of the data table \"{}\". It seems the table does not contain XMI data and this is invalid to use with this reader.", dataTable); throw new ResourceInitializationException(e); } } }
/** * Adds the extract string <tt>tablename</tt> to the list of annotation * table names. * * @param tablename */ void addAnnotationTableToList(String tablename) { try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){ conn.setAutoCommit(true); Statement stmt = conn.createStatement(); String template = "INSERT INTO %s VALUES('%s')"; String sql = String.format(template, dbc.getActiveDataPGSchema() + "." + ANNOTATION_LIST_TABLE, tablename); stmt.execute(sql); } catch (PSQLException e) { log.debug("Tried to add already existing annotation table to annotation list: \"{}\", ignoring.", tablename); } catch (SQLException e) { e.printStackTrace(); SQLException ne = e.getNextException(); if (null != ne) ne.printStackTrace(); } }
try (CoStoSysConnection ignored = dbc.obtainOrReserveConnection()) { log.trace("Using connection {} to retrieveAndMark", ignored.getConnection()); ids = dbc.retrieveAndMark(tableName, getClass().getSimpleName(), hostName, pid, limit, selectionOrder);
private void createNamespaceTable(DataBaseConnector dbc) { if (!dbc.tableExists(dbc.getActiveDataPGSchema() + "." + XMI_NS_TABLE)) { try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){ conn.setAutoCommit(true); Statement stmt = conn.createStatement(); String sql = String.format("CREATE TABLE %s (%s text PRIMARY KEY, %s text)", dbc.getActiveDataPGSchema() + "." + XMI_NS_TABLE, PREFIX, NS_URI); stmt.execute(sql); } catch (SQLException e) { e.printStackTrace(); SQLException ne = e.getNextException(); if (null != ne) ne.printStackTrace(); } } }
obsoleteAnnotationTables = new ArrayList<>(); try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){ Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT " + TABLE_NAME + " FROM " + dbc.getActiveDataPGSchema() + "." + ANNOTATION_LIST_TABLE);
private Map<String, String> getNamespaceMap() { Map<String, String> map = null; if (dbc.tableExists(dbc.getActiveDataPGSchema() + "." + XmiSplitConstants.XMI_NS_TABLE)) { try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){ map = new HashMap<>(); conn.setAutoCommit(true); Statement stmt = conn.createStatement(); String sql = String.format("SELECT %s,%s FROM %s", XmiSplitConstants.PREFIX, XmiSplitConstants.NS_URI, dbc.getActiveDataPGSchema() + "." + XmiSplitConstants.XMI_NS_TABLE); ResultSet rs = stmt.executeQuery(String.format(sql)); while (rs.next()) map.put(rs.getString(1), rs.getString(2)); } catch (SQLException e) { e.printStackTrace(); SQLException ne = e.getNextException(); if (null != ne) ne.printStackTrace(); } } else { log.warn( "Table \"{}\" was not found it is assumed that the table from which is read contains complete XMI documents.", dbc.getActiveDataPGSchema() + "." + XmiSplitConstants.XMI_NS_TABLE); } return map; }
private void createAnnotationListTable() { if (!dbc.tableExists(dbc.getActiveDataPGSchema() + "." + ANNOTATION_LIST_TABLE)) { try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){ conn.setAutoCommit(true); Statement stmt = conn.createStatement(); String sql = String.format("CREATE TABLE %s (%s text PRIMARY KEY)", dbc.getActiveDataPGSchema() + "." + ANNOTATION_LIST_TABLE, TABLE_NAME); stmt.execute(sql); } catch (SQLException e) { e.printStackTrace(); SQLException ne = e.getNextException(); if (null != ne) ne.printStackTrace(); } } } }
try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()) { nsAndXmiVersion = getNamespaceMap();
try (CoStoSysConnection ignored = dbc.obtainOrReserveConnection()) { ids = dbc.retrieveAndMark(tableName, getReaderComponentName(), hostName, pid, limit, selectionOrder);
try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()){ conn.setAutoCommit(false); for (String tableName : serializedCASes.keySet()) {
if (batchSize == 0) log.warn("Batch size of retrieved documents is set to 0. Nothing will be returned."); try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()) { if (resetTable) dbc.resetSubset(tableName);
throw new ResourceInitializationException(e); try (CoStoSysConnection ignored = dbc.obtainOrReserveConnection()) { List<Map<String, String>> primaryKeyFields = dbc.getActiveTableFieldConfiguration().getPrimaryKeyFields().collect(Collectors.toList()); if (rowBatch.getReadsBaseXmiDocument()) {
throw new ResourceInitializationException(e); try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()) { List<Map<String, String>> primaryKeyFields = dbc.getActiveTableFieldConfiguration().getPrimaryKeyFields().collect(Collectors.toList()); if ((Boolean) getConfigParameterValue(PARAM_READS_BASE_DOCUMENT)) {
throw new ResourceInitializationException(e); try (CoStoSysConnection conn = dbc.obtainOrReserveConnection()) { List<Map<String, String>> primaryKeyFields = dbc.getActiveTableFieldConfiguration().getPrimaryKeyFields().collect(Collectors.toList()); if ((Boolean) getConfigParameterValue(PARAM_READS_BASE_DOCUMENT)) {