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

Clover viewer #1815

Merged
merged 18 commits into from
Oct 16, 2024
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
@@ -0,0 +1,34 @@
package edu.unc.lib.boxc.search.solr.filters;

import edu.unc.lib.boxc.search.api.SearchFieldKey;
import edu.unc.lib.boxc.search.api.filters.QueryFilter;

import java.util.List;
import java.util.stream.Collectors;

/**
* Filter which restricts results to entries which contain populated values for the given key with
* the specified field search value
*
* @author lfarrell
*/
public class HasValuesFilter implements QueryFilter {
private final SearchFieldKey fieldKey;
private final List<String> fieldValues;

protected HasValuesFilter(SearchFieldKey fieldKey, List<String> fieldValues) {
this.fieldKey = fieldKey;
this.fieldValues = fieldValues;
}

@Override
public String toFilterString() {
return fieldValues.stream().map(v -> getFieldKey().getSolrField() + ":" + v)
.collect(Collectors.joining(" OR "));
}

@Override
public SearchFieldKey getFieldKey() {
return fieldKey;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,14 @@ public static QueryFilter createFilter(SearchFieldKey fieldKey) {
public static QueryFilter createIIIFv3ViewableFilter(List<String> fileTypes) {
return new IIIFv3ViewableFilter(fileTypes);
}

/**
*
* @param fieldKey searchField
* @param fieldValues list of values to search for
* @return new QueryFilter instance with the provided file type
*/
public static QueryFilter createHasValuesFilter(SearchFieldKey fieldKey, List<String> fieldValues) {
return new HasValuesFilter(fieldKey, fieldValues);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.Test;

import java.util.HashSet;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertInstanceOf;

Expand Down Expand Up @@ -33,4 +34,10 @@ public void HasPopulatedFieldFilterTest() {
var filter = QueryFilterFactory.createFilter(SearchFieldKey.STREAMING_TYPE);
assertInstanceOf(HasPopulatedFieldFilter.class, filter);
}

@Test
public void HasValuesFilterTest() {
var filter = QueryFilterFactory.createHasValuesFilter(SearchFieldKey.FILE_FORMAT_TYPE, List.of("application/pdf"));
assertInstanceOf(HasValuesFilter.class, filter);
}
}
11 changes: 11 additions & 0 deletions static/css/sass/cdr_ui_styles.scss

Large diffs are not rendered by default.

Loading
Loading