-
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.
Merge pull request #310 from Crown-Commercial-Service/NAS-4_WEB-2746_…
…add_TPP_fields_to_AS_and_GM added regulation and agreementType
- Loading branch information
Showing
12 changed files
with
490 additions
and
6 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
21 changes: 21 additions & 0 deletions
21
...crowncommercial/dts/scale/service/agreements/exception/InvalidAgreementTypeException.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,21 @@ | ||
package uk.gov.crowncommercial.dts.scale.service.agreements.exception; | ||
|
||
import uk.gov.crowncommercial.dts.scale.service.agreements.model.dto.Regulation; | ||
|
||
public class InvalidAgreementTypeException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = 1L; | ||
public static final String ERROR_MSG_TEMPLATE = "Invalid agreementType '%s' passed in. agreementType must be one of the following: [Dynamic Purchasing System, Dynamic Market, Open Framework, Closed Framework, PCR15 Framework, PCR06 Framework]"; | ||
public static final String ERROR_MSG_TEMPLATE_FOR_REGULATION = "agreementType must be one of the following: '%s' for '%s'"; | ||
|
||
public InvalidAgreementTypeException(final String agreementType) { | ||
super(String.format(ERROR_MSG_TEMPLATE, agreementType)); | ||
} | ||
|
||
public InvalidAgreementTypeException(final String allowList, final Regulation regulation) { | ||
super(String.format(ERROR_MSG_TEMPLATE_FOR_REGULATION, allowList, regulation.getName())); | ||
} | ||
} | ||
|
||
|
||
|
11 changes: 11 additions & 0 deletions
11
...ov/crowncommercial/dts/scale/service/agreements/exception/InvalidRegulationException.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,11 @@ | ||
package uk.gov.crowncommercial.dts.scale.service.agreements.exception; | ||
|
||
public class InvalidRegulationException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = 1L; | ||
public static final String ERROR_MSG_TEMPLATE = "Invalid regulation '%s' passed in. Regulation must be one of the following: [PA2023, PCR2015, PCR2006]"; | ||
|
||
public InvalidRegulationException(final String regulation) { | ||
super(String.format(ERROR_MSG_TEMPLATE, regulation)); | ||
} | ||
} |
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
66 changes: 66 additions & 0 deletions
66
...ain/java/uk/gov/crowncommercial/dts/scale/service/agreements/model/dto/AgreementType.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,66 @@ | ||
package uk.gov.crowncommercial.dts.scale.service.agreements.model.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.List; | ||
|
||
public enum AgreementType { | ||
|
||
@JsonProperty("Dynamic Purchasing System") | ||
DYNAMIC_PURCHASING_SYSTEM("Dynamic Purchasing System"), | ||
|
||
@JsonProperty("Dynamic Market") | ||
DYNAMIC_MARKET("Dynamic Market"), | ||
|
||
@JsonProperty("Open Framework") | ||
OPEN_FRAMEWORK("Open Framework"), | ||
|
||
@JsonProperty("Closed Framework") | ||
CLOSED_FRAMEWORK("Closed Framework"), | ||
|
||
@JsonProperty("PCR15 Framework") | ||
PCR15_FRAMEWORK("PCR15 Framework"), | ||
|
||
@JsonProperty("PCR06 Framework") | ||
PCR06_FRAMEWORK("PCR06 Framework"); | ||
|
||
private String name; | ||
|
||
private AgreementType(String name){ | ||
this.name = name; | ||
} | ||
|
||
public String getName(){ | ||
return this.name; | ||
} | ||
|
||
@JsonCreator | ||
public static AgreementType getAgreementTypeFromName(String value) { | ||
|
||
for (AgreementType a : AgreementType.values()) { | ||
if (a.getName().equalsIgnoreCase(value)) { | ||
return a; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static String getStringFormatForAgreementTypes( List<AgreementType> agreementTypeList){ | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
sb.append("["); | ||
|
||
for (int i = 0; i < agreementTypeList.size(); i++) { | ||
sb.append(agreementTypeList.get(i).getName()); | ||
if (i < agreementTypeList.size() - 1) { | ||
sb.append(", "); | ||
} | ||
} | ||
|
||
sb.append("]"); | ||
|
||
return sb.toString(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/uk/gov/crowncommercial/dts/scale/service/agreements/model/dto/Regulation.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,41 @@ | ||
package uk.gov.crowncommercial.dts.scale.service.agreements.model.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Regulation | ||
*/ | ||
public enum Regulation { | ||
|
||
@JsonProperty("PA2023") | ||
PA2023("PA2023"), | ||
|
||
@JsonProperty("PCR2015") | ||
PCR2015("PCR2015"), | ||
|
||
@JsonProperty("PCR2006") | ||
PCR2006("PCR2006"); | ||
|
||
private String name; | ||
|
||
private Regulation(String name){ | ||
this.name = name; | ||
} | ||
|
||
public String getName(){ | ||
return this.name; | ||
} | ||
|
||
@JsonCreator | ||
public static Regulation getRegulationFromName(String value) { | ||
|
||
for (Regulation r : Regulation.values()) { | ||
if (r.getName().equalsIgnoreCase(value)) { | ||
return r; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
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
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.