Class SimpleDepcyResolver

java.lang.Object
org.pgcodekeeper.core.model.graph.SimpleDepcyResolver

public class SimpleDepcyResolver extends Object
Simple dependency resolver for database objects. Provides methods to find create and drop dependencies for database statements using dependency graphs built from old and new database schemas.
  • Constructor Details

    • SimpleDepcyResolver

      public SimpleDepcyResolver(AbstractDatabase oldDatabase, boolean isShowColumns)
      Creates a dependency resolver with old database only.
      Parameters:
      oldDatabase - the old database schema
      isShowColumns - whether to show column dependencies
    • SimpleDepcyResolver

      public SimpleDepcyResolver(AbstractDatabase oldDatabase, AbstractDatabase newDatabase, boolean isShowColumns)
      Creates a dependency resolver with both old and new database schemas.
      Parameters:
      oldDatabase - the old database schema
      newDatabase - the new database schema, can be null
      isShowColumns - whether to show column dependencies
  • Method Details

    • getCreateDepcies

      public Collection<PgStatement> getCreateDepcies(PgStatement toCreate)
      Gets dependencies required for creating a statement. Returns forward dependencies from the new database schema.
      Parameters:
      toCreate - the statement to create
      Returns:
      collection of statements that must be created before the target statement
      Throws:
      IllegalStateException - if new database is not defined
    • getDropDepcies

      public Collection<PgStatement> getDropDepcies(PgStatement toDrop)
      Gets dependencies that must be dropped when dropping a statement. Returns reverse dependencies from the old database schema.
      Parameters:
      toDrop - the statement to drop
      Returns:
      collection of statements that depend on the target statement and must be dropped first
    • getConnectedTo

      public Set<PgStatement> getConnectedTo(PgStatement entity)
      Gets statements that the given entity is directly connected to. Returns outgoing edges from the entity in the old database dependency graph.
      Parameters:
      entity - the statement to find connections for
      Returns:
      set of statements that the entity depends on