Skip to content

Commit

Permalink
Merge pull request #273 from europeana/EA-3954_new_profiles_definitions
Browse files Browse the repository at this point in the history
Ea 3954 new profiles definitions
  • Loading branch information
gsergiu authored Nov 15, 2024
2 parents f36be22 + 9ac2a1a commit b45bdbf
Show file tree
Hide file tree
Showing 7 changed files with 496 additions and 358 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package eu.europeana.set.web.model.search;

import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRawValue;
import eu.europeana.set.definitions.model.vocabulary.WebUserSetFields;

public class ItemDescriptionsResultPage extends BaseUserSetResultPage<String> {
List<String> itemList;

@JsonProperty(WebUserSetFields.ITEMS)
@JsonRawValue
public List<String> getItemList() {
return itemList;
}

public void setItemList(List<String> itemList) {
this.itemList = itemList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

public class ItemIdsResultPage extends BaseUserSetResultPage<String> {


}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import eu.europeana.set.web.model.WebResource;
import eu.europeana.set.web.model.search.BaseUserSetResultPage;
import eu.europeana.set.web.model.search.CollectionPage;
import eu.europeana.set.web.model.search.ItemIdsResultPage;
import eu.europeana.set.web.service.controller.exception.SetUniquenessValidationException;

public interface UserSetService {
Expand Down Expand Up @@ -160,8 +159,8 @@ BaseUserSetResultPage<?> buildResultsPage(UserSetQuery searchQuery,
ResultSet<? extends UserSet> results, String requestUrl, String reqParams,
List<SetPageProfile> profiles, Authentication authentication) throws HttpException;

ItemIdsResultPage buildItemIdsResultsPage(String setId, List<String> itemIds, int page,
int pageSize, HttpServletRequest request);
BaseUserSetResultPage<String> buildRecodsResultsPage(String setId, List<String> itemIds, int page,
int pageSize, SetPageProfile profile, HttpServletRequest request) throws HttpException;

CollectionPage buildCollectionPage(UserSet userSet, UserSetProfile profile, int pageNr,
int pageSize, HttpServletRequest request) throws HttpException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -32,7 +33,6 @@
import eu.europeana.set.web.http.SwaggerConstants;
import eu.europeana.set.web.http.UserSetHttpHeaders;
import eu.europeana.set.web.model.search.BaseUserSetResultPage;
import eu.europeana.set.web.model.search.ItemIdsResultPage;
import eu.europeana.set.web.search.UserSetLdSerializer;
import eu.europeana.set.web.search.UserSetQueryBuilder;
import eu.europeana.set.web.service.controller.BaseRest;
Expand Down Expand Up @@ -144,7 +144,7 @@ public ResponseEntity<String> searchItemsInSet(
@RequestParam(value = CommonApiConstants.QUERY_PARAM_PAGE_SIZE, required = false,
defaultValue = "" + UserSetConfigurationImpl.DEFAULT_ITEMS_PER_PAGE) int pageSize,
@RequestParam(value = CommonApiConstants.QUERY_PARAM_PROFILE, required = false,
defaultValue = ProfileConstants.VALUE_PARAM_META) String profileStr,
defaultValue = ProfileConstants.VALUE_PARAM_ITEMS) String profileStr,
HttpServletRequest request) throws HttpException {

try {
Expand All @@ -161,13 +161,12 @@ public ResponseEntity<String> searchItemsInSet(
List<SetPageProfile> profiles = getProfilesFromRequest(profileStr, request);
validateMultipleProfiles(profiles, profileStr);

//TODO: fix
// // get profile for pagination urls and item Page
// SetPageProfile profile = getUserSetService().getProfileForPagination(profiles);
// if(profile == null) {
// //if only technical profiles included in request, append the default profile
// profiles.add(SetPageProfile.ITEMS_META);
// }
// get profile for pagination urls and item Page
SetPageProfile profile = getUserSetService().getProfileForPagination(profiles);
if(profile == null) {
//if only technical profiles included in request, append the default profile
profiles.add(SetPageProfile.ITEMS);
}

// parses and validates qf
List<String> itemIds = buildItemIdsList(qf);
Expand All @@ -187,16 +186,16 @@ public ResponseEntity<String> searchItemsInSet(
}

List<String> filtered;
if (itemIds == null) {
filtered = existingUserSet.getItems();
} else {
if (itemIds != null && !itemIds.isEmpty()) {
filtered = new ArrayList<String>(existingUserSet.getItems());
filtered.retainAll(itemIds);
filtered.retainAll(itemIds);
} else {
filtered = Collections.emptyList();
}

ItemIdsResultPage resultPage = getUserSetService().buildItemIdsResultsPage(identifier,
filtered, page, pageSize, request);

BaseUserSetResultPage<String> resultPage = getUserSetService().buildRecodsResultsPage(identifier,
filtered, page, pageSize, profile, request);
UserSetLdSerializer serializer = new UserSetLdSerializer();
String jsonLd = serializer.serialize(resultPage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,12 @@ private boolean isUri(String value) {

@Override
public SetPageProfile getProfileForPagination(List<SetPageProfile> profiles) {
SetPageProfile profile = null;
for (SetPageProfile ldProfile : profiles) {
if (SetPageProfile.FACETS != profile) {
profile = ldProfile;
for (SetPageProfile profile : profiles) {
if (!SetPageProfile.FACETS.equals(profile)) {
return profile;
}
}
return profile;
return null;
}

private void validateAndSetItems(UserSet storedUserSet, UserSet userSetUpdates)
Expand Down
Loading

0 comments on commit b45bdbf

Please sign in to comment.