rbac-optimization #80

Merged
hsh-michaelhoennig merged 14 commits from rbac-optimization into master 2024-07-27 10:18:08 +02:00
9 changed files with 113 additions and 25 deletions
Showing only changes of commit a27ac13fad - Show all commits

View File

@ -21,6 +21,7 @@ import org.hibernate.annotations.NotFoundAction;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
@ -77,7 +78,7 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
@Version @Version
private int version; private int version;
@ManyToOne @ManyToOne(fetch = FetchType.LAZY)
@JoinFormula( @JoinFormula(
referencedColumnName = "uuid", referencedColumnName = "uuid",
value = """ value = """
@ -98,7 +99,7 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
@Pattern(regexp = TWO_DECIMAL_DIGITS) @Pattern(regexp = TWO_DECIMAL_DIGITS)
private String debitorNumberSuffix; private String debitorNumberSuffix;
@ManyToOne(cascade = { PERSIST, MERGE, REFRESH, DETACH }, optional = false) @ManyToOne(cascade = { PERSIST, MERGE, REFRESH, DETACH }, optional = false, fetch = FetchType.LAZY)
@JoinColumn(name = "debitorreluuid", nullable = false) @JoinColumn(name = "debitorreluuid", nullable = false)
private HsOfficeRelationEntity debitorRel; private HsOfficeRelationEntity debitorRel;
@ -117,7 +118,7 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
@Column(name = "vatreversecharge") @Column(name = "vatreversecharge")
private boolean vatReverseCharge; private boolean vatReverseCharge;
@ManyToOne @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "refundbankaccountuuid") @JoinColumn(name = "refundbankaccountuuid")
private HsOfficeBankAccountEntity refundBankAccount; private HsOfficeBankAccountEntity refundBankAccount;
@ -127,6 +128,7 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
@Override @Override
public HsOfficeDebitorEntity load() { public HsOfficeDebitorEntity load() {
RbacObject.super.load(); RbacObject.super.load();
partner.load();
debitorRel.load(); debitorRel.load();
if (refundBankAccount != null) { if (refundBankAccount != null) {
refundBankAccount.load(); refundBankAccount.load();

View File

@ -21,6 +21,7 @@ import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.EnumType; import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated; import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
@ -80,7 +81,7 @@ public class HsOfficeMembershipEntity implements RbacObject<HsOfficeMembershipEn
@Version @Version
private int version; private int version;
@ManyToOne @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "partneruuid") @JoinColumn(name = "partneruuid")
private HsOfficePartnerEntity partner; private HsOfficePartnerEntity partner;

View File

@ -28,15 +28,6 @@ public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEnt
List<HsOfficePartnerEntity> findPartnerByOptionalNameLike(String name); List<HsOfficePartnerEntity> findPartnerByOptionalNameLike(String name);
HsOfficePartnerEntity findPartnerByPartnerNumber(Integer partnerNumber); HsOfficePartnerEntity findPartnerByPartnerNumber(Integer partnerNumber);
@Query("""
SELECT DISTINCT partner
FROM HsOfficePartnerEntity partner
JOIN HsOfficeRelationEntity pRel
ON pRel.uuid = partner.partnerRel.uuid AND pRel.type = 'PARTNER'
WHERE pRel.holder.uuid = :partnerPersonUuid
""")
HsOfficePartnerEntity findPartnerByPartnerPersonUuid(UUID partnerPersonUuid);
HsOfficePartnerEntity save(final HsOfficePartnerEntity entity); HsOfficePartnerEntity save(final HsOfficePartnerEntity entity);
long count(); long count();

View File

@ -3,7 +3,7 @@
-- ============================================================================ -- ============================================================================
-- PG-STAT-STATEMENTS-EXTENSION -- PG-STAT-STATEMENTS-EXTENSION
--changeset pg-stat-statements-extension:1 runOnChange=true endDelimiter:--// --changeset pg-stat-statements-extension:1 context:pg_stat_statements endDelimiter:--//
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
/* /*
Makes improved uuid generation available. Makes improved uuid generation available.

View File

@ -750,7 +750,6 @@ begin
end if; end if;
end; end;
$$; $$;
ALTER FUNCTION queryAccessibleObjectUuidsOfSubjectIds SET enable_hashjoin = off;
--// --//
hsh-michaelhoennig marked this conversation as resolved Outdated

entfernen

entfernen
-- ============================================================================ -- ============================================================================

View File

@ -44,8 +44,6 @@ create table if not exists hs_hosting_asset
constraint chk_hs_hosting_asset_has_booking_item_or_parent_asset constraint chk_hs_hosting_asset_has_booking_item_or_parent_asset
check (bookingItemUuid is not null or parentAssetUuid is not null or type in ('DOMAIN_SETUP', 'IPV4_NUMBER', 'IPV6_NUMBER')) check (bookingItemUuid is not null or parentAssetUuid is not null or type in ('DOMAIN_SETUP', 'IPV4_NUMBER', 'IPV6_NUMBER'))
); );
-- create index on hs_hosting_asset (identifier);
-- create index on hs_hosting_asset (type);
--// --//
hsh-michaelhoennig marked this conversation as resolved Outdated

löschen

löschen

View File

@ -113,6 +113,38 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}, },
"debitorNumber": 1000111, "debitorNumber": 1000111,
"debitorNumberSuffix": 11, "debitorNumberSuffix": 11,
"partner": {
"partnerNumber": 10001,
"partnerRel": {
"anchor": {
"personType": "LEGAL_PERSON",
"tradeName": "Hostsharing eG",
"givenName": null,
"familyName": null
},
"holder": {
"personType": "LEGAL_PERSON",
"tradeName": "First GmbH",
"givenName": null,
"familyName": null
},
"type": "PARTNER",
"mark": null,
"contact": {
"caption": "first contact",
"emailAddresses": { "main": "contact-admin@firstcontact.example.com" },
"phoneNumbers": { "phone_office": "+49 123 1234567" }
}
},
"details": {
"registrationOffice": "Hamburg",
"registrationNumber": "RegNo123456789",
"birthName": null,
"birthPlace": null,
"birthday": null,
"dateOfDeath": null
}
},
"billable": true, "billable": true,
hsh-michaelhoennig marked this conversation as resolved Outdated

muss wieder rein

muss wieder rein
"vatId": null, "vatId": null,
"vatCountryCode": null, "vatCountryCode": null,
@ -136,6 +168,21 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}, },
"debitorNumber": 1000212, "debitorNumber": 1000212,
"debitorNumberSuffix": 12, "debitorNumberSuffix": 12,
"partner": {
"partnerNumber": 10002,
"partnerRel": {
"anchor": {"tradeName": "Hostsharing eG"},
"holder": {"tradeName": "Second e.K."},
"type": "PARTNER",
"contact": {
"emailAddresses": { "main": "contact-admin@secondcontact.example.com" }
}
},
"details": {
"registrationOffice": "Hamburg",
"registrationNumber": "RegNo123456789"
}
},
"billable": true, "billable": true,
"vatId": null, "vatId": null,
"vatCountryCode": null, "vatCountryCode": null,
@ -155,6 +202,21 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}, },
"debitorNumber": 1000313, "debitorNumber": 1000313,
"debitorNumberSuffix": 13, "debitorNumberSuffix": 13,
"partner": {
"partnerNumber": 10003,
"partnerRel": {
"anchor": {"tradeName": "Hostsharing eG"},
"holder": {"tradeName": "Third OHG"},
"type": "PARTNER",
"contact": {
"emailAddresses": { "main": "contact-admin@thirdcontact.example.com" }
}
},
"details": {
"registrationOffice": "Hamburg",
"registrationNumber": "RegNo123456789"
}
},
"billable": true, "billable": true,
"vatId": null, "vatId": null,
"vatCountryCode": null, "vatCountryCode": null,
@ -295,6 +357,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("debitorRel.contact.caption", is(givenContact.getCaption())) .body("debitorRel.contact.caption", is(givenContact.getCaption()))
.body("partner.partnerRel.holder.tradeName", is(givenPartner.getPartnerRel().getHolder().getTradeName()))
.body("vatId", equalTo(null)) .body("vatId", equalTo(null))
.body("vatCountryCode", equalTo(null)) .body("vatCountryCode", equalTo(null))
.body("vatBusiness", equalTo(false)) .body("vatBusiness", equalTo(false))
@ -408,6 +471,25 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}, },
"debitorNumber": 1000111, "debitorNumber": 1000111,
"debitorNumberSuffix": 11, "debitorNumberSuffix": 11,
"partner": {
"partnerNumber": 10001,
"partnerRel": {
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG"},
"holder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH"},
"type": "PARTNER",
"mark": null,
"contact": {
"caption": "first contact",
"postalAddress": "Vorname Nachname\\nStraße Hnr\\nPLZ Stadt",
"emailAddresses": { "main": "contact-admin@firstcontact.example.com" },
"phoneNumbers": { "phone_office": "+49 123 1234567" }
}
},
"details": {
"registrationOffice": "Hamburg",
"registrationNumber": "RegNo123456789"
}
},
"billable": true, "billable": true,
"vatBusiness": true, "vatBusiness": true,
"vatReverseCharge": false, "vatReverseCharge": false,
@ -501,6 +583,24 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
}, },
"debitorNumber": 10004${debitorNumberSuffix}, "debitorNumber": 10004${debitorNumberSuffix},
"debitorNumberSuffix": ${debitorNumberSuffix}, "debitorNumberSuffix": ${debitorNumberSuffix},
"partner": {
"partnerNumber": 10004,
"partnerRel": {
"anchor": { "tradeName": "Hostsharing eG" },
"holder": { "tradeName": "Fourth eG" },
"type": "PARTNER",
"mark": null,
"contact": { "caption": "fourth contact" }
},
"details": {
"registrationOffice": "Hamburg",
"registrationNumber": "RegNo123456789",
"birthName": null,
"birthPlace": null,
"birthday": null,
"dateOfDeath": null
}
},
"billable": true, "billable": true,
"vatId": "VAT222222", "vatId": "VAT222222",
"vatCountryCode": "AA", "vatCountryCode": "AA",
@ -623,7 +723,6 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0);
final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth contact").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth contact").get(0);
final var newDebitor = HsOfficeDebitorEntity.builder() final var newDebitor = HsOfficeDebitorEntity.builder()
.partner(givenPartner)
.debitorNumberSuffix(nextDebitorSuffix()) .debitorNumberSuffix(nextDebitorSuffix())
.billable(true) .billable(true)
.debitorRel( .debitorRel(

View File

@ -613,7 +613,6 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
final var givenBankAccount = final var givenBankAccount =
bankAccountHolder != null ? one(bankAccountRepo.findByOptionalHolderLike(bankAccountHolder)) : null; bankAccountHolder != null ? one(bankAccountRepo.findByOptionalHolderLike(bankAccountHolder)) : null;
final var newDebitor = HsOfficeDebitorEntity.builder() final var newDebitor = HsOfficeDebitorEntity.builder()
.partner(givenPartner)
.debitorNumberSuffix("20") .debitorNumberSuffix("20")
.debitorRel(HsOfficeRelationEntity.builder() .debitorRel(HsOfficeRelationEntity.builder()
.type(HsOfficeRelationType.DEBITOR) .type(HsOfficeRelationType.DEBITOR)

View File

@ -26,10 +26,9 @@ spring:
liquibase: liquibase:
change-log: classpath:/db/changelog/db.changelog-master.yaml change-log: classpath:/db/changelog/db.changelog-master.yaml
contexts: tc,test,dev contexts: tc,test,dev,pg_stat_statements
# FIXME: re-activate? logging:
#logging: level:
# level: liquibase: INFO
# liquibase: INFO net.ttddyy.dsproxy.listener: DEBUG
# net.ttddyy.dsproxy.listener: DEBUG