Skip to content

Commit

Permalink
Merge pull request #74 from cabinetoffice/release/6.0
Browse files Browse the repository at this point in the history
Release/6.0
  • Loading branch information
dominicwest authored Dec 6, 2023
2 parents b1ad641 + b047441 commit 6fcda7d
Show file tree
Hide file tree
Showing 52 changed files with 1,445 additions and 206 deletions.
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@
<artifactId>commons-lang3</artifactId>
<version>3.13.0</version>
</dependency>

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
36 changes: 36 additions & 0 deletions pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Description

Ticket # and link

Summary of the changes and the related issue. List any dependencies that are required for this change:

## Type of change

Please check the relevant options.

- [ ] Bug fix (non-breaking change which fixes an issue).
- [ ] New feature (non-breaking change which adds functionality).
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected).
- [ ] This change requires a documentation update.

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes:

- [ ] Unit Test

- [ ] Integration Test (if applicable)

- [ ] End to End Test (if applicable)

## Screenshots (if appropriate):

Please attach screenshots of the change if it is a UI change:

# Checklist:

- [ ] If I have listed dependencies above, I have ensured that they are present in the target branch.
- [ ] I have performed a self-review of my code.
- [ ] I have commented my code in hard-to-understand areas.
- [ ] I have made corresponding changes to the documentation where applicable.
- [ ] I have ran cypress tests and they all pass locally.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package gov.cabinetoffice.gap.applybackend.config;

