Merged w2p-57104_csv-import-delete-functionality into w2p-57107_mixing-entities-and-plaintest-values

This commit is contained in:
Raf Ponsaerts
2018-11-12 13:14:40 +01:00
10 changed files with 97 additions and 26 deletions

View File

@@ -1292,21 +1292,33 @@ 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) {
List<MetadataValue> dbMetadataValues = super.getMetadata(item, schema, element, qualifier, lang);
if (StringUtils.equals(schema, "relation") && !StringUtils.equals(element, "type")) {
if (!(StringUtils.equals(schema, "*") && StringUtils.equals(element, "*") &&
StringUtils.equals(qualifier, "*") && StringUtils.equals(lang, "*"))) {
return dbMetadataValues;
List<MetadataValue> 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 = getRelationshipMetadata(item, true);
fullMetadataValueList.addAll(dbMetadataValues);
return fullMetadataValueList;
}
List<MetadataValue> fullMetadataValueList = getRelationshipMetadata(item);
fullMetadataValueList.addAll(dbMetadataValues);
return fullMetadataValueList;
}
@Override
public List<MetadataValue> getRelationshipMetadata(Item item) {
public List<MetadataValue> getRelationshipMetadata(Item item, boolean extra) {
Context context = new Context();
List<MetadataValue> fullMetadataValueList = new LinkedList<>();
try {
@@ -1315,7 +1327,7 @@ prevent the generation of resource policy entry values with null dspace_object a
if (StringUtils.isNotBlank(entityType)) {
List<Relationship> relationships = relationshipService.findByItem(context, item);
for (Relationship relationship : relationships) {
fullMetadataValueList.addAll(handleItemRelationship(item, entityType, relationship));
fullMetadataValueList.addAll(handleItemRelationship(item, entityType, relationship, extra));
}
}
@@ -1326,7 +1338,7 @@ prevent the generation of resource policy entry values with null dspace_object a
}
private List<MetadataValue> handleItemRelationship(Item item, String entityType,
Relationship relationship) {
Relationship relationship, boolean extra) {
List<MetadataValue> resultingMetadataValueList = new LinkedList<>();
RelationshipType relationshipType = relationship.getRelationshipType();
HashMap<String, Concatenate> hashMaps = new HashMap<>();
@@ -1344,7 +1356,7 @@ prevent the generation of resource policy entry values with null dspace_object a
relationName = relationship.getRelationshipType().getRightLabel();
}
if (hashMaps != null) {
if (hashMaps != null && extra) {
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMappping(item, hashMaps,
otherItem, relationName));
}