1
0

more detailed person type (#12)

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/12
Reviewed-by: Michael Hierweck <michael.hierweck@hostsharing.net>
This commit is contained in:
Michael Hoennig
2024-01-24 15:18:44 +01:00
parent fd1bd897b1
commit f150ea2091
29 changed files with 209 additions and 141 deletions

View File

@ -11,7 +11,6 @@ import org.hibernate.annotations.GenericGenerator;
import jakarta.persistence.*;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.util.UUID;

View File

@ -35,7 +35,6 @@ public class HsOfficePersonEntity implements HasUuid, Stringifyable {
private UUID uuid;
@Column(name = "persontype")
@Enumerated(EnumType.STRING)
private HsOfficePersonType personType;
@Column(name = "tradename")

View File

@ -1,9 +1,21 @@
package net.hostsharing.hsadminng.hs.office.person;
public enum HsOfficePersonType {
UNKNOWN,
NATURAL,
LEGAL,
SOLE_REPRESENTATION,
JOINT_REPRESENTATION
UNKNOWN_PERSON_TYPE("??"),
NATURAL_PERSON("NP"), // a human being
LEGAL_PERSON("LP"), // incorporated legal entity like A/S, GmbH, e.K., eG, e.V.
INCORPORATED_FIRM("IF"), // registered business partnership like OHG, Partnerschaftsgesellschaft
UNINCORPORATED_FIRM("UF"), // unregistered partnership, association etc. like GbR, ARGE, community of heirs
PUBLIC_INSTITUTION("PI"); // entities under public law like government entities, KdöR, AöR
public final String shortName;
HsOfficePersonType(final String shortName) {
this.shortName = shortName;
}
@Override
public String toString() {
return shortName;
}
}

View File

@ -0,0 +1,29 @@
package net.hostsharing.hsadminng.hs.office.person;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import java.util.stream.Stream;
@Converter(autoApply = true)
public class HsOfficePersonTypeConverter implements AttributeConverter<HsOfficePersonType, String> {
@Override
public String convertToDatabaseColumn(HsOfficePersonType category) {
if (category == null) {
return null;
}
return category.shortName;
}
@Override
public HsOfficePersonType convertToEntityAttribute(String code) {
if (code == null) {
return null;
}
return Stream.of(HsOfficePersonType.values())
.filter(c -> c.shortName.equals(code))
.findFirst()
.orElseThrow(IllegalArgumentException::new);
}
}