diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java index 7b404165..7d5a14ea 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -73,23 +73,17 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { -1 ); - private static final List LEGAL_PERSON_CONTACTS = Arrays.asList( - 90641, // we have two persons with same name, but one is the legal person - -1 - ); - private static final List INCORPORATED_FIRM_CONTACTS = Arrays.asList( - -1 - ); - private static final List NATURAL_PERSON_CONTACTS = Arrays.asList( - -1 - ); - private static final List IGNORE_CONTACTS = Arrays.asList( 90547, // Kontakt hat keine Rolle 90312, // es gibt bereits einen partner Contact -1 ); + private static final Map PERSON_TYPES_BY_CONTACT = Map.of( + 90641, HsOfficePersonType.LEGAL_PERSON, + -1, HsOfficePersonType.LEGAL_PERSON + ); + static Map contacts = new WriteOnceMap<>(); static Map persons = new WriteOnceMap<>(); static Map partners = new WriteOnceMap<>(); @@ -971,6 +965,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { HsOfficePersonEntity contactPerson = partnerPerson; if (!StringUtils.equals(rec.getString("firma"), partnerPerson.getTradeName()) || + partnerPerson.getPersonType() != determinePersonType(rec) || !StringUtils.equals(rec.getString("first_name"), partnerPerson.getGivenName()) || !StringUtils.equals(rec.getString("last_name"), partnerPerson.getFamilyName())) { contactPerson = addPerson(HsOfficePersonEntity.builder().build(), rec); @@ -1087,12 +1082,8 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { String givenName = contactRecord.getString("first_name"); String tradeName = contactRecord.getString("firma"); - if (LEGAL_PERSON_CONTACTS.contains(contactRecord.getString("contact_id"))) { - return HsOfficePersonType.LEGAL_PERSON; - } else if (INCORPORATED_FIRM_CONTACTS.contains(contactRecord.getString("contact_id"))) { - return HsOfficePersonType.INCORPORATED_FIRM; - } else if (NATURAL_PERSON_CONTACTS.contains(contactRecord.getString("contact_id"))) { - return HsOfficePersonType.NATURAL_PERSON; + if (PERSON_TYPES_BY_CONTACT.containsKey(contactRecord.getInteger("contact_id"))) { + return PERSON_TYPES_BY_CONTACT.get(contactRecord.getInteger("contact_id")); } if (tradeName.isBlank() || tradeName.startsWith("verstorben")) {