Commit 6f42960e authored by R.W.Majeed's avatar R.W.Majeed

extension api changed to differentiate between slot type and information types

parent 84146233
......@@ -26,9 +26,9 @@ package de.sekmi.histream;
* Extensions allow additional information to be stored and retrieved
* for observations.
*
* @author Raphael
* @author R.W.Majeed
*
* @param <T> type class
* @param <T> slot type to be kept in memory with the observation
*/
public interface Extension<T>{
/**
......@@ -58,6 +58,7 @@ public interface Extension<T>{
* TODO change return type to array, to register all compatible classes
* @return instance type
*/
Iterable<Class<? super T>> getInstanceTypes();
Class<?>[] getInstanceTypes();
Class<T> getSlotType();
}
package de.sekmi.histream.impl;
import java.util.Arrays;
/*
* #%L
* histream
......@@ -36,10 +33,10 @@ import de.sekmi.histream.ext.Patient;
*
*/
public class SimplePatientExtension implements Extension<PatientImpl>{
private final static Iterable<Class<? super PatientImpl>> TYPES = Arrays.asList(Patient.class, PatientImpl.class);
private final static Class<?>[] TYPES = new Class[] {Patient.class, PatientImpl.class};
@Override
public Iterable<Class<? super PatientImpl>> getInstanceTypes() {return TYPES;}
public Class<?>[] getInstanceTypes() {return TYPES;}
@Override
public PatientImpl createInstance(Object... args) {
......@@ -63,4 +60,9 @@ public class SimplePatientExtension implements Extension<PatientImpl>{
return patient;
}
@Override
public Class<PatientImpl> getSlotType() {
return PatientImpl.class;
}
}
......@@ -23,7 +23,6 @@ package de.sekmi.histream.impl;
import de.sekmi.histream.Observation;
import java.util.Arrays;
import de.sekmi.histream.Extension;
import de.sekmi.histream.ext.ExternalSourceType;
......@@ -31,10 +30,10 @@ import de.sekmi.histream.ext.Patient;
import de.sekmi.histream.ext.Visit;
public class SimpleVisitExtension implements Extension<VisitImpl>{
private final static Iterable<Class<? super VisitImpl>> TYPES = Arrays.asList(Visit.class, VisitImpl.class);
private final static Class<?>[] TYPES = new Class[] {Visit.class, VisitImpl.class};
@Override
public Iterable<Class<? super VisitImpl>> getInstanceTypes() {return TYPES;}
public Class<?>[] getInstanceTypes() {return TYPES;}
@Override
public VisitImpl createInstance(Object... args) {
......@@ -65,4 +64,9 @@ public class SimpleVisitExtension implements Extension<VisitImpl>{
return visit;
}
@Override
public Class<VisitImpl> getSlotType() {
return VisitImpl.class;
}
}
......@@ -30,7 +30,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
......@@ -74,7 +73,7 @@ import de.sekmi.histream.ext.PatientStore;
*/
public class PostgresPatientStore extends PostgresExtension<I2b2Patient> implements PatientStore, Closeable{
private static final Logger log = Logger.getLogger(PostgresPatientStore.class.getName());
private static final Iterable<Class<? super I2b2Patient>> INSTANCE_TYPES = Arrays.asList(Patient.class, I2b2Patient.class);
private static final Class<?>[] INSTANCE_TYPES = new Class[] {Patient.class, I2b2Patient.class};
private String projectId;
private String idSourceDefault;
private char idSourceSeparator;
......@@ -541,7 +540,7 @@ public class PostgresPatientStore extends PostgresExtension<I2b2Patient> impleme
}
@Override
public Iterable<Class<? super I2b2Patient>> getInstanceTypes() {
public Class<?>[] getInstanceTypes() {
return INSTANCE_TYPES;
}
......@@ -649,5 +648,9 @@ public class PostgresPatientStore extends PostgresExtension<I2b2Patient> impleme
db = null;
}
}
@Override
public Class<I2b2Patient> getSlotType() {
return I2b2Patient.class;
}
}
......@@ -30,7 +30,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
......@@ -65,7 +64,7 @@ import de.sekmi.histream.ext.Visit.Status;
*/
public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements Closeable{
private static final Logger log = Logger.getLogger(PostgresVisitStore.class.getName());
private static final Iterable<Class<? super I2b2Visit>> INSTANCE_TYPES = Arrays.asList(Visit.class,I2b2Visit.class);
private static final Class<?>[] INSTANCE_TYPES = new Class[] {Visit.class,I2b2Visit.class};
private String projectId;
private int maxEncounterNum;
......@@ -480,10 +479,6 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements
public I2b2Visit createInstance(String encounterId, Patient patient, ExternalSourceType source) {
return getOrCreateInstance(encounterId, (I2b2Patient)patient, source);
}
@Override
public Iterable<Class<? super I2b2Visit>> getInstanceTypes() {
return INSTANCE_TYPES;
}
/**
* Find a visit. Does not create the visit if it doesn't exist.
......@@ -569,5 +564,13 @@ public class PostgresVisitStore extends PostgresExtension<I2b2Visit> implements
db = null;
}
}
@Override
public Class<?>[] getInstanceTypes() {
return INSTANCE_TYPES;
}
@Override
public Class<I2b2Visit> getSlotType() {
return I2b2Visit.class;
}
}
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