Compare commits

..

No commits in common. "ddfe8b68cf030e7d67555ff5e930c342bbfc0326" and "d1d0dda3739cbad90f633e7c12d968daac55b604" have entirely different histories.

8 changed files with 45 additions and 92 deletions

52
Jenkinsfile vendored
View File

@ -1,52 +0,0 @@
pipeline {
agent any
triggers {
pollSCM('H/1 * * * *')
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage ('Compile & Test') {
agent {
docker {
image 'eclipse-temurin:21-jdk'
args '-v "$PWD":/app'
reuseNode true
}
}
steps {
sh './gradlew clean check -x pitest -x dependencyCheckAnalyze'
}
}
stage('Archive Test Results') {
steps {
// archive test results
junit 'build/test-results/test/*.xml'
// archive the JaCoCo coverage report in XML and HTML format
publishHTML(target: [
reportDir: 'build/reports/jacoco/test/html',
reportFiles: 'index.html',
reportName: 'JaCoCo Code Coverage Report'
])
jacoco(execPattern: '**/jacoco.exec',
classPattern: 'build/classes/java/main',
sourcePattern: 'src/main/java',
exclusionPattern: '')
}
}
}
post {
always {
cleanWs()
}
}
}

View File

@ -53,11 +53,14 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
String contactData) { String contactData) {
context.define(currentSubject, assumedRoles); context.define(currentSubject, assumedRoles);
final List<HsOfficeRelationRbacEntity> entities = final var entities =
relationRbacRepo.findRelationRelatedToPersonUuidRelationTypePersonAndContactData( ( personData == null && contactData == null )
personUuid, ? relationRbacRepo.findRelationRelatedToPersonUuidAndRelationType(personUuid,
relationType == null ? null : HsOfficeRelationType.valueOf(relationType.name()), relationType == null ? null : HsOfficeRelationType.valueOf(relationType.name()))
personData, contactData); : relationRbacRepo.findRelationRelatedToPersonUuidRelationTypePersonAndContactData(
personUuid,
relationType == null ? null : HsOfficeRelationType.valueOf(relationType.name()),
forLike(personData), forLike(contactData));
final var resources = mapper.mapList(entities, HsOfficeRelationResource.class, final var resources = mapper.mapList(entities, HsOfficeRelationResource.class,
RELATION_ENTITY_TO_RESOURCE_POSTMAPPER); RELATION_ENTITY_TO_RESOURCE_POSTMAPPER);
@ -149,6 +152,10 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
return ResponseEntity.ok(mapped); return ResponseEntity.ok(mapped);
} }
private String forLike(final String text) {
return text == null ? null : ("%" + text.toLowerCase() + "%");
}
final BiConsumer<HsOfficeRelationRbacEntity, HsOfficeRelationResource> RELATION_ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> { final BiConsumer<HsOfficeRelationRbacEntity, HsOfficeRelationResource> RELATION_ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
resource.setAnchor(mapper.map(entity.getAnchor(), HsOfficePersonResource.class)); resource.setAnchor(mapper.map(entity.getAnchor(), HsOfficePersonResource.class));
resource.setHolder(mapper.map(entity.getHolder(), HsOfficePersonResource.class)); resource.setHolder(mapper.map(entity.getHolder(), HsOfficePersonResource.class));

View File

@ -12,48 +12,50 @@ public interface HsOfficeRelationRbacRepository extends Repository<HsOfficeRelat
Optional<HsOfficeRelationRbacEntity> findByUuid(UUID id); Optional<HsOfficeRelationRbacEntity> findByUuid(UUID id);
default List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuidAndRelationType(@NotNull UUID personUuid, HsOfficeRelationType relationType) {
return findRelationRelatedToPersonUuidAndRelationTypeString(personUuid, relationType == null ? null : relationType.toString());
}
@Query(value = """ @Query(value = """
SELECT p.* FROM hs_office.relation_rv AS p SELECT p.* FROM hs_office.relation_rv AS p
WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid
""", nativeQuery = true) """, nativeQuery = true)
List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid); List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid);
@Query(value = """
SELECT p.* FROM hs_office.relation_rv AS p
WHERE (:relationType IS NULL OR p.type = cast(:relationType AS hs_office.RelationType))
AND ( p.anchorUuid = :personUuid OR p.holderUuid = :personUuid)
""", nativeQuery = true)
List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuidAndRelationTypeString(@NotNull UUID personUuid, String relationType);
/** /**
* Finds relations by a conjunction of optional criteria, including anchorPerson, holderPerson and contact data. * Finds relations by a conjunction of optional criteria, including anchorPerson, holderPerson and contact data.
* * *
* @param personUuid the optional UUID of the anchorPerson or holderPerson * @param personUuid the optional UUID of the anchorPerson or holderPerson
* @param relationType the type of the relation * @param relationType the type of the relation
* @param personData a string to match the persons tradeName, familyName or givenName (use '%' for wildcard), case ignored * @param personData a lower-case string to match the persons tradeName, familyName or givenName (use '%' for wildcard)
* @param contactData a string to match the contacts caption, postalAddress, emailAddresses or phoneNumbers (use '%' for wildcard), case ignored * @param contactData a lower-case string to match the contacts caption, postalAddress, emailAddresses or phoneNumbers (use '%' for wildcard)
* @return a list of (accessible) relations which match all given criteria * @return a list of (accessible) relations which match all given criteria
*/ */
default List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuidRelationTypePersonAndContactData(
UUID personUuid,
HsOfficeRelationType relationType,
String personData,
String contactData) {
return findRelationRelatedToPersonUuidRelationTypePersonAndContactDataImpl(
personUuid, toStringOrNull(relationType), forLike(personData), forLike(contactData));
}
@Query(value = """ @Query(value = """
SELECT rel FROM HsOfficeRelationRbacEntity AS rel SELECT rel FROM HsOfficeRelationRbacEntity AS rel
WHERE (:relationType IS NULL OR CAST(rel.type AS String) = :relationType) WHERE (:relationType IS NULL OR CAST(rel.type AS String) = CAST(:relationType AS String))
AND ( :personUuid IS NULL AND ( :personUuid IS NULL OR
OR rel.anchor.uuid = :personUuid OR rel.holder.uuid = :personUuid ) rel.anchor.uuid = :personUuid OR rel.holder.uuid = :personUuid )
AND ( :personData IS NULL AND ( :personData IS NULL OR
OR lower(rel.anchor.tradeName) LIKE :personData OR lower(rel.holder.tradeName) LIKE :personData lower(rel.anchor.tradeName) LIKE :personData OR lower(rel.holder.tradeName) LIKE :personData OR
OR lower(rel.anchor.familyName) LIKE :personData OR lower(rel.holder.familyName) LIKE :personData lower(rel.anchor.familyName) LIKE :personData OR lower(rel.holder.familyName) LIKE :personData OR
OR lower(rel.anchor.givenName) LIKE :personData OR lower(rel.holder.givenName) LIKE :personData ) lower(rel.anchor.givenName) LIKE :personData OR lower(rel.holder.givenName) LIKE :personData )
AND ( :contactData IS NULL AND ( :contactData IS NULL OR
OR lower(rel.contact.caption) LIKE :contactData lower(rel.contact.caption) LIKE :contactData OR
OR lower(rel.contact.postalAddress) LIKE :contactData lower(rel.contact.postalAddress) LIKE :contactData OR
OR lower(CAST(rel.contact.emailAddresses AS String)) LIKE :contactData lower(CAST(rel.contact.emailAddresses AS String)) LIKE :contactData OR
OR lower(CAST(rel.contact.phoneNumbers AS String)) LIKE :contactData ) lower(CAST(rel.contact.phoneNumbers AS String)) LIKE :contactData )
""") """)
List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuidRelationTypePersonAndContactDataImpl( List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuidRelationTypePersonAndContactData(
UUID personUuid, UUID personUuid,
String relationType, HsOfficeRelationType relationType,
String personData, String personData,
String contactData); String contactData);
@ -62,12 +64,4 @@ public interface HsOfficeRelationRbacRepository extends Repository<HsOfficeRelat
long count(); long count();
int deleteByUuid(UUID uuid); int deleteByUuid(UUID uuid);
private static String forLike(final String text) {
return text == null ? null : ("%" + text.toLowerCase() + "%");
}
private static String toStringOrNull(final HsOfficeRelationType relationType) {
return relationType == null ? null : relationType.name();
}
} }

View File

@ -6,6 +6,7 @@ import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator; import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
import net.hostsharing.hsadminng.rbac.test.cust.TestCustomerEntity;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;

View File

@ -1,6 +1,7 @@
package net.hostsharing.hsadminng.hs.office.membership; package net.hostsharing.hsadminng.hs.office.membership;
import io.hypersistence.utils.hibernate.type.range.Range; import io.hypersistence.utils.hibernate.type.range.Range;
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator; import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.person; package net.hostsharing.hsadminng.hs.office.person;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator; import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -193,7 +193,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
.findFirst().orElseThrow(); .findFirst().orElseThrow();
// when: // when:
final var result = relationRbacRepo.findRelationRelatedToPersonUuidRelationTypePersonAndContactData(person.getUuid(), null, null, null); final var result = relationRbacRepo.findRelationRelatedToPersonUuidAndRelationType(person.getUuid(), null);
// then: // then:
exactlyTheseRelationsAreReturned( exactlyTheseRelationsAreReturned(

View File

@ -1,6 +1,7 @@
package net.hostsharing.hsadminng.hs.office.sepamandate; package net.hostsharing.hsadminng.hs.office.sepamandate;
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator; import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;