Commit ec792cf9 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch 'ui-402-counters-of-subset-isn-t-same' into 'master'

Fixed wrong suggestions caused by versions of subsets/datasets

Closes genesys-ui#408 and genesys-ui#402

See merge request genesys-pgr/genesys-server!425
parents f03322a6 bda1a6f2
......@@ -70,6 +70,9 @@ public class DatasetFilter extends UuidModelFilter<DatasetFilter, Dataset> imple
public Set<String> rights;
/** Is current version */
public Boolean current;
/**
* Builds the query.
*
......@@ -103,7 +106,6 @@ public class DatasetFilter extends UuidModelFilter<DatasetFilter, Dataset> imple
if (crops != null && !crops.isEmpty()) {
and.and(dataset.crops.any().in(crops));
}
if (locations != null) {
and.and(locations.buildQuery(dataset.locations.any()));
}
......@@ -111,7 +113,9 @@ public class DatasetFilter extends UuidModelFilter<DatasetFilter, Dataset> imple
if (CollectionUtils.isNotEmpty(rights)) {
and.and(dataset.rights.in(rights));
}
if (current != null) {
and.and(dataset.current.eq(current));
}
// if (StringUtils.isNotBlank(_text)) {
// /*@formatter:off*/
// and.andAnyOf(
......
......@@ -558,7 +558,7 @@ public class DatasetServiceImpl implements DatasetService {
} catch (NoSuchFieldException | IllegalAccessException e) {
LOG.error("Error while clearing filter: ", e.getMessage());
}
suggestionFilter.current = true;
ElasticsearchService.TermResult suggestion = elasticsearchService.termStatisticsAuto(Dataset.class, suggestionFilter, 100, suggestionKey);
suggestionRes.put(suggestionKey, suggestion);
}
......
......@@ -311,9 +311,10 @@ public class DatasetController extends ApiBaseController {
DatasetFilter overviewFilter = filter.copy(DatasetFilter.class);
overviewFilter.state = Sets.newHashSet(PublishState.PUBLISHED);
overviewFilter.current = true;
Map<String, TermResult> overview = elasticsearchService.termStatisticsAuto(Dataset.class, overviewFilter, 10, terms.toArray(new String[] {}));
long datasetCount = datasetService.countDatasets(filter);
long datasetCount = datasetService.countDatasets(overviewFilter);
Map<String, ElasticsearchService.TermResult> suggestionRes = datasetService.getSuggestions(filter);
return DatasetOverview.from(filterCode, filter, overview, datasetCount, suggestionRes);
......
......@@ -268,7 +268,7 @@ public class DescriptorListController {
overviewFilter.state = Sets.newHashSet(PublishState.PUBLISHED);
Map<String, TermResult> overview = elasticsearchService.termStatisticsAuto(DescriptorList.class, overviewFilter, 10, terms.toArray(new String[] {}));
long descriptorListCount = descriptorListService.countDescriptorLists(filter);
long descriptorListCount = descriptorListService.countDescriptorLists(overviewFilter);
Map<String, ElasticsearchService.TermResult> suggestionRes = descriptorListService.getSuggestions(filter);
return DescriptorListOverview.from(filterCode, filter, overview, descriptorListCount, suggestionRes);
......
......@@ -63,6 +63,9 @@ public class SubsetFilter extends UuidModelFilter<SubsetFilter, Subset> implemen
public Set<String> crops;
/** Is current version */
public Boolean current;
/**
* Builds the query.
*
......@@ -96,6 +99,9 @@ public class SubsetFilter extends UuidModelFilter<SubsetFilter, Subset> implemen
if (crops != null && !crops.isEmpty()) {
and.and(subset.crops.any().in(crops));
}
if (current != null) {
and.and(subset.current.eq(current));
}
return and;
}
......
......@@ -355,6 +355,7 @@ public class SubsetServiceImpl implements SubsetService {
} catch (NoSuchFieldException | IllegalAccessException e) {
LOG.error("Error while clearing filter: ", e.getMessage());
}
suggestionFilter.current = true;
ElasticsearchService.TermResult suggestion = elasticsearchService.termStatisticsAuto(Subset.class, suggestionFilter, 100, suggestionKey);
suggestionRes.put(suggestionKey, suggestion);
......@@ -776,7 +777,7 @@ public class SubsetServiceImpl implements SubsetService {
*
* @param target the target
* @param accessionRefs the subset accessionRefs
* @return
* @return
*/
private Subset copyAccessionRefs(final Subset target, final List<SubsetAccessionRef> accessionRefs) {
if (accessionRefs == null || accessionRefs.size() == 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment