Skip to content

Commit 3f78132

Browse files
committed
Updated development documentation
1 parent 0124460 commit 3f78132

File tree

8 files changed

+66
-25
lines changed

8 files changed

+66
-25
lines changed

README.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,7 @@ There is currently one database implementations available.
2828
2929
## Development
3030

31-
Run application with local postgresql database in development mode:
32-
```bash
33-
cd src/test/resources/docker-compose.yml
34-
docker-compose up keycloak
35-
36-
mvn -DskipTests=true -Dquarkus.profile=local package io.quarkus:quarkus-maven-plugin::dev
37-
```
38-
39-
In case of issues enable full debug logging by uncommenting the enable `ALL` logs in the `src/main/resources/application.properties` file:
40-
```properties
41-
quarkus.log.level = ALL
42-
quarkus.log.category."org.lfenergy.compas.scl.data".level = ALL
43-
```
31+
See [development](doc/development.md) documentation.
4432

4533
## Common Environment variables
4634

app/src/main/resources/application-local.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ quarkus.flyway.migrate-at-start = true
1010
quarkus.flyway.locations = classpath:org/lfenergy/compas/scl/data/repository/postgresql/db/migration
1111

1212
mp.jwt.verify.issuer = ${JWT_VERIFY_ISSUER:http://127.0.0.1:8089/auth/realms/compas}
13+
14+
compas.scl-data-service.features.soft-delete-enabled = true

app/src/main/resources/application.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ quarkus.websocket.max-frame-size = 157286400
1515
quarkus.log.level = INFO
1616
quarkus.log.category."org.lfenergy.compas.scl.data".level = INFO
1717

18+
compas.scl-data-service.features.soft-delete-enabled = ${SCL_DATA_SERVICE_SOFT_DELETE_ENABLED:false}
19+
1820
# Add scanning these dependencies for scanning, also used by native compilation.
1921
quarkus.index-dependency.websocket-commons.group-id = org.lfenergy.compas.core
2022
quarkus.index-dependency.websocket-commons.artifact-id = websocket-commons

app/src/test/resources/docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,19 @@ services:
1515
- KC_PROXY_HEADERS=xforwarded
1616
- KC_BOOTSTRAP_ADMIN_USERNAME=admin
1717
- KC_BOOTSTRAP_ADMIN_PASSWORD=admin
18+
19+
postgresql:
20+
image: postgres:latest
21+
container_name: compas_postgresql
22+
environment:
23+
POSTGRES_USER: postgres
24+
POSTGRES_PASSWORD: postgres
25+
POSTGRES_DB: compas
26+
ports:
27+
- "5432:5432"
28+
healthcheck:
29+
test: ["CMD-SHELL", "pg_isready -U postgres"]
30+
interval: 10s
31+
timeout: 5s
32+
retries: 5
33+
restart: unless-stopped

doc/development.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Development
2+
3+
Run application with local postgresql database in development mode:
4+
```bash
5+
cd src/test/resources/docker-compose.yml
6+
docker-compose up keycloak
7+
8+
mvn -DskipTests=true -Dquarkus.profile=local package io.quarkus:quarkus-maven-plugin::dev
9+
```
10+
11+
In case of issues enable full debug logging by uncommenting the enable `ALL` logs in the `src/main/resources/application.properties` file:
12+
```properties
13+
quarkus.log.level = ALL
14+
quarkus.log.category."org.lfenergy.compas.scl.data".level = ALL
15+
```
16+
17+
## Verify setup
18+
19+
To verify that the setup is correct, you can use the following curl command to list all ICDs in the database:
20+
```
21+
curl -X GET "http://localhost:8080/scl-data-service/icd/list" -H "Authorization: Bearer <ACCESS_TOKEN>" -H "accept: application
22+
```
23+
24+
The `<ACCESS_TOKEN>` should be replaced with a valid JWT token obtained from Keycloak with following command:
25+
```bash
26+
curl -X POST "http://localhost:8089/auth/realms/compas/protocol/openid-connect/token" \
27+
-H "Content-Type: application/x-www-form-urlencoded" \
28+
-d "client_id=scl-data-service&username=scl-data-editor&password=editor&grant_type=password"
29+
```

doc/postgresql.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Table: scl_file
3737
| type | varchar(3) | True | The type of SCL stored |
3838
| name | varchar(255) | True | The name of the SCL File |
3939
| scl_data | text | True | The SCL XML Content |
40+
| is_deleted | boolean | False | Flag indicating whether the record is marked as deleted |
4041

4142
## Development
4243

repository-postgresql/src/main/java/org/lfenergy/compas/scl/data/repository/postgresql/CompasSclDataPostgreSQLRepositoryConfiguration.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,30 @@
44

55
package org.lfenergy.compas.scl.data.repository.postgresql;
66

7-
import io.quarkus.arc.DefaultBean;
8-
import io.quarkus.arc.lookup.LookupIfProperty;
97
import jakarta.enterprise.context.ApplicationScoped;
108
import jakarta.enterprise.inject.Produces;
9+
import org.apache.logging.log4j.LogManager;
10+
import org.apache.logging.log4j.Logger;
11+
import org.eclipse.microprofile.config.inject.ConfigProperty;
1112
import org.lfenergy.compas.scl.data.repository.CompasSclDataRepository;
1213

1314
import javax.sql.DataSource;
1415

1516
public class CompasSclDataPostgreSQLRepositoryConfiguration {
1617

18+
private static final Logger LOGGER = LogManager.getLogger(CompasSclDataPostgreSQLRepositoryConfiguration.class);
19+
20+
@ConfigProperty(name = "compas.scl-data-service.features.soft-delete-enabled", defaultValue = "false")
21+
private boolean softDeleteEnabled;
22+
1723
@Produces
1824
@ApplicationScoped
19-
@LookupIfProperty(name = "compas.scl-data-service.features.soft-delete-enabled", stringValue = "true")
2025
CompasSclDataRepository softDeleteCompasSclDataPostgreSQLRepository(DataSource dataSource) {
26+
if (!softDeleteEnabled) {
27+
LOGGER.warn("Soft delete feature is disabled, using default repository.");
28+
return new CompasSclDataPostgreSQLRepository(dataSource);
29+
}
30+
LOGGER.info("Soft delete feature is enabled. Using SoftDeleteCompasSclDataPostgreSQLRepository.");
2131
return new SoftDeleteCompasSclDataPostgreSQLRepository(dataSource);
2232
}
23-
24-
@Produces
25-
@ApplicationScoped
26-
@DefaultBean
27-
CompasSclDataRepository defaultCompasSclDataPostgreSQLRepository(DataSource dataSource) {
28-
return new CompasSclDataPostgreSQLRepository(dataSource);
29-
}
3033
}

repository-postgresql/src/main/java/org/lfenergy/compas/scl/data/repository/postgresql/SoftDeleteCompasSclDataPostgreSQLRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public SoftDeleteCompasSclDataPostgreSQLRepository(DataSource dataSource) {
2727
public void delete(SclFileType type, UUID id) {
2828
var sql = """
2929
UPDATE scl_file
30-
SET scl_file.is_deleted = true
30+
SET is_deleted = true
3131
where scl_file.id = ?
3232
and scl_file.type = ?
3333
""";
@@ -47,7 +47,7 @@ public void delete(SclFileType type, UUID id) {
4747
public void delete(SclFileType type, UUID id, Version version) {
4848
var sql = """
4949
UPDATE scl_file
50-
SET scl_file.is_deleted = true
50+
SET is_deleted = true
5151
where scl_file.id = ?
5252
and scl_file.type = ?
5353
and scl_file.major_version = ?

0 commit comments

Comments
 (0)