Skip to content

Commit

Permalink
no hack
Browse files Browse the repository at this point in the history
  • Loading branch information
aguiraf committed Dec 23, 2024
1 parent b0928eb commit 667be6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 2 additions & 9 deletions src/main/java/com/conveyal/gtfs/loader/JdbcTableWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/conveyal/gtfs/loader/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public Table (String name, Class<? extends Entity> 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()
Expand Down

0 comments on commit 667be6b

Please sign in to comment.