Skip to content
Open
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
5 changes: 5 additions & 0 deletions api/src/org/labkey/api/exp/api/ExperimentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,11 @@ List<? extends ExpProtocol> getExpProtocolsWithParameterValue(
void clearMaterialAncestors(Collection<Long> materialRowIds);
void repopulateAncestors();

boolean hasSampleIdsNotInScope(Container container, User user, Collection<Long> sampleIds);

boolean hasSourceIdsNotInScope(Container container, User user, Collection<Long> sourceIds);


class XarExportOptions
{
String _lsidRelativizer = LSID_OPTION_FOLDER_RELATIVE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,32 @@ public List<Long> findIdsNotPermittedForOperation(List<? extends ExpMaterial> ca
.map(ExpObject::getRowId).collect(Collectors.toList());
}

@Override
public boolean hasSampleIdsNotInScope(Container container, User user, Collection<Long> sampleIds)
{
return hasEntityIdsNotInScope(container, user, getTinfoMaterial(), sampleIds);
}

@Override
public boolean hasSourceIdsNotInScope(Container container, User user, Collection<Long> sourceIds)
{
return hasEntityIdsNotInScope(container, user, getTinfoData(), sourceIds);
}

// GitHub Issue 1309
private boolean hasEntityIdsNotInScope(Container container, User user, TableInfo entityTable, Collection<Long> entityIds)
{
if (entityIds.isEmpty())
return false;

ContainerFilter cf = container.getProductFoldersDataContainerFilter(user);
SimpleFilter filter = new SimpleFilter().addInClause(FieldKey.fromParts("RowId"), entityIds);
filter.addClause(cf.createFilterClause(entityTable.getSchema(), FieldKey.fromParts("Container")));

Set<Long> inScope = new HashSet<>(new TableSelector(entityTable, Collections.singleton("RowId"), filter, null).getArrayList(Long.class));
return entityIds.stream().anyMatch(id -> !inScope.contains(id));
}

private @NotNull List<Material> getMaterials(SimpleFilter filter, @Nullable Sort sort)
{
return new TableSelector(getTinfoMaterial(), filter, sort).getArrayList(Material.class);
Expand Down