Skip to content

Commit

Permalink
springboot 3.1.2 (#78)
Browse files Browse the repository at this point in the history
* springcloud output-bindings migration
* jaxb javax/jakarta compatibility pom

By convention and compatibility with springboot 3 (for example hibernate 6 uses jaxb) we use
api:
  javax.xml.bind:jaxb-api javax version 2.x
  jakarta.xml.bind:jakarta.xml.bind-api jakarta version 3+
runtime:
  com.sun.xml.bind:jaxb-impl javax version 2.x
  org.glassfish.jaxb:jaxb-runtime jakarta version 3+

Signed-off-by: Abdelsalem <abdelsalem.hedhili@rte-france.com>
Co-authored-by: HARPER Jon <jon.harper87@gmail.com>
  • Loading branch information
AbdelHedhili and jonenst authored Sep 22, 2023
1 parent 4308652 commit 6f8fd32
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 63 deletions.
36 changes: 22 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-parent-ws</artifactId>
<version>12</version>
<version>15</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -45,7 +45,7 @@
<jaxb-api.version>2.4.0-b180830.0359</jaxb-api.version>
<jaxb-runtime.version>2.4.0-b180830.0438</jaxb-runtime.version>
<jib.from.image>gridsuite/java-simulator:2.0.0</jib.from.image>
<gridsuite-dependencies.version>25</gridsuite-dependencies.version>
<gridsuite-dependencies.version>26</gridsuite-dependencies.version>
<liquibase-hibernate-package>org.gridsuite.securityanalysis.server</liquibase-hibernate-package>
</properties>

Expand Down Expand Up @@ -77,8 +77,8 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Expand Down Expand Up @@ -156,7 +156,7 @@
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webflux-ui</artifactId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
</dependency>

<!-- Runtime dependencies -->
Expand Down Expand Up @@ -184,6 +184,22 @@
<groupId>com.rte-france.powsybl</groupId>
<artifactId>powsybl-hades2-integration</artifactId>
<scope>runtime</scope>
<exclusions>
<exclusion>
<!-- Use the "org.glassfish.jaxb:jaxb-runtime" coordinates for the new jakarta jaxb, and
"com.sun.xml.bind" for old the javax jaxb needed by powsybl-hades2-integration
-->
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- reimport the old javax jaxb because we excluded the new jakarta jaxb from powsybl-hades2-integration -->
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb-runtime.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
Expand All @@ -201,12 +217,6 @@
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-runtime.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
Expand Down Expand Up @@ -261,10 +271,8 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<type>test-jar</type>
<artifactId>spring-cloud-stream-test-binder</artifactId>
<scope>test</scope>
<classifier>test-binder</classifier>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
package org.gridsuite.securityanalysis.server.entities;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;

import com.powsybl.contingency.ContingencyElementType;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
package org.gridsuite.securityanalysis.server.entities;

import java.util.List;
import java.util.UUID;

import java.io.Serializable;

import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;
import jakarta.persistence.*;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -30,25 +24,10 @@
@NoArgsConstructor
@Entity
@Table(name = "contingency")
@IdClass(ContingencyEntity.ID.class)
public class ContingencyEntity implements Serializable {

@NoArgsConstructor
@Getter
@Embeddable
static class ID implements Serializable {
@Id
private UUID resultUuid;

@Id
private String contingencyId;
}

@Id
private UUID resultUuid;

@Id
private String contingencyId;
@EmbeddedId
private ContingencyEntityId resultId;

@ElementCollection
private List<ContingencyElementEmbeddable> contingencyElements;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.gridsuite.securityanalysis.server.entities;

import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.UUID;

@Embeddable
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class ContingencyEntityId implements Serializable {

private UUID resultUuid;

private String contingencyId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.io.Serializable;

import javax.persistence.*;
import jakarta.persistence.*;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.Table;

import com.powsybl.iidm.network.Branch;
import com.powsybl.security.LimitViolationType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@Repository
public interface ContingencyRepository extends JpaRepository<ContingencyEntity, UUID> {

List<ContingencyEntity> findByResultUuid(UUID resultUuid);
List<ContingencyEntity> findByResultIdResultUuid(UUID resultUuid);

void deleteByResultUuid(UUID resultUuid);
void deleteByResultIdResultUuid(UUID resultUuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static Contingency fromEntity(ContingencyEntity entity) {
throw new IllegalStateException("Element type not yet support: " + e.getElementType());
}
}).collect(Collectors.toList());
return new Contingency(entity.getContingencyId(), elements);
return new Contingency(entity.getResultId().getContingencyId(), elements);
}

private static LimitViolationEntity toEntity(UUID resultUuid, String contingencyId, LimitViolation limitViolation) {
Expand All @@ -98,7 +98,7 @@ private static List<LimitViolationEntity> toEntity(UUID resultUuid, Contingency
private static ContingencyEntity toEntity(UUID resultUuid, Contingency contingency) {
List<ContingencyElementEmbeddable> elements = contingency.getElements().stream()
.map(e -> new ContingencyElementEmbeddable(e.getType(), e.getId())).collect(Collectors.toList());
return new ContingencyEntity(resultUuid, contingency.getId(), elements);
return new ContingencyEntity(new ContingencyEntityId(resultUuid, contingency.getId()), elements);
}

private static GlobalStatusEntity toEntity(UUID resultUuid, SecurityAnalysisStatus status) {
Expand All @@ -125,7 +125,7 @@ public SecurityAnalysisResult find(UUID resultUuid, Set<LimitViolationType> limi
.collect(
Collectors.groupingBy(Pair::getKey, Collectors.mapping(Pair::getValue, Collectors.toCollection(ArrayList::new))));

List<ContingencyEntity> contingencyEntities = contingencyRepository.findByResultUuid(resultUuid);
List<ContingencyEntity> contingencyEntities = contingencyRepository.findByResultIdResultUuid(resultUuid);
List<Contingency> contingencies = contingencyEntities.stream()
.map(SecurityAnalysisResultRepository::fromEntity)
.collect(Collectors.toList());
Expand Down Expand Up @@ -182,7 +182,7 @@ public void delete(UUID resultUuid) {
Objects.requireNonNull(resultUuid);
computationStatusRepository.deleteByResultUuid(resultUuid);
limitViolationRepository.deleteByResultUuid(resultUuid);
contingencyRepository.deleteByResultUuid(resultUuid);
contingencyRepository.deleteByResultIdResultUuid(resultUuid);
globalStatusRepository.deleteByResultUuid(resultUuid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sa.stopped
publishFailed-out-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sa.failed
output-bindings: publishRun;publishResult;publishCancel;publishStopped;publishFailed
output-bindings: publishRun-out-0;publishResult-out-0;publishCancel-out-0;publishStopped-out-0;publishFailed-out-0

powsybl-ws:
database:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.1.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
<changeSet author="hedhiliabd" id="1689623201842-1">
<modifyDataType columnName="element_type"
newDataType="tinyint"
schemaName="public"
tableName="contingency_entity_contingency_elements"/>
</changeSet>
</databaseChangeLog>
3 changes: 3 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ databaseChangeLog:
- include:
file: changesets/changelog_20221128T124100Z.xml
relativeToChangelogFile: true
- include:
file: changesets/changelog_20230801T194601Z.xml
relativeToChangelogFile: true

0 comments on commit 6f8fd32

Please sign in to comment.