This commit is contained in:
Ben Bosman
2019-04-29 11:13:55 +02:00
parent 51aa22cdb9
commit 70e34edfef
4 changed files with 17 additions and 15 deletions

View File

@@ -35,12 +35,14 @@ public class EntityServiceImpl implements EntityService {
@Autowired(required = true) @Autowired(required = true)
protected ItemService itemService; protected ItemService itemService;
@Override
public Entity findByItemId(Context context, UUID itemId) throws SQLException { public Entity findByItemId(Context context, UUID itemId) throws SQLException {
Item item = itemService.find(context, itemId); Item item = itemService.find(context, itemId);
List<Relationship> relationshipList = relationshipService.findByItem(context, item); List<Relationship> relationshipList = relationshipService.findByItem(context, item);
return new Entity(item, relationshipList); return new Entity(item, relationshipList);
} }
@Override
public EntityType getType(Context context, Entity entity) throws SQLException { public EntityType getType(Context context, Entity entity) throws SQLException {
Item item = entity.getItem(); Item item = entity.getItem();
List<MetadataValue> list = itemService.getMetadata(item, "relationship", "type", null, Item.ANY); List<MetadataValue> list = itemService.getMetadata(item, "relationship", "type", null, Item.ANY);
@@ -51,12 +53,9 @@ public class EntityServiceImpl implements EntityService {
} }
} }
public List<Relationship> getAllRelations(Context context, Entity entity) { @Override
return entity.getRelationships();
}
public List<Relationship> getLeftRelations(Context context, Entity entity) { public List<Relationship> getLeftRelations(Context context, Entity entity) {
List<Relationship> fullList = this.getAllRelations(context, entity); List<Relationship> fullList = entity.getRelationships();
List<Relationship> listToReturn = new LinkedList<>(); List<Relationship> listToReturn = new LinkedList<>();
for (Relationship relationship : fullList) { for (Relationship relationship : fullList) {
if (relationship.getLeftItem().getID() == entity.getItem().getID()) { if (relationship.getLeftItem().getID() == entity.getItem().getID()) {
@@ -66,8 +65,9 @@ public class EntityServiceImpl implements EntityService {
return listToReturn; return listToReturn;
} }
@Override
public List<Relationship> getRightRelations(Context context, Entity entity) { public List<Relationship> getRightRelations(Context context, Entity entity) {
List<Relationship> fullList = this.getAllRelations(context, entity); List<Relationship> fullList = entity.getRelationships();
List<Relationship> listToReturn = new LinkedList<>(); List<Relationship> listToReturn = new LinkedList<>();
for (Relationship relationship : fullList) { for (Relationship relationship : fullList) {
if (relationship.getRightItem().getID() == entity.getItem().getID()) { if (relationship.getRightItem().getID() == entity.getItem().getID()) {
@@ -77,6 +77,7 @@ public class EntityServiceImpl implements EntityService {
return listToReturn; return listToReturn;
} }
@Override
public List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException { public List<Relationship> getRelationsByLabel(Context context, String label) throws SQLException {
List<Relationship> listToReturn = new LinkedList<>(); List<Relationship> listToReturn = new LinkedList<>();
List<Relationship> relationshipList = relationshipService.findAll(context); List<Relationship> relationshipList = relationshipService.findAll(context);
@@ -90,6 +91,7 @@ public class EntityServiceImpl implements EntityService {
return listToReturn; return listToReturn;
} }
@Override
public List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity) throws SQLException { public List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity) throws SQLException {
EntityType entityType = this.getType(context, entity); EntityType entityType = this.getType(context, entity);
List<RelationshipType> listToReturn = new LinkedList<>(); List<RelationshipType> listToReturn = new LinkedList<>();
@@ -102,6 +104,7 @@ public class EntityServiceImpl implements EntityService {
return listToReturn; return listToReturn;
} }
@Override
public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity) throws SQLException { public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity) throws SQLException {
EntityType entityType = this.getType(context, entity); EntityType entityType = this.getType(context, entity);
List<RelationshipType> listToReturn = new LinkedList<>(); List<RelationshipType> listToReturn = new LinkedList<>();
@@ -113,6 +116,7 @@ public class EntityServiceImpl implements EntityService {
return listToReturn; return listToReturn;
} }
@Override
public List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity) throws SQLException { public List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity) throws SQLException {
EntityType entityType = this.getType(context, entity); EntityType entityType = this.getType(context, entity);
List<RelationshipType> listToReturn = new LinkedList<>(); List<RelationshipType> listToReturn = new LinkedList<>();
@@ -124,6 +128,7 @@ public class EntityServiceImpl implements EntityService {
return listToReturn; return listToReturn;
} }
@Override
public List<RelationshipType> getRelationshipTypesByLabel(Context context, String label) throws SQLException { public List<RelationshipType> getRelationshipTypesByLabel(Context context, String label) throws SQLException {
List<RelationshipType> listToReturn = new LinkedList<>(); List<RelationshipType> listToReturn = new LinkedList<>();
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) { for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) {

View File

@@ -1355,6 +1355,7 @@ prevent the generation of resource policy entry values with null dspace_object a
return fullMetadataValueList; return fullMetadataValueList;
} }
@Override
public List<MetadataValue> getMetadata(Item item, String schema, String element, String qualifier, String lang, public List<MetadataValue> getMetadata(Item item, String schema, String element, String qualifier, String lang,
boolean enableVirtualMetadata) { boolean enableVirtualMetadata) {
//Fields of the relation schema are virtual metadata //Fields of the relation schema are virtual metadata

View File

@@ -27,6 +27,7 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService {
@Autowired(required = true) @Autowired(required = true)
protected AuthorizeService authorizeService; protected AuthorizeService authorizeService;
@Override
public RelationshipType create(Context context) throws SQLException, AuthorizeException { public RelationshipType create(Context context) throws SQLException, AuthorizeException {
if (!authorizeService.isAdmin(context)) { if (!authorizeService.isAdmin(context)) {
throw new AuthorizeException( throw new AuthorizeException(
@@ -84,15 +85,17 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService {
return create(context, relationshipType); return create(context, relationshipType);
} }
@Override
public RelationshipType find(Context context,int id) throws SQLException { public RelationshipType find(Context context,int id) throws SQLException {
return relationshipTypeDAO.findByID(context, RelationshipType.class, id); return relationshipTypeDAO.findByID(context, RelationshipType.class, id);
} }
@Override
public void update(Context context,RelationshipType relationshipType) throws SQLException, AuthorizeException { public void update(Context context,RelationshipType relationshipType) throws SQLException, AuthorizeException {
update(context,Collections.singletonList(relationshipType)); update(context,Collections.singletonList(relationshipType));
} }
@Override
public void update(Context context,List<RelationshipType> relationshipTypes) public void update(Context context,List<RelationshipType> relationshipTypes)
throws SQLException, AuthorizeException { throws SQLException, AuthorizeException {
if (CollectionUtils.isNotEmpty(relationshipTypes)) { if (CollectionUtils.isNotEmpty(relationshipTypes)) {
@@ -109,6 +112,7 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService {
} }
@Override
public void delete(Context context,RelationshipType relationshipType) throws SQLException, AuthorizeException { public void delete(Context context,RelationshipType relationshipType) throws SQLException, AuthorizeException {
if (!authorizeService.isAdmin(context)) { if (!authorizeService.isAdmin(context)) {
throw new AuthorizeException( throw new AuthorizeException(

View File

@@ -47,14 +47,6 @@ public interface EntityService {
*/ */
EntityType getType(Context context, Entity entity) throws SQLException; EntityType getType(Context context, Entity entity) throws SQLException;
/**
* Returns the list of relations for the given Entity object
* @param context The relevant DSpace context
* @param entity The Entity object for which the list of relationships will be returned
* @return The list of relationships for the given Entity object
*/
List<Relationship> getAllRelations(Context context, Entity entity);
/** /**
* Retrieves the list of relationships, which are attached to the Entity object that is passed along, where the * Retrieves the list of relationships, which are attached to the Entity object that is passed along, where the
* left item object of each relationship is equal to the Item object of the Entity object that is passed along * left item object of each relationship is equal to the Item object of the Entity object that is passed along