Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions ehr/api-src/org/labkey/api/ehr/EHRService.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import org.labkey.api.util.URLHelper;
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.template.ClientDependency;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Date;
Expand Down Expand Up @@ -339,7 +339,7 @@ public EHRQCState getQCState(@NotNull Container c)
* A use case is a separate pipeline server that performs the R computation on a cluster, and then triggers the main webserver to import
* those results.
*/
abstract public void standaloneProcessKinshipAndInbreeding(Container c, User u, File pipelineDir, Logger log) throws PipelineJobException;
abstract public void standaloneProcessKinshipAndInbreeding(Container c, User u, FileLike pipelineDir, Logger log) throws PipelineJobException;

/** Applicable for centers who use the model that projects have a reference to a protocol. Caches a protocol for a given project. **/
abstract public void updateCachedProtocol(Container c, Integer project, String protocol);
Expand Down
2 changes: 1 addition & 1 deletion ehr/resources/web/ehr/panel/ManageTreatmentsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ Ext4.define('EHR.panel.ManageTreatmentsPanel', {
dataIndex: 'amountAndVolume',
renderer: function(value, cellMetaData, record){
if (value){
return value.replace(/\n/, '<br>');
return value.replace(/\n/g, '<br>');
}

return value;
Expand Down
28 changes: 14 additions & 14 deletions ehr/src/org/labkey/ehr/EHRServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
import org.labkey.ehr.security.EHRSecurityManager;
import org.labkey.ehr.table.DefaultEHRCustomizer;
import org.labkey.ehr.table.SNOMEDCodesDisplayColumn;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -923,28 +923,28 @@ public void importFolderDefinition(Container container, User user, Module m, Pat
{
Resource root = m.getModuleResource(sourceFolderDirPath);
PipeRoot pipeRoot = PipelineService.get().findPipelineRoot(container);
java.nio.file.Path pipeRootPath = pipeRoot.getRootNioPath();
FileLike pipeRootPath = pipeRoot.getRootFileLike();

java.nio.file.Path folderXmlPath;
FileLike folderXmlPath;

if (root instanceof DirectoryResource && ((DirectoryResource)root).getDir().equals(pipeRootPath.toFile()))
if (root instanceof DirectoryResource dir && dir.getDir().equals(pipeRootPath.toNioPathForRead().toFile()))
{
// The pipeline root is already pointed at the folder definition, like it might be on a dev machine.
// No need to copy, especially since copying can cause infinite recursion when the paths are nested
folderXmlPath = pipeRootPath.resolve("folder.xml");
folderXmlPath = pipeRootPath.resolveChild("folder.xml");
}
else
{
java.nio.file.Path folderPath = pipeRootPath.resolve("moduleFolderImport");
folderXmlPath = folderPath.resolve("folder.xml");
if (Files.exists(folderPath))
FileLike folderPath = pipeRootPath.resolveChild("moduleFolderImport");
folderXmlPath = folderPath.resolveChild("folder.xml");
if (folderPath.exists())
{
FileUtil.deleteDir(folderPath);
}
copyResourceToPath(root, folderPath);
}

if (!Files.exists(folderXmlPath))
if (!folderXmlPath.exists())
{
throw new FileNotFoundException("Couldn't find an extracted " + folderXmlPath);
}
Expand All @@ -954,21 +954,21 @@ public void importFolderDefinition(Container container, User user, Module m, Pat
PipelineService.get().runFolderImportJob(container, user, null, folderXmlPath, "folder.xml", pipeRoot, options);
}

private void copyResourceToPath(Resource resource, java.nio.file.Path target) throws IOException
private void copyResourceToPath(Resource resource, FileLike target) throws IOException
{
if (resource.isCollection())
{
Files.createDirectory(target);
FileUtil.createDirectory(target);
for (Resource child : resource.list())
{
java.nio.file.Path childTarget = target.resolve(child.getName());
FileLike childTarget = target.resolveChild(child.getName());
copyResourceToPath(child, childTarget);
}
}
else
{
try (InputStream in = resource.getInputStream();
OutputStream out = Files.newOutputStream(target))
OutputStream out = target.openOutputStream())
{
FileUtil.copyData(in, out);
}
Expand Down Expand Up @@ -1069,7 +1069,7 @@ public void appendSNOMEDCols(AbstractTableInfo ti, String displayColumnName, Str
}

@Override
public void standaloneProcessKinshipAndInbreeding(Container c, User u, File pipelineDir, Logger log) throws PipelineJobException
public void standaloneProcessKinshipAndInbreeding(Container c, User u, FileLike pipelineDir, Logger log) throws PipelineJobException
{
GeneticCalculationsImportTask.standaloneProcessKinshipAndInbreeding(c, u, pipelineDir, log);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.labkey.api.util.FileType;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.ehr.EHRSchema;
import org.labkey.vfs.FileLike;

import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -151,8 +152,8 @@ public RecordedActionSet run() throws PipelineJobException
PipelineJob job = getJob();
FileAnalysisJobSupport support = (FileAnalysisJobSupport) job;

processInbreeding(job.getContainer(), job.getUser(), support.getAnalysisDirectoryPath().toFile(), job.getLogger());
processKinship(job.getContainer(), job.getUser(), support.getAnalysisDirectoryPath().toFile(), job.getLogger(), job);
processInbreeding(job.getContainer(), job.getUser(), support.getAnalysisDirectoryFileLike(), job.getLogger());
processKinship(job.getContainer(), job.getUser(), support.getAnalysisDirectoryFileLike(), job.getLogger(), job);

if (GeneticCalculationsJob.isKinshipValidation())
{
Expand All @@ -170,15 +171,15 @@ public RecordedActionSet run() throws PipelineJobException
return new RecordedActionSet(actions);
}

public static void standaloneProcessKinshipAndInbreeding(Container c, User u, File pipelineDir, Logger log) throws PipelineJobException
public static void standaloneProcessKinshipAndInbreeding(Container c, User u, FileLike pipelineDir, Logger log) throws PipelineJobException
{
processInbreeding(c, u, pipelineDir, log);
processKinship(c, u, pipelineDir, log, null);
}

private static void processKinship(Container c, User u, File pipelineDir, Logger log, @Nullable PipelineJob job) throws PipelineJobException
private static void processKinship(Container c, User u, FileLike pipelineDir, Logger log, @Nullable PipelineJob job) throws PipelineJobException
{
File output = new File(pipelineDir, KINSHIP_FILE);
FileLike output = pipelineDir.resolveChild(KINSHIP_FILE);
if (!output.exists())
throw new PipelineJobException("Unable to find file: " + output.getPath());

Expand All @@ -190,7 +191,7 @@ private static void processKinship(Container c, User u, File pipelineDir, Logger
try
{
try (DbScope.Transaction transaction = ExperimentService.get().ensureTransaction();
LineNumberReader lnr = new LineNumberReader(Readers.getReader(output)))
LineNumberReader lnr = new LineNumberReader(Readers.getReader(output.openInputStream())))
{
while (lnr.readLine() != null)
{
Expand Down Expand Up @@ -248,7 +249,7 @@ else if (kinshipTable.getSqlDialect().isPostgreSQL())
}

try (DbScope.Transaction transaction = ExperimentService.get().ensureTransaction();
BufferedReader reader = Readers.getReader(output);
BufferedReader reader = Readers.getReader(output.openInputStream());
PreparedStatement stmt = transaction.getConnection().prepareStatement(
"INSERT INTO " + EHRSchema.EHR_SCHEMANAME + ".kinship\n" +
"\t(Id, Id2, coefficient, container, created, createdby, modified, modifiedby)\n" +
Expand Down Expand Up @@ -619,9 +620,9 @@ private static TableInfo getRealTable(TableInfo ti)
return null;
}

private static void processInbreeding(Container c, User u, File pipelineDir, Logger log) throws PipelineJobException
private static void processInbreeding(Container c, User u, FileLike pipelineDir, Logger log) throws PipelineJobException
{
File output = new File(pipelineDir, INBREEDING_FILE);
FileLike output = pipelineDir.resolveChild(INBREEDING_FILE);
if (!output.exists())
throw new PipelineJobException("Unable to find file: " + output.getPath());

Expand All @@ -636,12 +637,12 @@ private static void processInbreeding(Container c, User u, File pipelineDir, Log
QueryUpdateService qus = ti.getUpdateService();
qus.setBulkLoad(true);

try (BufferedReader reader = Readers.getReader(output))
try (BufferedReader reader = Readers.getReader(output.openInputStream()))
{
try (DbScope.Transaction transaction = ExperimentService.get().ensureTransaction())
{
log.info("Inspecting file length: " + output.getPath());
try (LineNumberReader lnr = new LineNumberReader(Readers.getReader(output)))
try (LineNumberReader lnr = new LineNumberReader(Readers.getReader(output.openInputStream())))
{
while (lnr.readLine() != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
import org.labkey.api.pipeline.file.FileAnalysisTaskPipeline;
import org.labkey.api.security.User;
import org.labkey.api.util.ConfigurationException;
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.StringUtilsLabKey;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.ViewBackgroundInfo;
import org.labkey.ehr.EHRManager;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.FileWriter;
Expand Down Expand Up @@ -97,11 +99,11 @@ private void startCalculation(User u, Container c, boolean allowRunningDuringDay

protocol.setTimestampLog(true);

File fileParameters = protocol.getParametersFile(root.getRootPath(), root);
FileLike fileParameters = protocol.getParametersFile(root.getRootFileLike(), root);
if (!fileParameters.exists())
{
fileParameters.getParentFile().mkdirs();
fileParameters.createNewFile();
fileParameters.getParent().mkdirs();
FileUtil.createNewFile(fileParameters, true);
}
protocol.saveInstance(fileParameters, c);

Expand All @@ -118,11 +120,11 @@ private void startCalculation(User u, Container c, boolean allowRunningDuringDay
w.write(xml);
}

File inputFile = new File(root.getRootPath(), "kinship.txt");
FileLike inputFile = root.resolvePathToFileLike("kinship.txt");
if (!inputFile.exists())
inputFile.createNewFile();
FileUtil.createNewFile(inputFile, true);

AbstractFileAnalysisJob job = protocol.createPipelineJob(bg, root, Collections.singletonList(inputFile.toPath()), fileParameters.toPath(), null);
AbstractFileAnalysisJob job = protocol.createPipelineJob(bg, root, Collections.singletonList(inputFile), fileParameters, null);
PipelineService.get().queueJob(job);

String dateFormat = "yyyy_MM_dd_hh_mm_ss";
Expand All @@ -131,7 +133,7 @@ private void startCalculation(User u, Container c, boolean allowRunningDuringDay
Date now = cal.getTime();
String timestamp = formatter.format(now);

job.setLogFile(new File(job.getLogFile().getParent() + "/kinship_" + timestamp + ".txt.log"));
job.setLogFile(job.getLogFileLike().getParent().resolveChild("kinship_" + timestamp + ".txt.log"));
}
catch (ClassNotFoundException e)
{
Expand Down
17 changes: 5 additions & 12 deletions ehr/test/src/org/labkey/test/tests/ehr/AbstractEHRTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.junit.Assert;
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.Path;
import org.labkey.remoteapi.CommandException;
import org.labkey.remoteapi.Connection;
import org.labkey.remoteapi.SimplePostCommand;
Expand Down Expand Up @@ -59,7 +61,6 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Pattern;

import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
Expand Down Expand Up @@ -144,7 +145,7 @@ abstract public class AbstractEHRTest extends BaseWebDriverTest implements Advan
protected List<Long> _saveRowsTimes;

protected abstract String getModuleDirectory();
protected EHRBillingHelper _billingHelper = new EHRBillingHelper(this, getProjectName(), FOLDER_NAME, getModulePath(), getContainerPath(),BILLING_FOLDER);
protected EHRBillingHelper _billingHelper = new EHRBillingHelper(this, getProjectName(), BILLING_FOLDER);

//xpath fragment
public static final String VISIBLE = "not(ancestor-or-self::*[contains(@style,'visibility: hidden') or contains(@class, 'x-hide-display')])";
Expand Down Expand Up @@ -203,14 +204,6 @@ public void validateQueries(boolean validateSubfolders)
}
}

protected Pattern[] getIgnoredElements()
{
return new Pattern[] {
Pattern.compile("qcstate", Pattern.CASE_INSENSITIVE),//qcstate IDs aren't predictable
Pattern.compile("stacktrace", Pattern.CASE_INSENSITIVE)
};
}

protected String getMale() {
return "m";
}
Expand Down Expand Up @@ -365,8 +358,8 @@ public void doCleanup(boolean afterTest) throws TestTimeoutException

protected void importFolderFromPath(int jobCount)
{
File path = new File(TestFileUtils.getLabKeyRoot(), getModulePath() + "/resources/referenceStudy");
setPipelineRoot(path.getPath());
File path = FileUtil.appendPath(TestFileUtils.getLabKeyRoot(), Path.parse(getModulePath() + "/resources/referenceStudy"));
setPipelineRoot(path.getPath(), false);

beginAt(WebTestHelper.getBaseURL() + "/" + getContainerPath() + "/pipeline-status-begin.view");
clickButton("Process and Import Data", defaultWaitForPage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
@BaseWebDriverTest.ClassTimeout(minutes = 5)
public abstract class ComplianceTrainingTest extends BaseWebDriverTest implements AdvancedSqlTest
{
private final String listZIP = TestFileUtils.getLabKeyRoot() + "/server/modules/ehrModules/EHR_ComplianceDB/tools/SOP_Lists.zip";
private final String listZIP = new File(TestFileUtils.getLabKeyRoot(), "server/modules/ehrModules/EHR_ComplianceDB/tools/SOP_Lists.zip").getPath();

@Override
protected String getProjectName()
Expand Down
12 changes: 3 additions & 9 deletions ehr/test/src/org/labkey/test/tests/ehr/EHRBillingHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ public class EHRBillingHelper
{
private final BaseWebDriverTest _test;
private final String _projectName;
private String _folderName;
private String _modulePath;
private String _containerPath;
private String _billingFolder;
public Ext4Helper _ext4Helper;

Expand All @@ -58,12 +55,9 @@ public EHRBillingHelper(BaseWebDriverTest test, String projectName)
_ext4Helper = new Ext4Helper(_test);
}

public EHRBillingHelper(BaseWebDriverTest test, String projectName, String folderName, String modulePath, String containerPath, String billingFolder)
public EHRBillingHelper(BaseWebDriverTest test, String projectName, String billingFolder)
{
this(test, projectName);
_folderName = folderName;
_modulePath = modulePath;
_containerPath = containerPath;
_billingFolder = billingFolder;
}

Expand All @@ -88,7 +82,7 @@ public void performBillingRun(String startDate, String endDate, String comment,

public void checkMessageWindow(String title, @Nullable String bodyText, String buttonText)
{
Window msgWindow = new Window.WindowFinder(_test.getDriver()).withTitle(title).waitFor();
Window<?> msgWindow = new Window.WindowFinder(_test.getDriver()).withTitle(title).waitFor();
assertEquals("Message window Title mismatch", title, msgWindow.getTitle());

if (null != bodyText)
Expand Down Expand Up @@ -149,7 +143,7 @@ public void verifyBillingInvoicedItemsUsingAPI(String InvoicedId, List<InvoicedI
int sumQuantity = 0;
for (Map<String, Object> row : resp.getRows())
if (row.get("quantity") != null)
sumQuantity += (double) row.get("quantity");
sumQuantity += ((Number) row.get("quantity")).intValue();

assertEquals("Total quantity is not as expected", String.valueOf(sumQuantity), item.getTotalQuantity());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ public List<String> getProtocolActionNames()
}

@Override
public PipelineJob.Task createTask(PipelineJob job)
public BillingTask createTask(PipelineJob job)
{

return new BillingTask(this, job);
}

Expand Down