Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ Upmerge release/2023.2.x to release/2023.3.x #447

Merged
merged 3 commits into from
Aug 17, 2023
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 @@ -44,6 +44,7 @@
import com.labsynch.labseer.dto.TsvLoaderResponseDTO;
import com.labsynch.labseer.exceptions.ErrorMessage;
import com.labsynch.labseer.exceptions.NotFoundException;
import com.labsynch.labseer.exceptions.TooManyResultsException;
import com.labsynch.labseer.exceptions.UniqueNameException;
import com.labsynch.labseer.service.AnalysisGroupService;
import com.labsynch.labseer.service.AnalysisGroupValueService;
Expand Down Expand Up @@ -1634,20 +1635,19 @@ public ResponseEntity<java.lang.String> jsonFindExperimentByNameGet(@RequestPara
@RequestMapping(value = "/protocol/{codeName}", method = RequestMethod.GET, headers = "Accept=application/json")
@ResponseBody
public ResponseEntity<java.lang.String> jsonFindExperimentsByProtocolCodeName(
@PathVariable("codeName") String codeName, @RequestParam(value = "with", required = false) String with) {
@PathVariable("codeName") String codeName, @RequestParam(value = "projects", required = false) List<String> projects, @RequestParam(value = "with", required = false) String with) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
List<Protocol> protocols = Protocol.findProtocolsByCodeNameEqualsAndIgnoredNot(codeName, true).getResultList();
if (protocols.size() == 1) {
try {
Collection<Experiment> experiments = experimentService.findExperimentsByProtocolCodeName(codeName, projects);
return new ResponseEntity<String>(
Experiment.toJsonArrayStub(Experiment.findExperimentsByProtocol(protocols.get(0)).getResultList()),
Experiment.toJsonArrayStub(experiments),
headers, HttpStatus.OK);
} else if (protocols.size() > 1) {
logger.error("ERROR: multiple protocols found with the same code name");
return new ResponseEntity<String>("[ ]", headers, HttpStatus.CONFLICT);
} else {
logger.warn("WARN: no protocols found with the query code name");
} catch (NoResultException e) {
return new ResponseEntity<String>("[ ]", headers, HttpStatus.NOT_FOUND);

} catch (TooManyResultsException e) {
return new ResponseEntity<String>("[ ]", headers, HttpStatus.CONFLICT);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public Collection<JSTreeNodeDTO> getExperimentNodesByProtocolTree(
public Collection<Experiment> findExperimentsByMetadataJson(
List<StringCollectionDTO> metaDataList);


public Collection<Experiment> findExperimentsByProtocolCodeName(String query, List<String> projects)
throws TooManyResultsException;

public Collection<Experiment> findExperimentsByGenericMetaDataSearch(String query, String userName, Boolean includeDeleted)
throws TooManyResultsException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,45 @@ public Collection<Experiment> findExperimentsByGenericMetaDataSearch(String quer

}

public Collection<Experiment> findExperimentsByProtocolCodeName(String codeName, List<String> projects)
throws TooManyResultsException, NoResultException {
List<Protocol> protocols = Protocol.findProtocolsByCodeNameEqualsAndIgnoredNot(codeName, true).getResultList();

if (protocols.size() > 1) {
logger.error("ERROR: multiple protocols found with the same code name");
throw new TooManyResultsException("ERROR: multiple protocols found with the same code name");
} else if (protocols.size() < 1) {
logger.warn("WARN: no protocols found with the query code name");
throw new NoResultException("WARN: no protocols found with the query code name");
}

Collection<Experiment> rawResults = Experiment.findExperimentsByProtocol(protocols.get(0)).getResultList();
if (propertiesUtilService.getRestrictExperiments()) {
projects.add("unassigned");
Collection<Experiment> results = new HashSet<Experiment>();
for (Experiment rawResult : rawResults) {
String experimentProject = null;
for (ExperimentState state : rawResult.getLsStates()) {
if (!state.isIgnored() && !state.isDeleted()) {
for (ExperimentValue value : state.getLsValues()) {
if (value.getLsKind().equals("project") && !value.getDeleted() && !value.getIgnored()) {
experimentProject = value.getCodeValue();
break;
}
}
}
}
if (projects.contains(experimentProject)) {
results.add(rawResult);
}
}
return results;
} else {
return rawResults;
}

}

@Override
public Collection<Experiment> findExperimentsByGenericMetaDataSearch(String queryString, List<String> projects, Boolean includeDeleted)
throws TooManyResultsException {
Expand Down
Loading