Class RowData

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

public final class RowData extends Object
Stores database row data for INSERT script generation. Manages row information including table name, column data, foreign key relationships, and handles cyclic dependency resolution through null value replacements.
Author:
shamsutdinov_er
  • Constructor Details

    • RowData

      public RowData(String tableName, RowData parent, Map<String,String> data, List<String> fkCols, Collection<String> idCols)
      Creates a new row data instance.
      Parameters:
      tableName - qualified name of the table
      parent - parent row data for dependency tracking
      data - map of column names to values
      fkCols - list of foreign key column names with NOT NULL constraint
      idCols - collection of identity/primary key column names
  • Method Details

    • getTableName

      public String getTableName()
    • getParent

      public RowData getParent()
    • hasFk

      public boolean hasFk()
      Checks if this row has foreign key constraints with NOT NULL columns.
      Returns:
      true if has foreign key constraints, false otherwise
    • containsAllFkCols

      public boolean containsAllFkCols(Collection<String> columns)
      Checks if this row contains all specified foreign key columns.
      Parameters:
      columns - collection of column names to check
      Returns:
      true if all columns are present in foreign key columns
    • addReplacement

      public void addReplacement(String colName)
      Adds a column for null replacement to resolve cyclic dependencies. Only adds columns that have non-null values in the original data.
      Parameters:
      colName - the column name to replace with null
    • generateFilter

      public String generateFilter(Object[] foreignColumns, Object[] columns)
      Generates WHERE clause filter for foreign key relationship.
      Parameters:
      foreignColumns - array of foreign table column names
      columns - array of local table column names
      Returns:
      generated filter string, or null if any column value is null
    • appendInsert

      public void appendInsert(DatabaseType dbType, boolean haveIdentity, StringBuilder sb)
      Appends INSERT statement to the script builder. Handles database-specific syntax for PostgreSQL and Microsoft SQL.
      Parameters:
      dbType - the database type
      haveIdentity - whether table has identity columns
      sb - the script builder to append to
    • appendUpdate

      public void appendUpdate(DatabaseType dbType, StringBuilder sb)
      Appends UPDATE statement to fix cyclic dependency null replacements. Only generates UPDATE if there are replacement columns.
      Parameters:
      dbType - the database type
      sb - the script builder to append to
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object