Skip to content

Commit

Permalink
Fixed bug in creating tables introduced by last bug fix. Implemented …
Browse files Browse the repository at this point in the history
…creation of schema.
  • Loading branch information
schuemie committed Jul 16, 2017
1 parent 585c3c6 commit 6d2e6e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/org/ohdsi/databases/ConnectionWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ else if (dbType.equals(DbType.POSTGRESQL))
execute("USE " + database);
}

public void createDatabase(String database) {
execute("CREATE SCHEMA " + database);
}

/**
* Execute the given SQL statement.
*
Expand Down Expand Up @@ -205,7 +209,7 @@ public void createTable(String table, List<String> fields, List<String> types, L
sql.append(" " + fields.get(i) + " " + types.get(i));
}
if (primaryKey != null && primaryKey.size() != 0)
sql.append("\n PRIMARY KEY (" + StringUtilities.join(primaryKey, ",") + ")\n");
sql.append(",\n PRIMARY KEY (" + StringUtilities.join(primaryKey, ",") + ")\n");
sql.append(");\n\n");
execute(Abbreviator.abbreviate(sql.toString()));
}
Expand Down
6 changes: 4 additions & 2 deletions src/org/ohdsi/medlineXmlToDatabase/MedlineAnalyserMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void main(String[] args) {
MedlineAnalyserMain main = new MedlineAnalyserMain();
main.analyseFolder(iniFile.get("XML_FOLDER"));
main.createDatabase(iniFile.get("SERVER"), iniFile.get("SCHEMA"), iniFile.get("DOMAIN"), iniFile.get("USER"), iniFile.get("PASSWORD"),
iniFile.get("DATA_SOURCE_TYPE"));
iniFile.get("DATA_SOURCE_TYPE"), iniFile.get("CREATE_SCHEMA"));
// MedlineAnalyserMain main = new MedlineAnalyserMain();
// main.analyseFolder("S:/Data/MEDLINE/Unprocessed/test");
}
Expand All @@ -67,8 +67,10 @@ private void analyse(Document document) {
}
}

private void createDatabase(String server, String schema, String domain, String user, String password, String dateSourceType) {
private void createDatabase(String server, String schema, String domain, String user, String password, String dateSourceType, String createSchema) {
ConnectionWrapper connectionWrapper = new ConnectionWrapper(server, domain, user, password, new DbType(dateSourceType));
if (createSchema.toLowerCase().equals("true"))
connectionWrapper.createDatabase(schema);
connectionWrapper.use(schema);
System.out.println("Creating tables");
medlineCitationAnalyser.createTables(connectionWrapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ public void createTables(ConnectionWrapper connectionWrapper) {


private void analyseNode(Node node, String name, String tableName) {
if (node.getNodeName().toLowerCase().equals("abstracttext"))
System.out.println("asf");
// Add attributes:
NamedNodeMap attributes = node.getAttributes();
if (attributes != null)
Expand Down

0 comments on commit 6d2e6e7

Please sign in to comment.