Skip to content

Commit

Permalink
fix null issues with country, switch back to follower mode in testing…
Browse files Browse the repository at this point in the history
… after loading bulk
  • Loading branch information
clezag committed Nov 7, 2024
1 parent 648807c commit 8c12e5f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
X_DOCKER_TAG: ${{ env.DOCKER_TAG }}
X_JAVA_OPTIONS: -Xms128m -Xmx2048m
X_JDBC_URL: ${{ secrets.TEST_JDBC_URL }}
# X_OPERATION_MODE: "follow"
X_OPERATION_MODE: "month 2024 11"
X_OPERATION_MODE: "follow"
# X_OPERATION_MODE: "month 2024 11"

- name: Build project
uses: noi-techpark/github-actions/maven-build@v2
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: CC0-1.0

version: "3.4"

services:
app:
image: maven:3-jdk-8-alpine
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/it/bz/noi/a22traffic/BulkLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -95,8 +96,12 @@ public void run() {
ins.setInt(8, Integer.parseInt(res.get(i).get("class")));
ins.setDouble(9, Double.parseDouble(res.get(i).get("speed")));
ins.setInt(10, Integer.parseInt(res.get(i).get("direction")));
String country = res.get(i).get("country");
ins.setInt(11, !country.equals("null") ? Integer.parseInt(country) : null);
try {
String country = res.get(i).get("country");
ins.setInt(11, Integer.parseInt(country));
} catch (NullPointerException | NumberFormatException e) {
ins.setObject(11, null, Types.INTEGER);
}
ins.setString(12, res.get(i).get("license_plate_initials"));
ins.execute();
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/it/bz/noi/a22traffic/Follower.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -200,8 +201,12 @@ public static void fetchNew(Connector conn, String jdbc_url) throws IOException,
pst.setInt(8, Integer.parseInt(res.get(i).get("class")));
pst.setDouble(9, Double.parseDouble(res.get(i).get("speed")));
pst.setInt(10, Integer.parseInt(res.get(i).get("direction")));
String country = res.get(i).get("country");
pst.setInt(11, !country.equals("null") ? Integer.parseInt(country) : null);
try {
String country = res.get(i).get("country");
pst.setInt(11, Integer.parseInt(country));
} catch (NullPointerException | NumberFormatException e) {
pst.setObject(11, null, Types.INTEGER);
}
pst.setString(12, res.get(i).get("license_plate_initials"));
pst.execute();
}
Expand Down

0 comments on commit 8c12e5f

Please sign in to comment.