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 numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
package org.labkey.laboratory;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.json.JSONException;
import org.json.JSONObject;
Expand DownExpand Up@@ -46,7 +46,7 @@ public static AdditionalDataSource getFromParts(Container c, User u, String item
return new AdditionalDataSource(cat, label, containerId, schemaName, queryName, reportCategory, importIntoWorkbooks, subjectFieldKey, sampleDateFieldKey);
}

public static AdditionalDataSource getFromPropertyManager(Container c, User u, String key, String value) throws IllegalArgumentException
public static @Nullable AdditionalDataSource getFromPropertyManager(Container c, User u, String key, String value) throws IllegalArgumentException
{
if (value == null)
return null;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,10 +44,12 @@ public static DemographicsSource getFromParts(Container c, User u, String label,
return new DemographicsSource(label, containerId, schemaName, queryName, targetColumn);
}

public static DemographicsSource getFromPropertyManager(Container c, User u, String key, String value) throws IllegalArgumentException
public static @Nullable DemographicsSource getFromPropertyManager(Container c, User u, String key, String value) throws IllegalArgumentException
{
if (value == null)
{
return null;
}

try
{
Expand Down
32 changes: 24 additions & 8 deletions laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -431,11 +431,19 @@ public Map<Container, Set<AdditionalDataSource>> getAllAdditionalDataSources(Use
set = new HashSet<>();

AdditionalDataSource source = AdditionalDataSource.getFromPropertyManager(c, u, entry.getKey(), entry.getValue());
if (source != null)
set.add(source);
if (source == null)
{
continue;
}

Container targetContainer = source.getTargetContainer(c);
if (targetContainer == null || !targetContainer.hasPermission(u, ReadPermission.class))
{
continue;
}

if (set.size() > 0)
map.put(c, set);
set.add(source);
map.put(c, set);
}

return Collections.unmodifiableMap(map);
Expand All@@ -457,11 +465,19 @@ public Map<Container, Set<DemographicsSource>> getAllDemographicsSources(User u)
set = new HashSet<>();

DemographicsSource source = DemographicsSource.getFromPropertyManager(c, u, entry.getKey(), entry.getValue());
if (source != null)
set.add(source);
if (source == null)
{
continue;
}

Container targetContainer = source.getTargetContainer(c);
if (targetContainer == null || !targetContainer.hasPermission(u, ReadPermission.class))
{
continue;
}

if (set.size() > 0)
map.put(c, set);
set.add(source);
map.put(c, set);
}

return Collections.unmodifiableMap(map);
Expand Down