Skip to content

Commit 85aecb9

Browse files
authored
Make it possible for users to view their data on Panorama Public (#387)
Add a "My Data" view for datasets submitted to Panorama Public.
1 parent 8975ce0 commit 85aecb9

File tree

12 files changed

+482
-103
lines changed

12 files changed

+482
-103
lines changed

panoramapublic/src/org/labkey/panoramapublic/PanoramaPublicController.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
import org.labkey.panoramapublic.query.ExperimentAnnotationsManager;
179179
import org.labkey.panoramapublic.query.JournalManager;
180180
import org.labkey.panoramapublic.query.ModificationInfoManager;
181+
import org.labkey.panoramapublic.query.MyDataTableInfo;
181182
import org.labkey.panoramapublic.query.PxXmlManager;
182183
import org.labkey.panoramapublic.query.SpecLibInfoManager;
183184
import org.labkey.panoramapublic.query.SubmissionManager;
@@ -8952,7 +8953,7 @@ public ModelAndView getView(IdForm form, BindException errors)
89528953

89538954
ensureCorrectContainer(getContainer(), expAnnotations.getContainer(), getViewContext()); // container check
89548955

8955-
return new CatalogEntryWebPart(expAnnotations, getUser(), true);
8956+
return new CatalogEntryWebPart(expAnnotations, getUser(), form.getReturnActionURL(PageFlowUtil.urlProvider(ProjectUrls.class).getBeginURL(getContainer())));
89568957
}
89578958

89588959
@Override
@@ -9183,6 +9184,34 @@ public ModelAndView getView(Object o, BindException errors)
91839184
}
91849185
}
91859186

9187+
@RequiresPermission(ReadPermission.class)
9188+
@RequiresLogin
9189+
public class MyDataViewAction extends SimpleViewAction<Object>
9190+
{
9191+
@Override
9192+
public void addNavTrail(NavTree root)
9193+
{
9194+
root.addChild("My Panorama Public Data");
9195+
}
9196+
9197+
@Override
9198+
public ModelAndView getView(Object o, BindException errors) throws Exception
9199+
{
9200+
QuerySettings settings = new QuerySettings(getViewContext(), MyDataTableInfo.NAME, MyDataTableInfo.NAME);
9201+
settings.setContainerFilterName(ContainerFilter.Type.CurrentAndSubfolders.name());
9202+
QueryView view = new QueryView(new PanoramaPublicSchema(getUser(), getContainer()), settings, errors);
9203+
view.setTitle("Panorama Public Experiments");
9204+
view.setShowRecordSelectors(false);
9205+
view.setShowExportButtons(false);
9206+
view.setShowDetailsColumn(false);
9207+
view.setShowDeleteButton(false);
9208+
view.setShowUpdateColumn(false);
9209+
view.setShowInsertNewButton(false);
9210+
view.disableContainerFilterSelection();
9211+
return view;
9212+
}
9213+
}
9214+
91869215
// ------------------------------------------------------------------------
91879216
// BEGIN Assign PanoramaPublicSubmitterRole to data submitters and lab heads
91889217
// ------------------------------------------------------------------------

