mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
When moving metadata, make sure virtual metadata is handled correctly
This commit is contained in:
@@ -677,11 +677,11 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
MetadataValue newMetadata = addMetadata(context, dso, schema, element, qualifier,
|
||||
lang, value, authority, confidence);
|
||||
|
||||
moveSingleMetadataValue(context, dso, schema, element, qualifier, place, newMetadata);
|
||||
moveSingleMetadataValue(context, dso, place, newMetadata);
|
||||
place++;
|
||||
last = false;
|
||||
}
|
||||
moveSingleMetadataValue(context, dso, schema, element, qualifier, place, rr);
|
||||
moveSingleMetadataValue(context, dso, place, rr);
|
||||
place++;
|
||||
idx++;
|
||||
}
|
||||
@@ -721,31 +721,30 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
boolean last = true;
|
||||
for (MetadataValue rr : list) {
|
||||
if (idx == to && to < from) {
|
||||
moveSingleMetadataValue(context, dso, schema, element, qualifier, place, moved);
|
||||
moveSingleMetadataValue(context, dso, place, moved);
|
||||
place++;
|
||||
last = false;
|
||||
}
|
||||
if (idx != from) {
|
||||
moveSingleMetadataValue(context, dso, schema, element, qualifier, place, rr);
|
||||
moveSingleMetadataValue(context, dso, place, rr);
|
||||
place++;
|
||||
}
|
||||
if (idx == to && to > from) {
|
||||
moveSingleMetadataValue(context, dso, schema, element, qualifier, place, moved);
|
||||
moveSingleMetadataValue(context, dso, place, moved);
|
||||
place++;
|
||||
last = false;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
if (last) {
|
||||
moveSingleMetadataValue(context, dso, schema, element, qualifier, place, moved);
|
||||
moveSingleMetadataValue(context, dso, place, moved);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports moving metadata by updating the place of the metadata value
|
||||
*/
|
||||
protected void moveSingleMetadataValue(Context context, T dso, String schema, String element,
|
||||
String qualifier, int place, MetadataValue rr) throws SQLException {
|
||||
protected void moveSingleMetadataValue(Context context, T dso, int place, MetadataValue rr) {
|
||||
//just move the metadata
|
||||
rr.setPlace(place);
|
||||
}
|
||||
|
@@ -1376,8 +1376,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
* Supports moving metadata by adding the metadata value or updating the place of the relationship
|
||||
*/
|
||||
@Override
|
||||
protected void moveSingleMetadataValue(Context context, Item dso, String schema, String element,
|
||||
String qualifier, int place, MetadataValue rr) throws SQLException {
|
||||
protected void moveSingleMetadataValue(Context context, Item dso, int place, MetadataValue rr) {
|
||||
if (rr instanceof RelationshipMetadataValue) {
|
||||
try {
|
||||
//Retrieve the applicable relationship
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.model.MetadataValueRest;
|
||||
@@ -40,18 +41,7 @@ public abstract class MetadataValueRemovePatchOperation<DSO extends DSpaceObject
|
||||
String[] metadata = Utils.tokenize(target);
|
||||
List<MetadataValue> mm = getDSpaceObjectService().getMetadata(source, metadata[0], metadata[1], metadata[2],
|
||||
Item.ANY);
|
||||
getDSpaceObjectService().clearMetadata(context, source, metadata[0], metadata[1], metadata[2], Item.ANY);
|
||||
if (index != -1) {
|
||||
int idx = 0;
|
||||
for (MetadataValue m : mm) {
|
||||
if (idx != index) {
|
||||
getDSpaceObjectService().addMetadata(context, source, metadata[0], metadata[1], metadata[2],
|
||||
m.getLanguage(), m.getValue(), m.getAuthority(),
|
||||
m.getConfidence());
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
getDSpaceObjectService().removeMetadataValues(context, source, Arrays.asList(mm.get(index)));
|
||||
}
|
||||
|
||||
protected abstract DSpaceObjectService<DSO> getDSpaceObjectService();
|
||||
|
Reference in New Issue
Block a user