@@ -115,15 +115,23 @@ public void fallthroughHandler(String methodName)
115115 else if (methodName .startsWith (IMPORT_FROM_TSV_PREFIX ))
116116 {
117117 String [] tsvArguments = methodName .split (";" );
118- if (tsvArguments .length != 4 )
118+ if (tsvArguments .length < 4 || tsvArguments . length > 5 )
119119 {
120- throw new UnsupportedOperationException ("Expected three arguments for importFromTsv but got " + (tsvArguments .length - 1 ));
120+ throw new UnsupportedOperationException ("Expected three or four arguments for importFromTsv but got " + (tsvArguments .length - 1 ));
121121 }
122122 String schemaName = tsvArguments [1 ];
123123 String queryName = tsvArguments [2 ];
124124 String tsvPath = tsvArguments [3 ];
125125
126- _tsvImports .add (new TsvImport (schemaName , queryName , tsvPath ));
126+ if (tsvArguments .length == 5 )
127+ {
128+ String containerPath = tsvArguments [4 ];
129+ _tsvImports .add (new TsvImport (schemaName , queryName , tsvPath , containerPath ));
130+ }
131+ else
132+ {
133+ _tsvImports .add (new TsvImport (schemaName , queryName , tsvPath ));
134+ }
127135 }
128136 else if (methodName .startsWith (IMPORT_DOMAIN_TEMPLATE ))
129137 {
@@ -216,7 +224,23 @@ public void moduleStartupComplete(ServletContext servletContext)
216224 {
217225 for (TsvImport tsvImport : _tsvImports )
218226 {
219- importFile (tsvImport , container , user );
227+ if (tsvImport ._containerPath != null )
228+ {
229+ Container tsvImportContainer = ContainerManager .getForPath (tsvImport ._containerPath );
230+ if (tsvImportContainer != null )
231+ {
232+ importFile (tsvImport , tsvImportContainer , user );
233+ }
234+ else
235+ {
236+ LOG .warn ("Unable to find container for path " + tsvImport ._containerPath + ". Importing into EHR study container." );
237+ importFile (tsvImport , container , user );
238+ }
239+ }
240+ else
241+ {
242+ importFile (tsvImport , container , user );
243+ }
220244 }
221245
222246 if (_reloadFolder )
@@ -308,6 +332,7 @@ private static class TsvImport
308332 private final String _schemaName ;
309333 private final String _queryName ;
310334 private final String _tsvPath ;
335+ private String _containerPath ;
311336
312337 public TsvImport (String schemaName , String queryName , String tsvPath )
313338 {
@@ -316,6 +341,12 @@ public TsvImport(String schemaName, String queryName, String tsvPath)
316341 _tsvPath = tsvPath ;
317342 }
318343
344+ public TsvImport (String schemaName , String queryName , String tsvPath , String containerPath )
345+ {
346+ this (schemaName , queryName , tsvPath );
347+ _containerPath = containerPath ;
348+ }
349+
319350 @ Override
320351 public boolean equals (Object o )
321352 {
0 commit comments