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 number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public StudyController(BrAPIStudyService studyService, StudyQueryMapper studyQue
@Get("/programs/{programId}" + BrapiVersion.BRAPI_V2 + "/studies{?queryParams*}")
@Produces(MediaType.APPLICATION_JSON)
@ProgramSecured(roleGroups = {ProgramSecuredRoleGroup.ALL})
public HttpResponse<Response<DataResponse<List<BrAPIStudy>>>> getStudy(
public HttpResponse<Response<DataResponse<List<BrAPIStudy>>>> getStudies(
@PathVariable("programId") UUID programId,
@QueryValue @QueryValid(using = StudyQueryMapper.class) @Valid StudyQuery queryParams) {
try {
Expand Down
32 changes: 0 additions & 32 deletions src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIStudyDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,36 +163,4 @@ private Map<String,BrAPIStudy> processStudyForDisplay(List<BrAPIStudy> programSt
return programStudyMap;
}

public BrAPIStudy getStudyByUUID(String studyId, UUID programId) throws ApiException, DoesNotExistException {
Map<String, BrAPIStudy> cache = programStudyCache.get(programId);
BrAPIStudy study = null;
if (cache != null) {
study = cache.get(studyId);
}
if (study == null) {
throw new DoesNotExistException("UUID for this study does not exist");
}
return study;
}

public Optional<BrAPIStudy> getStudyByDBID(String studyDbId, UUID programId) throws ApiException {
Map<String, BrAPIStudy> cache = programStudyCache.get(programId);
//key is UUID, want to filter by DBID
BrAPIStudy study = null;
if (cache != null) {
study = cache.values().stream().filter(x -> x.getStudyDbId().equals(studyDbId)).collect(Collectors.toList()).get(0);
}
return Optional.ofNullable(study);
}

public List<BrAPIStudy> getStudiesByDBID(Collection<String> studyDbIds, UUID programId) throws ApiException {
Map<String, BrAPIStudy> cache = programStudyCache.get(programId);
//key is UUID, want to filter by DBID
List<BrAPIStudy> studies = new ArrayList<>();
if (cache != null) {
studies = cache.values().stream().filter(x -> studyDbIds.contains(x.getStudyDbId())).collect(Collectors.toList());
}
return studies;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.brapi.client.v2.model.exceptions.ApiException;
import org.brapi.v2.model.core.BrAPIStudy;
import org.breedinginsight.brapi.v2.dao.BrAPIStudyDAO;
import org.breedinginsight.services.exceptions.DoesNotExistException;

import javax.inject.Inject;
import javax.inject.Singleton;
Expand All @@ -48,12 +47,4 @@ public List<BrAPIStudy> getStudies(UUID programId) throws ApiException {
}
}

public BrAPIStudy getStudyByUUID(UUID programId, String studyId) throws DoesNotExistException {
try {
return studyDAO.getStudyByUUID(studyId, programId);
} catch (ApiException e) {
throw new InternalServerException(e.getMessage(), e);
}
}

}