From c4e0e980ee8a93ce25b9eb9b3cfc47e0ec3cae55 Mon Sep 17 00:00:00 2001 From: vagisha Date: Sat, 16 Mar 2024 15:11:07 -0700 Subject: [PATCH 1/3] Make "Public" column in the ExperimentAnnotations table an ExprColumn so that it can be sorted and filtered. --- .../query/ExperimentAnnotationsTableInfo.java | 62 +++++-------------- 1 file changed, 15 insertions(+), 47 deletions(-) diff --git a/panoramapublic/src/org/labkey/panoramapublic/query/ExperimentAnnotationsTableInfo.java b/panoramapublic/src/org/labkey/panoramapublic/query/ExperimentAnnotationsTableInfo.java index 0b4372b8..5bb1a5f5 100644 --- a/panoramapublic/src/org/labkey/panoramapublic/query/ExperimentAnnotationsTableInfo.java +++ b/panoramapublic/src/org/labkey/panoramapublic/query/ExperimentAnnotationsTableInfo.java @@ -51,6 +51,7 @@ import org.labkey.api.security.permissions.Permission; import org.labkey.api.security.roles.FolderAdminRole; import org.labkey.api.security.roles.ProjectAdminRole; +import org.labkey.api.security.roles.ReaderRole; import org.labkey.api.security.roles.Role; import org.labkey.api.security.roles.RoleManager; import org.labkey.api.settings.AppProps; @@ -236,53 +237,7 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep runCountColumn.setLabel("Skyline Docs"); addColumn(runCountColumn); - var isPublicCol = wrapColumn("Public", getRealTable().getColumn("Id")); - isPublicCol.setDisplayColumnFactory(colInfo -> new DataColumn(colInfo) - { - @Override - public Object getValue(RenderContext ctx) - { - Integer experimentAnnotationsId = ctx.get(colInfo.getFieldKey(), Integer.class); - ExperimentAnnotations expAnnotations = ExperimentAnnotationsManager.get(experimentAnnotationsId); - if(expAnnotations != null) - { - return expAnnotations.isPublic() ? "Yes" : "No"; - } - return "Row not found in ExperimentAnnotations for id " + experimentAnnotationsId; - } - @Override - public Object getDisplayValue(RenderContext ctx) - { - return getValue(ctx); - } - @Override - public @NotNull HtmlString getFormattedHtml(RenderContext ctx) - { - return HtmlString.of((String)getValue(ctx)); - } - @Override - public Class getValueClass() - { - return String.class; - } - @Override - public Class getDisplayValueClass() - { - return String.class; - } - - @Override - public boolean isFilterable() - { - return false; - } - - @Override - public boolean isSortable() - { - return false; - } - }); + var isPublicCol = getIsPublicCol(); addColumn(isPublicCol); var licenseCol = wrapColumn("Data License", getRealTable().getColumn("Id")); @@ -430,6 +385,19 @@ private ExprColumn getCatalogEntryCol() return col; } + private ExprColumn getIsPublicCol() + { + SQLFragment isPublicColSql = new SQLFragment(" (SELECT CASE WHEN EXISTS (SELECT 1 FROM ") + .append(CoreSchema.getInstance().getTableInfoRoleAssignments()) + .append(" WHERE userId = ? AND role = ? AND resourceId = ").append(ExprColumn.STR_TABLE_ALIAS + ".Container").append(")") + .append(" THEN 'Yes' ELSE 'No' END ) ") + .add(Group.groupGuests) + .add(ReaderRole.class.getName()); + + ExprColumn isPublicCol = new ExprColumn(this, "Public", isPublicColSql, JdbcType.VARCHAR); + return isPublicCol; + } + @Override public String getName() { From 6a26f2da1fefbd7a6e7b11b9ba3faff5a2bb8c24 Mon Sep 17 00:00:00 2001 From: vagisha Date: Mon, 18 Mar 2024 16:38:36 -0700 Subject: [PATCH 2/3] Added comment. --- .../panoramapublic/query/ExperimentAnnotationsTableInfo.java | 1 + 1 file changed, 1 insertion(+) diff --git a/panoramapublic/src/org/labkey/panoramapublic/query/ExperimentAnnotationsTableInfo.java b/panoramapublic/src/org/labkey/panoramapublic/query/ExperimentAnnotationsTableInfo.java index 5bb1a5f5..764d589d 100644 --- a/panoramapublic/src/org/labkey/panoramapublic/query/ExperimentAnnotationsTableInfo.java +++ b/panoramapublic/src/org/labkey/panoramapublic/query/ExperimentAnnotationsTableInfo.java @@ -387,6 +387,7 @@ private ExprColumn getCatalogEntryCol() private ExprColumn getIsPublicCol() { + // Panorama Public dataset folders do not inherit permissions from the parent folder, so we don't need to worry about that case. SQLFragment isPublicColSql = new SQLFragment(" (SELECT CASE WHEN EXISTS (SELECT 1 FROM ") .append(CoreSchema.getInstance().getTableInfoRoleAssignments()) .append(" WHERE userId = ? AND role = ? AND resourceId = ").append(ExprColumn.STR_TABLE_ALIAS + ".Container").append(")") From b7d27487e07f6a6e4bcfc3bf4ee7928be5469a64 Mon Sep 17 00:00:00 2001 From: vagisha Date: Tue, 19 Mar 2024 09:10:25 -0700 Subject: [PATCH 3/3] Updated test. --- .../PanoramaPublicMakePublicTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/panoramapublic/test/src/org/labkey/test/tests/panoramapublic/PanoramaPublicMakePublicTest.java b/panoramapublic/test/src/org/labkey/test/tests/panoramapublic/PanoramaPublicMakePublicTest.java index 93e16b5f..f81de6b8 100644 --- a/panoramapublic/test/src/org/labkey/test/tests/panoramapublic/PanoramaPublicMakePublicTest.java +++ b/panoramapublic/test/src/org/labkey/test/tests/panoramapublic/PanoramaPublicMakePublicTest.java @@ -13,6 +13,7 @@ import org.labkey.test.components.panoramapublic.TargetedMsExperimentWebPart; import org.labkey.test.pages.admin.PermissionsPage; import org.labkey.test.util.ApiPermissionsHelper; +import org.labkey.test.util.DataRegionTable; import org.labkey.test.util.Ext4Helper; import org.labkey.test.util.PermissionsHelper; import org.openqa.selenium.NoSuchElementException; @@ -42,6 +43,7 @@ public void testExperimentCopy() String experimentTitle = "This is an experiment to test making data public"; String shortAccessUrl = setupFolderSubmitAndCopy(projectName, folderName, targetFolder, experimentTitle); + verifyIsPublicColumn(PANORAMA_PUBLIC, experimentTitle, false); verifyPermissions(projectName, folderName, PANORAMA_PUBLIC, targetFolder); // Verify that the submitter can make the data public @@ -63,6 +65,8 @@ public void testExperimentCopy() verifyMakePublic(PANORAMA_PUBLIC, targetFolder, SUBMITTER, true, true); verifyMakePublic(PANORAMA_PUBLIC, v1Folder, ADMIN_2, false); + verifyIsPublicColumn(PANORAMA_PUBLIC, experimentTitle, true); + // Data has been made public, and publication link and citation have been added. User should not able to resubmit goToProjectFolder(projectName, folderName); impersonate(SUBMITTER); @@ -223,6 +227,22 @@ private void verifyPermissions(String userProject, String userFolder, String pan } } + private void verifyIsPublicColumn(String panoramaPublicProject, String experimentTitle, boolean isPublic) + { + if (isImpersonating()) + { + stopImpersonating(true); + } + goToProjectHome(panoramaPublicProject); + + DataRegionTable expListTable = DataRegionTable.findDataRegionWithinWebpart(this, "Targeted MS Experiment List"); + expListTable.ensureColumnsPresent("Title", "DataVersion", "Public"); + expListTable.setFilter("Title", "Equals", experimentTitle); + expListTable.setFilter("DataVersion", "Equals", "1"); + assertEquals(1, expListTable.getDataRowCount()); + assertEquals(isPublic ? "Yes" : "No", expListTable.getDataAsText(0, "Public")); + } + private String getReviewerEmail(String panoramaPublicProject, String panoramaPublicFolder) { // Get the reviewer's email from the notification messages