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..7186eef39 100644 --- a/src/main/java/com/conveyal/datatools/manager/models/Deployment.java +++ b/src/main/java/com/conveyal/datatools/manager/models/Deployment.java @@ -442,31 +442,16 @@ 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); - } - - /** 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 ""; } } @@ -487,37 +472,17 @@ 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). */ 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 760a0a11f..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,28 +6,11 @@ /** * 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 { 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..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,35 +7,11 @@ /** * 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 { 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; }