Commit b2b13333 authored by R.W.Majeed's avatar R.W.Majeed
Browse files

Import module for any table based format

parent 70b98829
.settings/
.classpath
.project
target/
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>HIStream : Import</name>
<groupId>de.sekmi.histream</groupId>
<artifactId>histream-import</artifactId>
<version>0.2-alpha</version>
<parent>
<groupId>de.sekmi.histream</groupId>
<artifactId>histream</artifactId>
<version>0.2-alpha</version>
</parent>
<build>
<plugins>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>de.sekmi.histream</groupId>
<artifactId>histream-core</artifactId>
<version>0.2-alpha</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package de.sekmi.histream.etl;
import de.sekmi.histream.Observation;
import de.sekmi.histream.ObservationSupplier;
public class ETLObservationSupplier implements ObservationSupplier{
@Override
public Observation get() {
// TODO Auto-generated method stub
return null;
}
@Override
public void close() throws Exception {
// TODO Auto-generated method stub
}
@Override
public String getMeta(String arg0) {
// TODO Auto-generated method stub
return null;
}
}
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
public class Column {
private Column(){
}
public Column(String name){
this();
this.name = name;
}
@XmlAttribute
String na;
@XmlAttribute(name="constant-value")
String constantValue;
@XmlValue
String name;
}
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
/**
* Concept from a wide table
* @author Raphael
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
public class Concept{
@XmlAttribute(required=true)
String id;
// TODO: value should contain also type (string,decimal,integer,...)
Column value;
Column unit;
@XmlElement(required=true)
Column start;
Column end;
@XmlElement(name="modifier")
Modifier[] modifiers;
// ...
@XmlAccessorType(XmlAccessType.FIELD)
public static class Modifier{
@XmlAttribute(required=true)
String id;
// TODO: value with type
Column value;
Column unit;
private Modifier(){
}
public Modifier(String id){
this();
this.id = id;
}
}
private Concept(){
}
public Concept(String id, String startColumn){
this();
this.id = id;
this.start = new Column(startColumn);
}
}
\ No newline at end of file
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
@XmlAccessorType(XmlAccessType.FIELD)
public class DataSource {
@XmlElement
Meta meta;
@XmlElementWrapper(name="transformation")
@XmlElement(name="xml-source")
XmlSource[] xmlSources;
@XmlElement(name="patient-table",required=true)
PatientTable patientTable;
@XmlElement(name="visit-table")
VisitTable visitTable;
@XmlElement(name="wide-table")
WideTable[] wideTables;
}
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlElement;
public class DataTableIdat extends IdatColumns {
@XmlElement(name="visit-id")
Column visitId;
}
package de.sekmi.histream.etl.config;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.stream.Stream;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@XmlAccessorType(XmlAccessType.FIELD)
public class FileSource extends TableSource{
@XmlElement
URL url;
@XmlElement
String type;
private FileSource(){
}
public FileSource(String url, String type) throws MalformedURLException{
this();
this.url = new URL(url);
this.type = type;
}
@Override
public String[] getHeaders() {
// TODO Auto-generated method stub
return null;
}
@Override
public Stream<String[]> rows() {
return null;
}
}
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlElement;
public class IdatColumns {
@XmlElement(name="patient-id")
Column patientId;
}
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlElement;
public class Meta {
@XmlElement(name="source-id")
String sourceId;
@XmlElement(name="etl-strategy")
String etlStrategy;
}
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
/**
* Patient table. Contains patient id and other identifying information.
* Can also contain medical data
* @author marap1
*
*/
public class PatientTable extends Table implements WideInterface{
@XmlElement
IDAT idat;
@XmlElementWrapper(name="mdat")
@XmlElement(name="concept")
Concept[] concepts;
@XmlAccessorType(XmlAccessType.FIELD)
public static class IDAT extends IdatColumns{
Column firstname;
Column lastname;
Column birthdate;
Column deathdate;
Column gender;
Column[] ignore;
}
}
package de.sekmi.histream.etl.config;
import java.util.stream.Stream;
import javax.xml.bind.annotation.XmlElement;
public class SQLSource extends TableSource {
@XmlElement
String jdbcDriver;
@XmlElement
String connectString;
@XmlElement
String sql;
private SQLSource() {
}
public SQLSource(String driver, String connectString){
this();
this.jdbcDriver = driver;
this.connectString = connectString;
}
@Override
public String[] getHeaders() {
// TODO Auto-generated method stub
return null;
}
@Override
public Stream<String[]> rows() {
// TODO Auto-generated method stub
return null;
}
}
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
@XmlTransient
public class Table {
@XmlElement(required=true)
TableSource source;
}
package de.sekmi.histream.etl.config;
import java.util.stream.Stream;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlTransient;
@XmlTransient
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso({FileSource.class, SQLSource.class})
public abstract class TableSource{
public abstract String[] getHeaders();
public abstract Stream<String[]> rows();
}
\ No newline at end of file
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
public class VisitTable extends Table implements WideInterface{
@XmlElement
IDAT idat;
@XmlElementWrapper(name="mdat")
@XmlElement(name="concept")
Concept[] concepts;
@XmlType(name="patient-idat")
@XmlAccessorType(XmlAccessType.FIELD)
public static class IDAT extends IdatColumns{
@XmlElement(name="visit-id")
Column visitId;
Column start;
Column end;
// TODO inpatient/outpatient state
Column[] ignore;
}
}
package de.sekmi.histream.etl.config;
public interface WideInterface {
}
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
public class WideTable extends Table {
@XmlElement
DataTableIdat idat;
@XmlElementWrapper(name="mdat")
@XmlElement(name="concept")
Concept[] concepts;
}
package de.sekmi.histream.etl.config;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlSource {
@XmlAttribute
URL url;
@XmlElement
Transform[] transform;
public static class Transform{
@XmlAttribute
URL with;
@XmlAttribute
String to; // TODO use Path internally
public Transform(){
}
public Transform(String with, String to) throws MalformedURLException{
this.with = new URL(with);
this.to = to;
}
}
}
/**
*
*/
/**
* @author marap1
*
*/
package de.sekmi.histream.etl.config;
\ No newline at end of file
/**
*
*/
/**
* @author marap1
*
*/
package de.sekmi.histream.etl;
\ No newline at end of file
Supports Markdown
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