diff --git a/study/src/org/labkey/study/controllers/ParticipantGroupController.java b/study/src/org/labkey/study/controllers/ParticipantGroupController.java index 3fa5470a6c1..2e05e2a1f13 100644 --- a/study/src/org/labkey/study/controllers/ParticipantGroupController.java +++ b/study/src/org/labkey/study/controllers/ParticipantGroupController.java @@ -1128,6 +1128,7 @@ private static class UpdateParticipantGroupForm private String[] _participantIds; private String[] _ensureParticipantIds; private String[] _deleteParticipantIds; + private boolean _showDataRegionMessage = true; public int getRowId() { @@ -1198,6 +1199,16 @@ public void setDeleteParticipantIds(String[] deleteParticipantIds) { _deleteParticipantIds = deleteParticipantIds; } + + public boolean isShowDataRegionMessage() + { + return _showDataRegionMessage; + } + + public void setShowDataRegionMessage(boolean showDataRegionMessage) + { + _showDataRegionMessage = showDataRegionMessage; + } } @RequiresPermission(ReadPermission.class) @RequiresLogin @@ -1425,7 +1436,7 @@ public Object execute(UpdateParticipantGroupForm form, BindException errors) if (existing == null) throw new NotFoundException("Could not find participant group with rowId " + form.getRowId()); - ParticipantGroupManager.getInstance().setSessionParticipantGroup(getContainer(), getUser(), getViewContext().getRequest(), existing.getRowId()); + ParticipantGroupManager.getInstance().setSessionParticipantGroup(getContainer(), getUser(), getViewContext().getRequest(), existing.getRowId(), form.isShowDataRegionMessage()); return success(existing); } else @@ -1453,7 +1464,7 @@ else if (!group.isSession()) copy.setModified(copy.getModified()); copy.setModifiedBy(copy.getModifiedBy()); group = copy; - ParticipantGroupManager.getInstance().setSessionParticipantGroup(getContainer(), getUser(), getViewContext().getRequest(), group); + ParticipantGroupManager.getInstance().setSessionParticipantGroup(getContainer(), getUser(), getViewContext().getRequest(), group, form.isShowDataRegionMessage()); } Set participantIds = new HashSet<>(Arrays.asList(form.getParticipantIds() == null ? group.getParticipantIds() : form.getParticipantIds())); @@ -1473,7 +1484,7 @@ else if (!group.isSession()) if (form.getFilters() != null) group.setFilters(form.getFilters()); - group = ParticipantGroupManager.getInstance().setSessionParticipantGroup(getContainer(), getUser(), getViewContext().getRequest(), group); + group = ParticipantGroupManager.getInstance().setSessionParticipantGroup(getContainer(), getUser(), getViewContext().getRequest(), group, form.isShowDataRegionMessage()); return success(group); } } diff --git a/study/src/org/labkey/study/model/ParticipantGroupManager.java b/study/src/org/labkey/study/model/ParticipantGroupManager.java index 581acee37c6..969867945a6 100644 --- a/study/src/org/labkey/study/model/ParticipantGroupManager.java +++ b/study/src/org/labkey/study/model/ParticipantGroupManager.java @@ -55,6 +55,7 @@ import org.labkey.api.util.MemTracker; import org.labkey.api.util.PageFlowUtil; import org.labkey.api.util.Pair; +import org.labkey.api.util.SessionHelper; import org.labkey.api.view.ActionURL; import org.labkey.api.view.NavTree; import org.labkey.api.view.ViewContext; @@ -659,16 +660,17 @@ private Map getParticipantIdMap(Container c, User user, Particip return participantIdMap; } - public void setSessionParticipantGroup(Container c, User user, HttpServletRequest request, Integer groupRowId) + public void setSessionParticipantGroup(Container c, User user, HttpServletRequest request, Integer groupRowId, boolean showDataRegionMessage) { HttpSession session = request.getSession(true); if (session == null) return; session.setAttribute(PARTICIPANT_GROUP_SESSION_KEY + c.getRowId(), groupRowId); + session.setAttribute(PARTICIPANT_GROUP_SESSION_KEY + c.getRowId() + ".showMessage", showDataRegionMessage); } - public ParticipantGroup setSessionParticipantGroup(Container c, User user, HttpServletRequest request, ParticipantGroup group) + public ParticipantGroup setSessionParticipantGroup(Container c, User user, HttpServletRequest request, ParticipantGroup group, boolean showDataRegionMessage) { assert group.isSession(); HttpSession session = request.getSession(true); @@ -676,11 +678,20 @@ public ParticipantGroup setSessionParticipantGroup(Container c, User user, HttpS return null; session.setAttribute(PARTICIPANT_GROUP_SESSION_KEY + c.getRowId(), group); + session.setAttribute(PARTICIPANT_GROUP_SESSION_KEY + c.getRowId() + ".showMessage", showDataRegionMessage); + // don't MemTrack track this one, since it's going in session MemTracker.get().remove(group); return group; } + public boolean getSessionParticipantGroupShowMessage(Container c, HttpServletRequest request) + { + Boolean b = (Boolean)SessionHelper.getAttribute(request, PARTICIPANT_GROUP_SESSION_KEY + c.getRowId() + ".showMessage", false); + + return b == Boolean.TRUE; + } + public ParticipantGroup getSessionParticipantGroup(Container c, User user, HttpServletRequest request) { HttpSession session = request.getSession(true); @@ -703,6 +714,7 @@ public void deleteSessionParticipantGroup(Container c, User user, HttpServletReq return; session.removeAttribute(PARTICIPANT_GROUP_SESSION_KEY + c.getRowId()); + session.removeAttribute(PARTICIPANT_GROUP_SESSION_KEY + c.getRowId() + ".showMessage"); } diff --git a/study/src/org/labkey/study/query/DatasetQueryView.java b/study/src/org/labkey/study/query/DatasetQueryView.java index a22c1cac2c9..2efc5ea5c76 100644 --- a/study/src/org/labkey/study/query/DatasetQueryView.java +++ b/study/src/org/labkey/study/query/DatasetQueryView.java @@ -696,29 +696,32 @@ protected void addHeaderMessage(StringBuilder headerMessage, RenderContext ctx) } } - ParticipantGroup sessionGroup = ParticipantGroupManager.getInstance().getSessionParticipantGroup(dqs.getContainer(), dqs.getUser(), ctx.getViewContext().getRequest()); - if (sessionGroup != null) + if (ParticipantGroupManager.getInstance().getSessionParticipantGroupShowMessage(dqs.getContainer(), ctx.getViewContext().getRequest())) { - if (msg.length() > 0) - msg.append("  "); - msg.append("Selected " + PageFlowUtil.filter(dqs.getStudy().getSubjectNounPlural()) + ": "); - msg.append(sessionGroup.getParticipantIds().length); - } + ParticipantGroup sessionGroup = ParticipantGroupManager.getInstance().getSessionParticipantGroup(dqs.getContainer(), dqs.getUser(), ctx.getViewContext().getRequest()); + if (sessionGroup != null) + { + if (msg.length() > 0) + msg.append("  "); + msg.append("Selected " + PageFlowUtil.filter(dqs.getStudy().getSubjectNounPlural()) + ": "); + msg.append(sessionGroup.getParticipantIds().length); + } - if (msg.length() == 0) - return; + if (msg.length() != 0) + { + // HACK -- link to immport/studyFinder.view + Module immport = ModuleLoader.getInstance().getModule("immport"); + Container project = ctx.getContainer().getProject(); + if (immport != null && project != null && project.getActiveModules().contains(immport)) + { + ActionURL finderURL = new ActionURL("immport", "dataFinderRedirect.view", project); + msg.append("  ").append(PageFlowUtil.button("Edit").href(finderURL.toString())); + } + msg.append(""); - // HACK -- link to immport/studyFinder.view - Module immport = ModuleLoader.getInstance().getModule("immport"); - Container project = ctx.getContainer().getProject(); - if (immport != null && project != null && project.getActiveModules().contains(immport)) - { - ActionURL finderURL = new ActionURL("immport", "dataFinderRedirect.view", project); - msg.append("  ").append(PageFlowUtil.button("Edit").href(finderURL.toString())); + headerMessage.append(msg); + } } - msg.append(""); - - headerMessage.append(msg); } }