mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
Merged configurable_entities into w2p-57159_permission-to-create-relations
This commit is contained in:
@@ -21,7 +21,7 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.util.AuthorizeUtil;
|
||||
import org.dspace.authorize.AuthorizeConfiguration;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
@@ -69,7 +69,7 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static final Logger log = Logger.getLogger(Item.class);
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(Item.class);
|
||||
|
||||
@Autowired(required = true)
|
||||
protected ItemDAO itemDAO;
|
||||
@@ -230,10 +230,10 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
throws SQLException {
|
||||
|
||||
MetadataField metadataField = metadataFieldService
|
||||
.findByElement(context, MetadataSchema.DC_SCHEMA, "date", "accessioned");
|
||||
.findByElement(context, MetadataSchemaEnum.DC.getName(), "date", "accessioned");
|
||||
if (metadataField == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Required metadata field '" + MetadataSchema.DC_SCHEMA + ".date.accessioned' doesn't exist!");
|
||||
"Required metadata field '" + MetadataSchemaEnum.DC.getName() + ".date.accessioned' doesn't exist!");
|
||||
}
|
||||
|
||||
return itemDAO.findBySubmitter(context, eperson, metadataField, limit);
|
||||
@@ -554,7 +554,7 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
|
||||
prov.append(installItemService.getBitstreamProvenanceMessage(context, item));
|
||||
|
||||
addMetadata(context, item, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", prov.toString());
|
||||
addMetadata(context, item, MetadataSchemaEnum.DC.getName(), "description", "provenance", "en", prov.toString());
|
||||
|
||||
// Update item in DB
|
||||
update(context, item);
|
||||
@@ -609,7 +609,7 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
// bitstream checksums
|
||||
prov.append(installItemService.getBitstreamProvenanceMessage(context, item));
|
||||
|
||||
addMetadata(context, item, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", prov.toString());
|
||||
addMetadata(context, item, MetadataSchemaEnum.DC.getName(), "description", "provenance", "en", prov.toString());
|
||||
|
||||
// Update item in DB
|
||||
update(context, item);
|
||||
@@ -1292,7 +1292,9 @@ 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) {
|
||||
if (StringUtils.equals(schema, "relation") && !StringUtils.equals(element, "type")) {
|
||||
//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<>();
|
||||
@@ -1320,7 +1322,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationshipMetadataValue> getRelationshipMetadata(Item item, boolean extra) {
|
||||
public List<RelationshipMetadataValue> getRelationshipMetadata(Item item, boolean enableVirtualMetadata) {
|
||||
Context context = new Context();
|
||||
List<RelationshipMetadataValue> fullMetadataValueList = new LinkedList<>();
|
||||
try {
|
||||
@@ -1329,8 +1331,8 @@ 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(context, item, entityType, relationship, extra));
|
||||
fullMetadataValueList.addAll(handleItemRelationship(context, item, entityType,
|
||||
relationship, enableVirtualMetadata));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1341,7 +1343,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
}
|
||||
|
||||
private List<RelationshipMetadataValue> handleItemRelationship(Context context, Item item, String entityType,
|
||||
Relationship relationship, boolean extra)
|
||||
Relationship relationship, boolean enableVirtualMetadata)
|
||||
throws SQLException {
|
||||
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
|
||||
RelationshipType relationshipType = relationship.getRelationshipType();
|
||||
@@ -1360,7 +1362,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
relationName = relationship.getRelationshipType().getRightLabel();
|
||||
}
|
||||
|
||||
if (hashMaps != null && extra) {
|
||||
if (hashMaps != null && enableVirtualMetadata) {
|
||||
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMappping(context, item, hashMaps,
|
||||
otherItem, relationName,
|
||||
relationship.getID()));
|
||||
@@ -1378,12 +1380,13 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
String key = entry.getKey();
|
||||
VirtualBean virtualBean = entry.getValue();
|
||||
|
||||
RelationshipMetadataValue metadataValue = constructMetadataValue(context, key);
|
||||
metadataValue = constructResultingMetadataValue(context, item, otherItem, virtualBean, metadataValue,
|
||||
relationshipId);
|
||||
metadataValue.setUseForPlace(virtualBean.getUseForPlace());
|
||||
if (StringUtils.isNotBlank(metadataValue.getValue())) {
|
||||
resultingMetadataValueList.add(metadataValue);
|
||||
for (String value : virtualBean.getValues(context, otherItem)) {
|
||||
RelationshipMetadataValue metadataValue = constructMetadataValue(context, key);
|
||||
metadataValue = constructResultingMetadataValue(item, value, metadataValue, relationshipId);
|
||||
metadataValue.setUseForPlace(virtualBean.getUseForPlace());
|
||||
if (StringUtils.isNotBlank(metadataValue.getValue())) {
|
||||
resultingMetadataValueList.add(metadataValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultingMetadataValueList;
|
||||
@@ -1392,7 +1395,9 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
private RelationshipMetadataValue getRelationMetadataFromOtherItem(Context context, Item otherItem,
|
||||
String relationName,
|
||||
Integer relationshipId) {
|
||||
RelationshipMetadataValue metadataValue = constructMetadataValue(context, "relation." + relationName);
|
||||
RelationshipMetadataValue metadataValue = constructMetadataValue(context,
|
||||
MetadataSchemaEnum.RELATION
|
||||
.getName() + "." + relationName);
|
||||
metadataValue.setAuthority("virtual::" + relationshipId);
|
||||
metadataValue.setValue(otherItem.getID().toString());
|
||||
return metadataValue;
|
||||
@@ -1412,12 +1417,10 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
return entityType;
|
||||
}
|
||||
|
||||
private RelationshipMetadataValue constructResultingMetadataValue(Context context, Item item, Item otherItem,
|
||||
VirtualBean virtualBean,
|
||||
private RelationshipMetadataValue constructResultingMetadataValue(Item item, String value,
|
||||
RelationshipMetadataValue metadataValue,
|
||||
Integer relationshipId)
|
||||
throws SQLException {
|
||||
metadataValue.setValue(virtualBean.getValue(context, otherItem));
|
||||
int relationshipId) {
|
||||
metadataValue.setValue(value);
|
||||
metadataValue.setAuthority("virtual::" + relationshipId);
|
||||
metadataValue.setConfidence(-1);
|
||||
metadataValue.setDSpaceObject(item);
|
||||
|
Reference in New Issue
Block a user