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

publication date (issued) added #233

Merged
merged 8 commits into from
Mar 20, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.Date;
import java.util.List;
import java.util.Map;

import eu.europeana.set.definitions.model.agent.Agent;
import eu.europeana.set.definitions.model.impl.Provider;

Expand Down Expand Up @@ -49,6 +48,10 @@ public interface UserSet extends PageInfo {

void setModified(Date modified);

Date getIssued();

void setIssued(Date issued);

List<String> getItems();

void setItems(List<String> items);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.Date;
import java.util.List;
import java.util.Map;

import eu.europeana.set.definitions.model.UserSet;
import eu.europeana.set.definitions.model.agent.Agent;
import eu.europeana.set.definitions.model.vocabulary.UserSetTypes;
Expand Down Expand Up @@ -79,6 +78,12 @@ public abstract class BaseUserSet extends BasePageInfo implements UserSet {
* literal expressed as xsd:dateTime with the UTC timezone expressed as "Z".
*/
private Date modified;

/**
* The time at which the Set was published, after creation. The value must be a
* literal expressed as xsd:dateTime with the UTC timezone expressed as "Z".
*/
private Date issued;

/**
* Ordered Collections from Activity Streams For EDM Collection class
Expand Down Expand Up @@ -198,6 +203,16 @@ public void setModified(Date modified) {
this.modified = modified;
}

@Override
public Date getIssued() {
return issued;
}

@Override
public void setIssued(Date issued) {
this.issued = issued;
}

@Override
public List<String> getItems() {
return items;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class WebUserSetFields extends WebUserSetModelFields {
public static final String PATH_PARAM_CREATOR_ID = "creator";
public static final String PATH_PARAM_LOCAL_ID = "localId";
public static final String PATH_PARAM_POSITION = "position";
public static final String REQUEST_PARAM_ISSUED = "issued";

/**
* sort order should be included in the sort param
Expand Down Expand Up @@ -67,8 +68,6 @@ public class WebUserSetFields extends WebUserSetModelFields {

// Serialization Constants
public static final String SEPARATOR_SEMICOLON = ":";
public static final String SET_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
// public static final String DEFAULT_USER_BASE_URL = "http://data.europeana.eu/user/";

// Entity user set and Elevation Constants
public static final String ELEVATION_FILENAME = "elevate.xml";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class WebUserSetModelFields {
public static final String CONTRIBUTOR = "contributor";
public static final String CREATED = "created";
public static final String MODIFIED = "modified";
public static final String ISSUED = "issued";
public static final String IS_DEFINED_BY = "isDefinedBy";
public static final String SUBJECT = "subject";
public static final String ITEMS = "items";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -316,4 +317,17 @@ protected void addToCreatedSets(String identifier) {
userSet.setIdentifier(identifier);
createdUserSets.add(userSet);
}

protected String getStringValue(String jsonBody, String fieldName) throws JSONException {
JSONObject json = new JSONObject(jsonBody);
return json.getString(fieldName);
}

protected List<String> getStringListValues(String jsonBody, String fieldName) throws JSONException {
assertNotNull(jsonBody);
JSONObject json = new JSONObject(jsonBody);
return Collections.singletonList(json.getString(fieldName));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -105,10 +101,10 @@ void createSetSuccessfully() throws Exception {
createdUserSets.add(createdSet);

assertNotNull(identifier);
String creator = getCreator(result);
String creator = getStringValue(result, WebUserSetModelFields.CREATOR);
assertNotNull(creator);
assertTrue(StringUtils.contains(creator, getConfiguration().getEntityUserSetUserId()));
String provider = getProvider(result);
String provider = getStringValue(result, WebUserSetModelFields.PROVIDER);
assertNotNull(provider);
// check name
assertTrue(containsKeyOrValue(provider, "Europeana XX"));
Expand All @@ -117,7 +113,7 @@ void createSetSuccessfully() throws Exception {
containsKeyOrValue(provider, "https:\\/\\/pro.europeana.eu\\/project\\/europeana-xx"));
// check subject
assertEquals("http://data.europeana.eu/concept/114", createdSet.getSubject().get(0));
assertNotNull(getSetContributors(result));
assertNotNull(getStringListValues(result, WebUserSetModelFields.CONTRIBUTOR));
}


Expand All @@ -140,18 +136,18 @@ void createSetWithProviderId() throws Exception {
createdUserSets.add(createdSet);

assertNotNull(identifier);
String creator = getCreator(result);
String creator = getStringValue(result, WebUserSetModelFields.CREATOR);
assertNotNull(creator);
assertTrue(StringUtils.contains(creator, getConfiguration().getEntityUserSetUserId()));
String provider = getProvider(result);
String provider = getStringValue(result, WebUserSetModelFields.PROVIDER);
assertNotNull(provider);
// check name - must not be present
assertFalse(containsKeyOrValue(provider, "Europeana XX"));
// check id
assertTrue(
containsKeyOrValue(provider, "https:\\/\\/pro.europeana.eu\\/project\\/europeana-xx"));

assertNotNull(getSetContributors(result));
assertNotNull(getStringListValues(result, WebUserSetModelFields.CONTRIBUTOR));
}

@Test
Expand Down Expand Up @@ -684,26 +680,6 @@ void deletePinnedItems_EntityUserSets_withEditorUser() throws Exception {

}

private String getCreator(String result) throws JSONException {
assertNotNull(result);
JSONObject json = new JSONObject(result);
String creator = json.getString(WebUserSetModelFields.CREATOR);
return creator;
}

private String getProvider(String result) throws JSONException {
assertNotNull(result);
JSONObject json = new JSONObject(result);
String provider = json.getString(WebUserSetModelFields.PROVIDER);
return provider;
}

private List<String> getSetContributors(String result) throws JSONException {
assertNotNull(result);
JSONObject json = new JSONObject(result);
return Collections.singletonList(json.getString(WebUserSetModelFields.CONTRIBUTOR));
}

private void checkItemCountAndPosition(UserSet existingUserSet, String newItem,
int expectedTotalItems, int expectedPinnedItems, int expectedPositionOfItem) {
assertEquals(expectedPinnedItems, existingUserSet.getPinned());
Expand Down
Loading