Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete feed from RDBMS #134

Merged
merged 17 commits into from
Sep 17, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/main/java/com/conveyal/gtfs/GTFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ public static DataSource createDataSource (String url, String username, String p
* It also lets you run a GraphQL API for all the feeds loaded into the database.
*/
public static void main (String[] args) throws IOException {
// Object mapper used for writing load or validation results to file.
ObjectMapper mapper = new ObjectMapper();
// Object mapper used for writing load or validation results to file (instantia).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be stray text in this comment. This is a detail, but I'd find the code easier to read if the variable were declared and initialized to null just before it is conditionally set to a new instance, around line 211 where we also declare File directory = null;

ObjectMapper mapper = null;
Options options = getOptions();
CommandLine cmd;
try {
Expand Down Expand Up @@ -210,6 +210,8 @@ public static void main (String[] args) throws IOException {
boolean storeResults = cmd.hasOption("json");
File directory = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the creation of the objectMapper down here, conditional upon storeResults=true.

if (storeResults) {
// Instantiate mapper for use with outputting load/validation results.
mapper = new ObjectMapper();
directory = cmd.getOptionValue("json") != null ? new File(cmd.getOptionValue("json")) : Files.createTempDir();
LOG.info("Storing results in directory: {}", directory.getAbsolutePath());
}
Expand Down Expand Up @@ -296,7 +298,7 @@ public static void main (String[] args) throws IOException {
String namespaceToDelete = cmd.getOptionValue("delete");

if (namespaceToDelete != null) {
LOG.info("Exporting feed with unique identifier {}", namespaceToDelete);
LOG.info("Deleting feed with unique identifier {}", namespaceToDelete);
try {
delete(namespaceToDelete, dataSource);
LOG.info("Feed {} has been successfully deleted.", namespaceToDelete);
Expand Down