Skip to content

Commit

Permalink
Refactor materialized views package
Browse files Browse the repository at this point in the history
  • Loading branch information
bchapuis committed Jan 13, 2025
1 parent bba9f4b commit 948876a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.baremaps.postgres.graph.DatabaseMetadataRetriever;
import org.apache.baremaps.postgres.graph.DependencyGraphBuilder;
import org.apache.baremaps.postgres.graph.MaterializedViewRefresher;
import org.apache.baremaps.postgres.refresh.DatabaseMetadataRetriever;
import org.apache.baremaps.postgres.refresh.DependencyGraphBuilder;
import org.apache.baremaps.postgres.refresh.MaterializedViewRefresher;
import org.apache.baremaps.workflow.Task;
import org.apache.baremaps.workflow.WorkflowContext;
import org.slf4j.Logger;
Expand All @@ -33,20 +33,22 @@ public class RefreshMaterializedViews implements Task {

private Object database;

private String schema = "public";

public RefreshMaterializedViews() {
// Default constructor
}

public RefreshMaterializedViews(Object database) {
public RefreshMaterializedViews(Object database, String schema) {
this.database = database;
this.schema = schema;
}

@Override
public void execute(WorkflowContext context) throws Exception {
DataSource dataSource = context.getDataSource(database);
try (var connection = dataSource.getConnection()) {
LOGGER.info("Connected to PostgreSQL database.");
var schema = "public";

// 1. Retrieve database objects (tables, views, materialized views).
var objects = DatabaseMetadataRetriever.getObjects(connection, schema);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.baremaps.postgres.graph;
package org.apache.baremaps.postgres.refresh;

import java.sql.Connection;
import java.sql.SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.baremaps.postgres.graph;
package org.apache.baremaps.postgres.refresh;

import com.google.common.graph.GraphBuilder;
import com.google.common.graph.MutableGraph;
Expand All @@ -25,8 +25,8 @@
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.apache.baremaps.postgres.graph.DatabaseMetadataRetriever.DatabaseDependency;
import org.apache.baremaps.postgres.graph.DatabaseMetadataRetriever.DatabaseObject;
import org.apache.baremaps.postgres.refresh.DatabaseMetadataRetriever.DatabaseDependency;
import org.apache.baremaps.postgres.refresh.DatabaseMetadataRetriever.DatabaseObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* limitations under the License.
*/

package org.apache.baremaps.postgres.graph;
package org.apache.baremaps.postgres.refresh;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import org.apache.baremaps.postgres.graph.DatabaseMetadataRetriever.DatabaseIndex;
import org.apache.baremaps.postgres.graph.DatabaseMetadataRetriever.DatabaseObject;
import org.apache.baremaps.postgres.graph.DatabaseMetadataRetriever.ObjectType;
import org.apache.baremaps.postgres.refresh.DatabaseMetadataRetriever.DatabaseIndex;
import org.apache.baremaps.postgres.refresh.DatabaseMetadataRetriever.DatabaseObject;
import org.apache.baremaps.postgres.refresh.DatabaseMetadataRetriever.ObjectType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down

0 comments on commit 948876a

Please sign in to comment.