Skip to content

Commit

Permalink
Merge pull request #371 from HSLdevcom/DT-5388
Browse files Browse the repository at this point in the history
Add new option for gbfs updaters to not have .json in filenames
  • Loading branch information
vesameskanen authored May 2, 2022
2 parents 45bcda5 + dc2d094 commit 57eca54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void configurePolling (Graph graph, JsonNode config) throws Exception
// Each updater can be assigned a unique network ID in the configuration to prevent returning bikes at
// stations for another network. TODO shouldn't we give each updater a unique network ID by default?
String networkName = config.path("network").asText();
boolean allowOverloading = config.path("allowOverloading").asText().equals("true");
boolean allowOverloading = config.path("allowOverloading").asText().equals("true");

BikeRentalDataSource source = null;
if (sourceType != null) {
Expand Down Expand Up @@ -94,7 +94,8 @@ protected void configurePolling (Graph graph, JsonNode config) throws Exception
} else if (sourceType.equals("uip-bike")) {
source = new UIPBikeRentalDataSource(apiKey);
} else if (sourceType.equals("gbfs")) {
source = new GbfsBikeRentalDataSource(networkName, allowOverloading);
boolean missesFileExtension = config.path("missesFileExtension").asText().equals("true");
source = new GbfsBikeRentalDataSource(networkName, allowOverloading, missesFileExtension);
} else if (sourceType.equals("smoove")) {
source = new SmooveBikeRentalDataSource(networkName, allowOverloading);
} else if (sourceType.equals("bicimad")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ public class GbfsBikeRentalDataSource implements BikeRentalDataSource, JsonConfi

private String networkName;

private boolean missesFileExtension;

/** Some car rental systems and flex transit systems work exactly like bike rental, but with cars. */
private boolean routeAsCar;

public GbfsBikeRentalDataSource (String networkName, boolean allowOverloading) {
public GbfsBikeRentalDataSource (String networkName, boolean allowOverloading, boolean missesFileExtension) {
stationInformationSource = new GbfsStationDataSource(allowOverloading);
stationStatusSource = new GbfsStationStatusDataSource();
// floatingBikeSource = new GbfsFloatingBikeDataSource();
Expand All @@ -38,14 +40,16 @@ public GbfsBikeRentalDataSource (String networkName, boolean allowOverloading) {
} else {
this.networkName = "GBFS";
}
this.missesFileExtension = missesFileExtension;
}

public void setBaseUrl (String url) {
baseUrl = url;
if (!baseUrl.endsWith("/")) baseUrl += "/";
stationInformationSource.setUrl(baseUrl + "station_information.json");
stationStatusSource.setUrl(baseUrl + "station_status.json");
// floatingBikeSource.setUrl(baseUrl + "free_bike_status.json");
String fileExtension = missesFileExtension ? "" : ".json";
stationInformationSource.setUrl(baseUrl + "station_information" + fileExtension);
stationStatusSource.setUrl(baseUrl + "station_status" + fileExtension);
// floatingBikeSource.setUrl(baseUrl + "free_bike_status" + fileExtension);
}

@Override
Expand Down

0 comments on commit 57eca54

Please sign in to comment.