From 32e61bb3c5837ea5cc7f14aa04f1dac2fc9e440d Mon Sep 17 00:00:00 2001 From: "Keith W. Boone" <36998841+keithboone@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:56:19 -0500 Subject: [PATCH] Updated IDestination to add default methods for is* methods. (#17) --- .../gov/cdc/izgateway/model/IDestination.java | 56 ++++++++++++++++--- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/src/main/java/gov/cdc/izgateway/model/IDestination.java b/src/main/java/gov/cdc/izgateway/model/IDestination.java index 5442841..299d4c7 100644 --- a/src/main/java/gov/cdc/izgateway/model/IDestination.java +++ b/src/main/java/gov/cdc/izgateway/model/IDestination.java @@ -2,18 +2,36 @@ import java.util.Date; +import org.apache.commons.lang3.StringUtils; + import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonFormat.Shape; import gov.cdc.izgateway.common.Constants; import gov.cdc.izgateway.common.HasDestinationUri; +import io.swagger.v3.oas.annotations.media.Schema; public interface IDestination extends IEndpoint, HasDestinationUri { @SuppressWarnings("serial") static class Map extends MappableEntity {} static String ID_PATTERN = "^[-_\\p{Alnum}]+$"; + /** Version value for IIS endpoints using CDC Schema */ + public static final String IZGW_2011 = "2011"; + /** Version value for IIS endpoints using 2014 Schema (subset of HUB Schema w/o HubHeader) */ + public static final String IZGW_2014 = "2014"; + /** Version value for IIS endpoints using IZGW Hub Schema */ + public static final String IZGW_HUB = "HUB"; + /** Version value for ADS endpoints using DEX 1.0 Schema */ + public static final String IZGW_ADS_VERSION1 = "DEX1.0"; + /** Version value for ADS endpoints using DEX 2.0 Schema */ + public static final String IZGW_ADS_VERSION2 = "DEX2.0"; + /** Version value for ADS endpoints using NDLP 1.0 Schema (Azure with v1 Folder Structure) */ + public static final String IZGW_AZURE_VERSION1 = "V2022-12-31"; + /** Version value for ADS endpoints using NDLP 2.0 Schema (Azure with v2 Folder Structure) */ + public static final String IZGW_AZURE_VERSION2 = "V2022-12-31"; + String getFacilityId(); IDestinationId getId(); @@ -84,16 +102,38 @@ static class Map extends MappableEntity {} IDestination safeCopy(); - boolean is2011(); - - boolean is2014(); - - boolean isHub(); + @JsonIgnore + @Schema(description = "True if this destination supports the original CDC 2011 Protocol", hidden=true) + default boolean is2011() { + return IZGW_2011.equals(getDestVersion()); + } - boolean isDex(); + @JsonIgnore + @Schema(description = "True if this destination supports the IZ Gateway 2014 Protocol", hidden=true) + default boolean is2014() { + String destVersion = getDestVersion(); + return StringUtils.isEmpty(destVersion) || IZGW_2014.equals(destVersion); + } + + @JsonIgnore + @Schema(description = "True if this destination supports the IZ Gateway Hub Protocol", hidden=true) + default boolean isHub() { + return IZGW_HUB.equalsIgnoreCase(getDestVersion()); + } + + @JsonIgnore + @Schema(description = "True if this destination supports the CDC DEX Protocol", hidden=true) + default boolean isDex() { + String destVersion = getDestVersion(); + return IZGW_ADS_VERSION1.equals(destVersion) || IZGW_ADS_VERSION2.equals(destVersion); + } + + @JsonIgnore + @Schema(description = "True if this destination supports the Azure Blob Storage Protocol", hidden=true) + default boolean isAzure() { + return IZGW_AZURE_VERSION1.equals(getDestVersion()); + } - boolean isAzure(); - String getDestinationUri(); } \ No newline at end of file