1
0

rename contact.label to contact.caption

This commit is contained in:
Michael Hoennig
2024-05-06 09:22:21 +02:00
parent a93c097f64
commit 85376d51af
35 changed files with 191 additions and 191 deletions

@@ -36,10 +36,10 @@ public class HsOfficeContactController implements HsOfficeContactsApi {
public ResponseEntity<List<HsOfficeContactResource>> listContacts(
final String currentUser,
final String assumedRoles,
final String label) {
final String caption) {
context.define(currentUser, assumedRoles);
final var entities = contactRepo.findContactByOptionalLabelLike(label);
final var entities = contactRepo.findContactByOptionalCaptionLike(caption);
final var resources = mapper.mapList(entities, HsOfficeContactResource.class);
return ResponseEntity.ok(resources);

@@ -38,7 +38,7 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
public class HsOfficeContactEntity implements Stringifyable, RbacObject {
private static Stringify<HsOfficeContactEntity> toString = stringify(HsOfficeContactEntity.class, "contact")
.withProp(Fields.label, HsOfficeContactEntity::getLabel)
.withProp(Fields.caption, HsOfficeContactEntity::getCaption)
.withProp(Fields.emailAddresses, HsOfficeContactEntity::getEmailAddresses);
@Id
@@ -49,8 +49,8 @@ public class HsOfficeContactEntity implements Stringifyable, RbacObject {
@Version
private int version;
@Column(name = "label") // TODO.impl: rename to caption
private String label;
@Column(name = "caption")
private String caption;
@Column(name = "postaladdress")
private String postalAddress; // multiline free-format text
@@ -96,13 +96,13 @@ public class HsOfficeContactEntity implements Stringifyable, RbacObject {
@Override
public String toShortString() {
return label;
return caption;
}
public static RbacView rbac() {
return rbacViewFor("contact", HsOfficeContactEntity.class)
.withIdentityView(SQL.projection("label"))
.withUpdatableColumns("label", "postalAddress", "emailAddresses", "phoneNumbers")
.withIdentityView(SQL.projection("caption"))
.withUpdatableColumns("caption", "postalAddress", "emailAddresses", "phoneNumbers")
.createRole(OWNER, (with) -> {
with.owningUser(CREATOR);
with.incomingSuperRole(GLOBAL, ADMIN);

@@ -17,7 +17,7 @@ class HsOfficeContactEntityPatcher implements EntityPatcher<HsOfficeContactPatch
@Override
public void apply(final HsOfficeContactPatchResource resource) {
OptionalFromJson.of(resource.getLabel()).ifPresent(entity::setLabel);
OptionalFromJson.of(resource.getCaption()).ifPresent(entity::setCaption);
OptionalFromJson.of(resource.getPostalAddress()).ifPresent(entity::setPostalAddress);
Optional.ofNullable(resource.getEmailAddresses())
.ifPresent(r -> entity.getEmailAddresses().patch(KeyValueMap.from(resource.getEmailAddresses())));

@@ -13,10 +13,10 @@ public interface HsOfficeContactRepository extends Repository<HsOfficeContactEnt
@Query("""
SELECT c FROM HsOfficeContactEntity c
WHERE :label is null
OR c.label like concat(cast(:label as text), '%')
WHERE :caption is null
OR c.caption like concat(cast(:caption as text), '%')
""")
List<HsOfficeContactEntity> findContactByOptionalLabelLike(String label);
List<HsOfficeContactEntity> findContactByOptionalCaptionLike(String caption);
HsOfficeContactEntity save(final HsOfficeContactEntity entity);

@@ -41,7 +41,7 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
OR person.tradeName like concat(cast(:name as text), '%')
OR person.familyName like concat(cast(:name as text), '%')
OR person.givenName like concat(cast(:name as text), '%')
OR contact.label like concat(cast(:name as text), '%')
OR contact.caption like concat(cast(:name as text), '%')
""")
List<HsOfficeDebitorEntity> findDebitorByOptionalNameLike(String name);

@@ -20,7 +20,7 @@ public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEnt
JOIN HsOfficePersonEntity person ON person.uuid = rel.holder.uuid
WHERE :name is null
OR partner.details.birthName like concat(cast(:name as text), '%')
OR contact.label like concat(cast(:name as text), '%')
OR contact.caption like concat(cast(:name as text), '%')
OR person.tradeName like concat(cast(:name as text), '%')
OR person.givenName like concat(cast(:name as text), '%')
OR person.familyName like concat(cast(:name as text), '%')

@@ -33,10 +33,10 @@ public class HsOfficePersonController implements HsOfficePersonsApi {
public ResponseEntity<List<HsOfficePersonResource>> listPersons(
final String currentUser,
final String assumedRoles,
final String label) {
final String caption) {
context.define(currentUser, assumedRoles);
final var entities = personRepo.findPersonByOptionalNameLike(label);
final var entities = personRepo.findPersonByOptionalNameLike(caption);
final var resources = mapper.mapList(entities, HsOfficePersonResource.class);
return ResponseEntity.ok(resources);

@@ -9,7 +9,7 @@ components:
uuid:
type: string
format: uuid
label:
caption:
type: string
postalAddress:
type: string
@@ -21,7 +21,7 @@ components:
HsOfficeContactInsert:
type: object
properties:
label:
caption:
type: string
postalAddress:
type: string
@@ -30,12 +30,12 @@ components:
phoneNumbers:
$ref: '#/components/schemas/HsOfficeContactPhoneNumbers'
required:
- label
- caption
HsOfficeContactPatch:
type: object
properties:
label:
caption:
type: string
nullable: true
postalAddress:

@@ -12,7 +12,7 @@ get:
required: false
schema:
type: string
description: Prefix of label to filter the results.
description: Prefix of caption to filter the results.
responses:
"200":
description: OK

@@ -12,7 +12,7 @@ get:
required: false
schema:
type: string
description: Prefix of label to filter the results.
description: Prefix of caption to filter the results.
responses:
"200":
description: OK

@@ -8,7 +8,7 @@ create table if not exists hs_office_contact
(
uuid uuid unique references RbacObject (uuid) initially deferred,
version int not null default 0,
label varchar(128) not null,
caption varchar(128) not null,
postalAddress text,
emailAddresses jsonb not null,
phoneNumbers jsonb not null

@@ -82,7 +82,7 @@ execute procedure insertTriggerForHsOfficeContact_tf();
call generateRbacIdentityViewFromProjection('hs_office_contact',
$idName$
label
caption
$idName$);
--//
@@ -92,10 +92,10 @@ call generateRbacIdentityViewFromProjection('hs_office_contact',
-- ----------------------------------------------------------------------------
call generateRbacRestrictedView('hs_office_contact',
$orderBy$
label
caption
$orderBy$,
$updates$
label = new.label,
caption = new.caption,
postalAddress = new.postalAddress,
emailAddresses = new.emailAddresses,
phoneNumbers = new.phoneNumbers

@@ -8,28 +8,28 @@
/*
Creates a single contact test record.
*/
create or replace procedure createHsOfficeContactTestData(contLabel varchar)
create or replace procedure createHsOfficeContactTestData(contCaption varchar)
language plpgsql as $$
declare
currentTask varchar;
postalAddr varchar;
emailAddr varchar;
begin
currentTask = 'creating contact test-data ' || contLabel;
currentTask = 'creating contact test-data ' || contCaption;
execute format('set local hsadminng.currentTask to %L', currentTask);
emailAddr = 'contact-admin@' || cleanIdentifier(contLabel) || '.example.com';
emailAddr = 'contact-admin@' || cleanIdentifier(contCaption) || '.example.com';
call defineContext(currentTask);
perform createRbacUser(emailAddr);
call defineContext(currentTask, null, emailAddr);
postalAddr := E'Vorname Nachname\nStraße Hnr\nPLZ Stadt';
raise notice 'creating test contact: %', contLabel;
raise notice 'creating test contact: %', contCaption;
insert
into hs_office_contact (label, postaladdress, emailaddresses, phonenumbers)
into hs_office_contact (caption, postaladdress, emailaddresses, phonenumbers)
values (
contLabel,
contCaption,
postalAddr,
('{ "main": "' || emailAddr || '" }')::jsonb,
('{ "phone_office": "+49 123 1234567" }')::jsonb

@@ -12,7 +12,7 @@ create or replace procedure createHsOfficeRelationTestData(
holderPersonName varchar,
relationType HsOfficeRelationType,
anchorPersonName varchar,
contactLabel varchar,
contactCaption varchar,
mark varchar default null)
language plpgsql as $$
declare
@@ -44,9 +44,9 @@ begin
raise exception 'holderPerson "%" not found', holderPersonName;
end if;
select c.* into contact from hs_office_contact c where c.label = contactLabel;
select c.* into contact from hs_office_contact c where c.caption = contactCaption;
if contact is null then
raise exception 'contact "%" not found', contactLabel;
raise exception 'contact "%" not found', contactCaption;
end if;
raise notice 'creating test relation: %', idName;
@@ -74,7 +74,7 @@ begin
for t in startCount..endCount
loop
select p.* from hs_office_person p where tradeName = intToVarChar(t, 4) into person;
select c.* from hs_office_contact c where c.label = intToVarChar(t, 4) || '#' || t into contact;
select c.* from hs_office_contact c where c.caption = intToVarChar(t, 4) || '#' || t into contact;
call createHsOfficeRelationTestData(person.uuid, contact.uuid, 'REPRESENTATIVE');
commit;

@@ -12,7 +12,7 @@ create or replace procedure createHsOfficePartnerTestData(
mandantTradeName varchar,
newPartnerNumber numeric(5),
partnerPersonName varchar,
contactLabel varchar )
contactCaption varchar )
language plpgsql as $$
declare
currentTask varchar;
@@ -22,7 +22,7 @@ declare
relatedPerson hs_office_person;
relatedDetailsUuid uuid;
begin
idName := cleanIdentifier( partnerPersonName|| '-' || contactLabel);
idName := cleanIdentifier( partnerPersonName|| '-' || contactCaption);
currentTask := 'creating partner test-data ' || idName;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask);

@@ -11,7 +11,7 @@
create or replace procedure createHsOfficeDebitorTestData(
withDebitorNumberSuffix numeric(5),
forPartnerPersonName varchar,
forBillingContactLabel varchar,
forBillingContactCaption varchar,
withDefaultPrefix varchar
)
language plpgsql as $$
@@ -21,7 +21,7 @@ declare
relatedDebitorRelUuid uuid;
relatedBankAccountUuid uuid;
begin
idName := cleanIdentifier( forPartnerPersonName|| '-' || forBillingContactLabel);
idName := cleanIdentifier( forPartnerPersonName|| '-' || forBillingContactCaption);
currentTask := 'creating debitor test-data ' || idName;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask);