Skip to content

Commit eff4d32

Browse files
author
Rob Tjalma
authored
Merge pull request #144 from com-pas/implement-postgresql-repo
PostgreSQL Implementation of the Repository
2 parents eaa2a3e + b17d164 commit eff4d32

File tree

19 files changed

+689
-501
lines changed

19 files changed

+689
-501
lines changed

app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfiguration.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfiguration.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0
44
package org.lfenergy.compas.scl.data.rest;
55

6+
import io.quarkus.runtime.annotations.RegisterForReflection;
67
import org.lfenergy.compas.core.commons.ElementConverter;
78
import org.lfenergy.compas.scl.data.util.SclDataModelMarshaller;
89
import org.lfenergy.compas.scl.data.util.SclElementProcessor;
@@ -12,6 +13,13 @@
1213
/**
1314
* Create Beans from other dependencies that are used in the application.
1415
*/
16+
@RegisterForReflection(
17+
targets = {
18+
org.lfenergy.compas.core.jaxrs.model.ErrorMessage.class,
19+
org.lfenergy.compas.core.jaxrs.model.ErrorResponse.class,
20+
org.lfenergy.compas.scl.data.model.SclMetaInfo.class,
21+
org.lfenergy.compas.scl.data.model.ObjectFactory.class
22+
})
1523
public class CompasSclDataServiceConfiguration {
1624
@Produces
1725
public ElementConverter createElementConverter() {

app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

doc/postgresql.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ docker run --rm --name compas_postgres \
4747
You can run the following command to build the BaseX version of the application.
4848

4949
```shell script
50-
./mvnw -P !basex,postgres clean verify
50+
./mvnw -P postgres clean verify
5151
```
5252

5353
### Running the application in dev mode
5454

5555
You can run your application in dev mode that enables live coding using:
5656

5757
```shell script
58-
./mvnw -P !basex,postgres -DskipTests=true -Dquarkus.profile=dev,prod-postgres package io.quarkus:quarkus-maven-plugin::dev
58+
./mvnw -P postgres -DskipTests=true -Dquarkus.profile=dev,prod-postgres package io.quarkus:quarkus-maven-plugin::dev
5959
```
6060

pom.xml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ SPDX-License-Identifier: Apache-2.0
3535
<slf4j.version>1.7.32</slf4j.version>
3636

3737
<!-- Test -->
38-
<basex.version>9.2.4</basex.version>
3938
<junit-jupiter.version>5.8.1</junit-jupiter.version>
4039
<mockito-junit-jupiter.version>4.0.0</mockito-junit-jupiter.version>
4140
<openpojo.version>0.9.1</openpojo.version>
@@ -151,10 +150,13 @@ SPDX-License-Identifier: Apache-2.0
151150

152151
<!-- Test -->
153152
<dependency>
154-
<groupId>org.basex</groupId>
155-
<artifactId>basex</artifactId>
156-
<version>${basex.version}</version>
153+
<groupId>org.lfenergy.compas.scl.data</groupId>
154+
<artifactId>repository</artifactId>
155+
<version>${project.version}</version>
156+
<type>test-jar</type>
157+
<scope>test</scope>
157158
</dependency>
159+
158160
<dependency>
159161
<groupId>org.junit.jupiter</groupId>
160162
<artifactId>junit-jupiter-api</artifactId>
@@ -214,6 +216,13 @@ SPDX-License-Identifier: Apache-2.0
214216
<groupId>org.apache.maven.plugins</groupId>
215217
<artifactId>maven-jar-plugin</artifactId>
216218
<version>3.2.0</version>
219+
<executions>
220+
<execution>
221+
<goals>
222+
<goal>test-jar</goal>
223+
</goals>
224+
</execution>
225+
</executions>
217226
</plugin>
218227
</plugins>
219228
</pluginManagement>

repository-basex/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ SPDX-License-Identifier: Apache-2.0
1717
<artifactId>repository-basex</artifactId>
1818
<packaging>jar</packaging>
1919

20+
<properties>
21+
<basex.version>9.2.4</basex.version>
22+
</properties>
23+
2024
<dependencies>
2125
<dependency>
2226
<groupId>org.lfenergy.compas.scl.data</groupId>
@@ -51,11 +55,19 @@ SPDX-License-Identifier: Apache-2.0
5155
</dependency>
5256

5357
<!-- Test Dependencies -->
58+
<dependency>
59+
<groupId>org.lfenergy.compas.scl.data</groupId>
60+
<artifactId>repository</artifactId>
61+
<type>test-jar</type>
62+
<scope>test</scope>
63+
</dependency>
5464
<dependency>
5565
<groupId>org.basex</groupId>
5666
<artifactId>basex</artifactId>
67+
<version>${basex.version}</version>
5768
<scope>test</scope>
5869
</dependency>
70+
5971
<dependency>
6072
<groupId>org.junit.jupiter</groupId>
6173
<artifactId>junit-jupiter-api</artifactId>

repository-basex/src/main/java/org/lfenergy/compas/scl/data/basex/repository/CompasSclDataBaseXRepository.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public List<Item> list(SclType type) {
110110

111111
@Override
112112
public List<Item> listVersionsByUUID(SclType type, UUID id) {
113-
var items = executeQuery(type, DECLARE_SCL_NS_URI +
113+
return executeQuery(type, DECLARE_SCL_NS_URI +
114114
DECLARE_COMPAS_NAMESPACE +
115115
format(DECLARE_DB_VARIABLE, type) +
116116
format(DECLARE_ID_VARIABLE, id) +
@@ -125,12 +125,6 @@ public List<Item> listVersionsByUUID(SclType type, UUID id) {
125125
" order by $majorVersion, $minorVersion, $patchVersion\n" +
126126
" return '<Item xmlns=\"" + SCL_DATA_SERVICE_V1_NS_URI + "\"><Id>' || $id || '</Id><Name>' || $name || '</Name><Version>' || $version || '</Version></Item>' ",
127127
sclDataMarshaller::unmarshalItem);
128-
129-
if (items.isEmpty()) {
130-
var message = String.format("No versions found for type '%s' with ID '%s'", type, id);
131-
throw new CompasNoDataFoundException(message);
132-
}
133-
return items;
134128
}
135129

136130
@Override
@@ -190,7 +184,8 @@ public SclMetaInfo findMetaInfoByUUID(SclType type, UUID id) {
190184
}
191185

192186
@Override
193-
public void create(SclType type, UUID id, String name, String scl, Version version) {
187+
public void create(SclType type, UUID id, String name, String scl, Version version, String who) {
188+
// Who is ignored in the BaseX implementation.
194189
var inputStream = new ReaderInputStream(new StringReader(scl), StandardCharsets.UTF_8);
195190
executeCommand(client -> {
196191
openDatabase(client, type);

0 commit comments

Comments
 (0)