mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
[Task 59343] sorted the list of metadatavalues and forced the itemconverter to use the itemservice
This commit is contained in:
@@ -11,6 +11,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -18,6 +19,8 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -1329,6 +1332,8 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
listToReturn.add(metadataValue);
|
||||
}
|
||||
}
|
||||
listToReturn = sortMetadataValueList(listToReturn);
|
||||
|
||||
return listToReturn;
|
||||
|
||||
} else {
|
||||
@@ -1346,11 +1351,27 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
finalList.add(metadataValue);
|
||||
}
|
||||
}
|
||||
finalList = sortMetadataValueList(finalList);
|
||||
return finalList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<MetadataValue> sortMetadataValueList(List<MetadataValue> listToReturn) {
|
||||
Comparator<MetadataValue> comparator = Comparator.comparing(
|
||||
metadataValue -> metadataValue.getMetadataField().getMetadataSchema().getName());
|
||||
comparator = comparator.thenComparing(Comparator.comparing(
|
||||
metadataValue -> metadataValue.getMetadataField().getElement()));
|
||||
comparator = comparator.thenComparing(Comparator.comparing(
|
||||
metadataValue -> metadataValue.getMetadataField().getQualifier()));
|
||||
comparator = comparator.thenComparing(Comparator.comparing(
|
||||
metadataValue -> metadataValue.getPlace()));
|
||||
|
||||
Stream<MetadataValue> metadataValueStream = listToReturn.stream().sorted(comparator);
|
||||
listToReturn = metadataValueStream.collect(Collectors.toList());
|
||||
return listToReturn;
|
||||
}
|
||||
|
||||
private List<RelationshipMetadataValue> handleItemRelationship(Context context, Item item, String entityType,
|
||||
Relationship relationship,
|
||||
boolean enableVirtualMetadata)
|
||||
|
@@ -95,8 +95,7 @@ public class ItemConverter extends DSpaceObjectConverter<org.dspace.content.Item
|
||||
item.setRelationships(relationshipRestList);
|
||||
|
||||
List<MetadataValue> fullList = new LinkedList<>();
|
||||
fullList.addAll(obj.getMetadata());
|
||||
fullList.addAll(itemService.getRelationshipMetadata(obj, true));
|
||||
fullList = itemService.getMetadata(obj, Item.ANY, Item.ANY, Item.ANY, Item.ANY, true);
|
||||
|
||||
List<MetadataEntryRest> metadata = super.convertMetadataToRest(fullList);
|
||||
item.setMetadata(metadata);
|
||||
|
Reference in New Issue
Block a user