panoramapublic/src/org/labkey/panoramapublic/PanoramaPublicSchema.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.labkey.panoramapublic.query.DataValidationTableInfo;
5555
import org.labkey.panoramapublic.query.ExperimentAnnotationsTableInfo;
5656
import org.labkey.panoramapublic.query.JournalExperimentTableInfo;
57+
import org.labkey.panoramapublic.query.MyDataTableInfo;
5758
import org.labkey.panoramapublic.query.PanoramaPublicTable;
5859
import org.labkey.panoramapublic.query.SubmissionTableInfo;
5960
import org.labkey.panoramapublic.query.modification.ExperimentIsotopeModInfoTableInfo;
@@ -129,6 +130,10 @@ public TableInfo createTable(String name, ContainerFilter cf)
129130
{
130131
return new ExperimentAnnotationsTableInfo(this, cf);
131132
}
133+
if (MyDataTableInfo.NAME.equalsIgnoreCase(name))
134+
{
135+
return new MyDataTableInfo(this, cf, getUser());
136+
}
132137
if (TABLE_JOURNAL_EXPERIMENT.equalsIgnoreCase(name))
133138
{
134139
return new JournalExperimentTableInfo(this, cf);

panoramapublic/src/org/labkey/panoramapublic/query/ExperimentAnnotationsTableInfo.java

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.labkey.api.security.roles.ProjectAdminRole;
5454
import org.labkey.api.security.roles.Role;
5555
import org.labkey.api.security.roles.RoleManager;
56+
import org.labkey.api.settings.AppProps;
5657
import org.labkey.api.util.DOM;
5758
import org.labkey.api.util.HtmlString;
5859
import org.labkey.api.util.PageFlowUtil;
@@ -65,8 +66,10 @@
6566
import org.labkey.panoramapublic.PanoramaPublicController;
6667
import org.labkey.panoramapublic.PanoramaPublicManager;
6768
import org.labkey.panoramapublic.PanoramaPublicSchema;
69+
import org.labkey.panoramapublic.model.CatalogEntry;
6870
import org.labkey.panoramapublic.model.DataLicense;
6971
import org.labkey.panoramapublic.model.ExperimentAnnotations;
72+
import org.labkey.panoramapublic.view.publish.CatalogEntryWebPart;
7073
import org.labkey.panoramapublic.view.publish.ShortUrlDisplayColumnFactory;
7174

7275
import java.io.IOException;
@@ -75,8 +78,12 @@
7578
import java.util.List;
7679
import java.util.Set;
7780

81+
import static org.labkey.api.util.DOM.Attribute.height;
82+
import static org.labkey.api.util.DOM.Attribute.href;
7883
import static org.labkey.api.util.DOM.Attribute.onclick;
7984
import static org.labkey.api.util.DOM.Attribute.src;
85+
import static org.labkey.api.util.DOM.Attribute.title;
86+
import static org.labkey.api.util.DOM.Attribute.width;
8087
import static org.labkey.api.util.DOM.IMG;
8188
import static org.labkey.api.util.DOM.at;
8289

@@ -337,6 +344,10 @@ public Class getDisplayValueClass()
337344
getMutableColumn("CreatedBy").setFk(new UserIdQueryForeignKey(schema));
338345
getMutableColumn("ModifiedBy").setFk(new UserIdQueryForeignKey(schema));
339346

347+
ExprColumn catalogEntryCol = getCatalogEntryCol();
348+
catalogEntryCol.setDisplayColumnFactory(colInfo -> new CatalogEntryIconColumn(colInfo));
349+
addColumn(catalogEntryCol);
350+
340351
List<FieldKey> visibleColumns = new ArrayList<>();
341352
visibleColumns.add(FieldKey.fromParts("Share"));
342353
visibleColumns.add(FieldKey.fromParts("Title"));
@@ -407,6 +418,18 @@ private ExprColumn getVersionCountCol()
407418
return versionCountCol;
408419
}
409420

