mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
Bugfix indirect relationship discovery updates
This commit is contained in:
@@ -375,15 +375,16 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
// authorization system here so that this failure doesn't happen when the items need to be update
|
// authorization system here so that this failure doesn't happen when the items need to be update
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
try {
|
try {
|
||||||
int max = configurationService.getIntProperty("relationship.update.relateditems.max", 5);
|
int max = configurationService.getIntProperty("relationship.update.relateditems.max", 10);
|
||||||
|
int maxDepth = configurationService.getIntProperty("relationship.update.relateditems.maxdepth", 3);
|
||||||
List<Item> itemsToUpdate = new LinkedList<>();
|
List<Item> itemsToUpdate = new LinkedList<>();
|
||||||
itemsToUpdate.add(relationship.getLeftItem());
|
itemsToUpdate.add(relationship.getLeftItem());
|
||||||
itemsToUpdate.add(relationship.getRightItem());
|
itemsToUpdate.add(relationship.getRightItem());
|
||||||
|
|
||||||
itemsToUpdate = getRelatedItemsForLeftItem(context, relationship.getLeftItem(),
|
getRelatedItemsForLeftItem(context, relationship.getLeftItem(),
|
||||||
relationship, itemsToUpdate, max);
|
relationship, itemsToUpdate, max, 0, maxDepth);
|
||||||
itemsToUpdate = getRelatedItemsForRightItem(context, relationship.getRightItem(),
|
getRelatedItemsForRightItem(context, relationship.getRightItem(),
|
||||||
relationship, itemsToUpdate, max);
|
relationship, itemsToUpdate, max, 0, maxDepth);
|
||||||
|
|
||||||
for (Item item : itemsToUpdate) {
|
for (Item item : itemsToUpdate) {
|
||||||
if (!item.isMetadataModified()) {
|
if (!item.isMetadataModified()) {
|
||||||
@@ -398,11 +399,14 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Item> getRelatedItemsForRightItem(Context context, Item item, Relationship relationship,
|
private List<Item> getRelatedItemsForRightItem(Context context, Item item, Relationship relationship,
|
||||||
List<Item> itemsToUpdate, int max)
|
List<Item> itemsToUpdate, int max, int currentDepth, int maxDepth)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
if (itemsToUpdate.size() >= max) {
|
if (itemsToUpdate.size() >= max) {
|
||||||
return itemsToUpdate;
|
return itemsToUpdate;
|
||||||
}
|
}
|
||||||
|
if (currentDepth == maxDepth) {
|
||||||
|
return itemsToUpdate;
|
||||||
|
}
|
||||||
List<RelationshipType> relationshipTypes = new LinkedList<>();
|
List<RelationshipType> relationshipTypes = new LinkedList<>();
|
||||||
EntityType leftType = relationship.getRelationshipType().getLeftType();
|
EntityType leftType = relationship.getRelationshipType().getLeftType();
|
||||||
String entityTypeStringFromMetadata = relationshipMetadataService.getEntityTypeStringFromMetadata(item);
|
String entityTypeStringFromMetadata = relationshipMetadataService.getEntityTypeStringFromMetadata(item);
|
||||||
@@ -420,13 +424,17 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
List<Relationship> list = findByItemAndRelationshipType(context, item, relationshipType, isLeft);
|
List<Relationship> list = findByItemAndRelationshipType(context, item, relationshipType, isLeft);
|
||||||
for (Relationship foundRelationship : list) {
|
for (Relationship foundRelationship : list) {
|
||||||
if (isLeft) {
|
if (isLeft) {
|
||||||
itemsToUpdate.add(foundRelationship.getRightItem());
|
if (!itemsToUpdate.contains(foundRelationship.getRightItem())) {
|
||||||
itemsToUpdate.addAll(getRelatedItemsForRightItem(context, foundRelationship.getRightItem(),
|
itemsToUpdate.add(foundRelationship.getRightItem());
|
||||||
foundRelationship, itemsToUpdate, max));
|
}
|
||||||
|
getRelatedItemsForRightItem(context, foundRelationship.getRightItem(),
|
||||||
|
foundRelationship, itemsToUpdate, max, currentDepth + 1, maxDepth);
|
||||||
} else {
|
} else {
|
||||||
itemsToUpdate.add(foundRelationship.getLeftItem());
|
if (!itemsToUpdate.contains(foundRelationship.getLeftItem())) {
|
||||||
itemsToUpdate.addAll(getRelatedItemsForLeftItem(context, foundRelationship.getLeftItem(),
|
itemsToUpdate.add(foundRelationship.getLeftItem());
|
||||||
foundRelationship, itemsToUpdate, max));
|
}
|
||||||
|
getRelatedItemsForLeftItem(context, foundRelationship.getLeftItem(),
|
||||||
|
foundRelationship, itemsToUpdate, max, currentDepth + 1, maxDepth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -435,7 +443,7 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Item> getRelatedItemsForLeftItem(Context context, Item item, Relationship relationship,
|
private List<Item> getRelatedItemsForLeftItem(Context context, Item item, Relationship relationship,
|
||||||
List<Item> itemsToUpdate, int max)
|
List<Item> itemsToUpdate, int max, int currentDepth, int maxDepth)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
if (itemsToUpdate.size() >= max) {
|
if (itemsToUpdate.size() >= max) {
|
||||||
return itemsToUpdate;
|
return itemsToUpdate;
|
||||||
@@ -459,11 +467,11 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
if (isLeft) {
|
if (isLeft) {
|
||||||
itemsToUpdate.add(foundRelationship.getRightItem());
|
itemsToUpdate.add(foundRelationship.getRightItem());
|
||||||
itemsToUpdate.addAll(getRelatedItemsForRightItem(context, foundRelationship.getRightItem(),
|
itemsToUpdate.addAll(getRelatedItemsForRightItem(context, foundRelationship.getRightItem(),
|
||||||
foundRelationship, itemsToUpdate, max));
|
foundRelationship, itemsToUpdate, max, currentDepth + 1, maxDepth));
|
||||||
} else {
|
} else {
|
||||||
itemsToUpdate.add(foundRelationship.getLeftItem());
|
itemsToUpdate.add(foundRelationship.getLeftItem());
|
||||||
itemsToUpdate.addAll(getRelatedItemsForLeftItem(context, foundRelationship.getLeftItem(),
|
itemsToUpdate.addAll(getRelatedItemsForLeftItem(context, foundRelationship.getLeftItem(),
|
||||||
foundRelationship, itemsToUpdate, max));
|
foundRelationship, itemsToUpdate, max, currentDepth + 1, maxDepth));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user