Class MetaUtils

java.lang.Object
org.pgcodekeeper.core.schema.meta.MetaUtils

public final class MetaUtils extends Object
Utility class for creating and managing database metadata objects. Provides methods for converting database statements to metadata representations and organizing them into metadata containers.
  • Method Details

    • createTreeFromDb

      public static MetaContainer createTreeFromDb(AbstractDatabase db)
      Creates a metadata container from a database object.
      Parameters:
      db - the database object
      Returns:
      the metadata container with all database objects
    • createTreeFromDefs

      public static MetaContainer createTreeFromDefs(Stream<MetaStatement> defs, DatabaseType dbType, SupportedPgVersion version)
      Creates a metadata container from a stream of metadata definitions.
      Parameters:
      defs - the stream of metadata statements
      dbType - the database type
      version - the PostgreSQL version (used only for PG databases)
      Returns:
      the metadata container with all definitions
    • getObjDefinitions

      public static Map<String,List<MetaStatement>> getObjDefinitions(AbstractDatabase db)
      Returns object definitions grouped by file path.
      Parameters:
      db - the database object
      Returns:
      map of file paths to lists of metadata statements
    • initializeView

      public static void initializeView(MetaContainer meta, String schemaName, String name, List<? extends Pair<String,String>> columns)
      Initializes a view with column information in the metadata container.
      Parameters:
      meta - the metadata container
      schemaName - the schema name
      name - the view name
      columns - the list of column name-type pairs