421+
private ExprColumn getCatalogEntryCol()
422+
{
423+
SQLFragment catalogEntrySql = new SQLFragment(" (SELECT entry.id AS CatalogEntry ")
424+
.append(" FROM ").append(PanoramaPublicManager.getTableInfoCatalogEntry(), "entry")
425+
.append(" WHERE ")
426+
.append(" entry.shortUrl = ").append(ExprColumn.STR_TABLE_ALIAS).append(".shortUrl")
427+
.append(") ");
428+
ExprColumn col = new ExprColumn(this, "CatalogEntry", catalogEntrySql, JdbcType.INTEGER);
429+
col.setDescription("Add or view the catalog entry for the experiment");
430+
return col;
431+
}
432+
410433
@Override
411434
public String getName()
412435
{
@@ -724,4 +747,48 @@ String getRenderId()
724747
return "input-picker-div-instrument";
725748
}
726749
}
750+
751+
public static class CatalogEntryIconColumn extends DataColumn
752+
{
753+
public CatalogEntryIconColumn(ColumnInfo col)
754+
{
755+
super(col);
756+
super.setCaption("Catalog Entry");
757+
}
758+
759+
@Override
760+
public void renderGridCellContents(RenderContext ctx, Writer out) throws IOException
761+
{
762+
User user = ctx.getViewContext().getUser();
763+
if (user == null || user.isGuest())
764+
{
765+
HtmlString.NBSP.appendTo(out);
766+
return;
767+
}
768+
Integer catalogEntryId = ctx.get(getColumnInfo().getFieldKey(), Integer.class);
769+
770+
// Get the experiment connected with this catalog entry.
771+
Integer experimentId = ctx.get(FieldKey.fromParts("id"), Integer.class);
772+
if (experimentId != null)
773+
{
774+
ExperimentAnnotations expAnnot = ExperimentAnnotationsManager.get(experimentId);
775+
// Display the catalog entry link only if the user has the required permissions (Admin or PanoramaPublicSubmitter) in the the experiment folder.
776+
if (expAnnot != null && CatalogEntryWebPart.canBeDisplayed(expAnnot, user))
777+
{
778+
CatalogEntry entry = catalogEntryId == null ? null : CatalogEntryManager.get(catalogEntryId);
779+
String imageUrl = entry != null ? AppProps.getInstance().getContextPath() + "/PanoramaPublic/images/slideshow-icon-green.png"
780+
: AppProps.getInstance().getContextPath() + "/PanoramaPublic/images/slideshow-icon.png";
781+
String imageTitle = entry != null ? "View catalog entry" : "Add catalog entry";
782+
ActionURL returnUrl = ctx.getViewContext().getActionURL().clone();
783+
ActionURL catalogEntryLink = entry != null ? PanoramaPublicController.getViewCatalogEntryUrl(expAnnot, entry).addReturnURL(returnUrl)
784+
: PanoramaPublicController.getAddCatalogEntryUrl(expAnnot).addReturnURL(returnUrl);
785+
DOM.A(at(href, catalogEntryLink.getLocalURIString(), title, PageFlowUtil.filter(imageTitle)),
786+
DOM.IMG(at(src, imageUrl, height, 22, width, 22)))
787+
.appendTo(out);
788+
return;
789+
}
790+
}
791+
HtmlString.NBSP.appendTo(out);
792+
}
793+
}
727794
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.labkey.panoramapublic.query;
2+
3+
import org.labkey.api.data.CompareType;
4+
import org.labkey.api.data.ContainerFilter;
5+
import org.labkey.api.data.SimpleFilter;
6+
import org.labkey.api.query.FieldKey;
7+
import org.labkey.api.security.User;
8+
import org.labkey.panoramapublic.PanoramaPublicSchema;
9+
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
13+
public class MyDataTableInfo extends ExperimentAnnotationsTableInfo
14+
{
15+
public static final String NAME = "MyPanoramaPublicData";
16+
17+
public MyDataTableInfo(PanoramaPublicSchema schema, ContainerFilter cf, User user)
18+
{
19+
super(schema, cf);
20+
21+
if (user != null)
22+
{
23+
// Filter to rows where the given user is either the submitter or the lab head.
24+
SimpleFilter.OrClause or = new SimpleFilter.OrClause();
25+
or.addClause(new CompareType.EqualsCompareClause(FieldKey.fromParts("submitter"), CompareType.EQUAL, user.getUserId()));
26+
or.addClause(new CompareType.EqualsCompareClause(FieldKey.fromParts("labhead"), CompareType.EQUAL, user.getUserId()));
27+
SimpleFilter filter = new SimpleFilter();
28+
filter.addClause(or);
29+
addCondition(filter);
30+
}
31+
32+
List<FieldKey> visibleColumns = new ArrayList<>();
33+
visibleColumns.add(FieldKey.fromParts("Share"));
34+
visibleColumns.add(FieldKey.fromParts("Title"));
35+
visibleColumns.add(FieldKey.fromParts("Organism"));
36+
visibleColumns.add(FieldKey.fromParts("Instrument"));
37+
visibleColumns.add(FieldKey.fromParts("Runs"));
38+
visibleColumns.add(FieldKey.fromParts("Keywords"));
39+
visibleColumns.add(FieldKey.fromParts("Citation"));
40+
visibleColumns.add(FieldKey.fromParts("pxid"));
41+
visibleColumns.add(FieldKey.fromParts("Public"));
42+
visibleColumns.add(FieldKey.fromParts("CatalogEntry"));
43+
setDefaultVisibleColumns(visibleColumns);
44+
}
45+
}

panoramapublic/src/org/labkey/panoramapublic/view/expannotations/TargetedMSExperimentsWebPart.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,12 @@ protected void populateButtonBar(DataView view, ButtonBar bb)
7777
deleteExperimentAnnotation.setDisplayPermission(DeletePermission.class);
7878
deleteExperimentAnnotation.setRequiresSelection(true);
7979
bb.add(deleteExperimentAnnotation);
80+
81+
if (!view.getViewContext().getUser().isGuest())
82+
{
83+
ActionURL viewMyDataUrl = new ActionURL(PanoramaPublicController.MyDataViewAction.class, getContainer());
84+
ActionButton viewMyDataButton = new ActionButton(viewMyDataUrl, "My Data");
85+
bb.add(viewMyDataButton);
86+
}
8087
}
8188
}

panoramapublic/src/org/labkey/panoramapublic/view/publish/CatalogEntryWebPart.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package org.labkey.panoramapublic.view.publish;
22

