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:
@ -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;
|
||||
|
||||
|
@ -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")
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user