Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions ehr/api-src/org/labkey/api/ehr/SharedEHRUpgradeCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,23 @@ public void fallthroughHandler(String methodName)
else if (methodName.startsWith(IMPORT_FROM_TSV_PREFIX))
{
String[] tsvArguments = methodName.split(";");
if (tsvArguments.length != 4)
if (tsvArguments.length < 4 || tsvArguments.length > 5)
{
throw new UnsupportedOperationException("Expected three arguments for importFromTsv but got " + (tsvArguments.length - 1));
throw new UnsupportedOperationException("Expected three or four arguments for importFromTsv but got " + (tsvArguments.length - 1));
}
String schemaName = tsvArguments[1];
String queryName = tsvArguments[2];
String tsvPath = tsvArguments[3];

_tsvImports.add(new TsvImport(schemaName, queryName, tsvPath));
if (tsvArguments.length == 5)
{
String containerPath = tsvArguments[4];
_tsvImports.add(new TsvImport(schemaName, queryName, tsvPath, containerPath));
}
else
{
_tsvImports.add(new TsvImport(schemaName, queryName, tsvPath));
}
}
else if (methodName.startsWith(IMPORT_DOMAIN_TEMPLATE))
{
Expand Down Expand Up @@ -216,7 +224,23 @@ public void moduleStartupComplete(ServletContext servletContext)
{
for (TsvImport tsvImport : _tsvImports)
{
importFile(tsvImport, container, user);
if (tsvImport._containerPath != null)
{
Container tsvImportContainer = ContainerManager.getForPath(tsvImport._containerPath);
if (tsvImportContainer != null)
{
importFile(tsvImport, tsvImportContainer, user);
}
else
{
LOG.warn("Unable to find container for path " + tsvImport._containerPath + ". Importing into EHR study container.");
importFile(tsvImport, container, user);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's log that we couldn't find the target container and are falling back to the default.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}
else
{
importFile(tsvImport, container, user);
}
}

if (_reloadFolder)
Expand Down Expand Up @@ -308,6 +332,7 @@ private static class TsvImport
private final String _schemaName;
private final String _queryName;
private final String _tsvPath;
private String _containerPath;

public TsvImport(String schemaName, String queryName, String tsvPath)
{
Expand All @@ -316,6 +341,12 @@ public TsvImport(String schemaName, String queryName, String tsvPath)
_tsvPath = tsvPath;
}

public TsvImport(String schemaName, String queryName, String tsvPath, String containerPath)
{
this(schemaName, queryName, tsvPath);
_containerPath = containerPath;
}

@Override
public boolean equals(Object o)
{
Expand Down