import: map for PERSON_TYPES_BY_CONTACT

This commit is contained in:
Timotheus Pokorra 2024-10-10 14:48:07 +02:00 committed by Dev und Test fuer hsadminng
parent bec4439fb0
commit a3418a1d49

View File

@ -73,23 +73,17 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
-1
);
private static final List<Integer> LEGAL_PERSON_CONTACTS = Arrays.asList(
90641, // we have two persons with same name, but one is the legal person
-1
);
private static final List<Integer> INCORPORATED_FIRM_CONTACTS = Arrays.asList(
-1
);
private static final List<Integer> NATURAL_PERSON_CONTACTS = Arrays.asList(
-1
);
private static final List<Integer> IGNORE_CONTACTS = Arrays.asList(
90547, // Kontakt hat keine Rolle
90312, // es gibt bereits einen partner Contact
-1
);
private static final Map<Integer, HsOfficePersonType> PERSON_TYPES_BY_CONTACT = Map.of(
90641, HsOfficePersonType.LEGAL_PERSON,
-1, HsOfficePersonType.LEGAL_PERSON
);
static Map<Integer, HsOfficeContactRealEntity> contacts = new WriteOnceMap<>();
static Map<Integer, HsOfficePersonEntity> persons = new WriteOnceMap<>();
static Map<Integer, HsOfficePartnerEntity> 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")) {