Skip to content

Commit c650b1e

Browse files
author
Flurb
committed
Review comments
Signed-off-by: Flurb <[email protected]>
1 parent 74c8c8e commit c650b1e

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public String findByUUID(SclFileType type, UUID id, Version version) {
158158
@Override
159159
public boolean hasDuplicateSclName(SclFileType type, String name) {
160160
var sql = "SELECT DISTINCT ON (id) m.* "
161-
+ "FROM scl_file m "
161+
+ FROM_CLAUSE + "m "
162162
+ "WHERE m.type=? "
163163
+ "ORDER BY m.id, m.major_version desc, m.minor_version desc, m.patch_version desc";
164164

repository-postgresql/src/test/java/org/lfenergy/compas/scl/data/repository/postgresql/CompasSclDataPostgreSQLRepositoryTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ void beforeEach() {
2929
repository = new CompasSclDataPostgreSQLRepository(PostgreSQLServerJUnitExtension.getDataSource());
3030
}
3131

32-
/**
32+
/*
3333
* TODO: Method beneath needs to be moved to AbstractCompasSclDataRepository
34-
* when hasDuplicateSclName has been implemented by CompasSclDataBaseXRepository.
35-
*/
34+
* when hasDuplicateSclName has been implemented by CompasSclDataBaseXRepository. */
3635
@Test
3736
void hasDuplicateSclName_WhenUsingSclNameThatHasBeenUsedYet_ThenDuplicateIsFound() {
3837
var expectedVersion = new Version(1, 0, 0);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public interface CompasSclDataRepository {
7474
* Return the specific version of a specific SCL Entry.
7575
*
7676
* @param type The type of SCL to search for the specific SCL.
77-
* @param id The ID of the SCL to search for.
77+
* @param name The name of the SCL used for checking duplicates.
7878
* @return True if name is already used by another SCL File of the same File type, otherwise false.
7979
*/
8080
@Transactional(SUPPORTS)

service/src/main/java/org/lfenergy/compas/scl/data/service/impl/CompasSclDataServiceImpl.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public String create(SclFileType type, String name, String who, String comment,
121121
throw new CompasException(NO_SCL_ELEMENT_FOUND_ERROR_CODE, "No valid SCL found in the passed SCL Data.");
122122
}
123123

124-
if (hasDuplicateSclName(type, name)) {
124+
if (repository.hasDuplicateSclName(type, name)) {
125125
throw new CompasException(DUPLICATE_SCL_NAME_ERROR_CODE, "Given name of SCL File already used.");
126126
}
127127

@@ -167,7 +167,7 @@ public String update(SclFileType type, UUID id, ChangeSetType changeSetType, Str
167167

168168
if (newFileName.isPresent()
169169
&& !newFileName.get().equals(currentSclMetaInfo.getName())
170-
&& hasDuplicateSclName(type, newFileName.get())) {
170+
&& repository.hasDuplicateSclName(type, newFileName.get())) {
171171
throw new CompasException(DUPLICATE_SCL_NAME_ERROR_CODE, "Given name of SCL File already used.");
172172
}
173173

@@ -213,10 +213,6 @@ public void delete(SclFileType type, UUID id, Version version) {
213213
repository.delete(type, id, version);
214214
}
215215

216-
private boolean hasDuplicateSclName(SclFileType type, String name) {
217-
return repository.hasDuplicateSclName(type, name);
218-
}
219-
220216
/**
221217
* Retrieve the Header from the SCL Fiel or create one if it doesn't exists and set the ID and
222218
* version on the Header.

0 commit comments

Comments
 (0)