Applied community feedback

This commit is contained in:
Raf Ponsaerts
2018-11-08 14:28:58 +01:00
parent d8ced6aa7d
commit b37d0e2167
19 changed files with 187 additions and 472 deletions

View File

@@ -59,6 +59,7 @@ import org.dspace.eperson.EPerson;
import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.dspace.util.UUIDUtils;
import org.dspace.workflow.WorkflowItem;
import org.dspace.workflow.WorkflowService;
import org.dspace.workflow.factory.WorkflowServiceFactory;
@@ -427,6 +428,14 @@ public class MetadataImport {
return changes;
}
/**
* This metod handles the BulkEditMetadataValue objects that correspond to Relationship metadatavalues
* @param item The item to which this metadatavalue will belong
* @param dcv The BulkEditMetadataValue to be processed
* @throws SQLException If something goes wrong
* @throws AuthorizeException If something goes wrong
*/
private void handleRelationshipMetadataValueFromBulkEditMetadataValue(Item item, BulkEditMetadataValue dcv)
throws SQLException, AuthorizeException {
LinkedList<String> values = new LinkedList<>();
@@ -639,6 +648,21 @@ public class MetadataImport {
}
}
/**
* This method decides whether the metadatavalue is of type relation.type or if it corresponds to
* a relationship and handles it accordingly to their respective methods
* @param c The relevant DSpace context
* @param item The item to which this metadatavalue belongs to
* @param schema The schema for the metadatavalue
* @param element The element for the metadatavalue
* @param qualifier The qualifier for the metadatavalue
* @param language The language for the metadatavalue
* @param values The values for the metadatavalue
* @param authorities The authorities for the metadatavalue
* @param confidences The confidences for the metadatavalue
* @throws SQLException If something goes wrong
* @throws AuthorizeException If something goes wrong
*/
private void handleRelationMetadata(Context c, Item item, String schema, String element, String qualifier,
String language, List<String> values, List<String> authorities,
List<Integer> confidences) throws SQLException, AuthorizeException {
@@ -652,14 +676,23 @@ public class MetadataImport {
}
/**
* This method takes the item, element and values to determine what relationships should be built
* for these parameters and calls on the method to construct them
* @param c The relevant DSpace context
* @param item The item that the relationships will be made for
* @param element The string determining which relationshiptype is to be used
* @param values The value for the relationship
* @throws SQLException If something goes wrong
* @throws AuthorizeException If something goes wrong
*/
private void handleRelationOtherMetadata(Context c, Item item, String element, 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)) {
if (UUIDUtils.fromString(values.get(0)) == null && StringUtils.isNotBlank(url)) {
return;
}
@@ -697,6 +730,16 @@ public class MetadataImport {
buildRelationObject(c, item, values, left, acceptableRelationshipTypes);
}
/**
* This method creates the relationship for the item and stores it in the database
* @param c The relevant DSpace context
* @param item The item for which this relationship will be constructed
* @param values The value for the relationship
* @param left A boolean indicating whether the item is the leftItem or the rightItem
* @param acceptableRelationshipTypes The acceptable relationship types
* @throws SQLException If something goes wrong
* @throws AuthorizeException If something goes wrong
*/
private void buildRelationObject(Context c, Item item, List<String> values, boolean left,
List<RelationshipType> acceptableRelationshipTypes)
throws SQLException, AuthorizeException {
@@ -716,6 +759,23 @@ public class MetadataImport {
relationshipService.update(c, persistedRelationship);
}
/**
* This method will add RelationshipType objects to the acceptableRelationshipTypes list
* if applicable and valid RelationshipType objects are found. It will also return a boolean indicating
* whether we're dealing with a left Relationship or not
* @param c The relevant DSpace context
* @param entity The Entity for which the RelationshipType has to be checked
* @param relationEntity The other Entity of the Relationship
* @param left Boolean indicating whether the Relationship is left or not
* @param acceptableRelationshipTypes The list of RelationshipType objects that will be added to
* @param rightRelationshipTypesForEntity The list of RelationshipType objects that are possible
* for the right entity
* @param relationshipType The RelationshipType object that we want to check whether it's
* valid to be added or not
* @return A boolean indicating whether the relationship is left or right, will
* be false in this case
* @throws SQLException If something goes wrong
*/
private boolean handleRightLabelEqualityRelationshipTypeElement(Context c, Entity entity, Entity relationEntity,
boolean left,
List<RelationshipType> acceptableRelationshipTypes,
@@ -741,6 +801,23 @@ public class MetadataImport {
return left;
}
/**
* This method will add RelationshipType objects to the acceptableRelationshipTypes list
* if applicable and valid RelationshipType objects are found. It will also return a boolean indicating
* whether we're dealing with a left Relationship or not
* @param c The relevant DSpace context
* @param entity The Entity for which the RelationshipType has to be checked
* @param relationEntity The other Entity of the Relationship
* @param left Boolean indicating whether the Relationship is left or not
* @param acceptableRelationshipTypes The list of RelationshipType objects that will be added to
* @param leftRelationshipTypesForEntity The list of RelationshipType objects that are possible
* for the left entity
* @param relationshipType The RelationshipType object that we want to check whether it's
* valid to be added or not
* @return A boolean indicating whether the relationship is left or right, will
* be true in this case
* @throws SQLException If something goes wrong
*/
private boolean handleLeftLabelEqualityRelationshipTypeElement(Context c, Entity entity, Entity relationEntity,
boolean left,
List<RelationshipType> acceptableRelationshipTypes,
@@ -765,13 +842,30 @@ public class MetadataImport {
return left;
}
/**
* This method will add the relationship.type metadata to the item if an EntityType can be found for the value in
* the values list.
* @param c The relevant DSpace context
* @param item The item to which this metadatavalue will be added
* @param schema The schema for the metadatavalue to be added
* @param element The element for the metadatavalue to be added
* @param qualifier The qualifier for the metadatavalue to be added
* @param language The language for the metadatavalue to be added
* @param values The value on which we'll search for EntityType object and it's the value
* for the metadatavalue that will be created
* @param authorities The authority for the metadatavalue. This will be filled with the ID
* of the found EntityType for the value if it exists
* @param confidences The confidence for the metadatavalue
* @throws SQLException If something goes wrong
* @throws AuthorizeException If something goes wrong
*/
private void handleRelationTypeMetadata(Context c, Item item, String schema, String element, String qualifier,
String language, List<String> values, List<String> authorities,
List<Integer> confidences)
throws SQLException, AuthorizeException {
EntityType entityType = entityTypeService.findByEntityType(c, values.get(0));
if (entityType != null) {
authorities.add(String.valueOf(entityType.getId()));
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);

View File

@@ -1,388 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.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;
/**
* This script is used to populate the database with specific objects (see UUIDs) with a set of
* relationships so that various functionalities can be tested properly.
*/
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();
}
/**
* The main method for this script
*
* @param argv The commandline arguments given with this command, though nothing will be done with them
* @throws SQLException If something goes wrong with the database
* @throws AuthorizeException If something goes wrong with permissions
* @throws ParseException If something goes wrong with the parsing
*/
public static void main(String[] argv) throws SQLException, AuthorizeException, ParseException {
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);
}
}

View File

@@ -234,18 +234,15 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
List<String> authorities, List<Integer> confidences) throws SQLException {
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++) {
if (authorities != null && authorities.size() >= i) {
if (StringUtils.equals(authorities.get(i), "virtual")) {
continue;
}
}
MetadataValue metadataValue = metadataValueService.create(context, dso, metadataField);
metadataValue.setLanguage(lang == null ? null : lang.trim());

View File

@@ -15,6 +15,8 @@ import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.dspace.core.ReloadableEntity;
/**
* Class representing an EntityType
* This class contains an Integer ID that will be the unique value for this class and also the primary key
@@ -22,7 +24,7 @@ import javax.persistence.Table;
*/
@Entity
@Table(name = "entity_type")
public class EntityType {
public class EntityType implements ReloadableEntity<Integer> {
/**
* The Integer ID used as a primary key for this database object.
@@ -41,14 +43,6 @@ public class EntityType {
@Column(name = "label", nullable = false)
private String label;
/**
* The standard getter for the ID of this EntityType
* @return The ID for this EntityType
*/
public Integer getId() {
return id;
}
/**
* The standard setter for the ID of this EntityType
* @param id The ID that this EntityType's ID will be set to
@@ -73,4 +67,11 @@ public class EntityType {
this.label = label;
}
/**
* The standard getter for the ID of this EntityType
* @return The ID for this EntityType
*/
public Integer getID() {
return id;
}
}

View File

@@ -127,7 +127,7 @@ public class RelationshipServiceImpl implements RelationshipService {
}
private void logRelationshipTypeDetails(RelationshipType relationshipType) {
log.warn("The relationshipType's ID is: " + relationshipType.getId());
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());

View File

@@ -19,6 +19,8 @@ import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.dspace.core.ReloadableEntity;
/**
* Class representing a RelationshipType
* This class contains an Integer ID that will be the unique value and primary key in the database.
@@ -29,7 +31,7 @@ import javax.persistence.Table;
*/
@Entity
@Table(name = "relationship_type")
public class RelationshipType {
public class RelationshipType implements ReloadableEntity<Integer> {
/**
* The Integer ID used as a primary key for this database object.
@@ -99,14 +101,6 @@ public class RelationshipType {
@Column(name = "right_max_cardinality")
private int rightMaxCardinality;
/**
* Standard getter for the ID of this RelationshipType
* @return The ID of this RelationshipType
*/
public Integer getId() {
return id;
}
/**
* Standard getter for the ID of this RelationshipType
* @param id The ID that this RelationshipType should receive
@@ -242,4 +236,12 @@ public class RelationshipType {
public void setRightMaxCardinality(int rightMaxCardinality) {
this.rightMaxCardinality = rightMaxCardinality;
}
/**
* Standard getter for the ID of this RelationshipType
* @return The ID of this RelationshipType
*/
public Integer getID() {
return id;
}
}

View File

@@ -21,6 +21,15 @@ import org.dspace.core.GenericDAO;
*/
public interface EntityTypeDAO extends GenericDAO<EntityType> {
/**
* This method returns the EntityType object that has the given entityType String
* as label
* @param context The relevant DSpace context
* @param entityType The entityType String that will be matched on to find
* the correct EntityType
* @return The EntityType object that has the entityType String as label
* @throws SQLException If something goes wrong
*/
public EntityType findByEntityType(Context context, String entityType) throws SQLException;
}

View File

@@ -23,9 +23,37 @@ import org.dspace.core.GenericDAO;
*/
public interface RelationshipDAO extends GenericDAO<Relationship> {
/**
* This method returns a list of Relationship objects that have the given Item object
* as a leftItem or a rightItem
* @param context The relevant DSpace context
* @param item The item that should be either a leftItem or a rightItem of all
* the Relationship objects in the returned list
* @return The list of Relationship objects that contain either a left or a
* right item that is equal to the given item
* @throws SQLException If something goes wrong
*/
List<Relationship> findByItem(Context context,Item item) throws SQLException;
/**
* This method returns the highest leftplace integer for all the relationships where this
* item is the leftitem so that we can set a proper leftplace attribute on the next relationship
* @param context The relevant DSpace context
* @param item The item to be matched on leftItem
* @return The integer for the highest leftPlace value for all the relatonship objects
* that have the given item as leftItem
* @throws SQLException If something goes wrong
*/
int findLeftPlaceByLeftItem(Context context,Item item) throws SQLException;
/**
* This method returns the highest rightplace integer for all the relationships where this
* item is the rightitem so that we can set a proper rightplace attribute on the next relationship
* @param context The relevant DSpace context
* @param item The item to be matched on rightItem
* @return The integer for the highest rightPlace value for all the relatonship objects
* that have the given item as rightItem
* @throws SQLException If something goes wrong
*/
int findRightPlaceByRightItem(Context context,Item item) throws SQLException;
}

View File

@@ -22,6 +22,17 @@ import org.dspace.core.GenericDAO;
*/
public interface RelationshipTypeDAO extends GenericDAO<RelationshipType> {
/**
* This method is used to retrieve the RelationshipType object that has the same
* leftType, rightType, leftLabel and rightLabel as given in the parameters
* @param context The relevant DSpace context
* @param leftType The leftType EntityType object to be matched in the query
* @param rightType The rightType EntityType object to be matched in the query
* @param leftLabel The leftLabel String to be matched in the query
* @param rightLabel The rightLabel String to be matched in the query
* @return The RelationshipType object that matches all the given parameters
* @throws SQLException If something goes wrong
*/
RelationshipType findbyTypesAndLabels(Context context,
EntityType leftType,EntityType rightType,String leftLabel,String rightLabel)
throws SQLException;

View File

@@ -22,7 +22,6 @@ import org.dspace.app.rest.model.SearchResultEntryRest;
import org.dspace.app.rest.model.SearchResultsRest;
import org.dspace.app.rest.parameter.SearchFilter;
import org.dspace.content.DSpaceObject;
import org.dspace.content.service.ItemService;
import org.dspace.core.Context;
import org.dspace.discovery.DiscoverQuery;
import org.dspace.discovery.DiscoverResult;
@@ -46,9 +45,6 @@ public class DiscoverResultConverter {
@Autowired
private List<DSpaceObjectConverter> converters;
@Autowired
private ItemService itemService;
@Autowired
private SearchService searchService;

View File

@@ -26,7 +26,7 @@ public class EntityTypeConverter extends DSpaceConverter<org.dspace.content.Enti
*/
public EntityTypeRest fromModel(EntityType obj) {
EntityTypeRest entityTypeRest = new EntityTypeRest();
entityTypeRest.setId(obj.getId());
entityTypeRest.setId(obj.getID());
entityTypeRest.setLabel(obj.getLabel());
return entityTypeRest;
}

View File

@@ -7,15 +7,11 @@
*/
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;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
/**
* This converter is responsible for transforming the model representation of an Relationship to the REST
@@ -24,11 +20,6 @@ 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;
@@ -57,18 +48,6 @@ public class RelationshipConverter extends DSpaceConverter<Relationship, Relatio
* @return The Relationship model object that is made from the REST object
*/
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;
throw new NotImplementedException();
}
}

View File

@@ -31,7 +31,7 @@ public class RelationshipTypeConverter extends DSpaceConverter<RelationshipType,
public RelationshipTypeRest fromModel(RelationshipType obj) {
RelationshipTypeRest relationshipTypeRest = new RelationshipTypeRest();
relationshipTypeRest.setId(obj.getId());
relationshipTypeRest.setId(obj.getID());
relationshipTypeRest.setLeftLabel(obj.getLeftLabel());
relationshipTypeRest.setRightLabel(obj.getRightLabel());
relationshipTypeRest.setLeftMinCardinality(obj.getLeftMinCardinality());

View File

@@ -226,7 +226,7 @@ public class RelationshipTypeRestRepositoryIT extends AbstractControllerIntegrat
}
if (foundRelationshipType != null) {
getClient().perform(get("/api/core/relationshiptypes/" + foundRelationshipType.getId()))
getClient().perform(get("/api/core/relationshiptypes/" + foundRelationshipType.getID()))
.andExpect(jsonPath("$._embedded.leftType",
EntityTypeMatcher.matchEntityTypeEntryForLabel("Publication")))
.andExpect(
@@ -248,7 +248,7 @@ public class RelationshipTypeRestRepositoryIT extends AbstractControllerIntegrat
assertEquals(Integer.MAX_VALUE, relationshipType.getLeftMaxCardinality());
assertEquals(Integer.MAX_VALUE, relationshipType.getRightMaxCardinality());
getClient().perform(get("/api/core/relationshiptypes/" + relationshipType.getId()))
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)))
@@ -271,7 +271,7 @@ public class RelationshipTypeRestRepositoryIT extends AbstractControllerIntegrat
}
if (foundRelationshipType != null) {
getClient().perform(get("/api/core/relationshiptypes/" + foundRelationshipType.getId()))
getClient().perform(get("/api/core/relationshiptypes/" + foundRelationshipType.getID()))
.andExpect(jsonPath("$._embedded.leftType",
EntityTypeMatcher.matchEntityTypeEntryForLabel("JournalVolume")))
.andExpect(jsonPath("$._embedded.rightType",
@@ -293,7 +293,7 @@ public class RelationshipTypeRestRepositoryIT extends AbstractControllerIntegrat
assertEquals(Integer.MAX_VALUE, relationshipType.getLeftMaxCardinality());
assertEquals(1, relationshipType.getRightMaxCardinality());
getClient().perform(get("/api/core/relationshiptypes/" + relationshipType.getId()))
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)))

View File

@@ -21,7 +21,7 @@ public class EntityTypeMatcher {
private EntityTypeMatcher() {}
public static Matcher<? super Object> matchEntityTypeEntry(EntityType entityType) {
return matchEntityTypeExplicitValuesEntry(entityType.getId(), entityType.getLabel());
return matchEntityTypeExplicitValuesEntry(entityType.getID(), entityType.getLabel());
}
public static Matcher<? super Object> matchEntityTypeEntryForLabel(String label) {

View File

@@ -29,15 +29,15 @@ public class RelationshipTypeMatcher {
private static Matcher<? super Object> matchRelationshipTypeExplicitEntityTypes(RelationshipType relationshipType,
EntityType leftType,
EntityType rightType) {
return matchRelationshipTypeExplicitEntityTypeValues(relationshipType, leftType.getId(), leftType.getLabel(),
rightType.getId(), rightType.getLabel());
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(),
return matchExplicitRelationshipTypeValuesAndExplicitEntityTypeValues(relationshipType.getID(),
relationshipType.getLeftLabel(),
relationshipType.getRightLabel(),
relationshipType.getLeftMinCardinality(),
@@ -55,9 +55,9 @@ public class RelationshipTypeMatcher {
leftMinCardinality, leftMaxCardinality,
rightMinCardinality,
rightMaxCardinality,
leftEntityType.getId(),
leftEntityType.getID(),
leftEntityType.getLabel(),
rightEntityType.getId(),
rightEntityType.getID(),
rightEntityType.getLabel());
}

View File

@@ -18,12 +18,6 @@
<!-- 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>

View File

@@ -373,12 +373,4 @@
<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>

View File

@@ -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 = ::