Bugfix indirect relationship discovery updates

This commit is contained in:
Ben Bosman
2020-12-17 15:46:38 +01:00
parent c4d4b18150
commit 7b346e7584

View File

@@ -376,16 +376,20 @@ 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", 10); int max = configurationService.getIntProperty("relationship.update.relateditems.max", 20);
int maxDepth = configurationService.getIntProperty("relationship.update.relateditems.maxdepth", 3); int maxDepth = configurationService.getIntProperty("relationship.update.relateditems.maxdepth", 5);
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());
if (containsVirtualMetadata(relationship.getRelationshipType().getLeftwardType())) {
findModifiedDiscoveryItemsForCurrentItem(context, relationship.getLeftItem(), findModifiedDiscoveryItemsForCurrentItem(context, relationship.getLeftItem(),
itemsToUpdate, max, 0, maxDepth); itemsToUpdate, max, 0, maxDepth);
}
if (containsVirtualMetadata(relationship.getRelationshipType().getRightwardType())) {
findModifiedDiscoveryItemsForCurrentItem(context, relationship.getRightItem(), findModifiedDiscoveryItemsForCurrentItem(context, relationship.getRightItem(),
itemsToUpdate, max, 0, maxDepth); itemsToUpdate, max, 0, maxDepth);
}
for (Item item : itemsToUpdate) { for (Item item : itemsToUpdate) {
if (!item.isMetadataModified()) { if (!item.isMetadataModified()) {
@@ -435,8 +439,7 @@ public class RelationshipServiceImpl implements RelationshipService {
} else { } else {
typeToSearchInVirtualMetadata = relationshipType.getLeftwardType(); typeToSearchInVirtualMetadata = relationshipType.getLeftwardType();
} }
if (virtualMetadataPopulator.getMap().containsKey(typeToSearchInVirtualMetadata) if (containsVirtualMetadata(typeToSearchInVirtualMetadata)) {
&& virtualMetadataPopulator.getMap().get(typeToSearchInVirtualMetadata).size() > 0) {
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) {
@@ -461,6 +464,11 @@ public class RelationshipServiceImpl implements RelationshipService {
} }
} }
private boolean containsVirtualMetadata(String typeToSearchInVirtualMetadata) {
return virtualMetadataPopulator.getMap().containsKey(typeToSearchInVirtualMetadata)
&& virtualMetadataPopulator.getMap().get(typeToSearchInVirtualMetadata).size() > 0;
}
/** /**
* Converts virtual metadata from RelationshipMetadataValue objects to actual item metadata. * Converts virtual metadata from RelationshipMetadataValue objects to actual item metadata.
* *