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
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,7 @@ private static class UpdateParticipantGroupForm
private String[] _participantIds;
private String[] _ensureParticipantIds;
private String[] _deleteParticipantIds;
private boolean _showDataRegionMessage = true;

public int getRowId()
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<String> participantIds = new HashSet<>(Arrays.asList(form.getParticipantIds() == null ? group.getParticipantIds() : form.getParticipantIds()));
Expand All @@ -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);
}
}
Expand Down
16 changes: 14 additions & 2 deletions study/src/org/labkey/study/model/ParticipantGroupManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -659,28 +660,38 @@ private Map<String, String> 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);
if (session == null)
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);
Expand All @@ -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");
}


Expand Down
41 changes: 22 additions & 19 deletions study/src/org/labkey/study/query/DatasetQueryView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("&nbsp;&nbsp;");
msg.append("<span class=\"labkey-strong\">Selected " + PageFlowUtil.filter(dqs.getStudy().getSubjectNounPlural()) + ":</span>&nbsp;");
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("&nbsp;&nbsp;");
msg.append("<span class=\"labkey-strong\">Selected " + PageFlowUtil.filter(dqs.getStudy().getSubjectNounPlural()) + ":</span>&nbsp;");
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("&nbsp;&nbsp;").append(PageFlowUtil.button("Edit").href(finderURL.toString()));
}
msg.append("</div>");

// 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("&nbsp;&nbsp;").append(PageFlowUtil.button("Edit").href(finderURL.toString()));
headerMessage.append(msg);
}
}
msg.append("</div>");

headerMessage.append(msg);
}
}

Expand Down