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

View File

@ -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);

View File

@ -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);

View File

@ -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())));

View File

@ -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);

View File

@ -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);

View File

@ -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), '%')

View File

@ -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);