Skip to content

Commit

Permalink
Item 7348 : Front Page, ETL & Breadcrumbs on Reports (#272)
Browse files Browse the repository at this point in the history
- Feature Request 39428: Modify home page to clarify for HIV: Font updates.
- Feature Request 36306: Update virus metadata in Learn - Assays: ETL file name change from VirusPanel_Metadata.txt to VirusPanel.txt, and PK updates to cds.import_nabantigen and cds.nabantigen tables.
- Feature Request 39429: Enable more than 2 reports in MAB section: add breadcrumbs on reports page.
- Secure Issue 40526: Invalid param value for 'study' throws NPE : show error message instead of NPE.
  • Loading branch information
labkey-bpatel authored May 31, 2020
1 parent 155678e commit e77083a
Show file tree
Hide file tree
Showing 20 changed files with 216 additions and 53 deletions.
5 changes: 5 additions & 0 deletions resources/schemas/dbscripts/postgresql/cds-20.003-20.004.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE cds.import_nabantigen DROP CONSTRAINT import_nabantigen_pkey;
ALTER TABLE cds.import_nabantigen ADD PRIMARY KEY (container, assay_identifier, cds_virus_id);

ALTER TABLE cds.nabantigen DROP CONSTRAINT nabantigen_pkey;
ALTER TABLE cds.nabantigen ADD PRIMARY KEY (container, assay_identifier, cds_virus_id);
8 changes: 6 additions & 2 deletions src/org/labkey/cds/CDSController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,6 @@ else if (isPost())
@RequiresPermission(ReadPermission.class)
public static class GetStudyDocumentAction extends SimpleViewAction<StudyDocumentForm>
{
@Override
public NavTree appendNavTrail(NavTree root)
{
return null;
Expand Down Expand Up @@ -1067,7 +1066,12 @@ public ModelAndView getView(StudyDocumentForm form, BindException errors) throws

if (!errors.hasErrors() && !StringUtils.isBlank(filename))
{
if (form.isPublicAccess() || CDSManager.get().isStudyDocumentAccessible(form.getStudy(), form.getDocumentId(), getUser(), getContainer()))
//fix for Secure Issue 40526: Invalid param value for 'study' throws NPE
if (null != form.getStudy() && null != form.getDocumentId() && !CDSManager.get().isParamValueValid(form.getStudy(), form.getDocumentId(), getUser(), getContainer()))
{
errors.reject(ERROR_MSG, "Invalid parameter value(s) for 'study' and/or 'documentId'.");
}
else if (form.isPublicAccess() || CDSManager.get().isStudyDocumentAccessible(form.getStudy(), form.getDocumentId(), getUser(), getContainer()))
{
WebdavService service = ServiceRegistry.get().getService(WebdavService.class);
WebdavResource resource = service.lookup(Path.parse(basePath + filename));
Expand Down
21 changes: 19 additions & 2 deletions src/org/labkey/cds/CDSManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.labkey.cds;

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.data.CoreSchema;
Expand Down Expand Up @@ -244,16 +245,32 @@ public void setActiveUserProperties(User user, Container container, Map<String,
}

public boolean isStudyDocumentAccessible(String studyName, String docId, User user, Container container)
{
TableSelector selector = getDocumentsForStudiesTableSelector(studyName, docId, user, container);
return selector.getObject(Boolean.class);
}

@NotNull
private TableSelector getDocumentsForStudiesTableSelector(String studyName, String docId, User user, Container container)
{
TableInfo tableInfo = getCDSQueryTableInfo("learn_documentsforstudies", user, container);
SimpleFilter filter = new SimpleFilter();
filter.addCondition(FieldKey.fromParts("prot"), studyName);
filter.addCondition(FieldKey.fromParts("document_id"), docId);

TableSelector selector = new TableSelector(tableInfo, Collections.singleton("accessible"), filter, null);
return selector.getObject(Boolean.class);
return new TableSelector(tableInfo, Collections.singleton("accessible"), filter, null);
}

public boolean isParamValueValid(String studyName, String docId, User user, Container container)
{
TableSelector selector = getDocumentsForStudiesTableSelector(studyName, docId, user, container);

if (null == selector.getObject(Boolean.class))
{
return false;
}
return selector.getObject(Boolean.class);
}

public static TableInfo getCDSQueryTableInfo(String queryName, User user, Container container)
{
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/cds/CDSModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public String getName()
@Override
public @Nullable Double getSchemaVersion()
{
return 20.003;
return 20.004;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/cds/data/steps/CDSImportTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class CDSImportTask extends TaskRefTaskImpl
new TSVCopyConfig("NAbAntigen", "AssayNABAntigen_Metadata"),
new TSVCopyConfig("BAMAAntigen", "AssayBAMAAntigen_Metadata"),
new TSVCopyConfig("antigenPanel", "AntigenPanel_Metadata"),
new TSVCopyConfig("virusPanel", "VirusPanel_Metadata"),
new TSVCopyConfig("virusPanel", "VirusPanel"),

// Datasets
new TSVCopyConfig("ICS", "AssayICS"),
Expand Down
11 changes: 8 additions & 3 deletions src/org/labkey/cds/view/template/FrontPage.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,16 @@
<span>Don't have an account?</span>
<a href="#" class="register-modal-trigger front-page-button">Register Here</a>
</div>
<div class="welcome">
<div class="title">
<div class="welcome" style="margin-bottom: unset">
<div class="title" style="margin-bottom: unset">
<h1></h1>
<h1>Welcome to the</h1>
<h1>CAVD DataSpace</h1>
<h1>A data sharing and discovery tool for HIV vaccine research</h1>
</div>
</div>
<div class="learn-more" style="max-width:unset;">
<div class="container" style="margin-top: unset;">
<h3>A data sharing and discovery tool for HIV vaccine research</h3>
</div>
</div>
<div class="video-container">
Expand Down
43 changes: 42 additions & 1 deletion test/src/org/labkey/test/tests/cds/CDSMAbTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,24 @@
import org.junit.experimental.categories.Category;
import org.junit.rules.Timeout;
import org.labkey.test.Locator;
import org.labkey.test.TestFileUtils;
import org.labkey.test.pages.cds.AntigenFilterPanel;
import org.labkey.test.pages.cds.CDSExport;
import org.labkey.test.pages.cds.InfoPane;
import org.labkey.test.pages.cds.MAbDataGrid;
import org.labkey.test.util.cds.CDSHelper;
import org.openqa.selenium.WebElement;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.labkey.test.pages.cds.MAbDataGrid.ANTIGEN_BINDING_COL;
import static org.labkey.test.pages.cds.MAbDataGrid.CLADES_COL;
import static org.labkey.test.pages.cds.MAbDataGrid.GEOMETRIC_MEAN_IC50_COL;
Expand Down Expand Up @@ -227,7 +232,7 @@ public void testMAbSearchFilter()
}

@Test
public void testMAbReports()
public void testMAbReports() throws IOException
{
CDSHelper.NavigationLink.MABGRID.makeNavigationSelection(this);
MAbDataGrid grid = new MAbDataGrid(getGridEl(), this, this);
Expand Down Expand Up @@ -284,6 +289,42 @@ public void testMAbReports()
log("Verify the 2nd R report");
grid.openIC50Report();
Assert.assertTrue("Report image is not rendered", isElementPresent(grid.getReportImageOut()));

verifyBreadCrumbs(grid);
}

private void verifyBreadCrumbs(MAbDataGrid grid) throws IOException
{
log("Verify header breadcrumbs from the Reports view");
clickExportCSVBreadCrumb();
clickExportExcelBreadCrumb();
clickViewGrid(grid);
}

private void clickViewGrid(MAbDataGrid grid)
{
log("Verify 'View Grid' button takes user back to MAb grid.");
Locator.XPathLocator viewGridBtn = Locator.tagWithId("a", "mabgridcolumnsbtn-breadcrumb");
click(viewGridBtn);
assertTrue("Unable to get back to the grid, MAb report buttons not present",
isElementPresent(grid.getDilutionReportBtn()) && isElementPresent(grid.getIC50ReportBtn()));
}

private void clickExportExcelBreadCrumb()
{
log("Verify 'Export CSV' button downloads the zip from Reports view.");
Locator.XPathLocator exportExcelBtn = Locator.tagWithId("a", "gridexportexcelbtn-breadcrumb");
File exceldownload = clickAndWaitForDownload(exportExcelBtn);
String fileContents = TestFileUtils.getFileContents(exceldownload);
assertTrue("Empty file", fileContents.length() > 0);
}

private void clickExportCSVBreadCrumb() throws IOException
{
Locator.XPathLocator exportCSVBtn = Locator.tagWithId("a", "gridexportcsvbtn-breadcrumb");
File csvZipArchive = clickAndWaitForDownload(exportCSVBtn);
assertEquals("Zip archive file count mismatch (expected these files in the zip archive: Assays.csv, MAbs.csv, Metadata.txt, NAB MAB.csv, Studies.csv, Study and MAbs.csv, Variable definitions.csv)", 7,
TestFileUtils.getFilesInZipArchive(csvZipArchive).size());
}

private void verifyReportContent(List<String> expectedContent, String reportContent)
Expand Down
10 changes: 8 additions & 2 deletions test/src/org/labkey/test/tests/cds/CDSTestLearnAbout.java
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,8 @@ private void verifyNonIntegratedDetailFieldValues(String value, String suffix)
private void verifyNonIntegratedDownloadLink(String altText, String documentName)
{
Locator.XPathLocator downloadLinkLocator = Locator.tagWithAttributeContaining("img", "alt", altText);
File downloadedFile = clickAndWaitForDownload(downloadLinkLocator, 1)[0];
scrollIntoView(downloadLinkLocator);
File downloadedFile = clickAndWaitForDownload(downloadLinkLocator);
assertTrue(downloadedFile + " not downloaded.", downloadedFile.getName().contains(documentName));
}

Expand All @@ -1149,7 +1150,7 @@ private void verifyNonIntegratedDataHeader(String studyName)

verifySectionHeaders("Non-integrated data");

Locator.XPathLocator nonIntegratedDataElement = Locator.tagWithAttributeContaining("div", "id", "nonintegrateddataavailability");
Locator.XPathLocator nonIntegratedDataElement = Locator.tagWithAttributeContaining("div", "id", "studynonintegrateddata");
assertElementPresent(nonIntegratedDataElement);

Locator.XPathLocator instructions = nonIntegratedDataElement.withDescendant(Locator.tag("p")).containing("Download individual files");
Expand Down Expand Up @@ -1676,18 +1677,21 @@ public void validateReportsDocumentLinks()
documentLink = CDSHelper.Locators.studyReportLink("Epitope Mapping Results Summary").findElement(getDriver());
assertTrue("Was not able to find link to the Powerpoint document for study '" + studyName + "'.", documentLink != null);
documentName = "cvd260_CAVIMC 031 Linear Epitope Mapping_BaselineSubtracted-3.pptx";
scrollIntoView(documentLink);
cds.validateDocLink(documentLink, documentName);

log("Now check the Excel link.");
documentLink = CDSHelper.Locators.studyReportLink("NAB Data Summary 2").findElement(getDriver());
assertTrue("Was not able to find link to the Excel document for study '" + studyName + "'.", documentLink != null);
documentName = "cvd260_CAVIMC-031 Neutralization Data with AUC 3 May 2011-6.xlsx";
scrollIntoView(documentLink);
cds.validateDocLink(documentLink, documentName);

log("Finally for this study validate the pdf file.");
documentLink = CDSHelper.Locators.studyReportLink("NAB Data Summary 1").findElement(getDriver());
assertTrue("Was not able to find link to the PDF document for study '" + studyName + "'.", documentLink != null);
documentName = "cvd260_McElrath_Seder_Antibody Responses 1.1 01Jun11.pdf";
scrollIntoView(documentLink);
cds.validatePDFLink(documentLink, documentName);

cds.viewLearnAboutPage("Studies");
Expand All @@ -1706,12 +1710,14 @@ public void validateReportsDocumentLinks()
documentLink = CDSHelper.Locators.studyReportLink("CFSE Results Summary").findElement(getDriver());
assertTrue("Was not able to find link to the Word Document document for study '" + studyName + "'.", documentLink != null);
documentName = "cvd264_DCVax001_CFSE_Memo_JUL13_v4.docx";
scrollIntoView(documentLink);
cds.validateDocLink(documentLink, documentName);

log("Now check one of the PDF link.");
documentLink = CDSHelper.Locators.studyReportLink("ICS Data Summary").findElement(getDriver());
assertTrue("Was not able to find link to the PDF document for study '" + studyName + "'.", documentLink != null);
documentName = "cvd264_ICS_LAB_REPORT_19APR13_n24fcm_fh_IL2_CD154_MIMOSA.pdf";
scrollIntoView(documentLink);
cds.validatePDFLink(documentLink, documentName);

cds.viewLearnAboutPage("Studies");
Expand Down
2 changes: 1 addition & 1 deletion webapp/Connector/src/app/store/Publication.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Ext.define('Connector.app.store.Publication', {
}, this);

// map the docs to each publication
let publicationMap = {};
var publicationMap = {};
Ext.each(documents, function (doc) {
publicationMap[doc.publication_id] = publicationMap[doc.publication_id] || [];
publicationMap[doc.publication_id].push(doc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Ext.define('Connector.view.module.NonIntegratedDataAvailability', {

initComponent : function() {

const data = this.getData();
var data = this.getData();
if (data.length > 0) {
var docIsValidAction = function(doc, status) {
doc.isLinkValid = status;
Expand Down Expand Up @@ -62,7 +62,7 @@ Ext.define('Connector.view.module.NonIntegratedDataAvailability', {
width: '90%',
sortable: false,
menuDisabled: true,
tpl: this.getColTemplate(),
tpl: this.getColTemplate()
}],
listeners : {
'itemmouseenter' : function(view, record, item, index, evt) {
Expand Down Expand Up @@ -268,7 +268,7 @@ Ext.define('Connector.view.module.PublicationNonIntegratedData', {
},

getStore : function(data) {
let config = {
var config = {
fields: ['publication_id', 'document_id', 'label', 'fileName', 'filePath', 'docType', 'isLinkValid', 'suffix'],
data: data,
storeId: 'PublicationNonIntegratedDataStore'
Expand Down
2 changes: 1 addition & 1 deletion webapp/Connector/src/component/Started.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Ext.define('Connector.component.Started', {
me.loadHelpFile();
}
}
}],
}]
};
Connector.panel.HelpCenter.displayWikiWindow(target, config);
},
Expand Down
2 changes: 1 addition & 1 deletion webapp/Connector/src/controller/AbstractGridController.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ Ext.define('Connector.controller.AbstractGridController', {

onViewActivate : function() {},

onViewDeactivate : function() {},
onViewDeactivate : function() {}
});
2 changes: 1 addition & 1 deletion webapp/Connector/src/ext-patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Ext.override(Ext.grid.View, {
});

Ext.override(Ext.util.Format, {
date(v, format){
date : function(v, format){
if (!v) {
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/Connector/src/panel/HelpCenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Ext.define('Connector.panel.HelpCenter', {
},
scope: this
}
}],
}]
};
Connector.panel.HelpCenter.displayWikiWindow(animateTarget, config);
},
Expand Down
2 changes: 1 addition & 1 deletion webapp/Connector/src/panel/ToolsAndLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Ext.define('Connector.panel.ToolsAndLinks', {
id: 'toolspopup',
items: [{
xtype: 'toolslinks'
}],
}]
};
Connector.panel.HelpCenter.displayWikiWindow(animateTarget, config);
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/Connector/src/view/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Ext.define('Connector.view.Grid', {
xtype: 'container',
items: [this.getSourceTabHeader(), this.getSelectColumnsButton()],
layout: {
type: 'hbox',
type: 'hbox'
}
}]
}];
Expand Down
Loading

0 comments on commit e77083a

Please sign in to comment.