Skip to content

Commit

Permalink
Update PathResponseConverter.java
Browse files Browse the repository at this point in the history
  • Loading branch information
HamzaJugon authored Apr 5, 2024
1 parent d853eb7 commit 11620a7
Showing 1 changed file with 23 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,29 @@ but currently projections do not support using Specification (See https://github
Therefore, this is a 'manual' conversion of the HousekeepingPath object, which will be used in the API.
*/

public class PathResponseConverter {

private static HousekeepingPathResponse convertToHousekeepingPathResponse(HousekeepingPath housekeepingPath) {
return HousekeepingPathResponse
.builder()
.path(housekeepingPath.getPath())
.databaseName(housekeepingPath.getDatabaseName())
.tableName(housekeepingPath.getTableName())
.housekeepingStatus(housekeepingPath.getHousekeepingStatus())
.creationTimestamp(housekeepingPath.getCreationTimestamp())
.modifiedTimestamp(housekeepingPath.getModifiedTimestamp())
.cleanupTimestamp(housekeepingPath.getCleanupTimestamp())
.cleanupDelay(housekeepingPath.getCleanupDelay().toString())
.cleanupAttempts(housekeepingPath.getCleanupAttempts())
.lifecycleType(housekeepingPath.getLifecycleType())
.build();
}

public static Page<HousekeepingPathResponse> convertToHousekeepingPathResponsePage(
Page<HousekeepingPath> housekeepingPathPage) {
List<HousekeepingPath> housekeepingPathList = housekeepingPathPage.getContent();
List<HousekeepingPathResponse> housekeepingPathResponseList = new ArrayList<>();
for (HousekeepingPath housekeepingPath : housekeepingPathList) {
HousekeepingPathResponse housekeepingPathResponse = convertToHousekeepingPathResponse(housekeepingPath);
housekeepingPathResponseList.add(housekeepingPathResponse);
public class PathResponseFacade {

public static HousekeepingPathResponse convert(HousekeepingPath housekeepingPath) {
return HousekeepingPathResponse
.builder()
.path(housekeepingPath.getPath())
.databaseName(housekeepingPath.getDatabaseName())
.tableName(housekeepingPath.getTableName())
.housekeepingStatus(housekeepingPath.getHousekeepingStatus())
.creationTimestamp(housekeepingPath.getCreationTimestamp())
.modifiedTimestamp(housekeepingPath.getModifiedTimestamp())
.cleanupTimestamp(housekeepingPath.getCleanupTimestamp())
.cleanupDelay(housekeepingPath.getCleanupDelay().toString())
.cleanupAttempts(housekeepingPath.getCleanupAttempts())
.lifecycleType(housekeepingPath.getLifecycleType())
.build();
}
PageImpl<HousekeepingPathResponse> housekeepingPathResponses = new PageImpl<>(
housekeepingPathResponseList, housekeepingPathPage.getPageable(), housekeepingPathPage.getTotalElements());
return housekeepingPathResponses;
}

public static Page<HousekeepingPathResponse> convertPage(Page<HousekeepingPath> housekeepingPathPage) {
List<HousekeepingPathResponse> responses = new ArrayList<>();
for (HousekeepingPath housekeepingPath : housekeepingPathPage.getContent()) {
responses.add(convert(housekeepingPath));
}
return new PageImpl<>(responses, housekeepingPathPage.getPageable(), housekeepingPathPage.getTotalElements());
}
}

0 comments on commit 11620a7

Please sign in to comment.