diff --git a/src/main/java/com/conveyal/gtfs/loader/JdbcTableWriter.java b/src/main/java/com/conveyal/gtfs/loader/JdbcTableWriter.java index 7f12965e..fe8b99cb 100644 --- a/src/main/java/com/conveyal/gtfs/loader/JdbcTableWriter.java +++ b/src/main/java/com/conveyal/gtfs/loader/JdbcTableWriter.java @@ -160,20 +160,13 @@ public String update(Integer id, String json, boolean autoCommit) throws SQLExce if (specTable.name.equals("patterns")) { referencingTables.add(Table.SHAPES); } - // 5T: hacky hack hack to add calendar_dates table if we're updating a calendar. - if (specTable.name.equals("calendars")) { - referencingTables.add(Table.CALENDAR_DATES); - System.out.println("Ho appena aggiunto calendar_dates alle referencingTables"); - } + // Iterate over referencing (child) tables and update those rows that reference the parent entity with the // JSON array for the key that matches the child table's name (e.g., trip.stop_times array will trigger // update of stop_times with matching trip_id). for (Table referencingTable : referencingTables) { Table parentTable = referencingTable.getParentTable(); - if (parentTable != null && parentTable.name.equals(specTable.name) || referencingTable.name.equals("shapes") - //5t - || referencingTable.name.equals("calendar_dates") - ) { + if (parentTable != null && parentTable.name.equals(specTable.name) || referencingTable.name.equals("shapes")) { // If a referencing table has the current table as its parent, update child elements. JsonNode childEntities = jsonObject.get(referencingTable.name); if (childEntities == null || childEntities.isNull() || !childEntities.isArray()) { diff --git a/src/main/java/com/conveyal/gtfs/loader/Table.java b/src/main/java/com/conveyal/gtfs/loader/Table.java index 67122c16..bfe5ceec 100644 --- a/src/main/java/com/conveyal/gtfs/loader/Table.java +++ b/src/main/java/com/conveyal/gtfs/loader/Table.java @@ -164,7 +164,7 @@ public Table (String name, Class entityClass, Requirement requ ); public static final Table CALENDAR_DATES = new Table("calendar_dates", CalendarDate.class, OPTIONAL, - new StringField("service_id", REQUIRED), + new StringField("service_id", REQUIRED).isReferenceTo(CALENDAR), //5t aggiunto isReferenceTo(CALENDAR) new DateField("date", REQUIRED), new IntegerField("exception_type", REQUIRED, 1, 2) ).keyFieldIsNotUnique()