import com.amazonaws.services.sqs.AmazonSQS;
import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@RequiredArgsConstructor
public class SQSConfig {

@Bean
AmazonSQS amazonSQS() {
return AmazonSQSClientBuilder.defaultClient();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package gov.cabinetoffice.gap.applybackend.config;

import lombok.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.validation.constraints.NotNull;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Configuration
@ConfigurationProperties(prefix = "spotlight-queue")
public class SpotlightQueueConfigProperties {

@NotNull
private String queueUrl;

}
Original file line number Diff line number Diff line change
@@ -1,50 +1,57 @@
package gov.cabinetoffice.gap.applybackend.constants;

import gov.cabinetoffice.gap.applybackend.enums.GrantMandatoryQuestionOrgType;

public class MandatoryQuestionConstants {

public static final String ORGANISATION_DETAILS_SECTION_ID = "ORGANISATION_DETAILS";
public static final String ORGANISATION_DETAILS_SECTION_TITLE = "Your Organisation";
public static final String ORGANISATION_DETAILS_SECTION_TITLE = "Your organisation";
public static final String ORGANISATION_INDIVIDUAL_DETAILS_SECTION_TITLE = "Your details";

public static final String FUNDING_DETAILS_SECTION_ID = "FUNDING_DETAILS";
public static final String FUNDING_DETAILS_SECTION_TITLE = "Funding";

public static final String APPLICANT_ORG_NAME_TITLE = "Enter the name of your organisation";
public static final String APPLICANT_SUBMISSION_ORG_NAME_TITLE = "Name";
public static final String APPLICANT_ORG_NAME_PROFILE_FIELD = "ORG_NAME";
public static final String APPLICANT_ORG_NAME_HINT = "This is the official name of your organisation. It could be the name that is registered with Companies House or the Charities Commission";
public static final String APPLICANT_ORG_NAME_ADMIN_SUMMARY = "organisation legal name";
public static final int APPLICANT_ORG_NAME_MIN_LENGTH = 0;
public static final int APPLICANT_ORG_NAME_MAX_LENGTH = 250;

public static final String APPLICANT_TYPE_TITLE = "Choose your organisation type";
public static final String APPLICANT_SUBMISSION_TYPE_TITLE = "Type of organisation";
public static final String APPLICANT_INDIVIDUAL_SUBMISSION_TYPE_TITLE = "Type of application";
public static final String APPLICANT_TYPE_PROFILE_FIELD = "ORG_TYPE";
public static final String APPLICANT_TYPE_HINT_TEXT = "Choose the option that best describes your organisation";
public static final String APPLICANT_TYPE_ADMIN_SUMMARY = "organisation type (e.g. limited company)";
public static final String[] APPLICANT_TYPE_OPTIONS = new String[] {
"Limited company",
"Non-limited company",
"Registered charity",
"Unregistered charity",
"Other",
"Charity",
"I am applying as an Individual",
GrantMandatoryQuestionOrgType.LIMITED_COMPANY.toString(),
GrantMandatoryQuestionOrgType.NON_LIMITED_COMPANY.toString(),
GrantMandatoryQuestionOrgType.REGISTERED_CHARITY.toString(),
GrantMandatoryQuestionOrgType.UNREGISTERED_CHARITY.toString(),
GrantMandatoryQuestionOrgType.OTHER.toString(),
GrantMandatoryQuestionOrgType.CHARITY.toString(),
GrantMandatoryQuestionOrgType.INDIVIDUAL.toString(),
};

public static final String ORGANISATION_ADDRESS_TITLE = "Enter your organisations address";
public static final String ORGANISATION_SUBMISSION_ADDRESS_TITLE = "Address";
public static final String ORGANISATION_ADDRESS_PROFILE_FIELD = "ORG_ADDRESS";
public static final String ORGANISATION_ADDRESS_ADMIN_SUMMARY = "Enter your organisations address";

public static final String CHARITY_COMMISSION_NUMBER_TITLE = "Enter your Charity Commission number (if you have one)";
public static final String CHARITY_COMMISSION_NUMBER_TITLE = "Enter your Charity Commission number";
public static final String CHARITY_COMMISSION_NUMBER_PROFILE_FIELD = "ORG_CHARITY_NUMBER";
public static final String CHARITY_COMMISSION_NUMBER_HINT_TEXT = "Funding organisation might use this to identify your organisation when you apply for a grant. It might also be used to check your organisation is legitimate.";
public static final String CHARITY_COMMISSION_NUMBER_ADMIN_SUMMARY = "Charity Commission number (if applicable)";
public static final String CHARITY_COMMISSION_NUMBER_ADMIN_SUMMARY = "Charity Commission number";
public static final int CHARITY_COMMISSION_NUMBER_MIN_LENGTH = 2;
public static final int CHARITY_COMMISSION_NUMBER_MAX_LENGTH = 15;
public static final String CHARITY_COMMISSION_NUMBER_VALID_INPUT = "alphanumeric-nospace";

public static final String COMPANIES_HOUSE_NUMBER_TITLE = "Enter your Companies House number (if you have one)";
public static final String COMPANIES_HOUSE_NUMBER_TITLE = "Enter your Companies House number";
public static final String COMPANIES_HOUSE_NUMBER_PROFILE_FIELD = "ORG_COMPANIES_HOUSE";
public static final String COMPANIES_HOUSE_NUMBER_HINT_TEXT = "Funding organisation might use this to identify your organisation when you apply for a grant. It might also be used to check your organisation is legitimate.";
public static final String COMPANIES_HOUSE_NUMBER_ADMIN_SUMMARY = "Companies House number (if applicable)";
public static final String COMPANIES_HOUSE_NUMBER_ADMIN_SUMMARY = "Companies House number";
public static final int COMPANIES_HOUSE_NUMBER_MIN_LENGTH = 2;
public static final int COMPANIES_HOUSE_NUMBER_MAX_LENGTH = 8;
public static final String COMPANIES_HOUSE_NUMBER_VALID_INPUT = "alphanumeric-nospace";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ public class GetGrantAdvertDto {
private boolean isAdvertInDatabase;

private GetGrantMandatoryQuestionDto mandatoryQuestionsDto;

@JsonProperty("isPublished")
private boolean isPublished;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package gov.cabinetoffice.gap.applybackend.dto.api;

import gov.cabinetoffice.gap.applybackend.enums.GrantApplicantStatus;
import lombok.Data;
import lombok.RequiredArgsConstructor;

import java.time.Instant;

@Data
@RequiredArgsConstructor
public class GetGrantApplicationDto {
private Integer id;
private Integer grantSchemeId;
private Integer version;
private Instant created;
private Instant lastUpdated;
private Integer lastUpdatedBy;
private String applicationName;
private GrantApplicantStatus applicationStatus;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public class GetGrantMandatoryQuestionDto {
private String fundingAmount;

private List<String> fundingLocation;

private String status;
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
package gov.cabinetoffice.gap.applybackend.dto.api;

import lombok.AllArgsConstructor;
import lombok.Builder;
import gov.cabinetoffice.gap.applybackend.model.GrantScheme;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;

import java.time.ZonedDateTime;
import java.time.Instant;

@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
@RequiredArgsConstructor
public class GetGrantSchemeDto {
private long id;
private long funderId;
private int version;
private ZonedDateTime lastUpdated;
private long lastUpdatedBy;
private Integer id;
private Integer funderId;
private Integer version;
private Instant createdDate;
private Instant lastUpdated;
private Integer lastUpdatedBy;
private String ggisIdentifier;
private String schemeName;
private String schemeContact;
private String sectionId;
private String sectionTitle;
private String sectionStatus;
}
private String name;
private String email;

public GetGrantSchemeDto(final GrantScheme grantScheme) {
this.id = grantScheme.getId();
this.funderId = grantScheme.getFunderId();
this.version = grantScheme.getVersion();
this.createdDate = grantScheme.getCreatedDate();
this.lastUpdated = grantScheme.getLastUpdated();
this.lastUpdatedBy = grantScheme.getLastUpdatedBy();
this.ggisIdentifier = grantScheme.getGgisIdentifier();
this.name = grantScheme.getName();
this.email = grantScheme.getEmail();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gov.cabinetoffice.gap.applybackend.dto.api;

import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
@Builder
public class GetGrantSchemeWithApplicationAndAdverts {
private GetGrantSchemeDto grantScheme;
private GetGrantApplicationDto grantApplication;
private List<GetGrantAdvertDto> grantAdverts;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum GrantApplicantOrganisationType {
REGISTERED_CHARITY("Registered charity"),
UNREGISTERED_CHARITY("Unregistered charity"),
CHARITY("Charity"),
INDIVIDUAL("I am applying as an Individual"),
INDIVIDUAL("I am applying as an individual"),
OTHER("Other");

private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public enum GrantMandatoryQuestionFundingLocation {
YORKSHIRE_AND_THE_HUMBER("Yorkshire and the Humber"),
EAST_MIDLANDS_ENGLAND("East Midlands (England)"),
WEST_MIDLANDS("West Midlands (England)"),
EAST_ENGLAND("East England"),
EAST_ENGLAND("East (England)"),
LONDON("London"),
SOUTH_EAST_ENGLAND("South East (England)"),
SOUTH_WEST_ENGLAND("South West (England)"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public enum GrantMandatoryQuestionOrgType {
REGISTERED_CHARITY("Registered charity"),
UNREGISTERED_CHARITY("Unregistered charity"),
CHARITY("Charity"),
INDIVIDUAL("I am applying as an Individual"),
INDIVIDUAL("I am applying as an individual"),
OTHER("Other");

private String name;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package gov.cabinetoffice.gap.applybackend.enums;

public enum SpotlightBatchStatus {
QUEUED,
SUCCESS,
FAILURE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package gov.cabinetoffice.gap.applybackend.enums;

public enum SpotlightSubmissionStatus {
QUEUED,
SENT,
SEND_ERROR,
GGIS_ERROR,
VALIDATION_ERROR
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import gov.cabinetoffice.gap.applybackend.dto.api.UpdateGrantMandatoryQuestionDto;
import gov.cabinetoffice.gap.applybackend.enums.GrantMandatoryQuestionFundingLocation;
import gov.cabinetoffice.gap.applybackend.enums.GrantMandatoryQuestionOrgType;
import gov.cabinetoffice.gap.applybackend.enums.GrantMandatoryQuestionStatus;
import gov.cabinetoffice.gap.applybackend.model.GrantMandatoryQuestions;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
Expand All @@ -27,8 +28,14 @@ public interface GrantMandatoryQuestionMapper {
@Mapping(source = "fundingAmount", target = "fundingAmount", qualifiedByName = "mapEntityFundingAmountToDtoFundingAmount")
@Mapping(source = "fundingLocation", target = "fundingLocation", qualifiedByName = "mapEntityFundingLocationToDtoFundingLocation")
@Mapping(source = "submission.id", target = "submissionId")
@Mapping(source = "status", target = "status", qualifiedByName = "mapEntityStatusToDtoStatus")
GetGrantMandatoryQuestionDto mapGrantMandatoryQuestionToGetGrantMandatoryQuestionDTO(GrantMandatoryQuestions source);

@Named("mapEntityStatusToDtoStatus")
default String mapEntityStatusToDtoStatus(GrantMandatoryQuestionStatus status) {
return status.toString();
}

@Named("mapEntityOrgTypeToDtoOrgType")
default String mapEntityOrgTypeToDtoOrgType(GrantMandatoryQuestionOrgType type) {
return type.toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package gov.cabinetoffice.gap.applybackend.mapper;

import gov.cabinetoffice.gap.applybackend.dto.api.GetGrantApplicationDto;
import gov.cabinetoffice.gap.applybackend.dto.api.GetGrantSchemeDto;
import gov.cabinetoffice.gap.applybackend.model.GrantScheme;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;


@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface GrantSchemeMapper {
GetGrantSchemeDto grantSchemeToGetGrantSchemeDto(GrantScheme grantScheme);

@Mapping(source = "grantApplication", target = ".")
GetGrantApplicationDto grantSchemeToGetGrantApplicationDto(GrantScheme grantScheme);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gov.cabinetoffice.gap.applybackend.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import gov.cabinetoffice.gap.applybackend.enums.GrantAdvertStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down Expand Up @@ -33,7 +34,6 @@
@EntityListeners(AuditingEntityListener.class)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
Expand All @@ -50,6 +50,7 @@ public class GrantAdvert extends BaseEntity {
@JoinColumn(name = "scheme_id", nullable = false)
@ToString.Exclude
@JsonIgnoreProperties({"hibernateLazyInitializer"})
@JsonManagedReference
private GrantScheme scheme;

@Column(name = "version", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.CascadeType;
import javax.persistence.Column;
Expand Down Expand Up @@ -60,4 +61,17 @@ public class GrantApplicantOrganisationProfile {

@Column
private String companiesHouseNumber;

public Boolean isComplete() {
if (StringUtils.isEmpty(legalName)) return false;
if (StringUtils.isEmpty(addressLine1)) return false;
if (StringUtils.isEmpty(town)) return false;
if (StringUtils.isEmpty(postcode)) return false;
if (type == null) return false;
if (type != GrantApplicantOrganisationType.INDIVIDUAL && type != GrantApplicantOrganisationType.NON_LIMITED_COMPANY) {
if (StringUtils.isEmpty(getCompaniesHouseNumber())) return false;
return !StringUtils.isEmpty(getCharityCommissionNumber());
}
return true;
}
}
Loading

0 comments on commit 6fcda7d

Please sign in to comment.