Skip to content

Commit

Permalink
MODLISTS-63:Include list_versioning in refresh data
Browse files Browse the repository at this point in the history
  • Loading branch information
kjain110 committed Dec 21, 2023
1 parent 02caa9d commit 07d0347
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/folio/list/domain/ListEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/folio/list/domain/ListRefreshDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public class ListRefreshDetails {
@Column(name = "error_message")
@Size(max = 1024)
private String errorMessage;

@Column(name = "list_version")
private Integer listVersion;

@Column(name = "metadata")
@JdbcTypeCode(SqlTypes.JSON)
private Map<String, String> metadata;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/folio/list/mapper/ListRefreshMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<include file="sql/create-list-versions-table.sql" relativeToChangelogFile="true"/>
<include file="yml/update-list-versions-fkey.yaml" relativeToChangelogFile="true"/>
<include file="yml/alter-list-details-updated-metadata-add-not-null-constraint.yaml" relativeToChangelogFile="true"/>
<include file="sql/update-list-refresh-details-table.sql" relativeToChangelogFile="true"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE IF EXISTS list_refresh_details ADD COLUMN list_version TYPE integer;
4 changes: 4 additions & 0 deletions src/main/resources/swagger.api/schemas/ListRefreshDTO.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
"error": {
"description": "Error encountered during list refresh",
"$ref": "ListAppError.json"
},
"listVersion": {
"description": "Contains the version of the list",
"type": "integer"
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 07d0347

Please sign in to comment.