-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dtos for SpotlightBatch and spotlightSubmission (#81)
* add dto to get rid of hibernate issues due to lazy load of some entity relations * java format
- Loading branch information
Showing
11 changed files
with
549 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/gov/cabinetoffice/gap/adminbackend/dtos/spotlightBatch/SpotlightBatchDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package gov.cabinetoffice.gap.adminbackend.dtos.spotlightBatch; | ||
|
||
import gov.cabinetoffice.gap.adminbackend.dtos.spotlightSubmissions.SpotlightSubmissionDto; | ||
import gov.cabinetoffice.gap.adminbackend.enums.SpotlightBatchStatus; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SpotlightBatchDto { | ||
|
||
private UUID id; | ||
|
||
private SpotlightBatchStatus status; | ||
|
||
private Instant lastSendAttempt; | ||
|
||
private int version; | ||
|
||
private Instant created = Instant.now(); | ||
|
||
private Instant lastUpdated; | ||
|
||
private List<SpotlightSubmissionDto> spotlightSubmissions; | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...binetoffice/gap/adminbackend/dtos/spotlightSubmissions/SpotlightMandatoryQuestionDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package gov.cabinetoffice.gap.adminbackend.dtos.spotlightSubmissions; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.Instant; | ||
import java.util.UUID; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SpotlightMandatoryQuestionDto { | ||
|
||
private UUID id; | ||
|
||
private Integer schemeId; | ||
|
||
private UUID submissionId; | ||
|
||
private String name; | ||
|
||
private String addressLine1; | ||
|
||
private String addressLine2; | ||
|
||
private String city; | ||
|
||
private String county; | ||
|
||
private String postcode; | ||
|
||
private String orgType; | ||
|
||
private String companiesHouseNumber; | ||
|
||
private String charityCommissionNumber; | ||
|
||
private BigDecimal fundingAmount; | ||
|
||
private String[] fundingLocation; | ||
|
||
private String status; | ||
|
||
private Integer version; | ||
|
||
private Instant created; | ||
|
||
private long createdBy; | ||
|
||
private String gapId; | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
.../gov/cabinetoffice/gap/adminbackend/dtos/spotlightSubmissions/SpotlightSubmissionDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package gov.cabinetoffice.gap.adminbackend.dtos.spotlightSubmissions; | ||
|
||
import gov.cabinetoffice.gap.adminbackend.entities.SchemeEntity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.Instant; | ||
import java.util.UUID; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SpotlightSubmissionDto { | ||
|
||
private UUID id; | ||
|
||
private SpotlightMandatoryQuestionDto mandatoryQuestions; | ||
|
||
private SchemeEntity grantScheme; | ||
|
||
private String status; | ||
|
||
private Instant lastSendAttempt; | ||
|
||
private int version; | ||
|
||
private Instant created; | ||
|
||
private Instant lastUpdated; | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/gov/cabinetoffice/gap/adminbackend/mappers/SpotlightBatchMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package gov.cabinetoffice.gap.adminbackend.mappers; | ||
|
||
import gov.cabinetoffice.gap.adminbackend.dtos.spotlightBatch.SpotlightBatchDto; | ||
import gov.cabinetoffice.gap.adminbackend.dtos.spotlightSubmissions.SpotlightMandatoryQuestionDto; | ||
import gov.cabinetoffice.gap.adminbackend.dtos.spotlightSubmissions.SpotlightSubmissionDto; | ||
import gov.cabinetoffice.gap.adminbackend.entities.GrantMandatoryQuestions; | ||
import gov.cabinetoffice.gap.adminbackend.entities.SpotlightBatch; | ||
import gov.cabinetoffice.gap.adminbackend.entities.SpotlightSubmission; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.mapstruct.Named; | ||
|
||
import java.util.List; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface SpotlightBatchMapper { | ||
|
||
@Mapping(source = "spotlightSubmissions", target = "spotlightSubmissions", | ||
qualifiedByName = "mapSpotlightSubmissions") | ||
SpotlightBatchDto spotlightBatchToGetSpotlightBatchDto(SpotlightBatch spotlightBatch); | ||
|
||
@Named("mapSpotlightSubmissions") | ||
default List<SpotlightSubmissionDto> mapSpotlightSubmission(List<SpotlightSubmission> spotlightSubmissions) { | ||
return spotlightSubmissionListToSpotlightSubmissionDtoList(spotlightSubmissions); | ||
} | ||
|
||
@Mapping(source = "mandatoryQuestions", target = "mandatoryQuestions", qualifiedByName = "mapMandatoryQuestions") | ||
SpotlightSubmissionDto spotlightSubmissionToSpotlightSubmissionDto(SpotlightSubmission spotlightSubmission); | ||
|
||
@Named("mapMandatoryQuestions") | ||
default SpotlightMandatoryQuestionDto mapMandatoryQuestions(GrantMandatoryQuestions mandatoryQuestions) { | ||
return mandatoryQuestionsToSpotlightMandatoryQuestions(mandatoryQuestions); | ||
} | ||
|
||
@Mapping(source = "schemeEntity.id", target = "schemeId") | ||
@Mapping(source = "submission.id", target = "submissionId") | ||
@Mapping(source = "createdBy.id", target = "createdBy") | ||
SpotlightMandatoryQuestionDto mandatoryQuestionsToSpotlightMandatoryQuestions( | ||
GrantMandatoryQuestions mandatoryQuestions); | ||
|
||
default List<SpotlightSubmissionDto> spotlightSubmissionListToSpotlightSubmissionDtoList( | ||
List<SpotlightSubmission> submissions) { | ||
return submissions.stream().map(this::spotlightSubmissionToSpotlightSubmissionDto).toList(); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/gov/cabinetoffice/gap/adminbackend/mappers/SpotlightSubmissionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package gov.cabinetoffice.gap.adminbackend.mappers; | ||
|
||
import gov.cabinetoffice.gap.adminbackend.dtos.spotlightSubmissions.SpotlightMandatoryQuestionDto; | ||
import gov.cabinetoffice.gap.adminbackend.dtos.spotlightSubmissions.SpotlightSubmissionDto; | ||
import gov.cabinetoffice.gap.adminbackend.entities.GrantMandatoryQuestions; | ||
import gov.cabinetoffice.gap.adminbackend.entities.SpotlightSubmission; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.mapstruct.Named; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface SpotlightSubmissionMapper { | ||
|
||
@Mapping(source = "mandatoryQuestions", target = "mandatoryQuestions", qualifiedByName = "mapMandatoryQuestions") | ||
SpotlightSubmissionDto spotlightSubmissionToSpotlightSubmissionDto(SpotlightSubmission spotlightSubmission); | ||
|
||
@Named("mapMandatoryQuestions") | ||
default SpotlightMandatoryQuestionDto mapMandatoryQuestions(GrantMandatoryQuestions mandatoryQuestions) { | ||
return mandatoryQuestionsToSpotlightMandatoryQuestions(mandatoryQuestions); | ||
} | ||
|
||
@Mapping(source = "schemeEntity.id", target = "schemeId") | ||
@Mapping(source = "submission.id", target = "submissionId") | ||
@Mapping(source = "createdBy.id", target = "createdBy") | ||
SpotlightMandatoryQuestionDto mandatoryQuestionsToSpotlightMandatoryQuestions( | ||
GrantMandatoryQuestions mandatoryQuestions); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.