Skip to content

Commit

Permalink
Merge branch 'develop' into tsys-release-2024-05-28
Browse files Browse the repository at this point in the history
  • Loading branch information
web-mi committed May 28, 2024
2 parents 105a507 + 2a458e6 commit 4116ad0
Show file tree
Hide file tree
Showing 32 changed files with 339 additions and 482 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dockerImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
push_to_registry:
strategy:
matrix:
registry: ["docker.pkg.github.com", "ghcr.io"]
registry: ["ghcr.io"]
needs: [test]
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
Expand Down
53 changes: 31 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.12</version>
<version>2.7.18</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -30,7 +30,7 @@
<openapi-generator-maven.version>6.2.1</openapi-generator-maven.version>
<springfox-boot-starter.version>3.0.0</springfox-boot-starter.version>
<spring-data-mongodb.version>3.3.5</spring-data-mongodb.version>
<spring-security.version>5.7.5</spring-security.version>
<spring-security.version>5.7.12</spring-security.version>
<ehcache.version>2.10.9.2</ehcache.version>
</properties>

Expand Down Expand Up @@ -64,6 +64,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
Expand All @@ -73,7 +74,6 @@
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.1.6.Final</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
Expand Down Expand Up @@ -109,13 +109,6 @@
<version>4.3.1</version>
</dependency>

<!-- SpringFox: generate YAML file from POJOs and generate documentation -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${springfox-boot-starter.version}</version>
</dependency>

<!-- Keycloak dependencies -->
<dependency>
<groupId>org.keycloak</groupId>
Expand Down Expand Up @@ -155,7 +148,6 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>

<dependency>
Expand All @@ -173,7 +165,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.3.5.RELEASE</version>
</dependency>

<dependency>
Expand All @@ -200,23 +191,23 @@
<exclusions>
</exclusions>
</dependency>

<dependency>
<artifactId>powermock-module-junit4</artifactId>
<groupId>org.powermock</groupId>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>4.13.0</version>
<scope>test</scope>
<version>2.0.2</version>
</dependency>
<dependency>
<artifactId>powermock-api-mockito2</artifactId>
<groupId>org.powermock</groupId>
<scope>test</scope>
<version>2.0.2</version>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo.spring26x</artifactId>
<version>4.13.0</version>
</dependency>

<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
</dependency>

<!-- EasyRandom -->
Expand All @@ -242,6 +233,24 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>5.30.0</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_7</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-spring</artifactId>
<version>5.9.0</version>
</dependency>
</dependencies>
</plugin>

