github-advanced-security[bot] commented on code in PR #915:
URL: 
https://github.com/apache/incubator-baremaps/pull/915#discussion_r1913329079


##########
baremaps-postgres/src/main/java/org/apache/baremaps/postgres/refresh/DatabaseMetadataRetriever.java:
##########
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.baremaps.postgres.refresh;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Utility class to retrieve metadata about tables, views, and materialized 
views.
+ */
+public class DatabaseMetadataRetriever {
+
+  private static final Logger LOGGER =
+      LoggerFactory.getLogger(DatabaseMetadataRetriever.class.getName());
+
+  private DatabaseMetadataRetriever() {
+    // Prevent instantiation
+  }
+
+  /**
+   * Retrieves all tables, views, and materialized views in the given schema.
+   *
+   * @param connection the database connection
+   * @param schema the schema name
+   * @return a list of DatabaseObject records
+   * @throws SQLException if a database error occurs
+   */
+  public static List<DatabaseObject> getObjects(Connection connection, String 
schema)
+      throws SQLException {
+    var result = new ArrayList<DatabaseObject>();
+
+    var sql = """
+            SELECT c.oid,
+                   c.relname,
+                   c.relkind,
+                   n.nspname
+              FROM pg_class c
+              JOIN pg_namespace n ON n.oid = c.relnamespace
+             WHERE n.nspname = ?
+               AND c.relkind IN ('r', 'v', 'm')
+        """;
+
+    try (var ps = connection.prepareStatement(sql)) {
+      ps.setString(1, schema);
+      try (var rs = ps.executeQuery()) {
+        while (rs.next()) {
+          var oid = rs.getLong("oid");

Review Comment:
   ## Unread local variable
   
   Variable 'long oid' is never read.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1679)



##########
baremaps-postgres/src/main/java/org/apache/baremaps/postgres/refresh/DependencyGraphBuilder.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.baremaps.postgres.refresh;
+
+import com.google.common.graph.GraphBuilder;
+import com.google.common.graph.MutableGraph;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import 
org.apache.baremaps.postgres.refresh.DatabaseMetadataRetriever.DatabaseDependency;
+import 
org.apache.baremaps.postgres.refresh.DatabaseMetadataRetriever.DatabaseObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Utility class to build a directed dependency graph among DatabaseObject 
items.
+ */
+public class DependencyGraphBuilder {
+
+  private static final Logger LOGGER =
+      LoggerFactory.getLogger(DependencyGraphBuilder.class.getName());
+
+  private DependencyGraphBuilder() {
+    // Prevent instantiation
+  }
+
+  /**
+   * Builds a directed graph using Guava for the given list of objects, then 
populates edges from
+   * system catalogs.
+   *
+   * @return a MutableGraph<DatabaseObject>
+   */
+  public static MutableGraph<DatabaseObject> buildGraph(
+      Connection connection,
+      String schema,

Review Comment:
   ## Useless parameter
   
   The parameter 'schema' is never used.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1681)



##########
baremaps-postgres/src/main/java/org/apache/baremaps/postgres/refresh/DependencyGraphBuilder.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.baremaps.postgres.refresh;
+
+import com.google.common.graph.GraphBuilder;
+import com.google.common.graph.MutableGraph;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import 
org.apache.baremaps.postgres.refresh.DatabaseMetadataRetriever.DatabaseDependency;
+import 
org.apache.baremaps.postgres.refresh.DatabaseMetadataRetriever.DatabaseObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Utility class to build a directed dependency graph among DatabaseObject 
items.
+ */
+public class DependencyGraphBuilder {
+
+  private static final Logger LOGGER =
+      LoggerFactory.getLogger(DependencyGraphBuilder.class.getName());
+
+  private DependencyGraphBuilder() {
+    // Prevent instantiation
+  }
+
+  /**
+   * Builds a directed graph using Guava for the given list of objects, then 
populates edges from
+   * system catalogs.
+   *
+   * @return a MutableGraph<DatabaseObject>
+   */
+  public static MutableGraph<DatabaseObject> buildGraph(
+      Connection connection,

Review Comment:
   ## Useless parameter
   
   The parameter 'connection' is never used.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1680)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to