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
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/exp/api/ExpProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ enum Status
String getContact();

List<? extends ExpProtocol> getChildProtocols();
List<? extends ExpExperiment> getBatches();
List<? extends ExpExperiment> getBatches(@Nullable Container c);

void setEntityId(String entityId);
String getEntityId();
Expand Down
34 changes: 12 additions & 22 deletions assay/src/org/labkey/assay/AssayManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,16 @@ public AssaySchema createSchema(User user, Container container, @Nullable Contai

@Override
public @NotNull List<ExpProtocol> getAssayProtocols(Container container)
{
return getAssayProtocols(container, false);
}

private @NotNull List<ExpProtocol> getAssayProtocols(Container container, boolean currentOnly)
{
List<ExpProtocol> allProtocols = new ArrayList<>();

for (Container containerInScope : container.getContainersFor(ContainerType.DataType.protocol))
Collection<Container> containerScopes = currentOnly ? List.of(container) : container.getContainersFor(ContainerType.DataType.protocol);
for (Container containerInScope : containerScopes)
{
List<ExpProtocol> ids = PROTOCOL_CACHE.get(containerInScope);
allProtocols.addAll(ids);
Expand Down Expand Up @@ -622,14 +628,14 @@ public ExpExperiment findBatch(ExpRun run)
}

/**
* Creates a single document per assay design/folder combo, with some simple assay info (name, description), plus
* the names and comments from all the runs.
* Creates a single document per assay design, with some simple assay info (name, description).
* Note: the document for an assay protocol will just be associated with the protocol's container
*/
@Override
public void indexAssays(SearchService.TaskIndexingQueue queue)
{
List<ExpProtocol> protocols = getAssayProtocols(queue.getContainer());

// GitHub Issue 895: for the assay protocol search document just user the current container's protocols
List<ExpProtocol> protocols = getAssayProtocols(queue.getContainer(), true);
for (ExpProtocol protocol : protocols)
indexAssay(queue, protocol);
}
Expand Down Expand Up @@ -661,22 +667,6 @@ public void indexAssay(SearchService.TaskIndexingQueue queue, ExpProtocol protoc
m.put(SearchService.PROPERTY.keywordsMed.toString(), keywords);
m.put(SearchService.PROPERTY.categories.toString(), ASSAY_CATEGORY.getName());

ExperimentService.get().getExpRuns(c, protocol, null)
.forEach(run -> {
StringBuilder runKeywords = new StringBuilder();

runKeywords.append(" ");
runKeywords.append(run.getName());

if (null != run.getComments())
{
runKeywords.append(" ");
runKeywords.append(run.getComments());
}

body.append(runKeywords);
});

String docId = protocol.getDocumentId();
WebdavResource r = new SimpleDocumentResource(new Path(docId), docId, c.getEntityId(), "text/plain", body.toString(), assayBeginURL, createdBy, created, modifiedBy, modified, m);
queue.addResource(r);
Expand Down Expand Up @@ -728,7 +718,7 @@ private void indexAssayBatches(SearchService.TaskIndexingQueue queue, ExpProtoco
{
if (shouldIndexProtocolBatches(protocol))
{
for (ExpExperiment batch : protocol.getBatches())
for (ExpExperiment batch : protocol.getBatches(queue.getContainer()))
{
if (modifiedSince == null || modifiedSince.before(batch.getModified()))
indexAssayBatch(queue, batch);
Expand Down
8 changes: 5 additions & 3 deletions experiment/src/org/labkey/experiment/api/ExpProtocolImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.labkey.api.assay.AssayProvider;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.data.Filter;
import org.labkey.api.data.SQLFragment;
import org.labkey.api.data.SimpleFilter;
import org.labkey.api.data.SqlSelector;
Expand Down Expand Up @@ -329,9 +328,12 @@ public List<ExpProtocolImpl> getChildProtocols()
}

@Override
public List<ExpExperimentImpl> getBatches()
public List<ExpExperimentImpl> getBatches(@Nullable Container c)
{
Filter filter = new SimpleFilter(FieldKey.fromParts("BatchProtocolId"), getRowId());
SimpleFilter filter = new SimpleFilter(FieldKey.fromParts("BatchProtocolId"), getRowId());
// GitHub Issue 895: add param option to get just the assay batches for a specific container
if (c != null)
filter.addCondition(FieldKey.fromParts("container"), c);
return ExpExperimentImpl.fromExperiments(new TableSelector(ExperimentServiceImpl.get().getTinfoExperiment(), filter, null).getArray(Experiment.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4528,7 +4528,7 @@ public void deleteProtocolByRowIds(Container c, User user, @Nullable String audi

for (ExpProtocol protocolToDelete : expProtocols)
{
for (ExpExperiment batch : protocolToDelete.getBatches())
for (ExpExperiment batch : protocolToDelete.getBatches(null))
{
batch.delete(user);
}
Expand Down
Loading