3-
import org.labkey.api.action.UrlProvider;
3+
import org.jetbrains.annotations.Nullable;
44
import org.labkey.api.data.Container;
5-
import org.labkey.api.portal.ProjectUrls;
65
import org.labkey.api.security.User;
76
import org.labkey.api.security.permissions.AdminPermission;
87
import org.labkey.api.util.Button;
98
import org.labkey.api.util.HtmlString;
10-
import org.labkey.api.util.PageFlowUtil;
119
import org.labkey.api.util.URLHelper;
1210
import org.labkey.api.view.ActionURL;
1311
import org.labkey.api.view.HtmlView;
@@ -40,10 +38,10 @@ public class CatalogEntryWebPart extends VBox
4038
{
4139
public CatalogEntryWebPart(ExperimentAnnotations expAnnotations, User user)
4240
{
43-
this(expAnnotations, user, false);
41+
this(expAnnotations, user, null);
4442
}
4543

46-
public CatalogEntryWebPart(ExperimentAnnotations expAnnotations, User user, boolean standalone)
44+
public CatalogEntryWebPart(ExperimentAnnotations expAnnotations, User user, @Nullable ActionURL returnUrl)
4745
{
4846
Container container = expAnnotations.getContainer();
4947
setTitle("Panorama Public Catalog Entry");
@@ -108,9 +106,8 @@ public CatalogEntryWebPart(ExperimentAnnotations expAnnotations, User user, bool
108106
HtmlString.NBSP,
109107
new Button.ButtonBuilder("Delete").href(deleteUrl)
110108
.usePost("Are you sure you want to delete the Panorama Public catalog entry for this experiment?"),
111-
standalone ? DIV(at(style, "margin-top:25px;"),
112-
new Button.ButtonBuilder("Back to Folder").href(PageFlowUtil.urlProvider(ProjectUrls.class).getBeginURL(container)))
113-
: HtmlString.EMPTY_STRING
109+
returnUrl != null ? DIV(at(style, "margin-top:25px;"), new Button.ButtonBuilder("Back").href(returnUrl))
110+
: HtmlString.EMPTY_STRING
114111
)));
115112
}
116113
}

panoramapublic/src/org/labkey/panoramapublic/view/publish/catalogEntryForm.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
int imgWidth = settings.getImgWidth();
5454
int imgHeight = settings.getImgHeight();
5555
56-
ActionURL cancelUrl = PanoramaPublicController.getViewExperimentDetailsURL(form.getId(), form.getContainer());
56+
ActionURL cancelUrl = bean.getForm().getReturnActionURL(PanoramaPublicController.getViewExperimentDetailsURL(form.getId(), form.getContainer()));
5757
5858
%>
5959
<labkey:errors/>

panoramapublic/src/org/labkey/panoramapublic/view/search/panoramaWebSearch.jsp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,16 @@
479479
success: function (wp) {
480480
let expWebpart = wp.body.filter(webpart => webpart.name === "Targeted MS Experiment List");
481481
if (expWebpart.length === 1) {
482+
483+
let buttonBarItems = [];
484+
if (!LABKEY.user.isGuest)
485+
{
486+
buttonBarItems = [
487+
{text: 'My Data', url: LABKEY.ActionURL.buildURL('panoramapublic', 'myDataView')},
488+
LABKEY.QueryWebPart.standardButtons.views
489+
];
490+
}
491+
482492
let wp = new LABKEY.QueryWebPart({
483493
renderTo: 'webpart_'+ expWebpart[0].webPartId,
484494
title: 'Panorama Public Experiments',
@@ -491,6 +501,10 @@
491501
showExportButtons: false,//this needs to be set to false otherwise setting selectRecordSelector to false still shows the checkbox column
492502
showDetailsColumn: false,
493503
dataRegionName: "Targeted MS Experiment List",
504+
buttonBar: {
505+
includeStandardButtons: true,
506+
items: buttonBarItems,
507+
},
494508
success: function () {
495509
}
496510
});

panoramapublic/test/src/org/labkey/test/components/panoramapublic/TargetedMsExperimentWebPart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public TargetedMsExperimentInsertPage startInsert()
4343

4444
public void clickSubmit()
4545
{
46-
getWrapper().clickAndWait(Locator.linkContainingText("Submit"));
46+
getWrapper().clickAndWait(Locator.linkWithText("Submit"));
4747
}
4848

4949
public void clickResubmit()

0 commit comments

Comments
 (0)