From 91f5b1848a42629742bacc189b03e4c873ea8c9e Mon Sep 17 00:00:00 2001 From: miles-grant-ibi Date: Fri, 13 Dec 2024 11:52:13 -0500 Subject: [PATCH 1/2] remove project-wide deployment settings --- .../datatools/manager/models/Deployment.java | 35 ++----------------- .../manager/models/OtpBuildConfig.java | 19 ---------- .../manager/models/OtpRouterConfig.java | 26 -------------- .../datatools/manager/models/Project.java | 6 ---- 4 files changed, 2 insertions(+), 84 deletions(-) diff --git a/src/main/java/com/conveyal/datatools/manager/models/Deployment.java b/src/main/java/com/conveyal/datatools/manager/models/Deployment.java index cb06e25fd..4fe7ebb92 100644 --- a/src/main/java/com/conveyal/datatools/manager/models/Deployment.java +++ b/src/main/java/com/conveyal/datatools/manager/models/Deployment.java @@ -442,22 +442,12 @@ public byte[] generateBuildConfig() throws IOException { } return customBuildConfig != null ? customBuildConfig.getBytes(StandardCharsets.UTF_8) - : getProjectBuildConfig(); - } - - /** - * If a project build config exists, return this as a byte array, or null if not available. - */ - private byte[] getProjectBuildConfig() { - Project project = parentProject(); - return project.buildConfig != null - ? writeToBytes(project.buildConfig) : null; } public String generateBuildConfigAsString() { if (customBuildConfig != null) return customBuildConfig; - return writeToString(this.parentProject().buildConfig); + return null; } /** Convenience method to write serializable object (primarily for router/build config objects) to byte array. */ @@ -487,30 +477,9 @@ public byte[] generateRouterConfig() throws IOException { customRouterConfig = downloadedConfig; } - byte[] customRouterConfigString = customRouterConfig != null + return customRouterConfig != null ? customRouterConfig.getBytes(StandardCharsets.UTF_8) : null; - - byte[] routerConfigString = parentProject().routerConfig != null - ? writeToBytes(parentProject().routerConfig) - : null; - - // If both router configs are present, merge the JSON before returning - // Merger code from: https://stackoverflow.com/questions/35747813/how-to-merge-two-json-strings-into-one-in-java - if (customRouterConfigString != null && routerConfigString != null) { - ObjectMapper mapper = new ObjectMapper(); - Map map1 = mapper.readValue(customRouterConfigString, Map.class); - Map map2 = mapper.readValue(routerConfigString, Map.class); - Map merged = new HashMap(map2); - merged.putAll(map1); - return mapper.writeValueAsString(merged).getBytes(); - } - - return customRouterConfigString != null - ? customRouterConfigString - : routerConfigString != null - ? routerConfigString - : null; } /** Generate router config for deployment as byte array (for writing to file output stream). */ diff --git a/src/main/java/com/conveyal/datatools/manager/models/OtpBuildConfig.java b/src/main/java/com/conveyal/datatools/manager/models/OtpBuildConfig.java index 760a0a11f..4ee8471b4 100644 --- a/src/main/java/com/conveyal/datatools/manager/models/OtpBuildConfig.java +++ b/src/main/java/com/conveyal/datatools/manager/models/OtpBuildConfig.java @@ -11,23 +11,4 @@ public class OtpBuildConfig implements Serializable { private static final long serialVersionUID = 1L; - public Boolean fetchElevationUS; - // FIXME: elevation bucket causing NPE issue if missing values when deploying to OTP - // public S3Bucket elevationBucket; - - public Boolean stationTransfers; - - public Double subwayAccessTime; - - /** Currently only supports no-configuration fares, e.g. New York or San Francisco */ - public String fares; - - public OtpBuildConfig() {} - - public static class S3Bucket implements Serializable { - private static final long serialVersionUID = 1L; - public String accessKey; - public String secretKey; - public String bucketName; - } } diff --git a/src/main/java/com/conveyal/datatools/manager/models/OtpRouterConfig.java b/src/main/java/com/conveyal/datatools/manager/models/OtpRouterConfig.java index 09771fb76..6be7d51e4 100644 --- a/src/main/java/com/conveyal/datatools/manager/models/OtpRouterConfig.java +++ b/src/main/java/com/conveyal/datatools/manager/models/OtpRouterConfig.java @@ -11,31 +11,5 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class OtpRouterConfig implements Serializable { private static final long serialVersionUID = 1L; - public Double driveDistanceReluctance; - public Double stairsReluctance; - - public Collection updaters; - - public ItineraryFilter itineraryFilters; - - public static class ItineraryFilter implements Serializable { - private static final long serialVersionUID = 1L; - public String nonTransitGeneralizedCostLimit; - } - - public static class Updater implements Serializable { - private static final long serialVersionUID = 1L; - public String type; - - public Integer frequencySec; - - public String sourceType; - - public String url; - - public String feedId; - } - - public String requestLogFile; } diff --git a/src/main/java/com/conveyal/datatools/manager/models/Project.java b/src/main/java/com/conveyal/datatools/manager/models/Project.java index eccb7d33a..073405297 100644 --- a/src/main/java/com/conveyal/datatools/manager/models/Project.java +++ b/src/main/java/com/conveyal/datatools/manager/models/Project.java @@ -47,10 +47,6 @@ public class Project extends Model { public boolean useCustomOsmBounds; - public OtpBuildConfig buildConfig; - - public OtpRouterConfig routerConfig; - public String organizationId; /** Last successful auto deploy. **/ @@ -111,8 +107,6 @@ public List availableOtpServers() { public Project() { - this.buildConfig = new OtpBuildConfig(); - this.routerConfig = new OtpRouterConfig(); this.useCustomOsmBounds = false; } From 47bfc275608a9380db30ba621ccca5dc8efe78d4 Mon Sep 17 00:00:00 2001 From: miles-grant-ibi Date: Tue, 17 Dec 2024 11:01:08 -0500 Subject: [PATCH 2/2] clean up --- .../datatools/manager/models/Deployment.java | 18 +++++++----------- .../manager/models/OtpBuildConfig.java | 2 ++ .../manager/models/OtpRouterConfig.java | 2 ++ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/conveyal/datatools/manager/models/Deployment.java b/src/main/java/com/conveyal/datatools/manager/models/Deployment.java index 4fe7ebb92..7186eef39 100644 --- a/src/main/java/com/conveyal/datatools/manager/models/Deployment.java +++ b/src/main/java/com/conveyal/datatools/manager/models/Deployment.java @@ -446,17 +446,12 @@ public byte[] generateBuildConfig() throws IOException { } public String generateBuildConfigAsString() { - if (customBuildConfig != null) return customBuildConfig; - return null; - } - - /** Convenience method to write serializable object (primarily for router/build config objects) to byte array. */ - private byte[] writeToBytes(O object) { try { - return otpConfigMapper.writer().writeValueAsBytes(object); - } catch (JsonProcessingException e) { - LOG.error("Value contains malformed JSON", e); - return null; + return new String(generateBuildConfig(), StandardCharsets.UTF_8); + // TODO: Correctly generate default build config + } catch (Exception e) { + LOG.error("Failed to generate build config: ", e); + return ""; } } @@ -486,7 +481,8 @@ public byte[] generateRouterConfig() throws IOException { public String generateRouterConfigAsString() { try { return new String(generateRouterConfig(), StandardCharsets.UTF_8); - } catch (IOException e) { + // TODO: Correctly generate default router config + } catch (Exception e) { LOG.error("Failed to generate router config: ", e); return ""; } diff --git a/src/main/java/com/conveyal/datatools/manager/models/OtpBuildConfig.java b/src/main/java/com/conveyal/datatools/manager/models/OtpBuildConfig.java index 4ee8471b4..d0f385ef4 100644 --- a/src/main/java/com/conveyal/datatools/manager/models/OtpBuildConfig.java +++ b/src/main/java/com/conveyal/datatools/manager/models/OtpBuildConfig.java @@ -6,6 +6,8 @@ /** * Created by demory on 3/8/15. + * + * TODO: Figure out how to remove this class without causing problems in the DB migration */ @JsonIgnoreProperties(ignoreUnknown = true) public class OtpBuildConfig implements Serializable { diff --git a/src/main/java/com/conveyal/datatools/manager/models/OtpRouterConfig.java b/src/main/java/com/conveyal/datatools/manager/models/OtpRouterConfig.java index 6be7d51e4..da2d1961d 100644 --- a/src/main/java/com/conveyal/datatools/manager/models/OtpRouterConfig.java +++ b/src/main/java/com/conveyal/datatools/manager/models/OtpRouterConfig.java @@ -7,6 +7,8 @@ /** * Created by demory on 3/8/15. + * + * TODO: Figure out how to remove this class without causing problems in the DB migration */ @JsonIgnoreProperties(ignoreUnknown = true) public class OtpRouterConfig implements Serializable {