13
13
import org .lfenergy .compas .scl .data .repository .CompasSclDataRepository ;
14
14
15
15
import javax .sql .DataSource ;
16
- import javax .transaction .Transactional ;
17
16
import java .sql .ResultSet ;
18
17
import java .sql .SQLException ;
19
18
import java .util .ArrayList ;
20
19
import java .util .List ;
21
20
import java .util .UUID ;
22
21
23
- import static javax .transaction .Transactional .TxType .REQUIRED ;
24
- import static javax .transaction .Transactional .TxType .SUPPORTS ;
25
22
import static org .lfenergy .compas .scl .data .exception .CompasSclDataServiceErrorCode .*;
26
23
27
24
public class CompasSclDataPostgreSQLRepository implements CompasSclDataRepository {
28
25
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 " ;
29
27
private static final String FROM_CLAUSE = " from scl_file " ;
30
28
private static final String DELETE_FROM_CLAUSE = "delete " + FROM_CLAUSE ;
31
29
private static final String WHERE_CLAUSE = " where " ;
@@ -50,7 +48,6 @@ public CompasSclDataPostgreSQLRepository(DataSource dataSource) {
50
48
}
51
49
52
50
@ Override
53
- @ Transactional (SUPPORTS )
54
51
public List <Item > list (SclType type ) {
55
52
var sql = SELECT_METADATA_CLAUSE
56
53
+ FROM_CLAUSE
@@ -97,7 +94,6 @@ public List<Item> list(SclType type) {
97
94
}
98
95
99
96
@ Override
100
- @ Transactional (SUPPORTS )
101
97
public List <Item > listVersionsByUUID (SclType type , UUID id ) {
102
98
var sql = SELECT_METADATA_CLAUSE
103
99
+ FROM_CLAUSE
@@ -125,7 +121,6 @@ public List<Item> listVersionsByUUID(SclType type, UUID id) {
125
121
}
126
122
127
123
@ Override
128
- @ Transactional (SUPPORTS )
129
124
public String findByUUID (SclType type , UUID id ) {
130
125
// Use the find meta info to retrieve info about the latest version.
131
126
var metaInfo = findMetaInfoByUUID (type , id );
@@ -134,9 +129,8 @@ public String findByUUID(SclType type, UUID id) {
134
129
}
135
130
136
131
@ Override
137
- @ Transactional (SUPPORTS )
138
132
public String findByUUID (SclType type , UUID id , Version version ) {
139
- var sql = "select scl_data "
133
+ var sql = SELECT_DATA_CLAUSE
140
134
+ FROM_CLAUSE
141
135
+ WHERE_CLAUSE + FILTER_ON_ID
142
136
+ AND_CLAUSE + FILTER_ON_TYPE
@@ -163,7 +157,6 @@ public String findByUUID(SclType type, UUID id, Version version) {
163
157
}
164
158
165
159
@ Override
166
- @ Transactional (SUPPORTS )
167
160
public SclMetaInfo findMetaInfoByUUID (SclType type , UUID id ) {
168
161
var sql = SELECT_METADATA_CLAUSE
169
162
+ FROM_CLAUSE
@@ -192,7 +185,6 @@ public SclMetaInfo findMetaInfoByUUID(SclType type, UUID id) {
192
185
}
193
186
194
187
@ Override
195
- @ Transactional (REQUIRED )
196
188
public void create (SclType type , UUID id , String name , String scl , Version version , String who ) {
197
189
var sql = "insert into scl_file(id, major_version, minor_version, patch_version, type, name, created_by, scl_data)"
198
190
+ " values (?, ?, ?, ?, ?, ?, ?, ?)" ;
@@ -214,7 +206,6 @@ public void create(SclType type, UUID id, String name, String scl, Version versi
214
206
}
215
207
216
208
@ Override
217
- @ Transactional (REQUIRED )
218
209
public void delete (SclType type , UUID id ) {
219
210
var sql = DELETE_FROM_CLAUSE
220
211
+ WHERE_CLAUSE + FILTER_ON_ID
@@ -231,7 +222,6 @@ public void delete(SclType type, UUID id) {
231
222
}
232
223
233
224
@ Override
234
- @ Transactional (REQUIRED )
235
225
public void delete (SclType type , UUID id , Version version ) {
236
226
var sql = DELETE_FROM_CLAUSE
237
227
+ WHERE_CLAUSE + FILTER_ON_ID
0 commit comments