diff --git a/src/main/java/org/folio/list/domain/ListEntity.java b/src/main/java/org/folio/list/domain/ListEntity.java index a6f42c4e..459d7670 100644 --- a/src/main/java/org/folio/list/domain/ListEntity.java +++ b/src/main/java/org/folio/list/domain/ListEntity.java @@ -131,6 +131,7 @@ public void refreshStarted(User startedBy) { .refreshedBy(startedBy.id()) .refreshedByUsername(startedBy.getFullName().orElse(startedBy.id().toString())) .refreshStartDate(OffsetDateTime.now()) + .version(getVersion()) .build(); } diff --git a/src/main/java/org/folio/list/domain/ListRefreshDetails.java b/src/main/java/org/folio/list/domain/ListRefreshDetails.java index 5a637124..c35aedb7 100644 --- a/src/main/java/org/folio/list/domain/ListRefreshDetails.java +++ b/src/main/java/org/folio/list/domain/ListRefreshDetails.java @@ -56,6 +56,10 @@ public class ListRefreshDetails { @Column(name = "error_message") @Size(max = 1024) private String errorMessage; + + @Column(name = "version") + private Integer version; + @Column(name = "metadata") @JdbcTypeCode(SqlTypes.JSON) private Map metadata; diff --git a/src/main/java/org/folio/list/mapper/ListRefreshMapper.java b/src/main/java/org/folio/list/mapper/ListRefreshMapper.java index f768e644..93fd7981 100644 --- a/src/main/java/org/folio/list/mapper/ListRefreshMapper.java +++ b/src/main/java/org/folio/list/mapper/ListRefreshMapper.java @@ -18,6 +18,7 @@ public interface ListRefreshMapper { @Mapping(target = "recordsCount", source = "listRefreshDetails.recordsCount") @Mapping(target = "contentVersion", source = "listRefreshDetails.contentVersion") @Mapping(target = "error", expression = "java(convertToListAppError(listRefreshDetails))") + @Mapping(target = "version", source = "listRefreshDetails.version") ListRefreshDTO toListRefreshDTO(ListRefreshDetails listRefreshDetails); default ListAppError convertToListAppError(ListRefreshDetails listRefreshDetails) { diff --git a/src/main/resources/db/changelog/changes/v1.1.0/changelog-v1.1.0.xml b/src/main/resources/db/changelog/changes/v1.1.0/changelog-v1.1.0.xml index e60861bb..345a133f 100644 --- a/src/main/resources/db/changelog/changes/v1.1.0/changelog-v1.1.0.xml +++ b/src/main/resources/db/changelog/changes/v1.1.0/changelog-v1.1.0.xml @@ -7,4 +7,5 @@ + diff --git a/src/main/resources/db/changelog/changes/v1.1.0/sql/update-list-refresh-details-table.sql b/src/main/resources/db/changelog/changes/v1.1.0/sql/update-list-refresh-details-table.sql new file mode 100644 index 00000000..04fd8d5f --- /dev/null +++ b/src/main/resources/db/changelog/changes/v1.1.0/sql/update-list-refresh-details-table.sql @@ -0,0 +1 @@ +ALTER TABLE IF EXISTS list_refresh_details ADD COLUMN list_versions TYPE integer; diff --git a/src/main/resources/swagger.api/schemas/ListRefreshDTO.json b/src/main/resources/swagger.api/schemas/ListRefreshDTO.json index 3da59ce4..0373d092 100644 --- a/src/main/resources/swagger.api/schemas/ListRefreshDTO.json +++ b/src/main/resources/swagger.api/schemas/ListRefreshDTO.json @@ -48,6 +48,10 @@ "error": { "description": "Error encountered during list refresh", "$ref": "ListAppError.json" + }, + "version": { + "description": "Contains the version of the list", + "type": "integer" } }, "additionalProperties": false, diff --git a/src/test/java/org/folio/list/mapper/ListRefreshMapperTest.java b/src/test/java/org/folio/list/mapper/ListRefreshMapperTest.java index 9a4d719c..0774aa05 100644 --- a/src/test/java/org/folio/list/mapper/ListRefreshMapperTest.java +++ b/src/test/java/org/folio/list/mapper/ListRefreshMapperTest.java @@ -30,6 +30,7 @@ void shouldMapEntityToDTO() { listRefreshDetails.getRefreshEndDate())); assertEquals(dto.getRefreshedBy(), listRefreshDetails.getRefreshedBy()); assertEquals(dto.getRefreshedByUsername(), listRefreshDetails.getRefreshedByUsername()); + assertEquals(dto.getVersion(), listRefreshDetails.getVersion()); assertEquals(dto.getRecordsCount(), listRefreshDetails.getRecordsCount()); } }