Commit 137f0b2c authored by R.W.Majeed's avatar R.W.Majeed

More validation for data columns

parent 6a92cdf5
......@@ -5,4 +5,8 @@ import javax.xml.bind.annotation.XmlElement;
public class DataTableIdat extends IdatColumns {
@XmlElement(name="visit-id")
StringColumn visitId;
/**
* Ignored columns
*/
Column<?>[] ignore;
}
......@@ -66,15 +66,19 @@ public abstract class Table<T extends FactRow> {
for( int i=0; i<headers.length; i++ ){
// check if in map
if( map.isRegistered(headers[i]) )continue;
// not registered in map
// check if listed in ignore element
int j=0;
if( ignored == null ){
ignored = new Column<?>[]{};
}
for( j=0; j<ignored.length; j++ ){
if( headers[i].equals(ignored[j].getName()) )break;
}
if( j == ignored.length ){
// unassigned column
throw new ParseException("Header not specified in configuration: "+headers[i]);
throw new ParseException("Table data header missing in configuration: "+headers[i]);
}
}
}
......
......@@ -35,18 +35,32 @@ public class VisitTable extends Table<VisitRow> implements ConceptTable{
@Override
public ColumnMap getColumnMap(String[] headers) throws ParseException {
ColumnMap map = new ColumnMap(headers);
if( idat.patientId == null ){
throw new ParseException("datasource/visit-table/idat/patient-id column not specified");
}
if( idat.visitId == null ){
throw new ParseException("datasource/visit-table/idat/visit-id column not specified");
}
map.registerColumn(idat.patientId);
map.registerColumn(idat.visitId);
map.registerColumn(idat.start);
map.registerColumn(idat.end);
if( idat.start != null ){
map.registerColumn(idat.start);
}
if( idat.end != null ){
map.registerColumn(idat.end);
}
if( idat.location != null ){
map.registerColumn(idat.location);
}
for( Concept c : concepts ){
mapRegisterConcept(map, c);
}
// make sure all columns are specified
validateAllHeaders(headers, map, idat.ignore);
return map;
}
......
......@@ -22,11 +22,24 @@ public class WideTable extends Table<WideRow> implements ConceptTable{
@Override
public ColumnMap getColumnMap(String[] headers) throws ParseException {
ColumnMap map = new ColumnMap(headers);
if( idat.patientId == null ){
throw new ParseException("datasource/wide-table/idat/patient-id column not specified");
}
if( idat.visitId == null ){
throw new ParseException("datasource/wide-table/idat/visit-id column not specified");
}
map.registerColumn(idat.patientId);
map.registerColumn(idat.visitId);
for( Concept c : concepts ){
mapRegisterConcept(map, c);
}
// TODO allow option/parameter to force column checking for data tables
//validateAllHeaders(headers, map, idat.ignore);
return map;
}
......
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