Skip to content

Commit a283dd7

Browse files
author
Dennis Labordus
committed
Small updates.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent ec9aa2e commit a283dd7

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@
1313
import org.lfenergy.compas.scl.data.repository.CompasSclDataRepository;
1414

1515
import javax.sql.DataSource;
16-
import javax.transaction.Transactional;
1716
import java.sql.ResultSet;
1817
import java.sql.SQLException;
1918
import java.util.ArrayList;
2019
import java.util.List;
2120
import java.util.UUID;
2221

23-
import static javax.transaction.Transactional.TxType.REQUIRED;
24-
import static javax.transaction.Transactional.TxType.SUPPORTS;
2522
import static org.lfenergy.compas.scl.data.exception.CompasSclDataServiceErrorCode.*;
2623

2724
public class CompasSclDataPostgreSQLRepository implements CompasSclDataRepository {
2825
private static final String SELECT_METADATA_CLAUSE = "select id, name, major_version, minor_version, patch_version ";
26+
private static final String SELECT_DATA_CLAUSE = "select scl_data ";
2927
private static final String FROM_CLAUSE = " from scl_file ";
3028
private static final String DELETE_FROM_CLAUSE = "delete " + FROM_CLAUSE;
3129
private static final String WHERE_CLAUSE = " where ";
@@ -50,7 +48,6 @@ public CompasSclDataPostgreSQLRepository(DataSource dataSource) {
5048
}
5149

5250
@Override
53-
@Transactional(SUPPORTS)
5451
public List<Item> list(SclType type) {
5552
var sql = SELECT_METADATA_CLAUSE
5653
+ FROM_CLAUSE
@@ -97,7 +94,6 @@ public List<Item> list(SclType type) {
9794
}
9895

9996
@Override
100-
@Transactional(SUPPORTS)
10197
public List<Item> listVersionsByUUID(SclType type, UUID id) {
10298
var sql = SELECT_METADATA_CLAUSE
10399
+ FROM_CLAUSE
@@ -125,7 +121,6 @@ public List<Item> listVersionsByUUID(SclType type, UUID id) {
125121
}
126122

127123
@Override
128-
@Transactional(SUPPORTS)
129124
public String findByUUID(SclType type, UUID id) {
130125
// Use the find meta info to retrieve info about the latest version.
131126
var metaInfo = findMetaInfoByUUID(type, id);
@@ -134,9 +129,8 @@ public String findByUUID(SclType type, UUID id) {
134129
}
135130

136131
@Override
137-
@Transactional(SUPPORTS)
138132
public String findByUUID(SclType type, UUID id, Version version) {
139-
var sql = "select scl_data "
133+
var sql = SELECT_DATA_CLAUSE
140134
+ FROM_CLAUSE
141135
+ WHERE_CLAUSE + FILTER_ON_ID
142136
+ AND_CLAUSE + FILTER_ON_TYPE
@@ -163,7 +157,6 @@ public String findByUUID(SclType type, UUID id, Version version) {
163157
}
164158

165159
@Override
166-
@Transactional(SUPPORTS)
167160
public SclMetaInfo findMetaInfoByUUID(SclType type, UUID id) {
168161
var sql = SELECT_METADATA_CLAUSE
169162
+ FROM_CLAUSE
@@ -192,7 +185,6 @@ public SclMetaInfo findMetaInfoByUUID(SclType type, UUID id) {
192185
}
193186

194187
@Override
195-
@Transactional(REQUIRED)
196188
public void create(SclType type, UUID id, String name, String scl, Version version, String who) {
197189
var sql = "insert into scl_file(id, major_version, minor_version, patch_version, type, name, created_by, scl_data)"
198190
+ " values (?, ?, ?, ?, ?, ?, ?, ?)";
@@ -214,7 +206,6 @@ public void create(SclType type, UUID id, String name, String scl, Version versi
214206
}
215207

216208
@Override
217-
@Transactional(REQUIRED)
218209
public void delete(SclType type, UUID id) {
219210
var sql = DELETE_FROM_CLAUSE
220211
+ WHERE_CLAUSE + FILTER_ON_ID
@@ -231,7 +222,6 @@ public void delete(SclType type, UUID id) {
231222
}
232223

233224
@Override
234-
@Transactional(REQUIRED)
235225
public void delete(SclType type, UUID id, Version version) {
236226
var sql = DELETE_FROM_CLAUSE
237227
+ WHERE_CLAUSE + FILTER_ON_ID

repository/src/main/java/org/lfenergy/compas/scl/data/repository/CompasSclDataRepository.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
import org.lfenergy.compas.scl.data.model.SclType;
99
import org.lfenergy.compas.scl.data.model.Version;
1010

11+
import javax.transaction.Transactional;
1112
import java.util.List;
1213
import java.util.UUID;
1314

15+
import static javax.transaction.Transactional.TxType.REQUIRED;
16+
import static javax.transaction.Transactional.TxType.SUPPORTS;
17+
1418
/**
1519
* Repository class that will be used to handle SCL File for a specific type of storage.
1620
* The repository class needs to be able to create and delete entries and find/list entries.
@@ -22,6 +26,7 @@ public interface CompasSclDataRepository {
2226
* @param type The type of SCL to search for.
2327
* @return The list of entries found for the passed type.
2428
*/
29+
@Transactional(SUPPORTS)
2530
List<Item> list(SclType type);
2631

2732
/**
@@ -31,6 +36,7 @@ public interface CompasSclDataRepository {
3136
* @param id The ID of the SCL to search for.
3237
* @return The list of versions found for that specific sCl Entry.
3338
*/
39+
@Transactional(SUPPORTS)
3440
List<Item> listVersionsByUUID(SclType type, UUID id);
3541

3642
/**
@@ -40,6 +46,7 @@ public interface CompasSclDataRepository {
4046
* @param id The ID of the SCL to search for.
4147
* @return The SCL XML File Content that is search for.
4248
*/
49+
@Transactional(SUPPORTS)
4350
String findByUUID(SclType type, UUID id);
4451

4552
/**
@@ -49,6 +56,7 @@ public interface CompasSclDataRepository {
4956
* @param id The ID of the SCL to search for.
5057
* @return The Meta Info of SCL Entry that is search for.
5158
*/
59+
@Transactional(SUPPORTS)
5260
SclMetaInfo findMetaInfoByUUID(SclType type, UUID id);
5361

5462
/**
@@ -59,6 +67,7 @@ public interface CompasSclDataRepository {
5967
* @param version The version of the ScL to search for.
6068
* @return The SCL XML File Content that is search for.
6169
*/
70+
@Transactional(SUPPORTS)
6271
String findByUUID(SclType type, UUID id, Version version);
6372

6473
/**
@@ -75,6 +84,7 @@ public interface CompasSclDataRepository {
7584
* @param version The version of the new entry to be created.
7685
* @param who The user that created the new entry.
7786
*/
87+
@Transactional(REQUIRED)
7888
void create(SclType type, UUID id, String name, String scl, Version version, String who);
7989

8090
/**
@@ -83,6 +93,7 @@ public interface CompasSclDataRepository {
8393
* @param type The type of SCL where to find the SCL File
8494
* @param id The ID of the SCL File to delete.
8595
*/
96+
@Transactional(REQUIRED)
8697
void delete(SclType type, UUID id);
8798

8899
/**
@@ -92,5 +103,6 @@ public interface CompasSclDataRepository {
92103
* @param id The ID of the SCL File to delete.
93104
* @param version The version of that SCL File to delete.
94105
*/
106+
@Transactional(REQUIRED)
95107
void delete(SclType type, UUID id, Version version);
96108
}

0 commit comments

Comments
 (0)