Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sondrev committed Oct 11, 2024
1 parent a2cdf0e commit 0545172
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ public final ParameterValidator<K, Q> withDockerHostUri(URI uri) {
return this;
}

public final ParameterValidator<K, Q> withAlwaysExcludedFields(List<String> excludedFields) {
searchQuery.setAlwaysExcludedFields(excludedFields);
return this;
}

public final ParameterValidator<K, Q> withAlwaysExcludedFields(String... excludedFields) {
searchQuery.setAlwaysExcludedFields(List.of(excludedFields));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public final class Constants {
public static final String UNIQUE_PUBLICATIONS = "unique_publications";
public static final String CRISTIN_ORGANIZATION_PATH = "/cristin/organization/";
public static final String CRISTIN_PERSON_PATH = "/cristin/person/";
public static final String EXCLUDED_FIELDS = "joinField";
public static final List<String> GLOBAL_EXCLUDED_FIELDS = List.of("joinField");
public static final String IDENTIFIER_KEYWORD = IDENTIFIER + DOT + KEYWORD;
public static final String FILES_STATUS_KEYWORD = FILES_STATUS + DOT + KEYWORD;
public static final String ENTITY_CONTRIBUTORS_DOT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import static no.unit.nva.search.common.constant.Patterns.COLON_OR_SPACE;
import static no.unit.nva.search.resource.Constants.CRISTIN_ORGANIZATION_PATH;
import static no.unit.nva.search.resource.Constants.CRISTIN_PERSON_PATH;
import static no.unit.nva.search.resource.Constants.EXCLUDED_FIELDS;
import static no.unit.nva.search.resource.Constants.GLOBAL_EXCLUDED_FIELDS;
import static no.unit.nva.search.resource.Constants.IDENTIFIER_KEYWORD;
import static no.unit.nva.search.resource.Constants.RESOURCES_AGGREGATIONS;
import static no.unit.nva.search.resource.Constants.STATUS_KEYWORD;
Expand Down Expand Up @@ -89,7 +89,7 @@ public final class ResourceSearchQuery extends SearchQuery<ResourceParameter> {
private ResourceSearchQuery() {
super();
assignStatusImpossibleWhiteList();
setAlwaysExcludedFields(List.of(EXCLUDED_FIELDS));
setAlwaysExcludedFields(GLOBAL_EXCLUDED_FIELDS);
streamBuilders = new ResourceStreamBuilders(parameters());
filterBuilder = new ResourceAccessFilter(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import static no.unit.nva.search.common.enums.PublicationStatus.PUBLISHED;
import static no.unit.nva.search.common.enums.PublicationStatus.PUBLISHED_METADATA;
import static no.unit.nva.search.common.enums.PublicationStatus.UNPUBLISHED;
import static no.unit.nva.search.resource.Constants.EXCLUDED_FIELDS;
import static no.unit.nva.search.resource.Constants.GLOBAL_EXCLUDED_FIELDS;
import static no.unit.nva.search.resource.ResourceParameter.AGGREGATION;
import static no.unit.nva.search.resource.ResourceParameter.EXCLUDE_SUBUNITS;
import static no.unit.nva.search.resource.ResourceParameter.FROM;
Expand Down Expand Up @@ -870,7 +870,7 @@ void searchWithUriReturnsCsvResponse(URI uri) throws ApiGatewayException {
ResourceSearchQuery.builder()
.fromTestQueryParameters(queryToMapEntries(uri))
.withRequiredParameters(FROM, SIZE, AGGREGATION)
.withAlwaysExcludedFields(EXCLUDED_FIELDS)
.withAlwaysExcludedFields(GLOBAL_EXCLUDED_FIELDS)
.withDockerHostUri(URI.create(container.getHttpHostAddress()))
.withMediaType(Words.TEXT_CSV)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import static no.unit.nva.search.common.enums.PublicationStatus.PUBLISHED;
import static no.unit.nva.search.common.enums.PublicationStatus.PUBLISHED_METADATA;
import static no.unit.nva.search.common.enums.PublicationStatus.UNPUBLISHED;
import static no.unit.nva.search.resource.Constants.EXCLUDED_FIELDS;
import static no.unit.nva.search.resource.Constants.GLOBAL_EXCLUDED_FIELDS;
import static no.unit.nva.search.resource.ResourceClient.defaultClient;
import static no.unit.nva.search.resource.ResourceParameter.AGGREGATION;
import static no.unit.nva.search.resource.ResourceParameter.FROM;
Expand Down Expand Up @@ -66,7 +66,7 @@ protected String processInput(Void input, RequestInfo requestInfo, Context conte
return ResourceSearchQuery.builder()
.fromRequestInfo(requestInfo)
.withRequiredParameters(FROM, SIZE, AGGREGATION)
.withAlwaysExcludedFields(EXCLUDED_FIELDS)
.withAlwaysExcludedFields(GLOBAL_EXCLUDED_FIELDS)
.validate()
.build()
.withFilter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static no.unit.nva.constants.Defaults.DEFAULT_RESPONSE_MEDIA_TYPES;
import static no.unit.nva.search.common.enums.PublicationStatus.PUBLISHED;
import static no.unit.nva.search.common.enums.PublicationStatus.PUBLISHED_METADATA;
import static no.unit.nva.search.resource.Constants.EXCLUDED_FIELDS;
import static no.unit.nva.search.resource.Constants.GLOBAL_EXCLUDED_FIELDS;
import static no.unit.nva.search.resource.ResourceClient.defaultClient;
import static no.unit.nva.search.resource.ResourceParameter.AGGREGATION;
import static no.unit.nva.search.resource.ResourceParameter.FROM;
Expand All @@ -22,7 +22,9 @@
import nva.commons.core.JacocoGenerated;

import java.net.HttpURLConnection;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;

/**
* Handler for searching resources.
Expand Down Expand Up @@ -60,7 +62,7 @@ protected String processInput(Void input, RequestInfo requestInfo, Context conte
return ResourceSearchQuery.builder()
.fromRequestInfo(requestInfo)
.withRequiredParameters(FROM, SIZE, AGGREGATION)
.withAlwaysExcludedFields(EXCLUDED_FIELDS, ENTITY_DESCRIPTION_CONTRIBUTORS)
.withAlwaysExcludedFields(getExcludedFields())
.validate()
.build()
.withFilter()
Expand All @@ -70,6 +72,12 @@ protected String processInput(Void input, RequestInfo requestInfo, Context conte
.toString();
}

private List<String> getExcludedFields() {
return Stream.of(GLOBAL_EXCLUDED_FIELDS, List.of(ENTITY_DESCRIPTION_CONTRIBUTORS))
.flatMap(Collection::stream)
.toList();
}

@Override
protected Integer getSuccessStatusCode(Void input, String output) {
return HttpURLConnection.HTTP_OK;
Expand Down

0 comments on commit 0545172

Please sign in to comment.