From c66580a8b3cc59f52986f07bb83fcccafe805f3e Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 5 Feb 2024 11:54:30 +0100 Subject: [PATCH 1/2] fix missing contractual in import --- .../hsadminng/hs/office/migration/ImportOfficeData.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java index f02dae61..1ca112d2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java @@ -516,7 +516,7 @@ public class ImportOfficeData extends ContextBasedTest { jpaAttempt.transacted(() -> { context(rbacSuperuser); coopAssets.forEach(this::persist); - updateLegacyIds(coopShares, "hs_office_coopassetstransaction_legacy_id", "member_asset_id"); + updateLegacyIds(coopAssets, "hs_office_coopassetstransaction_legacy_id", "member_asset_id"); }).assertSuccessful(); } @@ -878,13 +878,13 @@ public class ImportOfficeData extends ContextBasedTest { partners.forEach( (id, partner) -> { final var partnerPerson = partner.getPerson(); if (relationships.values().stream() - .filter(rel -> rel.getRelHolder() == partnerPerson && rel.getRelType() == HsOfficeRelationshipType.REPRESENTATIVE) + .filter(rel -> rel.getRelAnchor() == partnerPerson && rel.getRelType() == HsOfficeRelationshipType.REPRESENTATIVE) .findFirst().isEmpty()) { - addRelationship(partnerPerson, partnerPerson, partner.getContact(), HsOfficeRelationshipType.REPRESENTATIVE); + //addRelationship(partnerPerson, partnerPerson, partner.getContact(), HsOfficeRelationshipType.REPRESENTATIVE); contractualMissing.add(partner.getPartnerNumber()); } }); - // assertThat(contractualMissing).isEmpty(); uncomment if we don't want allow missing contractual contact + assertThat(contractualMissing).isEmpty(); // comment out if we do want to allow missing contractual contact } private static boolean containsRole(final Record rec, final String role) { final var roles = rec.getString("roles"); -- 2.39.5 From 3dd8916999529bd679f7ef170d2924affea1b753 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 5 Feb 2024 12:34:22 +0100 Subject: [PATCH 2/2] flush before updating legacy-ids --- .../hsadminng/hs/office/migration/ImportOfficeData.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java index 1ca112d2..562eaf06 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java @@ -596,6 +596,7 @@ public class ImportOfficeData extends ContextBasedTest { Map entities, final String legacyIdTable, final String legacyIdColumn) { + em.flush(); entities.forEach((id, entity) -> em.createNativeQuery(""" UPDATE ${legacyIdTable} SET ${legacyIdColumn} = :legacyId -- 2.39.5