diff --git a/webservice/src/main/java/life/catalogue/assembly/SectorRunnable.java b/webservice/src/main/java/life/catalogue/assembly/SectorRunnable.java index 75b4e653f..9fb414597 100644 --- a/webservice/src/main/java/life/catalogue/assembly/SectorRunnable.java +++ b/webservice/src/main/java/life/catalogue/assembly/SectorRunnable.java @@ -54,8 +54,6 @@ abstract class SectorRunnable implements Runnable { // maps keyed on taxon ids from this sector final Map decisions = new HashMap<>(); List childSectors; - // map with foreign child id to original parent name - Map foreignChildrenParents = new HashMap<>(); private final UsageMatcherGlobal matcher; private final boolean clearMatcherCache; private final Consumer successCallback; @@ -283,7 +281,8 @@ private void loadAttachedSectors() { SectorMapper sm = session.getMapper(SectorMapper.class); childSectors=sm.listChildSectors(sectorKey); } - LOG.info("Loaded {} sectors targeting taxa from sector {}", childSectors.size(), sectorKey); + long mergeCnt = childSectors.stream().filter(s -> s.getMode() == Sector.Mode.MERGE).count(); + LOG.info("Loaded {} sectors incl {} merge sectors targeting taxa from sector {}", childSectors.size(), mergeCnt, sectorKey); } abstract void doWork() throws Exception; diff --git a/webservice/src/main/java/life/catalogue/assembly/SectorSync.java b/webservice/src/main/java/life/catalogue/assembly/SectorSync.java index 912edb52f..534d0b680 100644 --- a/webservice/src/main/java/life/catalogue/assembly/SectorSync.java +++ b/webservice/src/main/java/life/catalogue/assembly/SectorSync.java @@ -19,6 +19,7 @@ import life.catalogue.matching.decision.RematchRequest; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -57,6 +58,8 @@ public class SectorSync extends SectorRunnable { private final int targetDatasetKey; // dataset to sync into private @Nullable TreeMergeHandlerConfig mergeCfg; private List foreignChildren; + // map with foreign child id to original parent name + private final Map foreignChildrenParents = new HashMap<>(); private final UsageIdGen usageIdGen; private final Supplier nameIdGen; private final Supplier typeMaterialIdGen; @@ -145,13 +148,17 @@ void init() throws Exception { super.init(true); loadForeignChildren(); if (!disableAutoBlocking) { - // also load all sector subjects to auto block them + // also load all sector subjects of non merge sources to auto block them try (SqlSession session = factory.openSession()) { AtomicInteger counter = new AtomicInteger(); PgUtils.consume( () -> session.getMapper(SectorMapper.class).processSectors(sectorKey.getDatasetKey(), subjectDatasetKey), s -> { - if (!s.getId().equals(sectorKey.getId()) && s.getSubject() != null && s.getSubject().getId() != null) { + if (!s.getId().equals(sectorKey.getId()) + && s.getSubject() != null + && s.getSubject().getId() != null + && s.getMode() != Sector.Mode.MERGE + ) { EditorialDecision d = new EditorialDecision(); d.setSubject(s.getSubject()); d.setDatasetKey(sectorKey.getDatasetKey()); diff --git a/webservice/src/test/java/life/catalogue/assembly/SectorSyncMergeIT.java b/webservice/src/test/java/life/catalogue/assembly/SectorSyncMergeIT.java index c6254952e..6c7c316f6 100644 --- a/webservice/src/test/java/life/catalogue/assembly/SectorSyncMergeIT.java +++ b/webservice/src/test/java/life/catalogue/assembly/SectorSyncMergeIT.java @@ -83,6 +83,7 @@ public class SectorSyncMergeIT extends SectorSyncTestBase { @Parameterized.Parameters public static Collection data() { return Arrays.asList(new Object[][] { + {"myosotis", List.of("taxref", "uksi", "pbdb", "bavaria")}, {"tetralobus", List.of("wfo", "bouchard", "plazi")}, {"cactus", List.of("wfo", "wcvp", "grin", "taxref", "tpl", "pbdb")}, {"aphanizomenon", List.of("worms","ncbi","dyntaxa")}, // https://github.com/CatalogueOfLife/xcol/issues/146