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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are dealing with RowIds in both the entityIds collection and the inScope collection, could we just return a check for if the size of the collections match? If the size of the inScope set is smaller than the entityIds side, then there are some not in scope, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now after doing the CR on the limsModules side that this method was just ported over from WorkflowManager, so fine to leave it as is. I thought this was new code.

}

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