mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
Merge branch 'master' of https://github.com/DSpace/DSpace into DS-4210
This commit is contained in:
@@ -54,10 +54,7 @@ EXPOSE 8080 8009
|
|||||||
|
|
||||||
ENV JAVA_OPTS=-Xmx2000m
|
ENV JAVA_OPTS=-Xmx2000m
|
||||||
|
|
||||||
RUN ln -s $DSPACE_INSTALL/webapps/solr /usr/local/tomcat/webapps/solr && \
|
RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/ROOT && \
|
||||||
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/spring-rest && \
|
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/spring-rest && \
|
||||||
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest && \
|
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest
|
||||||
ln -s $DSPACE_INSTALL/webapps/oai /usr/local/tomcat/webapps/oai && \
|
|
||||||
ln -s $DSPACE_INSTALL/webapps/rdf /usr/local/tomcat/webapps/rdf && \
|
|
||||||
ln -s $DSPACE_INSTALL/webapps/sword /usr/local/tomcat/webapps/sword && \
|
|
||||||
ln -s $DSPACE_INSTALL/webapps/swordv2 /usr/local/tomcat/webapps/swordv2
|
|
||||||
|
@@ -54,16 +54,11 @@ EXPOSE 8080 8009
|
|||||||
|
|
||||||
ENV JAVA_OPTS=-Xmx2000m
|
ENV JAVA_OPTS=-Xmx2000m
|
||||||
|
|
||||||
RUN ln -s $DSPACE_INSTALL/webapps/solr /usr/local/tomcat/webapps/solr && \
|
RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/ROOT && \
|
||||||
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/spring-rest && \
|
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/spring-rest && \
|
||||||
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest && \
|
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest
|
||||||
ln -s $DSPACE_INSTALL/webapps/oai /usr/local/tomcat/webapps/oai && \
|
|
||||||
ln -s $DSPACE_INSTALL/webapps/rdf /usr/local/tomcat/webapps/rdf && \
|
|
||||||
ln -s $DSPACE_INSTALL/webapps/sword /usr/local/tomcat/webapps/sword && \
|
|
||||||
ln -s $DSPACE_INSTALL/webapps/swordv2 /usr/local/tomcat/webapps/swordv2
|
|
||||||
|
|
||||||
COPY dspace/src/main/docker/test/solr_web.xml $DSPACE_INSTALL/webapps/solr/WEB-INF/web.xml
|
|
||||||
COPY dspace/src/main/docker/test/rest_web.xml $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml
|
COPY dspace/src/main/docker/test/rest_web.xml $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml
|
||||||
|
|
||||||
RUN sed -i -e "s|\${dspace.dir}|$DSPACE_INSTALL|" $DSPACE_INSTALL/webapps/solr/WEB-INF/web.xml && \
|
RUN sed -i -e "s|\${dspace.dir}|$DSPACE_INSTALL|" $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml
|
||||||
sed -i -e "s|\${dspace.dir}|$DSPACE_INSTALL|" $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.dspace</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
<artifactId>dspace-api</artifactId>
|
<artifactId>dspace-api</artifactId>
|
||||||
|
@@ -21,6 +21,7 @@ import org.apache.xpath.XPathAPI;
|
|||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.NonUniqueMetadataException;
|
import org.dspace.content.NonUniqueMetadataException;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.MetadataFieldService;
|
import org.dspace.content.service.MetadataFieldService;
|
||||||
@@ -248,7 +249,7 @@ public class MetadataImporter {
|
|||||||
|
|
||||||
// If the schema is not provided default to DC
|
// If the schema is not provided default to DC
|
||||||
if (schema == null) {
|
if (schema == null) {
|
||||||
schema = MetadataSchema.DC_SCHEMA;
|
schema = MetadataSchemaEnum.DC.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@ import java.util.UUID;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.authority.AuthorityValue;
|
import org.dspace.authority.AuthorityValue;
|
||||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||||
import org.dspace.authority.service.AuthorityValueService;
|
import org.dspace.authority.service.AuthorityValueService;
|
||||||
@@ -34,6 +35,7 @@ import org.dspace.content.Collection;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.authority.Choices;
|
import org.dspace.content.authority.Choices;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
@@ -198,20 +200,24 @@ public class DSpaceCSV implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that the scheme exists
|
// Check that the scheme exists
|
||||||
MetadataSchema foundSchema = metadataSchemaService.find(c, metadataSchema);
|
if (!StringUtils.equals(metadataSchema, MetadataSchemaEnum.RELATION.getName())) {
|
||||||
if (foundSchema == null) {
|
MetadataSchema foundSchema = metadataSchemaService.find(c, metadataSchema);
|
||||||
throw new MetadataImportInvalidHeadingException(clean[0],
|
if (foundSchema == null) {
|
||||||
MetadataImportInvalidHeadingException.SCHEMA,
|
throw new MetadataImportInvalidHeadingException(clean[0],
|
||||||
columnCounter);
|
MetadataImportInvalidHeadingException
|
||||||
}
|
.SCHEMA,
|
||||||
|
columnCounter);
|
||||||
|
}
|
||||||
|
|
||||||
// Check that the metadata element exists in the schema
|
// Check that the metadata element exists in the schema
|
||||||
MetadataField foundField = metadataFieldService
|
MetadataField foundField = metadataFieldService
|
||||||
.findByElement(c, foundSchema, metadataElement, metadataQualifier);
|
.findByElement(c, foundSchema, metadataElement, metadataQualifier);
|
||||||
if (foundField == null) {
|
if (foundField == null) {
|
||||||
throw new MetadataImportInvalidHeadingException(clean[0],
|
throw new MetadataImportInvalidHeadingException(clean[0],
|
||||||
MetadataImportInvalidHeadingException.ELEMENT,
|
MetadataImportInvalidHeadingException
|
||||||
columnCounter);
|
.ELEMENT,
|
||||||
|
columnCounter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the heading
|
// Store the heading
|
||||||
|
@@ -15,6 +15,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -33,14 +34,23 @@ import org.dspace.authority.service.AuthorityValueService;
|
|||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
|
import org.dspace.content.Entity;
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
|
import org.dspace.content.Relationship;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.authority.Choices;
|
import org.dspace.content.authority.Choices;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
|
import org.dspace.content.service.EntityService;
|
||||||
|
import org.dspace.content.service.EntityTypeService;
|
||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -50,6 +60,7 @@ import org.dspace.eperson.EPerson;
|
|||||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||||
import org.dspace.handle.factory.HandleServiceFactory;
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
import org.dspace.handle.service.HandleService;
|
import org.dspace.handle.service.HandleService;
|
||||||
|
import org.dspace.util.UUIDUtils;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
import org.dspace.workflow.WorkflowService;
|
import org.dspace.workflow.WorkflowService;
|
||||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||||
@@ -101,6 +112,10 @@ public class MetadataImport {
|
|||||||
protected final CollectionService collectionService;
|
protected final CollectionService collectionService;
|
||||||
protected final HandleService handleService;
|
protected final HandleService handleService;
|
||||||
protected final WorkspaceItemService workspaceItemService;
|
protected final WorkspaceItemService workspaceItemService;
|
||||||
|
protected final RelationshipTypeService relationshipTypeService;
|
||||||
|
protected final RelationshipService relationshipService;
|
||||||
|
protected final EntityTypeService entityTypeService;
|
||||||
|
protected final EntityService entityService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of the metadata importer. Requires a context and an array of CSV lines
|
* Create an instance of the metadata importer. Requires a context and an array of CSV lines
|
||||||
@@ -120,6 +135,10 @@ public class MetadataImport {
|
|||||||
handleService = HandleServiceFactory.getInstance().getHandleService();
|
handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||||
authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
||||||
workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
|
workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
|
||||||
|
relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||||
|
relationshipTypeService = ContentServiceFactory.getInstance().getRelationshipTypeService();
|
||||||
|
entityTypeService = ContentServiceFactory.getInstance().getEntityTypeService();
|
||||||
|
entityService = ContentServiceFactory.getInstance().getEntityService();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -336,16 +355,30 @@ public class MetadataImport {
|
|||||||
item = wsItem.getItem();
|
item = wsItem.getItem();
|
||||||
|
|
||||||
// Add the metadata to the item
|
// Add the metadata to the item
|
||||||
|
List<BulkEditMetadataValue> relationships = new LinkedList<>();
|
||||||
for (BulkEditMetadataValue dcv : whatHasChanged.getAdds()) {
|
for (BulkEditMetadataValue dcv : whatHasChanged.getAdds()) {
|
||||||
itemService.addMetadata(c, item, dcv.getSchema(),
|
if (StringUtils.equals(dcv.getSchema(), MetadataSchemaEnum.RELATION.getName())) {
|
||||||
dcv.getElement(),
|
|
||||||
dcv.getQualifier(),
|
if (!StringUtils.equals(dcv.getElement(), "type")) {
|
||||||
dcv.getLanguage(),
|
relationships.add(dcv);
|
||||||
dcv.getValue(),
|
} else {
|
||||||
dcv.getAuthority(),
|
handleRelationshipMetadataValueFromBulkEditMetadataValue(item, dcv);
|
||||||
dcv.getConfidence());
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
itemService.addMetadata(c, item, dcv.getSchema(),
|
||||||
|
dcv.getElement(),
|
||||||
|
dcv.getQualifier(),
|
||||||
|
dcv.getLanguage(),
|
||||||
|
dcv.getValue(),
|
||||||
|
dcv.getAuthority(),
|
||||||
|
dcv.getConfidence());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (BulkEditMetadataValue relationship : relationships) {
|
||||||
|
handleRelationshipMetadataValueFromBulkEditMetadataValue(item, relationship);
|
||||||
|
}
|
||||||
// Should the workflow be used?
|
// Should the workflow be used?
|
||||||
if (useWorkflow) {
|
if (useWorkflow) {
|
||||||
WorkflowService workflowService = WorkflowServiceFactory.getInstance().getWorkflowService();
|
WorkflowService workflowService = WorkflowServiceFactory.getInstance().getWorkflowService();
|
||||||
@@ -396,6 +429,27 @@ public class MetadataImport {
|
|||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This metod handles the BulkEditMetadataValue objects that correspond to Relationship metadatavalues
|
||||||
|
* @param item The item to which this metadatavalue will belong
|
||||||
|
* @param dcv The BulkEditMetadataValue to be processed
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
private void handleRelationshipMetadataValueFromBulkEditMetadataValue(Item item, BulkEditMetadataValue dcv)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
LinkedList<String> values = new LinkedList<>();
|
||||||
|
values.add(dcv.getValue());
|
||||||
|
LinkedList<String> authorities = new LinkedList<>();
|
||||||
|
authorities.add(dcv.getAuthority());
|
||||||
|
LinkedList<Integer> confidences = new LinkedList<>();
|
||||||
|
confidences.add(dcv.getConfidence());
|
||||||
|
handleRelationMetadata(c, item, dcv.getSchema(), dcv.getElement(),
|
||||||
|
dcv.getQualifier(),
|
||||||
|
dcv.getLanguage(), values, authorities, confidences);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare an item metadata with a line from CSV, and optionally update the item
|
* Compare an item metadata with a line from CSV, and optionally update the item
|
||||||
*
|
*
|
||||||
@@ -583,9 +637,251 @@ public class MetadataImport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set those values
|
|
||||||
|
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName())) {
|
||||||
|
List<RelationshipType> relationshipTypeList = relationshipTypeService
|
||||||
|
.findByLeftOrRightLabel(c, element);
|
||||||
|
for (RelationshipType relationshipType : relationshipTypeList) {
|
||||||
|
for (Relationship relationship : relationshipService
|
||||||
|
.findByItemAndRelationshipType(c, item, relationshipType)) {
|
||||||
|
relationshipService.delete(c, relationship);
|
||||||
|
relationshipService.update(c, relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handleRelationMetadata(c, item, schema, element, qualifier, language, values, authorities, confidences);
|
||||||
|
} else {
|
||||||
|
itemService.clearMetadata(c, item, schema, element, qualifier, language);
|
||||||
|
itemService.addMetadata(c, item, schema, element, qualifier,
|
||||||
|
language, values, authorities, confidences);
|
||||||
|
itemService.update(c, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method decides whether the metadatavalue is of type relation.type or if it corresponds to
|
||||||
|
* a relationship and handles it accordingly to their respective methods
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param item The item to which this metadatavalue belongs to
|
||||||
|
* @param schema The schema for the metadatavalue
|
||||||
|
* @param element The element for the metadatavalue
|
||||||
|
* @param qualifier The qualifier for the metadatavalue
|
||||||
|
* @param language The language for the metadatavalue
|
||||||
|
* @param values The values for the metadatavalue
|
||||||
|
* @param authorities The authorities for the metadatavalue
|
||||||
|
* @param confidences The confidences for the metadatavalue
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
private void handleRelationMetadata(Context c, Item item, String schema, String element, String qualifier,
|
||||||
|
String language, List<String> values, List<String> authorities,
|
||||||
|
List<Integer> confidences) throws SQLException, AuthorizeException {
|
||||||
|
|
||||||
|
if (StringUtils.equals(element, "type") && StringUtils.isBlank(qualifier)) {
|
||||||
|
handleRelationTypeMetadata(c, item, schema, element, qualifier, language, values, authorities, confidences);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for (String value : values) {
|
||||||
|
handleRelationOtherMetadata(c, item, element, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method takes the item, element and values to determine what relationships should be built
|
||||||
|
* for these parameters and calls on the method to construct them
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param item The item that the relationships will be made for
|
||||||
|
* @param element The string determining which relationshiptype is to be used
|
||||||
|
* @param value The value for the relationship
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
private void handleRelationOtherMetadata(Context c, Item item, String element, String value)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
Entity entity = entityService.findByItemId(c, item.getID());
|
||||||
|
boolean left = false;
|
||||||
|
List<RelationshipType> acceptableRelationshipTypes = new LinkedList<>();
|
||||||
|
String url = handleService.resolveToURL(c, value);
|
||||||
|
UUID uuid = UUIDUtils.fromString(value);
|
||||||
|
if (uuid == null && StringUtils.isNotBlank(url)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity relationEntity = entityService.findByItemId(c, uuid);
|
||||||
|
|
||||||
|
|
||||||
|
List<RelationshipType> leftRelationshipTypesForEntity = entityService.getLeftRelationshipTypes(c, entity);
|
||||||
|
List<RelationshipType> rightRelationshipTypesForEntity = entityService.getRightRelationshipTypes(c, entity);
|
||||||
|
|
||||||
|
for (RelationshipType relationshipType : entityService.getAllRelationshipTypes(c, entity)) {
|
||||||
|
if (StringUtils.equalsIgnoreCase(relationshipType.getLeftLabel(), element)) {
|
||||||
|
left = handleLeftLabelEqualityRelationshipTypeElement(c, entity, relationEntity, left,
|
||||||
|
acceptableRelationshipTypes,
|
||||||
|
leftRelationshipTypesForEntity,
|
||||||
|
relationshipType);
|
||||||
|
} else if (StringUtils.equalsIgnoreCase(relationshipType.getRightLabel(), element)) {
|
||||||
|
left = handleRightLabelEqualityRelationshipTypeElement(c, entity, relationEntity, left,
|
||||||
|
acceptableRelationshipTypes,
|
||||||
|
rightRelationshipTypesForEntity,
|
||||||
|
relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (acceptableRelationshipTypes.size() > 1) {
|
||||||
|
log.error("Ambiguous relationship_types were found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (acceptableRelationshipTypes.size() == 0) {
|
||||||
|
log.error("no relationship_types were found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//There is exactly one
|
||||||
|
buildRelationObject(c, item, value, left, acceptableRelationshipTypes.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates the relationship for the item and stores it in the database
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param item The item for which this relationship will be constructed
|
||||||
|
* @param value The value for the relationship
|
||||||
|
* @param left A boolean indicating whether the item is the leftItem or the rightItem
|
||||||
|
* @param acceptedRelationshipType The acceptable relationship type
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
private void buildRelationObject(Context c, Item item, String value, boolean left,
|
||||||
|
RelationshipType acceptedRelationshipType)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
Item leftItem = null;
|
||||||
|
Item rightItem = null;
|
||||||
|
if (left) {
|
||||||
|
leftItem = item;
|
||||||
|
rightItem = itemService.findByIdOrLegacyId(c, value);
|
||||||
|
} else {
|
||||||
|
rightItem = item;
|
||||||
|
leftItem = itemService.findByIdOrLegacyId(c, value);
|
||||||
|
}
|
||||||
|
RelationshipType relationshipType = acceptedRelationshipType;
|
||||||
|
int leftPlace = relationshipService.findLeftPlaceByLeftItem(c, leftItem) + 1;
|
||||||
|
int rightPlace = relationshipService.findRightPlaceByRightItem(c, rightItem) + 1;
|
||||||
|
Relationship persistedRelationship = relationshipService.create(c, leftItem, rightItem,
|
||||||
|
relationshipType, leftPlace, rightPlace);
|
||||||
|
relationshipService.update(c, persistedRelationship);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will add RelationshipType objects to the acceptableRelationshipTypes list
|
||||||
|
* if applicable and valid RelationshipType objects are found. It will also return a boolean indicating
|
||||||
|
* whether we're dealing with a left Relationship or not
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param entity The Entity for which the RelationshipType has to be checked
|
||||||
|
* @param relationEntity The other Entity of the Relationship
|
||||||
|
* @param left Boolean indicating whether the Relationship is left or not
|
||||||
|
* @param acceptableRelationshipTypes The list of RelationshipType objects that will be added to
|
||||||
|
* @param rightRelationshipTypesForEntity The list of RelationshipType objects that are possible
|
||||||
|
* for the right entity
|
||||||
|
* @param relationshipType The RelationshipType object that we want to check whether it's
|
||||||
|
* valid to be added or not
|
||||||
|
* @return A boolean indicating whether the relationship is left or right, will
|
||||||
|
* be false in this case
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
private boolean handleRightLabelEqualityRelationshipTypeElement(Context c, Entity entity, Entity relationEntity,
|
||||||
|
boolean left,
|
||||||
|
List<RelationshipType> acceptableRelationshipTypes,
|
||||||
|
List<RelationshipType>
|
||||||
|
rightRelationshipTypesForEntity,
|
||||||
|
RelationshipType relationshipType)
|
||||||
|
throws SQLException {
|
||||||
|
if (StringUtils.equalsIgnoreCase(entityService.getType(c, entity).getLabel(),
|
||||||
|
relationshipType.getRightType().getLabel()) &&
|
||||||
|
StringUtils.equalsIgnoreCase(entityService.getType(c, relationEntity).getLabel(),
|
||||||
|
relationshipType.getLeftType().getLabel())) {
|
||||||
|
|
||||||
|
for (RelationshipType rightRelationshipType : rightRelationshipTypesForEntity) {
|
||||||
|
if (StringUtils.equalsIgnoreCase(rightRelationshipType.getLeftType().getLabel(),
|
||||||
|
relationshipType.getLeftType().getLabel()) ||
|
||||||
|
StringUtils.equalsIgnoreCase(rightRelationshipType.getRightType().getLabel(),
|
||||||
|
relationshipType.getLeftType().getLabel())) {
|
||||||
|
left = false;
|
||||||
|
acceptableRelationshipTypes.add(relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will add RelationshipType objects to the acceptableRelationshipTypes list
|
||||||
|
* if applicable and valid RelationshipType objects are found. It will also return a boolean indicating
|
||||||
|
* whether we're dealing with a left Relationship or not
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param entity The Entity for which the RelationshipType has to be checked
|
||||||
|
* @param relationEntity The other Entity of the Relationship
|
||||||
|
* @param left Boolean indicating whether the Relationship is left or not
|
||||||
|
* @param acceptableRelationshipTypes The list of RelationshipType objects that will be added to
|
||||||
|
* @param leftRelationshipTypesForEntity The list of RelationshipType objects that are possible
|
||||||
|
* for the left entity
|
||||||
|
* @param relationshipType The RelationshipType object that we want to check whether it's
|
||||||
|
* valid to be added or not
|
||||||
|
* @return A boolean indicating whether the relationship is left or right, will
|
||||||
|
* be true in this case
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
private boolean handleLeftLabelEqualityRelationshipTypeElement(Context c, Entity entity, Entity relationEntity,
|
||||||
|
boolean left,
|
||||||
|
List<RelationshipType> acceptableRelationshipTypes,
|
||||||
|
List<RelationshipType>
|
||||||
|
leftRelationshipTypesForEntity,
|
||||||
|
RelationshipType relationshipType)
|
||||||
|
throws SQLException {
|
||||||
|
if (StringUtils.equalsIgnoreCase(entityService.getType(c, entity).getLabel(),
|
||||||
|
relationshipType.getLeftType().getLabel()) &&
|
||||||
|
StringUtils.equalsIgnoreCase(entityService.getType(c, relationEntity).getLabel(),
|
||||||
|
relationshipType.getRightType().getLabel())) {
|
||||||
|
for (RelationshipType leftRelationshipType : leftRelationshipTypesForEntity) {
|
||||||
|
if (StringUtils.equalsIgnoreCase(leftRelationshipType.getRightType().getLabel(),
|
||||||
|
relationshipType.getRightType().getLabel()) ||
|
||||||
|
StringUtils.equalsIgnoreCase(leftRelationshipType.getLeftType().getLabel(),
|
||||||
|
relationshipType.getRightType().getLabel())) {
|
||||||
|
left = true;
|
||||||
|
acceptableRelationshipTypes.add(relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will add the relationship.type metadata to the item if an EntityType can be found for the value in
|
||||||
|
* the values list.
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param item The item to which this metadatavalue will be added
|
||||||
|
* @param schema The schema for the metadatavalue to be added
|
||||||
|
* @param element The element for the metadatavalue to be added
|
||||||
|
* @param qualifier The qualifier for the metadatavalue to be added
|
||||||
|
* @param language The language for the metadatavalue to be added
|
||||||
|
* @param values The value on which we'll search for EntityType object and it's the value
|
||||||
|
* for the metadatavalue that will be created
|
||||||
|
* @param authorities The authority for the metadatavalue. This will be filled with the ID
|
||||||
|
* of the found EntityType for the value if it exists
|
||||||
|
* @param confidences The confidence for the metadatavalue
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
private void handleRelationTypeMetadata(Context c, Item item, String schema, String element, String qualifier,
|
||||||
|
String language, List<String> values, List<String> authorities,
|
||||||
|
List<Integer> confidences)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
EntityType entityType = entityTypeService.findByEntityType(c, values.get(0));
|
||||||
|
if (entityType != null) {
|
||||||
|
authorities.add(String.valueOf(entityType.getID()));
|
||||||
itemService.clearMetadata(c, item, schema, element, qualifier, language);
|
itemService.clearMetadata(c, item, schema, element, qualifier, language);
|
||||||
itemService.addMetadata(c, item, schema, element, qualifier, language, values, authorities, confidences);
|
itemService.addMetadata(c, item, schema, element, qualifier, language,
|
||||||
|
values, authorities, confidences);
|
||||||
itemService.update(c, item);
|
itemService.update(c, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ import org.dspace.content.Community;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
@@ -214,7 +214,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
|||||||
protected void writeMetadata(Context c, String schema, Item i,
|
protected void writeMetadata(Context c, String schema, Item i,
|
||||||
File destDir, boolean migrate) throws Exception {
|
File destDir, boolean migrate) throws Exception {
|
||||||
String filename;
|
String filename;
|
||||||
if (schema.equals(MetadataSchema.DC_SCHEMA)) {
|
if (schema.equals(MetadataSchemaEnum.DC.getName())) {
|
||||||
filename = "dublin_core.xml";
|
filename = "dublin_core.xml";
|
||||||
} else {
|
} else {
|
||||||
filename = "metadata_" + schema + ".xml";
|
filename = "metadata_" + schema + ".xml";
|
||||||
|
@@ -74,6 +74,7 @@ import org.dspace.content.DSpaceObject;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.service.BitstreamFormatService;
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
@@ -677,7 +678,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
|||||||
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem(
|
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem(
|
||||||
"schema");
|
"schema");
|
||||||
if (schemaAttr == null) {
|
if (schemaAttr == null) {
|
||||||
schema = MetadataSchema.DC_SCHEMA;
|
schema = MetadataSchemaEnum.DC.getName();
|
||||||
} else {
|
} else {
|
||||||
schema = schemaAttr.getNodeValue();
|
schema = schemaAttr.getNodeValue();
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,7 @@ import org.dspace.authorize.AuthorizeException;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
@@ -189,7 +190,7 @@ public class MetadataUtilities {
|
|||||||
NodeList metadata = XPathAPI.selectNodeList(document, "/dublin_core");
|
NodeList metadata = XPathAPI.selectNodeList(document, "/dublin_core");
|
||||||
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem("schema");
|
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem("schema");
|
||||||
if (schemaAttr == null) {
|
if (schemaAttr == null) {
|
||||||
schema = MetadataSchema.DC_SCHEMA;
|
schema = MetadataSchemaEnum.DC.getName();
|
||||||
} else {
|
} else {
|
||||||
schema = schemaAttr.getNodeValue();
|
schema = schemaAttr.getNodeValue();
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
@@ -763,9 +763,10 @@ public class ReportGenerator {
|
|||||||
// build the referece
|
// build the referece
|
||||||
// FIXME: here we have blurred the line between content and presentation
|
// FIXME: here we have blurred the line between content and presentation
|
||||||
// and it should probably be un-blurred
|
// and it should probably be un-blurred
|
||||||
List<MetadataValue> title = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
List<MetadataValue> title = itemService.getMetadata(item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, Item.ANY);
|
||||||
List<MetadataValue> author = itemService
|
List<MetadataValue> author = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "contributor", "author", Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "contributor", "author", Item.ANY);
|
||||||
|
|
||||||
StringBuffer authors = new StringBuffer();
|
StringBuffer authors = new StringBuffer();
|
||||||
if (author.size() > 0) {
|
if (author.size() > 0) {
|
||||||
|
@@ -14,7 +14,7 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.core.Utils;
|
import org.dspace.core.Utils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -160,7 +160,7 @@ public class DCInput {
|
|||||||
// Default the schema to dublin core
|
// Default the schema to dublin core
|
||||||
dcSchema = fieldMap.get("dc-schema");
|
dcSchema = fieldMap.get("dc-schema");
|
||||||
if (dcSchema == null) {
|
if (dcSchema == null) {
|
||||||
dcSchema = MetadataSchema.DC_SCHEMA;
|
dcSchema = MetadataSchemaEnum.DC.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if the input have a language tag
|
//check if the input have a language tag
|
||||||
|
@@ -21,7 +21,7 @@ import javax.xml.parsers.FactoryConfigurationError;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.core.Utils;
|
import org.dspace.core.Utils;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@@ -464,7 +464,7 @@ public class DCInputsReader {
|
|||||||
String elem = field.get("dc-element");
|
String elem = field.get("dc-element");
|
||||||
String qual = field.get("dc-qualifier");
|
String qual = field.get("dc-qualifier");
|
||||||
if ((schema == null) || (schema.equals(""))) {
|
if ((schema == null) || (schema.equals(""))) {
|
||||||
schema = MetadataSchema.DC_SCHEMA;
|
schema = MetadataSchemaEnum.DC.getName();
|
||||||
}
|
}
|
||||||
String schemaTest;
|
String schemaTest;
|
||||||
|
|
||||||
@@ -474,7 +474,7 @@ public class DCInputsReader {
|
|||||||
Map<String, String> fld = pg.get(j);
|
Map<String, String> fld = pg.get(j);
|
||||||
if ((fld.get("dc-schema") == null) ||
|
if ((fld.get("dc-schema") == null) ||
|
||||||
((fld.get("dc-schema")).equals(""))) {
|
((fld.get("dc-schema")).equals(""))) {
|
||||||
schemaTest = MetadataSchema.DC_SCHEMA;
|
schemaTest = MetadataSchemaEnum.DC.getName();
|
||||||
} else {
|
} else {
|
||||||
schemaTest = fld.get("dc-schema");
|
schemaTest = fld.get("dc-schema");
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,227 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.apache.commons.cli.CommandLine;
|
||||||
|
import org.apache.commons.cli.CommandLineParser;
|
||||||
|
import org.apache.commons.cli.HelpFormatter;
|
||||||
|
import org.apache.commons.cli.Options;
|
||||||
|
import org.apache.commons.cli.ParseException;
|
||||||
|
import org.apache.commons.cli.PosixParser;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
|
import org.dspace.content.service.EntityTypeService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This script is used to initialize the database with a set of relationshiptypes that are written
|
||||||
|
* in an xml file that is given to this script.
|
||||||
|
* This XML file needs to have a proper XML structure and needs to define the variables of the RelationshipType object
|
||||||
|
*/
|
||||||
|
public class InitializeEntities {
|
||||||
|
|
||||||
|
private final static Logger log = LogManager.getLogger();
|
||||||
|
|
||||||
|
private RelationshipTypeService relationshipTypeService;
|
||||||
|
private RelationshipService relationshipService;
|
||||||
|
private EntityTypeService entityTypeService;
|
||||||
|
|
||||||
|
private InitializeEntities() {
|
||||||
|
relationshipTypeService = ContentServiceFactory.getInstance().getRelationshipTypeService();
|
||||||
|
relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||||
|
entityTypeService = ContentServiceFactory.getInstance().getEntityTypeService();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main method for this script
|
||||||
|
*
|
||||||
|
* @param argv The commandline arguments given with this command
|
||||||
|
* @throws SQLException If something goes wrong with the database
|
||||||
|
* @throws AuthorizeException If something goes wrong with permissions
|
||||||
|
* @throws ParseException If something goes wrong with the parsing
|
||||||
|
*/
|
||||||
|
public static void main(String[] argv) throws SQLException, AuthorizeException, ParseException {
|
||||||
|
InitializeEntities initializeEntities = new InitializeEntities();
|
||||||
|
CommandLineParser parser = new PosixParser();
|
||||||
|
Options options = createCommandLineOptions();
|
||||||
|
CommandLine line = parser.parse(options,argv);
|
||||||
|
String fileLocation = getFileLocationFromCommandLine(line);
|
||||||
|
checkHelpEntered(options, line);
|
||||||
|
initializeEntities.run(fileLocation);
|
||||||
|
}
|
||||||
|
private static void checkHelpEntered(Options options, CommandLine line) {
|
||||||
|
if (line.hasOption("h")) {
|
||||||
|
HelpFormatter formatter = new HelpFormatter();
|
||||||
|
formatter.printHelp("Intialize Entities", options);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static String getFileLocationFromCommandLine(CommandLine line) {
|
||||||
|
String query = line.getOptionValue("f");
|
||||||
|
if (StringUtils.isEmpty(query)) {
|
||||||
|
System.out.println("No file location was entered");
|
||||||
|
log.info("No file location was entered");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static Options createCommandLineOptions() {
|
||||||
|
Options options = new Options();
|
||||||
|
options.addOption("f", "file", true, "the location for the file containing the xml data");
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run(String fileLocation) throws SQLException, AuthorizeException {
|
||||||
|
Context context = new Context();
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
this.parseXMLToRelations(context, fileLocation);
|
||||||
|
context.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseXMLToRelations(Context context, String fileLocation) throws AuthorizeException {
|
||||||
|
try {
|
||||||
|
File fXmlFile = new File(fileLocation);
|
||||||
|
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder dBuilder = null;
|
||||||
|
dBuilder = dbFactory.newDocumentBuilder();
|
||||||
|
Document doc = dBuilder.parse(fXmlFile);
|
||||||
|
|
||||||
|
doc.getDocumentElement().normalize();
|
||||||
|
|
||||||
|
NodeList nList = doc.getElementsByTagName("type");
|
||||||
|
List<RelationshipType> relationshipTypes = new LinkedList<>();
|
||||||
|
for (int i = 0; i < nList.getLength(); i++) {
|
||||||
|
Node nNode = nList.item(i);
|
||||||
|
|
||||||
|
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
|
|
||||||
|
Element eElement = (Element) nNode;
|
||||||
|
|
||||||
|
String leftType = eElement.getElementsByTagName("leftType").item(0).getTextContent();
|
||||||
|
String rightType = eElement.getElementsByTagName("rightType").item(0).getTextContent();
|
||||||
|
String leftLabel = eElement.getElementsByTagName("leftLabel").item(0).getTextContent();
|
||||||
|
String rightLabel = eElement.getElementsByTagName("rightLabel").item(0).getTextContent();
|
||||||
|
|
||||||
|
|
||||||
|
NodeList leftCardinalityList = eElement.getElementsByTagName("leftCardinality");
|
||||||
|
NodeList rightCardinalityList = eElement.getElementsByTagName("rightCardinality");
|
||||||
|
|
||||||
|
String leftCardinalityMin = "";
|
||||||
|
String leftCardinalityMax = "";
|
||||||
|
|
||||||
|
String rightCardinalityMin = "";
|
||||||
|
String rightCardinalityMax = "";
|
||||||
|
|
||||||
|
for (int j = 0; j < leftCardinalityList.getLength(); j++) {
|
||||||
|
Node node = leftCardinalityList.item(j);
|
||||||
|
leftCardinalityMin = getString(leftCardinalityMin,(Element) node, "min");
|
||||||
|
leftCardinalityMax = getString(leftCardinalityMax,(Element) node, "max");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < rightCardinalityList.getLength(); j++) {
|
||||||
|
Node node = rightCardinalityList.item(j);
|
||||||
|
rightCardinalityMin = getString(rightCardinalityMin,(Element) node, "min");
|
||||||
|
rightCardinalityMax = getString(rightCardinalityMax,(Element) node, "max");
|
||||||
|
|
||||||
|
}
|
||||||
|
populateRelationshipType(context, leftType, rightType, leftLabel, rightLabel,
|
||||||
|
leftCardinalityMin, leftCardinalityMax,
|
||||||
|
rightCardinalityMin, rightCardinalityMax);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ParserConfigurationException | SAXException | IOException | SQLException e) {
|
||||||
|
log.error("An error occurred while parsing the XML file to relations", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getString(String leftCardinalityMin,Element node, String minOrMax) {
|
||||||
|
if (node.getElementsByTagName(minOrMax).getLength() > 0) {
|
||||||
|
leftCardinalityMin = node.getElementsByTagName(minOrMax).item(0).getTextContent();
|
||||||
|
}
|
||||||
|
return leftCardinalityMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateRelationshipType(Context context, String leftType, String rightType, String leftLabel,
|
||||||
|
String rightLabel, String leftCardinalityMin, String leftCardinalityMax,
|
||||||
|
String rightCardinalityMin, String rightCardinalityMax)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
|
||||||
|
EntityType leftEntityType = entityTypeService.findByEntityType(context,leftType);
|
||||||
|
if (leftEntityType == null) {
|
||||||
|
leftEntityType = entityTypeService.create(context, leftType);
|
||||||
|
}
|
||||||
|
EntityType rightEntityType = entityTypeService.findByEntityType(context, rightType);
|
||||||
|
if (rightEntityType == null) {
|
||||||
|
rightEntityType = entityTypeService.create(context, rightType);
|
||||||
|
}
|
||||||
|
Integer leftCardinalityMinInteger;
|
||||||
|
Integer leftCardinalityMaxInteger;
|
||||||
|
Integer rightCardinalityMinInteger;
|
||||||
|
Integer rightCardinalityMaxInteger;
|
||||||
|
if (StringUtils.isNotBlank(leftCardinalityMin)) {
|
||||||
|
leftCardinalityMinInteger = Integer.parseInt(leftCardinalityMin);
|
||||||
|
} else {
|
||||||
|
leftCardinalityMinInteger = null;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(leftCardinalityMax)) {
|
||||||
|
leftCardinalityMaxInteger = Integer.parseInt(leftCardinalityMax);
|
||||||
|
} else {
|
||||||
|
leftCardinalityMaxInteger = null;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(rightCardinalityMin)) {
|
||||||
|
rightCardinalityMinInteger = Integer.parseInt(rightCardinalityMin);
|
||||||
|
} else {
|
||||||
|
rightCardinalityMinInteger = null;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(rightCardinalityMax)) {
|
||||||
|
rightCardinalityMaxInteger = Integer.parseInt(rightCardinalityMax);
|
||||||
|
} else {
|
||||||
|
rightCardinalityMaxInteger = null;
|
||||||
|
}
|
||||||
|
RelationshipType relationshipType = relationshipTypeService
|
||||||
|
.findbyTypesAndLabels(context, leftEntityType, rightEntityType, leftLabel, rightLabel);
|
||||||
|
if (relationshipType == null) {
|
||||||
|
relationshipTypeService.create(context, leftEntityType, rightEntityType, leftLabel, rightLabel,
|
||||||
|
leftCardinalityMinInteger, leftCardinalityMaxInteger,
|
||||||
|
rightCardinalityMinInteger, rightCardinalityMaxInteger);
|
||||||
|
} else {
|
||||||
|
relationshipType.setLeftMinCardinality(leftCardinalityMinInteger);
|
||||||
|
relationshipType.setLeftMaxCardinality(leftCardinalityMaxInteger);
|
||||||
|
relationshipType.setRightMinCardinality(rightCardinalityMinInteger);
|
||||||
|
relationshipType.setRightMaxCardinality(rightCardinalityMaxInteger);
|
||||||
|
relationshipTypeService.update(context, relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -130,7 +130,8 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return getBitstreamService().getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
return getBitstreamService().getMetadataFirstValue(this, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -141,7 +142,8 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public void setName(Context context, String n) throws SQLException {
|
public void setName(Context context, String n) throws SQLException {
|
||||||
getBitstreamService().setMetadataSingleValue(context, this, MetadataSchema.DC_SCHEMA, "title", null, null, n);
|
getBitstreamService().setMetadataSingleValue(context, this, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, null, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,7 +154,8 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* @return the source of the bitstream
|
* @return the source of the bitstream
|
||||||
*/
|
*/
|
||||||
public String getSource() {
|
public String getSource() {
|
||||||
return getBitstreamService().getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "source", null, Item.ANY);
|
return getBitstreamService().getMetadataFirstValue(this, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"source", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -163,7 +166,8 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public void setSource(Context context, String n) throws SQLException {
|
public void setSource(Context context, String n) throws SQLException {
|
||||||
getBitstreamService().setMetadataSingleValue(context, this, MetadataSchema.DC_SCHEMA, "source", null, null, n);
|
getBitstreamService().setMetadataSingleValue(context, this, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"source", null, null, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -174,7 +178,8 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
*/
|
*/
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return getBitstreamService()
|
return getBitstreamService()
|
||||||
.getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "description", null, Item.ANY);
|
.getMetadataFirstValue(this, MetadataSchemaEnum.DC.getName(), "description",
|
||||||
|
null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -186,7 +191,7 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
*/
|
*/
|
||||||
public void setDescription(Context context, String n) throws SQLException {
|
public void setDescription(Context context, String n) throws SQLException {
|
||||||
getBitstreamService()
|
getBitstreamService()
|
||||||
.setMetadataSingleValue(context, this, MetadataSchema.DC_SCHEMA, "description", null, null, n);
|
.setMetadataSingleValue(context, this, MetadataSchemaEnum.DC.getName(), "description", null, null, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -235,7 +240,8 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* @return the user's format description.
|
* @return the user's format description.
|
||||||
*/
|
*/
|
||||||
public String getUserFormatDescription() {
|
public String getUserFormatDescription() {
|
||||||
return getBitstreamService().getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "format", null, Item.ANY);
|
return getBitstreamService().getMetadataFirstValue(this, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"format", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BitstreamFormat getBitstreamFormat() {
|
protected BitstreamFormat getBitstreamFormat() {
|
||||||
|
@@ -205,7 +205,7 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> imp
|
|||||||
@Override
|
@Override
|
||||||
public void setUserFormatDescription(Context context, Bitstream bitstream, String desc) throws SQLException {
|
public void setUserFormatDescription(Context context, Bitstream bitstream, String desc) throws SQLException {
|
||||||
setFormat(context, bitstream, null);
|
setFormat(context, bitstream, null);
|
||||||
setMetadataSingleValue(context, bitstream, MetadataSchema.DC_SCHEMA, "format", null, null, desc);
|
setMetadataSingleValue(context, bitstream, MetadataSchemaEnum.DC.getName(), "format", null, null, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -235,7 +235,7 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove user type description
|
// Remove user type description
|
||||||
clearMetadata(context, bitstream, MetadataSchema.DC_SCHEMA, "format", null, Item.ANY);
|
clearMetadata(context, bitstream, MetadataSchemaEnum.DC.getName(), "format", null, Item.ANY);
|
||||||
|
|
||||||
// Update the ID in the table row
|
// Update the ID in the table row
|
||||||
bitstream.setFormat(bitstreamFormat);
|
bitstream.setFormat(bitstreamFormat);
|
||||||
|
@@ -88,7 +88,7 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return getBundleService().getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
return getBundleService().getMetadataFirstValue(this, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,7 +100,8 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport {
|
|||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public void setName(Context context, String name) throws SQLException {
|
public void setName(Context context, String name) throws SQLException {
|
||||||
getBundleService().setMetadataSingleValue(context, this, MetadataSchema.DC_SCHEMA, "title", null, null, name);
|
getBundleService().setMetadataSingleValue(context, this, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, null, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -120,7 +120,7 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
|
|||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String value = getCollectionService()
|
String value = getCollectionService()
|
||||||
.getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
.getMetadataFirstValue(this, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
|
||||||
return value == null ? "" : value;
|
return value == null ? "" : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -153,10 +153,11 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Collection> findAll(Context context) throws SQLException {
|
public List<Collection> findAll(Context context) throws SQLException {
|
||||||
MetadataField nameField = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, "title", null);
|
MetadataField nameField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null);
|
||||||
if (nameField == null) {
|
if (nameField == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Required metadata field '" + MetadataSchema.DC_SCHEMA + ".title' doesn't exist!");
|
"Required metadata field '" + MetadataSchemaEnum.DC.getName() + ".title' doesn't exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return collectionDAO.findAll(context, nameField);
|
return collectionDAO.findAll(context, nameField);
|
||||||
@@ -164,10 +165,11 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Collection> findAll(Context context, Integer limit, Integer offset) throws SQLException {
|
public List<Collection> findAll(Context context, Integer limit, Integer offset) throws SQLException {
|
||||||
MetadataField nameField = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, "title", null);
|
MetadataField nameField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null);
|
||||||
if (nameField == null) {
|
if (nameField == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Required metadata field '" + MetadataSchema.DC_SCHEMA + ".title' doesn't exist!");
|
"Required metadata field '" + MetadataSchemaEnum.DC.getName() + ".title' doesn't exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return collectionDAO.findAll(context, nameField, limit, offset);
|
return collectionDAO.findAll(context, nameField, limit, offset);
|
||||||
|
@@ -262,7 +262,7 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String value = getCommunityService()
|
String value = getCommunityService()
|
||||||
.getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
.getMetadataFirstValue(this, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
|
||||||
return value == null ? "" : value;
|
return value == null ? "" : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -148,10 +148,11 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Community> findAll(Context context) throws SQLException {
|
public List<Community> findAll(Context context) throws SQLException {
|
||||||
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, "title", null);
|
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null);
|
||||||
if (sortField == null) {
|
if (sortField == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Required metadata field '" + MetadataSchema.DC_SCHEMA + ".title' doesn't exist!");
|
"Required metadata field '" + MetadataSchemaEnum.DC.getName() + ".title' doesn't exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return communityDAO.findAll(context, sortField);
|
return communityDAO.findAll(context, sortField);
|
||||||
@@ -159,10 +160,11 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Community> findAll(Context context, Integer limit, Integer offset) throws SQLException {
|
public List<Community> findAll(Context context, Integer limit, Integer offset) throws SQLException {
|
||||||
MetadataField nameField = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, "title", null);
|
MetadataField nameField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null);
|
||||||
if (nameField == null) {
|
if (nameField == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Required metadata field '" + MetadataSchema.DC_SCHEMA + ".title' doesn't exist!");
|
"Required metadata field '" + MetadataSchemaEnum.DC.getName() + ".title' doesn't exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return communityDAO.findAll(context, nameField, limit, offset);
|
return communityDAO.findAll(context, nameField, limit, offset);
|
||||||
@@ -171,10 +173,11 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
|||||||
@Override
|
@Override
|
||||||
public List<Community> findAllTop(Context context) throws SQLException {
|
public List<Community> findAllTop(Context context) throws SQLException {
|
||||||
// get all communities that are not children
|
// get all communities that are not children
|
||||||
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, "title", null);
|
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null);
|
||||||
if (sortField == null) {
|
if (sortField == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Required metadata field '" + MetadataSchema.DC_SCHEMA + ".title' doesn't exist!");
|
"Required metadata field '" + MetadataSchemaEnum.DC.getName() + ".title' doesn't exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return communityDAO.findAllNoParent(context, sortField);
|
return communityDAO.findAllNoParent(context, sortField);
|
||||||
|
@@ -10,8 +10,10 @@ package org.dspace.content;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@@ -27,6 +29,7 @@ import org.dspace.content.authority.service.MetadataAuthorityService;
|
|||||||
import org.dspace.content.service.DSpaceObjectService;
|
import org.dspace.content.service.DSpaceObjectService;
|
||||||
import org.dspace.content.service.MetadataFieldService;
|
import org.dspace.content.service.MetadataFieldService;
|
||||||
import org.dspace.content.service.MetadataValueService;
|
import org.dspace.content.service.MetadataValueService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.handle.service.HandleService;
|
import org.dspace.handle.service.HandleService;
|
||||||
@@ -60,6 +63,8 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
protected MetadataFieldService metadataFieldService;
|
protected MetadataFieldService metadataFieldService;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected MetadataAuthorityService metadataAuthorityService;
|
protected MetadataAuthorityService metadataAuthorityService;
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected RelationshipService relationshipService;
|
||||||
|
|
||||||
public DSpaceObjectServiceImpl() {
|
public DSpaceObjectServiceImpl() {
|
||||||
|
|
||||||
@@ -67,7 +72,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(T dso) {
|
public String getName(T dso) {
|
||||||
String value = getMetadataFirstValue(dso, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
String value = getMetadataFirstValue(dso, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
|
||||||
return value == null ? "" : value;
|
return value == null ? "" : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,12 +240,19 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
throws SQLException {
|
throws SQLException {
|
||||||
boolean authorityControlled = metadataAuthorityService.isAuthorityControlled(metadataField);
|
boolean authorityControlled = metadataAuthorityService.isAuthorityControlled(metadataField);
|
||||||
boolean authorityRequired = metadataAuthorityService.isAuthorityRequired(metadataField);
|
boolean authorityRequired = metadataAuthorityService.isAuthorityRequired(metadataField);
|
||||||
|
|
||||||
// We will not verify that they are valid entries in the registry
|
// We will not verify that they are valid entries in the registry
|
||||||
// until update() is called.
|
// until update() is called.
|
||||||
for (int i = 0; i < values.size(); i++) {
|
for (int i = 0; i < values.size(); i++) {
|
||||||
|
|
||||||
|
if (authorities != null && authorities.size() >= i) {
|
||||||
|
if (StringUtils.startsWith(authorities.get(i), Constants.VIRTUAL_AUTHORITY_PREFIX)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
MetadataValue metadataValue = metadataValueService.create(context, dso, metadataField);
|
MetadataValue metadataValue = metadataValueService.create(context, dso, metadataField);
|
||||||
|
//Set place to list length
|
||||||
|
metadataValue.setPlace(this.getMetadata(dso, Item.ANY, Item.ANY, Item.ANY, Item.ANY).size());
|
||||||
|
|
||||||
metadataValue.setLanguage(lang == null ? null : lang.trim());
|
metadataValue.setLanguage(lang == null ? null : lang.trim());
|
||||||
|
|
||||||
// Logic to set Authority and Confidence:
|
// Logic to set Authority and Confidence:
|
||||||
@@ -543,11 +555,50 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
*/
|
*/
|
||||||
// A map created to store the latest place for each metadata field
|
// A map created to store the latest place for each metadata field
|
||||||
Map<MetadataField, Integer> fieldToLastPlace = new HashMap<>();
|
Map<MetadataField, Integer> fieldToLastPlace = new HashMap<>();
|
||||||
List<MetadataValue> metadataValues = dso.getMetadata();
|
List<MetadataValue> metadataValues = new LinkedList<>();
|
||||||
|
if (dso.getType() == Constants.ITEM) {
|
||||||
|
metadataValues = getMetadata(dso, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
||||||
|
} else {
|
||||||
|
metadataValues = dso.getMetadata();
|
||||||
|
}
|
||||||
|
//This inline sort function will sort the MetadataValues based on their place in ascending order
|
||||||
|
//If two places are the same then the MetadataValue instance will be placed before the
|
||||||
|
//RelationshipMetadataValue instance.
|
||||||
|
//This is done to ensure that the order is correct.
|
||||||
|
metadataValues.sort(new Comparator<MetadataValue>() {
|
||||||
|
public int compare(MetadataValue o1, MetadataValue o2) {
|
||||||
|
int compare = o1.getPlace() - o2.getPlace();
|
||||||
|
if (compare == 0) {
|
||||||
|
if (o1 instanceof RelationshipMetadataValue) {
|
||||||
|
return 1;
|
||||||
|
} else if (o2 instanceof RelationshipMetadataValue) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return compare;
|
||||||
|
}
|
||||||
|
});
|
||||||
for (MetadataValue metadataValue : metadataValues) {
|
for (MetadataValue metadataValue : metadataValues) {
|
||||||
//Retrieve & store the place for each metadata value
|
//Retrieve & store the place for each metadata value
|
||||||
int mvPlace = getMetadataValuePlace(fieldToLastPlace, metadataValue);
|
if (StringUtils.startsWith(metadataValue.getAuthority(), Constants.VIRTUAL_AUTHORITY_PREFIX) &&
|
||||||
metadataValue.setPlace(mvPlace);
|
((RelationshipMetadataValue) metadataValue).isUseForPlace()) {
|
||||||
|
int mvPlace = getMetadataValuePlace(fieldToLastPlace, metadataValue);
|
||||||
|
metadataValue.setPlace(mvPlace);
|
||||||
|
String authority = metadataValue.getAuthority();
|
||||||
|
String relationshipId = StringUtils.split(authority, "::")[1];
|
||||||
|
Relationship relationship = relationshipService.find(context, Integer.parseInt(relationshipId));
|
||||||
|
if (relationship.getLeftItem() == (Item) dso) {
|
||||||
|
relationship.setLeftPlace(mvPlace);
|
||||||
|
} else {
|
||||||
|
relationship.setRightPlace(mvPlace);
|
||||||
|
}
|
||||||
|
relationshipService.update(context, relationship);
|
||||||
|
|
||||||
|
} else if (!StringUtils.startsWith(metadataValue.getAuthority(),
|
||||||
|
Constants.VIRTUAL_AUTHORITY_PREFIX)) {
|
||||||
|
int mvPlace = getMetadataValuePlace(fieldToLastPlace, metadataValue);
|
||||||
|
metadataValue.setPlace(mvPlace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,7 +608,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
*
|
*
|
||||||
* @param fieldToLastPlace the map containing the latest place of each metadata field
|
* @param fieldToLastPlace the map containing the latest place of each metadata field
|
||||||
* @param metadataValue the metadata value that needs to get a place
|
* @param metadataValue the metadata value that needs to get a place
|
||||||
* @return The new place for the metadata valu
|
* @return The new place for the metadata value
|
||||||
*/
|
*/
|
||||||
protected int getMetadataValuePlace(Map<MetadataField, Integer> fieldToLastPlace, MetadataValue metadataValue) {
|
protected int getMetadataValuePlace(Map<MetadataField, Integer> fieldToLastPlace, MetadataValue metadataValue) {
|
||||||
MetadataField metadataField = metadataValue.getMetadataField();
|
MetadataField metadataField = metadataValue.getMetadataField();
|
||||||
@@ -573,23 +624,23 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
protected String[] getMDValueByLegacyField(String field) {
|
protected String[] getMDValueByLegacyField(String field) {
|
||||||
switch (field) {
|
switch (field) {
|
||||||
case "introductory_text":
|
case "introductory_text":
|
||||||
return new String[] {MetadataSchema.DC_SCHEMA, "description", null};
|
return new String[] {MetadataSchemaEnum.DC.getName(), "description", null};
|
||||||
case "short_description":
|
case "short_description":
|
||||||
return new String[] {MetadataSchema.DC_SCHEMA, "description", "abstract"};
|
return new String[] {MetadataSchemaEnum.DC.getName(), "description", "abstract"};
|
||||||
case "side_bar_text":
|
case "side_bar_text":
|
||||||
return new String[] {MetadataSchema.DC_SCHEMA, "description", "tableofcontents"};
|
return new String[] {MetadataSchemaEnum.DC.getName(), "description", "tableofcontents"};
|
||||||
case "copyright_text":
|
case "copyright_text":
|
||||||
return new String[] {MetadataSchema.DC_SCHEMA, "rights", null};
|
return new String[] {MetadataSchemaEnum.DC.getName(), "rights", null};
|
||||||
case "name":
|
case "name":
|
||||||
return new String[] {MetadataSchema.DC_SCHEMA, "title", null};
|
return new String[] {MetadataSchemaEnum.DC.getName(), "title", null};
|
||||||
case "provenance_description":
|
case "provenance_description":
|
||||||
return new String[] {MetadataSchema.DC_SCHEMA, "provenance", null};
|
return new String[] {MetadataSchemaEnum.DC.getName(), "provenance", null};
|
||||||
case "license":
|
case "license":
|
||||||
return new String[] {MetadataSchema.DC_SCHEMA, "rights", "license"};
|
return new String[] {MetadataSchemaEnum.DC.getName(), "rights", "license"};
|
||||||
case "user_format_description":
|
case "user_format_description":
|
||||||
return new String[] {MetadataSchema.DC_SCHEMA, "format", null};
|
return new String[] {MetadataSchemaEnum.DC.getName(), "format", null};
|
||||||
case "source":
|
case "source":
|
||||||
return new String[] {MetadataSchema.DC_SCHEMA, "source", null};
|
return new String[] {MetadataSchemaEnum.DC.getName(), "source", null};
|
||||||
case "firstname":
|
case "firstname":
|
||||||
return new String[] {"eperson", "firstname", null};
|
return new String[] {"eperson", "firstname", null};
|
||||||
case "lastname":
|
case "lastname":
|
||||||
|
68
dspace-api/src/main/java/org/dspace/content/Entity.java
Normal file
68
dspace-api/src/main/java/org/dspace/content/Entity.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents an Entity object. An Entity object has an Item that it describes with a list
|
||||||
|
* of relationships that it includes as well.
|
||||||
|
*/
|
||||||
|
public class Entity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Item that is being described by this Entity
|
||||||
|
*/
|
||||||
|
private Item item;
|
||||||
|
/**
|
||||||
|
* The relationships for the Item that is included in this Entity
|
||||||
|
*/
|
||||||
|
private List<Relationship> relationships;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor for the Entity object
|
||||||
|
* @param item The Item to be included in this Entity object as a property
|
||||||
|
* @param relationshipList The list of relationships
|
||||||
|
*/
|
||||||
|
public Entity(Item item,List<Relationship> relationshipList) {
|
||||||
|
setItem(item);
|
||||||
|
setRelationships(relationshipList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the Item for this Entity object
|
||||||
|
* @return The Item that is described in this Entity object
|
||||||
|
*/
|
||||||
|
public Item getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the Item for this Entity object
|
||||||
|
* @param item The Item to be set
|
||||||
|
*/
|
||||||
|
public void setItem(Item item) {
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the list of relationships for the Item in this Entity object
|
||||||
|
* @return the list of relationships
|
||||||
|
*/
|
||||||
|
public List<Relationship> getRelationships() {
|
||||||
|
return relationships;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the list of relationships for the Item in this Entity object
|
||||||
|
* @param relationships The list of relationships to be set
|
||||||
|
*/
|
||||||
|
public void setRelationships(List<Relationship> relationships) {
|
||||||
|
this.relationships = relationships;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,142 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dspace.content.service.EntityService;
|
||||||
|
import org.dspace.content.service.EntityTypeService;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
public class EntityServiceImpl implements EntityService {
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected EntityTypeService entityTypeService;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected RelationshipService relationshipService;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected RelationshipTypeService relationshipTypeService;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected ItemService itemService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entity findByItemId(Context context, UUID itemId) throws SQLException {
|
||||||
|
Item item = itemService.find(context, itemId);
|
||||||
|
List<Relationship> relationshipList = relationshipService.findByItem(context, item);
|
||||||
|
return new Entity(item, relationshipList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityType getType(Context context, Entity entity) throws SQLException {
|
||||||
|
Item item = entity.getItem();
|
||||||
|
List<MetadataValue> list = itemService.getMetadata(item, "relationship", "type", null, Item.ANY);
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
return entityTypeService.findByEntityType(context, list.get(0).getValue());
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> getLeftRelations(Context context, Entity entity) {
|
||||||
|
List<Relationship> fullList = entity.getRelationships();
|
||||||
|
List<Relationship> listToReturn = new LinkedList<>();
|
||||||
|
for (Relationship relationship : fullList) {
|
||||||
|
if (relationship.getLeftItem().getID() == entity.getItem().getID()) {
|
||||||
|
listToReturn.add(relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> getRightRelations(Context context, Entity entity) {
|
||||||
|
List<Relationship> fullList = entity.getRelationships();
|
||||||
|
List<Relationship> listToReturn = new LinkedList<>();
|
||||||
|
for (Relationship relationship : fullList) {
|
||||||
|
if (relationship.getRightItem().getID() == entity.getItem().getID()) {
|
||||||
|
listToReturn.add(relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException {
|
||||||
|
List<Relationship> listToReturn = new LinkedList<>();
|
||||||
|
List<Relationship> relationshipList = relationshipService.findAll(context);
|
||||||
|
for (Relationship relationship : relationshipList) {
|
||||||
|
RelationshipType relationshipType = relationship.getRelationshipType();
|
||||||
|
if (StringUtils.equals(relationshipType.getLeftLabel(),label) ||
|
||||||
|
StringUtils.equals(relationshipType.getRightLabel(),label)) {
|
||||||
|
listToReturn.add(relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity) throws SQLException {
|
||||||
|
EntityType entityType = this.getType(context, entity);
|
||||||
|
List<RelationshipType> listToReturn = new LinkedList<>();
|
||||||
|
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) {
|
||||||
|
if (relationshipType.getLeftType().getID() == entityType.getID() ||
|
||||||
|
relationshipType.getRightType().getID() == entityType.getID()) {
|
||||||
|
listToReturn.add(relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity) throws SQLException {
|
||||||
|
EntityType entityType = this.getType(context, entity);
|
||||||
|
List<RelationshipType> listToReturn = new LinkedList<>();
|
||||||
|
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) {
|
||||||
|
if (relationshipType.getLeftType().getID() == entityType.getID()) {
|
||||||
|
listToReturn.add(relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity) throws SQLException {
|
||||||
|
EntityType entityType = this.getType(context, entity);
|
||||||
|
List<RelationshipType> listToReturn = new LinkedList<>();
|
||||||
|
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) {
|
||||||
|
if (relationshipType.getRightType().getID() == entityType.getID()) {
|
||||||
|
listToReturn.add(relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> getRelationshipTypesByLabel(Context context, String label) throws SQLException {
|
||||||
|
List<RelationshipType> listToReturn = new LinkedList<>();
|
||||||
|
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) {
|
||||||
|
if (StringUtils.equals(relationshipType.getLeftLabel(),label) ||
|
||||||
|
StringUtils.equals(relationshipType.getRightLabel(),label)) {
|
||||||
|
listToReturn.add(relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
}
|
77
dspace-api/src/main/java/org/dspace/content/EntityType.java
Normal file
77
dspace-api/src/main/java/org/dspace/content/EntityType.java
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.dspace.core.ReloadableEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class representing an EntityType
|
||||||
|
* This class contains an Integer ID that will be the unique value for this class and also the primary key
|
||||||
|
* This also has a label that will be used to identify what kind of EntityType this object is
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "entity_type")
|
||||||
|
public class EntityType implements ReloadableEntity<Integer> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Integer ID used as a primary key for this database object.
|
||||||
|
* This is generated by a sequence
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "entity_type_id_seq")
|
||||||
|
@SequenceGenerator(name = "entity_type_id_seq", sequenceName = "entity_type_id_seq", allocationSize = 1)
|
||||||
|
@Column(name = "id", unique = true, nullable = false, insertable = true, updatable = false)
|
||||||
|
protected Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The String label field for the entity type
|
||||||
|
* This cannot be null
|
||||||
|
*/
|
||||||
|
@Column(name = "label", nullable = false)
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The standard setter for the ID of this EntityType
|
||||||
|
* @param id The ID that this EntityType's ID will be set to
|
||||||
|
*/
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The standard getter for the label of this EntityType
|
||||||
|
* @return The label for this EntityType
|
||||||
|
*/
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The standard setter for the label of this EntityType
|
||||||
|
* @param label The label that this EntityType's label will be set to
|
||||||
|
*/
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The standard getter for the ID of this EntityType
|
||||||
|
* @return The ID for this EntityType
|
||||||
|
*/
|
||||||
|
public Integer getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,94 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
|
import org.dspace.content.dao.EntityTypeDAO;
|
||||||
|
import org.dspace.content.service.EntityTypeService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
public class EntityTypeServiceImpl implements EntityTypeService {
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected EntityTypeDAO entityTypeDAO;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected AuthorizeService authorizeService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityType findByEntityType(Context context,String entityType) throws SQLException {
|
||||||
|
return entityTypeDAO.findByEntityType(context, entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EntityType> findAll(Context context) throws SQLException {
|
||||||
|
return entityTypeDAO.findAll(context, EntityType.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityType create(Context context) throws SQLException, AuthorizeException {
|
||||||
|
if (!authorizeService.isAdmin(context)) {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"Only administrators can modify entityType");
|
||||||
|
}
|
||||||
|
return entityTypeDAO.create(context, new EntityType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityType create(Context context, String entityTypeString) throws SQLException, AuthorizeException {
|
||||||
|
if (!authorizeService.isAdmin(context)) {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"Only administrators can modify entityType");
|
||||||
|
}
|
||||||
|
EntityType entityType = new EntityType();
|
||||||
|
entityType.setLabel(entityTypeString);
|
||||||
|
return entityTypeDAO.create(context, entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityType find(Context context,int id) throws SQLException {
|
||||||
|
EntityType entityType = entityTypeDAO.findByID(context, EntityType.class, id);
|
||||||
|
return entityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Context context,EntityType entityType) throws SQLException, AuthorizeException {
|
||||||
|
update(context,Collections.singletonList(entityType));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Context context,List<EntityType> entityTypes) throws SQLException, AuthorizeException {
|
||||||
|
if (CollectionUtils.isNotEmpty(entityTypes)) {
|
||||||
|
// Check authorisation - only administrators can change formats
|
||||||
|
if (!authorizeService.isAdmin(context)) {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"Only administrators can modify entityType");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (EntityType entityType : entityTypes) {
|
||||||
|
entityTypeDAO.save(context, entityType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Context context,EntityType entityType) throws SQLException, AuthorizeException {
|
||||||
|
if (!authorizeService.isAdmin(context)) {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"Only administrators can delete entityType");
|
||||||
|
}
|
||||||
|
entityTypeDAO.delete(context, entityType);
|
||||||
|
}
|
||||||
|
}
|
@@ -104,9 +104,10 @@ public class InstallItemServiceImpl implements InstallItemService {
|
|||||||
|
|
||||||
// If the item doesn't have a date.accessioned, set it to today
|
// If the item doesn't have a date.accessioned, set it to today
|
||||||
List<MetadataValue> dateAccessioned = itemService
|
List<MetadataValue> dateAccessioned = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "date", "accessioned", Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "date", "accessioned", Item.ANY);
|
||||||
if (dateAccessioned.isEmpty()) {
|
if (dateAccessioned.isEmpty()) {
|
||||||
itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "accessioned", null, now.toString());
|
itemService.addMetadata(c, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"date", "accessioned", null, now.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If issue date is set as "today" (literal string), then set it to current date
|
// If issue date is set as "today" (literal string), then set it to current date
|
||||||
@@ -114,8 +115,8 @@ public class InstallItemServiceImpl implements InstallItemService {
|
|||||||
// replacing "today" with today's date.
|
// replacing "today" with today's date.
|
||||||
// NOTE: As of DSpace 4.0, DSpace no longer sets an issue date by default
|
// NOTE: As of DSpace 4.0, DSpace no longer sets an issue date by default
|
||||||
List<MetadataValue> currentDateIssued = itemService
|
List<MetadataValue> currentDateIssued = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "date", "issued", Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "date", "issued", Item.ANY);
|
||||||
itemService.clearMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "issued", Item.ANY);
|
itemService.clearMetadata(c, item, MetadataSchemaEnum.DC.getName(), "date", "issued", Item.ANY);
|
||||||
for (MetadataValue dcv : currentDateIssued) {
|
for (MetadataValue dcv : currentDateIssued) {
|
||||||
if (dcv.getValue() != null && dcv.getValue().equalsIgnoreCase("today")) {
|
if (dcv.getValue() != null && dcv.getValue().equalsIgnoreCase("today")) {
|
||||||
DCDate issued = new DCDate(now.getYear(), now.getMonth(), now.getDay(), -1, -1, -1);
|
DCDate issued = new DCDate(now.getYear(), now.getMonth(), now.getDay(), -1, -1, -1);
|
||||||
@@ -127,7 +128,8 @@ public class InstallItemServiceImpl implements InstallItemService {
|
|||||||
|
|
||||||
// Record that the item was restored
|
// Record that the item was restored
|
||||||
String provDescription = "Restored into DSpace on " + now + " (GMT).";
|
String provDescription = "Restored into DSpace on " + now + " (GMT).";
|
||||||
itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription);
|
itemService.addMetadata(c, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"description", "provenance", "en", provDescription);
|
||||||
|
|
||||||
return finishItem(c, item, is);
|
return finishItem(c, item, is);
|
||||||
}
|
}
|
||||||
@@ -137,14 +139,16 @@ public class InstallItemServiceImpl implements InstallItemService {
|
|||||||
throws SQLException, AuthorizeException {
|
throws SQLException, AuthorizeException {
|
||||||
// create accession date
|
// create accession date
|
||||||
DCDate now = DCDate.getCurrent();
|
DCDate now = DCDate.getCurrent();
|
||||||
itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "accessioned", null, now.toString());
|
itemService.addMetadata(c, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"date", "accessioned", null, now.toString());
|
||||||
|
|
||||||
// add date available if not under embargo, otherwise it will
|
// add date available if not under embargo, otherwise it will
|
||||||
// be set when the embargo is lifted.
|
// be set when the embargo is lifted.
|
||||||
// this will flush out fatal embargo metadata
|
// this will flush out fatal embargo metadata
|
||||||
// problems before we set inArchive.
|
// problems before we set inArchive.
|
||||||
if (embargoService.getEmbargoTermsAsDate(c, item) == null) {
|
if (embargoService.getEmbargoTermsAsDate(c, item) == null) {
|
||||||
itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "available", null, now.toString());
|
itemService.addMetadata(c, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"date", "available", null, now.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If issue date is set as "today" (literal string), then set it to current date
|
// If issue date is set as "today" (literal string), then set it to current date
|
||||||
@@ -152,8 +156,8 @@ public class InstallItemServiceImpl implements InstallItemService {
|
|||||||
// replacing "today" with today's date.
|
// replacing "today" with today's date.
|
||||||
// NOTE: As of DSpace 4.0, DSpace no longer sets an issue date by default
|
// NOTE: As of DSpace 4.0, DSpace no longer sets an issue date by default
|
||||||
List<MetadataValue> currentDateIssued = itemService
|
List<MetadataValue> currentDateIssued = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "date", "issued", Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "date", "issued", Item.ANY);
|
||||||
itemService.clearMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "issued", Item.ANY);
|
itemService.clearMetadata(c, item, MetadataSchemaEnum.DC.getName(), "date", "issued", Item.ANY);
|
||||||
for (MetadataValue dcv : currentDateIssued) {
|
for (MetadataValue dcv : currentDateIssued) {
|
||||||
if (dcv.getValue() != null && dcv.getValue().equalsIgnoreCase("today")) {
|
if (dcv.getValue() != null && dcv.getValue().equalsIgnoreCase("today")) {
|
||||||
DCDate issued = new DCDate(now.getYear(), now.getMonth(), now.getDay(), -1, -1, -1);
|
DCDate issued = new DCDate(now.getYear(), now.getMonth(), now.getDay(), -1, -1, -1);
|
||||||
@@ -178,7 +182,8 @@ public class InstallItemServiceImpl implements InstallItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add provenance description
|
// Add provenance description
|
||||||
itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription);
|
itemService.addMetadata(c, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"description", "provenance", "en", provDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -362,7 +362,7 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport, Ind
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return getItemService().getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
return getItemService().getMetadataFirstValue(this, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -174,7 +174,7 @@ public class ItemComparator implements Comparator, Serializable {
|
|||||||
protected String getValue(Item item) {
|
protected String getValue(Item item) {
|
||||||
// The overall array and each element are guaranteed non-null
|
// The overall array and each element are guaranteed non-null
|
||||||
List<MetadataValue> dcvalues = itemService
|
List<MetadataValue> dcvalues = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, element, qualifier, language);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), element, qualifier, language);
|
||||||
|
|
||||||
if (dcvalues.isEmpty()) {
|
if (dcvalues.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
@@ -11,10 +11,16 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -36,7 +42,10 @@ import org.dspace.content.service.CommunityService;
|
|||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.content.service.MetadataSchemaService;
|
import org.dspace.content.service.MetadataSchemaService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
|
import org.dspace.content.virtual.VirtualMetadataConfiguration;
|
||||||
|
import org.dspace.content.virtual.VirtualMetadataPopulator;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
@@ -102,6 +111,11 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected WorkflowItemService workflowItemService;
|
protected WorkflowItemService workflowItemService;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected RelationshipService relationshipService;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected VirtualMetadataPopulator virtualMetadataPopulator;
|
||||||
|
|
||||||
protected ItemServiceImpl() {
|
protected ItemServiceImpl() {
|
||||||
super();
|
super();
|
||||||
@@ -230,10 +244,10 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
|
||||||
MetadataField metadataField = metadataFieldService
|
MetadataField metadataField = metadataFieldService
|
||||||
.findByElement(context, MetadataSchema.DC_SCHEMA, "date", "accessioned");
|
.findByElement(context, MetadataSchemaEnum.DC.getName(), "date", "accessioned");
|
||||||
if (metadataField == null) {
|
if (metadataField == null) {
|
||||||
throw new IllegalArgumentException(
|
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);
|
return itemDAO.findBySubmitter(context, eperson, metadataField, limit);
|
||||||
@@ -554,7 +568,7 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
|
|
||||||
prov.append(installItemService.getBitstreamProvenanceMessage(context, item));
|
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 item in DB
|
||||||
update(context, item);
|
update(context, item);
|
||||||
@@ -609,7 +623,7 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
// bitstream checksums
|
// bitstream checksums
|
||||||
prov.append(installItemService.getBitstreamProvenanceMessage(context, item));
|
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 item in DB
|
||||||
update(context, item);
|
update(context, item);
|
||||||
@@ -1206,7 +1220,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
@Override
|
@Override
|
||||||
public int countAllItems(Context context, Collection collection) throws SQLException {
|
public int countAllItems(Context context, Collection collection) throws SQLException {
|
||||||
return itemDAO.countItems(context, collection, true, false) + itemDAO.countItems(context, collection,
|
return itemDAO.countItems(context, collection, true, false) + itemDAO.countItems(context, collection,
|
||||||
false, true);
|
false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1225,7 +1239,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
|
|
||||||
// Now, lets count unique items across that list of collections
|
// Now, lets count unique items across that list of collections
|
||||||
return itemDAO.countItems(context, collections, true, false) + itemDAO.countItems(context, collections,
|
return itemDAO.countItems(context, collections, true, false) + itemDAO.countItems(context, collections,
|
||||||
false, true);
|
false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1294,4 +1308,246 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* This method will return a list of MetadataValue objects that contains all the regular
|
||||||
|
* metadata of the item passed along in the parameters as well as all the virtual metadata
|
||||||
|
* which will be generated and processed together with the {@link VirtualMetadataPopulator}
|
||||||
|
* by processing the item's relationships
|
||||||
|
* @param item the Item to be processed
|
||||||
|
* @param schema the schema for the metadata field. <em>Must</em> match
|
||||||
|
* the <code>name</code> of an existing metadata schema.
|
||||||
|
* @param element the element name. <code>DSpaceObject.ANY</code> matches any
|
||||||
|
* element. <code>null</code> doesn't really make sense as all
|
||||||
|
* metadata must have an element.
|
||||||
|
* @param qualifier the qualifier. <code>null</code> means unqualified, and
|
||||||
|
* <code>DSpaceObject.ANY</code> means any qualifier (including
|
||||||
|
* unqualified.)
|
||||||
|
* @param lang the ISO639 language code, optionally followed by an underscore
|
||||||
|
* and the ISO3166 country code. <code>null</code> means only
|
||||||
|
* values with no language are returned, and
|
||||||
|
* <code>DSpaceObject.ANY</code> means values with any country code or
|
||||||
|
* no country code are returned.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<MetadataValue> getMetadata(Item item, String schema, String element, String qualifier, String lang) {
|
||||||
|
return this.getMetadata(item, schema, element, qualifier, lang, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipMetadataValue> getRelationshipMetadata(Item item, boolean enableVirtualMetadata) {
|
||||||
|
Context context = new Context();
|
||||||
|
List<RelationshipMetadataValue> fullMetadataValueList = new LinkedList<>();
|
||||||
|
try {
|
||||||
|
List<MetadataValue> list = item.getMetadata();
|
||||||
|
String entityType = getEntityTypeStringFromMetadata(list);
|
||||||
|
if (StringUtils.isNotBlank(entityType)) {
|
||||||
|
List<Relationship> relationships = relationshipService.findByItem(context, item);
|
||||||
|
for (Relationship relationship : relationships) {
|
||||||
|
fullMetadataValueList
|
||||||
|
.addAll(handleItemRelationship(context, item, entityType, relationship, enableVirtualMetadata));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Lookup for Relationships for item with uuid: " + item.getID() + " caused DSpace to crash", e);
|
||||||
|
}
|
||||||
|
return fullMetadataValueList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
listToReturn = sortMetadataValueList(listToReturn);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finalList = sortMetadataValueList(finalList);
|
||||||
|
return finalList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will sort the List of MetadataValue objects based on the MetadataSchema, MetadataField Element,
|
||||||
|
* MetadataField Qualifier and MetadataField Place in that order.
|
||||||
|
* @param listToReturn The list to be sorted
|
||||||
|
* @return The list sorted on those criteria
|
||||||
|
*/
|
||||||
|
private List<MetadataValue> sortMetadataValueList(List<MetadataValue> listToReturn) {
|
||||||
|
Comparator<MetadataValue> comparator = Comparator.comparing(
|
||||||
|
metadataValue -> metadataValue.getMetadataField().getMetadataSchema().getName(),
|
||||||
|
Comparator.nullsFirst(Comparator.naturalOrder()));
|
||||||
|
comparator = comparator.thenComparing(metadataValue -> metadataValue.getMetadataField().getElement(),
|
||||||
|
Comparator.nullsFirst(Comparator.naturalOrder()));
|
||||||
|
comparator = comparator.thenComparing(metadataValue -> metadataValue.getMetadataField().getQualifier(),
|
||||||
|
Comparator.nullsFirst(Comparator.naturalOrder()));
|
||||||
|
comparator = comparator.thenComparing(metadataValue -> metadataValue.getPlace(),
|
||||||
|
Comparator.nullsFirst(Comparator.naturalOrder()));
|
||||||
|
|
||||||
|
Stream<MetadataValue> metadataValueStream = listToReturn.stream().sorted(comparator);
|
||||||
|
listToReturn = metadataValueStream.collect(Collectors.toList());
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
//This method processes the Relationship of an Item and will return a list of RelationshipMetadataValue objects
|
||||||
|
//that are generated for this specfic relationship for the item through the config in VirtualMetadataPopulator
|
||||||
|
private List<RelationshipMetadataValue> handleItemRelationship(Context context, Item item, String entityType,
|
||||||
|
Relationship relationship,
|
||||||
|
boolean enableVirtualMetadata)
|
||||||
|
throws SQLException {
|
||||||
|
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
|
||||||
|
RelationshipType relationshipType = relationship.getRelationshipType();
|
||||||
|
HashMap<String, VirtualMetadataConfiguration> hashMaps;
|
||||||
|
String relationName = "";
|
||||||
|
Item otherItem = null;
|
||||||
|
int place = 0;
|
||||||
|
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
|
||||||
|
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getLeftLabel());
|
||||||
|
otherItem = relationship.getRightItem();
|
||||||
|
relationName = relationship.getRelationshipType().getLeftLabel();
|
||||||
|
place = relationship.getLeftPlace();
|
||||||
|
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) {
|
||||||
|
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getRightLabel());
|
||||||
|
otherItem = relationship.getLeftItem();
|
||||||
|
relationName = relationship.getRelationshipType().getRightLabel();
|
||||||
|
place = relationship.getRightPlace();
|
||||||
|
} else {
|
||||||
|
//No virtual metadata can be created
|
||||||
|
return resultingMetadataValueList;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hashMaps != null && enableVirtualMetadata) {
|
||||||
|
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMapping(context, item, hashMaps,
|
||||||
|
otherItem, relationName,
|
||||||
|
relationship.getID(), place));
|
||||||
|
}
|
||||||
|
RelationshipMetadataValue relationMetadataFromOtherItem =
|
||||||
|
getRelationMetadataFromOtherItem(context, otherItem, relationName, relationship.getID(), place);
|
||||||
|
if (relationMetadataFromOtherItem != null) {
|
||||||
|
resultingMetadataValueList.add(relationMetadataFromOtherItem);
|
||||||
|
}
|
||||||
|
return resultingMetadataValueList;
|
||||||
|
}
|
||||||
|
|
||||||
|
//This method will retrieve a list of RelationshipMetadataValue objects based on the config passed along in the
|
||||||
|
//hashmaps parameter. The beans will be used to retrieve the values for the RelationshipMetadataValue objects
|
||||||
|
//and the keys of the hashmap will be used to construct the RelationshipMetadataValue object.
|
||||||
|
private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMapping(Context context, Item item,
|
||||||
|
HashMap<String, VirtualMetadataConfiguration> hashMaps,
|
||||||
|
Item otherItem, String relationName,
|
||||||
|
Integer relationshipId, int place)
|
||||||
|
throws SQLException {
|
||||||
|
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
|
||||||
|
for (Map.Entry<String, VirtualMetadataConfiguration> entry : hashMaps.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
VirtualMetadataConfiguration virtualBean = entry.getValue();
|
||||||
|
|
||||||
|
for (String value : virtualBean.getValues(context, otherItem)) {
|
||||||
|
RelationshipMetadataValue metadataValue = constructMetadataValue(context, key);
|
||||||
|
if (metadataValue != null) {
|
||||||
|
metadataValue = constructResultingMetadataValue(item, value, metadataValue, relationshipId);
|
||||||
|
metadataValue.setUseForPlace(virtualBean.getUseForPlace());
|
||||||
|
metadataValue.setPlace(place);
|
||||||
|
if (StringUtils.isNotBlank(metadataValue.getValue())) {
|
||||||
|
resultingMetadataValueList.add(metadataValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultingMetadataValueList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RelationshipMetadataValue getRelationMetadataFromOtherItem(Context context, Item otherItem,
|
||||||
|
String relationName,
|
||||||
|
Integer relationshipId, int place) {
|
||||||
|
RelationshipMetadataValue metadataValue = constructMetadataValue(context,
|
||||||
|
MetadataSchemaEnum.RELATION
|
||||||
|
.getName() + "." + relationName);
|
||||||
|
if (metadataValue != null) {
|
||||||
|
metadataValue.setAuthority(Constants.VIRTUAL_AUTHORITY_PREFIX + relationshipId);
|
||||||
|
metadataValue.setValue(otherItem.getID().toString());
|
||||||
|
metadataValue.setPlace(place);
|
||||||
|
return metadataValue;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getEntityTypeStringFromMetadata(List<MetadataValue> list) {
|
||||||
|
for (MetadataValue mdv : list) {
|
||||||
|
if (StringUtils.equals(mdv.getMetadataField().getMetadataSchema().getName(),
|
||||||
|
"relationship")
|
||||||
|
&& StringUtils.equals(mdv.getMetadataField().getElement(),
|
||||||
|
"type")) {
|
||||||
|
|
||||||
|
return mdv.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RelationshipMetadataValue constructResultingMetadataValue(Item item, String value,
|
||||||
|
RelationshipMetadataValue metadataValue,
|
||||||
|
Integer relationshipId) {
|
||||||
|
metadataValue.setValue(value);
|
||||||
|
metadataValue.setAuthority(Constants.VIRTUAL_AUTHORITY_PREFIX + relationshipId);
|
||||||
|
metadataValue.setConfidence(-1);
|
||||||
|
metadataValue.setDSpaceObject(item);
|
||||||
|
return metadataValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//This method will construct a RelationshipMetadataValue object with proper schema, element and qualifier based
|
||||||
|
//on the key String parameter passed along to it
|
||||||
|
private RelationshipMetadataValue constructMetadataValue(Context context, String key) {
|
||||||
|
String[] splittedKey = key.split("\\.");
|
||||||
|
RelationshipMetadataValue metadataValue = new RelationshipMetadataValue();
|
||||||
|
String metadataSchema = splittedKey.length > 0 ? splittedKey[0] : null;
|
||||||
|
String metadataElement = splittedKey.length > 1 ? splittedKey[1] : null;
|
||||||
|
String metadataQualifier = splittedKey.length > 2 ? splittedKey[2] : null;
|
||||||
|
MetadataField metadataField = null;
|
||||||
|
try {
|
||||||
|
metadataField = metadataFieldService
|
||||||
|
.findByElement(context, metadataSchema, metadataElement, metadataQualifier);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Could not find element with MetadataSchema: " + metadataSchema +
|
||||||
|
", MetadataElement: " + metadataElement + " and MetadataQualifier: " + metadataQualifier, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (metadataField == null) {
|
||||||
|
log.error("A MetadataValue was attempted to construct with MetadataField for parameters: " +
|
||||||
|
"metadataschema: {}, metadataelement: {}, metadataqualifier: {}",
|
||||||
|
metadataSchema, metadataElement, metadataQualifier);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
metadataValue.setMetadataField(metadataField);
|
||||||
|
metadataValue.setLanguage(Item.ANY);
|
||||||
|
return metadataValue;
|
||||||
|
}
|
||||||
|
}
|
@@ -39,10 +39,6 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
||||||
@Table(name = "metadataschemaregistry")
|
@Table(name = "metadataschemaregistry")
|
||||||
public class MetadataSchema implements ReloadableEntity<Integer> {
|
public class MetadataSchema implements ReloadableEntity<Integer> {
|
||||||
/**
|
|
||||||
* Short Name of built-in Dublin Core schema.
|
|
||||||
*/
|
|
||||||
public static final String DC_SCHEMA = "dc";
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "metadata_schema_id")
|
@Column(name = "metadata_schema_id")
|
||||||
|
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an enum that holds track of a few special MetadataSchema types.
|
||||||
|
* It is important to note that this list is not exhaustive for the MetadataSchema
|
||||||
|
* types and different MetadataSchema can easily be made.
|
||||||
|
* These MetadataSchema objects are simply required.
|
||||||
|
*/
|
||||||
|
public enum MetadataSchemaEnum {
|
||||||
|
DC("dc"), RELATION("relation");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The String representation of the MetadataSchemaEnum
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor with the name parameter
|
||||||
|
* @param name The name parameter
|
||||||
|
*/
|
||||||
|
MetadataSchemaEnum(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the String representation of the enum object
|
||||||
|
* @return The name of the enum object
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
180
dspace-api/src/main/java/org/dspace/content/Relationship.java
Normal file
180
dspace-api/src/main/java/org/dspace/content/Relationship.java
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.core.ReloadableEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a relationship
|
||||||
|
* It has a leftItem and a rightItem which are both DSpaceObjects
|
||||||
|
* that have a specified RelationshipType that links them together
|
||||||
|
* It also has a left and right place column that works just like a normal DSpace metadata place column
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "relationship")
|
||||||
|
public class Relationship implements ReloadableEntity<Integer> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Integer ID field for this object
|
||||||
|
* This is automatically generated
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "relationship_id_seq")
|
||||||
|
@SequenceGenerator(name = "relationship_id_seq", sequenceName = "relationship_id_seq", allocationSize = 1)
|
||||||
|
@Column(name = "id", unique = true, nullable = false, insertable = true, updatable = false)
|
||||||
|
protected Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The leftItem property for the Relationship object.
|
||||||
|
* This leftItem is a DSpaceObject and is stored as an ID
|
||||||
|
*/
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "left_id", nullable = false)
|
||||||
|
private Item leftItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The relationshipType property for this Relationship object
|
||||||
|
* This is stored as an ID in the database
|
||||||
|
*/
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "type_id", nullable = false)
|
||||||
|
private RelationshipType relationshipType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The rightItem property for the Relationship object.
|
||||||
|
* This rightItem is a DSpaceObject and is stored as an ID
|
||||||
|
*/
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "right_id", nullable = false)
|
||||||
|
private Item rightItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Integer to describe the left place for this relationship
|
||||||
|
*/
|
||||||
|
@Column(name = "left_place")
|
||||||
|
private int leftPlace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Integer to describe the right place for this relationship
|
||||||
|
*/
|
||||||
|
@Column(name = "right_place")
|
||||||
|
private int rightPlace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Protected constructor, create object using:
|
||||||
|
* {@link org.dspace.content.service.RelationshipService#create(Context)} }
|
||||||
|
*/
|
||||||
|
protected Relationship() {}
|
||||||
|
/**
|
||||||
|
* Standard setter for the ID field
|
||||||
|
* @param id The ID to be set
|
||||||
|
*/
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the leftItem field
|
||||||
|
* @return The leftItem Item object in this relationship
|
||||||
|
*/
|
||||||
|
public Item getLeftItem() {
|
||||||
|
return leftItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the leftItem field
|
||||||
|
* @param leftItem The leftItem Item object that the leftItem field should be set to
|
||||||
|
*/
|
||||||
|
public void setLeftItem(Item leftItem) {
|
||||||
|
this.leftItem = leftItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the relationshipType field
|
||||||
|
* @return The relationshipType RelationshipType object in this relationship
|
||||||
|
*/
|
||||||
|
public RelationshipType getRelationshipType() {
|
||||||
|
return relationshipType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the relationshipType field for the Relationship
|
||||||
|
* @param relationshipType The relationshipType that will be set in this Relationship
|
||||||
|
*/
|
||||||
|
public void setRelationshipType(RelationshipType relationshipType) {
|
||||||
|
this.relationshipType = relationshipType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the rightItem Item object in this Relationship
|
||||||
|
* @return the rightItem Item object
|
||||||
|
*/
|
||||||
|
public Item getRightItem() {
|
||||||
|
return rightItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the rightItem Item object in this Relationship
|
||||||
|
* @param rightItem The rightItem Item object that will be used in this relationship
|
||||||
|
*/
|
||||||
|
public void setRightItem(Item rightItem) {
|
||||||
|
this.rightItem = rightItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the leftPlace Integer in this Relationship
|
||||||
|
* @return The leftPlace integer for this relationship
|
||||||
|
*/
|
||||||
|
public int getLeftPlace() {
|
||||||
|
return leftPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the leftPlace Integer in this Relationship
|
||||||
|
* @param leftPlace the leftPlace Integer that will be used in this relationship
|
||||||
|
*/
|
||||||
|
public void setLeftPlace(int leftPlace) {
|
||||||
|
this.leftPlace = leftPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the rightPlace Integer in this Relationship
|
||||||
|
* @return the rightPlace integer for this relationship
|
||||||
|
*/
|
||||||
|
public int getRightPlace() {
|
||||||
|
return rightPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the rightPlace Integer in this Relationship
|
||||||
|
* @param rightPlace the rightPlace Integer that will be used in this relationship
|
||||||
|
*/
|
||||||
|
public void setRightPlace(int rightPlace) {
|
||||||
|
this.rightPlace = rightPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the ID for this Relationship
|
||||||
|
* @return The ID of this relationship
|
||||||
|
*/
|
||||||
|
public Integer getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used as a representation of MetadataValues for the MetadataValues that are derived from the
|
||||||
|
* Relationships that the item has. This includes the useForPlace property which we'll have to use to determine
|
||||||
|
* whether these Values should be counted for place calculation on both the native MetadataValues and the
|
||||||
|
* Relationship's place attributes.
|
||||||
|
*/
|
||||||
|
public class RelationshipMetadataValue extends MetadataValue {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property determines whether this RelationshipMetadataValue should be used in place calculation or not
|
||||||
|
*/
|
||||||
|
private boolean useForPlace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property determines whether this RelationshipMetadataValue should be used in place calculation or not.
|
||||||
|
* This is retrieved from Spring configuration when constructing RelationshipMetadataValues. This Spring
|
||||||
|
* configuration is located in the core-services.xml configuration file.
|
||||||
|
* Putting this property on true will imply that we're now mixing plain-text metadatavalues with the
|
||||||
|
* metadatavalues that are constructed through Relationships with regards to the place attribute.
|
||||||
|
* For example, currently the RelationshipMetadataValue dc.contributor.author that is constructed through a
|
||||||
|
* Relationship for a Publication will have its useForPlace set to true. This means that the place
|
||||||
|
* calculation will take both these RelationshipMetadataValues into account together with the normal
|
||||||
|
* plain text metadatavalues.
|
||||||
|
* On the other hand, the journal name, volume and issue number which are constructed through a
|
||||||
|
* Relationship from a Publication to a journal issue will have its useForPlace set to false.
|
||||||
|
* This would typically be set to false for any singular metadata, and for any relationship where no mixing
|
||||||
|
* with plain text variables is applicable
|
||||||
|
*/
|
||||||
|
public boolean isUseForPlace() {
|
||||||
|
return useForPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseForPlace(boolean useForPlace) {
|
||||||
|
this.useForPlace = useForPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (! (obj instanceof RelationshipMetadataValue)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final RelationshipMetadataValue other = (RelationshipMetadataValue) obj;
|
||||||
|
if (this.isUseForPlace() != other.isUseForPlace()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.equals(obj);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,414 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
|
import org.dspace.content.dao.RelationshipDAO;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
|
import org.dspace.content.virtual.VirtualMetadataPopulator;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
public class RelationshipServiceImpl implements RelationshipService {
|
||||||
|
|
||||||
|
private static final Logger log = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected RelationshipDAO relationshipDAO;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected AuthorizeService authorizeService;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected ItemService itemService;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected RelationshipTypeService relationshipTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VirtualMetadataPopulator virtualMetadataPopulator;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Relationship create(Context context) throws SQLException, AuthorizeException {
|
||||||
|
if (!authorizeService.isAdmin(context)) {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"Only administrators can modify relationship");
|
||||||
|
}
|
||||||
|
return relationshipDAO.create(context, new Relationship());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Relationship create(Context c, Item leftItem, Item rightItem, RelationshipType relationshipType,
|
||||||
|
int leftPlace, int rightPlace) throws AuthorizeException, SQLException {
|
||||||
|
Relationship relationship = new Relationship();
|
||||||
|
relationship.setLeftItem(leftItem);
|
||||||
|
relationship.setRightItem(rightItem);
|
||||||
|
relationship.setRelationshipType(relationshipType);
|
||||||
|
relationship.setLeftPlace(leftPlace);
|
||||||
|
relationship.setRightPlace(rightPlace);
|
||||||
|
return create(c, relationship);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Relationship create(Context context, Relationship relationship) throws SQLException, AuthorizeException {
|
||||||
|
if (isRelationshipValidToCreate(context, relationship)) {
|
||||||
|
if (authorizeService.authorizeActionBoolean(context, relationship.getLeftItem(), Constants.WRITE) ||
|
||||||
|
authorizeService.authorizeActionBoolean(context, relationship.getRightItem(), Constants.WRITE)) {
|
||||||
|
updatePlaceInRelationship(context, relationship, true);
|
||||||
|
return relationshipDAO.create(context, relationship);
|
||||||
|
} else {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"You do not have write rights on this relationship's items");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("The relationship given was not valid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updatePlaceInRelationship(Context context, Relationship relationship, boolean isCreation)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
Item leftItem = relationship.getLeftItem();
|
||||||
|
List<Relationship> leftRelationships = findByItemAndRelationshipType(context,
|
||||||
|
leftItem,
|
||||||
|
relationship.getRelationshipType(), true);
|
||||||
|
Item rightItem = relationship.getRightItem();
|
||||||
|
List<Relationship> rightRelationships = findByItemAndRelationshipType(context,
|
||||||
|
rightItem,
|
||||||
|
relationship.getRelationshipType(),
|
||||||
|
false);
|
||||||
|
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
//If useForPlace for the leftlabel is false for the relationshipType,
|
||||||
|
// we need to sort the relationships here based on leftplace.
|
||||||
|
if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), true)) {
|
||||||
|
if (!leftRelationships.isEmpty()) {
|
||||||
|
leftRelationships.sort(Comparator.comparingInt(Relationship::getLeftPlace));
|
||||||
|
for (int i = 0; i < leftRelationships.size(); i++) {
|
||||||
|
leftRelationships.get(i).setLeftPlace(i);
|
||||||
|
}
|
||||||
|
relationship.setLeftPlace(leftRelationships.size());
|
||||||
|
} else {
|
||||||
|
relationship.setLeftPlace(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updateItem(context, leftItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//If useForPlace for the rightLabel is false for the relationshipType,
|
||||||
|
// we need to sort the relationships here based on the rightplace.
|
||||||
|
if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), false)) {
|
||||||
|
if (!rightRelationships.isEmpty()) {
|
||||||
|
rightRelationships.sort(Comparator.comparingInt(Relationship::getRightPlace));
|
||||||
|
for (int i = 0; i < rightRelationships.size(); i++) {
|
||||||
|
rightRelationships.get(i).setRightPlace(i);
|
||||||
|
}
|
||||||
|
relationship.setRightPlace(rightRelationships.size());
|
||||||
|
} else {
|
||||||
|
relationship.setRightPlace(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
updateItem(context, rightItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCreation) {
|
||||||
|
handleCreationPlaces(context, relationship);
|
||||||
|
}
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateItem(Context context, Item relatedItem)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
relatedItem.setMetadataModified();
|
||||||
|
itemService.update(context, relatedItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Sets the places for the Relationship properly if the updatePlaceInRelationship was called for a new creation
|
||||||
|
//of this Relationship
|
||||||
|
private void handleCreationPlaces(Context context, Relationship relationship) throws SQLException {
|
||||||
|
List<Relationship> leftRelationships;
|
||||||
|
List<Relationship> rightRelationships;
|
||||||
|
leftRelationships = findByItemAndRelationshipType(context,
|
||||||
|
relationship.getLeftItem(),
|
||||||
|
relationship.getRelationshipType(), true);
|
||||||
|
rightRelationships = findByItemAndRelationshipType(context,
|
||||||
|
relationship.getRightItem(),
|
||||||
|
relationship.getRelationshipType(),
|
||||||
|
false);
|
||||||
|
leftRelationships.sort((o1, o2) -> o2.getLeftPlace() - o1.getLeftPlace());
|
||||||
|
rightRelationships.sort((o1, o2) -> o2.getRightPlace() - o1.getRightPlace());
|
||||||
|
|
||||||
|
if (!leftRelationships.isEmpty()) {
|
||||||
|
relationship.setLeftPlace(leftRelationships.get(0).getLeftPlace() + 1);
|
||||||
|
} else {
|
||||||
|
relationship.setLeftPlace(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rightRelationships.isEmpty()) {
|
||||||
|
relationship.setRightPlace(rightRelationships.get(0).getRightPlace() + 1);
|
||||||
|
} else {
|
||||||
|
relationship.setRightPlace(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int findLeftPlaceByLeftItem(Context context, Item item) throws SQLException {
|
||||||
|
return relationshipDAO.findLeftPlaceByLeftItem(context, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int findRightPlaceByRightItem(Context context, Item item) throws SQLException {
|
||||||
|
return relationshipDAO.findRightPlaceByRightItem(context, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isRelationshipValidToCreate(Context context, Relationship relationship) throws SQLException {
|
||||||
|
RelationshipType relationshipType = relationship.getRelationshipType();
|
||||||
|
|
||||||
|
if (!verifyEntityTypes(relationship.getLeftItem(), relationshipType.getLeftType())) {
|
||||||
|
log.warn("The relationship has been deemed invalid since the leftItem" +
|
||||||
|
" and leftType do no match on entityType");
|
||||||
|
logRelationshipTypeDetailsForError(relationshipType);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!verifyEntityTypes(relationship.getRightItem(), relationshipType.getRightType())) {
|
||||||
|
log.warn("The relationship has been deemed invalid since the rightItem" +
|
||||||
|
" and rightType do no match on entityType");
|
||||||
|
logRelationshipTypeDetailsForError(relationshipType);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!verifyMaxCardinality(context, relationship.getLeftItem(),
|
||||||
|
relationshipType.getLeftMaxCardinality(), relationshipType)) {
|
||||||
|
log.warn("The relationship has been deemed invalid since the left item has more" +
|
||||||
|
" relationships than the left max cardinality allows after we'd store this relationship");
|
||||||
|
logRelationshipTypeDetailsForError(relationshipType);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!verifyMaxCardinality(context, relationship.getRightItem(),
|
||||||
|
relationshipType.getRightMaxCardinality(), relationshipType)) {
|
||||||
|
log.warn("The relationship has been deemed invalid since the right item has more" +
|
||||||
|
" relationships than the right max cardinality allows after we'd store this relationship");
|
||||||
|
logRelationshipTypeDetailsForError(relationshipType);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logRelationshipTypeDetailsForError(RelationshipType relationshipType) {
|
||||||
|
log.warn("The relationshipType's ID is: " + relationshipType.getID());
|
||||||
|
log.warn("The relationshipType's left label is: " + relationshipType.getLeftLabel());
|
||||||
|
log.warn("The relationshipType's right label is: " + relationshipType.getRightLabel());
|
||||||
|
log.warn("The relationshipType's left entityType label is: " + relationshipType.getLeftType().getLabel());
|
||||||
|
log.warn("The relationshipType's right entityType label is: " + relationshipType.getRightType().getLabel());
|
||||||
|
log.warn("The relationshipType's left min cardinality is: " + relationshipType.getLeftMinCardinality());
|
||||||
|
log.warn("The relationshipType's left max cardinality is: " + relationshipType.getLeftMaxCardinality());
|
||||||
|
log.warn("The relationshipType's right min cardinality is: " + relationshipType.getRightMinCardinality());
|
||||||
|
log.warn("The relationshipType's right max cardinality is: " + relationshipType.getRightMaxCardinality());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean verifyMaxCardinality(Context context, Item itemToProcess,
|
||||||
|
Integer maxCardinality,
|
||||||
|
RelationshipType relationshipType) throws SQLException {
|
||||||
|
List<Relationship> rightRelationships = findByItemAndRelationshipType(context, itemToProcess, relationshipType,
|
||||||
|
false);
|
||||||
|
if (maxCardinality != null && rightRelationships.size() >= maxCardinality) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean verifyEntityTypes(Item itemToProcess, EntityType entityTypeToProcess) {
|
||||||
|
List<MetadataValue> list = itemService.getMetadata(itemToProcess, "relationship", "type", null, Item.ANY);
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String leftEntityType = list.get(0).getValue();
|
||||||
|
return StringUtils.equals(leftEntityType, entityTypeToProcess.getLabel());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Relationship find(Context context, int id) throws SQLException {
|
||||||
|
Relationship relationship = relationshipDAO.findByID(context, Relationship.class, id);
|
||||||
|
return relationship;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> findByItem(Context context, Item item) throws SQLException {
|
||||||
|
|
||||||
|
List<Relationship> list = relationshipDAO.findByItem(context, item);
|
||||||
|
|
||||||
|
list.sort((o1, o2) -> {
|
||||||
|
int relationshipType = o1.getRelationshipType().getLeftLabel()
|
||||||
|
.compareTo(o2.getRelationshipType().getLeftLabel());
|
||||||
|
if (relationshipType != 0) {
|
||||||
|
return relationshipType;
|
||||||
|
} else {
|
||||||
|
if (o1.getLeftItem() == item) {
|
||||||
|
return o1.getLeftPlace() - o2.getLeftPlace();
|
||||||
|
} else {
|
||||||
|
return o1.getRightPlace() - o2.getRightPlace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> findAll(Context context) throws SQLException {
|
||||||
|
return relationshipDAO.findAll(context, Relationship.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Context context, Relationship relationship) throws SQLException, AuthorizeException {
|
||||||
|
update(context, Collections.singletonList(relationship));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Context context, List<Relationship> relationships) throws SQLException, AuthorizeException {
|
||||||
|
if (CollectionUtils.isNotEmpty(relationships)) {
|
||||||
|
for (Relationship relationship : relationships) {
|
||||||
|
if (authorizeService.authorizeActionBoolean(context, relationship.getLeftItem(), Constants.WRITE) ||
|
||||||
|
authorizeService.authorizeActionBoolean(context, relationship.getRightItem(), Constants.WRITE)) {
|
||||||
|
if (isRelationshipValidToCreate(context, relationship)) {
|
||||||
|
relationshipDAO.save(context, relationship);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new AuthorizeException("You do not have write rights on this relationship's items");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Context context, Relationship relationship) throws SQLException, AuthorizeException {
|
||||||
|
if (isRelationshipValidToDelete(context, relationship)) {
|
||||||
|
// To delete a relationship, a user must have WRITE permissions on one of the related Items
|
||||||
|
if (authorizeService.authorizeActionBoolean(context, relationship.getLeftItem(), Constants.WRITE) ||
|
||||||
|
authorizeService.authorizeActionBoolean(context, relationship.getRightItem(), Constants.WRITE)) {
|
||||||
|
relationshipDAO.delete(context, relationship);
|
||||||
|
updatePlaceInRelationship(context, relationship, false);
|
||||||
|
} else {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"You do not have write rights on this relationship's items");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("The relationship given was not valid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isRelationshipValidToDelete(Context context, Relationship relationship) throws SQLException {
|
||||||
|
if (relationship == null) {
|
||||||
|
log.warn("The relationship has been deemed invalid since the relation was null");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (relationship.getID() == null) {
|
||||||
|
log.warn("The relationship has been deemed invalid since the ID" +
|
||||||
|
" off the given relationship was null");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.find(context, relationship.getID()) == null) {
|
||||||
|
log.warn("The relationship has been deemed invalid since the relationship" +
|
||||||
|
" is not present in the DB with the current ID");
|
||||||
|
logRelationshipTypeDetailsForError(relationship.getRelationshipType());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!checkMinCardinality(context, relationship.getLeftItem(),
|
||||||
|
relationship, relationship.getRelationshipType().getLeftMinCardinality(), true)) {
|
||||||
|
log.warn("The relationship has been deemed invalid since the leftMinCardinality" +
|
||||||
|
" constraint would be violated upon deletion");
|
||||||
|
logRelationshipTypeDetailsForError(relationship.getRelationshipType());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkMinCardinality(context, relationship.getRightItem(),
|
||||||
|
relationship, relationship.getRelationshipType().getRightMinCardinality(), false)) {
|
||||||
|
log.warn("The relationship has been deemed invalid since the rightMinCardinality" +
|
||||||
|
" constraint would be violated upon deletion");
|
||||||
|
logRelationshipTypeDetailsForError(relationship.getRelationshipType());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkMinCardinality(Context context, Item item,
|
||||||
|
Relationship relationship,
|
||||||
|
Integer minCardinality, boolean isLeft) throws SQLException {
|
||||||
|
List<Relationship> list = this
|
||||||
|
.findByItemAndRelationshipType(context, item, relationship.getRelationshipType(), isLeft);
|
||||||
|
if (minCardinality != null && !(list.size() > minCardinality)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Relationship> findByItemAndRelationshipType(Context context, Item item,
|
||||||
|
RelationshipType relationshipType, boolean isLeft)
|
||||||
|
|
||||||
|
throws SQLException {
|
||||||
|
List<Relationship> list = this.findByItem(context, item);
|
||||||
|
List<Relationship> listToReturn = new LinkedList<>();
|
||||||
|
for (Relationship relationship : list) {
|
||||||
|
if (isLeft) {
|
||||||
|
if (StringUtils
|
||||||
|
.equals(relationship.getRelationshipType().getLeftLabel(), relationshipType.getLeftLabel())) {
|
||||||
|
listToReturn.add(relationship);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (StringUtils
|
||||||
|
.equals(relationship.getRelationshipType().getRightLabel(), relationshipType.getRightLabel())) {
|
||||||
|
listToReturn.add(relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> findByItemAndRelationshipType(Context context, Item item,
|
||||||
|
RelationshipType relationshipType)
|
||||||
|
|
||||||
|
throws SQLException {
|
||||||
|
List<Relationship> list = this.findByItem(context, item);
|
||||||
|
List<Relationship> listToReturn = new LinkedList<>();
|
||||||
|
for (Relationship relationship : list) {
|
||||||
|
if (relationship.getRelationshipType().equals(relationshipType)) {
|
||||||
|
listToReturn.add(relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType)
|
||||||
|
throws SQLException {
|
||||||
|
return relationshipDAO.findByRelationshipType(context, relationshipType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,254 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.core.ReloadableEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class representing a RelationshipType
|
||||||
|
* This class contains an Integer ID that will be the unique value and primary key in the database.
|
||||||
|
* This key is automatically generated
|
||||||
|
* It also has a leftType and rightType EntityType that describes the relationshipType together with a leftLabel and
|
||||||
|
* rightLabel.
|
||||||
|
* The cardinality properties describe how many of each relations this relationshipType can support
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "relationship_type")
|
||||||
|
public class RelationshipType implements ReloadableEntity<Integer> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Integer ID used as a primary key for this database object.
|
||||||
|
* This is generated by a sequence
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "relationship_type_id_seq")
|
||||||
|
@SequenceGenerator(name = "relationship_type_id_seq", sequenceName = "relationship_type_id_seq", allocationSize = 1)
|
||||||
|
@Column(name = "id", unique = true, nullable = false, insertable = true, updatable = false)
|
||||||
|
protected Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The leftType EntityType field for the relationshipType
|
||||||
|
* This is stored as an ID and cannot be null
|
||||||
|
*/
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST})
|
||||||
|
@JoinColumn(name = "left_type", nullable = false)
|
||||||
|
private EntityType leftType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The rightType EntityType field for the relationshipType
|
||||||
|
* This is stored as an ID and cannot be null
|
||||||
|
*/
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST})
|
||||||
|
@JoinColumn(name = "right_type", nullable = false)
|
||||||
|
private EntityType rightType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The leftLabel String field for the relationshipType
|
||||||
|
* This is stored as a String and cannot be null
|
||||||
|
* This is a textual representation of the name of the relationship that this RelationshipType is connected to
|
||||||
|
*/
|
||||||
|
@Column(name = "left_label", nullable = false)
|
||||||
|
private String leftLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The rightLabel String field for the relationshipType
|
||||||
|
* This is stored as a String and cannot be null
|
||||||
|
* This is a textual representation of the name of the relationship that this RelationshipType is connected to
|
||||||
|
*/
|
||||||
|
@Column(name = "right_label", nullable = false)
|
||||||
|
private String rightLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum amount of relations for the leftItem that need to be present at all times
|
||||||
|
* This is stored as an Integer
|
||||||
|
*/
|
||||||
|
@Column(name = "left_min_cardinality")
|
||||||
|
private Integer leftMinCardinality;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum amount of relations for the leftItem that can to be present at all times
|
||||||
|
* This is stored as an Integer
|
||||||
|
*/
|
||||||
|
@Column(name = "left_max_cardinality")
|
||||||
|
private Integer leftMaxCardinality;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum amount of relations for the rightItem that need to be present at all times
|
||||||
|
*/
|
||||||
|
@Column(name = "right_min_cardinality")
|
||||||
|
private Integer rightMinCardinality;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tha maximum amount of relations for the rightItem that can be present at all times
|
||||||
|
*/
|
||||||
|
@Column(name = "right_max_cardinality")
|
||||||
|
private Integer rightMaxCardinality;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Protected constructor, create object using:
|
||||||
|
* {@link org.dspace.content.service.RelationshipTypeService#create(Context)} }
|
||||||
|
*/
|
||||||
|
protected RelationshipType() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the ID of this RelationshipType
|
||||||
|
* @param id The ID that this RelationshipType should receive
|
||||||
|
*/
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for The leftType EntityType for this RelationshipType
|
||||||
|
* @return The leftType EntityType of this RelationshipType
|
||||||
|
*/
|
||||||
|
public EntityType getLeftType() {
|
||||||
|
return leftType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the leftType EntityType for this RelationshipType
|
||||||
|
* @param leftType The leftType EntityType that this RelationshipType should receive
|
||||||
|
*/
|
||||||
|
public void setLeftType(EntityType leftType) {
|
||||||
|
this.leftType = leftType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for The rightType EntityType for this RelationshipType
|
||||||
|
* @return The rightType EntityType of this RelationshipType
|
||||||
|
*/
|
||||||
|
public EntityType getRightType() {
|
||||||
|
return rightType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the rightType EntityType for this RelationshipType
|
||||||
|
* @param rightType The rightType EntityType that this RelationshipType should receive
|
||||||
|
*/
|
||||||
|
public void setRightType(EntityType rightType) {
|
||||||
|
this.rightType = rightType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the leftLabel String for this RelationshipType
|
||||||
|
* @return The leftLabel String of this RelationshipType
|
||||||
|
*/
|
||||||
|
public String getLeftLabel() {
|
||||||
|
return leftLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the leftLabel String for this RelationshipType
|
||||||
|
* @param leftLabel The leftLabel String that this RelationshipType should receive
|
||||||
|
*/
|
||||||
|
public void setLeftLabel(String leftLabel) {
|
||||||
|
this.leftLabel = leftLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the rightLabel String for this RelationshipType
|
||||||
|
* @return The rightLabel String of this RelationshipType
|
||||||
|
*/
|
||||||
|
public String getRightLabel() {
|
||||||
|
return rightLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the rightLabel String for this RelationshipType
|
||||||
|
* @param rightLabel The rightLabel String that this RelationshipType should receive
|
||||||
|
*/
|
||||||
|
public void setRightLabel(String rightLabel) {
|
||||||
|
this.rightLabel = rightLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the leftMinCardinality Integer for this RelationshipType
|
||||||
|
* @return the leftMinCardinality Integer of this RelationshipType
|
||||||
|
*/
|
||||||
|
public Integer getLeftMinCardinality() {
|
||||||
|
return leftMinCardinality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the leftMinCardinality Integer for this RelationshipType
|
||||||
|
* @param leftMinCardinality The leftMinCardinality Integer that this RelationshipType should recieve
|
||||||
|
*/
|
||||||
|
public void setLeftMinCardinality(Integer leftMinCardinality) {
|
||||||
|
this.leftMinCardinality = leftMinCardinality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the leftMaxCardinality Integer for this RelationshipType
|
||||||
|
* @return the leftMaxCardinality Integer of this RelationshipType
|
||||||
|
*/
|
||||||
|
public Integer getLeftMaxCardinality() {
|
||||||
|
return leftMaxCardinality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the leftMaxCardinality Integer for this RelationshipType
|
||||||
|
* @param leftMaxCardinality The leftMaxCardinality Integer that this RelationshipType should recieve
|
||||||
|
*/
|
||||||
|
public void setLeftMaxCardinality(Integer leftMaxCardinality) {
|
||||||
|
this.leftMaxCardinality = leftMaxCardinality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the rightMinCardinality Integer for this RelationshipType
|
||||||
|
* @return the rightMinCardinality Integer of this RelationshipType
|
||||||
|
*/
|
||||||
|
public Integer getRightMinCardinality() {
|
||||||
|
return rightMinCardinality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the rightMinCardinality Integer for this RelationshipType
|
||||||
|
* @param rightMinCardinality The rightMinCardinality Integer that this RelationshipType should recieve
|
||||||
|
*/
|
||||||
|
public void setRightMinCardinality(Integer rightMinCardinality) {
|
||||||
|
this.rightMinCardinality = rightMinCardinality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the rightMaxCardinality Integer for this RelationshipType
|
||||||
|
* @return the rightMaxCardinality Integer of this RelationshipType
|
||||||
|
*/
|
||||||
|
public Integer getRightMaxCardinality() {
|
||||||
|
return rightMaxCardinality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the rightMaxCardinality Integer for this RelationshipType
|
||||||
|
* @param rightMaxCardinality The rightMaxCardinality Integer that this RelationshipType should recieve
|
||||||
|
*/
|
||||||
|
public void setRightMaxCardinality(Integer rightMaxCardinality) {
|
||||||
|
this.rightMaxCardinality = rightMaxCardinality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the ID of this RelationshipType
|
||||||
|
* @return The ID of this RelationshipType
|
||||||
|
*/
|
||||||
|
public Integer getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,123 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
|
import org.dspace.content.dao.RelationshipTypeDAO;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
public class RelationshipTypeServiceImpl implements RelationshipTypeService {
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected RelationshipTypeDAO relationshipTypeDAO;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected AuthorizeService authorizeService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RelationshipType create(Context context) throws SQLException, AuthorizeException {
|
||||||
|
if (!authorizeService.isAdmin(context)) {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"Only administrators can modify relationshipType");
|
||||||
|
}
|
||||||
|
return relationshipTypeDAO.create(context, new RelationshipType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RelationshipType create(Context context, RelationshipType relationshipType)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
if (!authorizeService.isAdmin(context)) {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"Only administrators can modify relationshipType");
|
||||||
|
}
|
||||||
|
return relationshipTypeDAO.create(context, relationshipType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType,
|
||||||
|
String leftLabel,String rightLabel) throws SQLException {
|
||||||
|
return relationshipTypeDAO.findByTypesAndLabels(context, leftType, rightType, leftLabel, rightLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> findAll(Context context) throws SQLException {
|
||||||
|
return relationshipTypeDAO.findAll(context, RelationshipType.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> findByLeftOrRightLabel(Context context, String label) throws SQLException {
|
||||||
|
return relationshipTypeDAO.findByLeftOrRightLabel(context, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException {
|
||||||
|
return relationshipTypeDAO.findByEntityType(context, entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RelationshipType create(Context context, EntityType leftEntityType, EntityType rightEntityType,
|
||||||
|
String leftLabel, String rightLabel, Integer leftCardinalityMinInteger,
|
||||||
|
Integer leftCardinalityMaxInteger, Integer rightCardinalityMinInteger,
|
||||||
|
Integer rightCardinalityMaxInteger)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
RelationshipType relationshipType = new RelationshipType();
|
||||||
|
relationshipType.setLeftType(leftEntityType);
|
||||||
|
relationshipType.setRightType(rightEntityType);
|
||||||
|
relationshipType.setLeftLabel(leftLabel);
|
||||||
|
relationshipType.setRightLabel(rightLabel);
|
||||||
|
relationshipType.setLeftMinCardinality(leftCardinalityMinInteger);
|
||||||
|
relationshipType.setLeftMaxCardinality(leftCardinalityMaxInteger);
|
||||||
|
relationshipType.setRightMinCardinality(rightCardinalityMinInteger);
|
||||||
|
relationshipType.setRightMaxCardinality(rightCardinalityMaxInteger);
|
||||||
|
return create(context, relationshipType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RelationshipType find(Context context,int id) throws SQLException {
|
||||||
|
return relationshipTypeDAO.findByID(context, RelationshipType.class, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Context context,RelationshipType relationshipType) throws SQLException, AuthorizeException {
|
||||||
|
update(context,Collections.singletonList(relationshipType));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Context context,List<RelationshipType> relationshipTypes)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
if (CollectionUtils.isNotEmpty(relationshipTypes)) {
|
||||||
|
// Check authorisation - only administrators can change formats
|
||||||
|
if (!authorizeService.isAdmin(context)) {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"Only administrators can modify RelationshipType");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (RelationshipType relationshipType : relationshipTypes) {
|
||||||
|
relationshipTypeDAO.save(context, relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Context context,RelationshipType relationshipType) throws SQLException, AuthorizeException {
|
||||||
|
if (!authorizeService.isAdmin(context)) {
|
||||||
|
throw new AuthorizeException(
|
||||||
|
"Only administrators can delete entityType");
|
||||||
|
}
|
||||||
|
relationshipTypeDAO.delete(context, relationshipType);
|
||||||
|
}
|
||||||
|
}
|
@@ -15,7 +15,7 @@ import org.dspace.authorize.AuthorizeException;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -67,7 +67,8 @@ public class OAIDCIngestionCrosswalk
|
|||||||
lang = element.getAttributeValue("lang");
|
lang = element.getAttributeValue("lang");
|
||||||
}
|
}
|
||||||
MetadataField metadataField = metadataValidator
|
MetadataField metadataField = metadataValidator
|
||||||
.checkMetadata(context, MetadataSchema.DC_SCHEMA, element.getName(), null, createMissingMetadataFields);
|
.checkMetadata(context, MetadataSchemaEnum.DC.getName(),
|
||||||
|
element.getName(), null, createMissingMetadataFields);
|
||||||
itemService.addMetadata(context, item, metadataField, lang, element.getText());
|
itemService.addMetadata(context, item, metadataField, lang, element.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ import org.dspace.content.Bitstream;
|
|||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
@@ -122,7 +122,7 @@ public class OREDisseminationCrosswalk
|
|||||||
|
|
||||||
Element aggLink;
|
Element aggLink;
|
||||||
List<MetadataValue> uris = itemService
|
List<MetadataValue> uris = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "identifier", "uri", Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "identifier", "uri", Item.ANY);
|
||||||
for (MetadataValue uri : uris) {
|
for (MetadataValue uri : uris) {
|
||||||
aggLink = new Element("link", ATOM_NS);
|
aggLink = new Element("link", ATOM_NS);
|
||||||
aggLink.setAttribute("rel", "alternate");
|
aggLink.setAttribute("rel", "alternate");
|
||||||
@@ -159,7 +159,8 @@ public class OREDisseminationCrosswalk
|
|||||||
|
|
||||||
// Information about the aggregation (item) itself
|
// Information about the aggregation (item) itself
|
||||||
Element aggTitle = new Element("title", ATOM_NS);
|
Element aggTitle = new Element("title", ATOM_NS);
|
||||||
List<MetadataValue> titles = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
List<MetadataValue> titles = itemService.getMetadata(item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, Item.ANY);
|
||||||
if (titles != null && titles.size() > 0) {
|
if (titles != null && titles.size() > 0) {
|
||||||
aggTitle.addContent(titles.get(0).getValue());
|
aggTitle.addContent(titles.get(0).getValue());
|
||||||
} else {
|
} else {
|
||||||
@@ -170,7 +171,7 @@ public class OREDisseminationCrosswalk
|
|||||||
Element aggAuthor;
|
Element aggAuthor;
|
||||||
Element aggAuthorName;
|
Element aggAuthorName;
|
||||||
List<MetadataValue> authors = itemService
|
List<MetadataValue> authors = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "contributor", "author", Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "contributor", "author", Item.ANY);
|
||||||
for (MetadataValue author : authors) {
|
for (MetadataValue author : authors) {
|
||||||
aggAuthor = new Element("author", ATOM_NS);
|
aggAuthor = new Element("author", ATOM_NS);
|
||||||
aggAuthorName = new Element("name", ATOM_NS);
|
aggAuthorName = new Element("name", ATOM_NS);
|
||||||
|
@@ -26,6 +26,7 @@ import org.dspace.content.DSpaceObject;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
@@ -353,7 +354,7 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
|||||||
|
|
||||||
// only complain about missing elements in the DC schema:
|
// only complain about missing elements in the DC schema:
|
||||||
if (elt == null) {
|
if (elt == null) {
|
||||||
if (metadataField.getMetadataSchema().getName().equals(MetadataSchema.DC_SCHEMA)) {
|
if (metadataField.getMetadataSchema().getName().equals(MetadataSchemaEnum.DC.getName())) {
|
||||||
log.warn("WARNING: " + myName + ": No QDC mapping for \"" + qdc + "\"");
|
log.warn("WARNING: " + myName + ": No QDC mapping for \"" + qdc + "\"");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -17,7 +17,7 @@ import org.dspace.authorize.AuthorizeException;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
@@ -101,7 +101,7 @@ public class SimpleDCDisseminationCrosswalk extends SelfNamedPlugin
|
|||||||
|
|
||||||
Item item = (Item) dso;
|
Item item = (Item) dso;
|
||||||
List<MetadataValue> allDC = itemService
|
List<MetadataValue> allDC = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, Item.ANY, Item.ANY, Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), Item.ANY, Item.ANY, Item.ANY);
|
||||||
|
|
||||||
List<Element> dcl = new ArrayList<Element>(allDC.size());
|
List<Element> dcl = new ArrayList<Element>(allDC.size());
|
||||||
|
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.dao;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.core.GenericDAO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database Access Object Interface class for the EntityType object
|
||||||
|
* The implementation of this class is responsible for all database calls for the EntityType object and is autowired by
|
||||||
|
* spring
|
||||||
|
* This class should only be accessed from a single service and should never be exposed outside of the API
|
||||||
|
*/
|
||||||
|
public interface EntityTypeDAO extends GenericDAO<EntityType> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the EntityType object that has the given entityType String
|
||||||
|
* as label
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entityType The entityType String that will be matched on to find
|
||||||
|
* the correct EntityType
|
||||||
|
* @return The EntityType object that has the entityType String as label
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
public EntityType findByEntityType(Context context, String entityType) throws SQLException;
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,72 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.dao;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.Relationship;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.core.GenericDAO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database Access Object Interface class for the Relationship object
|
||||||
|
* The implementation of this class is responsible for all
|
||||||
|
* database calls for the Relationship object and is autowired by spring
|
||||||
|
* This class should only be accessed from a single service and should never be exposed outside of the API
|
||||||
|
*/
|
||||||
|
public interface RelationshipDAO extends GenericDAO<Relationship> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a list of Relationship objects that have the given Item object
|
||||||
|
* as a leftItem or a rightItem
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The item that should be either a leftItem or a rightItem of all
|
||||||
|
* the Relationship objects in the returned list
|
||||||
|
* @return The list of Relationship objects that contain either a left or a
|
||||||
|
* right item that is equal to the given item
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<Relationship> findByItem(Context context,Item item) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the highest leftplace integer for all the relationships where this
|
||||||
|
* item is the leftitem so that we can set a proper leftplace attribute on the next relationship
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The item to be matched on leftItem
|
||||||
|
* @return The integer for the highest leftPlace value for all the relatonship objects
|
||||||
|
* that have the given item as leftItem
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
int findLeftPlaceByLeftItem(Context context,Item item) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the highest rightplace integer for all the relationships where this
|
||||||
|
* item is the rightitem so that we can set a proper rightplace attribute on the next relationship
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The item to be matched on rightItem
|
||||||
|
* @return The integer for the highest rightPlace value for all the relatonship objects
|
||||||
|
* that have the given item as rightItem
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
int findRightPlaceByRightItem(Context context,Item item) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a list of Relationship objects for the given RelationshipType object.
|
||||||
|
* It will construct a list of all Relationship objects that have the given RelationshipType object
|
||||||
|
* as the relationshipType property
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param relationshipType The RelationshipType object to be checked on
|
||||||
|
* @return A list of Relationship objects that have the given RelationshipType object as the
|
||||||
|
* relationshipType property
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException;
|
||||||
|
}
|
@@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.dao;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.core.GenericDAO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database Access Object Interface class for the RelationshipType object
|
||||||
|
* The implementation of this class is responsible for all
|
||||||
|
* database calls for the RelationshipType object and is autowired by spring
|
||||||
|
* This class should only be accessed from a single service and should never be exposed outside of the API
|
||||||
|
*/
|
||||||
|
public interface RelationshipTypeDAO extends GenericDAO<RelationshipType> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to retrieve the RelationshipType object that has the same
|
||||||
|
* leftType, rightType, leftLabel and rightLabel as given in the parameters
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param leftType The leftType EntityType object to be matched in the query
|
||||||
|
* @param rightType The rightType EntityType object to be matched in the query
|
||||||
|
* @param leftLabel The leftLabel String to be matched in the query
|
||||||
|
* @param rightLabel The rightLabel String to be matched in the query
|
||||||
|
* @return The RelationshipType object that matches all the given parameters
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
RelationshipType findByTypesAndLabels(Context context,
|
||||||
|
EntityType leftType,EntityType rightType,String leftLabel,String rightLabel)
|
||||||
|
throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will return a list of RelationshipType objects for which the given label is equal to
|
||||||
|
* either the leftLabel or rightLabel.
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param label The label that will be used to check on
|
||||||
|
* @return A list of RelationshipType objects that have the given label as either the leftLabel or rightLabel
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<RelationshipType> findByLeftOrRightLabel(Context context, String label) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will return a list of RelationshipType objects for which the given EntityType object is equal
|
||||||
|
* to the leftType or rightType
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entityType The EntityType object that will be used to check on
|
||||||
|
* @return The list of RelationshipType objects that have the given EntityType object
|
||||||
|
* as either a leftType or rightType
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException;
|
||||||
|
}
|
@@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.dao.impl;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
|
import org.dspace.content.EntityType_;
|
||||||
|
import org.dspace.content.dao.EntityTypeDAO;
|
||||||
|
import org.dspace.core.AbstractHibernateDAO;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
|
public class EntityTypeDAOImpl extends AbstractHibernateDAO<EntityType> implements EntityTypeDAO {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityType findByEntityType(Context context, String entityType) throws SQLException {
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, EntityType.class);
|
||||||
|
Root<EntityType> entityTypeRoot = criteriaQuery.from(EntityType.class);
|
||||||
|
criteriaQuery.select(entityTypeRoot);
|
||||||
|
criteriaQuery.where(criteriaBuilder.equal(criteriaBuilder.upper(entityTypeRoot.get(EntityType_.label)),
|
||||||
|
entityType.toUpperCase()));
|
||||||
|
return uniqueResult(context, criteriaQuery, true, EntityType.class, -1, -1);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.dao.impl;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.Relationship;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
import org.dspace.content.Relationship_;
|
||||||
|
import org.dspace.content.dao.RelationshipDAO;
|
||||||
|
import org.dspace.core.AbstractHibernateDAO;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
|
public class RelationshipDAOImpl extends AbstractHibernateDAO<Relationship> implements RelationshipDAO {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> findByItem(Context context, Item item) throws SQLException {
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class);
|
||||||
|
Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class);
|
||||||
|
criteriaQuery.select(relationshipRoot);
|
||||||
|
criteriaQuery
|
||||||
|
.where(criteriaBuilder.or(criteriaBuilder.equal(relationshipRoot.get(Relationship_.leftItem), item),
|
||||||
|
criteriaBuilder.equal(relationshipRoot.get(Relationship_.rightItem), item)));
|
||||||
|
return list(context, criteriaQuery, false, Relationship.class, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int findLeftPlaceByLeftItem(Context context, Item item) throws SQLException {
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class);
|
||||||
|
Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class);
|
||||||
|
criteriaQuery.select(relationshipRoot);
|
||||||
|
criteriaQuery.where(criteriaBuilder.equal(relationshipRoot.get(Relationship_.leftItem), item));
|
||||||
|
List<Relationship> list = list(context, criteriaQuery, false, Relationship.class, -1, -1);
|
||||||
|
list.sort((o1, o2) -> o2.getLeftPlace() - o1.getLeftPlace());
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
return list.get(0).getLeftPlace();
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int findRightPlaceByRightItem(Context context, Item item) throws SQLException {
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class);
|
||||||
|
Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class);
|
||||||
|
criteriaQuery.select(relationshipRoot);
|
||||||
|
criteriaQuery.where(criteriaBuilder.equal(relationshipRoot.get(Relationship_.rightItem), item));
|
||||||
|
List<Relationship> list = list(context, criteriaQuery, false, Relationship.class, -1, -1);
|
||||||
|
list.sort((o1, o2) -> o2.getLeftPlace() - o1.getLeftPlace());
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
return list.get(0).getLeftPlace();
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType)
|
||||||
|
throws SQLException {
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class);
|
||||||
|
Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class);
|
||||||
|
criteriaQuery.select(relationshipRoot);
|
||||||
|
criteriaQuery
|
||||||
|
.where(criteriaBuilder.equal(relationshipRoot.get(Relationship_.relationshipType), relationshipType));
|
||||||
|
return list(context, criteriaQuery, true, Relationship.class, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,73 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.dao.impl;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
import org.dspace.content.RelationshipType_;
|
||||||
|
import org.dspace.content.dao.RelationshipTypeDAO;
|
||||||
|
import org.dspace.core.AbstractHibernateDAO;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
|
public class RelationshipTypeDAOImpl extends AbstractHibernateDAO<RelationshipType> implements RelationshipTypeDAO {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RelationshipType findByTypesAndLabels(Context context, EntityType leftType, EntityType rightType,
|
||||||
|
String leftLabel, String rightLabel)
|
||||||
|
throws SQLException {
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class);
|
||||||
|
Root<RelationshipType> relationshipTypeRoot = criteriaQuery.from(RelationshipType.class);
|
||||||
|
criteriaQuery.select(relationshipTypeRoot);
|
||||||
|
criteriaQuery.where(
|
||||||
|
criteriaBuilder.and(criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.leftType), leftType),
|
||||||
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightType), rightType),
|
||||||
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.leftLabel), leftLabel),
|
||||||
|
criteriaBuilder
|
||||||
|
.equal(relationshipTypeRoot.get(RelationshipType_.rightLabel), rightLabel)));
|
||||||
|
return uniqueResult(context, criteriaQuery, false, RelationshipType.class, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> findByLeftOrRightLabel(Context context, String label) throws SQLException {
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class);
|
||||||
|
Root<RelationshipType> relationshipTypeRoot = criteriaQuery.from(RelationshipType.class);
|
||||||
|
criteriaQuery.select(relationshipTypeRoot);
|
||||||
|
criteriaQuery.where(
|
||||||
|
criteriaBuilder.or(
|
||||||
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.leftLabel), label),
|
||||||
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightLabel), label)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return list(context, criteriaQuery, true, RelationshipType.class, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException {
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class);
|
||||||
|
Root<RelationshipType> relationshipTypeRoot = criteriaQuery.from(RelationshipType.class);
|
||||||
|
criteriaQuery.select(relationshipTypeRoot);
|
||||||
|
criteriaQuery.where(
|
||||||
|
criteriaBuilder.or(criteriaBuilder.
|
||||||
|
equal(relationshipTypeRoot.get(RelationshipType_.leftType), entityType),
|
||||||
|
criteriaBuilder
|
||||||
|
.equal(relationshipTypeRoot.get(RelationshipType_.rightType), entityType)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return list(context, criteriaQuery, false, RelationshipType.class, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -20,6 +20,8 @@ import org.dspace.content.service.CollectionService;
|
|||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
||||||
import org.dspace.content.service.DSpaceObjectService;
|
import org.dspace.content.service.DSpaceObjectService;
|
||||||
|
import org.dspace.content.service.EntityService;
|
||||||
|
import org.dspace.content.service.EntityTypeService;
|
||||||
import org.dspace.content.service.InProgressSubmissionService;
|
import org.dspace.content.service.InProgressSubmissionService;
|
||||||
import org.dspace.content.service.IndexableObjectService;
|
import org.dspace.content.service.IndexableObjectService;
|
||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
@@ -27,6 +29,8 @@ import org.dspace.content.service.ItemService;
|
|||||||
import org.dspace.content.service.MetadataFieldService;
|
import org.dspace.content.service.MetadataFieldService;
|
||||||
import org.dspace.content.service.MetadataSchemaService;
|
import org.dspace.content.service.MetadataSchemaService;
|
||||||
import org.dspace.content.service.MetadataValueService;
|
import org.dspace.content.service.MetadataValueService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
import org.dspace.content.service.SiteService;
|
import org.dspace.content.service.SiteService;
|
||||||
import org.dspace.content.service.SupervisedItemService;
|
import org.dspace.content.service.SupervisedItemService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
@@ -80,6 +84,34 @@ public abstract class ContentServiceFactory {
|
|||||||
|
|
||||||
public abstract SiteService getSiteService();
|
public abstract SiteService getSiteService();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the implementation of the RelationshipTypeService interface
|
||||||
|
*
|
||||||
|
* @return the RelationshipTypeService
|
||||||
|
*/
|
||||||
|
public abstract RelationshipTypeService getRelationshipTypeService();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the implementation of the RelationshipService interface
|
||||||
|
*
|
||||||
|
* @return the RelationshipService
|
||||||
|
*/
|
||||||
|
public abstract RelationshipService getRelationshipService();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the implementation of the EntityTypeService interface
|
||||||
|
*
|
||||||
|
* @return the EntityTypeService
|
||||||
|
*/
|
||||||
|
public abstract EntityTypeService getEntityTypeService();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the implementation of the EntityService interface
|
||||||
|
*
|
||||||
|
* @return the EntityService
|
||||||
|
*/
|
||||||
|
public abstract EntityService getEntityService();
|
||||||
|
|
||||||
public InProgressSubmissionService getInProgressSubmissionService(InProgressSubmission inProgressSubmission) {
|
public InProgressSubmissionService getInProgressSubmissionService(InProgressSubmission inProgressSubmission) {
|
||||||
if (inProgressSubmission instanceof WorkspaceItem) {
|
if (inProgressSubmission instanceof WorkspaceItem) {
|
||||||
return getWorkspaceItemService();
|
return getWorkspaceItemService();
|
||||||
|
@@ -17,12 +17,16 @@ import org.dspace.content.service.CollectionService;
|
|||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
||||||
import org.dspace.content.service.DSpaceObjectService;
|
import org.dspace.content.service.DSpaceObjectService;
|
||||||
|
import org.dspace.content.service.EntityService;
|
||||||
|
import org.dspace.content.service.EntityTypeService;
|
||||||
import org.dspace.content.service.IndexableObjectService;
|
import org.dspace.content.service.IndexableObjectService;
|
||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.content.service.MetadataFieldService;
|
import org.dspace.content.service.MetadataFieldService;
|
||||||
import org.dspace.content.service.MetadataSchemaService;
|
import org.dspace.content.service.MetadataSchemaService;
|
||||||
import org.dspace.content.service.MetadataValueService;
|
import org.dspace.content.service.MetadataValueService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
import org.dspace.content.service.SiteService;
|
import org.dspace.content.service.SiteService;
|
||||||
import org.dspace.content.service.SupervisedItemService;
|
import org.dspace.content.service.SupervisedItemService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
@@ -69,6 +73,15 @@ public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
|||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
private RelationshipService relationshipService;
|
||||||
|
@Autowired(required = true)
|
||||||
|
private RelationshipTypeService relationshipTypeService;
|
||||||
|
@Autowired(required = true)
|
||||||
|
private EntityTypeService entityTypeService;
|
||||||
|
@Autowired(required = true)
|
||||||
|
private EntityService entityService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IndexableObjectService> getIndexableObjectServices() {
|
public List<IndexableObjectService> getIndexableObjectServices() {
|
||||||
return new DSpace().getServiceManager().getServicesByType(IndexableObjectService.class);
|
return new DSpace().getServiceManager().getServicesByType(IndexableObjectService.class);
|
||||||
@@ -149,4 +162,24 @@ public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
|||||||
return siteService;
|
return siteService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RelationshipTypeService getRelationshipTypeService() {
|
||||||
|
return relationshipTypeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RelationshipService getRelationshipService() {
|
||||||
|
return relationshipService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityTypeService getEntityTypeService() {
|
||||||
|
return entityTypeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityService getEntityService() {
|
||||||
|
return entityService;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ import org.dspace.content.Collection;
|
|||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.crosswalk.CrosswalkException;
|
import org.dspace.content.crosswalk.CrosswalkException;
|
||||||
import org.dspace.content.crosswalk.MetadataValidationException;
|
import org.dspace.content.crosswalk.MetadataValidationException;
|
||||||
@@ -377,10 +377,11 @@ public class PDFPackager
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("PDF Info dict title=\"" + title + "\"");
|
log.debug("PDF Info dict title=\"" + title + "\"");
|
||||||
}
|
}
|
||||||
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "title", null, "en", title);
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(), "title", null, "en", title);
|
||||||
String value = docinfo.getAuthor();
|
String value = docinfo.getAuthor();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "contributor", "author", null, value);
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"contributor", "author", null, value);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("PDF Info dict author=\"" + value + "\"");
|
log.debug("PDF Info dict author=\"" + value + "\"");
|
||||||
}
|
}
|
||||||
@@ -388,25 +389,29 @@ public class PDFPackager
|
|||||||
|
|
||||||
value = docinfo.getCreator();
|
value = docinfo.getCreator();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "description", "provenance", "en",
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"description", "provenance", "en",
|
||||||
"Application that created the original document: " + value);
|
"Application that created the original document: " + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = docinfo.getProducer();
|
value = docinfo.getProducer();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "description", "provenance", "en",
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"description", "provenance", "en",
|
||||||
"Original document converted to PDF by: " + value);
|
"Original document converted to PDF by: " + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = docinfo.getSubject();
|
value = docinfo.getSubject();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
itemService
|
itemService
|
||||||
.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "description", "abstract", null, value);
|
.addMetadata(context, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"description", "abstract", null, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = docinfo.getKeywords();
|
value = docinfo.getKeywords();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "subject", "other", null, value);
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"subject", "other", null, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take either CreationDate or ModDate as "date.created",
|
// Take either CreationDate or ModDate as "date.created",
|
||||||
@@ -417,7 +422,7 @@ public class PDFPackager
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (calValue != null) {
|
if (calValue != null) {
|
||||||
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "created", null,
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(), "date", "created", null,
|
||||||
(new DCDate(calValue.getTime())).toString());
|
(new DCDate(calValue.getTime())).toString());
|
||||||
}
|
}
|
||||||
itemService.update(context, item);
|
itemService.update(context, item);
|
||||||
|
@@ -30,7 +30,7 @@ import org.dspace.content.Collection;
|
|||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
@@ -158,7 +158,7 @@ public class PackageUtils {
|
|||||||
*/
|
*/
|
||||||
public static void checkItemMetadata(Item item)
|
public static void checkItemMetadata(Item item)
|
||||||
throws PackageValidationException {
|
throws PackageValidationException {
|
||||||
List<MetadataValue> t = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
List<MetadataValue> t = itemService.getMetadata(item, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
|
||||||
if (t == null || t.size() == 0) {
|
if (t == null || t.size() == 0) {
|
||||||
throw new PackageValidationException("Item cannot be created without the required \"title\" DC metadata.");
|
throw new PackageValidationException("Item cannot be created without the required \"title\" DC metadata.");
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,6 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
|||||||
*/
|
*/
|
||||||
public abstract String getName(T dso);
|
public abstract String getName(T dso);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to lookup all Identifiers of this DSpaceObject.
|
* Tries to lookup all Identifiers of this DSpaceObject.
|
||||||
*
|
*
|
||||||
|
@@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.service;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.dspace.content.Entity;
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
|
import org.dspace.content.Relationship;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This Service provides us with a few methods to return objects based on the Entity object.
|
||||||
|
* Since the Entity object isn't a database object, this method mostly outsources to getters for other services
|
||||||
|
* to return the wanted objects to then check for properties on either the list of relationships or the item included
|
||||||
|
* in the Entity.
|
||||||
|
*/
|
||||||
|
public interface EntityService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will construct an Entity object that will be returned with the Item that matches the ItemID that was
|
||||||
|
* passed along
|
||||||
|
* as well as a list of relationships for that Item.
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param itemId The ItemID for the Item that is to be used in the Entity object
|
||||||
|
* @return The constructed Entity object with the Item and the list of relationships
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
Entity findByItemId(Context context, UUID itemId) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the EntityType for the Item that is attached to the Entity that is passed along to this method.
|
||||||
|
* The EntityType String logic is in the Metadata for that Item and will be searched on in the EntityTypeService
|
||||||
|
* to retrieve the actual EntityType object
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entity The Entity object which contains the Item
|
||||||
|
* @return The EntityType that belongs to this Item
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
EntityType getType(Context context, Entity entity) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of relationships, which are attached to the Entity object that is passed along, where the
|
||||||
|
* left item object of each relationship is equal to the Item object of the Entity object that is passed along
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entity The Entity object to be returned
|
||||||
|
* @return The list of relationships that have the Item in the Entity object as their left item
|
||||||
|
*/
|
||||||
|
List<Relationship> getLeftRelations(Context context, Entity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of relationships, which are attached to the Entity object that is passed along, where the
|
||||||
|
* right item object of each relationship is equal to the Item object of the Entity object that is passed along
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entity The Entity object to be returned
|
||||||
|
* @return The list of relationships that have the Item in the Entity object as their right item
|
||||||
|
*/
|
||||||
|
List<Relationship> getRightRelations(Context context, Entity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of relationships for which their relationshiptype has a left or right label that is
|
||||||
|
* equal to the passed along label String
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param label The label that needs to be in the relationshiptype of the relationship
|
||||||
|
* @return The list of relationships that have a relationshiptype with a left or right label
|
||||||
|
* that is equal to the label param
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given
|
||||||
|
* Entity
|
||||||
|
* in either the leftEntityType or the rightEntityType variables
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entity The Entity for which the EntityType should be checked for relationships
|
||||||
|
* @return The list of relationships that each contain a relationshiptype in which there is a right or left
|
||||||
|
* entity type that
|
||||||
|
* is equal to the entity type for the given entity
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given
|
||||||
|
* Entity
|
||||||
|
* in the leftEntityType
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entity The Entity for which the EntityType should be checked for relationships
|
||||||
|
* @return The list of relationships that each contain a relationshiptype in which there is a left entity type that
|
||||||
|
* is equal to the entity type for the given entity
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of relationships that have a relationshiptype that contains the EntityType for the given
|
||||||
|
* Entity
|
||||||
|
* in the rightEntityType
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entity The Entity for which the EntityType should be checked for relationships
|
||||||
|
* @return The list of relationships that each contain a relationshiptype in which there is a right entity type that
|
||||||
|
* is equal to the entity type for the given entity
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a list of RelationshipType objects for which either their left or right label is equal to the
|
||||||
|
* label parameter that's being passed along
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param label The label for which the relationshiptype's labels must be checked
|
||||||
|
* @return The list of relationshiptypes that each contain a left or right label that is equal
|
||||||
|
* to the given label parameter
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<RelationshipType> getRelationshipTypesByLabel(Context context, String label) throws SQLException;
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.service;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.service.DSpaceCRUDService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This Service is used to access the data for EntityTypes through the DAO objects
|
||||||
|
*/
|
||||||
|
public interface EntityTypeService extends DSpaceCRUDService<EntityType> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the EntityType that has the entityType String parameter as label
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entityType The String label that has to match
|
||||||
|
* @return The EntityType that has a String
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
public EntityType findByEntityType(Context context,String entityType) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all the EntityType objects currently in the system
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @return A list of all EntityType objects
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
public List<EntityType> findAll(Context context) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates an EntityType object in the database with the given entityTypeString as it's label
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entityTypeString The label for the newly created EntityType
|
||||||
|
* @return The newly created EntityType
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something geos wrong with authorizations
|
||||||
|
*/
|
||||||
|
public EntityType create(Context context, String entityTypeString) throws SQLException, AuthorizeException;
|
||||||
|
}
|
@@ -23,8 +23,11 @@ import org.dspace.content.Collection;
|
|||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
|
import org.dspace.content.MetadataValue;
|
||||||
|
import org.dspace.content.RelationshipMetadataValue;
|
||||||
import org.dspace.content.Thumbnail;
|
import org.dspace.content.Thumbnail;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
|
import org.dspace.content.virtual.VirtualMetadataPopulator;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
@@ -651,4 +654,69 @@ public interface ItemService
|
|||||||
*/
|
*/
|
||||||
boolean isInProgressSubmission(Context context, Item item) throws SQLException;
|
boolean isInProgressSubmission(Context context, Item item) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method retrieves a list of MetadataValue objects that get constructed from processing
|
||||||
|
* the given Item's Relationships through the config given to the {@link VirtualMetadataPopulator}
|
||||||
|
* @param item The Item that will be processed through it's Relationships
|
||||||
|
* @param enableVirtualMetadata This parameter will determine whether the list of Relationship metadata
|
||||||
|
* should be populated with metadata that is being generated through the
|
||||||
|
* VirtualMetadataPopulator functionality or not
|
||||||
|
* @return The list of MetadataValue objects constructed through the Relationships
|
||||||
|
*/
|
||||||
|
public List<RelationshipMetadataValue> getRelationshipMetadata(Item item, boolean enableVirtualMetadata);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get metadata for the DSpace Object in a chosen schema.
|
||||||
|
* See <code>MetadataSchema</code> for more information about schemas.
|
||||||
|
* Passing in a <code>null</code> value for <code>qualifier</code>
|
||||||
|
* or <code>lang</code> only matches metadata fields where that
|
||||||
|
* qualifier or languages is actually <code>null</code>.
|
||||||
|
* Passing in <code>DSpaceObject.ANY</code>
|
||||||
|
* retrieves all metadata fields with any value for the qualifier or
|
||||||
|
* language, including <code>null</code>
|
||||||
|
* <P>
|
||||||
|
* Examples:
|
||||||
|
* <P>
|
||||||
|
* Return values of the unqualified "title" field, in any language.
|
||||||
|
* Qualified title fields (e.g. "title.uniform") are NOT returned:
|
||||||
|
* <P>
|
||||||
|
* <code>dspaceobject.getMetadataByMetadataString("dc", "title", null, DSpaceObject.ANY );</code>
|
||||||
|
* <P>
|
||||||
|
* Return all US English values of the "title" element, with any qualifier
|
||||||
|
* (including unqualified):
|
||||||
|
* <P>
|
||||||
|
* <code>dspaceobject.getMetadataByMetadataString("dc, "title", DSpaceObject.ANY, "en_US" );</code>
|
||||||
|
* <P>
|
||||||
|
* The ordering of values of a particular element/qualifier/language
|
||||||
|
* combination is significant. When retrieving with wildcards, values of a
|
||||||
|
* particular element/qualifier/language combinations will be adjacent, but
|
||||||
|
* the overall ordering of the combinations is indeterminate.
|
||||||
|
*
|
||||||
|
* If enableVirtualMetadata is set to false, the virtual metadata will not be included
|
||||||
|
*
|
||||||
|
* @param item Item
|
||||||
|
* @param schema the schema for the metadata field. <em>Must</em> match
|
||||||
|
* the <code>name</code> of an existing metadata schema.
|
||||||
|
* @param element the element name. <code>DSpaceObject.ANY</code> matches any
|
||||||
|
* element. <code>null</code> doesn't really make sense as all
|
||||||
|
* metadata must have an element.
|
||||||
|
* @param qualifier the qualifier. <code>null</code> means unqualified, and
|
||||||
|
* <code>DSpaceObject.ANY</code> means any qualifier (including
|
||||||
|
* unqualified.)
|
||||||
|
* @param lang the ISO639 language code, optionally followed by an underscore
|
||||||
|
* and the ISO3166 country code. <code>null</code> means only
|
||||||
|
* values with no language are returned, and
|
||||||
|
* <code>DSpaceObject.ANY</code> means values with any country code or
|
||||||
|
* no country code are returned.
|
||||||
|
* @param enableVirtualMetadata
|
||||||
|
* Enables virtual metadata calculation and inclusion from the
|
||||||
|
* relationships.
|
||||||
|
* @return metadata fields that match the parameters
|
||||||
|
*/
|
||||||
|
public List<MetadataValue> getMetadata(Item item, String schema, String element, String qualifier,
|
||||||
|
String lang, boolean enableVirtualMetadata);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,144 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.service;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.Relationship;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.service.DSpaceCRUDService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This Service will use the DAO classes to access the information about Relationships from the database
|
||||||
|
*/
|
||||||
|
public interface RelationshipService extends DSpaceCRUDService<Relationship> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of Relationships currently in the system for which the given Item is either
|
||||||
|
* a leftItem or a rightItem object
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The Item that has to be the left or right item for the relationship to be included in the list
|
||||||
|
* @return The list of relationships for which each relationship adheres to the above listed constraint
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
public List<Relationship> findByItem(Context context,Item item) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the full list of relationships currently in the system
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @return The list of all relationships currently in the system
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
public List<Relationship> findAll(Context context) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates a relationship object in the database equal to the given relationship param
|
||||||
|
* if this is a valid relationship
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param relationship The relationship that will be created in the database if it is valid
|
||||||
|
* @return The created relationship with updated place variables
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong with authorizations
|
||||||
|
*/
|
||||||
|
public Relationship create(Context context, Relationship relationship) throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the highest integer value for the leftplace property of a Relationship for all relationships
|
||||||
|
* that have the given item as a left item
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The item that has to be the leftItem of a relationship for it to qualify
|
||||||
|
* @return The integer value of the highest left place property of all relationships
|
||||||
|
* that have the given item as a leftitem property
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
int findLeftPlaceByLeftItem(Context context, Item item) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the highest integer value for the rightplace property of a Relationship for all relationships
|
||||||
|
* that have the given item as a right item
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The item that has to be the rightitem of a relationship for it to qualify
|
||||||
|
* @return The integer value of the highest right place property of all relationships
|
||||||
|
* that have the given item as a rightitem property
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
int findRightPlaceByRightItem(Context context, Item item) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a list of Relationships for which the leftItem or rightItem is equal to the given
|
||||||
|
* Item object and for which the RelationshipType object is equal to the relationshipType property
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The Item object to be matched on the leftItem or rightItem for the relationship
|
||||||
|
* @param relationshipType The RelationshipType object that will be used to check the Relationship on
|
||||||
|
* @return The list of Relationship objects that have the given Item object as leftItem or rightItem and
|
||||||
|
* for which the relationshipType property is equal to the given RelationshipType
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
public List<Relationship> findByItemAndRelationshipType(Context context, Item item,
|
||||||
|
RelationshipType relationshipType)
|
||||||
|
throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will update the place for the Relationship and all other relationships found by the items and
|
||||||
|
* relationship type of the given Relatonship. It will give this Relationship the last place in both the
|
||||||
|
* left and right place determined by querying for the list of leftRelationships and rightRelationships
|
||||||
|
* by the leftItem, rightItem and relationshipType of the given Relationship.
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param relationship The Relationship object that will have it's place updated and that will be used
|
||||||
|
* to retrieve the other relationships whose place might need to be updated
|
||||||
|
* @param isCreation Is the relationship new or did it already exist
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
public void updatePlaceInRelationship(Context context, Relationship relationship, boolean isCreation)
|
||||||
|
throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will update the given item's metadata order.
|
||||||
|
* If the relationships for the item have been modified and will calculate the place based on a
|
||||||
|
* metadata field, this function will ensure the place is calculated.
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param relatedItem The Item for which the list of Relationship location is calculated
|
||||||
|
* based on a metadata field
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* If the user is not authorized to update the item
|
||||||
|
*/
|
||||||
|
public void updateItem(Context context, Item relatedItem) throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a list of Relationship objets for which the relationshipType property is equal to the given
|
||||||
|
* RelationshipType object
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param relationshipType The RelationshipType object that will be used to check the Relationship on
|
||||||
|
* @return The list of Relationship objects for which the given RelationshipType object is equal
|
||||||
|
* to the relationshipType property
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<Relationship> findByRelationshipType(Context context, RelationshipType relationshipType) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to construct a Relationship object with all it's variables
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param leftItem The leftItem Item object for the relationship
|
||||||
|
* @param rightItem The rightItem Item object for the relationship
|
||||||
|
* @param relationshipType The RelationshipType object for the relationship
|
||||||
|
* @param leftPlace The leftPlace integer for the relationship
|
||||||
|
* @param rightPlace The rightPlace integer for the relationship
|
||||||
|
* @return The created Relationship object with the given properties
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
Relationship create(Context c, Item leftItem, Item rightItem, RelationshipType relationshipType,
|
||||||
|
int leftPlace, int rightPlace)
|
||||||
|
throws AuthorizeException, SQLException;
|
||||||
|
}
|
@@ -0,0 +1,97 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.service;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.service.DSpaceCRUDService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This Service uses DAOs to access information on the database objects for the RelationshipTypes
|
||||||
|
*/
|
||||||
|
public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipType> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates the given RelationshipType object in the database and returns it
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param relationshipType The RelationshipType to be created in the database
|
||||||
|
* @return The newly created RelationshipType
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong with authorizations
|
||||||
|
*/
|
||||||
|
RelationshipType create(Context context,RelationshipType relationshipType) throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a RelationshipType for which the given parameters all match the one in the returned RelationshipType
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param leftType The rightType EntityType that needs to match for the returned RelationshipType
|
||||||
|
* @param rightType The rightType EntityType that needs to match for the returned RelationshipType
|
||||||
|
* @param leftLabel The leftLabel String that needs to match for the returned RelationshipType
|
||||||
|
* @param rightLabel The rightLabel String that needs to match for the returned RelationshipType
|
||||||
|
* @return
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType,
|
||||||
|
String leftLabel,String rightLabel)
|
||||||
|
throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all RelationshipType objects currently in the system
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @return The list of all RelationshipType objects currently in the system
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<RelationshipType> findAll(Context context) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all RelationshipType objects that have a left or right label that is
|
||||||
|
* equal to the given String
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param label The label that has to match
|
||||||
|
* @return The list of all RelationshipType objects that have a left or right label
|
||||||
|
* that is equal to the given label param
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<RelationshipType> findByLeftOrRightLabel(Context context, String label) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of RelationshipType objects for which the given EntityType is equal to either the leftType
|
||||||
|
* or the rightType
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param entityType The EntityType object used to check the leftType and rightType properties
|
||||||
|
* @return A list of RelationshipType objects for which the leftType or rightType property are equal to the
|
||||||
|
* given EntityType object
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<RelationshipType> findByEntityType(Context context, EntityType entityType) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will support the creation of a RelationshipType object with the given parameters
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param leftEntityType The leftEntityType EntityType object for this relationshipType
|
||||||
|
* @param rightEntityType The rightEntityType EntityType object for this relationshipType
|
||||||
|
* @param leftLabel The leftLabel String object for this relationshipType
|
||||||
|
* @param rightLabel The rightLabel String object for this relationshipType
|
||||||
|
* @param leftCardinalityMinInteger The leftCardinalityMinInteger Integer object for this relationshipType
|
||||||
|
* @param leftCardinalityMaxInteger The leftCardinalityMaxInteger Integer object for this relationshipType
|
||||||
|
* @param rightCardinalityMinInteger The rightCardinalityMinInteger Integer object for this relationshipType
|
||||||
|
* @param rightCardinalityMaxInteger The rightCardinalityMaxInteger Integer object for this relationshipType
|
||||||
|
* @return The created RelationshipType object for these properties
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
RelationshipType create(Context context, EntityType leftEntityType, EntityType rightEntityType, String leftLabel,
|
||||||
|
String rightLabel, Integer leftCardinalityMinInteger, Integer leftCardinalityMaxInteger,
|
||||||
|
Integer rightCardinalityMinInteger, Integer rightCardinalityMaxInteger)
|
||||||
|
throws SQLException, AuthorizeException;
|
||||||
|
}
|
@@ -0,0 +1,111 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.virtual;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.MetadataValue;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A bean implementing the {@link VirtualMetadataConfiguration} interface to achieve the generation of Virtual
|
||||||
|
* metadata
|
||||||
|
* The Collected bean will take all the values of each metadata field defined in the list and it'll
|
||||||
|
* create a list of virtual metadata fields defined by the map in which it's defined.
|
||||||
|
* All values from the metadata fields will returned as separate elements
|
||||||
|
*/
|
||||||
|
public class Collected implements VirtualMetadataConfiguration {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ItemService itemService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property determines whether this RelationshipMetadataValue should be used in place calculation or not.
|
||||||
|
* This is retrieved from Spring configuration when constructing RelationshipMetadataValues. This Spring
|
||||||
|
* configuration is located in the core-services.xml configuration file.
|
||||||
|
* Putting this property on true will imply that we're now mixing plain-text metadatavalues with the
|
||||||
|
* metadatavalues that are constructed through Relationships with regards to the place attribute.
|
||||||
|
* For example, currently the RelationshipMetadataValue dc.contributor.author that is constructed through a
|
||||||
|
* Relationship for a Publication will have its useForPlace set to true. This means that the place
|
||||||
|
* calculation will take both these RelationshipMetadataValues into account together with the normal
|
||||||
|
* plain text metadatavalues.
|
||||||
|
*/
|
||||||
|
private boolean useForPlace;
|
||||||
|
/**
|
||||||
|
* The fields for which the metadata will be retrieved
|
||||||
|
*/
|
||||||
|
private List<String> fields;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the fields property
|
||||||
|
* @return The list of fields to be used in this bean
|
||||||
|
*/
|
||||||
|
public List<String> getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic setter for the fields property
|
||||||
|
* @param fields the list of fields to which the fields property will be set to
|
||||||
|
*/
|
||||||
|
public void setFields(List<String> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Generic setter for the useForPlace property
|
||||||
|
* @param useForPlace The boolean value that the useForPlace property will be set to
|
||||||
|
*/
|
||||||
|
public void setUseForPlace(boolean useForPlace) {
|
||||||
|
this.useForPlace = useForPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the useForPlace property
|
||||||
|
* @return The useForPlace to be used by this bean
|
||||||
|
*/
|
||||||
|
public boolean getUseForPlace() {
|
||||||
|
return useForPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method will retrieve the metadata values from the given item for all the metadata fields listed
|
||||||
|
* in the fields property and it'll return all those values as a list
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The item that will be used to either retrieve metadata values from
|
||||||
|
* @return The String values for all of the retrieved metadatavalues
|
||||||
|
*/
|
||||||
|
public List<String> getValues(Context context, Item item) {
|
||||||
|
List<String> resultValues = new LinkedList<>();
|
||||||
|
List<String> value = this.getFields();
|
||||||
|
for (String s : value) {
|
||||||
|
String[] splittedString = s.split("\\.");
|
||||||
|
|
||||||
|
List<MetadataValue> resultList = itemService.getMetadata(item,
|
||||||
|
splittedString.length > 0 ? splittedString[0] :
|
||||||
|
null,
|
||||||
|
splittedString.length > 1 ? splittedString[1] :
|
||||||
|
null,
|
||||||
|
splittedString.length > 2 ? splittedString[2] :
|
||||||
|
null,
|
||||||
|
Item.ANY, false);
|
||||||
|
|
||||||
|
for (MetadataValue metadataValue : resultList) {
|
||||||
|
if (StringUtils.isNotBlank(metadataValue.getValue())) {
|
||||||
|
resultValues.add(metadataValue.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultValues;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,140 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.virtual;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.MetadataValue;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A bean implementing the {@link VirtualMetadataConfiguration} interface to achieve the generation of Virtual
|
||||||
|
* metadata
|
||||||
|
* The Concatenate bean will take all the values of each metadata field configured in the list
|
||||||
|
* and it will join all of these together with the separator defined in this bean. This means that whichever
|
||||||
|
* entry this bean belongs to, that metadata field will have the value of the related item's metadata values
|
||||||
|
* joined together with this separator. Only one value will be returned
|
||||||
|
*/
|
||||||
|
public class Concatenate implements VirtualMetadataConfiguration {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ItemService itemService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The fields for which the metadata will be retrieved
|
||||||
|
*/
|
||||||
|
private List<String> fields;
|
||||||
|
/**
|
||||||
|
* The separator that will be used to concatenate the values retrieved from the above mentioned fields
|
||||||
|
*/
|
||||||
|
private String separator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The boolean value indicating whether this field should be used for place or not
|
||||||
|
*/
|
||||||
|
private boolean useForPlace = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the fields property
|
||||||
|
* @return The list of fields to be used in this bean
|
||||||
|
*/
|
||||||
|
public List<String> getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic setter for the fields property
|
||||||
|
* @param fields the list of fields to which the fields property will be set to
|
||||||
|
*/
|
||||||
|
public void setFields(List<String> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the seperator
|
||||||
|
* @return the seperator to be used by this bean
|
||||||
|
*/
|
||||||
|
public String getSeparator() {
|
||||||
|
return separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic setter for the seperator property
|
||||||
|
* @param separator The String seperator value to which this seperator value will be set to
|
||||||
|
*/
|
||||||
|
public void setSeparator(String separator) {
|
||||||
|
this.separator = separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic setter for the useForPlace property
|
||||||
|
* @param useForPlace The boolean value that the useForPlace property will be set to
|
||||||
|
*/
|
||||||
|
public void setUseForPlace(boolean useForPlace) {
|
||||||
|
this.useForPlace = useForPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the useForPlace property
|
||||||
|
* @return The useForPlace to be used by this bean
|
||||||
|
*/
|
||||||
|
public boolean getUseForPlace() {
|
||||||
|
return useForPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method will retrieve the metadata values from the given item for all the metadata fields listed
|
||||||
|
* in the fields property and it'll concatenate all those values together with the separator specified
|
||||||
|
* in this class
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The item that will be used to either retrieve metadata values from
|
||||||
|
* @return The String value for all of the retrieved metadatavalues combined with the separator
|
||||||
|
*/
|
||||||
|
public List<String> getValues(Context context, Item item) {
|
||||||
|
|
||||||
|
List<String> resultValues = new LinkedList<>();
|
||||||
|
List<String> value = this.getFields();
|
||||||
|
for (String s : value) {
|
||||||
|
String[] splittedString = s.split("\\.");
|
||||||
|
|
||||||
|
List<MetadataValue> resultList = itemService.getMetadata(item,
|
||||||
|
splittedString.length > 0 ? splittedString[0] :
|
||||||
|
null,
|
||||||
|
splittedString.length > 1 ? splittedString[1] :
|
||||||
|
null,
|
||||||
|
splittedString.length > 2 ? splittedString[2] :
|
||||||
|
null,
|
||||||
|
Item.ANY, false);
|
||||||
|
|
||||||
|
String resultString = "";
|
||||||
|
for (int i = 0; i < resultList.size(); i++) {
|
||||||
|
String metadataValueString = resultList.get(i).getValue();
|
||||||
|
if (StringUtils.isNotBlank(metadataValueString)) {
|
||||||
|
if (StringUtils.isNotBlank(resultString)) {
|
||||||
|
resultString += this.getSeparator();
|
||||||
|
}
|
||||||
|
resultString += metadataValueString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(resultString)) {
|
||||||
|
resultValues.add(resultString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String result = StringUtils.join(resultValues, this.getSeparator());
|
||||||
|
List<String> listToReturn = new LinkedList<>();
|
||||||
|
listToReturn.add(result);
|
||||||
|
return listToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.virtual;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This service offers a way to convert EntityType String labels to a filter query which is defined in the
|
||||||
|
* bean config for this service
|
||||||
|
*/
|
||||||
|
public class EntityTypeToFilterQueryService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This map contains the mapping between the String label and the String for the filter query
|
||||||
|
* e.g. <entry key="Person" value="f.entityType=Person,equals"/>
|
||||||
|
*/
|
||||||
|
private Map<String, String> map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for this map
|
||||||
|
* @param map The map that should be set in this service
|
||||||
|
*/
|
||||||
|
public void setMap(Map map) {
|
||||||
|
this.map = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the map
|
||||||
|
* @return the map
|
||||||
|
*/
|
||||||
|
public Map getMap() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the filterQuery for the key that's given as a parameter. It looks in the map for the value
|
||||||
|
* @param key The key for which we'll find the value in the map
|
||||||
|
* @return The filter query representation for the given key
|
||||||
|
*/
|
||||||
|
public String getFilterQueryForKey(String key) {
|
||||||
|
return map.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a boolean depending on whether a key is present in the map or not
|
||||||
|
* @param key The key to be checked for
|
||||||
|
* @return The boolean indicating whether this key is present in the map or not
|
||||||
|
*/
|
||||||
|
public boolean hasKey(String key) {
|
||||||
|
return map.containsKey(key);
|
||||||
|
}
|
||||||
|
}
|
181
dspace-api/src/main/java/org/dspace/content/virtual/Related.java
Normal file
181
dspace-api/src/main/java/org/dspace/content/virtual/Related.java
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.virtual;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dspace.content.Entity;
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.Relationship;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
import org.dspace.content.service.EntityService;
|
||||||
|
import org.dspace.content.service.EntityTypeService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A bean implementing the {@link VirtualMetadataConfiguration} interface to achieve the generation of
|
||||||
|
* Virtual metadata by traversing the path of relation specified in the config for this bean
|
||||||
|
* The Related bean will find the relationshiptype defined in the relationshipTypeString property on
|
||||||
|
* the current item and it'll use the related item from that relationship to pass it along to the
|
||||||
|
* virtualMetadataConfiguration property which in turn refers to another VirtualBean instance and it continues
|
||||||
|
* the chain until it reaches either a Concatenate or Collected bean to retrieve the values. It will then return
|
||||||
|
* that value through the chain again and it'll fill the values into the virtual metadata fields that are defined
|
||||||
|
* in the map for the first Related bean.
|
||||||
|
*/
|
||||||
|
public class Related implements VirtualMetadataConfiguration {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RelationshipTypeService relationshipTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RelationshipService relationshipService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityTypeService entityTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityService entityService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The String representing the relationshipType that needs to be used to find the next item
|
||||||
|
*/
|
||||||
|
private String relationshipTypeString;
|
||||||
|
/**
|
||||||
|
* The left or right place that this relationship needs to have to retrieve the proper item
|
||||||
|
*/
|
||||||
|
private Integer place;
|
||||||
|
/**
|
||||||
|
* The next bean to call its getValues() method on
|
||||||
|
*/
|
||||||
|
private VirtualMetadataConfiguration virtualMetadataConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The boolean value indicating whether this field should be used for place or not
|
||||||
|
*/
|
||||||
|
private boolean useForPlace = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the relationshipTypeString property of this class
|
||||||
|
* @return The relationshipTypeString property
|
||||||
|
*/
|
||||||
|
public String getRelationshipTypeString() {
|
||||||
|
return relationshipTypeString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic setter for the relationshipTypeString property of this class
|
||||||
|
* @param relationshipTypeString The String to which the relationshipTypeString will be set to
|
||||||
|
*/
|
||||||
|
public void setRelationshipTypeString(String relationshipTypeString) {
|
||||||
|
this.relationshipTypeString = relationshipTypeString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the place property of this class
|
||||||
|
* @return The place property
|
||||||
|
*/
|
||||||
|
public Integer getPlace() {
|
||||||
|
return place;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic setter for the place property of this class
|
||||||
|
* @param place The Integer to which the place property will be set to
|
||||||
|
*/
|
||||||
|
public void setPlace(Integer place) {
|
||||||
|
this.place = place;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the virtualMetadataConfiguration property of this class
|
||||||
|
* @return The virtualMetadataConfiguration property
|
||||||
|
*/
|
||||||
|
public VirtualMetadataConfiguration getVirtualMetadataConfiguration() {
|
||||||
|
return virtualMetadataConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic setter for the virtualMetadataConfiguration property of this class
|
||||||
|
* @param virtualMetadataConfiguration The VirtualBean to which the
|
||||||
|
* virtualMetadataConfiguration property will be set to
|
||||||
|
*/
|
||||||
|
public void setVirtualMetadataConfiguration(VirtualMetadataConfiguration
|
||||||
|
virtualMetadataConfiguration) {
|
||||||
|
this.virtualMetadataConfiguration = virtualMetadataConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic setter for the useForPlace property
|
||||||
|
* @param useForPlace The boolean value that the useForPlace property will be set to
|
||||||
|
*/
|
||||||
|
public void setUseForPlace(boolean useForPlace) {
|
||||||
|
this.useForPlace = useForPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the useForPlace property
|
||||||
|
* @return The useForPlace to be used by this bean
|
||||||
|
*/
|
||||||
|
public boolean getUseForPlace() {
|
||||||
|
return useForPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will find the correct Relationship from the given item to retrieve the other item from it
|
||||||
|
* and pass this along to the next VirtualBean that's stored in this class.
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The item that will be used to find the related item through its relationships
|
||||||
|
* @return The String value of the metadata fields concatened with a seperator as defined
|
||||||
|
* in the deepest Concatened bean in the chain
|
||||||
|
* Will return an empty list if no relationships are found
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
public List<String> getValues(Context context, Item item) throws SQLException {
|
||||||
|
Entity entity = entityService.findByItemId(context, item.getID());
|
||||||
|
EntityType entityType = entityService.getType(context, entity);
|
||||||
|
|
||||||
|
List<RelationshipType> relationshipTypes = entityService.getAllRelationshipTypes(context, entity);
|
||||||
|
List<RelationshipType> possibleRelationshipTypes = new LinkedList<>();
|
||||||
|
for (RelationshipType relationshipType : relationshipTypes) {
|
||||||
|
if (StringUtils.equals(relationshipType.getLeftLabel(), relationshipTypeString) || StringUtils
|
||||||
|
.equals(relationshipType.getRightLabel(), relationshipTypeString)) {
|
||||||
|
possibleRelationshipTypes.add(relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Relationship> relationships = new LinkedList<>();
|
||||||
|
for (RelationshipType relationshipType : possibleRelationshipTypes) {
|
||||||
|
relationships.addAll(relationshipService.findByItemAndRelationshipType(context, item, relationshipType));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Relationship relationship : relationships) {
|
||||||
|
if (relationship.getRelationshipType().getLeftType() == entityType) {
|
||||||
|
if (relationship.getLeftPlace() == place) {
|
||||||
|
Item otherItem = relationship.getRightItem();
|
||||||
|
return virtualMetadataConfiguration.getValues(context, otherItem);
|
||||||
|
}
|
||||||
|
} else if (relationship.getRelationshipType().getRightType() == entityType) {
|
||||||
|
if (relationship.getRightPlace() == place) {
|
||||||
|
Item otherItem = relationship.getLeftItem();
|
||||||
|
return virtualMetadataConfiguration.getValues(context, otherItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return an empty list if no relationships were found
|
||||||
|
return new LinkedList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.virtual;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used by the VirtualMetadataPopulator. It will simply take the ID of the item that's passed along
|
||||||
|
* to this and return that as it's value
|
||||||
|
*/
|
||||||
|
public class UUIDValue implements VirtualMetadataConfiguration {
|
||||||
|
|
||||||
|
private boolean useForPlace;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getValues(Context context, Item item) throws SQLException {
|
||||||
|
List<String> list = new LinkedList<>();
|
||||||
|
list.add(String.valueOf(item.getID()));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUseForPlace(boolean useForPlace) {
|
||||||
|
this.useForPlace = useForPlace;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getUseForPlace() {
|
||||||
|
return useForPlace;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.virtual;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface describes beans to be used for the {@link VirtualMetadataPopulator} implementation.
|
||||||
|
* The config is located in core-services.xml whilst the actual code implementation is located in
|
||||||
|
* {@link org.dspace.content.ItemServiceImpl}
|
||||||
|
*/
|
||||||
|
public interface VirtualMetadataConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will return a list filled with String values which will be determine by the bean that's responsible
|
||||||
|
* of handling the metadata fields when fully traversed through all the {@link Related} beans
|
||||||
|
* @param context The relevant DSpace context
|
||||||
|
* @param item The item that will be used to either retrieve metadata values from or to find
|
||||||
|
* the related item through its relationships
|
||||||
|
* @return The list of String values of all the metadata values as constructed by the responsible bean
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
List<String> getValues(Context context, Item item) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic setter for the useForPlace property
|
||||||
|
* @param useForPlace The boolean value that the useForPlace property will be set to
|
||||||
|
*/
|
||||||
|
void setUseForPlace(boolean useForPlace);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic getter for the useForPlace property
|
||||||
|
* @return The useForPlace to be used by this bean
|
||||||
|
*/
|
||||||
|
boolean getUseForPlace();
|
||||||
|
}
|
@@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.virtual;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is responsible for holding the representation of how a certain relationshipType label has to be
|
||||||
|
* translated to the virtual metadata added onto the items that belong to the relationships that these
|
||||||
|
* relationshipTypes belong to
|
||||||
|
*/
|
||||||
|
public class VirtualMetadataPopulator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The map that holds this representation
|
||||||
|
*/
|
||||||
|
private Map<String, HashMap<String, VirtualMetadataConfiguration>> map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard setter for the map
|
||||||
|
* @param map The map to be used in the VirtualMetadataPopulator
|
||||||
|
*/
|
||||||
|
public void setMap(Map<String, HashMap<String, VirtualMetadataConfiguration>> map) {
|
||||||
|
this.map = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard getter for the map
|
||||||
|
* @return The map that is used in the VirtualMetadataPopulator
|
||||||
|
*/
|
||||||
|
public Map<String, HashMap<String, VirtualMetadataConfiguration>> getMap() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will return a boolean indicating whether the useForPlace is true or false for the given
|
||||||
|
* RelationshipType for the left or right label as indicated by the second parameter.
|
||||||
|
* @param relationshipType The relationshipType for which this should be checked
|
||||||
|
* @param isLeft The boolean indicating whether to check the left or the right label
|
||||||
|
* @return A boolean indicating whether the useForPlace is true or not for the given parameters
|
||||||
|
*/
|
||||||
|
public boolean isUseForPlaceTrueForRelationshipType(RelationshipType relationshipType, boolean isLeft) {
|
||||||
|
HashMap<String, VirtualMetadataConfiguration> hashMaps;
|
||||||
|
if (isLeft) {
|
||||||
|
hashMaps = this.getMap().get(relationshipType.getLeftLabel());
|
||||||
|
} else {
|
||||||
|
hashMaps = this.getMap().get(relationshipType.getRightLabel());
|
||||||
|
}
|
||||||
|
if (hashMaps != null) {
|
||||||
|
for (Map.Entry<String, VirtualMetadataConfiguration> entry : hashMaps.entrySet()) {
|
||||||
|
VirtualMetadataConfiguration virtualBean = entry.getValue();
|
||||||
|
boolean useForPlace = virtualBean.getUseForPlace();
|
||||||
|
if (useForPlace) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@@ -244,6 +244,7 @@ public class Constants {
|
|||||||
|
|
||||||
public static final String DEFAULT_ENCODING = "UTF-8";
|
public static final String DEFAULT_ENCODING = "UTF-8";
|
||||||
|
|
||||||
|
public static final String VIRTUAL_AUTHORITY_PREFIX = "virtual::";
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
|
@@ -34,8 +34,6 @@ import java.util.TimeZone;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.apache.commons.collections4.Transformer;
|
import org.apache.commons.collections4.Transformer;
|
||||||
@@ -473,7 +471,8 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case Constants.ITEM:
|
case Constants.ITEM:
|
||||||
Iterator<Item> items = itemService.findAllUnfiltered(context);
|
Iterator<Item> items = itemService.findAllUnfiltered(context);
|
||||||
for (Item item : ImmutableList.copyOf(items)) {
|
while (items.hasNext()) {
|
||||||
|
Item item = items.next();
|
||||||
indexContent(context, item, force);
|
indexContent(context, item, force);
|
||||||
//To prevent memory issues, discard an object from the cache after processing
|
//To prevent memory issues, discard an object from the cache after processing
|
||||||
context.uncacheEntity(item);
|
context.uncacheEntity(item);
|
||||||
|
@@ -17,7 +17,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -153,8 +153,8 @@ public class EmbargoServiceImpl implements EmbargoService {
|
|||||||
itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY);
|
itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY);
|
||||||
|
|
||||||
// set the dc.date.available value to right now
|
// set the dc.date.available value to right now
|
||||||
itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", Item.ANY);
|
itemService.clearMetadata(context, item, MetadataSchemaEnum.DC.getName(), "date", "available", Item.ANY);
|
||||||
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", null,
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(), "date", "available", null,
|
||||||
DCDate.getCurrent().toString());
|
DCDate.getCurrent().toString());
|
||||||
|
|
||||||
log.info("Lifting embargo on Item " + item.getHandle());
|
log.info("Lifting embargo on Item " + item.getHandle());
|
||||||
|
@@ -30,7 +30,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
@@ -228,7 +228,7 @@ public class SubscribeCLITool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<MetadataValue> authors = itemService
|
List<MetadataValue> authors = itemService
|
||||||
.getMetadata(hii.item, MetadataSchema.DC_SCHEMA, "contributor", Item.ANY, Item.ANY);
|
.getMetadata(hii.item, MetadataSchemaEnum.DC.getName(), "contributor", Item.ANY, Item.ANY);
|
||||||
|
|
||||||
if (authors.size() > 0) {
|
if (authors.size() > 0) {
|
||||||
emailText.append("\n ").append(labels.getString("org.dspace.eperson.Subscribe.authors"))
|
emailText.append("\n ").append(labels.getString("org.dspace.eperson.Subscribe.authors"))
|
||||||
|
@@ -15,7 +15,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
@@ -228,14 +228,15 @@ public class HandleIdentifierProvider extends IdentifierProvider {
|
|||||||
// First check that identifier doesn't already exist.
|
// First check that identifier doesn't already exist.
|
||||||
boolean identifierExists = false;
|
boolean identifierExists = false;
|
||||||
List<MetadataValue> identifiers = itemService
|
List<MetadataValue> identifiers = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "identifier", "uri", Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "identifier", "uri", Item.ANY);
|
||||||
for (MetadataValue identifier : identifiers) {
|
for (MetadataValue identifier : identifiers) {
|
||||||
if (handleref.equals(identifier.getValue())) {
|
if (handleref.equals(identifier.getValue())) {
|
||||||
identifierExists = true;
|
identifierExists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!identifierExists) {
|
if (!identifierExists) {
|
||||||
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "identifier", "uri", null, handleref);
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"identifier", "uri", null, handleref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
@@ -417,9 +417,9 @@ public class VersionedHandleIdentifierProvider extends IdentifierProvider {
|
|||||||
// load all identifiers, clear the metadata field, re add all
|
// load all identifiers, clear the metadata field, re add all
|
||||||
// identifiers which are not from type handle and add the new handle.
|
// identifiers which are not from type handle and add the new handle.
|
||||||
List<MetadataValue> identifiers = itemService.getMetadata(item,
|
List<MetadataValue> identifiers = itemService.getMetadata(item,
|
||||||
MetadataSchema.DC_SCHEMA, "identifier", "uri",
|
MetadataSchemaEnum.DC.getName(), "identifier", "uri",
|
||||||
Item.ANY);
|
Item.ANY);
|
||||||
itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA,
|
itemService.clearMetadata(context, item, MetadataSchemaEnum.DC.getName(),
|
||||||
"identifier", "uri", Item.ANY);
|
"identifier", "uri", Item.ANY);
|
||||||
for (MetadataValue identifier : identifiers) {
|
for (MetadataValue identifier : identifiers) {
|
||||||
if (this.supports(identifier.getValue())) {
|
if (this.supports(identifier.getValue())) {
|
||||||
@@ -439,7 +439,8 @@ public class VersionedHandleIdentifierProvider extends IdentifierProvider {
|
|||||||
|
|
||||||
// Add handle as identifier.uri DC value.
|
// Add handle as identifier.uri DC value.
|
||||||
if (StringUtils.isNotBlank(handleref)) {
|
if (StringUtils.isNotBlank(handleref)) {
|
||||||
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "identifier", "uri", null, handleref);
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"identifier", "uri", null, handleref);
|
||||||
}
|
}
|
||||||
itemService.update(context, item);
|
itemService.update(context, item);
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
@@ -493,8 +493,8 @@ public class VersionedHandleIdentifierProviderWithCanonicalHandles extends Ident
|
|||||||
// identifiers which are not from type handle and add the new handle.
|
// identifiers which are not from type handle and add the new handle.
|
||||||
String handleref = handleService.getCanonicalForm(handle);
|
String handleref = handleService.getCanonicalForm(handle);
|
||||||
List<MetadataValue> identifiers = itemService
|
List<MetadataValue> identifiers = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "identifier", "uri", Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "identifier", "uri", Item.ANY);
|
||||||
itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA, "identifier", "uri", Item.ANY);
|
itemService.clearMetadata(context, item, MetadataSchemaEnum.DC.getName(), "identifier", "uri", Item.ANY);
|
||||||
for (MetadataValue identifier : identifiers) {
|
for (MetadataValue identifier : identifiers) {
|
||||||
if (this.supports(identifier.getValue())) {
|
if (this.supports(identifier.getValue())) {
|
||||||
// ignore handles
|
// ignore handles
|
||||||
@@ -509,7 +509,8 @@ public class VersionedHandleIdentifierProviderWithCanonicalHandles extends Ident
|
|||||||
identifier.getConfidence());
|
identifier.getConfidence());
|
||||||
}
|
}
|
||||||
if (!StringUtils.isEmpty(handleref)) {
|
if (!StringUtils.isEmpty(handleref)) {
|
||||||
itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "identifier", "uri", null, handleref);
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"identifier", "uri", null, handleref);
|
||||||
}
|
}
|
||||||
itemService.update(context, item);
|
itemService.update(context, item);
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@ import org.dspace.content.DSpaceObject;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.DSpaceObjectService;
|
import org.dspace.content.service.DSpaceObjectService;
|
||||||
@@ -133,7 +134,7 @@ public class MetadataConverterPlugin implements ConverterPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<MetadataValue> metadata_values = dsoService
|
List<MetadataValue> metadata_values = dsoService
|
||||||
.getMetadata(dso, MetadataSchema.DC_SCHEMA, Item.ANY, Item.ANY, Item.ANY);
|
.getMetadata(dso, MetadataSchemaEnum.DC.getName(), Item.ANY, Item.ANY, Item.ANY);
|
||||||
for (MetadataValue value : metadata_values) {
|
for (MetadataValue value : metadata_values) {
|
||||||
MetadataField metadataField = value.getMetadataField();
|
MetadataField metadataField = value.getMetadataField();
|
||||||
MetadataSchema metadataSchema = metadataField.getMetadataSchema();
|
MetadataSchema metadataSchema = metadataField.getMetadataSchema();
|
||||||
|
@@ -354,13 +354,13 @@ public class StatisticsDataVisits extends StatisticsData {
|
|||||||
/*
|
/*
|
||||||
for (int j = 0; j < topCounts2.length; j++) {
|
for (int j = 0; j < topCounts2.length; j++) {
|
||||||
ObjectCount count2 = topCounts2[j];
|
ObjectCount count2 = topCounts2[j];
|
||||||
String query = firsDataset.getFacetField() + ":" + count1.getValue();
|
String query = firsDataset.getFacetField() + ":" + count1.getValues();
|
||||||
// Check if we also have a type present (if so this should be put into the query
|
// Check if we also have a type present (if so this should be put into the query
|
||||||
if ("id".equals(firsDataset.getFacetField()) && firsDataset.getQueries().get(0).getDsoType()
|
if ("id".equals(firsDataset.getFacetField()) && firsDataset.getQueries().get(0).getDsoType()
|
||||||
!= -1)
|
!= -1)
|
||||||
query += " AND type:" + firsDataset.getQueries().get(0).getDsoType();
|
query += " AND type:" + firsDataset.getQueries().get(0).getDsoType();
|
||||||
|
|
||||||
query += " AND " + secondDataSet.getFacetField() + ":" + count2.getValue();
|
query += " AND " + secondDataSet.getFacetField() + ":" + count2.getValues();
|
||||||
// Check if we also have a type present (if so this should be put into the query
|
// Check if we also have a type present (if so this should be put into the query
|
||||||
if ("id".equals(secondDataSet.getFacetField()) && secondDataSet.getQueries().get(0)
|
if ("id".equals(secondDataSet.getFacetField()) && secondDataSet.getQueries().get(0)
|
||||||
.getDsoType() != -1)
|
.getDsoType() != -1)
|
||||||
@@ -372,8 +372,8 @@ public class StatisticsDataVisits extends StatisticsData {
|
|||||||
// No need to add this many times
|
// No need to add this many times
|
||||||
// TODO: dit vervangen door te displayen value
|
// TODO: dit vervangen door te displayen value
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
dataset.setRowLabel(j, getResultName(count2.getValue(), secondDataSet, context));
|
dataset.setRowLabel(j, getResultName(count2.getValues(), secondDataSet, context));
|
||||||
dataset.setRowLabelAttr(j, getAttributes(count2.getValue(), secondDataSet, context));
|
dataset.setRowLabelAttr(j, getAttributes(count2.getValues(), secondDataSet, context));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,6 +71,13 @@ public class DatabaseRegistryUpdater implements FlywayCallback {
|
|||||||
MetadataImporter.loadRegistry(base + "dublin-core-types.xml", true);
|
MetadataImporter.loadRegistry(base + "dublin-core-types.xml", true);
|
||||||
MetadataImporter.loadRegistry(base + "dcterms-types.xml", true);
|
MetadataImporter.loadRegistry(base + "dcterms-types.xml", true);
|
||||||
MetadataImporter.loadRegistry(base + "local-types.xml", true);
|
MetadataImporter.loadRegistry(base + "local-types.xml", true);
|
||||||
|
MetadataImporter.loadRegistry(base + "relationship-formats.xml", true);
|
||||||
|
MetadataImporter.loadRegistry(base + "person-types.xml", true);
|
||||||
|
MetadataImporter.loadRegistry(base + "project-types.xml", true);
|
||||||
|
MetadataImporter.loadRegistry(base + "orgunit-types.xml", true);
|
||||||
|
MetadataImporter.loadRegistry(base + "journal-types.xml", true);
|
||||||
|
MetadataImporter.loadRegistry(base + "journalissue-types.xml", true);
|
||||||
|
MetadataImporter.loadRegistry(base + "journalvolume-types.xml", true);
|
||||||
MetadataImporter.loadRegistry(base + "eperson-types.xml", true);
|
MetadataImporter.loadRegistry(base + "eperson-types.xml", true);
|
||||||
MetadataImporter.loadRegistry(base + "sword-metadata.xml", true);
|
MetadataImporter.loadRegistry(base + "sword-metadata.xml", true);
|
||||||
|
|
||||||
@@ -163,6 +170,5 @@ public class DatabaseRegistryUpdater implements FlywayCallback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterInfo(Connection connection) {
|
public void afterInfo(Connection connection) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1190,14 +1190,15 @@ public class DatabaseUtils {
|
|||||||
* <P>
|
* <P>
|
||||||
* Because the DB migration may be initialized by commandline or any one of
|
* Because the DB migration may be initialized by commandline or any one of
|
||||||
* the many DSpace webapps, this checks for the existence of a temporary
|
* the many DSpace webapps, this checks for the existence of a temporary
|
||||||
* file to know when Discovery/Solr needs reindexing.
|
* file, and the discovery.autoReindex setting to know when
|
||||||
*
|
* Discovery/Solr needs reindexing.
|
||||||
* @return whether reindex flag is true/false
|
* @return whether reindexing should happen.
|
||||||
*/
|
*/
|
||||||
public static boolean getReindexDiscovery() {
|
public static boolean getReindexDiscovery() {
|
||||||
// Simply check if the flag file exists
|
boolean autoReindex = DSpaceServicesFactory.getInstance()
|
||||||
File reindexFlag = new File(reindexDiscoveryFilePath);
|
.getConfigurationService()
|
||||||
return reindexFlag.exists();
|
.getBooleanProperty("discovery.autoReindex", true);
|
||||||
|
return (autoReindex && new File(reindexDiscoveryFilePath).exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1222,7 +1223,7 @@ public class DatabaseUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal class to actually perform re-indexing in a separate thread.
|
* Internal class to actually perform re-indexing in a separate thread.
|
||||||
* (See checkReindexDiscovery() method)>
|
* (See checkReindexDiscovery() method).
|
||||||
*/
|
*/
|
||||||
private static class ReindexerThread extends Thread {
|
private static class ReindexerThread extends Thread {
|
||||||
private final IndexingService indexer;
|
private final IndexingService indexer;
|
||||||
|
@@ -31,7 +31,7 @@ import org.dspace.content.Bundle;
|
|||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
@@ -910,8 +910,8 @@ public class BasicWorkflowServiceImpl implements BasicWorkflowService {
|
|||||||
+ rejection_message + " on " + now + " (GMT) ";
|
+ rejection_message + " on " + now + " (GMT) ";
|
||||||
|
|
||||||
// Add to item as a DC field
|
// Add to item as a DC field
|
||||||
itemService
|
itemService.addMetadata(context, myitem, MetadataSchemaEnum.DC.getName(),
|
||||||
.addMetadata(context, myitem, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription);
|
"description", "provenance", "en", provDescription);
|
||||||
itemService.update(context, myitem);
|
itemService.update(context, myitem);
|
||||||
|
|
||||||
// convert into personal workspace
|
// convert into personal workspace
|
||||||
@@ -1135,8 +1135,8 @@ public class BasicWorkflowServiceImpl implements BasicWorkflowService {
|
|||||||
provDescription += installItemService.getBitstreamProvenanceMessage(context, item);
|
provDescription += installItemService.getBitstreamProvenanceMessage(context, item);
|
||||||
|
|
||||||
// Add to item as a DC field
|
// Add to item as a DC field
|
||||||
itemService
|
itemService.addMetadata(context, item, MetadataSchemaEnum.DC.getName(),
|
||||||
.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription);
|
"description", "provenance", "en", provDescription);
|
||||||
itemService.update(context, item);
|
itemService.update(context, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1163,8 +1163,8 @@ public class BasicWorkflowServiceImpl implements BasicWorkflowService {
|
|||||||
provmessage += installItemService.getBitstreamProvenanceMessage(context, myitem);
|
provmessage += installItemService.getBitstreamProvenanceMessage(context, myitem);
|
||||||
|
|
||||||
// Add message to the DC
|
// Add message to the DC
|
||||||
itemService
|
itemService.addMetadata(context, myitem, MetadataSchemaEnum.DC.getName(),
|
||||||
.addMetadata(context, myitem, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provmessage);
|
"description", "provenance", "en", provmessage);
|
||||||
itemService.update(context, myitem);
|
itemService.update(context, myitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ import org.dspace.content.Bundle;
|
|||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.service.BitstreamFormatService;
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
@@ -593,7 +593,7 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
|
|
||||||
// Get title
|
// Get title
|
||||||
List<MetadataValue> titles = itemService
|
List<MetadataValue> titles = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
|
||||||
String title = "";
|
String title = "";
|
||||||
try {
|
try {
|
||||||
title = I18nUtil.getMessage("org.dspace.workflow.WorkflowManager.untitled");
|
title = I18nUtil.getMessage("org.dspace.workflow.WorkflowManager.untitled");
|
||||||
@@ -891,7 +891,8 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
|
|
||||||
// Add to item as a DC field
|
// Add to item as a DC field
|
||||||
itemService
|
itemService
|
||||||
.addMetadata(context, myitem, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription);
|
.addMetadata(context, myitem, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"description", "provenance", "en", provDescription);
|
||||||
|
|
||||||
//Clear any workflow schema related metadata
|
//Clear any workflow schema related metadata
|
||||||
itemService
|
itemService
|
||||||
@@ -1024,7 +1025,8 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
|
|||||||
|
|
||||||
// Add message to the DC
|
// Add message to the DC
|
||||||
itemService
|
itemService
|
||||||
.addMetadata(context, myitem, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provmessage);
|
.addMetadata(context, myitem, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"description", "provenance", "en", provmessage);
|
||||||
itemService.update(context, myitem);
|
itemService.update(context, myitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
||||||
import org.dspace.xmlworkflow.state.Step;
|
import org.dspace.xmlworkflow.state.Step;
|
||||||
@@ -91,7 +91,7 @@ public class AcceptEditRejectAction extends ProcessingAction {
|
|||||||
+ usersName + " on " + now + " (GMT) ";
|
+ usersName + " on " + now + " (GMT) ";
|
||||||
|
|
||||||
// Add to item as a DC field
|
// Add to item as a DC field
|
||||||
itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en",
|
itemService.addMetadata(c, wfi.getItem(), MetadataSchemaEnum.DC.getName(), "description", "provenance", "en",
|
||||||
provDescription);
|
provDescription);
|
||||||
itemService.update(c, wfi.getItem());
|
itemService.update(c, wfi.getItem());
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
||||||
import org.dspace.xmlworkflow.state.Step;
|
import org.dspace.xmlworkflow.state.Step;
|
||||||
@@ -68,7 +68,7 @@ public class FinalEditAction extends ProcessingAction {
|
|||||||
+ usersName + " on " + now + " (GMT) ";
|
+ usersName + " on " + now + " (GMT) ";
|
||||||
|
|
||||||
// Add to item as a DC field
|
// Add to item as a DC field
|
||||||
itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en",
|
itemService.addMetadata(c, wfi.getItem(), MetadataSchemaEnum.DC.getName(), "description", "provenance", "en",
|
||||||
provDescription);
|
provDescription);
|
||||||
itemService.update(c, wfi.getItem());
|
itemService.update(c, wfi.getItem());
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
||||||
import org.dspace.xmlworkflow.state.Step;
|
import org.dspace.xmlworkflow.state.Step;
|
||||||
@@ -74,7 +74,7 @@ public class ReviewAction extends ProcessingAction {
|
|||||||
+ usersName + " on " + now + " (GMT) ";
|
+ usersName + " on " + now + " (GMT) ";
|
||||||
|
|
||||||
// Add to item as a DC field
|
// Add to item as a DC field
|
||||||
itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en",
|
itemService.addMetadata(c, wfi.getItem(), MetadataSchemaEnum.DC.getName(), "description", "provenance", "en",
|
||||||
provDescription);
|
provDescription);
|
||||||
itemService.update(c, wfi.getItem());
|
itemService.update(c, wfi.getItem());
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.workflow.WorkflowException;
|
import org.dspace.workflow.WorkflowException;
|
||||||
@@ -66,8 +66,8 @@ public class ScoreEvaluationAction extends ProcessingAction {
|
|||||||
|
|
||||||
String provDescription = getProvenanceStartId() + " Approved for entry into archive with a score of: " +
|
String provDescription = getProvenanceStartId() + " Approved for entry into archive with a score of: " +
|
||||||
scoreMean;
|
scoreMean;
|
||||||
itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en",
|
itemService.addMetadata(c, wfi.getItem(), MetadataSchemaEnum.DC.getName(),
|
||||||
provDescription);
|
"description", "provenance", "en", provDescription);
|
||||||
itemService.update(c, wfi.getItem());
|
itemService.update(c, wfi.getItem());
|
||||||
}
|
}
|
||||||
if (hasPassed) {
|
if (hasPassed) {
|
||||||
|
@@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import org.dspace.app.util.Util;
|
import org.dspace.app.util.Util;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
||||||
import org.dspace.xmlworkflow.state.Step;
|
import org.dspace.xmlworkflow.state.Step;
|
||||||
@@ -91,7 +91,7 @@ public class SingleUserReviewAction extends ProcessingAction {
|
|||||||
+ usersName + " on " + now + " (GMT) ";
|
+ usersName + " on " + now + " (GMT) ";
|
||||||
|
|
||||||
// Add to item as a DC field
|
// Add to item as a DC field
|
||||||
itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en",
|
itemService.addMetadata(c, wfi.getItem(), MetadataSchemaEnum.DC.getName(), "description", "provenance", "en",
|
||||||
provDescription);
|
provDescription);
|
||||||
itemService.update(c, wfi.getItem());
|
itemService.update(c, wfi.getItem());
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,65 @@
|
|||||||
|
--
|
||||||
|
-- The contents of this file are subject to the license and copyright
|
||||||
|
-- detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
-- tree and available online at
|
||||||
|
--
|
||||||
|
-- http://www.dspace.org/license/
|
||||||
|
--
|
||||||
|
|
||||||
|
-- ===============================================================
|
||||||
|
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||||
|
--
|
||||||
|
-- DO NOT MANUALLY RUN THIS DATABASE MIGRATION. IT WILL BE EXECUTED
|
||||||
|
-- AUTOMATICALLY (IF NEEDED) BY "FLYWAY" WHEN YOU STARTUP DSPACE.
|
||||||
|
-- http://flywaydb.org/
|
||||||
|
-- ===============================================================
|
||||||
|
|
||||||
|
-------------------------------------------------------------
|
||||||
|
-- This will create the setup for the dspace 7 entities usage
|
||||||
|
-------------------------------------------------------------
|
||||||
|
CREATE SEQUENCE entity_type_id_seq;
|
||||||
|
CREATE SEQUENCE relationship_type_id_seq;
|
||||||
|
CREATE SEQUENCE relationship_id_seq;
|
||||||
|
|
||||||
|
CREATE TABLE entity_type
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
|
label varchar(32) UNIQUE NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE relationship_type
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
|
left_type INTEGER NOT NULL,
|
||||||
|
right_type INTEGER NOT NULL,
|
||||||
|
left_label varchar(32) NOT NULL,
|
||||||
|
right_label varchar(32) NOT NULL,
|
||||||
|
left_min_cardinality INTEGER,
|
||||||
|
left_max_cardinality INTEGER,
|
||||||
|
right_min_cardinality INTEGER,
|
||||||
|
right_max_cardinality INTEGER,
|
||||||
|
FOREIGN KEY (left_type) REFERENCES entity_type(id),
|
||||||
|
FOREIGN KEY (right_type) REFERENCES entity_type(id),
|
||||||
|
CONSTRAINT u_relationship_type_constraint UNIQUE (left_type, right_type, left_label, right_label)
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE relationship
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
|
left_id uuid NOT NULL REFERENCES item(uuid),
|
||||||
|
type_id INTEGER NOT NULL REFERENCES relationship_type(id),
|
||||||
|
right_id uuid NOT NULL REFERENCES item(uuid),
|
||||||
|
left_place INTEGER,
|
||||||
|
right_place INTEGER,
|
||||||
|
CONSTRAINT u_constraint UNIQUE (left_id, type_id, right_id)
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX entity_type_label_idx ON entity_type(label);
|
||||||
|
CREATE INDEX relationship_type_by_left_type_idx ON relationship_type(left_type);
|
||||||
|
CREATE INDEX relationship_type_by_right_type_idx ON relationship_type(right_type);
|
||||||
|
CREATE INDEX relationship_type_by_left_label_idx ON relationship_type(left_label);
|
||||||
|
CREATE INDEX relationship_type_by_right_label_idx ON relationship_type(right_label);
|
||||||
|
CREATE INDEX relationship_by_left_id_idx ON relationship(left_id);
|
||||||
|
CREATE INDEX relationship_by_right_id_idx ON relationship(right_id);
|
@@ -0,0 +1,65 @@
|
|||||||
|
--
|
||||||
|
-- The contents of this file are subject to the license and copyright
|
||||||
|
-- detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
-- tree and available online at
|
||||||
|
--
|
||||||
|
-- http://www.dspace.org/license/
|
||||||
|
--
|
||||||
|
|
||||||
|
-- ===============================================================
|
||||||
|
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||||
|
--
|
||||||
|
-- DO NOT MANUALLY RUN THIS DATABASE MIGRATION. IT WILL BE EXECUTED
|
||||||
|
-- AUTOMATICALLY (IF NEEDED) BY "FLYWAY" WHEN YOU STARTUP DSPACE.
|
||||||
|
-- http://flywaydb.org/
|
||||||
|
-- ===============================================================
|
||||||
|
|
||||||
|
-------------------------------------------------------------
|
||||||
|
-- This will create the setup for the dspace 7 entities usage
|
||||||
|
-------------------------------------------------------------
|
||||||
|
CREATE SEQUENCE entity_type_id_seq;
|
||||||
|
CREATE SEQUENCE relationship_type_id_seq;
|
||||||
|
CREATE SEQUENCE relationship_id_seq;
|
||||||
|
|
||||||
|
CREATE TABLE entity_type
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
|
label varchar(32) UNIQUE NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE relationship_type
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
|
left_type INTEGER NOT NULL,
|
||||||
|
right_type INTEGER NOT NULL,
|
||||||
|
left_label varchar(32) NOT NULL,
|
||||||
|
right_label varchar(32) NOT NULL,
|
||||||
|
left_min_cardinality INTEGER,
|
||||||
|
left_max_cardinality INTEGER,
|
||||||
|
right_min_cardinality INTEGER,
|
||||||
|
right_max_cardinality INTEGER,
|
||||||
|
FOREIGN KEY (left_type) REFERENCES entity_type(id),
|
||||||
|
FOREIGN KEY (right_type) REFERENCES entity_type(id),
|
||||||
|
CONSTRAINT u_relationship_type_constraint UNIQUE (left_type, right_type, left_label, right_label)
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE relationship
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
|
left_id uuid NOT NULL REFERENCES item(uuid),
|
||||||
|
type_id INTEGER NOT NULL REFERENCES relationship_type(id),
|
||||||
|
right_id uuid NOT NULL REFERENCES item(uuid),
|
||||||
|
left_place INTEGER,
|
||||||
|
right_place INTEGER,
|
||||||
|
CONSTRAINT u_constraint UNIQUE (left_id, type_id, right_id)
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX entity_type_label_idx ON entity_type(label);
|
||||||
|
CREATE INDEX relationship_type_by_left_type_idx ON relationship_type(left_type);
|
||||||
|
CREATE INDEX relationship_type_by_right_type_idx ON relationship_type(right_type);
|
||||||
|
CREATE INDEX relationship_type_by_left_label_idx ON relationship_type(left_label);
|
||||||
|
CREATE INDEX relationship_type_by_right_label_idx ON relationship_type(right_label);
|
||||||
|
CREATE INDEX relationship_by_left_id_idx ON relationship(left_id);
|
||||||
|
CREATE INDEX relationship_by_right_id_idx ON relationship(right_id);
|
@@ -0,0 +1,64 @@
|
|||||||
|
--
|
||||||
|
-- The contents of this file are subject to the license and copyright
|
||||||
|
-- detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
-- tree and available online at
|
||||||
|
--
|
||||||
|
-- http://www.dspace.org/license/
|
||||||
|
--
|
||||||
|
|
||||||
|
-- ===============================================================
|
||||||
|
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||||
|
--
|
||||||
|
-- DO NOT MANUALLY RUN THIS DATABASE MIGRATION. IT WILL BE EXECUTED
|
||||||
|
-- AUTOMATICALLY (IF NEEDED) BY "FLYWAY" WHEN YOU STARTUP DSPACE.
|
||||||
|
-- http://flywaydb.org/
|
||||||
|
-- ===============================================================
|
||||||
|
|
||||||
|
-------------------------------------------------------------
|
||||||
|
-- This will create the setup for the dspace 7 entities usage
|
||||||
|
-------------------------------------------------------------
|
||||||
|
CREATE SEQUENCE entity_type_id_seq;
|
||||||
|
CREATE SEQUENCE relationship_type_id_seq;
|
||||||
|
CREATE SEQUENCE relationship_id_seq;
|
||||||
|
|
||||||
|
CREATE TABLE entity_type
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
|
label varchar(32) UNIQUE NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE relationship_type
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
|
left_type INTEGER NOT NULL,
|
||||||
|
right_type INTEGER NOT NULL,
|
||||||
|
left_label varchar(32) NOT NULL,
|
||||||
|
right_label varchar(32) NOT NULL,
|
||||||
|
left_min_cardinality INTEGER,
|
||||||
|
left_max_cardinality INTEGER,
|
||||||
|
right_min_cardinality INTEGER,
|
||||||
|
right_max_cardinality INTEGER,
|
||||||
|
FOREIGN KEY (left_type) REFERENCES entity_type(id),
|
||||||
|
FOREIGN KEY (right_type) REFERENCES entity_type(id),
|
||||||
|
CONSTRAINT u_relationship_type_constraint UNIQUE (left_type, right_type, left_label, right_label)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE relationship
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
|
left_id uuid NOT NULL REFERENCES item(uuid),
|
||||||
|
type_id INTEGER NOT NULL REFERENCES relationship_type(id),
|
||||||
|
right_id uuid NOT NULL REFERENCES item(uuid),
|
||||||
|
left_place INTEGER,
|
||||||
|
right_place INTEGER,
|
||||||
|
CONSTRAINT u_constraint UNIQUE (left_id, type_id, right_id)
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX entity_type_label_idx ON entity_type(label);
|
||||||
|
CREATE INDEX relationship_type_by_left_type_idx ON relationship_type(left_type);
|
||||||
|
CREATE INDEX relationship_type_by_right_type_idx ON relationship_type(right_type);
|
||||||
|
CREATE INDEX relationship_type_by_left_label_idx ON relationship_type(left_label);
|
||||||
|
CREATE INDEX relationship_type_by_right_label_idx ON relationship_type(right_label);
|
||||||
|
CREATE INDEX relationship_by_left_id_idx ON relationship(left_id);
|
||||||
|
CREATE INDEX relationship_by_right_id_idx ON relationship(right_id);
|
@@ -0,0 +1,127 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE relationships SYSTEM "relationship-types.dtd">
|
||||||
|
|
||||||
|
<relationships>
|
||||||
|
<type>
|
||||||
|
<leftType>Publication</leftType>
|
||||||
|
<rightType>Person</rightType>
|
||||||
|
<leftLabel>isAuthorOfPublication</leftLabel>
|
||||||
|
<rightLabel>isPublicationOfAuthor</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>10</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Publication</leftType>
|
||||||
|
<rightType>Project</rightType>
|
||||||
|
<leftLabel>isProjectOfPublication</leftLabel>
|
||||||
|
<rightLabel>isPublicationOfProject</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Publication</leftType>
|
||||||
|
<rightType>OrgUnit</rightType>
|
||||||
|
<leftLabel>isOrgUnitOfPublication</leftLabel>
|
||||||
|
<rightLabel>isPublicationOfOrgUnit</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Person</leftType>
|
||||||
|
<rightType>Project</rightType>
|
||||||
|
<leftLabel>isProjectOfPerson</leftLabel>
|
||||||
|
<rightLabel>isPersonOfProject</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Person</leftType>
|
||||||
|
<rightType>OrgUnit</rightType>
|
||||||
|
<leftLabel>isOrgUnitOfPerson</leftLabel>
|
||||||
|
<rightLabel>isPersonOfOrgUnit</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Project</leftType>
|
||||||
|
<rightType>OrgUnit</rightType>
|
||||||
|
<leftLabel>isOrgUnitOfProject</leftLabel>
|
||||||
|
<rightLabel>isProjectOfOrgUnit</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Journal</leftType>
|
||||||
|
<rightType>JournalVolume</rightType>
|
||||||
|
<leftLabel>isVolumeOfJournal</leftLabel>
|
||||||
|
<rightLabel>isJournalOfVolume</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>1</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>JournalVolume</leftType>
|
||||||
|
<rightType>JournalIssue</rightType>
|
||||||
|
<leftLabel>isIssueOfJournalVolume</leftLabel>
|
||||||
|
<rightLabel>isJournalVolumeOfIssue</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>1</min>
|
||||||
|
<max>1</max>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Publication</leftType>
|
||||||
|
<rightType>OrgUnit</rightType>
|
||||||
|
<leftLabel>isAuthorOfPublication</leftLabel>
|
||||||
|
<rightLabel>isPublicationOfAuthor</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>JournalIssue</leftType>
|
||||||
|
<rightType>Publication</rightType>
|
||||||
|
<leftLabel>isPublicationOfJournalIssue</leftLabel>
|
||||||
|
<rightLabel>isJournalIssueOfPublication</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
<max>1</max>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
</relationships>
|
@@ -0,0 +1,13 @@
|
|||||||
|
<!-- Build relationships from XML -->
|
||||||
|
|
||||||
|
|
||||||
|
<!ELEMENT relationships (type)*>
|
||||||
|
<!ELEMENT type (leftType|rightType|leftLabel|rightLabel|leftCardinality|rightCardinality)*>
|
||||||
|
<!ELEMENT leftType (#PCDATA)>
|
||||||
|
<!ELEMENT rightType (#PCDATA)>
|
||||||
|
<!ELEMENT leftLabel (#PCDATA)>
|
||||||
|
<!ELEMENT rightLabel (#PCDATA)>
|
||||||
|
<!ELEMENT leftCardinality (min|max)*>
|
||||||
|
<!ELEMENT min (#PCDATA)>
|
||||||
|
<!ELEMENT rightCardinality (min|max)*>
|
||||||
|
<!ELEMENT max (#PCDATA)>
|
@@ -0,0 +1,127 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE relationships SYSTEM "relationship-types.dtd">
|
||||||
|
|
||||||
|
<relationships>
|
||||||
|
<type>
|
||||||
|
<leftType>Publication</leftType>
|
||||||
|
<rightType>Person</rightType>
|
||||||
|
<leftLabel>isAuthorOfPublication</leftLabel>
|
||||||
|
<rightLabel>isPublicationOfAuthor</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Publication</leftType>
|
||||||
|
<rightType>Project</rightType>
|
||||||
|
<leftLabel>isProjectOfPublication</leftLabel>
|
||||||
|
<rightLabel>isPublicationOfProject</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Publication</leftType>
|
||||||
|
<rightType>OrgUnit</rightType>
|
||||||
|
<leftLabel>isOrgUnitOfPublication</leftLabel>
|
||||||
|
<rightLabel>isPublicationOfOrgUnit</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Person</leftType>
|
||||||
|
<rightType>Project</rightType>
|
||||||
|
<leftLabel>isProjectOfPerson</leftLabel>
|
||||||
|
<rightLabel>isPersonOfProject</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Person</leftType>
|
||||||
|
<rightType>OrgUnit</rightType>
|
||||||
|
<leftLabel>isOrgUnitOfPerson</leftLabel>
|
||||||
|
<rightLabel>isPersonOfOrgUnit</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Project</leftType>
|
||||||
|
<rightType>OrgUnit</rightType>
|
||||||
|
<leftLabel>isOrgUnitOfProject</leftLabel>
|
||||||
|
<rightLabel>isProjectOfOrgUnit</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Journal</leftType>
|
||||||
|
<rightType>JournalVolume</rightType>
|
||||||
|
<leftLabel>isVolumeOfJournal</leftLabel>
|
||||||
|
<rightLabel>isJournalOfVolume</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>1</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>JournalVolume</leftType>
|
||||||
|
<rightType>JournalIssue</rightType>
|
||||||
|
<leftLabel>isIssueOfJournalVolume</leftLabel>
|
||||||
|
<rightLabel>isJournalVolumeOfIssue</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>1</min>
|
||||||
|
<max>1</max>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>Publication</leftType>
|
||||||
|
<rightType>OrgUnit</rightType>
|
||||||
|
<leftLabel>isAuthorOfPublication</leftLabel>
|
||||||
|
<rightLabel>isPublicationOfAuthor</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
<type>
|
||||||
|
<leftType>JournalIssue</leftType>
|
||||||
|
<rightType>Publication</rightType>
|
||||||
|
<leftLabel>isPublicationOfJournalIssue</leftLabel>
|
||||||
|
<rightLabel>isJournalIssueOfPublication</rightLabel>
|
||||||
|
<leftCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
</leftCardinality>
|
||||||
|
<rightCardinality>
|
||||||
|
<min>0</min>
|
||||||
|
<max>1</max>
|
||||||
|
</rightCardinality>
|
||||||
|
</type>
|
||||||
|
</relationships>
|
@@ -1838,16 +1838,16 @@ public class CollectionTest extends AbstractDSpaceObjectTest {
|
|||||||
public void testGetCommunities() throws Exception {
|
public void testGetCommunities() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
Community community = communityService.create(null, context);
|
Community community = communityService.create(null, context);
|
||||||
communityService.setMetadataSingleValue(context, community, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
communityService.setMetadataSingleValue(context, community, MetadataSchemaEnum.DC.getName(),
|
||||||
"community 3");
|
"title", null, Item.ANY, "community 3");
|
||||||
this.collection.addCommunity(community);
|
this.collection.addCommunity(community);
|
||||||
community = communityService.create(null, context);
|
community = communityService.create(null, context);
|
||||||
communityService.setMetadataSingleValue(context, community, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
communityService.setMetadataSingleValue(context, community, MetadataSchemaEnum.DC.getName(),
|
||||||
"community 1");
|
"title", null, Item.ANY, "community 1");
|
||||||
this.collection.addCommunity(community);
|
this.collection.addCommunity(community);
|
||||||
community = communityService.create(null, context);
|
community = communityService.create(null, context);
|
||||||
communityService.setMetadataSingleValue(context, community, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
communityService.setMetadataSingleValue(context, community, MetadataSchemaEnum.DC.getName(),
|
||||||
"community 2");
|
"title", null, Item.ANY, "community 2");
|
||||||
this.collection.addCommunity(community);
|
this.collection.addCommunity(community);
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
assertTrue("testGetCommunities 0", collection.getCommunities().size() == 4);
|
assertTrue("testGetCommunities 0", collection.getCommunities().size() == 4);
|
||||||
|
@@ -673,14 +673,17 @@ public class CommunityTest extends AbstractDSpaceObjectTest {
|
|||||||
|
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
Collection collection = collectionService.create(context, c);
|
Collection collection = collectionService.create(context, c);
|
||||||
collectionService.setMetadataSingleValue(context, collection, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
collectionService
|
||||||
"collection B");
|
.setMetadataSingleValue(context, collection, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, Item.ANY, "collection B");
|
||||||
collection = collectionService.create(context, c);
|
collection = collectionService.create(context, c);
|
||||||
collectionService.setMetadataSingleValue(context, collection, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
collectionService
|
||||||
"collection C");
|
.setMetadataSingleValue(context, collection, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, Item.ANY, "collection C");
|
||||||
collection = collectionService.create(context, c);
|
collection = collectionService.create(context, c);
|
||||||
collectionService.setMetadataSingleValue(context, collection, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
collectionService
|
||||||
"collection A");
|
.setMetadataSingleValue(context, collection, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, Item.ANY, "collection A");
|
||||||
//we need to commit the changes so we don't block the table for testing
|
//we need to commit the changes so we don't block the table for testing
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
@@ -712,14 +715,17 @@ public class CommunityTest extends AbstractDSpaceObjectTest {
|
|||||||
|
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
Community community = communityService.create(c, context);
|
Community community = communityService.create(c, context);
|
||||||
communityService.setMetadataSingleValue(context, community, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
communityService
|
||||||
"subcommunity B");
|
.setMetadataSingleValue(context, community, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, Item.ANY, "subcommunity B");
|
||||||
community = communityService.create(c, context);
|
community = communityService.create(c, context);
|
||||||
communityService.setMetadataSingleValue(context, community, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
communityService
|
||||||
"subcommunity A");
|
.setMetadataSingleValue(context, community, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, Item.ANY, "subcommunity A");
|
||||||
community = communityService.create(c, context);
|
community = communityService.create(c, context);
|
||||||
communityService.setMetadataSingleValue(context, community, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
communityService
|
||||||
"subcommunity C");
|
.setMetadataSingleValue(context, community, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, Item.ANY, "subcommunity C");
|
||||||
//we need to commit the changes so we don't block the table for testing
|
//we need to commit the changes so we don't block the table for testing
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
@@ -737,12 +737,12 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
|||||||
public void testGetCollections() throws Exception {
|
public void testGetCollections() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
Collection collection = collectionService.create(context, owningCommunity);
|
Collection collection = collectionService.create(context, owningCommunity);
|
||||||
collectionService.setMetadataSingleValue(context, collection, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
collectionService.setMetadataSingleValue(context, collection, MetadataSchemaEnum.DC.getName(),
|
||||||
"collection B");
|
"title", null, Item.ANY, "collection B");
|
||||||
it.addCollection(collection);
|
it.addCollection(collection);
|
||||||
collection = collectionService.create(context, owningCommunity);
|
collection = collectionService.create(context, owningCommunity);
|
||||||
collectionService.setMetadataSingleValue(context, collection, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY,
|
collectionService.setMetadataSingleValue(context, collection, MetadataSchemaEnum.DC.getName(),
|
||||||
"collection A");
|
"title", null, Item.ANY, "collection A");
|
||||||
it.addCollection(collection);
|
it.addCollection(collection);
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
assertThat("testGetCollections 0", it.getCollections(), notNullValue());
|
assertThat("testGetCollections 0", it.getCollections(), notNullValue());
|
||||||
|
@@ -78,14 +78,14 @@ public class MetadataFieldTest extends AbstractUnitTest {
|
|||||||
public void init() {
|
public void init() {
|
||||||
super.init();
|
super.init();
|
||||||
try {
|
try {
|
||||||
this.dcSchema = metadataSchemaService.find(context, MetadataSchema.DC_SCHEMA);
|
this.dcSchema = metadataSchemaService.find(context, MetadataSchemaEnum.DC.getName());
|
||||||
this.mf = metadataFieldService.findByElement(context,
|
this.mf = metadataFieldService.findByElement(context,
|
||||||
MetadataSchema.DC_SCHEMA, element, qualifier);
|
MetadataSchemaEnum.DC.getName(), element, qualifier);
|
||||||
if (mf == null) {
|
if (mf == null) {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
this.mf = metadataFieldService
|
this.mf = metadataFieldService
|
||||||
.create(context, metadataSchemaService.find(context, MetadataSchema.DC_SCHEMA), element, qualifier,
|
.create(context, metadataSchemaService.find(context, MetadataSchemaEnum.DC.getName()),
|
||||||
scopeNote);
|
element, qualifier, scopeNote);
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ public class MetadataFieldTest extends AbstractUnitTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetSchema() {
|
public void testGetSchema() {
|
||||||
assertThat("testGetSchemaID 0", mf.getMetadataSchema().getName(), equalTo(MetadataSchema.DC_SCHEMA));
|
assertThat("testGetSchemaID 0", mf.getMetadataSchema().getName(), equalTo(MetadataSchemaEnum.DC.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -259,7 +259,8 @@ public class MetadataFieldTest extends AbstractUnitTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFindByElement() throws Exception {
|
public void testFindByElement() throws Exception {
|
||||||
MetadataField found = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, element, qualifier);
|
MetadataField found = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
|
||||||
|
element, qualifier);
|
||||||
assertThat("testFindByElement 0", found, notNullValue());
|
assertThat("testFindByElement 0", found, notNullValue());
|
||||||
assertThat("testFindByElement 1", found.getID(), equalTo(mf.getID()));
|
assertThat("testFindByElement 1", found.getID(), equalTo(mf.getID()));
|
||||||
assertThat("testFindByElement 2", found.getElement(), equalTo(mf.getElement()));
|
assertThat("testFindByElement 2", found.getElement(), equalTo(mf.getElement()));
|
||||||
@@ -290,7 +291,7 @@ public class MetadataFieldTest extends AbstractUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFindAllInSchema() throws Exception {
|
public void testFindAllInSchema() throws Exception {
|
||||||
List<MetadataField> found = metadataFieldService
|
List<MetadataField> found = metadataFieldService
|
||||||
.findAllInSchema(context, metadataSchemaService.find(context, MetadataSchema.DC_SCHEMA));
|
.findAllInSchema(context, metadataSchemaService.find(context, MetadataSchemaEnum.DC.getName()));
|
||||||
assertThat("testFindAllInSchema 0", found, notNullValue());
|
assertThat("testFindAllInSchema 0", found, notNullValue());
|
||||||
assertTrue("testFindAllInSchema 1", found.size() >= 1);
|
assertTrue("testFindAllInSchema 1", found.size() >= 1);
|
||||||
assertTrue("testFindAllInSchema 2", found.size() <= metadataFieldService.findAll(context).size());
|
assertTrue("testFindAllInSchema 2", found.size() <= metadataFieldService.findAll(context).size());
|
||||||
@@ -320,7 +321,7 @@ public class MetadataFieldTest extends AbstractUnitTest {
|
|||||||
MetadataField m = metadataFieldService.create(context, dcSchema, elem, qual, null);
|
MetadataField m = metadataFieldService.create(context, dcSchema, elem, qual, null);
|
||||||
metadataFieldService.update(context, m);
|
metadataFieldService.update(context, m);
|
||||||
|
|
||||||
MetadataField found = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, elem, qual);
|
MetadataField found = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(), elem, qual);
|
||||||
assertThat("testUpdateAuth 0", found.getID(), equalTo(m.getID()));
|
assertThat("testUpdateAuth 0", found.getID(), equalTo(m.getID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,7 +381,7 @@ public class MetadataFieldTest extends AbstractUnitTest {
|
|||||||
|
|
||||||
metadataFieldService.delete(context, m);
|
metadataFieldService.delete(context, m);
|
||||||
|
|
||||||
MetadataField found = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, elem, qual);
|
MetadataField found = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(), elem, qual);
|
||||||
assertThat("testDeleteAuth 0", found, nullValue());
|
assertThat("testDeleteAuth 0", found, nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ public class MetadataSchemaTest extends AbstractUnitTest {
|
|||||||
public void init() {
|
public void init() {
|
||||||
super.init();
|
super.init();
|
||||||
try {
|
try {
|
||||||
this.ms = metadataSchemaService.find(context, MetadataSchema.DC_SCHEMA);
|
this.ms = metadataSchemaService.find(context, MetadataSchemaEnum.DC.getName());
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
log.error("SQL Error in init", ex);
|
log.error("SQL Error in init", ex);
|
||||||
fail("SQL Error in init: " + ex.getMessage());
|
fail("SQL Error in init: " + ex.getMessage());
|
||||||
@@ -122,7 +122,7 @@ public class MetadataSchemaTest extends AbstractUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetSchemaID() throws SQLException {
|
public void testGetSchemaID() throws SQLException {
|
||||||
assertThat("testGetSchemaID 0", ms.getID(),
|
assertThat("testGetSchemaID 0", ms.getID(),
|
||||||
equalTo(metadataSchemaService.find(context, MetadataSchema.DC_SCHEMA).getID()));
|
equalTo(metadataSchemaService.find(context, MetadataSchemaEnum.DC.getName()).getID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -95,7 +95,7 @@ public class MetadataValueTest extends AbstractUnitTest {
|
|||||||
this.it = installItemService.installItem(context, workspaceItem);
|
this.it = installItemService.installItem(context, workspaceItem);
|
||||||
|
|
||||||
this.mf = metadataFieldService.findByElement(context,
|
this.mf = metadataFieldService.findByElement(context,
|
||||||
MetadataSchema.DC_SCHEMA, element, qualifier);
|
MetadataSchemaEnum.DC.getName(), element, qualifier);
|
||||||
this.mv = metadataValueService.create(context, it, mf);
|
this.mv = metadataValueService.create(context, it, mf);
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
} catch (AuthorizeException ex) {
|
} catch (AuthorizeException ex) {
|
||||||
|
@@ -36,7 +36,7 @@ import org.dspace.content.Collection;
|
|||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.crosswalk.CrosswalkException;
|
import org.dspace.content.crosswalk.CrosswalkException;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
@@ -164,17 +164,18 @@ public class ITDSpaceAIP extends AbstractUnitTest {
|
|||||||
//
|
//
|
||||||
Community topCommunity = communityService.create(null, context);
|
Community topCommunity = communityService.create(null, context);
|
||||||
communityService
|
communityService
|
||||||
.addMetadata(context, topCommunity, MetadataSchema.DC_SCHEMA, "title", null, null, "Top Community");
|
.addMetadata(context, topCommunity, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, null, "Top Community");
|
||||||
communityService.update(context, topCommunity);
|
communityService.update(context, topCommunity);
|
||||||
topCommunityHandle = topCommunity.getHandle();
|
topCommunityHandle = topCommunity.getHandle();
|
||||||
|
|
||||||
Community child = communityService.createSubcommunity(context, topCommunity);
|
Community child = communityService.createSubcommunity(context, topCommunity);
|
||||||
communityService
|
communityService
|
||||||
.addMetadata(context, child, MetadataSchema.DC_SCHEMA, "title", null, null, "Child Community");
|
.addMetadata(context, child, MetadataSchemaEnum.DC.getName(), "title", null, null, "Child Community");
|
||||||
communityService.update(context, child);
|
communityService.update(context, child);
|
||||||
|
|
||||||
Community grandchild = communityService.createSubcommunity(context, child);
|
Community grandchild = communityService.createSubcommunity(context, child);
|
||||||
communityService.addMetadata(context, grandchild, MetadataSchema.DC_SCHEMA, "title", null, null,
|
communityService.addMetadata(context, grandchild, MetadataSchemaEnum.DC.getName(), "title", null, null,
|
||||||
"Grandchild Community");
|
"Grandchild Community");
|
||||||
communityService.update(context, grandchild);
|
communityService.update(context, grandchild);
|
||||||
|
|
||||||
@@ -558,8 +559,9 @@ public class ITDSpaceAIP extends AbstractUnitTest {
|
|||||||
|
|
||||||
// Change the Community name
|
// Change the Community name
|
||||||
String newName = "This is NOT my Community name!";
|
String newName = "This is NOT my Community name!";
|
||||||
communityService.clearMetadata(context, topCommunity, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
communityService.clearMetadata(context, topCommunity, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
|
||||||
communityService.addMetadata(context, topCommunity, MetadataSchema.DC_SCHEMA, "title", null, null, newName);
|
communityService.addMetadata(context, topCommunity, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, null, newName);
|
||||||
|
|
||||||
// Ensure name is changed
|
// Ensure name is changed
|
||||||
assertEquals("testReplaceCommunityOnly() new name", topCommunity.getName(), newName);
|
assertEquals("testReplaceCommunityOnly() new name", topCommunity.getName(), newName);
|
||||||
@@ -781,8 +783,10 @@ public class ITDSpaceAIP extends AbstractUnitTest {
|
|||||||
|
|
||||||
// Change the Collection name
|
// Change the Collection name
|
||||||
String newName = "This is NOT my Collection name!";
|
String newName = "This is NOT my Collection name!";
|
||||||
collectionService.clearMetadata(context, testCollection, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
collectionService.clearMetadata(context, testCollection, MetadataSchemaEnum.DC.getName(),
|
||||||
collectionService.addMetadata(context, testCollection, MetadataSchema.DC_SCHEMA, "title", null, null, newName);
|
"title", null, Item.ANY);
|
||||||
|
collectionService.addMetadata(context, testCollection, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, null, newName);
|
||||||
|
|
||||||
// Ensure name is changed
|
// Ensure name is changed
|
||||||
assertEquals("testReplaceCollectionOnly() new name", testCollection.getName(), newName);
|
assertEquals("testReplaceCollectionOnly() new name", testCollection.getName(), newName);
|
||||||
@@ -1029,8 +1033,8 @@ public class ITDSpaceAIP extends AbstractUnitTest {
|
|||||||
|
|
||||||
// Change the Item name
|
// Change the Item name
|
||||||
String newName = "This is NOT my Item name!";
|
String newName = "This is NOT my Item name!";
|
||||||
itemService.clearMetadata(context, testItem, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
itemService.clearMetadata(context, testItem, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
|
||||||
itemService.addMetadata(context, testItem, MetadataSchema.DC_SCHEMA, "title", null, null, newName);
|
itemService.addMetadata(context, testItem, MetadataSchemaEnum.DC.getName(), "title", null, null, newName);
|
||||||
|
|
||||||
// Ensure name is changed
|
// Ensure name is changed
|
||||||
assertEquals("testReplaceItem() new name", testItem.getName(), newName);
|
assertEquals("testReplaceItem() new name", testItem.getName(), newName);
|
||||||
|
@@ -20,7 +20,7 @@ import org.dspace.AbstractUnitTest;
|
|||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
@@ -87,13 +87,14 @@ public class PackageUtilsTest extends AbstractUnitTest {
|
|||||||
//
|
//
|
||||||
Community topCommunity = communityService.create(null, context);
|
Community topCommunity = communityService.create(null, context);
|
||||||
communityService
|
communityService
|
||||||
.addMetadata(context, topCommunity, MetadataSchema.DC_SCHEMA, "title", null, null, "Top Community");
|
.addMetadata(context, topCommunity, MetadataSchemaEnum.DC.getName(), "title", null, null,
|
||||||
|
"Top Community");
|
||||||
communityService.update(context, topCommunity);
|
communityService.update(context, topCommunity);
|
||||||
topCommunityHandle = topCommunity.getHandle();
|
topCommunityHandle = topCommunity.getHandle();
|
||||||
|
|
||||||
Community child = communityService.createSubcommunity(context, topCommunity);
|
Community child = communityService.createSubcommunity(context, topCommunity);
|
||||||
communityService
|
communityService
|
||||||
.addMetadata(context, child, MetadataSchema.DC_SCHEMA, "title", null, null, "Child Community");
|
.addMetadata(context, child, MetadataSchemaEnum.DC.getName(), "title", null, null, "Child Community");
|
||||||
communityService.update(context, child);
|
communityService.update(context, child);
|
||||||
|
|
||||||
// Create our primary Test Collection
|
// Create our primary Test Collection
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>dspace-oai</artifactId>
|
<artifactId>dspace-oai</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>DSpace OAI-PMH</name>
|
<name>DSpace OAI-PMH</name>
|
||||||
<description>DSpace OAI-PMH Web Application and API</description>
|
<description>DSpace OAI-PMH Extension</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dspace-parent</artifactId>
|
<artifactId>dspace-parent</artifactId>
|
||||||
@@ -17,34 +16,19 @@
|
|||||||
<!-- This is the path to the root [dspace-src] directory. -->
|
<!-- This is the path to the root [dspace-src] directory. -->
|
||||||
<root.basedir>${basedir}/..</root.basedir>
|
<root.basedir>${basedir}/..</root.basedir>
|
||||||
<xoai.version>3.2.10</xoai.version>
|
<xoai.version>3.2.10</xoai.version>
|
||||||
<jtwig.version>2.0.1</jtwig.version>
|
<!-- NOTE: Once updated to Spring Boot v2, this should update to 5.87.0.RELEASE -->
|
||||||
|
<jtwig.version>5.86.1.RELEASE</jtwig.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<attachClasses>true</attachClasses>
|
|
||||||
<!-- In version 2.1-alpha-1, this was incorrectly named warSourceExcludes -->
|
|
||||||
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
|
|
||||||
<warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
|
|
||||||
<!-- Filter the web.xml (needed for IDE compatibility/debugging) -->
|
|
||||||
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>prepare-package</phase>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.mycila</groupId>
|
<groupId>com.mycila</groupId>
|
||||||
<artifactId>license-maven-plugin</artifactId>
|
<artifactId>license-maven-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>src/main/webapp/**</exclude>
|
<!-- Ignore license header requirements on CSS/images/HTML/XSL -->
|
||||||
|
<exclude>src/main/resources/**</exclude>
|
||||||
<exclude>**/*.xsl</exclude>
|
<exclude>**/*.xsl</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -107,74 +91,63 @@
|
|||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<!-- Later version provided by SolrJ -->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.codehaus.woodstox</groupId>
|
||||||
|
<artifactId>wstx-asl</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Java Injection and MVC -->
|
<!-- Java Injection -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.inject</groupId>
|
<groupId>javax.inject</groupId>
|
||||||
<artifactId>javax.inject</artifactId>
|
<artifactId>javax.inject</artifactId>
|
||||||
<version>1</version>
|
<version>1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Needed to support Spring @Configuration classes (to register servlets/beans with Spring Boot webapp) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-webmvc</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
<version>${spring.version}</version>
|
<version>${spring-boot.version}</version>
|
||||||
</dependency>
|
<exclusions>
|
||||||
<dependency>
|
<exclusion>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-beans</artifactId>
|
<artifactId>spring-boot-starter-logging</artifactId>
|
||||||
<version>${spring.version}</version>
|
</exclusion>
|
||||||
</dependency>
|
</exclusions>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-context</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-web</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Templating Engine -->
|
<!-- Templating Engine -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.lyncode</groupId>
|
<groupId>org.jtwig</groupId>
|
||||||
<artifactId>jtwig-spring</artifactId>
|
<artifactId>jtwig-spring-boot-starter</artifactId>
|
||||||
<version>${jtwig.version}</version>
|
<version>${jtwig.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
|
<!-- We don't need spring-boot-starter-web, it is provided by our Spring Boot webapp -->
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<!-- More recent version is pulled in via solr-core -->
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.javassist</groupId>
|
<groupId>org.ow2.asm</groupId>
|
||||||
<artifactId>javassist</artifactId>
|
<artifactId>asm</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<!-- This exclusion may be removable once we update to Spring Boot v2 -->
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -284,7 +257,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.parboiled</groupId>
|
<groupId>org.parboiled</groupId>
|
||||||
<artifactId>parboiled-core</artifactId>
|
<artifactId>parboiled-core</artifactId>
|
||||||
<version>1.1.6</version>
|
<version>1.1.7</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -294,24 +267,4 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<developers>
|
|
||||||
<developer>
|
|
||||||
<name>DSpace @ Lyncode</name>
|
|
||||||
<email>dspace@lyncode.com</email>
|
|
||||||
<organization>Lyncode</organization>
|
|
||||||
<organizationUrl>http://www.lyncode.com</organizationUrl>
|
|
||||||
</developer>
|
|
||||||
<developer>
|
|
||||||
<id>helix84</id>
|
|
||||||
<name>Ivan Másar</name>
|
|
||||||
<email>helix84@centrum.sk</email>
|
|
||||||
</developer>
|
|
||||||
<developer>
|
|
||||||
<name>Ariel J. Lira</name>
|
|
||||||
<email>arieljlira@gmail.com</email>
|
|
||||||
<organization>SeDiCI</organization>
|
|
||||||
<organizationUrl>http://sedici.unlp.edu.ar</organizationUrl>
|
|
||||||
</developer>
|
|
||||||
</developers>
|
|
||||||
</project>
|
</project>
|
||||||
|
@@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.configuration;
|
||||||
|
import static java.lang.Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
import org.dspace.xoai.app.BasicConfiguration;
|
||||||
|
import org.dspace.xoai.services.api.xoai.ItemRepositoryResolver;
|
||||||
|
import org.dspace.xoai.services.impl.xoai.DSpaceItemRepositoryResolver;
|
||||||
|
import org.jtwig.spring.JtwigViewResolver;
|
||||||
|
import org.jtwig.spring.boot.config.JtwigViewResolverConfigurer;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAI-PMH webapp configuration. Replaces the old web.xml
|
||||||
|
* <p>
|
||||||
|
* This @Configuration class is automatically discovered by Spring Boot via a @ComponentScan
|
||||||
|
* on the org.dspace.app.configuration package.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Tim Donohue
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
// Import additional configuration and beans from BasicConfiguration
|
||||||
|
@Import(BasicConfiguration.class)
|
||||||
|
// Scan for controllers in this package
|
||||||
|
@ComponentScan("org.dspace.xoai.controller")
|
||||||
|
public class OAIWebConfig extends WebMvcConfigurerAdapter implements JtwigViewResolverConfigurer {
|
||||||
|
|
||||||
|
// Path where OAI is deployed. Defaults to "oai"
|
||||||
|
// NOTE: deployment on this path is handled by org.dspace.xoai.controller.DSpaceOAIDataProvider
|
||||||
|
@Value("${oai.path:oai}")
|
||||||
|
private String oaiPath;
|
||||||
|
|
||||||
|
private static final String TWIG_HTML_EXTENSION = ".twig.html";
|
||||||
|
private static final String VIEWS_LOCATION = "classpath:/templates/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure all resources under src/main/resources/static/ directory are available
|
||||||
|
* off the /{oai.path}/static subpath
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
registry.addResourceHandler("/" + oaiPath + "/static/**")
|
||||||
|
.addResourceLocations("classpath:/static/")
|
||||||
|
.setCachePeriod(MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the Jtwig template engine for Spring Boot
|
||||||
|
* Ensures Jtwig looks for templates in proper location with proper extension
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void configure(JtwigViewResolver viewResolver) {
|
||||||
|
viewResolver.setPrefix(VIEWS_LOCATION);
|
||||||
|
viewResolver.setSuffix(TWIG_HTML_EXTENSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ItemRepositoryResolver xoaiItemRepositoryResolver() {
|
||||||
|
return new DSpaceItemRepositoryResolver();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -1,62 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.xoai.app;
|
|
||||||
|
|
||||||
import static java.lang.Integer.MAX_VALUE;
|
|
||||||
|
|
||||||
import com.lyncode.jtwig.mvc.JtwigViewResolver;
|
|
||||||
import org.dspace.xoai.services.api.xoai.ItemRepositoryResolver;
|
|
||||||
import org.dspace.xoai.services.impl.xoai.DSpaceItemRepositoryResolver;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Import;
|
|
||||||
import org.springframework.web.servlet.ViewResolver;
|
|
||||||
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
||||||
|
|
||||||
@Import( {
|
|
||||||
BasicConfiguration.class
|
|
||||||
})
|
|
||||||
@Configuration
|
|
||||||
@EnableWebMvc
|
|
||||||
@ComponentScan("org.dspace.xoai.controller")
|
|
||||||
public class DSpaceWebappConfiguration extends WebMvcConfigurerAdapter {
|
|
||||||
private static final String TWIG_HTML_EXTENSION = ".twig.html";
|
|
||||||
private static final String VIEWS_LOCATION = "/WEB-INF/views/";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
||||||
registry.addResourceHandler("/static/**")
|
|
||||||
.addResourceLocations("/static/")
|
|
||||||
.setCachePeriod(MAX_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
|
||||||
configurer.enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ViewResolver viewResolver() {
|
|
||||||
JtwigViewResolver viewResolver = new JtwigViewResolver();
|
|
||||||
viewResolver.setPrefix(VIEWS_LOCATION);
|
|
||||||
viewResolver.setSuffix(TWIG_HTML_EXTENSION);
|
|
||||||
viewResolver.setCached(false);
|
|
||||||
|
|
||||||
return viewResolver;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ItemRepositoryResolver xoaiItemRepositoryResolver() {
|
|
||||||
return new DSpaceItemRepositoryResolver();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -40,6 +40,7 @@ import org.dspace.xoai.services.api.xoai.ItemRepositoryResolver;
|
|||||||
import org.dspace.xoai.services.api.xoai.SetRepositoryResolver;
|
import org.dspace.xoai.services.api.xoai.SetRepositoryResolver;
|
||||||
import org.dspace.xoai.services.impl.xoai.DSpaceResumptionTokenFormatter;
|
import org.dspace.xoai.services.impl.xoai.DSpaceResumptionTokenFormatter;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@@ -49,6 +50,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
* @author Lyncode Development Team (dspace at lyncode dot com)
|
* @author Lyncode Development Team (dspace at lyncode dot com)
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
|
// Use the configured "oai.path" for all requests, or "/oai" by default
|
||||||
|
@RequestMapping("/${oai.path:oai}")
|
||||||
|
// Only enable this controller if "oai.enabled=true"
|
||||||
|
@ConditionalOnProperty("oai.enabled")
|
||||||
public class DSpaceOAIDataProvider {
|
public class DSpaceOAIDataProvider {
|
||||||
private static final Logger log = getLogger(DSpaceOAIDataProvider.class);
|
private static final Logger log = getLogger(DSpaceOAIDataProvider.class);
|
||||||
|
|
||||||
@@ -67,7 +72,7 @@ public class DSpaceOAIDataProvider {
|
|||||||
|
|
||||||
private DSpaceResumptionTokenFormatter resumptionTokenFormat = new DSpaceResumptionTokenFormatter();
|
private DSpaceResumptionTokenFormatter resumptionTokenFormat = new DSpaceResumptionTokenFormatter();
|
||||||
|
|
||||||
@RequestMapping("/")
|
@RequestMapping({"", "/"})
|
||||||
public String indexAction(HttpServletResponse response, Model model) throws ServletException {
|
public String indexAction(HttpServletResponse response, Model model) throws ServletException {
|
||||||
try {
|
try {
|
||||||
XOAIManager manager = xoaiManagerResolver.getManager();
|
XOAIManager manager = xoaiManagerResolver.getManager();
|
||||||
|
@@ -10,6 +10,8 @@ package org.dspace.xoai.services.impl;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.persistence.NoResultException;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
@@ -30,11 +32,16 @@ public class DSpaceEarliestDateResolver implements EarliestDateResolver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getEarliestDate(Context context) throws InvalidMetadataFieldException, SQLException {
|
public Date getEarliestDate(Context context) throws InvalidMetadataFieldException, SQLException {
|
||||||
String query = "SELECT MIN(text_value) as value FROM metadatavalue WHERE metadata_field_id = ?";
|
|
||||||
|
|
||||||
MetadataValueService metadataValueService = ContentServiceFactory.getInstance().getMetadataValueService();
|
MetadataValueService metadataValueService = ContentServiceFactory.getInstance().getMetadataValueService();
|
||||||
MetadataValue minimum = metadataValueService.getMinimum(context,
|
MetadataValue minimum = null;
|
||||||
fieldResolver.getFieldID(context, "dc.date.available"));
|
try {
|
||||||
|
minimum = metadataValueService.getMinimum(context,
|
||||||
|
fieldResolver.getFieldID(context, "dc.date.available"));
|
||||||
|
} catch (NoResultException e) {
|
||||||
|
// This error only occurs if no metadataFields of this type exist (i.e. no minimum exists)
|
||||||
|
// It can be safely ignored in this scenario, as it implies the DSpace is empty.
|
||||||
|
}
|
||||||
|
|
||||||
if (null != minimum) {
|
if (null != minimum) {
|
||||||
String str = minimum.getValue();
|
String str = minimum.getValue();
|
||||||
try {
|
try {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user