Skip to content

Commit

Permalink
dc.date.issued is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmajchrak committed Aug 10, 2023
1 parent 3ba8a27 commit d5de6c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.dspace.app.rest.model.ItemRest;
import org.dspace.app.rest.model.MetadataValueList;
import org.dspace.app.rest.projection.Projection;
import org.dspace.app.rest.utils.ContextUtil;
import org.dspace.content.Item;
import org.dspace.content.MetadataField;
import org.dspace.content.MetadataValue;
Expand Down Expand Up @@ -54,6 +55,14 @@ public ItemRest convert(Item obj, Projection projection) {
List<MetadataValue> issuedDates =
itemService.getMetadata(obj, "dc", "date", "issued", Item.ANY, false);
issuedDates.forEach(metadataValue -> metadataValue.setValue(approximatedDates.get(0).getValue()));

// Remove the date from the `dc.date.issued` because it was added into `local.approximateDate.issued`.
Context context = ContextUtil.obtainContext(requestService.getCurrentRequest().getHttpServletRequest());
try {
itemService.clearMetadata(context, obj, "dc", "date", "issued", Item.ANY);
} catch (SQLException e) {
log.error("Cannot remove `dc.date.issued` metadata because: " + e.getMessage());
}
}

ItemRest item = super.convert(obj, projection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public static Matcher<? super Object> matchItemWithTitleAndApproximateDateIssued
hasJsonPath("$.metadata", allOf(
matchMetadata("dc.title", title),
matchMetadata("local.approximateDate.issued", approximateDateIssued),
matchMetadata("dc.date.issued", approximateDateIssued))),
// It should be deleted from the `dc.date.issued`
matchMetadataDoesNotExist("dc.date.issued"))),

//Check links
matchLinks(item.getID())
Expand Down

0 comments on commit d5de6c4

Please sign in to comment.