mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
DSpace 7 Entities
This commit is contained in:
@@ -27,6 +27,7 @@ import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||
import org.dspace.authority.service.AuthorityValueService;
|
||||
@@ -208,7 +209,7 @@ public class DSpaceCSV implements Serializable {
|
||||
// Check that the metadata element exists in the schema
|
||||
MetadataField foundField = metadataFieldService
|
||||
.findByElement(c, foundSchema, metadataElement, metadataQualifier);
|
||||
if (foundField == null) {
|
||||
if (foundField == null && !StringUtils.equals(metadataSchema, "relationship")) {
|
||||
throw new MetadataImportInvalidHeadingException(clean[0],
|
||||
MetadataImportInvalidHeadingException.ELEMENT,
|
||||
columnCounter);
|
||||
|
@@ -15,6 +15,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -33,14 +34,22 @@ import org.dspace.authority.service.AuthorityValueService;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Entity;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.Relationship;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.content.authority.Choices;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
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.ItemService;
|
||||
import org.dspace.content.service.RelationshipService;
|
||||
import org.dspace.content.service.RelationshipTypeService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
@@ -101,6 +110,10 @@ public class MetadataImport {
|
||||
protected final CollectionService collectionService;
|
||||
protected final HandleService handleService;
|
||||
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
|
||||
@@ -120,6 +133,10 @@ public class MetadataImport {
|
||||
handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||
authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
||||
workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
|
||||
relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||
relationshipTypeService = ContentServiceFactory.getInstance().getRelationshipTypeService();
|
||||
entityTypeService = ContentServiceFactory.getInstance().getEntityTypeService();
|
||||
entityService = ContentServiceFactory.getInstance().getEntityService();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,16 +353,30 @@ public class MetadataImport {
|
||||
item = wsItem.getItem();
|
||||
|
||||
// Add the metadata to the item
|
||||
List<BulkEditMetadataValue> relationships = new LinkedList<>();
|
||||
for (BulkEditMetadataValue dcv : whatHasChanged.getAdds()) {
|
||||
itemService.addMetadata(c, item, dcv.getSchema(),
|
||||
dcv.getElement(),
|
||||
dcv.getQualifier(),
|
||||
dcv.getLanguage(),
|
||||
dcv.getValue(),
|
||||
dcv.getAuthority(),
|
||||
dcv.getConfidence());
|
||||
if (StringUtils.equals(dcv.getSchema(), "relationship")) {
|
||||
|
||||
if (!StringUtils.equals(dcv.getElement(), "type")) {
|
||||
relationships.add(dcv);
|
||||
} else {
|
||||
handleRelationshipMetadataValueFromBulkEditMetadataValue(item, dcv);
|
||||
}
|
||||
|
||||
} 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?
|
||||
if (useWorkflow) {
|
||||
WorkflowService workflowService = WorkflowServiceFactory.getInstance().getWorkflowService();
|
||||
@@ -396,6 +427,19 @@ public class MetadataImport {
|
||||
return changes;
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
@@ -583,9 +627,154 @@ public class MetadataImport {
|
||||
}
|
||||
}
|
||||
|
||||
// Set those values
|
||||
|
||||
if (StringUtils.equals(schema, "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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
handleRelationOtherMetadata(c, item, element, values);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleRelationOtherMetadata(Context c, Item item, String element, List<String> values)
|
||||
throws SQLException, AuthorizeException {
|
||||
Entity entity = entityService.findByItemId(c, item.getID());
|
||||
boolean left = false;
|
||||
List<RelationshipType> acceptableRelationshipTypes = new LinkedList<>();
|
||||
String[] components = values.get(0).split("-");
|
||||
String url = handleService.resolveToURL(c, values.get(0));
|
||||
if (components.length != 5 && StringUtils.isNotBlank(url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity relationEntity = entityService.findByItemId(c, UUID.fromString(values.get(0)));
|
||||
|
||||
|
||||
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) {
|
||||
System.out.println("Ambiguous relationship_types were found");
|
||||
log.error("Ambiguous relationship_types were found");
|
||||
return;
|
||||
}
|
||||
if (acceptableRelationshipTypes.size() == 0) {
|
||||
System.out.println("no relationship_types were found");
|
||||
log.error("no relationship_types were found");
|
||||
return;
|
||||
}
|
||||
|
||||
buildRelationObject(c, item, values, left, acceptableRelationshipTypes);
|
||||
}
|
||||
|
||||
private void buildRelationObject(Context c, Item item, List<String> values, boolean left,
|
||||
List<RelationshipType> acceptableRelationshipTypes)
|
||||
throws SQLException, AuthorizeException {
|
||||
Relationship relationship = new Relationship();
|
||||
RelationshipType acceptedRelationshipType = acceptableRelationshipTypes.get(0);
|
||||
if (left) {
|
||||
relationship.setLeftItem(item);
|
||||
relationship.setRightItem(itemService.findByIdOrLegacyId(c, values.get(0)));
|
||||
} else {
|
||||
relationship.setRightItem(item);
|
||||
relationship.setLeftItem(itemService.findByIdOrLegacyId(c, values.get(0)));
|
||||
}
|
||||
relationship.setRelationshipType(acceptedRelationshipType);
|
||||
relationship.setLeftPlace(relationshipService.findLeftPlaceByLeftItem(c, relationship.getLeftItem()) + 1);
|
||||
relationship.setRightPlace(relationshipService.findRightPlaceByRightItem(c, relationship.getLeftItem()) + 1);
|
||||
Relationship persistedRelationship = relationshipService.create(c, relationship);
|
||||
relationshipService.update(c, persistedRelationship);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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.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);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,376 @@
|
||||
/**
|
||||
* 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.sql.SQLException;
|
||||
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.Relationship;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
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;
|
||||
|
||||
public class AdditionalRelationshipScript {
|
||||
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
private RelationshipService relationshipService;
|
||||
private EntityTypeService entityTypeService;
|
||||
private ItemService itemService;
|
||||
|
||||
private AdditionalRelationshipScript() {
|
||||
relationshipTypeService = ContentServiceFactory.getInstance().getRelationshipTypeService();
|
||||
relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||
entityTypeService = ContentServiceFactory.getInstance().getEntityTypeService();
|
||||
itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
}
|
||||
|
||||
public static void main(String[] argv) throws SQLException, AuthorizeException, ParseException {
|
||||
AdditionalRelationshipScript additionalRelationshipScript = new AdditionalRelationshipScript();
|
||||
additionalRelationshipScript.execute();
|
||||
}
|
||||
|
||||
private void execute() throws SQLException, AuthorizeException {
|
||||
Context context = new Context();
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//(left label) -> isAuthorOfPublication => Publication is leftItem
|
||||
|
||||
Item article1 = itemService.findByIdOrLegacyId(context, "e98b0f27-5c19-49a0-960d-eb6ad5287067");
|
||||
Item article2 = itemService.findByIdOrLegacyId(context, "96715576-3748-4761-ad45-001646632963");
|
||||
Item article3 = itemService.findByIdOrLegacyId(context, "047556d1-3d01-4c53-bc68-0cee7ad7ed4e");
|
||||
Item article4 = itemService.findByIdOrLegacyId(context, "2f4ec582-109e-4952-a94a-b7d7615a8c69");
|
||||
Item article5 = itemService.findByIdOrLegacyId(context, "99c2e55c-6326-4442-9f36-fcac333b0e8c");
|
||||
Item article6 = itemService.findByIdOrLegacyId(context, "e7bd0d24-e83a-486a-bc0c-8aaaeb19dc7d");
|
||||
Item article7 = itemService.findByIdOrLegacyId(context, "72635f7f-37b5-4875-b4f2-5ff45d97a09b");
|
||||
Item article8 = itemService.findByIdOrLegacyId(context, "674f695e-8001-4150-8f9c-095c536a6bcb");
|
||||
Item article9 = itemService.findByIdOrLegacyId(context, "a64719f8-ba7b-41d1-8eb6-f8feb0c000b7");
|
||||
|
||||
Item author1 = itemService.findByIdOrLegacyId(context, "0ffbee3f-e7ea-42bc-92fe-2fbef1a52c0f");
|
||||
Item author2 = itemService.findByIdOrLegacyId(context, "5a3f7c7a-d3df-419c-b8a2-f00ede62c60a");
|
||||
Item author3 = itemService.findByIdOrLegacyId(context, "f2235aa6-6fe7-4174-a690-598b72dd8e44");
|
||||
|
||||
Item orgUnit1 = itemService.findByIdOrLegacyId(context, "d30de96b-1e76-40ae-8ef9-ab426b6f9763");
|
||||
Item orgUnit2 = itemService.findByIdOrLegacyId(context, "506a7e54-8d7c-4d5b-8636-d5f6411483de");
|
||||
Item orgUnit3 = itemService.findByIdOrLegacyId(context, "c216201f-ed10-4361-b0e0-5a065405bd3e");
|
||||
|
||||
Item project1 = itemService.findByIdOrLegacyId(context, "0de99067-c898-4d02-a82c-9555f3311288");
|
||||
Item project2 = itemService.findByIdOrLegacyId(context, "b1bc3a49-49b1-417a-ac90-8d5c7ba5e0ac");
|
||||
Item project3 = itemService.findByIdOrLegacyId(context, "18e7924c-f15b-4953-9fe3-3de370bccc97");
|
||||
|
||||
Item journal1 = itemService.findByIdOrLegacyId(context, "d4af6c3e-53d0-4757-81eb-566f3b45d63a");
|
||||
Item journal2 = itemService.findByIdOrLegacyId(context, "a23eae5a-7857-4ef9-8e52-989436ad2955");
|
||||
|
||||
Item journalVolume1OfJournal1 = itemService.findByIdOrLegacyId(context, "07c6249f-4bf7-494d-9ce3-6ffdb2aed538");
|
||||
Item journalVolume2OfJournal1 = itemService.findByIdOrLegacyId(context, "66bb4e5d-b419-42b7-a648-f270a527f17c");
|
||||
|
||||
Item journalVolume1OfJournal2 = itemService.findByIdOrLegacyId(context, "f9b89a11-b44e-4a64-a3b4-ab24a33553c7");
|
||||
Item journalVolume2OfJournal2 = itemService.findByIdOrLegacyId(context, "343d3263-2733-4367-9dc4-216a01b4a461");
|
||||
|
||||
Item journalIssue1OfJournalVolume1OfJournal1 = itemService.findByIdOrLegacyId
|
||||
(context, "44c29473-5de2-48fa-b005-e5029aa1a50b");
|
||||
Item journalIssue2OfJournalVolume1OfJournal1 = itemService.findByIdOrLegacyId
|
||||
(context, "c3076837-e5df-4221-80bc-2661cd390a7b");
|
||||
Item journalIssue1OfJournalVolume2OfJournal1 = itemService.findByIdOrLegacyId
|
||||
(context, "a4a63ab5-8c0b-4456-b5f7-5b5d9828cb69");
|
||||
|
||||
Item journalIssue1OfJournalVolume1OfJournal2 = itemService.findByIdOrLegacyId
|
||||
(context, "77877343-3f75-4c33-9492-6ed7c98ed84e");
|
||||
Item journalIssue2OfJournalVolume1OfJournal2 = itemService.findByIdOrLegacyId
|
||||
(context, "f4dcd8a6-4cc4-4806-8bb9-a7e8202e05b0");
|
||||
Item journalIssue1OfJournalVolume2OfJournal2 = itemService.findByIdOrLegacyId
|
||||
(context, "b7003f66-80e9-4c98-99a2-3695e8150b80");
|
||||
Item journalIssue2OfJournalVolume2OfJournal2 = itemService.findByIdOrLegacyId
|
||||
(context, "db55298c-a21f-4677-8793-a21f1194a226");
|
||||
|
||||
RelationshipType isAuthorOfPublication = relationshipTypeService.find(context, 1);
|
||||
RelationshipType isProjectOfPublication = relationshipTypeService.find(context, 2);
|
||||
RelationshipType isOrgUnitOfPublication = relationshipTypeService.find(context, 3);
|
||||
RelationshipType isProjectOfPerson = relationshipTypeService.find(context, 4);
|
||||
RelationshipType isOrgUnitOfPerson = relationshipTypeService.find(context, 5);
|
||||
RelationshipType isOrgUnitOfProject = relationshipTypeService.find(context, 6);
|
||||
RelationshipType isVolumeOfJournal = relationshipTypeService.find(context, 7);
|
||||
RelationshipType isIssueOfJournalVolume = relationshipTypeService.find(context, 8);
|
||||
RelationshipType isPublicationOfJournalIssue = relationshipTypeService.find(context, 9);
|
||||
|
||||
RelationshipType isAuthorOfPublicationNew = relationshipTypeService.find(context, 10);
|
||||
constructRelationshipAndStore(context, article1, orgUnit1, isAuthorOfPublicationNew, 1);
|
||||
constructRelationshipAndStore(context, article1, orgUnit2, isAuthorOfPublicationNew, 1);
|
||||
constructRelationshipAndStore(context, article1, orgUnit3, isAuthorOfPublicationNew, 1);
|
||||
|
||||
constructRelationshipAndStore(context, article1, author1, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article1, author2, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article1, author3, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article2, author1, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article2, author3, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article3, author3, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article4, author3, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article4, author2, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article4, author1, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article5, author1, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article6, author2, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article6, author3, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article7, author3, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article7, author2, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article7, author1, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article8, author2, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article9, author3, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article9, author1, isAuthorOfPublication, 1);
|
||||
|
||||
constructRelationshipAndStore(context, article1, project1, isProjectOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article6, project1, isProjectOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article7, project1, isProjectOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article1, project2, isProjectOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article9, project3, isProjectOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article8, project3, isProjectOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article4, project3, isProjectOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article5, project3, isProjectOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article2, project3, isProjectOfPublication, 1);
|
||||
|
||||
constructRelationshipAndStore(context, article1, orgUnit1, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article1, orgUnit2, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article1, orgUnit3, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article2, orgUnit1, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article2, orgUnit3, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article3, orgUnit3, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article4, orgUnit3, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article4, orgUnit2, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article4, orgUnit1, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article5, orgUnit1, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article6, orgUnit2, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article6, orgUnit3, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article7, orgUnit3, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article7, orgUnit2, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article7, orgUnit1, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article8, orgUnit2, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article9, orgUnit3, isOrgUnitOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article9, orgUnit1, isOrgUnitOfPublication, 1);
|
||||
|
||||
constructRelationshipAndStore(context, project1, orgUnit1, isOrgUnitOfProject, 1);
|
||||
constructRelationshipAndStore(context, project2, orgUnit2, isOrgUnitOfProject, 1);
|
||||
constructRelationshipAndStore(context, project3, orgUnit2, isOrgUnitOfProject, 1);
|
||||
constructRelationshipAndStore(context, project2, orgUnit3, isOrgUnitOfProject, 1);
|
||||
constructRelationshipAndStore(context, project1, orgUnit3, isOrgUnitOfProject, 1);
|
||||
constructRelationshipAndStore(context, project3, orgUnit3, isOrgUnitOfProject, 1);
|
||||
|
||||
|
||||
constructRelationshipAndStore(context, author1, project1, isProjectOfPerson, 1);
|
||||
constructRelationshipAndStore(context, author2, project2, isProjectOfPerson, 1);
|
||||
constructRelationshipAndStore(context, author2, project3, isProjectOfPerson, 1);
|
||||
constructRelationshipAndStore(context, author3, project1, isProjectOfPerson, 1);
|
||||
constructRelationshipAndStore(context, author3, project2, isProjectOfPerson, 1);
|
||||
constructRelationshipAndStore(context, author3, project3, isProjectOfPerson, 1);
|
||||
|
||||
constructRelationshipAndStore(context, author1,orgUnit1 ,isOrgUnitOfPerson, 1);
|
||||
constructRelationshipAndStore(context, author2,orgUnit2 ,isOrgUnitOfPerson, 1);
|
||||
constructRelationshipAndStore(context, author2,orgUnit3 ,isOrgUnitOfPerson, 1);
|
||||
constructRelationshipAndStore(context, author3,orgUnit1 ,isOrgUnitOfPerson, 1);
|
||||
constructRelationshipAndStore(context, author3,orgUnit2 ,isOrgUnitOfPerson, 1);
|
||||
constructRelationshipAndStore(context, author3,orgUnit3 ,isOrgUnitOfPerson, 1);
|
||||
|
||||
constructRelationshipAndStore(context, journal1, journalVolume1OfJournal1, isVolumeOfJournal, 1);
|
||||
constructRelationshipAndStore(context, journal1, journalVolume2OfJournal1, isVolumeOfJournal, 1);
|
||||
|
||||
constructRelationshipAndStore(context, journal2, journalVolume1OfJournal2, isVolumeOfJournal, 1);
|
||||
constructRelationshipAndStore(context, journal2, journalVolume2OfJournal2, isVolumeOfJournal, 1);
|
||||
|
||||
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal1,
|
||||
journalIssue1OfJournalVolume1OfJournal1, isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal1,
|
||||
journalIssue2OfJournalVolume1OfJournal1, isIssueOfJournalVolume, 1);
|
||||
|
||||
constructRelationshipAndStore(context, journalVolume2OfJournal1,
|
||||
journalIssue1OfJournalVolume2OfJournal1, isIssueOfJournalVolume, 1);
|
||||
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue1OfJournalVolume1OfJournal2,isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue2OfJournalVolume1OfJournal2,isIssueOfJournalVolume, 1);
|
||||
|
||||
constructRelationshipAndStore(context, journalVolume2OfJournal2,
|
||||
journalIssue1OfJournalVolume2OfJournal2,isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume2OfJournal2,
|
||||
journalIssue2OfJournalVolume2OfJournal2,isIssueOfJournalVolume, 1);
|
||||
|
||||
|
||||
Item journalIssue3 = itemService.findByIdOrLegacyId(context, "522eea91-096f-4a30-bd00-731b2dde33f3");
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue3,
|
||||
itemService.findByIdOrLegacyId(context, "434d9911-fc4e-4d8f-98a1-0343a84b637a"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue3,
|
||||
itemService.findByIdOrLegacyId(context, "e9aaa1de-5927-4ced-af36-bc6750ff33af"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
Item journalIssue4 = itemService.findByIdOrLegacyId(context, "df376455-2790-434a-9957-5e1ba740fff9");
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue4,
|
||||
itemService.findByIdOrLegacyId(context, "10bc6f8b-0796-486f-94d8-4d2e1814586f"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue4,
|
||||
itemService.findByIdOrLegacyId(context, "75c0f7f5-5a69-40e8-aa1f-8f35b1ce5a63"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
Item journalIssue5 = itemService.findByIdOrLegacyId(context, "9c75d673-412a-49ac-a58d-64df4fa1463a");
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue5,
|
||||
itemService.findByIdOrLegacyId(context, "5e945357-995a-424a-9ce8-bf3296120e30"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue5,
|
||||
itemService.findByIdOrLegacyId(context, "87123332-a615-427e-92bc-885f31f161a5"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
Item journalIssue6 = itemService.findByIdOrLegacyId(context, "d5944ff4-3dc1-407a-b49a-1a2681d75267");
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue6,
|
||||
itemService.findByIdOrLegacyId(context, "72ec3575-d9b5-46ab-8a1b-698dd6d73262"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue6,
|
||||
itemService.findByIdOrLegacyId(context, "5ee81de6-aaac-409d-986f-bf21a7fb543c"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
Item journalIssue7 = itemService.findByIdOrLegacyId(context, "4a45cacd-9653-437b-92cf-5824b0461f84");
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue7,
|
||||
itemService.findByIdOrLegacyId(context, "5f414d41-06ab-419a-b3c6-7e85f8480b31"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue7,
|
||||
itemService.findByIdOrLegacyId(context, "6e9d30d4-6b1c-4a45-aadc-c81d88444c1a"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
Item journalIssue8 = itemService.findByIdOrLegacyId(context, "7bba8606-37a1-4a78-b544-b3f1b7c79cb7");
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue8,
|
||||
itemService.findByIdOrLegacyId(context, "c5f0f7b6-7ba5-4d4f-94a3-c0d53b0cb62d"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue8,
|
||||
itemService.findByIdOrLegacyId(context, "2e241414-dfea-4452-b2c4-89f51d89e0b2"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
Item journalIssue9 = itemService.findByIdOrLegacyId(context, "c136663a-9925-453c-9aae-8cb8ed5e9e4b");
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue9,
|
||||
itemService.findByIdOrLegacyId(context, "d2dd2905-b178-45df-a5e1-8e2510bd33f8"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue9,
|
||||
itemService.findByIdOrLegacyId(context, "17101e66-686b-42d5-b3eb-17488f8e3a9c"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
Item journalIssue10 = itemService.findByIdOrLegacyId(context, "09f27238-8374-4da8-b442-295fd1c5fef7");
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue10,
|
||||
itemService.findByIdOrLegacyId(context, "249b1235-2793-4ad2-b40a-1745bcac7d52"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue10,
|
||||
itemService.findByIdOrLegacyId(context, "dc1e6daa-8aa5-4b10-b70d-517792ab9801"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
Item journalIssue11 = itemService.findByIdOrLegacyId(context, "f88bc89e-dcfa-4eca-8db6-1ef808c30564");
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue11,
|
||||
itemService.findByIdOrLegacyId(context, "786df549-c1c3-4818-8fee-10f07858b41f"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue11,
|
||||
itemService.findByIdOrLegacyId(context, "2a351411-1614-4bfa-af50-752af07acf1c"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
Item journalIssue12 = itemService.findByIdOrLegacyId(context, "961e137c-d815-4ade-aff1-0bb12f1fe965");
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue12,
|
||||
itemService.findByIdOrLegacyId(context, "19b25bea-59e6-4c3c-a461-19a2c18ec602"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue12,
|
||||
itemService.findByIdOrLegacyId(context, "dde41d4d-55cd-4107-9d91-4407cdb441c1"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue3,
|
||||
isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue4,
|
||||
isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue5,
|
||||
isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue6,
|
||||
isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue7,
|
||||
isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue8,
|
||||
isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue9,
|
||||
isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue10,
|
||||
isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue11,
|
||||
isIssueOfJournalVolume, 1);
|
||||
constructRelationshipAndStore(context, journalVolume1OfJournal2,
|
||||
journalIssue12,
|
||||
isIssueOfJournalVolume, 1);
|
||||
|
||||
|
||||
constructRelationshipAndStore(context, journalIssue1OfJournalVolume1OfJournal1,
|
||||
article1 ,isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue2OfJournalVolume1OfJournal1,
|
||||
article2 ,isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context, journalIssue1OfJournalVolume2OfJournal1,
|
||||
article3 ,isPublicationOfJournalIssue, 1);
|
||||
|
||||
|
||||
constructRelationshipAndStore(context, article8, author1, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article8, orgUnit1, isAuthorOfPublicationNew, 1);
|
||||
constructRelationshipAndStore(context, article8, author3, isAuthorOfPublication, 1);
|
||||
constructRelationshipAndStore(context, article8, orgUnit2, isAuthorOfPublicationNew, 1);
|
||||
|
||||
constructRelationshipAndStore(context,
|
||||
itemService.findByIdOrLegacyId(context, "77877343-3f75-4c33-9492-6ed7c98ed84e"),
|
||||
itemService.findByIdOrLegacyId(context, "32513cea-6b89-4bce-87c0-214ad118af3e"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context,
|
||||
itemService.findByIdOrLegacyId(context, "77877343-3f75-4c33-9492-6ed7c98ed84e"),
|
||||
itemService.findByIdOrLegacyId(context, "d10c32e6-2b14-41f7-be3e-46a41bbe1cb4"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context,
|
||||
itemService.findByIdOrLegacyId(context, "f4dcd8a6-4cc4-4806-8bb9-a7e8202e05b0"),
|
||||
itemService.findByIdOrLegacyId(context, "6a85aea7-a78b-43be-a2b6-c7948f4e12b7"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
constructRelationshipAndStore(context,
|
||||
itemService.findByIdOrLegacyId(context, "f4dcd8a6-4cc4-4806-8bb9-a7e8202e05b0"),
|
||||
itemService.findByIdOrLegacyId(context, "56f39a97-2f57-48cc-867d-8fa58804793a"),
|
||||
isPublicationOfJournalIssue, 1);
|
||||
|
||||
context.complete();
|
||||
}
|
||||
|
||||
private void constructRelationshipAndStore(Context context, Item leftItem,
|
||||
Item rightItem, RelationshipType relationshipType, int place)
|
||||
throws SQLException, AuthorizeException {
|
||||
Relationship relationship = new Relationship();
|
||||
relationship.setLeftItem(leftItem);
|
||||
relationship.setRightItem(rightItem);
|
||||
relationship.setRelationshipType(relationshipType);
|
||||
relationship.setLeftPlace(place);
|
||||
relationship.setRightPlace(place);
|
||||
relationshipService.create(context, relationship);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,229 @@
|
||||
/**
|
||||
* 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.lang.StringUtils;
|
||||
import org.apache.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;
|
||||
|
||||
public class InitializeEntities {
|
||||
|
||||
private final static Logger log = Logger.getLogger(InitializeEntities.class);
|
||||
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
private RelationshipService relationshipService;
|
||||
private EntityTypeService entityTypeService;
|
||||
|
||||
private InitializeEntities() {
|
||||
relationshipTypeService = ContentServiceFactory.getInstance().getRelationshipTypeService();
|
||||
relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||
entityTypeService = ContentServiceFactory.getInstance().getEntityTypeService();
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
List<RelationshipType> relationshipTypes = this.parseXMLToRelations(context, fileLocation);
|
||||
this.saveRelations(context, relationshipTypes);
|
||||
}
|
||||
|
||||
private void saveRelations(Context context, List<RelationshipType> list) throws SQLException, AuthorizeException {
|
||||
for (RelationshipType relationshipType : list) {
|
||||
RelationshipType relationshipTypeFromDb = relationshipTypeService.findbyTypesAndLabels(context,
|
||||
relationshipType.getLeftType(),
|
||||
relationshipType.getRightType(),
|
||||
relationshipType.getLeftLabel(),
|
||||
relationshipType.getRightLabel());
|
||||
if (relationshipTypeFromDb == null) {
|
||||
relationshipTypeService.create(context, relationshipType);
|
||||
} else {
|
||||
relationshipTypeFromDb.setLeftMinCardinality(relationshipType.getLeftMinCardinality());
|
||||
relationshipTypeFromDb.setLeftMaxCardinality(relationshipType.getLeftMaxCardinality());
|
||||
relationshipTypeFromDb.setRightMinCardinality(relationshipType.getRightMinCardinality());
|
||||
relationshipTypeFromDb.setRightMaxCardinality(relationshipType.getRightMaxCardinality());
|
||||
relationshipTypeService.update(context, relationshipTypeFromDb);
|
||||
}
|
||||
}
|
||||
context.commit();
|
||||
context.complete();
|
||||
}
|
||||
|
||||
private List<RelationshipType> 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");
|
||||
|
||||
}
|
||||
RelationshipType relationshipType = populateRelationshipType(context,leftType,rightType,leftLabel,
|
||||
rightLabel,leftCardinalityMin,
|
||||
leftCardinalityMax,
|
||||
rightCardinalityMin,
|
||||
rightCardinalityMax);
|
||||
|
||||
|
||||
relationshipTypes.add(relationshipType);
|
||||
}
|
||||
}
|
||||
return relationshipTypes;
|
||||
} catch (ParserConfigurationException | SAXException | IOException | SQLException e) {
|
||||
log.error(e, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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 RelationshipType populateRelationshipType(Context context,String leftType,String rightType,String leftLabel,
|
||||
String rightLabel,String leftCardinalityMin,
|
||||
String leftCardinalityMax,String rightCardinalityMin,
|
||||
String rightCardinalityMax)
|
||||
throws SQLException, AuthorizeException {
|
||||
RelationshipType relationshipType = new RelationshipType();
|
||||
|
||||
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);
|
||||
}
|
||||
relationshipType.setLeftType(leftEntityType);
|
||||
relationshipType.setRightType(rightEntityType);
|
||||
relationshipType.setLeftLabel(leftLabel);
|
||||
relationshipType.setRightLabel(rightLabel);
|
||||
if (StringUtils.isNotBlank(leftCardinalityMin)) {
|
||||
relationshipType.setLeftMinCardinality(Integer.parseInt(leftCardinalityMin));
|
||||
} else {
|
||||
relationshipType.setLeftMinCardinality(Integer.MIN_VALUE);
|
||||
}
|
||||
if (StringUtils.isNotBlank(leftCardinalityMax)) {
|
||||
relationshipType.setLeftMaxCardinality(Integer.parseInt(leftCardinalityMax));
|
||||
} else {
|
||||
relationshipType.setLeftMaxCardinality(Integer.MAX_VALUE);
|
||||
}
|
||||
if (StringUtils.isNotBlank(rightCardinalityMin)) {
|
||||
relationshipType.setRightMinCardinality(Integer.parseInt(rightCardinalityMin));
|
||||
} else {
|
||||
relationshipType.setRightMinCardinality(Integer.MIN_VALUE);
|
||||
}
|
||||
if (StringUtils.isNotBlank(rightCardinalityMax)) {
|
||||
relationshipType.setRightMaxCardinality(Integer.parseInt(rightCardinalityMax));
|
||||
} else {
|
||||
relationshipType.setRightMaxCardinality(Integer.MAX_VALUE);
|
||||
}
|
||||
return relationshipType;
|
||||
}
|
||||
}
|
@@ -235,6 +235,13 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
boolean authorityControlled = metadataAuthorityService.isAuthorityControlled(metadataField);
|
||||
boolean authorityRequired = metadataAuthorityService.isAuthorityRequired(metadataField);
|
||||
|
||||
if (authorities != null) {
|
||||
for (String s : authorities) {
|
||||
if (StringUtils.equals(s, "virtual")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// We will not verify that they are valid entries in the registry
|
||||
// until update() is called.
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
@@ -545,8 +552,10 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
List<MetadataValue> metadataValues = dso.getMetadata();
|
||||
for (MetadataValue metadataValue : metadataValues) {
|
||||
//Retrieve & store the place for each metadata value
|
||||
int mvPlace = getMetadataValuePlace(fieldToLastPlace, metadataValue);
|
||||
metadataValue.setPlace(mvPlace);
|
||||
if (!StringUtils.equals(metadataValue.getAuthority(), "virtual")) {
|
||||
int mvPlace = getMetadataValuePlace(fieldToLastPlace, metadataValue);
|
||||
metadataValue.setPlace(mvPlace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
37
dspace-api/src/main/java/org/dspace/content/Entity.java
Normal file
37
dspace-api/src/main/java/org/dspace/content/Entity.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public class Entity {
|
||||
|
||||
private Item item;
|
||||
private List<Relationship> relationships;
|
||||
|
||||
public Entity(Item item,List<Relationship> relationshipList) {
|
||||
setItem(item);
|
||||
setRelationships(relationshipList);
|
||||
}
|
||||
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public void setItem(Item item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public List<Relationship> getRelationships() {
|
||||
return relationships;
|
||||
}
|
||||
|
||||
public void setRelationships(List<Relationship> relationships) {
|
||||
this.relationships = relationships;
|
||||
}
|
||||
}
|
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* 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.lang.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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Relationship> getAllRelations(Context context, Entity entity) {
|
||||
return entity.getRelationships();
|
||||
}
|
||||
|
||||
public List<Relationship> getLeftRelations(Context context, Entity entity) {
|
||||
List<Relationship> fullList = this.getAllRelations(context, entity);
|
||||
List<Relationship> listToReturn = new LinkedList<>();
|
||||
for (Relationship relationship : fullList) {
|
||||
if (relationship.getLeftItem() == entity.getItem()) {
|
||||
listToReturn.add(relationship);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
}
|
||||
|
||||
public List<Relationship> getRightRelations(Context context, Entity entity) {
|
||||
List<Relationship> fullList = this.getAllRelations(context, entity);
|
||||
List<Relationship> listToReturn = new LinkedList<>();
|
||||
for (Relationship relationship : fullList) {
|
||||
if (relationship.getRightItem() == entity.getItem()) {
|
||||
listToReturn.add(relationship);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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() == entityType ||
|
||||
relationshipType.getRightType() == entityType) {
|
||||
listToReturn.add(relationshipType);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
}
|
||||
|
||||
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() == entityType) {
|
||||
listToReturn.add(relationshipType);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
}
|
||||
|
||||
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() == entityType) {
|
||||
listToReturn.add(relationshipType);
|
||||
}
|
||||
}
|
||||
return listToReturn;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
48
dspace-api/src/main/java/org/dspace/content/EntityType.java
Normal file
48
dspace-api/src/main/java/org/dspace/content/EntityType.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "entity_type")
|
||||
public class EntityType {
|
||||
|
||||
@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;
|
||||
|
||||
@Column(name = "label", nullable = false)
|
||||
private String label;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public EntityType findByEntityType(Context context,String entityType) throws SQLException {
|
||||
return entityTypeDAO.findByEntityType(context, entityType);
|
||||
}
|
||||
|
||||
public List<EntityType> findAll(Context context) throws SQLException {
|
||||
return entityTypeDAO.findAll(context, EntityType.class);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public EntityType find(Context context,int id) throws SQLException {
|
||||
EntityType entityType = entityTypeDAO.findByID(context, EntityType.class, id);
|
||||
return entityType;
|
||||
}
|
||||
|
||||
public void update(Context context,EntityType entityType) throws SQLException, AuthorizeException {
|
||||
update(context,Collections.singletonList(entityType));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@@ -12,8 +12,11 @@ import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -35,7 +38,9 @@ import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.InstallItemService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
import org.dspace.content.service.RelationshipService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
import org.dspace.content.virtual.VirtualMetadataPopulator;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
@@ -100,6 +105,11 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
@Autowired(required = true)
|
||||
protected WorkflowItemService workflowItemService;
|
||||
|
||||
@Autowired(required = true)
|
||||
protected RelationshipService relationshipService;
|
||||
|
||||
@Autowired(required = true)
|
||||
protected VirtualMetadataPopulator virtualMetadataPopulator;
|
||||
|
||||
protected ItemServiceImpl() {
|
||||
super();
|
||||
@@ -1257,4 +1267,155 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(Item item, String schema, String element, String qualifier, String lang) {
|
||||
List<MetadataValue> dbMetadataValues = super.getMetadata(item, schema, element, qualifier, lang);
|
||||
|
||||
if (!(StringUtils.equals(schema, "*") && StringUtils.equals(element, "*") &&
|
||||
StringUtils.equals(qualifier, "*") && StringUtils.equals(lang, "*"))) {
|
||||
return dbMetadataValues;
|
||||
}
|
||||
List<MetadataValue> fullMetadataValueList = getRelationshipMetadata(item);
|
||||
fullMetadataValueList.addAll(dbMetadataValues);
|
||||
|
||||
return fullMetadataValueList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> getRelationshipMetadata(Item item) {
|
||||
Context context = new Context();
|
||||
List<MetadataValue> 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(item, entityType, relationship));
|
||||
}
|
||||
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e, e);
|
||||
}
|
||||
return fullMetadataValueList;
|
||||
}
|
||||
|
||||
private List<MetadataValue> handleItemRelationship(Item item, String entityType,
|
||||
Relationship relationship) {
|
||||
List<MetadataValue> resultingMetadataValueList = new LinkedList<>();
|
||||
RelationshipType relationshipType = relationship.getRelationshipType();
|
||||
HashMap<String, List<String>> hashMaps = new HashMap<>();
|
||||
String relationName = "";
|
||||
Item otherItem = null;
|
||||
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
|
||||
hashMaps = (HashMap<String, List<String>>) virtualMetadataPopulator
|
||||
.getMap().get(relationshipType.getLeftLabel());
|
||||
otherItem = relationship.getRightItem();
|
||||
relationName = relationship.getRelationshipType().getLeftLabel();
|
||||
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) {
|
||||
hashMaps = (HashMap<String, List<String>>) virtualMetadataPopulator
|
||||
.getMap().get(relationshipType.getRightLabel());
|
||||
otherItem = relationship.getLeftItem();
|
||||
relationName = relationship.getRelationshipType().getRightLabel();
|
||||
}
|
||||
|
||||
if (hashMaps != null) {
|
||||
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMappping(item, hashMaps,
|
||||
otherItem, relationName));
|
||||
}
|
||||
return resultingMetadataValueList;
|
||||
}
|
||||
|
||||
private List<MetadataValue> handleRelationshipTypeMetadataMappping(Item item,
|
||||
HashMap<String, List<String>> hashMaps,
|
||||
Item otherItem,
|
||||
String relationName) {
|
||||
List<MetadataValue> resultingMetadataValueList = new LinkedList<>();
|
||||
for (Map.Entry<String, List<String>> entry : hashMaps.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
List<String> value = entry.getValue();
|
||||
|
||||
MetadataValue metadataValue = constructMetadataValue(key);
|
||||
metadataValue = constructResultingMetadataValue(item, otherItem, value, metadataValue);
|
||||
if (StringUtils.isNotBlank(metadataValue.getValue())) {
|
||||
resultingMetadataValueList.add(metadataValue);
|
||||
}
|
||||
}
|
||||
|
||||
resultingMetadataValueList.add(getRelationMetadataFromOtherItem(otherItem, relationName));
|
||||
return resultingMetadataValueList;
|
||||
}
|
||||
|
||||
private MetadataValue getRelationMetadataFromOtherItem(Item otherItem, String relationName) {
|
||||
MetadataValue metadataValue = constructMetadataValue("relation_" + relationName);
|
||||
metadataValue.setAuthority("virtual");
|
||||
metadataValue.setValue(otherItem.getID().toString());
|
||||
return metadataValue;
|
||||
}
|
||||
|
||||
private String getEntityTypeStringFromMetadata(List<MetadataValue> list) {
|
||||
String entityType = null;
|
||||
for (MetadataValue mdv : list) {
|
||||
if (StringUtils.equals(mdv.getMetadataField().getMetadataSchema().getName(),
|
||||
"relationship")
|
||||
&& StringUtils.equals(mdv.getMetadataField().getElement(),
|
||||
"type")) {
|
||||
|
||||
entityType = mdv.getValue();
|
||||
}
|
||||
}
|
||||
return entityType;
|
||||
}
|
||||
|
||||
private MetadataValue constructResultingMetadataValue(Item item, Item otherItem, List<String> value,
|
||||
MetadataValue metadataValue) {
|
||||
List<String> resultValues = new LinkedList<>();
|
||||
for (String s : value) {
|
||||
String[] splittedString = s.split("\\.");
|
||||
|
||||
List<MetadataValue> resultList = this.getMetadata(otherItem,
|
||||
splittedString.length > 0 ? splittedString[0] : null,
|
||||
splittedString.length > 1 ? splittedString[1] : null,
|
||||
splittedString.length > 2 ? splittedString[2] : null,
|
||||
Item.ANY);
|
||||
|
||||
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 += ", ";
|
||||
}
|
||||
resultString += metadataValueString;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(resultString)) {
|
||||
resultValues.add(resultString);
|
||||
}
|
||||
}
|
||||
|
||||
String result = StringUtils.join(resultValues, ", ");
|
||||
metadataValue.setValue(result);
|
||||
metadataValue.setAuthority("virtual");
|
||||
metadataValue.setConfidence(-1);
|
||||
metadataValue.setDSpaceObject(item);
|
||||
return metadataValue;
|
||||
}
|
||||
|
||||
private MetadataValue constructMetadataValue(String key) {
|
||||
String[] splittedKey = key.split("_");
|
||||
MetadataValue metadataValue = new MetadataValue();
|
||||
MetadataField metadataField = new MetadataField();
|
||||
MetadataSchema metadataSchema = new MetadataSchema();
|
||||
metadataSchema.setName(splittedKey.length > 0 ? splittedKey[0] : null);
|
||||
metadataField.setMetadataSchema(metadataSchema);
|
||||
metadataField.setElement(splittedKey.length > 1 ? splittedKey[1] : null);
|
||||
metadataField.setQualifier(splittedKey.length > 2 ? splittedKey[2] : null);
|
||||
metadataValue.setMetadataField(metadataField);
|
||||
metadataValue.setLanguage(Item.ANY);
|
||||
return metadataValue;
|
||||
}
|
||||
}
|
102
dspace-api/src/main/java/org/dspace/content/Relationship.java
Normal file
102
dspace-api/src/main/java/org/dspace/content/Relationship.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* 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.ReloadableEntity;
|
||||
|
||||
@Entity
|
||||
@Table(name = "relationship")
|
||||
public class Relationship implements ReloadableEntity<Integer> {
|
||||
|
||||
@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;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "left_id", nullable = false)
|
||||
private Item leftItem;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "type_id", nullable = false)
|
||||
private RelationshipType relationshipType;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "right_id", nullable = false)
|
||||
private Item rightItem;
|
||||
|
||||
@Column(name = "left_place")
|
||||
private int leftPlace;
|
||||
|
||||
@Column(name = "right_place")
|
||||
private int rightPlace;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Item getLeftItem() {
|
||||
return leftItem;
|
||||
}
|
||||
|
||||
public void setLeftItem(Item leftItem) {
|
||||
this.leftItem = leftItem;
|
||||
}
|
||||
|
||||
public RelationshipType getRelationshipType() {
|
||||
return relationshipType;
|
||||
}
|
||||
|
||||
public void setRelationshipType(RelationshipType relationshipType) {
|
||||
this.relationshipType = relationshipType;
|
||||
}
|
||||
|
||||
public Item getRightItem() {
|
||||
return rightItem;
|
||||
}
|
||||
|
||||
public void setRightItem(Item rightItem) {
|
||||
this.rightItem = rightItem;
|
||||
}
|
||||
|
||||
public int getLeftPlace() {
|
||||
return leftPlace;
|
||||
}
|
||||
|
||||
public void setLeftPlace(int leftPlace) {
|
||||
this.leftPlace = leftPlace;
|
||||
}
|
||||
|
||||
public int getRightPlace() {
|
||||
return rightPlace;
|
||||
}
|
||||
|
||||
public void setRightPlace(int rightPlace) {
|
||||
this.rightPlace = rightPlace;
|
||||
}
|
||||
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
}
|
@@ -0,0 +1,289 @@
|
||||
/**
|
||||
* 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.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.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.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class RelationshipServiceImpl implements RelationshipService {
|
||||
|
||||
private static final Logger log = Logger.getLogger(RelationshipServiceImpl.class);
|
||||
|
||||
@Autowired(required = true)
|
||||
protected RelationshipDAO relationshipDAO;
|
||||
|
||||
@Autowired(required = true)
|
||||
protected AuthorizeService authorizeService;
|
||||
|
||||
@Autowired(required = true)
|
||||
protected ItemService itemService;
|
||||
|
||||
@Autowired(required = true)
|
||||
protected RelationshipTypeService relationshipTypeService;
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
public Relationship create(Context context, Relationship relationship) throws SQLException, AuthorizeException {
|
||||
if (isRelationshipValidToCreate(context, relationship)) {
|
||||
if (!authorizeService.isAdmin(context)) {
|
||||
throw new AuthorizeException(
|
||||
"Only administrators can modify relationship");
|
||||
}
|
||||
updatePlaceInRelationship(context, relationship);
|
||||
|
||||
return relationshipDAO.create(context, relationship);
|
||||
} else {
|
||||
throw new IllegalArgumentException("The relationship given was not valid");
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePlaceInRelationship(Context context, Relationship relationship) throws SQLException {
|
||||
List<Relationship> leftRelationships = findByItemAndRelationshipType(context,
|
||||
relationship.getLeftItem(),
|
||||
relationship.getRelationshipType(), true);
|
||||
List<Relationship> rightRelationships = findByItemAndRelationshipType(context,
|
||||
relationship.getRightItem(),
|
||||
relationship.getRelationshipType(),
|
||||
false);
|
||||
|
||||
if (!leftRelationships.isEmpty()) {
|
||||
leftRelationships.sort((o1, o2) -> o2.getLeftPlace() - o1.getLeftPlace());
|
||||
relationship.setLeftPlace(leftRelationships.get(0).getLeftPlace() + 1);
|
||||
} else {
|
||||
relationship.setLeftPlace(1);
|
||||
}
|
||||
|
||||
if (!rightRelationships.isEmpty()) {
|
||||
rightRelationships.sort((o1, o2) -> o2.getRightPlace() - o1.getRightPlace());
|
||||
relationship.setRightPlace(rightRelationships.get(0).getRightPlace() + 1);
|
||||
} else {
|
||||
relationship.setRightPlace(1);
|
||||
}
|
||||
}
|
||||
|
||||
public int findLeftPlaceByLeftItem(Context context, Item item) throws SQLException {
|
||||
return relationshipDAO.findLeftPlaceByLeftItem(context, item);
|
||||
}
|
||||
|
||||
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");
|
||||
logRelationshipTypeDetails(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");
|
||||
logRelationshipTypeDetails(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");
|
||||
logRelationshipTypeDetails(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");
|
||||
logRelationshipTypeDetails(relationshipType);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void logRelationshipTypeDetails(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,
|
||||
int maxCardinality, RelationshipType relationshipType) throws SQLException {
|
||||
List<Relationship> rightRelationships = findByItemAndRelationshipType(context, itemToProcess, relationshipType,
|
||||
false);
|
||||
if (rightRelationships.size() >= maxCardinality && maxCardinality != 0) {
|
||||
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();
|
||||
if (!StringUtils.equals(leftEntityType, entityTypeToProcess.getLabel())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Relationship find(Context context, int id) throws SQLException {
|
||||
Relationship relationship = relationshipDAO.findByID(context, Relationship.class, id);
|
||||
return relationship;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public List<Relationship> findAll(Context context) throws SQLException {
|
||||
return relationshipDAO.findAll(context, Relationship.class);
|
||||
}
|
||||
|
||||
public void update(Context context, Relationship relationship) throws SQLException, AuthorizeException {
|
||||
update(context, Collections.singletonList(relationship));
|
||||
|
||||
}
|
||||
|
||||
public void update(Context context, List<Relationship> relationships) throws SQLException, AuthorizeException {
|
||||
if (CollectionUtils.isNotEmpty(relationships)) {
|
||||
// Check authorisation - only administrators can change formats
|
||||
if (!authorizeService.isAdmin(context)) {
|
||||
throw new AuthorizeException(
|
||||
"Only administrators can modify relationship");
|
||||
}
|
||||
|
||||
for (Relationship relationship : relationships) {
|
||||
relationshipDAO.save(context, relationship);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(Context context, Relationship relationship) throws SQLException, AuthorizeException {
|
||||
if (isRelationshipValidToDelete(context, relationship)) {
|
||||
if (!authorizeService.isAdmin(context)) {
|
||||
throw new AuthorizeException(
|
||||
"Only administrators can delete relationship");
|
||||
}
|
||||
relationshipDAO.delete(context, relationship);
|
||||
} 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");
|
||||
logRelationshipTypeDetails(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");
|
||||
logRelationshipTypeDetails(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");
|
||||
logRelationshipTypeDetails(relationship.getRelationshipType());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkMinCardinality(Context context, Item item,
|
||||
Relationship relationship,
|
||||
int minCardinality, boolean isLeft) throws SQLException {
|
||||
List<Relationship> list = this
|
||||
.findByItemAndRelationshipType(context, item, relationship.getRelationshipType(), isLeft);
|
||||
if (!(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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "relationship_type")
|
||||
public class RelationshipType {
|
||||
|
||||
@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;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST})
|
||||
@JoinColumn(name = "left_type", nullable = false)
|
||||
private EntityType leftType;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST})
|
||||
@JoinColumn(name = "right_type", nullable = false)
|
||||
private EntityType rightType;
|
||||
|
||||
@Column(name = "left_label", nullable = false)
|
||||
private String leftLabel;
|
||||
|
||||
@Column(name = "right_label", nullable = false)
|
||||
private String rightLabel;
|
||||
|
||||
@Column(name = "left_min_cardinality")
|
||||
private int leftMinCardinality;
|
||||
|
||||
@Column(name = "left_max_cardinality")
|
||||
private int leftMaxCardinality;
|
||||
|
||||
@Column(name = "right_min_cardinality")
|
||||
private int rightMinCardinality;
|
||||
|
||||
@Column(name = "right_max_cardinality")
|
||||
private int rightMaxCardinality;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public EntityType getLeftType() {
|
||||
return leftType;
|
||||
}
|
||||
|
||||
public void setLeftType(EntityType leftType) {
|
||||
this.leftType = leftType;
|
||||
}
|
||||
|
||||
public EntityType getRightType() {
|
||||
return rightType;
|
||||
}
|
||||
|
||||
public void setRightType(EntityType rightType) {
|
||||
this.rightType = rightType;
|
||||
}
|
||||
|
||||
public String getLeftLabel() {
|
||||
return leftLabel;
|
||||
}
|
||||
|
||||
public void setLeftLabel(String leftLabel) {
|
||||
this.leftLabel = leftLabel;
|
||||
}
|
||||
|
||||
public String getRightLabel() {
|
||||
return rightLabel;
|
||||
}
|
||||
|
||||
public void setRightLabel(String rightLabel) {
|
||||
this.rightLabel = rightLabel;
|
||||
}
|
||||
|
||||
public int getLeftMinCardinality() {
|
||||
return leftMinCardinality;
|
||||
}
|
||||
|
||||
public void setLeftMinCardinality(int leftMinCardinality) {
|
||||
this.leftMinCardinality = leftMinCardinality;
|
||||
}
|
||||
|
||||
public int getLeftMaxCardinality() {
|
||||
return leftMaxCardinality;
|
||||
}
|
||||
|
||||
public void setLeftMaxCardinality(int leftMaxCardinality) {
|
||||
this.leftMaxCardinality = leftMaxCardinality;
|
||||
}
|
||||
|
||||
public int getRightMinCardinality() {
|
||||
return rightMinCardinality;
|
||||
}
|
||||
|
||||
public void setRightMinCardinality(int rightMinCardinality) {
|
||||
this.rightMinCardinality = rightMinCardinality;
|
||||
}
|
||||
|
||||
public int getRightMaxCardinality() {
|
||||
return rightMaxCardinality;
|
||||
}
|
||||
|
||||
public void setRightMaxCardinality(int rightMaxCardinality) {
|
||||
this.rightMaxCardinality = rightMaxCardinality;
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType,
|
||||
String leftLabel,String rightLabel) throws SQLException {
|
||||
return relationshipTypeDAO.findbyTypesAndLabels(context, leftType, rightType, leftLabel, rightLabel);
|
||||
}
|
||||
|
||||
public List<RelationshipType> findAll(Context context) throws SQLException {
|
||||
return relationshipTypeDAO.findAll(context, RelationshipType.class);
|
||||
}
|
||||
|
||||
public RelationshipType find(Context context,int id) throws SQLException {
|
||||
return relationshipTypeDAO.findByID(context, RelationshipType.class, id);
|
||||
}
|
||||
|
||||
public void update(Context context,RelationshipType relationshipType) throws SQLException, AuthorizeException {
|
||||
update(context,Collections.singletonList(relationshipType));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public interface EntityTypeDAO extends GenericDAO<EntityType> {
|
||||
|
||||
public EntityType findByEntityType(Context context, String entityType) throws SQLException;
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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.core.Context;
|
||||
import org.dspace.core.GenericDAO;
|
||||
|
||||
public interface RelationshipDAO extends GenericDAO<Relationship> {
|
||||
|
||||
List<Relationship> findByItem(Context context,Item item) throws SQLException;
|
||||
|
||||
int findLeftPlaceByLeftItem(Context context,Item item) throws SQLException;
|
||||
|
||||
int findRightPlaceByRightItem(Context context,Item item) throws SQLException;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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.content.RelationshipType;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.GenericDAO;
|
||||
|
||||
public interface RelationshipTypeDAO extends GenericDAO<RelationshipType> {
|
||||
|
||||
RelationshipType findbyTypesAndLabels(Context context,
|
||||
EntityType leftType,EntityType rightType,String leftLabel,String rightLabel)
|
||||
throws SQLException;
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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 org.dspace.content.EntityType;
|
||||
import org.dspace.content.dao.EntityTypeDAO;
|
||||
import org.dspace.core.AbstractHibernateDAO;
|
||||
import org.dspace.core.Context;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
public class EntityTypeDAOImpl extends AbstractHibernateDAO<EntityType> implements EntityTypeDAO {
|
||||
|
||||
public EntityType findByEntityType(Context context,String entityType) throws SQLException {
|
||||
Criteria criteria = createCriteria(context,EntityType.class);
|
||||
criteria.add(Restrictions.and(
|
||||
Restrictions.eq("label", entityType).ignoreCase()
|
||||
));
|
||||
|
||||
return singleResult(criteria);
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* 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 org.dspace.content.Item;
|
||||
import org.dspace.content.Relationship;
|
||||
import org.dspace.content.dao.RelationshipDAO;
|
||||
import org.dspace.core.AbstractHibernateDAO;
|
||||
import org.dspace.core.Context;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
public class RelationshipDAOImpl extends AbstractHibernateDAO<Relationship> implements RelationshipDAO {
|
||||
|
||||
public List<Relationship> findByItem(Context context,Item item) throws SQLException {
|
||||
Criteria criteria = createCriteria(context,Relationship.class);
|
||||
criteria.add(Restrictions.or(
|
||||
Restrictions.eq("leftItem", item),
|
||||
Restrictions.eq("rightItem", item)
|
||||
));
|
||||
|
||||
return list(criteria);
|
||||
}
|
||||
|
||||
public int findLeftPlaceByLeftItem(Context context, Item item) throws SQLException {
|
||||
Criteria criteria = createCriteria(context, Relationship.class);
|
||||
criteria.add(Restrictions.and(
|
||||
Restrictions.eq("leftItem", item)
|
||||
));
|
||||
|
||||
List<Relationship> list = list(criteria);
|
||||
list.sort((o1, o2) -> o2.getLeftPlace() - o1.getLeftPlace());
|
||||
if (!list.isEmpty()) {
|
||||
return list.get(0).getLeftPlace();
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int findRightPlaceByRightItem(Context context, Item item) throws SQLException {
|
||||
Criteria criteria = createCriteria(context, Relationship.class);
|
||||
criteria.add(Restrictions.and(
|
||||
Restrictions.eq("rightItem", item)
|
||||
));
|
||||
|
||||
List<Relationship> list = list(criteria);
|
||||
list.sort((o1, o2) -> o2.getRightPlace() - o1.getRightPlace());
|
||||
if (!list.isEmpty()) {
|
||||
return list.get(0).getLeftPlace();
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
@@ -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.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.content.dao.RelationshipTypeDAO;
|
||||
import org.dspace.core.AbstractHibernateDAO;
|
||||
import org.dspace.core.Context;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
public class RelationshipTypeDAOImpl extends AbstractHibernateDAO<RelationshipType> implements RelationshipTypeDAO {
|
||||
|
||||
public RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType,
|
||||
String leftLabel,String rightLabel)
|
||||
throws SQLException {
|
||||
Criteria criteria = createCriteria(context,RelationshipType.class);
|
||||
criteria.add(Restrictions.and(
|
||||
Restrictions.eq("leftType", leftType),
|
||||
Restrictions.eq("rightType", rightType),
|
||||
Restrictions.eq("leftLabel", leftLabel),
|
||||
Restrictions.eq("rightLabel", rightLabel)
|
||||
));
|
||||
return singleResult(criteria);
|
||||
}
|
||||
|
||||
}
|
@@ -19,12 +19,16 @@ import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
||||
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.InstallItemService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
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.SupervisedItemService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
@@ -70,6 +74,14 @@ public abstract class ContentServiceFactory {
|
||||
|
||||
public abstract SiteService getSiteService();
|
||||
|
||||
public abstract RelationshipTypeService getRelationshipTypeService();
|
||||
|
||||
public abstract RelationshipService getRelationshipService();
|
||||
|
||||
public abstract EntityTypeService getEntityTypeService();
|
||||
|
||||
public abstract EntityService getEntityService();
|
||||
|
||||
public InProgressSubmissionService getInProgressSubmissionService(InProgressSubmission inProgressSubmission) {
|
||||
if (inProgressSubmission instanceof WorkspaceItem) {
|
||||
return getWorkspaceItemService();
|
||||
|
@@ -17,11 +17,15 @@ import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
||||
import org.dspace.content.service.DSpaceObjectService;
|
||||
import org.dspace.content.service.EntityService;
|
||||
import org.dspace.content.service.EntityTypeService;
|
||||
import org.dspace.content.service.InstallItemService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
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.SupervisedItemService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
@@ -68,6 +72,14 @@ public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
||||
@Autowired(required = true)
|
||||
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
|
||||
public List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices() {
|
||||
@@ -143,4 +155,23 @@ public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
||||
public SiteService getSiteService() {
|
||||
return siteService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RelationshipTypeService getRelationshipTypeService() {
|
||||
return relationshipTypeService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RelationshipService getRelationshipService() {
|
||||
return relationshipService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityTypeService getEntityTypeService() {
|
||||
return entityTypeService;
|
||||
}
|
||||
|
||||
public EntityService getEntityService() {
|
||||
return entityService;
|
||||
}
|
||||
}
|
||||
|
@@ -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.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;
|
||||
|
||||
public interface EntityService {
|
||||
|
||||
Entity findByItemId(Context context, UUID itemId) throws SQLException;
|
||||
EntityType getType(Context context, Entity entity) throws SQLException;
|
||||
List<Relationship> getAllRelations(Context context, Entity entity);
|
||||
List<Relationship> getLeftRelations(Context context, Entity entity);
|
||||
List<Relationship> getRightRelations(Context context, Entity entity);
|
||||
List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException;
|
||||
List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity) throws SQLException;
|
||||
List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity) throws SQLException;
|
||||
List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity) throws SQLException;
|
||||
List<RelationshipType> getRelationshipTypesByLabel(Context context, String label) throws SQLException;
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public interface EntityTypeService extends DSpaceCRUDService<EntityType> {
|
||||
|
||||
public EntityType findByEntityType(Context context,String entityType) throws SQLException;
|
||||
|
||||
public List<EntityType> findAll(Context context) throws SQLException;
|
||||
|
||||
public EntityType create(Context context, String entityTypeString) throws SQLException, AuthorizeException;
|
||||
}
|
@@ -23,6 +23,7 @@ import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.Thumbnail;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.Context;
|
||||
@@ -639,4 +640,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
boolean isInProgressSubmission(Context context, Item item) throws SQLException;
|
||||
|
||||
public List<MetadataValue> getRelationshipMetadata(Item item);
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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.core.Context;
|
||||
import org.dspace.service.DSpaceCRUDService;
|
||||
|
||||
public interface RelationshipService extends DSpaceCRUDService<Relationship> {
|
||||
public List<Relationship> findByItem(Context context,Item item) throws SQLException;
|
||||
|
||||
public List<Relationship> findAll(Context context) throws SQLException;
|
||||
|
||||
public Relationship create(Context context, Relationship relationship) throws SQLException, AuthorizeException;
|
||||
|
||||
int findLeftPlaceByLeftItem(Context context, Item item) throws SQLException;
|
||||
|
||||
int findRightPlaceByRightItem(Context context, Item item) throws SQLException;
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipType> {
|
||||
|
||||
RelationshipType create(Context context,RelationshipType relationshipType) throws SQLException, AuthorizeException;
|
||||
|
||||
RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType,
|
||||
String leftLabel,String rightLabel)
|
||||
throws SQLException;
|
||||
List<RelationshipType> findAll(Context context) throws SQLException;
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public class EntityTypeToFilterQueryService {
|
||||
|
||||
private Map<String, String> map;
|
||||
|
||||
public void setMap(Map map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public Map getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public String getFilterQueryForKey(String key) {
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
public boolean hasKey(String key) {
|
||||
return map.containsKey(key);
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public class VirtualMetadataPopulator {
|
||||
|
||||
private Map map;
|
||||
|
||||
public void setMap(Map map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public Map getMap() {
|
||||
return map;
|
||||
}
|
||||
}
|
@@ -71,6 +71,13 @@ public class DatabaseRegistryUpdater implements FlywayCallback {
|
||||
MetadataImporter.loadRegistry(base + "dublin-core-types.xml", true);
|
||||
MetadataImporter.loadRegistry(base + "dcterms-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 + "sword-metadata.xml", true);
|
||||
|
||||
@@ -163,6 +170,5 @@ public class DatabaseRegistryUpdater implements FlywayCallback {
|
||||
|
||||
@Override
|
||||
public void afterInfo(Connection connection) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,62 @@
|
||||
--
|
||||
-- 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)
|
||||
);
|
||||
|
||||
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_types_and_labels_idx ON relationship_type(left_type, right_type, left_label, right_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);
|
@@ -0,0 +1,62 @@
|
||||
--
|
||||
-- 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)
|
||||
);
|
||||
|
||||
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_types_and_labels_idx ON relationship_type(left_type, right_type, left_label, right_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);
|
@@ -0,0 +1,62 @@
|
||||
--
|
||||
-- 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)
|
||||
);
|
||||
|
||||
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_types_and_labels_idx ON relationship_type(left_type, right_type, left_label, right_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);
|
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
</relationships>
|
@@ -9,6 +9,7 @@ package org.dspace.app.rest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.rest.link.HalLinkService;
|
||||
import org.dspace.app.rest.model.RootRest;
|
||||
import org.dspace.app.rest.model.hateoas.RootResource;
|
||||
@@ -39,20 +40,15 @@ public class RootRestResourceController {
|
||||
@Autowired
|
||||
RootRestRepository rootRestRepository;
|
||||
|
||||
private static Logger log = Logger.getLogger(RootRestResourceController.class);
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public RootResource listDefinedEndpoint(HttpServletRequest request) {
|
||||
|
||||
String restUrl = getRestURL(request);
|
||||
|
||||
RootRest rootRest = rootRestRepository.getRoot(restUrl);
|
||||
RootRest rootRest = rootRestRepository.getRoot();
|
||||
RootResource rootResource = new RootResource(rootRest);
|
||||
halLinkService.addLinks(rootResource);
|
||||
|
||||
return rootResource;
|
||||
}
|
||||
|
||||
private String getRestURL(HttpServletRequest request) {
|
||||
String url = request.getRequestURL().toString();
|
||||
return url.substring(0, url.length() - request.getRequestURI().length()) + request.getContextPath();
|
||||
}
|
||||
}
|
@@ -34,16 +34,22 @@ public abstract class DSpaceObjectConverter<M extends DSpaceObject, R extends or
|
||||
resource.setUuid(obj.getID().toString());
|
||||
}
|
||||
resource.setName(obj.getName());
|
||||
List<MetadataValue> fullList = obj.getMetadata();
|
||||
List<MetadataEntryRest> metadata = convertMetadataToRest(fullList);
|
||||
resource.setMetadata(metadata);
|
||||
return resource;
|
||||
}
|
||||
|
||||
public List<MetadataEntryRest> convertMetadataToRest(List<MetadataValue> fullList) {
|
||||
List<MetadataEntryRest> metadata = new ArrayList<MetadataEntryRest>();
|
||||
for (MetadataValue mv : obj.getMetadata()) {
|
||||
for (MetadataValue mv : fullList) {
|
||||
MetadataEntryRest me = new MetadataEntryRest();
|
||||
me.setKey(mv.getMetadataField().toString('.'));
|
||||
me.setValue(mv.getValue());
|
||||
me.setLanguage(mv.getLanguage());
|
||||
metadata.add(me);
|
||||
}
|
||||
resource.setMetadata(metadata);
|
||||
return resource;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -45,6 +45,9 @@ public class DiscoverResultConverter {
|
||||
@Autowired
|
||||
private List<DSpaceObjectConverter> converters;
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
|
||||
@Autowired
|
||||
private SearchService searchService;
|
||||
|
||||
|
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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.rest.converter;
|
||||
|
||||
import org.dspace.app.rest.model.EntityTypeRest;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class EntityTypeConverter extends DSpaceConverter<org.dspace.content.EntityType, EntityTypeRest> {
|
||||
|
||||
public EntityTypeRest fromModel(EntityType obj) {
|
||||
EntityTypeRest entityTypeRest = new EntityTypeRest();
|
||||
entityTypeRest.setId(obj.getId());
|
||||
entityTypeRest.setLabel(obj.getLabel());
|
||||
return entityTypeRest;
|
||||
}
|
||||
|
||||
public EntityType toModel(EntityTypeRest obj) {
|
||||
EntityType entityType = new EntityType();
|
||||
entityType.setId(obj.getId());
|
||||
entityType.setLabel(obj.getLabel());
|
||||
return entityType;
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.rest.converter;
|
||||
|
||||
import org.dspace.app.rest.model.FilteredDiscoveryPageRest;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.virtual.EntityTypeToFilterQueryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FilteredDiscoveryPageConverter extends DSpaceConverter<org.dspace.content.EntityType,
|
||||
FilteredDiscoveryPageRest> {
|
||||
@Autowired
|
||||
private EntityTypeToFilterQueryService entityTypeToFilterQueryService;
|
||||
|
||||
public FilteredDiscoveryPageRest fromModel(EntityType obj) {
|
||||
FilteredDiscoveryPageRest filteredDiscoveryPageRest = new FilteredDiscoveryPageRest();
|
||||
filteredDiscoveryPageRest.setId(obj.getLabel());
|
||||
filteredDiscoveryPageRest.setLabel(obj.getLabel());
|
||||
filteredDiscoveryPageRest.setFilterQueryString(
|
||||
entityTypeToFilterQueryService.getFilterQueryForKey(obj.getLabel()));
|
||||
return filteredDiscoveryPageRest;
|
||||
}
|
||||
|
||||
public EntityType toModel(FilteredDiscoveryPageRest obj) {
|
||||
return new EntityType();
|
||||
}
|
||||
}
|
@@ -7,16 +7,25 @@
|
||||
*/
|
||||
package org.dspace.app.rest.converter;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.rest.model.BitstreamRest;
|
||||
import org.dspace.app.rest.model.ItemRest;
|
||||
import org.dspace.app.rest.model.MetadataEntryRest;
|
||||
import org.dspace.app.rest.model.RelationshipRest;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.Relationship;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.RelationshipService;
|
||||
import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -32,6 +41,12 @@ public class ItemConverter extends DSpaceObjectConverter<org.dspace.content.Item
|
||||
private CollectionConverter collectionConverter;
|
||||
@Autowired(required = true)
|
||||
private BitstreamConverter bitstreamConverter;
|
||||
@Autowired
|
||||
private RelationshipService relationshipService;
|
||||
@Autowired
|
||||
private RelationshipConverter relationshipConverter;
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
|
||||
private static final Logger log = Logger.getLogger(ItemConverter.class);
|
||||
|
||||
@@ -66,6 +81,27 @@ public class ItemConverter extends DSpaceObjectConverter<org.dspace.content.Item
|
||||
}
|
||||
}
|
||||
item.setBitstreams(bitstreams);
|
||||
List<Relationship> relationships = new LinkedList<>();
|
||||
try {
|
||||
relationships = relationshipService.findByItem(new Context(), obj);
|
||||
} catch (SQLException e) {
|
||||
log.error(e, e);
|
||||
}
|
||||
List<RelationshipRest> relationshipRestList = new LinkedList<>();
|
||||
for (Relationship relationship : relationships) {
|
||||
RelationshipRest relationshipRest = relationshipConverter.fromModel(relationship);
|
||||
relationshipRestList.add(relationshipRest);
|
||||
}
|
||||
item.setRelationships(relationshipRestList);
|
||||
|
||||
List<MetadataValue> fullList = new LinkedList<>();
|
||||
fullList.addAll(obj.getMetadata());
|
||||
fullList.addAll(itemService.getRelationshipMetadata(obj));
|
||||
|
||||
List<MetadataEntryRest> metadata = super.convertMetadataToRest(fullList);
|
||||
item.setMetadata(metadata);
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@@ -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.app.rest.converter;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.rest.model.RelationshipRest;
|
||||
import org.dspace.content.Relationship;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class RelationshipConverter extends DSpaceConverter<Relationship, RelationshipRest> {
|
||||
|
||||
private static final Logger log = Logger.getLogger(RelationshipConverter.class);
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
|
||||
@Autowired
|
||||
private RelationshipTypeConverter relationshipTypeConverter;
|
||||
|
||||
|
||||
public RelationshipRest fromModel(Relationship obj) {
|
||||
RelationshipRest relationshipRest = new RelationshipRest();
|
||||
relationshipRest.setId(obj.getId());
|
||||
relationshipRest.setLeftId(obj.getLeftItem().getID());
|
||||
relationshipRest.setRelationshipType(relationshipTypeConverter.fromModel(obj.getRelationshipType()));
|
||||
relationshipRest.setRightId(obj.getRightItem().getID());
|
||||
relationshipRest.setLeftPlace(obj.getLeftPlace());
|
||||
relationshipRest.setRightPlace(obj.getRightPlace());
|
||||
return relationshipRest;
|
||||
}
|
||||
|
||||
public Relationship toModel(RelationshipRest obj) {
|
||||
Relationship relationship = new Relationship();
|
||||
try {
|
||||
Context context = new Context();
|
||||
relationship.setLeftItem(itemService.find(context, obj.getLeftId()));
|
||||
relationship.setRightItem(itemService.find(context, obj.getRightId()));
|
||||
} catch (SQLException e) {
|
||||
log.error(e,e);
|
||||
}
|
||||
relationship.setRelationshipType(relationshipTypeConverter.toModel(obj.getRelationshipType()));
|
||||
relationship.setLeftPlace(obj.getLeftPlace());
|
||||
relationship.setRightPlace(obj.getRightPlace());
|
||||
relationship.setId(obj.getId());
|
||||
return relationship;
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 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.rest.converter;
|
||||
|
||||
import org.dspace.app.rest.model.RelationshipTypeRest;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class RelationshipTypeConverter extends DSpaceConverter<RelationshipType, RelationshipTypeRest> {
|
||||
|
||||
@Autowired
|
||||
private EntityTypeConverter entityTypeConverter;
|
||||
|
||||
public RelationshipTypeRest fromModel(RelationshipType obj) {
|
||||
RelationshipTypeRest relationshipTypeRest = new RelationshipTypeRest();
|
||||
|
||||
relationshipTypeRest.setId(obj.getId());
|
||||
relationshipTypeRest.setLeftLabel(obj.getLeftLabel());
|
||||
relationshipTypeRest.setRightLabel(obj.getRightLabel());
|
||||
relationshipTypeRest.setLeftMinCardinality(obj.getLeftMinCardinality());
|
||||
relationshipTypeRest.setLeftMaxCardinality(obj.getLeftMaxCardinality());
|
||||
relationshipTypeRest.setRightMinCardinality(obj.getRightMinCardinality());
|
||||
relationshipTypeRest.setRightMaxCardinality(obj.getRightMaxCardinality());
|
||||
relationshipTypeRest.setLeftType(entityTypeConverter.fromModel(obj.getLeftType()));
|
||||
relationshipTypeRest.setRightType(entityTypeConverter.fromModel(obj.getRightType()));
|
||||
|
||||
return relationshipTypeRest;
|
||||
}
|
||||
|
||||
public RelationshipType toModel(RelationshipTypeRest obj) {
|
||||
RelationshipType relationshipType = new RelationshipType();
|
||||
|
||||
relationshipType.setId(obj.getId());
|
||||
relationshipType.setLeftLabel(obj.getLeftLabel());
|
||||
relationshipType.setRightLabel(obj.getRightLabel());
|
||||
relationshipType.setLeftMinCardinality(obj.getLeftMinCardinality());
|
||||
relationshipType.setLeftMaxCardinality(obj.getLeftMaxCardinality());
|
||||
relationshipType.setRightMinCardinality(obj.getRightMinCardinality());
|
||||
relationshipType.setRightMaxCardinality(obj.getRightMaxCardinality());
|
||||
relationshipType.setLeftType(entityTypeConverter.toModel(obj.getLeftType()));
|
||||
relationshipType.setRightType(entityTypeConverter.toModel(obj.getRightType()));
|
||||
|
||||
return relationshipType;
|
||||
}
|
||||
}
|
@@ -21,11 +21,11 @@ public class RootConverter {
|
||||
@Autowired
|
||||
private ConfigurationService configurationService;
|
||||
|
||||
public RootRest convert(String restUrl) {
|
||||
public RootRest convert() {
|
||||
RootRest rootRest = new RootRest();
|
||||
rootRest.setDspaceName(configurationService.getProperty("dspace.name"));
|
||||
rootRest.setDspaceURL(configurationService.getProperty("dspace.url"));
|
||||
rootRest.setDspaceRest(restUrl);
|
||||
rootRest.setDspaceRest(configurationService.getProperty("dspace.restUrl"));
|
||||
return rootRest;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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.rest.model;
|
||||
|
||||
import org.dspace.app.rest.RestResourceController;
|
||||
|
||||
public class EntityTypeRest extends BaseObjectRest<Integer> {
|
||||
|
||||
public static final String NAME = "entitytype";
|
||||
public static final String CATEGORY = "core";
|
||||
|
||||
public String getCategory() {
|
||||
return CATEGORY;
|
||||
}
|
||||
|
||||
public Class getController() {
|
||||
return RestResourceController.class;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
private String label;
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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.rest.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.dspace.app.rest.RestResourceController;
|
||||
|
||||
public class FilteredDiscoveryPageRest extends BaseObjectRest<String> {
|
||||
|
||||
public static final String NAME = "filtered-discovery-page";
|
||||
public static final String CATEGORY = "config";
|
||||
|
||||
public String getCategory() {
|
||||
return CATEGORY;
|
||||
}
|
||||
|
||||
public Class getController() {
|
||||
return RestResourceController.class;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@JsonProperty(value = "filter-name")
|
||||
private String label;
|
||||
@JsonProperty(value = "discovery-query")
|
||||
private String filterQueryString;
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public void setFilterQueryString(String filterQueryString) {
|
||||
this.filterQueryString = filterQueryString; }
|
||||
|
||||
public String getFilterQueryString() {
|
||||
return this.filterQueryString; }
|
||||
}
|
@@ -32,6 +32,8 @@ public class ItemRest extends DSpaceObjectRest {
|
||||
|
||||
List<BitstreamRest> bitstreams;
|
||||
|
||||
List<RelationshipRest> relationships;
|
||||
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return CATEGORY;
|
||||
@@ -100,4 +102,13 @@ public class ItemRest extends DSpaceObjectRest {
|
||||
this.bitstreams = bitstreams;
|
||||
}
|
||||
|
||||
@LinkRest(linkClass = RelationshipRest.class)
|
||||
@JsonIgnore
|
||||
public List<RelationshipRest> getRelationships() {
|
||||
return relationships;
|
||||
}
|
||||
|
||||
public void setRelationships(List<RelationshipRest> relationships) {
|
||||
this.relationships = relationships;
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* 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.rest.model;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.dspace.app.rest.RestResourceController;
|
||||
|
||||
public class RelationshipRest extends BaseObjectRest<Integer> {
|
||||
public static final String NAME = "relationship";
|
||||
public static final String CATEGORY = "core";
|
||||
|
||||
private UUID leftId;
|
||||
private RelationshipTypeRest relationshipType;
|
||||
private UUID rightId;
|
||||
private int leftPlace;
|
||||
private int rightPlace;
|
||||
|
||||
public String getType() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return CATEGORY;
|
||||
}
|
||||
|
||||
public Class getController() {
|
||||
return RestResourceController.class;
|
||||
}
|
||||
|
||||
public UUID getLeftId() {
|
||||
return leftId;
|
||||
}
|
||||
|
||||
public void setLeftId(UUID leftId) {
|
||||
this.leftId = leftId;
|
||||
}
|
||||
|
||||
@LinkRest(linkClass = RelationshipTypeRest.class)
|
||||
@JsonIgnore
|
||||
public RelationshipTypeRest getRelationshipType() {
|
||||
return relationshipType;
|
||||
}
|
||||
|
||||
public void setRelationshipType(RelationshipTypeRest relationshipType) {
|
||||
this.relationshipType = relationshipType;
|
||||
}
|
||||
|
||||
public UUID getRightId() {
|
||||
return rightId;
|
||||
}
|
||||
|
||||
public void setRightId(UUID rightId) {
|
||||
this.rightId = rightId;
|
||||
}
|
||||
|
||||
public int getLeftPlace() {
|
||||
return leftPlace;
|
||||
}
|
||||
|
||||
public void setLeftPlace(int leftPlace) {
|
||||
this.leftPlace = leftPlace;
|
||||
}
|
||||
|
||||
public int getRightPlace() {
|
||||
return rightPlace;
|
||||
}
|
||||
|
||||
public void setRightPlace(int rightPlace) {
|
||||
this.rightPlace = rightPlace;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* 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.rest.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.dspace.app.rest.RestResourceController;
|
||||
|
||||
public class RelationshipTypeRest extends BaseObjectRest<Integer> {
|
||||
|
||||
public static final String NAME = "relationshiptype";
|
||||
public static final String CATEGORY = "core";
|
||||
|
||||
private String leftLabel;
|
||||
private String rightLabel;
|
||||
private int leftMinCardinality;
|
||||
private int leftMaxCardinality;
|
||||
private int rightMinCardinality;
|
||||
private int rightMaxCardinality;
|
||||
private EntityTypeRest leftType;
|
||||
private EntityTypeRest rightType;
|
||||
|
||||
public String getType() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return CATEGORY;
|
||||
}
|
||||
|
||||
public Class getController() {
|
||||
return RestResourceController.class;
|
||||
}
|
||||
|
||||
public String getLeftLabel() {
|
||||
return leftLabel;
|
||||
}
|
||||
|
||||
public void setLeftLabel(String leftLabel) {
|
||||
this.leftLabel = leftLabel;
|
||||
}
|
||||
|
||||
public String getRightLabel() {
|
||||
return rightLabel;
|
||||
}
|
||||
|
||||
public void setRightLabel(String rightLabel) {
|
||||
this.rightLabel = rightLabel;
|
||||
}
|
||||
|
||||
public int getLeftMinCardinality() {
|
||||
return leftMinCardinality;
|
||||
}
|
||||
|
||||
public void setLeftMinCardinality(int leftMinCardinality) {
|
||||
this.leftMinCardinality = leftMinCardinality;
|
||||
}
|
||||
|
||||
public int getLeftMaxCardinality() {
|
||||
return leftMaxCardinality;
|
||||
}
|
||||
|
||||
public void setLeftMaxCardinality(int leftMaxCardinality) {
|
||||
this.leftMaxCardinality = leftMaxCardinality;
|
||||
}
|
||||
|
||||
public int getRightMinCardinality() {
|
||||
return rightMinCardinality;
|
||||
}
|
||||
|
||||
public void setRightMinCardinality(int rightMinCardinality) {
|
||||
this.rightMinCardinality = rightMinCardinality;
|
||||
}
|
||||
|
||||
public int getRightMaxCardinality() {
|
||||
return rightMaxCardinality;
|
||||
}
|
||||
|
||||
public void setRightMaxCardinality(int rightMaxCardinality) {
|
||||
this.rightMaxCardinality = rightMaxCardinality;
|
||||
}
|
||||
|
||||
@LinkRest(linkClass = EntityTypeRest.class)
|
||||
@JsonIgnore
|
||||
public EntityTypeRest getLeftType() {
|
||||
return leftType;
|
||||
}
|
||||
|
||||
public void setLeftType(EntityTypeRest leftType) {
|
||||
this.leftType = leftType;
|
||||
}
|
||||
|
||||
@LinkRest(linkClass = EntityTypeRest.class)
|
||||
@JsonIgnore
|
||||
public EntityTypeRest getRightType() {
|
||||
return rightType;
|
||||
}
|
||||
|
||||
public void setRightType(EntityTypeRest rightType) {
|
||||
this.rightType = rightType;
|
||||
}
|
||||
}
|
@@ -28,6 +28,7 @@ import org.dspace.app.rest.utils.Utils;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.hateoas.Link;
|
||||
|
||||
/**
|
||||
@@ -119,12 +120,14 @@ public abstract class DSpaceResource<T extends RestAddressableModel> extends HAL
|
||||
linkedRMList.get(0).getType());
|
||||
// TODO should we force pagination also of embedded resource?
|
||||
// This will force pagination with size 10 for embedded collections as well
|
||||
// int pageSize = 1;
|
||||
// PageImpl<RestModel> page = new PageImpl(
|
||||
// linkedRMList.subList(0,
|
||||
// linkedRMList.size() > pageSize ? pageSize : linkedRMList.size()),
|
||||
// new PageRequest(0, pageSize), linkedRMList.size());
|
||||
PageImpl<RestAddressableModel> page = new PageImpl(linkedRMList);
|
||||
int pageSize = 20;
|
||||
PageImpl<RestAddressableModel> page = new PageImpl(
|
||||
linkedRMList.subList(0,
|
||||
linkedRMList
|
||||
.size() > pageSize ? pageSize : linkedRMList
|
||||
.size()),
|
||||
new PageRequest(0, pageSize), linkedRMList.size());
|
||||
// PageImpl<RestAddressableModel> page = new PageImpl(linkedRMList);
|
||||
wrapObject = new EmbeddedPage(linkToSubResource.getHref(),
|
||||
page.map(resourceRepository::wrapResource),
|
||||
linkedRMList, name);
|
||||
|
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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.rest.model.hateoas;
|
||||
|
||||
import org.dspace.app.rest.model.EntityTypeRest;
|
||||
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
|
||||
@RelNameDSpaceResource(EntityTypeRest.NAME)
|
||||
public class EntityTypeResource extends DSpaceResource<EntityTypeRest> {
|
||||
public EntityTypeResource(EntityTypeRest data, Utils utils, String... rels) {
|
||||
super(data, utils, rels);
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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.rest.model.hateoas;
|
||||
|
||||
import org.dspace.app.rest.model.FilteredDiscoveryPageRest;
|
||||
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
|
||||
@RelNameDSpaceResource(FilteredDiscoveryPageRest.NAME)
|
||||
public class FilteredDiscoveryPageResource extends DSpaceResource<FilteredDiscoveryPageRest> {
|
||||
public FilteredDiscoveryPageResource(FilteredDiscoveryPageRest data, Utils utils,
|
||||
String... rels) {
|
||||
super(data, utils, rels);
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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.rest.model.hateoas;
|
||||
|
||||
import org.dspace.app.rest.model.RelationshipRest;
|
||||
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
|
||||
@RelNameDSpaceResource(RelationshipRest.NAME)
|
||||
public class RelationshipResource extends DSpaceResource<RelationshipRest> {
|
||||
public RelationshipResource(RelationshipRest data, Utils utils, String... rels) {
|
||||
super(data, utils, rels);
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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.rest.model.hateoas;
|
||||
|
||||
import org.dspace.app.rest.model.RelationshipTypeRest;
|
||||
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
|
||||
@RelNameDSpaceResource(RelationshipTypeRest.NAME)
|
||||
public class RelationshipTypeResource extends DSpaceResource<RelationshipTypeRest> {
|
||||
public RelationshipTypeResource(RelationshipTypeRest data, Utils utils, String... rels) {
|
||||
super(data, utils, rels);
|
||||
}
|
||||
}
|
@@ -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.app.rest.repository;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.converter.EntityTypeConverter;
|
||||
import org.dspace.app.rest.model.EntityTypeRest;
|
||||
import org.dspace.app.rest.model.hateoas.DSpaceResource;
|
||||
import org.dspace.app.rest.model.hateoas.EntityTypeResource;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.service.EntityTypeService;
|
||||
import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component(EntityTypeRest.CATEGORY + "." + EntityTypeRest.NAME)
|
||||
public class EntityTypeRestRepository extends DSpaceRestRepository<EntityTypeRest, Integer> {
|
||||
|
||||
@Autowired
|
||||
private EntityTypeService entityTypeService;
|
||||
|
||||
@Autowired
|
||||
private EntityTypeConverter entityTypeConverter;
|
||||
|
||||
public EntityTypeRest findOne(Context context, Integer integer) {
|
||||
try {
|
||||
return entityTypeConverter.fromModel(entityTypeService.find(context, integer));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public Page<EntityTypeRest> findAll(Context context, Pageable pageable) {
|
||||
List<EntityType> entityTypeList = null;
|
||||
try {
|
||||
entityTypeList = entityTypeService.findAll(context);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Page<EntityTypeRest> page = utils.getPage(entityTypeList, pageable).map(entityTypeConverter);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Class<EntityTypeRest> getDomainClass() {
|
||||
return EntityTypeRest.class;
|
||||
}
|
||||
|
||||
public DSpaceResource<EntityTypeRest> wrapResource(EntityTypeRest model, String... rels) {
|
||||
return new EntityTypeResource(model, utils, rels);
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 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.rest.repository;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.converter.FilteredDiscoveryPageConverter;
|
||||
import org.dspace.app.rest.model.FilteredDiscoveryPageRest;
|
||||
import org.dspace.app.rest.model.hateoas.DSpaceResource;
|
||||
import org.dspace.app.rest.model.hateoas.FilteredDiscoveryPageResource;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.service.EntityTypeService;
|
||||
import org.dspace.content.virtual.EntityTypeToFilterQueryService;
|
||||
import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component(FilteredDiscoveryPageRest.CATEGORY + "." + FilteredDiscoveryPageRest.NAME)
|
||||
public class FilteredDiscoveryPageRestRepository extends DSpaceRestRepository<FilteredDiscoveryPageRest, String> {
|
||||
|
||||
@Autowired
|
||||
private EntityTypeService entityTypeService;
|
||||
|
||||
@Autowired
|
||||
private FilteredDiscoveryPageConverter filteredDiscoveryPageConverter;
|
||||
|
||||
@Autowired
|
||||
private EntityTypeToFilterQueryService entityTypeToFilterQueryService;
|
||||
|
||||
public FilteredDiscoveryPageRest findOne(Context context, String string) {
|
||||
try {
|
||||
return filteredDiscoveryPageConverter.fromModel(entityTypeService.findByEntityType(context, string));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public Page<FilteredDiscoveryPageRest> findAll(Context context, Pageable pageable) {
|
||||
List<EntityType> entityTypeList = null;
|
||||
try {
|
||||
entityTypeList = entityTypeService.findAll(context);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
List<EntityType> resultingList = new LinkedList<>();
|
||||
for (EntityType entityType : entityTypeList) {
|
||||
if (entityTypeToFilterQueryService.hasKey(entityType.getLabel())) {
|
||||
resultingList.add(entityType);
|
||||
}
|
||||
}
|
||||
Page<FilteredDiscoveryPageRest> page = utils.getPage(resultingList, pageable)
|
||||
.map(filteredDiscoveryPageConverter);
|
||||
return page; }
|
||||
|
||||
public Class<FilteredDiscoveryPageRest> getDomainClass() {
|
||||
return FilteredDiscoveryPageRest.class;
|
||||
}
|
||||
|
||||
public DSpaceResource<FilteredDiscoveryPageRest> wrapResource(FilteredDiscoveryPageRest model, String... rels) {
|
||||
return new FilteredDiscoveryPageResource(model, utils, rels);
|
||||
}
|
||||
}
|
@@ -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.app.rest.repository;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.converter.RelationshipConverter;
|
||||
import org.dspace.app.rest.model.RelationshipRest;
|
||||
import org.dspace.app.rest.model.hateoas.DSpaceResource;
|
||||
import org.dspace.app.rest.model.hateoas.RelationshipResource;
|
||||
import org.dspace.content.Relationship;
|
||||
import org.dspace.content.service.RelationshipService;
|
||||
import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component(RelationshipRest.CATEGORY + "." + RelationshipRest.NAME)
|
||||
public class RelationshipRestRepository extends DSpaceRestRepository<RelationshipRest, Integer> {
|
||||
|
||||
@Autowired
|
||||
private RelationshipService relationshipService;
|
||||
|
||||
@Autowired
|
||||
private RelationshipConverter relationshipConverter;
|
||||
|
||||
public RelationshipRest findOne(Context context, Integer integer) {
|
||||
try {
|
||||
return relationshipConverter.fromModel(relationshipService.find(context, integer));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public Page<RelationshipRest> findAll(Context context, Pageable pageable) {
|
||||
List<Relationship> relationships = null;
|
||||
try {
|
||||
relationships = relationshipService.findAll(context);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Page<RelationshipRest> page = utils.getPage(relationships, pageable).map(relationshipConverter);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Class<RelationshipRest> getDomainClass() {
|
||||
return RelationshipRest.class;
|
||||
}
|
||||
|
||||
public DSpaceResource<RelationshipRest> wrapResource(RelationshipRest model, String... rels) {
|
||||
return new RelationshipResource(model, utils, rels);
|
||||
}
|
||||
}
|
@@ -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.app.rest.repository;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.converter.RelationshipTypeConverter;
|
||||
import org.dspace.app.rest.model.RelationshipTypeRest;
|
||||
import org.dspace.app.rest.model.hateoas.DSpaceResource;
|
||||
import org.dspace.app.rest.model.hateoas.RelationshipTypeResource;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.content.service.RelationshipTypeService;
|
||||
import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component(RelationshipTypeRest.CATEGORY + "." + RelationshipTypeRest.NAME)
|
||||
public class RelationshipTypeRestRepository extends DSpaceRestRepository<RelationshipTypeRest, Integer> {
|
||||
|
||||
@Autowired
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
|
||||
@Autowired
|
||||
private RelationshipTypeConverter relationshipTypeConverter;
|
||||
|
||||
public RelationshipTypeRest findOne(Context context, Integer integer) {
|
||||
try {
|
||||
return relationshipTypeConverter.fromModel(relationshipTypeService.find(context, integer));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public Page<RelationshipTypeRest> findAll(Context context, Pageable pageable) {
|
||||
List<RelationshipType> relationshipTypeList = null;
|
||||
try {
|
||||
relationshipTypeList = relationshipTypeService.findAll(context);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Page<RelationshipTypeRest> page = utils.getPage(relationshipTypeList, pageable).map(relationshipTypeConverter);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Class<RelationshipTypeRest> getDomainClass() {
|
||||
return RelationshipTypeRest.class;
|
||||
}
|
||||
|
||||
public DSpaceResource<RelationshipTypeRest> wrapResource(RelationshipTypeRest model, String... rels) {
|
||||
return new RelationshipTypeResource(model, utils, rels);
|
||||
}
|
||||
}
|
@@ -21,7 +21,7 @@ public class RootRestRepository {
|
||||
@Autowired
|
||||
RootConverter rootConverter;
|
||||
|
||||
public RootRest getRoot(String restUrl) {
|
||||
return rootConverter.convert(restUrl);
|
||||
public RootRest getRoot() {
|
||||
return rootConverter.convert();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* 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.rest;
|
||||
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.matcher.EntityTypeMatcher;
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.content.service.EntityTypeService;
|
||||
import org.dspace.content.service.RelationshipTypeService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class EntityTypeRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
|
||||
@Autowired
|
||||
private EntityTypeService entityTypeService;
|
||||
|
||||
@Autowired
|
||||
private ConfigurationService configurationService;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
|
||||
//Set up the database for the next test
|
||||
String pathToFile = configurationService.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator + "entities" + File.separator + "relationship-types.xml";
|
||||
runDSpaceScript("initialize-entities", "-f", pathToFile);
|
||||
}
|
||||
|
||||
@After
|
||||
public void destroy() throws SQLException, AuthorizeException {
|
||||
|
||||
//Clean up the database for the next test
|
||||
context.turnOffAuthorisationSystem();
|
||||
List<RelationshipType> relationshipTypeList = relationshipTypeService.findAll(context);
|
||||
List<EntityType> entityTypeList = entityTypeService.findAll(context);
|
||||
|
||||
for (RelationshipType relationshipType : relationshipTypeList) {
|
||||
relationshipTypeService.delete(context, relationshipType);
|
||||
}
|
||||
|
||||
for (EntityType entityType : entityTypeList) {
|
||||
entityTypeService.delete(context, entityType);
|
||||
}
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
@Test
|
||||
public void findAllEntityTypesSizeTest() throws SQLException {
|
||||
assertEquals(7, entityTypeService.findAll(context).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findPublicationEntityTypeTest() throws SQLException {
|
||||
String type = "Publication";
|
||||
checkEntityType(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findPersonEntityTypeTest() throws SQLException {
|
||||
String type = "Person";
|
||||
checkEntityType(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findProjectEntityTypeTest() throws SQLException {
|
||||
String type = "Project";
|
||||
checkEntityType(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findOrgUnitEntityTypeTest() throws SQLException {
|
||||
String type = "OrgUnit";
|
||||
checkEntityType(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findJournalEntityTypeTest() throws SQLException {
|
||||
String type = "Journal";
|
||||
checkEntityType(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findJournalVolumeEntityTypeTest() throws SQLException {
|
||||
String type = "JournalVolume";
|
||||
checkEntityType(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findJournalIssueEntityTypeTest() throws SQLException {
|
||||
String type = "JournalIssue";
|
||||
checkEntityType(type);
|
||||
}
|
||||
private void checkEntityType(String type) throws SQLException {
|
||||
EntityType entityType = entityTypeService.findByEntityType(context, type);
|
||||
assertNotNull(entityType);
|
||||
assertEquals(type, entityType.getLabel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllEntityTypeEndpoint() throws Exception {
|
||||
//When we call this facets endpoint
|
||||
getClient().perform(get("/api/core/entitytypes"))
|
||||
|
||||
//We expect a 200 OK status
|
||||
.andExpect(status().isOk())
|
||||
//The type has to be 'discover'
|
||||
.andExpect(jsonPath("$.page.totalElements", is(7)))
|
||||
//There needs to be a self link to this endpoint
|
||||
.andExpect(jsonPath("$._links.self.href", containsString("api/core/entitytypes")))
|
||||
//We have 4 facets in the default configuration, they need to all be present in the embedded section
|
||||
.andExpect(jsonPath("$._embedded.entitytypes", containsInAnyOrder(
|
||||
EntityTypeMatcher.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "Publication")),
|
||||
EntityTypeMatcher.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "Person")),
|
||||
EntityTypeMatcher.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "Project")),
|
||||
EntityTypeMatcher.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "OrgUnit")),
|
||||
EntityTypeMatcher.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "Journal")),
|
||||
EntityTypeMatcher.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "JournalVolume")),
|
||||
EntityTypeMatcher.matchEntityTypeEntry(entityTypeService.findByEntityType(context, "JournalIssue"))
|
||||
)));
|
||||
}
|
||||
}
|
@@ -0,0 +1,171 @@
|
||||
package org.dspace.app.rest;
|
||||
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.builder.CollectionBuilder;
|
||||
import org.dspace.app.rest.builder.CommunityBuilder;
|
||||
import org.dspace.app.rest.builder.ItemBuilder;
|
||||
import org.dspace.app.rest.builder.RelationshipBuilder;
|
||||
import org.dspace.app.rest.matcher.PageMatcher;
|
||||
import org.dspace.app.rest.matcher.RelationshipMatcher;
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
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.EntityTypeService;
|
||||
import org.dspace.content.service.RelationshipTypeService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
|
||||
@Autowired
|
||||
private EntityTypeService entityTypeService;
|
||||
|
||||
@Autowired
|
||||
private ConfigurationService configurationService;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
|
||||
//Set up the database for the next test
|
||||
String pathToFile = configurationService.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator + "entities" + File.separator + "relationship-types.xml";
|
||||
runDSpaceScript("initialize-entities", "-f", pathToFile);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
public void destroy() throws SQLException, AuthorizeException {
|
||||
|
||||
//Clean up the database for the next test
|
||||
context.turnOffAuthorisationSystem();
|
||||
List<RelationshipType> relationshipTypeList = relationshipTypeService.findAll(context);
|
||||
List<EntityType> entityTypeList = entityTypeService.findAll(context);
|
||||
|
||||
for (RelationshipType relationshipType : relationshipTypeList) {
|
||||
relationshipTypeService.delete(context, relationshipType);
|
||||
}
|
||||
|
||||
for (EntityType entityType : entityTypeList) {
|
||||
entityTypeService.delete(context, entityType);
|
||||
}
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAllRelationshipTest() throws Exception {
|
||||
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
|
||||
.withName("Sub Community")
|
||||
.build();
|
||||
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
|
||||
Collection col2 = CollectionBuilder.createCollection(context, child1).withName("Collection 2").build();
|
||||
Collection col3 = CollectionBuilder.createCollection(context, child1).withName("OrgUnits").build();
|
||||
|
||||
Item auhor1 = ItemBuilder.createItem(context, col1)
|
||||
.withTitle("Author1")
|
||||
.withIssueDate("2017-10-17")
|
||||
.withAuthor("Smith, Donald")
|
||||
.withRelationshipType("Person")
|
||||
.build();
|
||||
|
||||
Item author2 = ItemBuilder.createItem(context, col2)
|
||||
.withTitle("Author2")
|
||||
.withIssueDate("2016-02-13")
|
||||
.withAuthor("Smith, Maria")
|
||||
.withRelationshipType("Person")
|
||||
.build();
|
||||
|
||||
Item author3 = ItemBuilder.createItem(context, col2)
|
||||
.withTitle("Author3")
|
||||
.withIssueDate("2016-02-13")
|
||||
.withAuthor("Maybe, Maybe")
|
||||
.withRelationshipType("Person")
|
||||
.build();
|
||||
|
||||
Item orgUnit1 = ItemBuilder.createItem(context, col3)
|
||||
.withTitle("OrgUnit1")
|
||||
.withAuthor("Testy, TEst")
|
||||
.withIssueDate("2015-01-01")
|
||||
.withRelationshipType("OrgUnit")
|
||||
.build();
|
||||
|
||||
Item project1 = ItemBuilder.createItem(context, col3)
|
||||
.withTitle("Project1")
|
||||
.withAuthor("Testy, TEst")
|
||||
.withIssueDate("2015-01-01")
|
||||
.withRelationshipType("Project")
|
||||
.build();
|
||||
|
||||
Item publication = ItemBuilder.createItem(context, col3)
|
||||
.withTitle("Publication1")
|
||||
.withAuthor("Testy, TEst")
|
||||
.withIssueDate("2015-01-01")
|
||||
.withRelationshipType("Publication")
|
||||
.build();
|
||||
|
||||
|
||||
RelationshipType isOrgUnitOfPersonRelationshipType = relationshipTypeService.findbyTypesAndLabels(context,
|
||||
entityTypeService
|
||||
.findByEntityType(context,
|
||||
"Person"),
|
||||
entityTypeService
|
||||
.findByEntityType(context,
|
||||
"OrgUnit"),
|
||||
"isOrgUnitOfPerson",
|
||||
"isPersonOfOrgUnit");
|
||||
|
||||
RelationshipType isOrgUnitOfProjectRelationshipType = relationshipTypeService.findbyTypesAndLabels(context,
|
||||
entityTypeService.findByEntityType(context, "Project"),
|
||||
entityTypeService.findByEntityType(context, "OrgUnit"),
|
||||
"isOrgUnitOfProject",
|
||||
"isProjectOfOrgUnit");
|
||||
|
||||
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService.findbyTypesAndLabels(context,
|
||||
entityTypeService.findByEntityType(context, "Publication"),
|
||||
entityTypeService.findByEntityType(context, "Person"),
|
||||
"isAuthorOfPublication",
|
||||
"isPublicationOfAuthor");
|
||||
Relationship relationship1 = RelationshipBuilder.createRelationshipBuilder(context, auhor1, orgUnit1, isOrgUnitOfPersonRelationshipType).build();
|
||||
|
||||
Relationship relationship2 = RelationshipBuilder.createRelationshipBuilder(context, project1, orgUnit1, isOrgUnitOfProjectRelationshipType).build();
|
||||
|
||||
Relationship relationship3 = RelationshipBuilder.createRelationshipBuilder(context, publication, auhor1, isAuthorOfPublicationRelationshipType).build();
|
||||
|
||||
getClient().perform(get("/api/core/relationships"))
|
||||
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.page",
|
||||
is(PageMatcher.pageEntryWithTotalPagesAndElements(0, 20, 1, 3))))
|
||||
.andExpect(jsonPath("$._embedded.relationships", containsInAnyOrder(
|
||||
RelationshipMatcher.matchRelationship(relationship1),
|
||||
RelationshipMatcher.matchRelationship(relationship2),
|
||||
RelationshipMatcher.matchRelationship(relationship3)
|
||||
)))
|
||||
; }
|
||||
}
|
@@ -0,0 +1,265 @@
|
||||
/**
|
||||
* 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.rest;
|
||||
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.dspace.app.rest.matcher.EntityTypeMatcher;
|
||||
import org.dspace.app.rest.matcher.RelationshipTypeMatcher;
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.content.service.EntityTypeService;
|
||||
import org.dspace.content.service.RelationshipTypeService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.h2.util.StringUtils;
|
||||
import org.jbibtex.StringUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class RelationshipTypeRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
|
||||
@Autowired
|
||||
private EntityTypeService entityTypeService;
|
||||
|
||||
@Autowired
|
||||
private ConfigurationService configurationService;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
|
||||
//Set up the database for the next test
|
||||
String pathToFile = configurationService.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator + "entities" + File.separator + "relationship-types.xml";
|
||||
runDSpaceScript("initialize-entities", "-f", pathToFile);
|
||||
}
|
||||
|
||||
@After
|
||||
public void destroy() throws SQLException, AuthorizeException {
|
||||
|
||||
//Clean up the database for the next test
|
||||
context.turnOffAuthorisationSystem();
|
||||
List<RelationshipType> relationshipTypeList = relationshipTypeService.findAll(context);
|
||||
List<EntityType> entityTypeList = entityTypeService.findAll(context);
|
||||
|
||||
for (RelationshipType relationshipType : relationshipTypeList) {
|
||||
relationshipTypeService.delete(context, relationshipType);
|
||||
}
|
||||
|
||||
for (EntityType entityType : entityTypeList) {
|
||||
entityTypeService.delete(context, entityType);
|
||||
}
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
@Test
|
||||
public void findAllRelationshipTypesTest() throws SQLException {
|
||||
assertEquals(8, relationshipTypeService.findAll(context).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findPublicationPersonRelationshipType() throws SQLException {
|
||||
String leftTypeString = "Publication";
|
||||
String rightTypeString = "Person";
|
||||
String leftLabel = "isAuthorOfPublication";
|
||||
String rightLabel = "isPublicationOfAuthor";
|
||||
checkRelationshipType(leftTypeString, rightTypeString, leftLabel, rightLabel);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findPublicationProjectRelationshipType() throws SQLException {
|
||||
String leftTypeString = "Publication";
|
||||
String rightTypeString = "Project";
|
||||
String leftLabel = "isProjectOfPublication";
|
||||
String rightLabel = "isPublicationOfProject";
|
||||
checkRelationshipType(leftTypeString, rightTypeString, leftLabel, rightLabel);
|
||||
}
|
||||
@Test
|
||||
public void findPublicationOrgUnitRelationshipType() throws SQLException {
|
||||
String leftTypeString = "Publication";
|
||||
String rightTypeString = "OrgUnit";
|
||||
String leftLabel = "isOrgUnitOfPublication";
|
||||
String rightLabel = "isPublicationOfOrgUnit";
|
||||
checkRelationshipType(leftTypeString, rightTypeString, leftLabel, rightLabel);
|
||||
}
|
||||
@Test
|
||||
public void findPersonProjectRelationshipType() throws SQLException {
|
||||
String leftTypeString = "Person";
|
||||
String rightTypeString = "Project";
|
||||
String leftLabel = "isProjectOfPerson";
|
||||
String rightLabel = "isPersonOfProject";
|
||||
checkRelationshipType(leftTypeString, rightTypeString, leftLabel, rightLabel);
|
||||
}
|
||||
@Test
|
||||
public void findPersonOrgUnitRelationshipType() throws SQLException {
|
||||
String leftTypeString = "Person";
|
||||
String rightTypeString = "OrgUnit";
|
||||
String leftLabel = "isOrgUnitOfPerson";
|
||||
String rightLabel = "isPersonOfOrgUnit";
|
||||
checkRelationshipType(leftTypeString, rightTypeString, leftLabel, rightLabel);
|
||||
}
|
||||
@Test
|
||||
public void findProjectOrgUnitRelationshipType() throws SQLException {
|
||||
String leftTypeString = "Project";
|
||||
String rightTypeString = "OrgUnit";
|
||||
String leftLabel = "isOrgUnitOfProject";
|
||||
String rightLabel = "isProjectOfOrgUnit";
|
||||
checkRelationshipType(leftTypeString, rightTypeString, leftLabel, rightLabel);
|
||||
}
|
||||
@Test
|
||||
public void findJournalJournalVolumeRelationshipType() throws SQLException {
|
||||
String leftTypeString = "Journal";
|
||||
String rightTypeString = "JournalVolume";
|
||||
String leftLabel = "isVolumeOfJournal";
|
||||
String rightLabel = "isJournalOfVolume";
|
||||
checkRelationshipType(leftTypeString, rightTypeString, leftLabel, rightLabel);
|
||||
}
|
||||
@Test
|
||||
public void findJournalVolumeJournalIssueRelationshipType() throws SQLException {
|
||||
String leftTypeString = "JournalVolume";
|
||||
String rightTypeString = "JournalIssue";
|
||||
String leftLabel = "isIssueOfJournalVolume";
|
||||
String rightLabel = "isJournalVolumeOfIssue";
|
||||
checkRelationshipType(leftTypeString, rightTypeString, leftLabel, rightLabel);
|
||||
}
|
||||
private void checkRelationshipType(String leftType, String rightType, String leftLabel, String rightLabel) throws SQLException {
|
||||
RelationshipType relationshipType = relationshipTypeService.findbyTypesAndLabels(context,
|
||||
entityTypeService.findByEntityType(context,leftType),
|
||||
entityTypeService.findByEntityType(context, rightType),
|
||||
leftLabel,
|
||||
rightLabel);
|
||||
assertNotNull(relationshipType);
|
||||
assertEquals(entityTypeService.findByEntityType(context, leftType), relationshipType.getLeftType());
|
||||
assertEquals(entityTypeService.findByEntityType(context, rightType), relationshipType.getRightType());
|
||||
assertEquals(leftLabel, relationshipType.getLeftLabel());
|
||||
assertEquals(rightLabel, relationshipType.getRightLabel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllRelationshipTypesEndpointTest() throws Exception {
|
||||
//When we call this facets endpoint
|
||||
List<RelationshipType> relationshipTypes = relationshipTypeService.findAll(context);
|
||||
|
||||
getClient().perform(get("/api/core/relationshiptypes"))
|
||||
|
||||
//We expect a 200 OK status
|
||||
.andExpect(status().isOk())
|
||||
//The type has to be 'discover'
|
||||
.andExpect(jsonPath("$.page.totalElements", is(8)))
|
||||
//There needs to be a self link to this endpoint
|
||||
.andExpect(jsonPath("$._links.self.href", containsString("api/core/relationshiptypes")))
|
||||
//We have 4 facets in the default configuration, they need to all be present in the embedded section
|
||||
.andExpect(jsonPath("$._embedded.relationshiptypes", containsInAnyOrder(
|
||||
RelationshipTypeMatcher.matchRelationshipTypeEntry(relationshipTypes.get(0)),
|
||||
RelationshipTypeMatcher.matchRelationshipTypeEntry(relationshipTypes.get(1)),
|
||||
RelationshipTypeMatcher.matchRelationshipTypeEntry(relationshipTypes.get(2)),
|
||||
RelationshipTypeMatcher.matchRelationshipTypeEntry(relationshipTypes.get(3)),
|
||||
RelationshipTypeMatcher.matchRelationshipTypeEntry(relationshipTypes.get(4)),
|
||||
RelationshipTypeMatcher.matchRelationshipTypeEntry(relationshipTypes.get(5)),
|
||||
RelationshipTypeMatcher.matchRelationshipTypeEntry(relationshipTypes.get(6)),
|
||||
RelationshipTypeMatcher.matchRelationshipTypeEntry(relationshipTypes.get(7)))
|
||||
));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityTypeForPublicationPersonRelationshipTypeTest() throws Exception{
|
||||
|
||||
List<RelationshipType> relationshipTypes = relationshipTypeService.findAll(context);
|
||||
|
||||
RelationshipType foundRelationshipType = null;
|
||||
for (RelationshipType relationshipType : relationshipTypes) {
|
||||
if(StringUtils.equals(relationshipType.getLeftLabel(), "isAuthorOfPublication") && StringUtils.equals(relationshipType.getRightLabel(), "isPublicationOfAuthor")) {
|
||||
foundRelationshipType = relationshipType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(foundRelationshipType != null) {
|
||||
getClient().perform(get("/api/core/relationshiptypes/"+foundRelationshipType.getId()))
|
||||
.andExpect(jsonPath("$._embedded.leftType", EntityTypeMatcher.matchEntityTypeEntryForLabel("Publication")))
|
||||
.andExpect(jsonPath("$._embedded.rightType", EntityTypeMatcher.matchEntityTypeEntryForLabel("Person")));
|
||||
} else {
|
||||
throw new Exception("RelationshipType not found for isIssueOfJournalVolume");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cardinalityOnAuthorPublicationRelationshipTypesTest() throws Exception{
|
||||
RelationshipType relationshipType = relationshipTypeService.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"), entityTypeService.findByEntityType(context, "Person"), "isAuthorOfPublication", "isPublicationOfAuthor");
|
||||
assertEquals(0, relationshipType.getLeftMinCardinality());
|
||||
assertEquals(0, relationshipType.getRightMinCardinality());
|
||||
assertEquals(Integer.MAX_VALUE, relationshipType.getLeftMaxCardinality());
|
||||
assertEquals(Integer.MAX_VALUE, relationshipType.getRightMaxCardinality());
|
||||
|
||||
getClient().perform(get("/api/core/relationshiptypes/"+relationshipType.getId()))
|
||||
.andExpect(jsonPath("$.leftMinCardinality", is(0)))
|
||||
.andExpect(jsonPath("$.rightMinCardinality", is(0)))
|
||||
.andExpect(jsonPath("$.leftMaxCardinality", is(Integer.MAX_VALUE)))
|
||||
.andExpect(jsonPath("$.rightMaxCardinality", is(Integer.MAX_VALUE)));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityTypeForIssueJournalRelationshipTypeTest() throws Exception{
|
||||
|
||||
List<RelationshipType> relationshipTypes = relationshipTypeService.findAll(context);
|
||||
|
||||
RelationshipType foundRelationshipType = null;
|
||||
for (RelationshipType relationshipType : relationshipTypes) {
|
||||
if(StringUtils.equals(relationshipType.getLeftLabel(), "isIssueOfJournalVolume") && StringUtils.equals(relationshipType.getRightLabel(), "isJournalVolumeOfIssue")) {
|
||||
foundRelationshipType = relationshipType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(foundRelationshipType != null) {
|
||||
getClient().perform(get("/api/core/relationshiptypes/"+foundRelationshipType.getId()))
|
||||
.andExpect(jsonPath("$._embedded.leftType", EntityTypeMatcher.matchEntityTypeEntryForLabel("JournalVolume")))
|
||||
.andExpect(jsonPath("$._embedded.rightType", EntityTypeMatcher.matchEntityTypeEntryForLabel("JournalIssue")));
|
||||
} else {
|
||||
throw new Exception("RelationshipType not found for isIssueOfJournalVolume");
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void cardinalityOnIssueJournalJournalVolumeRelationshipTypesTest() throws Exception{
|
||||
RelationshipType relationshipType = relationshipTypeService.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "JournalVolume"), entityTypeService.findByEntityType(context, "JournalIssue"), "isIssueOfJournalVolume", "isJournalVolumeOfIssue");
|
||||
assertEquals(0, relationshipType.getLeftMinCardinality());
|
||||
assertEquals(1, relationshipType.getRightMinCardinality());
|
||||
assertEquals(Integer.MAX_VALUE, relationshipType.getLeftMaxCardinality());
|
||||
assertEquals(1, relationshipType.getRightMaxCardinality());
|
||||
|
||||
getClient().perform(get("/api/core/relationshiptypes/"+relationshipType.getId()))
|
||||
.andExpect(jsonPath("$.leftMinCardinality", is(0)))
|
||||
.andExpect(jsonPath("$.rightMinCardinality", is(1)))
|
||||
.andExpect(jsonPath("$.leftMaxCardinality", is(Integer.MAX_VALUE)))
|
||||
.andExpect(jsonPath("$.rightMaxCardinality", is(1)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -55,7 +55,7 @@ public class SubmissionDefinitionsControllerIT extends AbstractControllerIntegra
|
||||
.andExpect(jsonPath("$.page.totalPages", greaterThanOrEqualTo(1)))
|
||||
.andExpect(jsonPath("$.page.number", is(0)))
|
||||
.andExpect(
|
||||
jsonPath("$._links.search.href", is(REST_SERVER_URL + "config/submissiondefinitions/search")))
|
||||
jsonPath("$._links.search.href", is(REST_SERVER_URL + "api/config/submissiondefinitions/search")))
|
||||
|
||||
//The array of browse index should have a size greater or equals to 1
|
||||
.andExpect(jsonPath("$._embedded.submissiondefinitions", hasSize(greaterThanOrEqualTo(1))))
|
||||
@@ -157,10 +157,10 @@ public class SubmissionDefinitionsControllerIT extends AbstractControllerIntegra
|
||||
hasJsonPath("$.type", is("submissionsection")),
|
||||
hasJsonPath("$._links.config.href",
|
||||
is(REST_SERVER_URL +
|
||||
"config/submissionforms/traditionalpageone")),
|
||||
"api/config/submissionforms/traditionalpageone")),
|
||||
hasJsonPath("$._links.self.href",
|
||||
is(REST_SERVER_URL +
|
||||
"config/submissionsections/traditionalpageone"))
|
||||
"api/config/submissionsections/traditionalpageone"))
|
||||
))))
|
||||
;
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ public class SubmissionSectionsControllerIT extends AbstractControllerIntegratio
|
||||
.andExpect(jsonPath("$.page.totalPages", greaterThanOrEqualTo(1)))
|
||||
.andExpect(jsonPath("$.page.number", is(0)))
|
||||
.andExpect(jsonPath("$._links.self.href",
|
||||
Matchers.startsWith(REST_SERVER_URL + "config/submissionsections")))
|
||||
Matchers.startsWith(REST_SERVER_URL + "api/config/submissionsections")))
|
||||
|
||||
//The array of browse index should have a size greater or equals to 1
|
||||
.andExpect(jsonPath("$._embedded.submissionsections", hasSize(greaterThanOrEqualTo(1))
|
||||
|
@@ -48,7 +48,7 @@ public class SubmissionUploadsControllerIT extends AbstractControllerIntegration
|
||||
.andExpect(jsonPath("$.page.totalPages", greaterThanOrEqualTo(1)))
|
||||
.andExpect(jsonPath("$.page.number", is(0)))
|
||||
.andExpect(jsonPath("$._links.self.href",
|
||||
Matchers.startsWith(REST_SERVER_URL + "config/submissionuploads")))
|
||||
Matchers.startsWith(REST_SERVER_URL + "api/config/submissionuploads")))
|
||||
|
||||
//The array of browse index should have a size greater or equals to 1
|
||||
.andExpect(jsonPath("$._embedded.submissionuploads", hasSize(greaterThanOrEqualTo(1))))
|
||||
|
@@ -27,6 +27,7 @@ import org.dspace.content.service.InstallItemService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
import org.dspace.content.service.RelationshipService;
|
||||
import org.dspace.content.service.SiteService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
import org.dspace.core.Context;
|
||||
@@ -72,6 +73,7 @@ public abstract class AbstractBuilder<T, S> {
|
||||
static MetadataFieldService metadataFieldService;
|
||||
static MetadataSchemaService metadataSchemaService;
|
||||
static SiteService siteService;
|
||||
static RelationshipService relationshipService;
|
||||
|
||||
protected Context context;
|
||||
|
||||
@@ -107,6 +109,7 @@ public abstract class AbstractBuilder<T, S> {
|
||||
metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService();
|
||||
metadataSchemaService = ContentServiceFactory.getInstance().getMetadataSchemaService();
|
||||
siteService = ContentServiceFactory.getInstance().getSiteService();
|
||||
relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||
|
||||
// Temporarily disabled
|
||||
// TODO find a way to be able to test the XML and "default" workflow at the same time
|
||||
|
@@ -67,6 +67,10 @@ public class ItemBuilder extends AbstractDSpaceObjectBuilder<Item> {
|
||||
return addMetadataValue(item, MetadataSchema.DC_SCHEMA, "subject", null, subject);
|
||||
}
|
||||
|
||||
public ItemBuilder withRelationshipType(final String relationshipType) {
|
||||
return addMetadataValue(item, "relationship", "type", null, relationshipType);
|
||||
}
|
||||
|
||||
public ItemBuilder makeUnDiscoverable() {
|
||||
item.setDiscoverable(false);
|
||||
return this;
|
||||
|
@@ -0,0 +1,80 @@
|
||||
package org.dspace.app.rest.builder;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.Relationship;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.content.service.RelationshipService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.discovery.SearchServiceException;
|
||||
|
||||
public class RelationshipBuilder extends AbstractBuilder<Relationship, RelationshipService> {
|
||||
|
||||
/* Log4j logger*/
|
||||
private static final Logger log = Logger.getLogger(RelationshipBuilder.class);
|
||||
|
||||
private Relationship relationship;
|
||||
|
||||
protected RelationshipBuilder(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RelationshipService getService() {
|
||||
return relationshipService;
|
||||
}
|
||||
|
||||
protected void cleanup() throws Exception {
|
||||
delete(relationship);
|
||||
}
|
||||
|
||||
public Relationship build() {
|
||||
try {
|
||||
|
||||
relationshipService.update(context, relationship);
|
||||
context.dispatchEvents();
|
||||
|
||||
indexingService.commit();
|
||||
} catch (SearchServiceException|SQLException|AuthorizeException e) {
|
||||
log.error(e);
|
||||
}
|
||||
return relationship;
|
||||
}
|
||||
|
||||
public void delete(Relationship dso) throws Exception {
|
||||
try (Context c = new Context()) {
|
||||
c.turnOffAuthorisationSystem();
|
||||
Relationship attachedDso = c.reloadEntity(dso);
|
||||
if (attachedDso != null) {
|
||||
getService().delete(c, attachedDso);
|
||||
}
|
||||
c.complete();
|
||||
}
|
||||
|
||||
indexingService.commit();
|
||||
}
|
||||
|
||||
public static RelationshipBuilder createRelationshipBuilder(Context context, Item leftItem, Item rightItem, RelationshipType relationshipType) {
|
||||
|
||||
RelationshipBuilder relationshipBuilder = new RelationshipBuilder(context);
|
||||
return relationshipBuilder.create(context, leftItem, rightItem, relationshipType);
|
||||
}
|
||||
private RelationshipBuilder create(Context context, Item leftItem, Item rightItem, RelationshipType relationshipType) {
|
||||
this.context = context;
|
||||
|
||||
try {
|
||||
relationship = new Relationship();
|
||||
relationship.setLeftItem(leftItem);
|
||||
relationship.setRightItem(rightItem);
|
||||
relationship.setRelationshipType(relationshipType);
|
||||
relationshipService.create(context, relationship);
|
||||
} catch (SQLException|AuthorizeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
@@ -36,17 +36,18 @@ public class RootConverterTest {
|
||||
public void setUp() throws Exception {
|
||||
when(configurationService.getProperty("dspace.url")).thenReturn("dspaceurl");
|
||||
when(configurationService.getProperty("dspace.name")).thenReturn("dspacename");
|
||||
when(configurationService.getProperty("dspace.restUrl")).thenReturn("rest");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReturnCorrectClass() throws Exception {
|
||||
assertEquals(rootConverter.convert("").getClass(), RootRest.class);
|
||||
assertEquals(rootConverter.convert().getClass(), RootRest.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCorrectPropertiesSetFromConfigurationService() throws Exception {
|
||||
String restUrl = "rest";
|
||||
RootRest rootRest = rootConverter.convert(restUrl);
|
||||
RootRest rootRest = rootConverter.convert();
|
||||
assertEquals("dspaceurl", rootRest.getDspaceURL());
|
||||
assertEquals("dspacename", rootRest.getDspaceName());
|
||||
assertEquals(restUrl, rootRest.getDspaceRest());
|
||||
@@ -54,6 +55,6 @@ public class RootConverterTest {
|
||||
|
||||
@Test
|
||||
public void testReturnNotNull() throws Exception {
|
||||
assertNotNull(rootConverter.convert(""));
|
||||
assertNotNull(rootConverter.convert());
|
||||
}
|
||||
}
|
||||
|
@@ -34,9 +34,9 @@ public class BrowseIndexMatcher {
|
||||
hasJsonPath("$.metadataBrowse", Matchers.is(true)),
|
||||
hasJsonPath("$.order", equalToIgnoringCase(order)),
|
||||
hasJsonPath("$.sortOptions[*].name", containsInAnyOrder("title", "dateissued", "dateaccessioned")),
|
||||
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "discover/browses/subject")),
|
||||
hasJsonPath("$._links.entries.href", is(REST_SERVER_URL + "discover/browses/subject/entries")),
|
||||
hasJsonPath("$._links.items.href", is(REST_SERVER_URL + "discover/browses/subject/items"))
|
||||
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "api/discover/browses/subject")),
|
||||
hasJsonPath("$._links.entries.href", is(REST_SERVER_URL + "api/discover/browses/subject/entries")),
|
||||
hasJsonPath("$._links.items.href", is(REST_SERVER_URL + "api/discover/browses/subject/items"))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ public class BrowseIndexMatcher {
|
||||
hasJsonPath("$.metadataBrowse", Matchers.is(false)),
|
||||
hasJsonPath("$.order", equalToIgnoringCase(order)),
|
||||
hasJsonPath("$.sortOptions[*].name", containsInAnyOrder("title", "dateissued", "dateaccessioned")),
|
||||
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "discover/browses/title")),
|
||||
hasJsonPath("$._links.items.href", is(REST_SERVER_URL + "discover/browses/title/items"))
|
||||
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "api/discover/browses/title")),
|
||||
hasJsonPath("$._links.items.href", is(REST_SERVER_URL + "api/discover/browses/title/items"))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ public class BrowseIndexMatcher {
|
||||
hasJsonPath("$.metadataBrowse", Matchers.is(true)),
|
||||
hasJsonPath("$.order", equalToIgnoringCase(order)),
|
||||
hasJsonPath("$.sortOptions[*].name", containsInAnyOrder("title", "dateissued", "dateaccessioned")),
|
||||
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "discover/browses/author")),
|
||||
hasJsonPath("$._links.entries.href", is(REST_SERVER_URL + "discover/browses/author/entries")),
|
||||
hasJsonPath("$._links.items.href", is(REST_SERVER_URL + "discover/browses/author/items"))
|
||||
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "api/discover/browses/author")),
|
||||
hasJsonPath("$._links.entries.href", is(REST_SERVER_URL + "api/discover/browses/author/entries")),
|
||||
hasJsonPath("$._links.items.href", is(REST_SERVER_URL + "api/discover/browses/author/items"))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ public class BrowseIndexMatcher {
|
||||
hasJsonPath("$.metadataBrowse", Matchers.is(false)),
|
||||
hasJsonPath("$.order", equalToIgnoringCase(order)),
|
||||
hasJsonPath("$.sortOptions[*].name", containsInAnyOrder("title", "dateissued", "dateaccessioned")),
|
||||
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "discover/browses/dateissued")),
|
||||
hasJsonPath("$._links.items.href", is(REST_SERVER_URL + "discover/browses/dateissued/items"))
|
||||
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "api/discover/browses/dateissued")),
|
||||
hasJsonPath("$._links.items.href", is(REST_SERVER_URL + "api/discover/browses/dateissued/items"))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 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.rest.matcher;
|
||||
|
||||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
|
||||
public class EntityTypeMatcher {
|
||||
public static Matcher<? super Object> matchEntityTypeEntry(EntityType entityType) {
|
||||
return matchEntityTypeExplicitValuesEntry(entityType.getId(), entityType.getLabel());
|
||||
}
|
||||
public static Matcher<? super Object> matchEntityTypeEntryForLabel(String label) {
|
||||
return matchEntityTypeExplicitValuesEntry(0, label);
|
||||
}
|
||||
|
||||
private static Matcher<? super Object> matchId(int id) {
|
||||
return id == 0 ?
|
||||
allOf(
|
||||
hasJsonPath("$.id", Matchers.not(Matchers.empty()))
|
||||
) :
|
||||
allOf(
|
||||
hasJsonPath("$.id", Matchers.is(id))
|
||||
);
|
||||
}
|
||||
|
||||
private static Matcher<? super Object> matchSelfLink(int id) {
|
||||
return id == 0 ?
|
||||
allOf(
|
||||
hasJsonPath("$._links.self.href", containsString("/api/core/entitytypes/"))
|
||||
) :
|
||||
allOf(
|
||||
hasJsonPath("$._links.self.href", containsString("/api/core/entitytypes/" + id))
|
||||
);
|
||||
}
|
||||
|
||||
public static Matcher<? super Object> matchEntityTypeExplicitValuesEntry(int id, String label) {
|
||||
return allOf(
|
||||
matchId(id),
|
||||
hasJsonPath("$.label", is(label)),
|
||||
hasJsonPath("$.type", is("entitytype")),
|
||||
matchSelfLink(id)
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package org.dspace.app.rest.matcher;
|
||||
|
||||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.Relationship;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.hamcrest.Matcher;
|
||||
|
||||
public class RelationshipMatcher {
|
||||
|
||||
public static Matcher<? super Object> matchRelationship(Relationship relationship) {
|
||||
return matchRelationshipExplicitValues(relationship.getLeftItem(), relationship.getRightItem(), relationship.getLeftPlace(), relationship.getRightPlace(), relationship.getRelationshipType());
|
||||
}
|
||||
|
||||
private static Matcher<? super Object> matchRelationshipExplicitValues(Item leftItem, Item rightItem, int leftPlace, int rightPlace, RelationshipType relationshipType) {
|
||||
return matchRelationshipExplicitObjectValues(leftItem.getID(), rightItem.getID(), leftPlace, rightPlace, relationshipType);
|
||||
}
|
||||
|
||||
private static Matcher<? super Object> matchRelationshipExplicitObjectValues(UUID leftId, UUID rightId, int leftPlace, int rightPlace,
|
||||
RelationshipType relationshipType) {
|
||||
return allOf(
|
||||
hasJsonPath("$.leftId",is(leftId.toString())),
|
||||
hasJsonPath("$.rightId", is(rightId.toString())),
|
||||
hasJsonPath("$.leftPlace", is(leftPlace)),
|
||||
hasJsonPath("$.rightPlace", is(rightPlace)),
|
||||
hasJsonPath("$._embedded.relationshipType", RelationshipTypeMatcher.matchRelationshipTypeEntry(relationshipType))
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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.rest.matcher;
|
||||
|
||||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
|
||||
public class RelationshipTypeMatcher {
|
||||
public static Matcher<? super Object> matchRelationshipTypeEntry(RelationshipType relationshipType) {
|
||||
return matchRelationshipTypeExplicitEntityTypes(relationshipType, relationshipType.getLeftType(), relationshipType.getRightType());
|
||||
}
|
||||
|
||||
private static Matcher<? super Object> matchRelationshipTypeExplicitEntityTypes(RelationshipType relationshipType, EntityType leftType, EntityType rightType) {
|
||||
return matchRelationshipTypeExplicitEntityTypeValues(relationshipType, leftType.getId(), leftType.getLabel(), rightType.getId(), rightType.getLabel());
|
||||
}
|
||||
|
||||
private static Matcher<? super Object> matchRelationshipTypeExplicitEntityTypeValues(RelationshipType relationshipType, int leftEntityTypeId, String leftEntityTypeLabel, int rightEntityTypeId,
|
||||
String rightEntityTypeLabel) {
|
||||
|
||||
return matchExplicitRelationshipTypeValuesAndExplicitEntityTypeValues(relationshipType.getId(), relationshipType.getLeftLabel(), relationshipType.getRightLabel(),
|
||||
relationshipType.getLeftMinCardinality(), relationshipType.getLeftMaxCardinality(),
|
||||
relationshipType.getRightMinCardinality(), relationshipType.getRightMaxCardinality(),
|
||||
leftEntityTypeId, leftEntityTypeLabel, rightEntityTypeId, rightEntityTypeLabel);
|
||||
}
|
||||
|
||||
private static Matcher<? super Object> matchExplicitRelationshipTypeValuesAndExplicitEntityType(int id, String leftLabel, String rightLabel,
|
||||
int leftMinCardinality, int leftMaxCardinality,
|
||||
int rightMinCardinality, int rightMaxCardinality,
|
||||
EntityType leftEntityType, EntityType rightEntityType) {
|
||||
return matchExplicitRelationshipTypeValuesAndExplicitEntityTypeValues(id, leftLabel, rightLabel, leftMinCardinality, leftMaxCardinality, rightMinCardinality,
|
||||
rightMaxCardinality, leftEntityType.getId(), leftEntityType.getLabel(),
|
||||
rightEntityType.getId(), rightEntityType.getLabel());
|
||||
}
|
||||
|
||||
private static Matcher<? super Object> matchExplicitRelationshipTypeValuesAndExplicitEntityTypeValues(int id, String leftLabel, String rightLabel,
|
||||
int leftMinCardinality, int leftMaxCardinality,
|
||||
int rightMinCardinality, int rightMaxCardinality,
|
||||
int leftEntityTypeId, String leftEntityTypeLabel,
|
||||
int rightEntityTypeId, String rightEntityTypeLabel) {
|
||||
return allOf(
|
||||
hasJsonPath("$.id", is(id)),
|
||||
hasJsonPath("$.leftLabel", is(leftLabel)),
|
||||
hasJsonPath("$.rightLabel", is(rightLabel)),
|
||||
hasJsonPath("$.leftMinCardinality", is(leftMinCardinality)),
|
||||
hasJsonPath("$.leftMaxCardinality", is(leftMaxCardinality)),
|
||||
hasJsonPath("$.rightMinCardinality", is(rightMinCardinality)),
|
||||
hasJsonPath("$.rightMaxCardinality", is(rightMaxCardinality)),
|
||||
hasJsonPath("$.type", is("relationshiptype")),
|
||||
hasJsonPath("$._links.self.href", containsString("/api/core/relationshiptypes/" + id)),
|
||||
hasJsonPath("$._embedded.leftType", Matchers.allOf(
|
||||
EntityTypeMatcher.matchEntityTypeExplicitValuesEntry(leftEntityTypeId, leftEntityTypeLabel)
|
||||
)),
|
||||
hasJsonPath("$._embedded.rightType", Matchers.is(
|
||||
EntityTypeMatcher.matchEntityTypeExplicitValuesEntry(rightEntityTypeId, rightEntityTypeLabel)
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
@@ -27,9 +27,9 @@ public class SubmissionDefinitionsMatcher {
|
||||
hasJsonPath("$.name", is(name)),
|
||||
hasJsonPath("$.id", is(id)),
|
||||
hasJsonPath("$.type", is("submissiondefinition")),
|
||||
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "config/submissiondefinitions/" + id)),
|
||||
hasJsonPath("$._links.self.href", is(REST_SERVER_URL + "api/config/submissiondefinitions/" + id)),
|
||||
hasJsonPath("$._links.sections.href",
|
||||
is(REST_SERVER_URL + "config/submissiondefinitions/" + id + "/sections"))
|
||||
is(REST_SERVER_URL + "api/config/submissiondefinitions/" + id + "/sections"))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
@@ -44,6 +45,8 @@ import org.springframework.test.context.transaction.TransactionalTestExecutionLi
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.RequestPostProcessor;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
import org.springframework.test.web.servlet.request.RequestPostProcessor;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
|
||||
import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
@@ -69,7 +72,11 @@ public class AbstractControllerIntegrationTest extends AbstractIntegrationTestWi
|
||||
//sits before the actual authentication token and can be used to easily compose or parse the Authorization header.
|
||||
protected static final String AUTHORIZATION_TYPE = "Bearer ";
|
||||
|
||||
public static final String REST_SERVER_URL = "http://localhost/api/";
|
||||
protected static final String REQUEST_SCHEME = "http";
|
||||
protected static final String REQUEST_NAME = "localhost";
|
||||
protected static final int REQUEST_PORT = 8080;
|
||||
protected static final String REQUEST_CONTEXTPATH = "rest";
|
||||
public static final String REST_SERVER_URL = REQUEST_SCHEME + "://" + REQUEST_NAME + ":" + REQUEST_PORT + "/" + REQUEST_CONTEXTPATH +"/";
|
||||
|
||||
protected MediaType contentType = new MediaType(MediaTypes.HAL_JSON.getType(),
|
||||
MediaTypes.HAL_JSON.getSubtype(), Charsets.UTF_8);
|
||||
@@ -109,10 +116,19 @@ public class AbstractControllerIntegrationTest extends AbstractIntegrationTestWi
|
||||
.addFilters(new ErrorPageFilter())
|
||||
.addFilters(requestFilters.toArray(new Filter[requestFilters.size()]));
|
||||
|
||||
MockHttpServletRequestBuilder defaultRequestParameters = get("")
|
||||
.with(request -> {
|
||||
request.setScheme(REQUEST_SCHEME);
|
||||
request.setServerName(REQUEST_NAME);
|
||||
request.setServerPort(REQUEST_PORT);
|
||||
request.setContextPath(REQUEST_CONTEXTPATH);
|
||||
return request;
|
||||
});
|
||||
if (StringUtils.isNotBlank(authToken)) {
|
||||
mockMvcBuilder.defaultRequest(
|
||||
get("").header(AUTHORIZATION_HEADER, AUTHORIZATION_TYPE + authToken));
|
||||
}
|
||||
mockMvcBuilder.defaultRequest(defaultRequestParameters);
|
||||
|
||||
return mockMvcBuilder
|
||||
.build();
|
||||
|
@@ -32,8 +32,13 @@ dspace.baseUrl = http://localhost:8080
|
||||
# the context path to the UI you are using.
|
||||
#
|
||||
# Alternatively, you can use a url redirect or deploy the web application under the servlet container root.
|
||||
# This is the URL that the front-end will be served on
|
||||
dspace.url = ${dspace.baseUrl}
|
||||
|
||||
# This is the URL that will be used for the REST endpoints to be served on.
|
||||
# This will typically be followed by /api to determine the root endpoints.
|
||||
dspace.restUrl = ${dspace.baseUrl}/rest
|
||||
|
||||
# Optional: DSpace URL for mobile access
|
||||
# This
|
||||
#dspace.mobileUrl = http://mobile.example.com
|
||||
@@ -882,8 +887,8 @@ webui.item.thumbnail.show = true
|
||||
#webui.browse.thumbnail.linkbehaviour = item
|
||||
|
||||
# maximum width and height of generated thumbnails
|
||||
thumbnail.maxwidth = 80
|
||||
thumbnail.maxheight = 80
|
||||
thumbnail.maxwidth = 300
|
||||
thumbnail.maxheight = 300
|
||||
|
||||
# Blur before scaling. A little blur before scaling does wonders for keeping
|
||||
# moire in check.
|
||||
|
@@ -44,6 +44,10 @@
|
||||
<mapping class="org.dspace.content.Collection"/>
|
||||
<mapping class="org.dspace.content.Community"/>
|
||||
<mapping class="org.dspace.content.Item"/>
|
||||
<mapping class="org.dspace.content.Relationship"/>
|
||||
<mapping class="org.dspace.content.RelationshipType"/>
|
||||
<mapping class="org.dspace.content.EntityType"/>
|
||||
|
||||
<mapping class="org.dspace.content.MetadataField"/>
|
||||
<mapping class="org.dspace.content.MetadataSchema"/>
|
||||
<mapping class="org.dspace.content.MetadataValue"/>
|
||||
|
@@ -18,6 +18,12 @@
|
||||
<!-- for handle "default". -->
|
||||
<submission-map>
|
||||
<name-map collection-handle="default" submission-name="traditional" />
|
||||
<name-map collection-handle="123456789/6" submission-name="People"/>
|
||||
<name-map collection-handle="123456789/7" submission-name="Project"/>
|
||||
<name-map collection-handle="123456789/8" submission-name="OrgUnit"/>
|
||||
<name-map collection-handle="123456789/28" submission-name="Journals"/>
|
||||
<name-map collection-handle="123456789/29" submission-name="JournalVolumes"/>
|
||||
<name-map collection-handle="123456789/30" submission-name="JournalIssues"/>
|
||||
</submission-map>
|
||||
|
||||
|
||||
@@ -57,6 +63,37 @@
|
||||
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
|
||||
<type>submission-form</type>
|
||||
</step>
|
||||
|
||||
<step id="peopleStep" mandatory="true">
|
||||
<heading>submit.progressbar.describe.stepone</heading>
|
||||
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
|
||||
<type>submission-form</type>
|
||||
</step>
|
||||
<step id="projectStep" mandatory="true">
|
||||
<heading>submit.progressbar.describe.stepone</heading>
|
||||
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
|
||||
<type>submission-form</type>
|
||||
</step>
|
||||
<step id="orgUnitStep" mandatory="true">
|
||||
<heading>submit.progressbar.describe.stepone</heading>
|
||||
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
|
||||
<type>submission-form</type>
|
||||
</step>
|
||||
<step id="journalStep" mandatory="true">
|
||||
<heading>submit.progressbar.describe.stepone</heading>
|
||||
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
|
||||
<type>submission-form</type>
|
||||
</step>
|
||||
<step id="journalVolumesStep" mandatory="true">
|
||||
<heading>submit.progressbar.describe.stepone</heading>
|
||||
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
|
||||
<type>submission-form</type>
|
||||
</step>
|
||||
<step id="journalIssuesStep" mandatory="true">
|
||||
<heading>submit.progressbar.describe.stepone</heading>
|
||||
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
|
||||
<type>submission-form</type>
|
||||
</step>
|
||||
<step id="traditionalpagetwo" mandatory="true">
|
||||
<heading>submit.progressbar.describe.steptwo</heading>
|
||||
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
|
||||
@@ -150,6 +187,26 @@
|
||||
<!-- <step id="verify"/> -->
|
||||
</submission-process>
|
||||
|
||||
<submission-process name="People">
|
||||
<step id="peopleStep"/>
|
||||
</submission-process>
|
||||
|
||||
<submission-process name="Project">
|
||||
<step id="projectStep"/>
|
||||
</submission-process>
|
||||
|
||||
<submission-process name="OrgUnit">
|
||||
<step id="orgUnitStep"/>
|
||||
</submission-process>
|
||||
<submission-process name="Journals">
|
||||
<step id="journalStep"/>
|
||||
</submission-process>
|
||||
<submission-process name="JournalVolumes">
|
||||
<step id="journalVolumesStep"/>
|
||||
</submission-process>
|
||||
<submission-process name="JournalIssues">
|
||||
<step id="journalIssuesStep"/>
|
||||
</submission-process>
|
||||
</submission-definitions>
|
||||
|
||||
</item-submission>
|
||||
|
@@ -366,4 +366,19 @@
|
||||
<class>org.dspace.app.util.Version</class>
|
||||
</step>
|
||||
</command>
|
||||
<command>
|
||||
<name>initialize-entities</name>
|
||||
<description>Initialize the entities with a provided xml</description>
|
||||
<step>
|
||||
<class>org.dspace.app.util.InitializeEntities</class>
|
||||
</step>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<name>additional-relationship-demo</name>
|
||||
<description>Creates additional relationships for the demo</description>
|
||||
<step>
|
||||
<class>org.dspace.app.util.AdditionalRelationshipScript</class>
|
||||
</step>
|
||||
</command>
|
||||
</commands>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
# bulkedit.valueseparator = ||
|
||||
|
||||
# The delimiter used to separate fields (defaults to a comma for CSV)
|
||||
# bulkedit.fieldseparator = ,
|
||||
bulkedit.fieldseparator = ;
|
||||
|
||||
# The delimiter used to serarate authority data (defaults to a double colon ::)
|
||||
# bulkedit.authorityseparator = ::
|
||||
|
55
dspace/config/registries/journal-types.xml
Normal file
55
dspace/config/registries/journal-types.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<dspace-dc-types>
|
||||
|
||||
<dspace-header>
|
||||
<title>DSpace journal Types</title>
|
||||
</dspace-header>
|
||||
|
||||
<dc-schema>
|
||||
<name>journal</name>
|
||||
<namespace>http://dspace.org/journal</namespace>
|
||||
</dc-schema>
|
||||
|
||||
|
||||
<dc-type>
|
||||
<schema>journal</schema>
|
||||
<element>contributor</element>
|
||||
<qualifier>editor</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
|
||||
<dc-type>
|
||||
<schema>journal</schema>
|
||||
<element>publisher</element>
|
||||
<qualifier></qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>journal</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>issn</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
<dc-type>
|
||||
<schema>journal</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>name</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>journal</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>description</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>journal</schema>
|
||||
<element>title</element>
|
||||
<qualifier></qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
</dspace-dc-types>
|
46
dspace/config/registries/journalissue-types.xml
Normal file
46
dspace/config/registries/journalissue-types.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<dspace-dc-types>
|
||||
|
||||
<dspace-header>
|
||||
<title>DSpace journalissue Types</title>
|
||||
</dspace-header>
|
||||
|
||||
<dc-schema>
|
||||
<name>journalissue</name>
|
||||
<namespace>http://dspace.org/journalissue</namespace>
|
||||
</dc-schema>
|
||||
|
||||
<dc-type>
|
||||
<schema>journalissue</schema>
|
||||
<element>issuedate</element>
|
||||
<qualifier></qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
|
||||
<dc-type>
|
||||
<schema>journalissue</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>number</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>journalissue</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>name</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>journalissue</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>description</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
<dc-type>
|
||||
<schema>journalissue</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>keyword</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
</dspace-dc-types>
|
41
dspace/config/registries/journalvolume-types.xml
Normal file
41
dspace/config/registries/journalvolume-types.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<dspace-dc-types>
|
||||
|
||||
<dspace-header>
|
||||
<title>DSpace journalvolume Types</title>
|
||||
</dspace-header>
|
||||
|
||||
<dc-schema>
|
||||
<name>journalvolume</name>
|
||||
<namespace>http://dspace.org/journalvolume</namespace>
|
||||
</dc-schema>
|
||||
|
||||
<dc-type>
|
||||
<schema>journalvolume</schema>
|
||||
<element>issuedate</element>
|
||||
<qualifier></qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
|
||||
<dc-type>
|
||||
<schema>journalvolume</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>volume</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>journalvolume</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>name</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>journalvolume</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>description</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
</dspace-dc-types>
|
55
dspace/config/registries/orgunit-types.xml
Normal file
55
dspace/config/registries/orgunit-types.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<dspace-dc-types>
|
||||
|
||||
<dspace-header>
|
||||
<title>DSpace OrgUnit Types</title>
|
||||
</dspace-header>
|
||||
|
||||
<dc-schema>
|
||||
<name>orgunit</name>
|
||||
<namespace>http://dspace.org/orgunit</namespace>
|
||||
</dc-schema>
|
||||
|
||||
|
||||
<dc-type>
|
||||
<schema>orgunit</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>name</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>orgunit</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>id</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>orgunit</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>dateestablished</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>orgunit</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>city</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>orgunit</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>country</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>orgunit</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>description</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
</dspace-dc-types>
|
61
dspace/config/registries/person-types.xml
Normal file
61
dspace/config/registries/person-types.xml
Normal file
@@ -0,0 +1,61 @@
|
||||
<dspace-dc-types>
|
||||
|
||||
<dspace-header>
|
||||
<title>DSpace Person Types</title>
|
||||
</dspace-header>
|
||||
|
||||
<dc-schema>
|
||||
<name>person</name>
|
||||
<namespace>http://dspace.org/person</namespace>
|
||||
</dc-schema>
|
||||
|
||||
|
||||
<dc-type>
|
||||
<schema>person</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>lastname</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>person</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>firstname</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>person</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>email</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>person</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>orcid</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>person</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>birthdate</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>person</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>staffid</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>person</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>jobtitle</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
</dspace-dc-types>
|
61
dspace/config/registries/project-types.xml
Normal file
61
dspace/config/registries/project-types.xml
Normal file
@@ -0,0 +1,61 @@
|
||||
<dspace-dc-types>
|
||||
|
||||
<dspace-header>
|
||||
<title>DSpace Project Types</title>
|
||||
</dspace-header>
|
||||
|
||||
<dc-schema>
|
||||
<name>project</name>
|
||||
<namespace>http://dspace.org/project</namespace>
|
||||
</dc-schema>
|
||||
|
||||
|
||||
<dc-type>
|
||||
<schema>project</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>name</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>project</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>id</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>project</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>status</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>project</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>startdate</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>project</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>expectedcompletion</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>project</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>keyword</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
|
||||
<dc-type>
|
||||
<schema>project</schema>
|
||||
<element>identifier</element>
|
||||
<qualifier>description</qualifier>
|
||||
<scope_note></scope_note>
|
||||
</dc-type>
|
||||
</dspace-dc-types>
|
19
dspace/config/registries/relationship-formats.xml
Normal file
19
dspace/config/registries/relationship-formats.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<dspace-dc-types>
|
||||
|
||||
<dspace-header>
|
||||
<title>DSpace Relationship</title>
|
||||
</dspace-header>
|
||||
|
||||
<dc-schema>
|
||||
<name>relationship</name>
|
||||
<namespace>http://dspace.org/relationship</namespace>
|
||||
</dc-schema>
|
||||
|
||||
|
||||
<dc-type>
|
||||
<schema>relationship</schema>
|
||||
<element>type</element>
|
||||
<scope_note>Metadata field used for the type of entity, stored in the item</scope_note>
|
||||
</dc-type>
|
||||
|
||||
</dspace-dc-types>
|
@@ -28,6 +28,9 @@
|
||||
<bean class="org.dspace.content.dao.impl.MetadataValueDAOImpl"/>
|
||||
<bean class="org.dspace.content.dao.impl.SiteDAOImpl"/>
|
||||
<bean class="org.dspace.content.dao.impl.WorkspaceItemDAOImpl"/>
|
||||
<bean class="org.dspace.content.dao.impl.RelationshipDAOImpl"/>
|
||||
<bean class="org.dspace.content.dao.impl.EntityTypeDAOImpl"/>
|
||||
<bean class="org.dspace.content.dao.impl.RelationshipTypeDAOImpl"/>
|
||||
|
||||
<bean class="org.dspace.eperson.dao.impl.EPersonDAOImpl"/>
|
||||
<bean class="org.dspace.eperson.dao.impl.Group2GroupCacheDAOImpl"/>
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" default-lazy-init="true">
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
|
||||
default-lazy-init="true">
|
||||
|
||||
|
||||
<!-- ******************** -->
|
||||
@@ -49,6 +50,10 @@
|
||||
<bean class="org.dspace.content.SiteServiceImpl"/>
|
||||
<bean class="org.dspace.content.SupervisedItemServiceImpl"/>
|
||||
<bean class="org.dspace.content.WorkspaceItemServiceImpl"/>
|
||||
<bean class="org.dspace.content.RelationshipServiceImpl"/>
|
||||
<bean class="org.dspace.content.EntityTypeServiceImpl"/>
|
||||
<bean class="org.dspace.content.EntityServiceImpl"/>
|
||||
<bean class="org.dspace.content.RelationshipTypeServiceImpl"/>
|
||||
|
||||
<bean class="org.dspace.content.authority.ChoiceAuthorityServiceImpl"/>
|
||||
<bean class="org.dspace.content.authority.MetadataAuthorityServiceImpl" lazy-init="true"/>
|
||||
@@ -111,5 +116,96 @@
|
||||
<bean class="org.dspace.xmlworkflow.XmlWorkflowServiceImpl"/>
|
||||
<bean class="org.dspace.xmlworkflow.WorkflowRequirementsServiceImpl"/>
|
||||
<bean class="org.dspace.xmlworkflow.XmlWorkflowFactoryImpl"/>-->
|
||||
<bean class="org.dspace.content.virtual.VirtualMetadataPopulator">
|
||||
<property name="map">
|
||||
<map>
|
||||
<entry key="isAuthorOfPublication" value-ref="isAuthorOfPublicationMap"/>
|
||||
<entry key="isOrgUnitOfPublication" value-ref="isOrgUnitOfPublicationMap"/>
|
||||
<entry key="isPersonOfProject" value-ref="isPersonOfProjectMap"/>
|
||||
<entry key="isOrgUnitOfProject" value-ref="isOrgUnitOfProjectMap"/>
|
||||
<entry key="isOrgUnitOfPerson" value-ref="isOrgUnitOfPersonMap"/>
|
||||
<entry key="isJournalVolumeOfIssue" value-ref="isJournalVolumeOfIssueMap"/>
|
||||
<entry key="isJournalOfVolume" value-ref="isJournalOfVolumeMap"/>
|
||||
<entry key="isVolumeOfJournal" value-ref="isVolumeOfJournalMap"/>
|
||||
<entry key="isIssueOfJournalVolume" value-ref="isIssueOfJournalVolumeMap"/>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean class="org.dspace.content.virtual.EntityTypeToFilterQueryService">
|
||||
<property name="map">
|
||||
<map>
|
||||
<entry key="Publication" value="f.entityType=Publication,equals"/>
|
||||
<entry key="Person" value="f.entityType=Person,equals"/>
|
||||
<entry key="Journal" value="f.entityType=Journal,equals"/>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<util:map id="isAuthorOfPublicationMap">
|
||||
<entry key="dc_contributor_author" value-ref="publicationAuthor_author"/>
|
||||
</util:map>
|
||||
<util:list id="publicationAuthor_author">
|
||||
<value>orgunit.identifier.name</value>
|
||||
<value>person.identifier.lastname</value>
|
||||
<value>person.identifier.firstname</value>
|
||||
</util:list>
|
||||
|
||||
<util:map id="isOrgUnitOfPublicationMap">
|
||||
<entry key="dc_contributor_other" value-ref="publicationOrgUnit_name"/>
|
||||
</util:map>
|
||||
<util:list id="publicationOrgUnit_name">
|
||||
<value>orgunit.identifier.name</value>
|
||||
</util:list>
|
||||
|
||||
<util:map id="isPersonOfProjectMap">
|
||||
<entry key="project_contributor_author" value-ref="projectPerson_author"/>
|
||||
</util:map>
|
||||
<util:list id="projectPerson_author">
|
||||
<value>person.identifier.lastname</value>
|
||||
<value>person.identifier.firstname</value>
|
||||
</util:list>
|
||||
|
||||
<util:map id="isOrgUnitOfProjectMap">
|
||||
<entry key="project_contributor_other" value-ref="projectOrgUnit_other"/>
|
||||
</util:map>
|
||||
<util:list id="projectOrgUnit_other">
|
||||
<value>orgunit.identifier.name</value>
|
||||
</util:list>
|
||||
|
||||
<util:map id="isOrgUnitOfPersonMap">
|
||||
<entry key="person_contributor_other" value-ref="personProject_other"/>
|
||||
</util:map>
|
||||
<util:list id="personProject_other">
|
||||
<value>orgunit.identifier.name</value>
|
||||
</util:list>
|
||||
|
||||
<util:map id="isJournalVolumeOfIssueMap">
|
||||
<entry key="journalvolume_identifier_volume" value-ref="issueVolume_volume"/>
|
||||
</util:map>
|
||||
<util:list id="issueVolume_volume">
|
||||
<value>journalvolume.identifier.volume</value>
|
||||
</util:list>
|
||||
|
||||
<util:map id="isJournalOfVolumeMap">
|
||||
<entry key="journal_identifier_issn" value-ref="volumeJournal_issn"/>
|
||||
<entry key="journal_title" value-ref="volumeJournal_title"/>
|
||||
</util:map>
|
||||
<util:list id="volumeJournal_issn">
|
||||
<value>journal.identifier.issn</value>
|
||||
</util:list>
|
||||
<util:list id="volumeJournal_title">
|
||||
<value>journal.identifier.name</value>
|
||||
</util:list>
|
||||
|
||||
<util:map id="isVolumeOfJournalMap">
|
||||
</util:map>
|
||||
|
||||
<util:map id="isIssueOfJournalVolumeMap">
|
||||
<entry key="journalissue_identifier_number" value-ref="journalIssue_number"/>
|
||||
</util:map>
|
||||
<util:list id="journalIssue_number">
|
||||
<value>journalissue.identifier.number</value>
|
||||
</util:list>
|
||||
</beans>
|
||||
|
||||
|
@@ -103,6 +103,7 @@
|
||||
<ref bean="searchFilterSubject" />
|
||||
<ref bean="searchFilterIssued" />
|
||||
<ref bean="searchFilterContentInOriginalBundle"/>
|
||||
<ref bean="searchFilterEntityType"/>
|
||||
</list>
|
||||
</property>
|
||||
<!-- Set TagCloud configuration per discovery configuration -->
|
||||
@@ -117,6 +118,7 @@
|
||||
<ref bean="searchFilterContentInOriginalBundle"/>
|
||||
<ref bean="searchFilterFileNameInOriginalBundle" />
|
||||
<ref bean="searchFilterFileDescriptionInOriginalBundle" />
|
||||
<ref bean="searchFilterEntityType"/>
|
||||
</list>
|
||||
</property>
|
||||
<!--The sort filters for the discovery search-->
|
||||
@@ -157,25 +159,36 @@
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightingConfiguration">
|
||||
<property name="metadataFields">
|
||||
<list>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="dc.title"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="dc.contributor.author"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="dc.description.abstract"/>
|
||||
<property name="maxSize" value="250"/>
|
||||
<property name="snippets" value="2"/>
|
||||
<property name="field" value="relationship.type"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="person.identifier.jobtitle"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="project.identifier.name"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<!-- By default, full text snippets are disabled, as snippets of embargoed/restricted bitstreams
|
||||
may appear in search results when the Item is public. See DS-3498
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="fulltext"/>
|
||||
<property name="field" value="project.identifier.status"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="orgunit.identifier.name"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="orgunit.identifier.description"/>
|
||||
<property name="maxSize" value="250"/>
|
||||
<property name="snippets" value="2"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
-->
|
||||
</list>
|
||||
@@ -216,6 +229,7 @@
|
||||
<ref bean="searchFilterSubject" />
|
||||
<ref bean="searchFilterIssued" />
|
||||
<ref bean="searchFilterContentInOriginalBundle"/>
|
||||
<ref bean="searchFilterEntityType"/>
|
||||
</list>
|
||||
</property>
|
||||
<!-- Set TagCloud configuration per discovery configuration -->
|
||||
@@ -230,6 +244,7 @@
|
||||
<ref bean="searchFilterContentInOriginalBundle"/>
|
||||
<ref bean="searchFilterFileNameInOriginalBundle" />
|
||||
<ref bean="searchFilterFileDescriptionInOriginalBundle" />
|
||||
<ref bean="searchFilterEntityType"/>
|
||||
</list>
|
||||
</property>
|
||||
<!--The sort filters for the discovery search (same as defaultConfiguration above)-->
|
||||
@@ -260,25 +275,36 @@
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightingConfiguration">
|
||||
<property name="metadataFields">
|
||||
<list>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="dc.title"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="dc.contributor.author"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="dc.description.abstract"/>
|
||||
<property name="maxSize" value="250"/>
|
||||
<property name="snippets" value="2"/>
|
||||
<property name="field" value="relationship.type"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="person.identifier.jobtitle"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="project.identifier.name"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<!-- By default, full text snippets are disabled, as snippets of embargoed/restricted bitstreams
|
||||
may appear in search results when the Item is public. See DS-3498
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="fulltext"/>
|
||||
<property name="field" value="project.identifier.status"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="orgunit.identifier.name"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||
<property name="field" value="orgunit.identifier.description"/>
|
||||
<property name="maxSize" value="250"/>
|
||||
<property name="snippets" value="2"/>
|
||||
<property name="snippets" value="5"/>
|
||||
</bean>
|
||||
-->
|
||||
</list>
|
||||
@@ -409,6 +435,18 @@
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="searchFilterEntityType" class="org.dspace.discovery.configuration.DiscoverySearchFilterFacet">
|
||||
<property name="indexFieldName" value="entityType"/>
|
||||
<property name="metadataFields">
|
||||
<list>
|
||||
<value>relationship.type</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="facetLimit" value="5"/>
|
||||
<property name="sortOrderSidebar" value="COUNT"/>
|
||||
<property name="sortOrderFilterPage" value="COUNT"/>
|
||||
</bean>
|
||||
|
||||
<bean id="searchFilterSubject" class="org.dspace.discovery.configuration.HierarchicalSidebarFacetConfiguration">
|
||||
<property name="indexFieldName" value="subject"/>
|
||||
<property name="metadataFields">
|
||||
|
@@ -229,6 +229,321 @@ it, please enter the types and the actual numbers or codes.</hint>
|
||||
</row>
|
||||
</form>
|
||||
|
||||
<form name="peopleStep">
|
||||
|
||||
<field>
|
||||
<dc-schema>person</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>lastname</dc-qualifier>
|
||||
<label>Last name</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the last name of the person</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>person</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>firstname</dc-qualifier>
|
||||
<label>First name</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the first name of the person</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>person</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>email</dc-qualifier>
|
||||
<label>Email</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the email of the person</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>person</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>orcid</dc-qualifier>
|
||||
<label>Orcid</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the orcid of the person</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>person</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>birthdate</dc-qualifier>
|
||||
<label>Birth date</label>
|
||||
<input-type>date</input-type>
|
||||
<hint>Enter the birth date of the person</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>person</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>staffid</dc-qualifier>
|
||||
<label>Staff ID</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the staff id of the person</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>person</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>jobtitle</dc-qualifier>
|
||||
<label>Job title</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the job title of the person</hint>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
<form name="projectStep">
|
||||
<field>
|
||||
<dc-schema>project</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>name</dc-qualifier>
|
||||
<label>Name</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the name of the project</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>project</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>id</dc-qualifier>
|
||||
<label>ID</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the id of the project</hint>
|
||||
</field>
|
||||
<field>
|
||||
<dc-schema>project</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>status</dc-qualifier>
|
||||
<label>Status</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the status of the project</hint>
|
||||
</field>
|
||||
<field>
|
||||
<dc-schema>project</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>startdate</dc-qualifier>
|
||||
<label>Start date</label>
|
||||
<input-type>date</input-type>
|
||||
<hint>Enter the start date of the project</hint>
|
||||
</field>
|
||||
<field>
|
||||
<dc-schema>project</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>expectedcompletion</dc-qualifier>
|
||||
<label>Expected Completion</label>
|
||||
<input-type>date</input-type>
|
||||
<hint>Enter the expected completion date of the project</hint>
|
||||
</field>
|
||||
<field>
|
||||
<dc-schema>project</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>keyword</dc-qualifier>
|
||||
<label>Keywords</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the keywords of the project</hint>
|
||||
</field>
|
||||
<field>
|
||||
<dc-schema>project</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>description</dc-qualifier>
|
||||
<label>Description</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the description of the project</hint>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
<form name="orgUnitStep">
|
||||
<field>
|
||||
<dc-schema>orgunit</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>name</dc-qualifier>
|
||||
<label>Name</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the name of the orgunit</hint>
|
||||
</field>
|
||||
<field>
|
||||
<dc-schema>orgunit</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>id</dc-qualifier>
|
||||
<label>ID</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the id of the orgunit</hint>
|
||||
</field>
|
||||
<field>
|
||||
<dc-schema>orgunit</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>dateestablished</dc-qualifier>
|
||||
<label>Date established</label>
|
||||
<input-type>date</input-type>
|
||||
<hint>Enter the established date of the orgunit</hint>
|
||||
</field>
|
||||
<field>
|
||||
<dc-schema>orgunit</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>city</dc-qualifier>
|
||||
<label>City</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the city of the orgunit</hint>
|
||||
</field>
|
||||
<field>
|
||||
<dc-schema>orgunit</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>country</dc-qualifier>
|
||||
<label>Country</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the country of the orgunit</hint>
|
||||
</field>
|
||||
<field>
|
||||
<dc-schema>orgunit</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>description</dc-qualifier>
|
||||
<label>Description</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the description of the orgunit</hint>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
<form name="journalStep">
|
||||
|
||||
<field>
|
||||
<dc-schema>journal</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>name</dc-qualifier>
|
||||
<label>Name</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the name of the journal</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journal</dc-schema>
|
||||
<dc-element>contributor</dc-element>
|
||||
<dc-qualifier>editor</dc-qualifier>
|
||||
<label>Editor</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the editor of the journal</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journal</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>issn</dc-qualifier>
|
||||
<label>Name</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the issn of the journal</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journal</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>description</dc-qualifier>
|
||||
<label>Description</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the description of the journal</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journal</dc-schema>
|
||||
<dc-element>publisher</dc-element>
|
||||
<label>Publisher</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the publisher of the journal</hint>
|
||||
</field>
|
||||
|
||||
</form>
|
||||
|
||||
<form name="journalVolumeStep">
|
||||
|
||||
<field>
|
||||
<dc-schema>journalvolume</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>name</dc-qualifier>
|
||||
<label>Name</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the name of the journal volume</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journalvolume</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>volume</dc-qualifier>
|
||||
<label>Volume</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the volume of the journal volume</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journalvolume</dc-schema>
|
||||
<dc-element>issuedate</dc-element>
|
||||
<label>Issue date</label>
|
||||
<input-type>date</input-type>
|
||||
<hint>Enter the issue date of the journal volume</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journalvolume</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>description</dc-qualifier>
|
||||
<label>Description</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the description of the journal volume</hint>
|
||||
</field>
|
||||
|
||||
</form>
|
||||
|
||||
<form name="journalIssueStep">
|
||||
|
||||
<field>
|
||||
<dc-schema>journalissue</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>name</dc-qualifier>
|
||||
<label>Name</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the name of the journal issue</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journalissue</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>number</dc-qualifier>
|
||||
<label>Number</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the number of the journal issue</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journalissue</dc-schema>
|
||||
<dc-element>issuedate</dc-element>
|
||||
<label>Issue date</label>
|
||||
<input-type>date</input-type>
|
||||
<hint>Enter the issue date of the journal issue</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journalissue</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>description</dc-qualifier>
|
||||
<label>Description</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the description of the journal issue</hint>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<dc-schema>journalissue</dc-schema>
|
||||
<dc-element>identifier</dc-element>
|
||||
<dc-qualifier>keyword</dc-qualifier>
|
||||
<label>Keywords</label>
|
||||
<input-type>textarea</input-type>
|
||||
<hint>Enter the keywords of the journal issue</hint>
|
||||
</field>
|
||||
|
||||
</form>
|
||||
|
||||
</form-definitions>
|
||||
|
||||
|
||||
|
@@ -559,6 +559,9 @@
|
||||
<!--<copyField source="dc.creator" dest="dc.contributor.author_sort"/>-->
|
||||
|
||||
|
||||
<!-- Dynamic field used to store the relation metadata as a keywordFilter -->
|
||||
<dynamicField name="relation.*" type="keywordFilter" indexed="true" stored="true" omitNorms="true" multiValued="true"/>
|
||||
|
||||
<!--Dynamic field used to store metadata for projection-->
|
||||
<dynamicField name="*_stored" type="dspaceMetadataProjection" indexed="false" stored="true" multiValued="true"/>
|
||||
|
||||
|
Reference in New Issue
Block a user