Skip to content

Commit 94d3c25

Browse files
committed
WIP Replacing SpringBoot 2 by SpringBoot 3, handling Hibernate changes as well, fixing tests.
1 parent 812a810 commit 94d3c25

22 files changed

+216
-230
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ Then run the following commands to clone the project in your local system.
3030

3131
In the project directory, to start CWLViewer exposed on port `8080`, run:
3232

33-
docker-compose up
33+
docker compose up
3434

3535
The web server will connect to a local host, you'll see the message saying "Tomcat started on port(s):8080".
3636

3737
To see the locally running CWL Viewer app, visit http://localhost:8080/ in your web browser.
3838

3939
To stop and remove:
4040

41-
docker-compose down
41+
docker compose down
4242

4343

4444
If you change the source code, then use this `docker-compose.override.yml` and
45-
re-build with `docker-compose build`:
45+
re-build with `docker compose build`:
4646

4747
```yaml
4848
version: '3.9'
@@ -75,7 +75,7 @@ services:
7575
Then start the containers:
7676
7777
```
78-
docker-compose up
78+
docker compose up
7979
```
8080
8181
Then start Spring Boot locally:
@@ -91,7 +91,7 @@ Now you can connect to http://localhost:7999 in your browser.
9191
To completely reset the state, you must delete the data volumes:
9292
9393
```
94-
docker-compose down
94+
docker compose down
9595
docker volume rm cwlviewer_bundle cwlviewer_git cwlviewer_graphviz cwlviewer_postgres cwlviewer_sparql
9696
```
9797

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3.9'
1+
version: '3.2'
22
networks:
33
postgres:
44
sparql:
@@ -77,4 +77,4 @@ services:
7777
nofile:
7878
soft: 65536
7979
hard: 65536
80-
command: "/start-jena.sh"
80+
command: "/start-jena.sh"

pom.xml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<parent>
1616
<groupId>org.springframework.boot</groupId>
1717
<artifactId>spring-boot-starter-parent</artifactId>
18-
<version>2.7.18</version>
18+
<version>3.1.4</version>
1919
<relativePath/>
2020
</parent>
2121

@@ -68,12 +68,20 @@
6868
<dependency>
6969
<groupId>org.springframework.data</groupId>
7070
<artifactId>spring-data-commons</artifactId>
71-
<version>2.7.18</version>
7271
</dependency>
7372
<dependency>
74-
<groupId>com.vladmihalcea</groupId>
75-
<artifactId>hibernate-types-55</artifactId>
76-
<version>2.21.1</version>
73+
<groupId>org.springframework.data</groupId>
74+
<artifactId>spring-data-jpa</artifactId>
75+
</dependency>
76+
<dependency>
77+
<groupId>jakarta.persistence</groupId>
78+
<artifactId>jakarta.persistence-api</artifactId>
79+
<version>3.1.0</version>
80+
</dependency>
81+
<dependency>
82+
<groupId>io.hypersistence</groupId>
83+
<artifactId>hypersistence-utils-hibernate-62</artifactId>
84+
<version>3.5.2</version>
7785
</dependency>
7886
<!-- Liquibase; note that Flyway, while probably having more documentation and users,
7987
changed its license model. Similarly to mongo, we prefer an open license that

src/main/java/org/commonwl/view/CwlViewerApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121

2222
import org.springframework.boot.SpringApplication;
2323
import org.springframework.boot.autoconfigure.SpringBootApplication;
24+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
2425
import org.springframework.scheduling.annotation.EnableAsync;
2526
import org.springframework.scheduling.annotation.EnableScheduling;
2627
import org.springframework.transaction.annotation.EnableTransactionManagement;
2728

2829
@SpringBootApplication
2930
@EnableAsync
31+
@EnableJpaRepositories
3032
@EnableScheduling
3133
@EnableTransactionManagement
3234
public class CwlViewerApplication {

src/main/java/org/commonwl/view/cwl/CWLValidationException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.commonwl.view.cwl;
2121

22-
import javax.validation.ValidationException;
22+
import jakarta.validation.ValidationException;
2323

2424
/** Exception thrown when a workflow failed CWLTool validation */
2525
public class CWLValidationException extends ValidationException {

src/main/java/org/commonwl/view/git/GitDetails.java

Lines changed: 52 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.commonwl.view.git;
2121

22+
import com.fasterxml.jackson.annotation.JsonAutoDetect;
23+
import com.fasterxml.jackson.annotation.JsonCreator;
2224
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2325
import com.fasterxml.jackson.databind.JsonNode;
2426
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -28,13 +30,14 @@
2830
import java.net.URISyntaxException;
2931
import java.nio.file.Path;
3032
import java.util.Objects;
33+
3134
import org.commonwl.view.util.LicenseUtils;
3235
import org.slf4j.Logger;
3336
import org.slf4j.LoggerFactory;
3437

3538
/** Represents all the parameters necessary to access a file/directory with Git */
3639
@JsonIgnoreProperties(
37-
value = {"internalUrl"},
40+
value = {"internalUrl", "logger"},
3841
ignoreUnknown = true)
3942
public class GitDetails implements Serializable {
4043

@@ -45,6 +48,7 @@ public class GitDetails implements Serializable {
4548
private String path;
4649
private String packedId;
4750

51+
@JsonCreator
4852
public GitDetails(String repoUrl, String branch, String path) {
4953
this.repoUrl = repoUrl;
5054

@@ -110,16 +114,12 @@ public GitType getType() {
110114
if (domain.startsWith("www.")) {
111115
domain = domain.substring(4);
112116
}
113-
switch (domain) {
114-
case "github.com":
115-
return GitType.GITHUB;
116-
case "gitlab.com":
117-
return GitType.GITLAB;
118-
case "bitbucket.org":
119-
return GitType.BITBUCKET;
120-
default:
121-
return GitType.GENERIC;
122-
}
117+
return switch (domain) {
118+
case "github.com" -> GitType.GITHUB;
119+
case "gitlab.com" -> GitType.GITLAB;
120+
case "bitbucket.org" -> GitType.BITBUCKET;
121+
default -> GitType.GENERIC;
122+
};
123123
} catch (URISyntaxException ex) {
124124
return GitType.GENERIC;
125125
}
@@ -133,27 +133,23 @@ public GitType getType() {
133133
*/
134134
public String getUrl(String branchOverride) {
135135
String packedPart = packedId == null ? "" : "#" + packedId;
136-
switch (getType()) {
137-
case GITHUB:
138-
case GITLAB:
139-
return "https://"
140-
+ normaliseUrl(repoUrl).replace(".git", "")
141-
+ "/blob/"
142-
+ branchOverride
143-
+ "/"
144-
+ path
145-
+ packedPart;
146-
case BITBUCKET:
147-
return "https://"
148-
+ normaliseUrl(repoUrl).replace(".git", "")
149-
+ "/src/"
150-
+ branchOverride
151-
+ "/"
152-
+ path
153-
+ packedPart;
154-
default:
155-
return repoUrl;
156-
}
136+
return switch (getType()) {
137+
case GITHUB, GITLAB -> "https://"
138+
+ normaliseUrl(repoUrl).replace(".git", "")
139+
+ "/blob/"
140+
+ branchOverride
141+
+ "/"
142+
+ path
143+
+ packedPart;
144+
case BITBUCKET -> "https://"
145+
+ normaliseUrl(repoUrl).replace(".git", "")
146+
+ "/src/"
147+
+ branchOverride
148+
+ "/"
149+
+ path
150+
+ packedPart;
151+
default -> repoUrl;
152+
};
157153
}
158154

159155
/**
@@ -174,18 +170,15 @@ public String getUrl() {
174170
public String getInternalUrl(String branchOverride) {
175171
String packedPart = packedId == null ? "" : "%23" + packedId;
176172
String pathPart = path.equals("/") ? "" : "/" + path;
177-
switch (getType()) {
178-
case GITHUB:
179-
case GITLAB:
180-
return "/workflows/"
181-
+ normaliseUrl(repoUrl).replace(".git", "")
182-
+ "/blob/"
183-
+ branchOverride
184-
+ pathPart
185-
+ packedPart;
186-
default:
187-
return "/workflows/" + normaliseUrl(repoUrl) + "/" + branchOverride + pathPart + packedPart;
188-
}
173+
return switch (getType()) {
174+
case GITHUB, GITLAB -> "/workflows/"
175+
+ normaliseUrl(repoUrl).replace(".git", "")
176+
+ "/blob/"
177+
+ branchOverride
178+
+ pathPart
179+
+ packedPart;
180+
default -> "/workflows/" + normaliseUrl(repoUrl) + "/" + branchOverride + pathPart + packedPart;
181+
};
189182
}
190183

191184
/**
@@ -211,25 +204,21 @@ public String getRawUrl(String branchOverride, String pathOverride) {
211204
if (pathOverride == null) {
212205
pathOverride = path;
213206
}
214-
switch (getType()) {
215-
case GITHUB:
216-
return "https://raw.githubusercontent.com/"
217-
+ normaliseUrl(repoUrl).replace("github.com/", "").replace(".git", "")
218-
+ "/"
219-
+ branchOverride
220-
+ "/"
221-
+ pathOverride;
222-
case GITLAB:
223-
case BITBUCKET:
224-
return "https://"
225-
+ normaliseUrl(repoUrl).replace(".git", "")
226-
+ "/raw/"
227-
+ branchOverride
228-
+ "/"
229-
+ pathOverride;
230-
default:
231-
return repoUrl;
232-
}
207+
return switch (getType()) {
208+
case GITHUB -> "https://raw.githubusercontent.com/"
209+
+ normaliseUrl(repoUrl).replace("github.com/", "").replace(".git", "")
210+
+ "/"
211+
+ branchOverride
212+
+ "/"
213+
+ pathOverride;
214+
case GITLAB, BITBUCKET -> "https://"
215+
+ normaliseUrl(repoUrl).replace(".git", "")
216+
+ "/raw/"
217+
+ branchOverride
218+
+ "/"
219+
+ pathOverride;
220+
default -> repoUrl;
221+
};
233222
}
234223

235224
/**

src/main/java/org/commonwl/view/git/GitLicenseException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.commonwl.view.git;
22

3-
import javax.validation.ValidationException;
3+
import jakarta.validation.ValidationException;
44

55
public class GitLicenseException extends ValidationException {
66

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
package org.commonwl.view.util;
22

3-
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
4-
import javax.persistence.MappedSuperclass;
5-
import org.hibernate.annotations.TypeDef;
6-
import org.hibernate.annotations.TypeDefs;
3+
import jakarta.persistence.MappedSuperclass;
74

8-
@TypeDefs({@TypeDef(name = "json", typeClass = JsonBinaryType.class)})
95
@MappedSuperclass
106
public class BaseEntity {}

src/main/java/org/commonwl/view/workflow/QueuedWorkflow.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
package org.commonwl.view.workflow;
22

3-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
43
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import io.hypersistence.utils.hibernate.type.json.JsonType;
5+
import jakarta.persistence.Column;
6+
import jakarta.persistence.Convert;
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.GeneratedValue;
9+
import jakarta.persistence.GenerationType;
10+
import jakarta.persistence.Id;
11+
import jakarta.persistence.Table;
512
import java.io.Serializable;
613
import java.util.List;
714
import java.util.Objects;
8-
import javax.persistence.Column;
9-
import javax.persistence.Convert;
10-
import javax.persistence.Entity;
11-
import javax.persistence.GeneratedValue;
12-
import javax.persistence.GenerationType;
13-
import javax.persistence.Id;
14-
import javax.persistence.Table;
1515
import org.commonwl.view.cwl.CWLToolStatus;
1616
import org.commonwl.view.util.BaseEntity;
1717
import org.hibernate.annotations.GenericGenerator;
1818
import org.hibernate.annotations.Type;
1919

2020
/** A workflow pending completion of cwltool */
21-
@JsonIgnoreProperties(value = {"id", "tempRepresentation", "workflowList"})
21+
// JsonIgnoreProperties(value = {"id", "tempRepresentation", "workflowList"})
2222
@JsonInclude(JsonInclude.Include.NON_EMPTY)
2323
@Entity
2424
@Table(name = "queued_workflow")
25-
@SuppressWarnings("JpaAttributeTypeInspection")
2625
public class QueuedWorkflow extends BaseEntity implements Serializable {
2726

2827
// ID for database
@@ -34,20 +33,20 @@ public class QueuedWorkflow extends BaseEntity implements Serializable {
3433

3534
// Very barebones workflow to build loading thumbnail and overview
3635
@Column(columnDefinition = "jsonb")
37-
@Type(type = "json")
36+
@Type(value = JsonType.class)
3837
@Convert(disableConversion = true)
3938
private Workflow tempRepresentation;
4039

4140
// List of packed workflows for packed workflows
4241
// TODO: Refactor so this is not necessary
4342
@Column(columnDefinition = "jsonb")
44-
@Type(type = "json")
43+
@Type(value = JsonType.class)
4544
@Convert(disableConversion = true)
4645
private List<WorkflowOverview> workflowList;
4746

4847
// Cwltool details
4948
@Column(columnDefinition = "jsonb")
50-
@Type(type = "json")
49+
@Type(value = JsonType.class)
5150
@Convert(disableConversion = true)
5251
private CWLToolStatus cwltoolStatus = CWLToolStatus.RUNNING;
5352

src/main/java/org/commonwl/view/workflow/QueuedWorkflowRepository.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.springframework.data.jpa.repository.JpaRepository;
66
import org.springframework.data.jpa.repository.Modifying;
77
import org.springframework.data.jpa.repository.Query;
8+
import org.springframework.stereotype.Repository;
89
import org.springframework.transaction.annotation.Transactional;
910

1011
/**
@@ -13,8 +14,8 @@
1314
* <p>Use only queries without objects and JSON here. For other methods use the Impl class to avoid
1415
* issues with serialization.
1516
*/
16-
public interface QueuedWorkflowRepository
17-
extends JpaRepository<QueuedWorkflow, String>, QueuedWorkflowRepositoryCustom {
17+
@Repository
18+
public interface QueuedWorkflowRepository extends JpaRepository<QueuedWorkflow, String>, QueuedWorkflowRepositoryCustom {
1819

1920
/**
2021
* Deletes all queued workflows with date retrieved on older or equal to the Date argument passed.

0 commit comments

Comments
 (0)