diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index cdc0922..fb1117f 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index c206fb9..d3c7076 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,6 @@ # # SPDX-License-Identifier: CC0-1.0 -version: "3.4" - services: app: image: maven:3-jdk-8-alpine diff --git a/src/main/java/it/bz/noi/a22traffic/BulkLoader.java b/src/main/java/it/bz/noi/a22traffic/BulkLoader.java index d3d7faf..0f2d69c 100644 --- a/src/main/java/it/bz/noi/a22traffic/BulkLoader.java +++ b/src/main/java/it/bz/noi/a22traffic/BulkLoader.java @@ -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; @@ -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(); } diff --git a/src/main/java/it/bz/noi/a22traffic/Follower.java b/src/main/java/it/bz/noi/a22traffic/Follower.java index fbfb952..b82a55e 100644 --- a/src/main/java/it/bz/noi/a22traffic/Follower.java +++ b/src/main/java/it/bz/noi/a22traffic/Follower.java @@ -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; @@ -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(); }