Issue : Handle gene table requests when no gene files are present for a reference
@@ -409,20 +409,33 @@ public class FeatureIndexManager {
public IndexSearchResult<GeneIndexEntry> searchGenesByReference(final GeneFilterForm filterForm,
final long referenceId) throws IOException {
- return getGeneSearchResult(filterForm, getGeneFilesForReference(referenceId, filterForm.getFileIds()));
+ final List<? extends FeatureFile> files = getGeneFilesForReference(referenceId, filterForm.getFileIds());
+ if (CollectionUtils.isEmpty(files)) {
+ return new IndexSearchResult<>();
+ }
+ return getGeneSearchResult(filterForm, files);
}
public GeneFilterInfo getAvailableGeneFieldsToSearch(final Long referenceId, ItemsByProject fileIdsByProjectId) {
- return featureIndexDao.getAvailableFieldsToSearch(
+ final List<? extends FeatureFile> files =
getGeneFilesForReference(referenceId, Optional.ofNullable(fileIdsByProjectId)
- .map(ItemsByProject::getFileIds).orElse(Collections.emptyList())));
+ .map(ItemsByProject::getFileIds).orElse(Collections.emptyList()));
+ if (CollectionUtils.isEmpty(files)) {
+ return GeneFilterInfo.builder().build();
+ }
+ return featureIndexDao.getAvailableFieldsToSearch(
+ files);
}
public Set<String> getAvailableFieldValues(final Long referenceId, final ItemsByProject fileIdsByProjectId,
final String fieldName) {
+ final List<Long> fileIds = Optional.ofNullable(fileIdsByProjectId)
+ .map(ItemsByProject::getFileIds).orElse(Collections.emptyList());
+ if (CollectionUtils.isEmpty(fileIds)) {
+ return Collections.emptySet();
+ }
return featureIndexDao.getAvailableFieldValues(
- getGeneFilesForReference(referenceId, Optional.ofNullable(fileIdsByProjectId)
- .map(ItemsByProject::getFileIds).orElse(Collections.emptyList())), fieldName);
+ getGeneFilesForReference(referenceId, fileIds), fieldName);
}
private List<? extends FeatureFile> getGeneFilesForReference(final long referenceId, final List<Long> fileIds) {
