16
16
import org .apache .commons .math3 .util .Pair ;
17
17
import org .obiba .magma .NoSuchValueTableException ;
18
18
import org .obiba .magma .support .Disposables ;
19
+ import org .obiba .magma .support .Initialisables ;
19
20
import org .obiba .mica .core .source .ExcelTableSource ;
20
21
import org .obiba .mica .core .source .OpalTableSource ;
21
22
import org .obiba .mica .dataset .domain .StudyDataset ;
@@ -92,13 +93,13 @@ private StudyTableSource makeStudyTableSourceInternal(StudyTableContext context,
92
93
if (OpalTableSource .isFor (source )) {
93
94
OpalTableSource tableSource = OpalTableSource .fromURN (source );
94
95
tableSource .setStudyTableContext (context );
95
- tableSource .initialise (opalService );
96
+ tableSource .setOpalService (opalService );
96
97
return tableSource ;
97
98
}
98
99
if (ExcelTableSource .isFor (source )) {
99
100
ExcelTableSource tableSource = ExcelTableSource .fromURN (source );
100
101
tableSource .setStudyTableContext (context );
101
- tableSource .initialise (new AttachmentStream (context , tableSource .getPath ()));
102
+ tableSource .setStudyTableFileStreamProvider (new AttachmentStreamProvider (context , tableSource .getPath ()));
102
103
return tableSource ;
103
104
}
104
105
Optional <StudyTableSourceService > serviceOptional = pluginsService .getStudyTableSourceServices ().stream ()
@@ -108,20 +109,24 @@ private StudyTableSource makeStudyTableSourceInternal(StudyTableContext context,
108
109
tableSource .setStudyTableContext (context );
109
110
if (tableSource instanceof StudyTableFileSource ) {
110
111
StudyTableFileSource fileSource = (StudyTableFileSource )tableSource ;
111
- fileSource .initialise (new AttachmentStream (context , fileSource .getPath ()));
112
+ fileSource .setStudyTableFileStreamProvider (new AttachmentStreamProvider (context , fileSource .getPath ()));
112
113
}
114
+ Initialisables .initialise (tableSource );
113
115
return tableSource ;
114
116
}
115
117
throw new NoSuchElementException ("Missing study-table-source plugin to handle source: " + source );
116
118
}
117
119
118
120
119
- private class AttachmentStream implements StudyTableFileStream {
121
+ /**
122
+ * Get the input stream from an {@link AttachmentState} object.
123
+ */
124
+ private class AttachmentStreamProvider implements StudyTableFileStreamProvider {
120
125
121
126
private final StudyTableContext context ;
122
127
private final String path ;
123
128
124
- private AttachmentStream (StudyTableContext context , String path ) {
129
+ private AttachmentStreamProvider (StudyTableContext context , String path ) {
125
130
this .context = context ;
126
131
this .path = path ;
127
132
}
0 commit comments