Commit 5d826c27 authored by R.W.Majeed's avatar R.W.Majeed

patient store and visit store now initialize with constructor

parent 36664aeb
......@@ -21,13 +21,13 @@ import de.sekmi.histream.Plugin;
*
* @param <T>
*/
public abstract class PostgresExtension<T> implements Extension<T>, Plugin {
abstract class PostgresExtension<T> implements Extension<T>, Plugin {
private static final int defaultFetchSize = 10000;
private static final String driver = "org.postgresql.Driver";
protected Map<String,String> config;
protected Connection db;
public PostgresExtension(Map<String,String> configuration){
protected PostgresExtension(Map<String,String> configuration){
this.config = configuration;
}
......@@ -39,7 +39,7 @@ public abstract class PostgresExtension<T> implements Extension<T>, Plugin {
return DriverManager.getConnection("jdbc:postgresql://"+props.get("host")+":"+props.get("port")+"/"+props.get("database"), jdbcProps);
}
public void open() throws ClassNotFoundException, SQLException{
protected void open() throws ClassNotFoundException, SQLException{
db = getConnection(config);
prepareStatements();
}
......
......@@ -20,6 +20,7 @@ import java.util.logging.Logger;
import de.sekmi.histream.DateTimeAccuracy;
import de.sekmi.histream.Observation;
import de.sekmi.histream.ext.ExternalSourceType;
......@@ -92,8 +93,10 @@ public class PostgresPatientStore extends PostgresExtension<I2b2Patient> impleme
* idSourceDefault ('HIVE'), idSourceSeparator (single char, ':')
* fetchSize (int, 10000)
* @param configuration
* @throws SQLException
* @throws ClassNotFoundException
*/
public PostgresPatientStore(Map<String,String> configuration) {
public PostgresPatientStore(Map<String,String> configuration) throws ClassNotFoundException, SQLException {
super(configuration);
this.projectId = config.get("project");
if( projectId == null ){
......@@ -104,6 +107,7 @@ public class PostgresPatientStore extends PostgresExtension<I2b2Patient> impleme
// this.autoInsertSourceId = "HS.auto";
patientCache = new Hashtable<>(1000);
idCache = new Hashtable<>(1000);
open();
}
private I2b2Patient getCached(int patient_num){
......
......@@ -55,17 +55,18 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit>{
private PreparedStatement deleteSource;
private PreparedStatement deleteMapSource;
public PostgresVisitStore(Map<String,String> configuration) {
public PostgresVisitStore(Map<String,String> configuration) throws ClassNotFoundException, SQLException {
super(configuration);
visitCache = new Hashtable<>();
idCache = new Hashtable<>();
projectId = config.get("project");
idSourceDefault = "HIVE";
idSourceSeparator = ':';
open();
}
@Override
public void open()throws SQLException, ClassNotFoundException{
protected void open()throws SQLException, ClassNotFoundException{
super.open();
// db is already opened by super.connect()
db.setAutoCommit(true);
......
......@@ -13,7 +13,7 @@ import de.sekmi.histream.Plugin;
public class XMLProviderFactory implements FileObservationProviderFactory, Plugin{
public void XMLObservationFactory(Map<String,String> props) {
public XMLProviderFactory(Map<String,String> props) {
// no configuration needed
}
@Override
......
......@@ -18,7 +18,6 @@ public class TestPostgresPatientStore implements Closeable {
props.put("port", Integer.toString(port));
props.put("password", "");
store = new PostgresPatientStore(props);
store.open();
}
public PostgresPatientStore getStore(){return store;}
......
......@@ -19,7 +19,6 @@ public class TestPostgresVisitStore implements Closeable {
props.put("port", Integer.toString(port));
props.put("password", "");
store = new PostgresVisitStore(props);
store.open();
}
private void open()throws Exception{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment