Skip to content

Commit 380706e

Browse files
rmohammed-goacojgunnCOarul-foursealsdominicwestdylanwrightCO
authored
Release/13.0 - Multiple Submissions (#322)
* amend schemeeditorcontroller (#302) * url validation updated to accept # symbol (#305) * Fix/gap lss 431 (#306) * url validation updated to accept # symbol * existing unknown chane removed * Lss 701 ownership transfer case sensitive (#309) * Release/3.2 (#28) * Adding constraint on gap_admin table * Adding unique constraint on grant_applicant_organisation_profile table * Removing unique constraints on tables with foreign key constraints * Release/3.3 (#39) Release 3.3 * Release/3.6 (#47) * TMI2-253: Add pre-commit check and update .gitignore to include application-local.properties and .env.local * Fixing unique constraint on indexes (#33) * Fixing unique constraint on indexes * GAP-2070 delete applicant from apply DB (#15) Hard deletes an applicant after an admin deletes them * GAP-2070 grant_beneficiary fk constraint & set null delete cascade (#34) * GAP-2070 fixing not null constraint on created_by * GAP-2148: grant advert not publishing on selected date (#32) * GAP-2148 - fixing view to use UTC * GAP-2148 - fixing scheduled job & setting opening/closing dates to use UTC not BST (#40) - Removing code that formats the excel sheet as this was causing an unacceptable performance problem * GAP-2230: Removing transactional from inserting exports, as this results in the lambda being invoked before exports exist in the DB (#46) * Creates an endpoint which removes applications attached to an advert (#42) (#49) --------- Co-authored-by: paul-lawlor-tco <paul.lawlor1@cabinetoffice.gov.uk> Co-authored-by: Iain Cooper <iain.cooper@cabinetoffice.gov.uk> Co-authored-by: iaincooper-tco <99728291+iaincooper-tco@users.noreply.github.com> Co-authored-by: john-tco <135222889+john-tco@users.noreply.github.com> Co-authored-by: rachelswart <99667350+rachelswart@users.noreply.github.com> Co-authored-by: ConorFayleTCO <141320269+ConorFayleTCO@users.noreply.github.com> Co-authored-by: GavCookCO <99668051+GavCookCO@users.noreply.github.com> Co-authored-by: paul-lawlor-tco <paul.lawlor1@cabinetoffice.gov.uk> * Create DUMMY * Tmi2 501/revert tmi2 496 changes (#129) (#130) * revert tmi2-496 changes * format * Release/6.1 (#136) * Tmi2 501/revert tmi2 496 changes (#129) * revert tmi2-496 changes * format * Adding tables for completion_statistics.sql (#131) * Adding tables for completion_statistics.sql * Formatting... * Tn 154 calculations tables (#132) * Adding tables for completion_statistics.sql * Formatting... * Adding sequence for calculations table id * Tn 154 calculations tables (#133) * Adding tables for completion_statistics.sql * Formatting... * Adding sequence for calculations table id * Fixing incorrect format for migration script name. Combining 2 into 1 * Fixing issue with db migration script (#134) * Adding tables for completion_statistics.sql * Formatting... * Adding sequence for calculations table id * Fixing incorrect format for migration script name. Combining 2 into 1 * Fixing errors in db migration script --------- Co-authored-by: a-lor-cab <107372333+a-lor-cab@users.noreply.github.com> * Fix promoteToProd.yml (#179) * Adds query to find application with no ownership check to allow lambdas to call (#212) * Fix unpublish application form from lambda (#268) (#269) * Updating release 10.0 with develop changes (#274) * Fix unpublish application form from lambda (#268) * GAP-2531: Cascade delete grant export tables createdby column (#270) * GAP-2533: Fix advert scheduler view for BST (#273) * use LocalDateTime for grant opening and closing times (#272) * use LocalDateTime for grant opening and closing times * fix test * fix more tests * Tmi2 740 - Handling new locations for MQ saving to grant_beneficiary table (#271) * Adding two new columns to grant_beneficiary for new locations --------- Co-authored-by: jgunnCO <135321532+jgunnCO@users.noreply.github.com> Co-authored-by: Connor Macqueen <138442814+ConnorTCO@users.noreply.github.com> * GAP-2533: Retrospectively fix BST ads in prod (#276) (#278) * GAP-2533: Retrospectively fix BST ads in prod * GAP-2533: Including release time * GAP-2533: Overriding UTC opening/closing dates as Europe/London time * GAP-2533: Update scheduled closing times too * GAP-2533: Fix syntax * GAP-2533: Hard code datetimes for BST * Improves logs around updating and deleting open search (#280) * Improving logging (#283) * Improving logging II * amend schemeeditorcontroller * Release/12.0 (#308) * amend schemeeditorcontroller (#302) * url validation updated to accept # symbol * existing unknown chane removed (#307) --------- Co-authored-by: jgunnCO <135321532+jgunnCO@users.noreply.github.com> * convert admin email to lowercase --------- Co-authored-by: dominicwest <101722961+dominicwest@users.noreply.github.com> Co-authored-by: dylanwrightCO <135221918+dylanwrightCO@users.noreply.github.com> Co-authored-by: paul-lawlor-tco <paul.lawlor1@cabinetoffice.gov.uk> Co-authored-by: Iain Cooper <iain.cooper@cabinetoffice.gov.uk> Co-authored-by: iaincooper-tco <99728291+iaincooper-tco@users.noreply.github.com> Co-authored-by: john-tco <135222889+john-tco@users.noreply.github.com> Co-authored-by: rachelswart <99667350+rachelswart@users.noreply.github.com> Co-authored-by: ConorFayleTCO <141320269+ConorFayleTCO@users.noreply.github.com> Co-authored-by: GavCookCO <99668051+GavCookCO@users.noreply.github.com> Co-authored-by: Gavin Cook <gavin.cook1@cabinetoffice.gov.uk> Co-authored-by: JamieGunnCO <jamie.gunn@cabinetoffice.gov.uk> Co-authored-by: a-lor-cab <107372333+a-lor-cab@users.noreply.github.com> Co-authored-by: Connor Macqueen <138442814+ConnorTCO@users.noreply.github.com> Co-authored-by: dylanwrightCO <dylan.wright@cabinetoffice.gov.uk> Co-authored-by: jgunnCO <135321532+jgunnCO@users.noreply.github.com> * LSS-550 Update Apache Commons IO to version 2.19.0 (#311) * LSS-712 Updated upload-artifact action version to v4 (#312) * Add health check endpoint and update security configuration to permit… (#314) * Add health check endpoint and update security configuration to permit access * Undo extra indentation * Release/test deployments (#315) * Add health check endpoint and update security configuration to permit access * Undo extra indentation * Add support for multiple submissions for single user on application - Added submission name Add Submission name to LambdaSubmissionDefinition and Submission entity Add event stream for event service tables if it does not exist (Locally) Add troubleshooting * Add support for multiple submissions for single (#318) user on application - Added submission name Add Submission name to LambdaSubmissionDefinition and Submission entity Add event stream for event service tables if it does not exist (Locally) Add troubleshooting * Add support for multiple submissions for single user on application - Added submission name Add Submission name to LambdaSubmissionDefinition and Submission entity Add event stream for event service tables if it does not exist (Locally) Add troubleshooting Fix migrations * Remove event_stream schema creation SQL migration file - Causing mass issues again * Add Flyway migration troubleshooting section to README * Force deployment * Add allowsMultipleSubmissions field to ApplicationFormPatchDTO and ApplicationFormEntity. Update ApplicationFormController and ApplicationFormService to handle null applicationStatus checks. Introduce Flyway migration to add allows_multiple_submissions column to grant_application table. * Update ApplicationFormTestData to include allowsMultipleSubmissions field in ApplicationFormEntity instances. * Add validation annotation to ApplicationFormPatchDTO to ensure at least one field is not null. Introduce AtLeastOneFieldNotNull annotation and its validator for this purpose. * Add submissionName field to ExportedSubmissionsDto and update mapping logic in CustomGrantExportMapperImpl. Implement new method to retrieve submission name from the repository. * Enhance tests for submissionName handling in CustomGrantExportMapperImplTest and GrantExportServiceTest. Add assertions to verify mapping of submissionName and handle null cases. * Temporarly add --disableCentral flag to feature and pushImage workflows as their service is down and blocking pipeline --------- Co-authored-by: jgunnCO <135321532+jgunnCO@users.noreply.github.com> Co-authored-by: Arulelango Jayaraman <arul@fourseals.co.uk> Co-authored-by: dominicwest <101722961+dominicwest@users.noreply.github.com> Co-authored-by: dylanwrightCO <135221918+dylanwrightCO@users.noreply.github.com> Co-authored-by: paul-lawlor-tco <paul.lawlor1@cabinetoffice.gov.uk> Co-authored-by: Iain Cooper <iain.cooper@cabinetoffice.gov.uk> Co-authored-by: iaincooper-tco <99728291+iaincooper-tco@users.noreply.github.com> Co-authored-by: john-tco <135222889+john-tco@users.noreply.github.com> Co-authored-by: rachelswart <99667350+rachelswart@users.noreply.github.com> Co-authored-by: ConorFayleTCO <141320269+ConorFayleTCO@users.noreply.github.com> Co-authored-by: GavCookCO <99668051+GavCookCO@users.noreply.github.com> Co-authored-by: Gavin Cook <gavin.cook1@cabinetoffice.gov.uk> Co-authored-by: JamieGunnCO <jamie.gunn@cabinetoffice.gov.uk> Co-authored-by: a-lor-cab <107372333+a-lor-cab@users.noreply.github.com> Co-authored-by: Connor Macqueen <138442814+ConnorTCO@users.noreply.github.com> Co-authored-by: dylanwrightCO <dylan.wright@cabinetoffice.gov.uk> Co-authored-by: Ben Tadiar <ben@tadtech.co.uk>
1 parent 3778b9b commit 380706e

21 files changed

Lines changed: 239 additions & 21 deletions

.github/workflows/feature.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
--enableRetired
4141
--disableOssIndex true
4242
--disableRetireJS true
43+
--disableCentral true
4344
4445
- name: Upload Test results
4546
uses: actions/upload-artifact@v4

.github/workflows/pushImage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
args: >
4242
--enableRetired
4343
--disableOssIndex true
44+
--disableCentral true
4445
- name: Upload Test results
4546
uses: actions/upload-artifact@v4
4647
with:

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,97 @@ mvn Test -Dtest=className
5858
mvn Test -Dtest=className#methodName
5959
```
6060

61+
## Troubleshooting
62+
63+
### MapStruct Mapper Implementation Not Found
64+
65+
If you encounter an error like:
66+
67+
```
68+
Parameter X of constructor in ...Service required a bean of type '...Mapper' that could not be found.
69+
```
70+
71+
This typically means MapStruct hasn't generated the mapper implementation classes. MapStruct generates these during compilation.
72+
73+
**Solution:**
74+
75+
1. **Clean and rebuild the project:**
76+
```bash
77+
mvn clean compile
78+
```
79+
80+
Or in your IDE:
81+
- **IntelliJ IDEA**: Build → Rebuild Project
82+
- **Eclipse**: Project → Clean → Clean all projects
83+
84+
2. **Verify annotation processing is enabled:**
85+
- **IntelliJ IDEA**: Settings → Build, Execution, Deployment → Compiler → Annotation Processors → Enable annotation processing
86+
- **Eclipse**: Project Properties → Java Compiler → Annotation Processing → Enable annotation processing
87+
88+
3. **Check for compilation errors:** If there are any compilation errors in mapper interfaces or related DTOs, MapStruct won't generate the implementation classes. Check the compiler output for errors.
89+
90+
After a successful build, you should see generated mapper implementations in:
91+
```
92+
target/generated-sources/annotations/gov/cabinetoffice/gap/adminbackend/mappers/
93+
```
94+
95+
### Flyway Migration Checksum Mismatch
96+
97+
If you encounter an error during deployment like:
98+
99+
```
100+
Migration checksum mismatch for migration version X.XX
101+
-> Applied to database : -336000449
102+
-> Resolved locally : -252574045
103+
Either revert the changes to the migration, or run repair to update the schema history.
104+
```
105+
106+
This occurs when a migration file has been modified after it was already applied to the database. Flyway validates checksums to ensure migration files haven't been changed.
107+
108+
**Important:** Never modify migration files after they've been deployed to any environment. If you need to change something, create a new migration file instead.
109+
110+
#### Solution Options
111+
112+
**Option 1: Use Flyway Repair (Recommended)**
113+
114+
Enable Flyway repair mode temporarily in your deployment configuration:
115+
116+
```properties
117+
spring.flyway.repair=true
118+
```
119+
120+
Then restart the application. Flyway will repair all checksums to match the current migration files. After the repair completes, remove this property.
121+
122+
**Option 2: Manually Update Checksum in Database**
123+
124+
If you have direct database access, you can manually update the checksum in the `flyway_schema_history` table:
125+
126+
```sql
127+
-- Connect to your database and run:
128+
UPDATE flyway_schema_history
129+
SET checksum = <new_checksum> -- Use the checksum from the error message
130+
WHERE version = '<version>';
131+
```
132+
133+
**⚠️ Warning:** Only update the checksum if you're certain the migration file changes don't affect the database schema. If the migration was modified to change the schema, you may need to create a new migration to apply those changes instead.
134+
135+
**Option 3: Use Flyway CLI Repair Command**
136+
137+
If you have access to run commands on your deployment environment:
138+
139+
```bash
140+
flyway repair -url=jdbc:postgresql://<your-db-host>:5432/<database-name> \
141+
-user=<username> -password=<password> \
142+
-locations=filesystem:src/main/resources/db/migration
143+
```
144+
145+
#### Prevention
146+
147+
- **Never modify migration files** after they've been applied to any environment
148+
- If you need to change something, **create a new migration file** instead
149+
- Use version control to track migration history
150+
- Consider using `spring.flyway.validate-on-migrate=true` (already enabled) to catch these issues early
151+
61152
## System Context Diagram
62153
```mermaid
63154
flowchart TD

src/main/java/gov/cabinetoffice/gap/adminbackend/controllers/ApplicationFormController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ public ResponseEntity<GenericErrorDTO> updateApplicationForm(HttpServletRequest
215215

216216
this.applicationFormService.patchApplicationForm(applicationId, applicationFormPatchDTO, false);
217217

218-
EventType eventType = applicationFormPatchDTO.getApplicationStatus().equals(ApplicationStatusEnum.PUBLISHED)
218+
EventType eventType = applicationFormPatchDTO.getApplicationStatus() != null
219+
&& applicationFormPatchDTO.getApplicationStatus().equals(ApplicationStatusEnum.PUBLISHED)
219220
? EventType.APPLICATION_PUBLISHED : EventType.APPLICATION_UPDATED;
220221

221222
logApplicationEvent(eventType, request.getRequestedSessionId(), applicationId.toString());
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
package gov.cabinetoffice.gap.adminbackend.dtos.application;
22

3-
import javax.validation.constraints.NotNull;
4-
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
54
import com.fasterxml.jackson.annotation.JsonInclude;
65
import gov.cabinetoffice.gap.adminbackend.enums.ApplicationStatusEnum;
7-
import lombok.AllArgsConstructor;
6+
import gov.cabinetoffice.gap.adminbackend.validation.AtLeastOneFieldNotNull;
87
import lombok.Data;
98
import lombok.NoArgsConstructor;
109

1110
@Data
12-
@AllArgsConstructor
1311
@NoArgsConstructor
1412
@JsonInclude(JsonInclude.Include.NON_NULL)
13+
@JsonIgnoreProperties(ignoreUnknown = false)
14+
@AtLeastOneFieldNotNull
1515
public class ApplicationFormPatchDTO {
1616

17-
@NotNull
1817
private ApplicationStatusEnum applicationStatus;
1918

19+
private Boolean allowsMultipleSubmissions;
20+
21+
public ApplicationFormPatchDTO(ApplicationStatusEnum applicationStatus) {
22+
this.applicationStatus = applicationStatus;
23+
}
24+
25+
public ApplicationFormPatchDTO(ApplicationStatusEnum applicationStatus, Boolean allowsMultipleSubmissions) {
26+
this.applicationStatus = applicationStatus;
27+
this.allowsMultipleSubmissions = allowsMultipleSubmissions;
28+
}
29+
2030
}

src/main/java/gov/cabinetoffice/gap/adminbackend/dtos/grantExport/ExportedSubmissionsDto.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ public class ExportedSubmissionsDto {
1818
private UUID submissionId;
1919
private GrantExportStatus status;
2020
private ZonedDateTime submittedDate;
21+
private String submissionName;
2122
}

src/main/java/gov/cabinetoffice/gap/adminbackend/dtos/submission/LambdaSubmissionDefinition.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class LambdaSubmissionDefinition {
1818

1919
private String gapId;
2020

21+
private String submissionName;
22+
2123
private ZonedDateTime submittedDate;
2224

2325
private List<SubmissionSection> sections;

src/main/java/gov/cabinetoffice/gap/adminbackend/entities/ApplicationFormEntity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public class ApplicationFormEntity extends BaseEntity {
5454
@Enumerated(EnumType.STRING)
5555
private ApplicationStatusEnum applicationStatus;
5656

57+
@Column(name = "allows_multiple_submissions")
58+
private Boolean allowsMultipleSubmissions;
59+
5760
@Column(name = "definition", nullable = false, columnDefinition = "json")
5861
@Type(type = "json")
5962
private ApplicationDefinitionDTO definition;
@@ -70,6 +73,7 @@ public ApplicationFormEntity(Integer grantSchemeId, String applicationName, Inte
7073
this.lastUpdateBy = lastUpdateBy;
7174
this.lastPublished = null;
7275
this.applicationName = applicationName;
76+
this.allowsMultipleSubmissions = false;
7377
this.definition = definition;
7478
}
7579

src/main/java/gov/cabinetoffice/gap/adminbackend/entities/Submission.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public class Submission extends BaseEntity {
7777
@Column
7878
private String applicationName;
7979

80+
@Column(name = "submission_name")
81+
private String submissionName;
82+
8083
@Column
8184
@Enumerated(EnumType.STRING)
8285
private SubmissionStatus status;

src/main/java/gov/cabinetoffice/gap/adminbackend/mappers/ApplicationFormMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import gov.cabinetoffice.gap.adminbackend.dtos.application.questions.QuestionOptionsPatchDTO;
77
import gov.cabinetoffice.gap.adminbackend.dtos.application.questions.QuestionOptionsPostDTO;
88
import gov.cabinetoffice.gap.adminbackend.entities.ApplicationFormEntity;
9+
import org.mapstruct.BeanMapping;
910
import org.mapstruct.Mapper;
1011
import org.mapstruct.Mapping;
1112
import org.mapstruct.MappingTarget;
13+
import org.mapstruct.NullValuePropertyMappingStrategy;
1214

1315
import java.util.ArrayList;
1416
import java.util.List;
@@ -52,6 +54,7 @@ public interface ApplicationFormMapper {
5254

5355
List<ApplicationFormsFoundDTO> applicationFormFoundViewToDTO(List<ApplicationFormsFoundView> foundView);
5456

57+
@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
5558
void updateApplicationEntityFromPatchDto(ApplicationFormPatchDTO patchDTO,
5659
@MappingTarget ApplicationFormEntity applicationFormEntity);
5760

0 commit comments

Comments
 (0)