mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 23:13:10 +00:00
Implemented the additional getMetadata function with the boolean
This commit is contained in:
@@ -1292,33 +1292,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
*/
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(Item item, String schema, String element, String qualifier, String lang) {
|
||||
//Fields of the relation schema are virtual metadata
|
||||
//except for relation.type which is the type of item in the model
|
||||
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName()) && !StringUtils.equals(element, "type")) {
|
||||
|
||||
List<RelationshipMetadataValue> relationMetadata = getRelationshipMetadata(item, false);
|
||||
List<MetadataValue> listToReturn = new LinkedList<>();
|
||||
for (MetadataValue metadataValue : relationMetadata) {
|
||||
if (StringUtils.equals(metadataValue.getMetadataField().getElement(), element)) {
|
||||
listToReturn.add(metadataValue);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
|
||||
} else {
|
||||
List<MetadataValue> dbMetadataValues = super.getMetadata(item, schema, element, qualifier, lang);
|
||||
|
||||
if (!(StringUtils.equals(schema, "*") && StringUtils.equals(element, "*") &&
|
||||
StringUtils.equals(qualifier, "*") && StringUtils.equals(lang, "*"))) {
|
||||
return dbMetadataValues;
|
||||
}
|
||||
List<MetadataValue> fullMetadataValueList = new LinkedList<>();
|
||||
fullMetadataValueList.addAll(getRelationshipMetadata(item, true));
|
||||
fullMetadataValueList.addAll(dbMetadataValues);
|
||||
|
||||
return fullMetadataValueList;
|
||||
}
|
||||
|
||||
return this.getMetadata(item, schema, element, qualifier, lang, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1342,6 +1316,40 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
return fullMetadataValueList;
|
||||
}
|
||||
|
||||
public List<MetadataValue> getMetadata(Item item, String schema, String element, String qualifier, String lang,
|
||||
boolean enableVirtualMetadata) {
|
||||
//Fields of the relation schema are virtual metadata
|
||||
//except for relation.type which is the type of item in the model
|
||||
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName()) && !StringUtils.equals(element, "type")) {
|
||||
|
||||
List<RelationshipMetadataValue> relationMetadata = getRelationshipMetadata(item, false);
|
||||
List<MetadataValue> listToReturn = new LinkedList<>();
|
||||
for (MetadataValue metadataValue : relationMetadata) {
|
||||
if (StringUtils.equals(metadataValue.getMetadataField().getElement(), element)) {
|
||||
listToReturn.add(metadataValue);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
|
||||
} else {
|
||||
List<MetadataValue> dbMetadataValues = super.getMetadata(item, schema, element, qualifier, lang);
|
||||
|
||||
List<MetadataValue> fullMetadataValueList = new LinkedList<>();
|
||||
if (enableVirtualMetadata) {
|
||||
fullMetadataValueList.addAll(getRelationshipMetadata(item, true));
|
||||
}
|
||||
fullMetadataValueList.addAll(dbMetadataValues);
|
||||
|
||||
List<MetadataValue> finalList = new LinkedList<>();
|
||||
for (MetadataValue metadataValue : fullMetadataValueList) {
|
||||
if (match(schema, element, qualifier, lang, metadataValue)) {
|
||||
finalList.add(metadataValue);
|
||||
}
|
||||
}
|
||||
return finalList;
|
||||
}
|
||||
}
|
||||
|
||||
private List<RelationshipMetadataValue> handleItemRelationship(Context context, Item item, String entityType,
|
||||
Relationship relationship,
|
||||
boolean enableVirtualMetadata)
|
||||
|
@@ -23,6 +23,7 @@ import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.RelationshipMetadataValue;
|
||||
import org.dspace.content.Thumbnail;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
@@ -653,4 +654,8 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
||||
*/
|
||||
public List<RelationshipMetadataValue> getRelationshipMetadata(Item item, boolean enableVirtualMetadata);
|
||||
|
||||
|
||||
public List<MetadataValue> getMetadata(Item item, String schema, String element, String qualifier,
|
||||
String lang, boolean enableVirtualMetadata);
|
||||
|
||||
}
|
||||
|
@@ -89,7 +89,7 @@ public class Collected implements VirtualBean {
|
||||
null,
|
||||
splittedString.length > 2 ? splittedString[2] :
|
||||
null,
|
||||
Item.ANY);
|
||||
Item.ANY, false);
|
||||
|
||||
for (MetadataValue metadataValue : resultList) {
|
||||
if (StringUtils.isNotBlank(metadataValue.getValue())) {
|
||||
|
@@ -113,7 +113,7 @@ public class Concatenate implements VirtualBean {
|
||||
null,
|
||||
splittedString.length > 2 ? splittedString[2] :
|
||||
null,
|
||||
Item.ANY);
|
||||
Item.ANY, false);
|
||||
|
||||
String resultString = "";
|
||||
for (int i = 0; i < resultList.size(); i++) {
|
||||
|
Reference in New Issue
Block a user