add-salut-and-title-to-person #25
@ -35,6 +35,8 @@ public class HsOfficePersonEntity implements RbacObject, Stringifyable {
|
|||||||
private static Stringify<HsOfficePersonEntity> toString = stringify(HsOfficePersonEntity.class, "person")
|
private static Stringify<HsOfficePersonEntity> toString = stringify(HsOfficePersonEntity.class, "person")
|
||||||
.withProp(Fields.personType, HsOfficePersonEntity::getPersonType)
|
.withProp(Fields.personType, HsOfficePersonEntity::getPersonType)
|
||||||
.withProp(Fields.tradeName, HsOfficePersonEntity::getTradeName)
|
.withProp(Fields.tradeName, HsOfficePersonEntity::getTradeName)
|
||||||
|
.withProp(Fields.salutation, HsOfficePersonEntity::getSalutation)
|
||||||
|
.withProp(Fields.title, HsOfficePersonEntity::getTitle)
|
||||||
.withProp(Fields.familyName, HsOfficePersonEntity::getFamilyName)
|
.withProp(Fields.familyName, HsOfficePersonEntity::getFamilyName)
|
||||||
.withProp(Fields.givenName, HsOfficePersonEntity::getGivenName);
|
.withProp(Fields.givenName, HsOfficePersonEntity::getGivenName);
|
||||||
|
|
||||||
@ -48,6 +50,12 @@ public class HsOfficePersonEntity implements RbacObject, Stringifyable {
|
|||||||
@Column(name = "tradename")
|
@Column(name = "tradename")
|
||||||
private String tradeName;
|
private String tradeName;
|
||||||
|
|
||||||
|
@Column(name = "salutation")
|
||||||
|
private String salutation;
|
||||||
|
|
||||||
|
@Column(name = "title")
|
||||||
|
private String title;
|
||||||
|
|
||||||
@Column(name = "familyname")
|
@Column(name = "familyname")
|
||||||
private String familyName;
|
private String familyName;
|
||||||
|
|
||||||
@ -68,7 +76,7 @@ public class HsOfficePersonEntity implements RbacObject, Stringifyable {
|
|||||||
public static RbacView rbac() {
|
public static RbacView rbac() {
|
||||||
return rbacViewFor("person", HsOfficePersonEntity.class)
|
return rbacViewFor("person", HsOfficePersonEntity.class)
|
||||||
.withIdentityView(SQL.projection("concat(tradeName, familyName, givenName)"))
|
.withIdentityView(SQL.projection("concat(tradeName, familyName, givenName)"))
|
||||||
.withUpdatableColumns("personType", "tradeName", "givenName", "familyName")
|
.withUpdatableColumns("personType", "title", "salutation", "tradeName", "givenName", "familyName")
|
||||||
.toRole("global", GUEST).grantPermission(INSERT)
|
.toRole("global", GUEST).grantPermission(INSERT)
|
||||||
|
|
||||||
.createRole(OWNER, (with) -> {
|
.createRole(OWNER, (with) -> {
|
||||||
|
@ -22,6 +22,8 @@ class HsOfficePersonEntityPatcher implements EntityPatcher<HsOfficePersonPatchRe
|
|||||||
.map(HsOfficePersonType::valueOf)
|
.map(HsOfficePersonType::valueOf)
|
||||||
.ifPresent(entity::setPersonType);
|
.ifPresent(entity::setPersonType);
|
||||||
OptionalFromJson.of(resource.getTradeName()).ifPresent(entity::setTradeName);
|
OptionalFromJson.of(resource.getTradeName()).ifPresent(entity::setTradeName);
|
||||||
|
OptionalFromJson.of(resource.getSalutation()).ifPresent(entity::setSalutation);
|
||||||
|
OptionalFromJson.of(resource.getTitle()).ifPresent(entity::setTitle);
|
||||||
OptionalFromJson.of(resource.getFamilyName()).ifPresent(entity::setFamilyName);
|
OptionalFromJson.of(resource.getFamilyName()).ifPresent(entity::setFamilyName);
|
||||||
OptionalFromJson.of(resource.getGivenName()).ifPresent(entity::setGivenName);
|
OptionalFromJson.of(resource.getGivenName()).ifPresent(entity::setGivenName);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,10 @@ components:
|
|||||||
$ref: '#/components/schemas/HsOfficePersonType'
|
$ref: '#/components/schemas/HsOfficePersonType'
|
||||||
tradeName:
|
tradeName:
|
||||||
type: string
|
type: string
|
||||||
|
salutation:
|
||||||
|
type: string
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
givenName:
|
givenName:
|
||||||
type: string
|
type: string
|
||||||
familyName:
|
familyName:
|
||||||
@ -35,6 +39,10 @@ components:
|
|||||||
$ref: '#/components/schemas/HsOfficePersonType'
|
$ref: '#/components/schemas/HsOfficePersonType'
|
||||||
tradeName:
|
tradeName:
|
||||||
type: string
|
type: string
|
||||||
|
salutation:
|
||||||
|
type: string
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
givenName:
|
givenName:
|
||||||
type: string
|
type: string
|
||||||
familyName:
|
familyName:
|
||||||
@ -51,6 +59,12 @@ components:
|
|||||||
tradeName:
|
tradeName:
|
||||||
type: string
|
type: string
|
||||||
nullable: true
|
nullable: true
|
||||||
|
salutation:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
givenName:
|
givenName:
|
||||||
type: string
|
type: string
|
||||||
nullable: true
|
nullable: true
|
||||||
|
@ -19,6 +19,8 @@ create table if not exists hs_office_person
|
|||||||
uuid uuid unique references RbacObject (uuid) initially deferred,
|
uuid uuid unique references RbacObject (uuid) initially deferred,
|
||||||
personType HsOfficePersonType not null,
|
personType HsOfficePersonType not null,
|
||||||
tradeName varchar(96),
|
tradeName varchar(96),
|
||||||
|
salutation varchar(30),
|
||||||
|
title varchar(20),
|
||||||
givenName varchar(48),
|
givenName varchar(48),
|
||||||
familyName varchar(48)
|
familyName varchar(48)
|
||||||
);
|
);
|
||||||
|
@ -138,6 +138,8 @@ call generateRbacRestrictedView('hs_office_person',
|
|||||||
$orderBy$,
|
$orderBy$,
|
||||||
$updates$
|
$updates$
|
||||||
personType = new.personType,
|
personType = new.personType,
|
||||||
|
title = new.title,
|
||||||
|
salutation = new.salutation,
|
||||||
tradeName = new.tradeName,
|
tradeName = new.tradeName,
|
||||||
givenName = new.givenName,
|
givenName = new.givenName,
|
||||||
familyName = new.familyName
|
familyName = new.familyName
|
||||||
|
@ -23,7 +23,9 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
final var entity = new HsOfficePersonEntity();
|
final var entity = new HsOfficePersonEntity();
|
||||||
entity.setUuid(INITIAL_PERSON_UUID);
|
entity.setUuid(INITIAL_PERSON_UUID);
|
||||||
entity.setPersonType(HsOfficePersonType.LEGAL_PERSON);
|
entity.setPersonType(HsOfficePersonType.LEGAL_PERSON);
|
||||||
entity.setTradeName("initial@example.org");
|
entity.setTradeName("initial trade name");
|
||||||
|
entity.setTitle("Dr. Init.");
|
||||||
|
entity.setSalutation("Herr Initial");
|
||||||
entity.setFamilyName("initial postal address");
|
entity.setFamilyName("initial postal address");
|
||||||
entity.setGivenName("+01 100 123456789");
|
entity.setGivenName("+01 100 123456789");
|
||||||
return entity;
|
return entity;
|
||||||
@ -54,6 +56,16 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
HsOfficePersonPatchResource::setTradeName,
|
HsOfficePersonPatchResource::setTradeName,
|
||||||
"patched trade name",
|
"patched trade name",
|
||||||
HsOfficePersonEntity::setTradeName),
|
HsOfficePersonEntity::setTradeName),
|
||||||
|
new JsonNullableProperty<>(
|
||||||
|
"title",
|
||||||
|
HsOfficePersonPatchResource::setTitle,
|
||||||
|
"Dr. Patch.",
|
||||||
|
HsOfficePersonEntity::setTitle),
|
||||||
|
new JsonNullableProperty<>(
|
||||||
|
"salutation",
|
||||||
|
HsOfficePersonPatchResource::setSalutation,
|
||||||
|
"Hallo Ini",
|
||||||
|
HsOfficePersonEntity::setSalutation),
|
||||||
new JsonNullableProperty<>(
|
new JsonNullableProperty<>(
|
||||||
"familyName",
|
"familyName",
|
||||||
HsOfficePersonPatchResource::setFamilyName,
|
HsOfficePersonPatchResource::setFamilyName,
|
||||||
|
@ -60,19 +60,63 @@ class HsOfficePersonEntityUnitTest {
|
|||||||
assertThat(actualDisplay).isEqualTo("NP some family name, some given name");
|
assertThat(actualDisplay).isEqualTo("NP some family name, some given name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void toShortStringWithSalutationAndTitleReturnsSalutationAndTitle() {
|
||||||
|
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||||
|
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||||
|
.salutation("Frau")
|
||||||
|
.title("Dr.")
|
||||||
|
.familyName("some family name")
|
||||||
|
.givenName("some given name")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final var actualDisplay = givenPersonEntity.toShortString();
|
||||||
|
|
||||||
|
assertThat(actualDisplay).isEqualTo("NP some family name, some given name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void toShortStringWithSalutationAndWithoutTitleReturnsSalutation() {
|
||||||
|
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||||
|
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||||
|
.salutation("Frau")
|
||||||
|
.familyName("some family name")
|
||||||
|
.givenName("some given name")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final var actualDisplay = givenPersonEntity.toShortString();
|
||||||
|
|
||||||
|
assertThat(actualDisplay).isEqualTo("NP Frau some family name, some given name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void toShortStringWithoutSalutationAndWithTitleReturnsTitle() {
|
||||||
|
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||||
|
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||||
|
.title("Dr. Dr.")
|
||||||
|
.familyName("some family name")
|
||||||
|
.givenName("some given name")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final var actualDisplay = givenPersonEntity.toShortString();
|
||||||
|
|
||||||
|
assertThat(actualDisplay).isEqualTo("NP some family name, some given name");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void toStringWithAllFieldsReturnsAllButUuid() {
|
void toStringWithAllFieldsReturnsAllButUuid() {
|
||||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||||
.uuid(UUID.randomUUID())
|
.uuid(UUID.randomUUID())
|
||||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||||
.tradeName("some trade name")
|
.tradeName("some trade name")
|
||||||
|
.title("Dr.")
|
||||||
.familyName("some family name")
|
.familyName("some family name")
|
||||||
.givenName("some given name")
|
.givenName("some given name")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final var actualDisplay = givenPersonEntity.toString();
|
final var actualDisplay = givenPersonEntity.toString();
|
||||||
|
|
||||||
assertThat(actualDisplay).isEqualTo("person(personType='NP', tradeName='some trade name', familyName='some family name', givenName='some given name')");
|
assertThat(actualDisplay).isEqualTo("person(personType='NP', tradeName='some trade name', title='Dr.', familyName='some family name', givenName='some given name')");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -86,4 +130,42 @@ class HsOfficePersonEntityUnitTest {
|
|||||||
|
|
||||||
assertThat(actualDisplay).isEqualTo("person(familyName='some family name', givenName='some given name')");
|
assertThat(actualDisplay).isEqualTo("person(familyName='some family name', givenName='some given name')");
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
void toStringWithSalutationAndTitleRetursSalutationAndTitle() {
|
||||||
|
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||||
|
.salutation("Herr")
|
||||||
|
.title("Prof. Dr.")
|
||||||
|
.familyName("some family name")
|
||||||
|
.givenName("some given name")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final var actualDisplay = givenPersonEntity.toString();
|
||||||
|
|
||||||
|
assertThat(actualDisplay).isEqualTo("person(salutation='Herr', title='Prof. Dr.', familyName='some family name', givenName='some given name')");
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void toStringWithSalutationAndWithoutTitleSkipsTitle() {
|
||||||
|
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||||
|
.salutation("Herr")
|
||||||
|
.familyName("some family name")
|
||||||
|
.givenName("some given name")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final var actualDisplay = givenPersonEntity.toString();
|
||||||
|
|
||||||
|
assertThat(actualDisplay).isEqualTo("person(salutation='Herr', familyName='some family name', givenName='some given name')");
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void toStringWithoutSalutationAndWithTitleSkipsSalutation() {
|
||||||
|
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||||
|
.title("some title")
|
||||||
|
.familyName("some family name")
|
||||||
|
.givenName("some given name")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final var actualDisplay = givenPersonEntity.toString();
|
||||||
|
|
||||||
|
assertThat(actualDisplay).isEqualTo("person(title='some title', familyName='some family name', givenName='some given name')");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user