When moving metadata, make sure virtual metadata is handled correctly

This commit is contained in:
Ben Bosman
2020-02-18 13:29:31 +01:00
parent b8bca78e50
commit 243b0c077f
3 changed files with 10 additions and 22 deletions

View File

@@ -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);
}