<!-- OpenApi codegen maven plugin: generates api stubs -->
<plugin>
<groupId>org.openapitools</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class StatisticsServiceApplication {

static {
System.setProperty("os.arch", "i686_64");
}

public static void main(String[] args) {
SpringApplication.run(StatisticsServiceApplication.class, args);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public class RegistrationStatisticsDTOConverter {
public RegistrationStatisticsResponseDTO convertStatisticsEvent(
StatisticsEvent rawEvent, StatisticEventsContainer statisticEventsContainer) {
RegistrationMetaData metadata = (RegistrationMetaData) rawEvent.getMetaData();
String maxArchiveDate = findMaxArchiveDate(rawEvent.getSessionId(), statisticEventsContainer.getArchiveSessionEvents());
String deleteAccountDate = findDeleteAccountDate(rawEvent.getUser().getId(), statisticEventsContainer.getDeleteAccountEvents());
String maxArchiveDate = findMaxArchiveDate(rawEvent.getSessionId(),
statisticEventsContainer.getArchiveSessionEvents());
String deleteAccountDate = findDeleteAccountDate(rawEvent.getUser().getId(),
statisticEventsContainer.getDeleteAccountEvents());

return new RegistrationStatisticsResponseDTO()
.userId(rawEvent.getUser().getId())
Expand All @@ -38,9 +40,14 @@ public RegistrationStatisticsResponseDTO convertStatisticsEvent(
.postalCode(metadata.getPostalCode())
.referer(metadata.getReferer())
.attendedVideoCallsCount(
countEventsPerAdviceSeekerMatchingOnMetadata(rawEvent.getUser().getId(), statisticEventsContainer.getVideoCallStartedEvents()))
.appointmentsBookedCount(countEventsPerAdviceSeekerMatchingOnMetadata(rawEvent.getUser().getId(), statisticEventsContainer.getBookingCreatedEvents()))
.consultantMessagesCount(countEventsPerAdviceSeekerMatchingOnMetadataByReceiverId(rawEvent.getUser().getId(), statisticEventsContainer.getConsultantMessageCreatedEvents()));
countEventsPerAdviceSeekerMatchingOnMetadata(rawEvent.getUser().getId(),
statisticEventsContainer.getVideoCallStartedEvents()))
.appointmentsBookedCount(
countEventsPerAdviceSeekerMatchingOnMetadata(rawEvent.getUser().getId(),
statisticEventsContainer.getBookingCreatedEvents()))
.consultantMessagesCount(
countEventsPerAdviceSeekerMatchingOnMetadataByReceiverId(rawEvent.getUser().getId(),
statisticEventsContainer.getConsultantMessageCreatedEvents()));
}

private Integer countEventsPerAdviceSeekerMatchingOnMetadata(String adviceSeekerId,
Expand All @@ -54,23 +61,27 @@ private Integer countEventsPerAdviceSeekerMatchingOnMetadataByReceiverId(String
Collection<StatisticsEvent> events) {

return events != null
? (int) getCountOfEventsPerAdviceSeekerMatchingOnMetadataByReceiverId(adviceSeekerId, events) : 0;
? (int) getCountOfEventsPerAdviceSeekerMatchingOnMetadataByReceiverId(adviceSeekerId,
events) : 0;
}

private long getCountOfEventsPerAdviceSeekerMatchingOnMetadata(String adviceSeekerId,
Collection<StatisticsEvent> statisticsEvents) {
return statisticsEvents.stream()
.filter(event -> event.getMetaData() instanceof AdviceSeekerAwareMetaData)
.filter(event -> {
AdviceSeekerAwareMetaData metaData = (AdviceSeekerAwareMetaData) event.getMetaData();
return metaData.getAdviceSeekerId() != null && metaData.getAdviceSeekerId()
.equals(adviceSeekerId);

})
.count();
}

private long getCountOfEventsPerAdviceSeekerMatchingOnMetadataByReceiverId(String adviceSeekerId,
Collection<StatisticsEvent> createMessageEvents) {
return createMessageEvents.stream()
.filter(event -> event.getMetaData() instanceof CreateMessageMetaData)
.filter(event -> {
CreateMessageMetaData metaData = (CreateMessageMetaData) event.getMetaData();
return metaData.getReceiverId() != null && metaData.getReceiverId()
Expand All @@ -83,14 +94,16 @@ private String getEndDate(String maxArchiveDate, String deleteAccountDate) {
return deleteAccountDate != null ? deleteAccountDate : maxArchiveDate;
}

private String findDeleteAccountDate(String userId, Collection<StatisticsEvent> deleteAccountEvents) {
private String findDeleteAccountDate(String userId,
Collection<StatisticsEvent> deleteAccountEvents) {
return deleteAccountEvents != null ? deleteAccountEvents.stream()
.filter(event -> event.getUser() != null && event.getUser().getId().equals(userId))
.map(event -> ((DeleteAccountMetaData) event.getMetaData()).getDeleteDate())
.findFirst().orElse(null) : null;
}

private String findMaxArchiveDate(Long sessionId, Collection<StatisticsEvent> archiveSessionEvents) {
private String findMaxArchiveDate(Long sessionId,
Collection<StatisticsEvent> archiveSessionEvents) {
var maxArchiveEvent = findMaxArchiveSessionEvent(sessionId, archiveSessionEvents);
if (maxArchiveEvent.isPresent()) {
ArchiveMetaData metaData = (ArchiveMetaData) maxArchiveEvent.get().getMetaData();
Expand All @@ -99,7 +112,8 @@ private String findMaxArchiveDate(Long sessionId, Collection<StatisticsEvent> ar
return null;
}

private Optional<StatisticsEvent> findMaxArchiveSessionEvent(Long sessionId, Collection<StatisticsEvent> archiveSessionEvents) {
private Optional<StatisticsEvent> findMaxArchiveSessionEvent(Long sessionId,
Collection<StatisticsEvent> archiveSessionEvents) {
return nonNull(archiveSessionEvents) ? archiveSessionEvents.stream()
.filter(event -> event.getSessionId() != null && event.getSessionId().equals(sessionId))
.max(comparing(StatisticsEvent::getTimestamp)) : Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.caritas.cob.statisticsservice.config;

import org.keycloak.adapters.KeycloakConfigResolver;
import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
Expand All @@ -25,4 +27,14 @@ public LocalValidatorFactoryBean validator(MessageSource messageSource) {
return validatorFactoryBean;
}

/**
* Use the KeycloakSpringBootConfigResolver to be able to save the Keycloak settings in the spring
* application properties.
*/
@Bean
public KeycloakConfigResolver keyCloakConfigResolver() {
return new KeycloakSpringBootConfigResolver();
}


}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ protected void configure(HttpSecurity http) throws Exception {
.anyRequest().denyAll();
}

/**
* Use the KeycloakSpringBootConfigResolver to be able to save the Keycloak settings in the spring
* application properties.
*/
@Bean
public KeycloakConfigResolver keyCloakConfigResolver() {
return new KeycloakSpringBootConfigResolver();
}

/**
* Change springs authentication strategy to be stateless (no session is being created).
Expand Down
Loading

0 comments on commit 4116ad0

Please sign in to comment.