/** * If <code>documentTableParameter</code> is not schema qualified, prependns the active data postgres schema. * * @param documentTableParameter The document table, as given in the component parameter. * @return The effective document table name. */ String getEffectiveDocumentTableName(String documentTableParameter) { // If the table is already schema qualified, accept it. if (documentTableParameter.contains(".")) return documentTableParameter; return dbc.getActiveDataPGSchema() + "." + documentTableParameter; }
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(); } } }
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(); } } } }
/** * 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(); } }
conn.setAutoCommit(true); Statement stmt = conn.createStatement(); String sql = String.format("SELECT %s FROM %s", PREFIX, dbc.getActiveDataPGSchema() + "." + XMI_NS_TABLE); ResultSet rs = stmt.executeQuery(String.format(sql)); while (rs.next()) { prefix = nsEntry.getKey(); uri = nsEntry.getValue(); sql = String.format(template, dbc.getActiveDataPGSchema() + "." + XMI_NS_TABLE, prefix, uri); stmt.execute(sql);
ResultSet rs = stmt.executeQuery("SELECT " + TABLE_NAME + " FROM " + dbc.getActiveDataPGSchema() + "." + ANNOTATION_LIST_TABLE); while (rs.next()) { obsoleteAnnotationTables.add(rs.getString(1));
tableName = dbc.getActiveDataPGSchema() + "." + tableName; tables[i + 1] = tableName; } else {
writeBatchSize = Optional.ofNullable((Integer) aContext.getConfigParameterValue(PARAM_WRITE_BATCH_SIZE)).orElse(50); componentDbName = Optional.ofNullable((String) aContext.getConfigParameterValue(PARAM_COMPONENT_DB_NAME)).orElse(getClass().getSimpleName()); annotationStorageSchema = Optional.ofNullable((String) aContext.getConfigParameterValue(PARAM_ANNO_STORAGE_PG_SCHEMA)).orElse(dbc.getActiveDataPGSchema());
additionalTableNames = (String[]) getConfigParameterValue(PARAM_ADDITIONAL_TABLES); additionalTableSchemas = (String[]) context.getConfigParameterValue(PARAM_ADDITIONAL_TABLE_SCHEMAS); additionalTablesPGSchema = Optional.ofNullable((String) getConfigParameterValue(PARAM_ADDITONAL_TABLES_STORAGE_PG_SCHEMA)).orElse(dbc.getActiveDataPGSchema()); checkAdditionalTableParameters(additionalTableNames, additionalTableSchemas); determineDataTable();