add SEPA-Mandate entity+repository
This commit is contained in:
parent
7f5b2358d3
commit
bece972a4e
@ -1,5 +1,7 @@
|
||||
package net.hostsharing.hsadminng;
|
||||
|
||||
import net.hostsharing.hsadminng.errors.DisplayName;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -28,7 +30,16 @@ public final class Stringify<B> {
|
||||
|
||||
private Stringify(final Class<B> clazz, final String name) {
|
||||
this.clazz = clazz;
|
||||
if (name != null) {
|
||||
this.name = name;
|
||||
} else {
|
||||
final var displayName = clazz.getAnnotation(DisplayName.class);
|
||||
if (displayName != null) {
|
||||
this.name = displayName.value();
|
||||
} else {
|
||||
this.name = clazz.getSimpleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Stringify<B> withProp(final String propName, final Function<B, ?> getter) {
|
||||
@ -53,7 +64,7 @@ public final class Stringify<B> {
|
||||
})
|
||||
.map(propVal -> propName(propVal, "=") + optionallyQuoted(propVal))
|
||||
.collect(Collectors.joining(separator));
|
||||
return (name != null ? name : object.getClass().getSimpleName()) + "(" + propValues + ")";
|
||||
return name + "(" + propValues + ")";
|
||||
}
|
||||
|
||||
public Stringify<B> withSeparator(final String separator) {
|
||||
|
@ -7,6 +7,7 @@ import net.hostsharing.hsadminng.Stringifyable;
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.UUID;
|
||||
|
@ -9,7 +9,7 @@ create table if not exists hs_office_sepamandate
|
||||
uuid uuid unique references RbacObject (uuid) initially deferred,
|
||||
debitorUuid uuid not null references hs_office_debitor(uuid),
|
||||
bankAccountUuid uuid not null references hs_office_bankaccount(uuid),
|
||||
reference varchar(96),
|
||||
reference varchar(96) not null,
|
||||
validity daterange not null
|
||||
);
|
||||
--//
|
||||
|
@ -1,21 +1,21 @@
|
||||
--liquibase formatted sql
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-office-sepaMandate-rbac-OBJECT:1 endDelimiter:--//
|
||||
--changeset hs-office-sepamandate-rbac-OBJECT:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
call generateRelatedRbacObject('hs_office_sepaMandate');
|
||||
call generateRelatedRbacObject('hs_office_sepamandate');
|
||||
--//
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-office-sepaMandate-rbac-ROLE-DESCRIPTORS:1 endDelimiter:--//
|
||||
--changeset hs-office-sepamandate-rbac-ROLE-DESCRIPTORS:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
call generateRbacRoleDescriptors('hsOfficeSepaMandate', 'hs_office_sepaMandate');
|
||||
call generateRbacRoleDescriptors('hsOfficeSepaMandate', 'hs_office_sepamandate');
|
||||
--//
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-office-sepaMandate-rbac-ROLES-CREATION:1 endDelimiter:--//
|
||||
--changeset hs-office-sepamandate-rbac-ROLES-CREATION:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
@ -36,10 +36,8 @@ begin
|
||||
|
||||
if TG_OP = 'INSERT' then
|
||||
|
||||
|
||||
-- === ATTENTION: code generated from related Mermaid flowchart: ===
|
||||
|
||||
|
||||
perform createRoleWithGrants(
|
||||
hsOfficeSepaMandateOwner(NEW),
|
||||
permissions => array['*'],
|
||||
@ -73,7 +71,6 @@ begin
|
||||
|
||||
-- === END of code generated from Mermaid flowchart. ===
|
||||
|
||||
|
||||
else
|
||||
raise exception 'invalid usage of TRIGGER';
|
||||
end if;
|
||||
@ -86,23 +83,23 @@ end; $$;
|
||||
*/
|
||||
create trigger createRbacRolesForHsOfficeSepaMandate_Trigger
|
||||
after insert
|
||||
on hs_office_sepaMandate
|
||||
on hs_office_sepamandate
|
||||
for each row
|
||||
execute procedure hsOfficeSepaMandateRbacRolesTrigger();
|
||||
--//
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-office-sepaMandate-rbac-IDENTITY-VIEW:1 endDelimiter:--//
|
||||
--changeset hs-office-sepamandate-rbac-IDENTITY-VIEW:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
call generateRbacIdentityView('hs_office_sepaMandate', idNameExpression => 'target.reference');
|
||||
call generateRbacIdentityView('hs_office_sepamandate', idNameExpression => 'target.reference');
|
||||
--//
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-office-sepaMandate-rbac-RESTRICTED-VIEW:1 endDelimiter:--//
|
||||
--changeset hs-office-sepamandate-rbac-RESTRICTED-VIEW:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
call generateRbacRestrictedView('hs_office_sepaMandate',
|
||||
call generateRbacRestrictedView('hs_office_sepamandate',
|
||||
orderby => 'target.reference',
|
||||
columnUpdates => $updates$
|
||||
validity = new.validity
|
||||
@ -111,7 +108,7 @@ call generateRbacRestrictedView('hs_office_sepaMandate',
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-office-sepaMandate-rbac-NEW-SepaMandate:1 endDelimiter:--//
|
||||
--changeset hs-office-sepamandate-rbac-NEW-SepaMandate:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
/*
|
||||
Creates a global permission for new-sepaMandate and assigns it to the hostsharing admins role.
|
||||
@ -146,9 +143,9 @@ end; $$;
|
||||
/**
|
||||
Checks if the user or assumed roles are allowed to create a new customer.
|
||||
*/
|
||||
create trigger hs_office_sepaMandate_insert_trigger
|
||||
create trigger hs_office_sepamandate_insert_trigger
|
||||
before insert
|
||||
on hs_office_sepaMandate
|
||||
on hs_office_sepamandate
|
||||
for each row
|
||||
-- TODO.spec: who is allowed to create new sepaMandates
|
||||
when ( not hasAssumedRole() )
|
||||
|
@ -31,7 +31,7 @@ begin
|
||||
raise notice '- using debitor (%): %', relatedDebitor.uuid, relatedDebitor;
|
||||
raise notice '- using bankAccount (%): %', relatedBankAccount.uuid, relatedBankAccount;
|
||||
insert
|
||||
into hs_office_sepaMandate (uuid, debitoruuid, bankAccountuuid, reference, validity)
|
||||
into hs_office_sepamandate (uuid, debitoruuid, bankAccountuuid, reference, validity)
|
||||
values (uuid_generate_v4(), relatedDebitor.uuid, relatedBankAccount.uuid, 'ref'||idName, daterange('20221001' , '20261231', '[]'));
|
||||
end; $$;
|
||||
--//
|
||||
|
@ -77,7 +77,7 @@ public class ArchitectureTest {
|
||||
public static final ArchRule HsOfficeBankAccountPackageRule = classes()
|
||||
.that().resideInAPackage("..hs.office.bankaccount..")
|
||||
.should().onlyBeAccessed().byClassesThat()
|
||||
.resideInAnyPackage("..hs.office.bankaccount..", "..hs.office.debitor..");
|
||||
.resideInAnyPackage("..hs.office.bankaccount..", "..hs.office.sepamandate..", "..hs.office.debitor..");
|
||||
|
||||
@ArchTest
|
||||
@SuppressWarnings("unused")
|
||||
@ -86,7 +86,6 @@ public class ArchitectureTest {
|
||||
.should().onlyBeAccessed().byClassesThat()
|
||||
.resideInAnyPackage("..hs.office.partner..", "..hs.office.debitor..");
|
||||
|
||||
|
||||
@ArchTest
|
||||
@SuppressWarnings("unused")
|
||||
public static final ArchRule acceptsAnnotationOnMethodsRule = methods()
|
||||
|
@ -9,7 +9,7 @@ import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.LEGA
|
||||
|
||||
public class TestHsOfficePartner {
|
||||
|
||||
public static final HsOfficePartnerEntity testLtd = HsOfficePartnerWithLegalPerson("Test Ltd.");
|
||||
public static final HsOfficePartnerEntity testPartner = HsOfficePartnerWithLegalPerson("Test Ltd.");
|
||||
|
||||
static public HsOfficePartnerEntity HsOfficePartnerWithLegalPerson(final String tradeName) {
|
||||
return HsOfficePartnerEntity.builder()
|
||||
|
@ -30,6 +30,7 @@ spring:
|
||||
logging:
|
||||
level:
|
||||
liquibase: INFO
|
||||
org.hibernate.SQL: DEBUG
|
||||
org.hibernate.type.descriptor.sql.BasicBinder: TRACE
|
||||
X.org.hibernate.SQL: DEBUG
|
||||
X.org.hibernate.type.descriptor.sql.BasicBinder: TRACE
|
||||
X.org.springframework.jdbc.core: TRACE
|
||||
net.ttddyy.dsproxy.listener: debug
|
||||
|
Loading…
Reference in New Issue
Block a user