Class DataSourceFunctions

java.lang.Object
mgui.datasources.util.DataSourceFunctions

public class DataSourceFunctions
extends java.lang.Object
  • Constructor Summary

    Constructors
    Constructor Description
    DataSourceFunctions()  
  • Method Summary

    Modifier and Type Method Description
    static DataSource createNewDataSource​(java.lang.String driver, java.lang.String name, java.lang.String url, java.lang.String login, java.lang.String encrypted_password)
    Attempts to creates a new data source, with the given parameters.
    static boolean dropDataSource​(DataSource source)
    Drops the specified data source; i.e., deletes it entirely.
    static boolean equalFields​(DataField f1, DataField f2)
    Compare fields for equality
    static boolean equalFields​(DataField f1, DataField f2, boolean ignore_name)
    Compare fields for equality
    static java.lang.String getAddFieldStatement​(java.lang.String table, DataField field)
    Returns an SQL statement for adding field to table.
    static java.lang.String getAddFieldStatement​(java.lang.String table, DataField field, DataSourceDriver driver)
    Returns an SQL statement for adding field to table.
    static java.lang.String getChangePrimaryKeyStatement​(java.lang.String table, DataField new_field)
    Returns an SQL statement to update table by adding or dropping a primary key for new_field.
    static java.lang.String getChangePrimaryKeyStatement​(java.lang.String table, DataField new_field, DataSourceDriver driver)
    Returns an SQL statement to update table by adding or dropping a primary key for new_field.
    static java.util.ArrayList<java.lang.String> getEditStatements​(DataSource source, DataTable old_table, DataTable new_table, java.util.HashMap<java.lang.String,​java.lang.String> changed_names)
    Generates a set of SQL statements which transform old_table into new_table.
    static java.lang.String getRemoveFieldStatement​(java.lang.String table, java.lang.String field)
    Returns an SQL statement for removing field from table.
    static java.lang.String getRemoveFieldStatement​(java.lang.String table, java.lang.String field, DataSourceDriver driver)
    Returns an SQL statement for removing field from table.
    static java.lang.String getRenameFieldStatement​(java.lang.String table, java.lang.String old_field, java.lang.String new_field)
    Returns an SQL statement to rename old_field to new_field.
    static java.lang.String getRenameFieldStatement​(java.lang.String table, java.lang.String old_name, java.lang.String new_name, DataSourceDriver driver)
    Returns an SQL statement to rename old_field to new_field.
    static java.lang.String getRenameTableStatement​(java.lang.String old_name, java.lang.String new_name)
    Returns an SQL statement to rename old_table to new_table.
    static java.lang.String getRenameTableStatement​(java.lang.String old_name, java.lang.String new_name, DataSourceDriver driver)
    Returns an SQL statement to rename old_table to new_table.
    static java.lang.String getUpdateFieldStatement​(java.lang.String table, DataField old_field, DataField new_field)
    Returns an SQL statement to update old_field to match new_field.
    static java.lang.String getUpdateFieldStatement​(java.lang.String table, DataField old_field, DataField new_field, DataSourceDriver driver)
    Returns an SQL statement to update old_field to match new_field.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DataSourceFunctions

      public DataSourceFunctions()
  • Method Details

    • createNewDataSource

      public static DataSource createNewDataSource​(java.lang.String driver, java.lang.String name, java.lang.String url, java.lang.String login, java.lang.String encrypted_password)
      Attempts to creates a new data source, with the given parameters. The password should already be encrypted using SecureDataSourceFunctions.getEncryptedPassword().
      Parameters:
      name -
      url -
      login -
      encrypted_password - System-encrypted version of the password
      Returns:
      the new datasource, if successful; null otherwise.
      See Also:
      mgui.datasources.security.SecureDataSourceFunctions#getEncryptedPassword(String)
    • dropDataSource

      public static boolean dropDataSource​(DataSource source)
      Drops the specified data source; i.e., deletes it entirely.
      Parameters:
      source -
      Returns:
    • getEditStatements

      public static java.util.ArrayList<java.lang.String> getEditStatements​(DataSource source, DataTable old_table, DataTable new_table, java.util.HashMap<java.lang.String,​java.lang.String> changed_names)
      Generates a set of SQL statements which transform old_table into new_table. Statements must be run in sequence; order is critical for some operations.
      Parameters:
      source -
      old_table -
      new_table -
      changed_names -
      Returns:
    • equalFields

      public static boolean equalFields​(DataField f1, DataField f2)
      Compare fields for equality
      Parameters:
      f1 -
      f2 -
      Returns:
    • equalFields

      public static boolean equalFields​(DataField f1, DataField f2, boolean ignore_name)
      Compare fields for equality
      Parameters:
      f1 -
      f2 -
      ignore_name - If true, doesn't include the names in the comparison
      Returns:
    • getAddFieldStatement

      public static java.lang.String getAddFieldStatement​(java.lang.String table, DataField field)
      Returns an SQL statement for adding field to table.
      Parameters:
      thisTable -
      thisField -
      Returns:
    • getAddFieldStatement

      public static java.lang.String getAddFieldStatement​(java.lang.String table, DataField field, DataSourceDriver driver)
      Returns an SQL statement for adding field to table.
      Parameters:
      thisTable -
      thisField -
      driver -
      Returns:
    • getRemoveFieldStatement

      public static java.lang.String getRemoveFieldStatement​(java.lang.String table, java.lang.String field)
      Returns an SQL statement for removing field from table.
      Parameters:
      thisTable -
      thisField -
      Returns:
    • getRemoveFieldStatement

      public static java.lang.String getRemoveFieldStatement​(java.lang.String table, java.lang.String field, DataSourceDriver driver)
      Returns an SQL statement for removing field from table.
      Parameters:
      thisTable -
      thisField -
      driver -
      Returns:
    • getRenameTableStatement

      public static java.lang.String getRenameTableStatement​(java.lang.String old_name, java.lang.String new_name)
      Returns an SQL statement to rename old_table to new_table.
      Parameters:
      thisTable -
      thisField -
      Returns:
    • getRenameTableStatement

      public static java.lang.String getRenameTableStatement​(java.lang.String old_name, java.lang.String new_name, DataSourceDriver driver)
      Returns an SQL statement to rename old_table to new_table.
      Parameters:
      thisTable -
      thisField -
      Returns:
    • getRenameFieldStatement

      public static java.lang.String getRenameFieldStatement​(java.lang.String table, java.lang.String old_field, java.lang.String new_field)
      Returns an SQL statement to rename old_field to new_field.
      Parameters:
      thisTable -
      thisField -
      Returns:
    • getRenameFieldStatement

      public static java.lang.String getRenameFieldStatement​(java.lang.String table, java.lang.String old_name, java.lang.String new_name, DataSourceDriver driver)
      Returns an SQL statement to rename old_field to new_field.
      Parameters:
      thisTable -
      thisField -
      Returns:
    • getUpdateFieldStatement

      public static java.lang.String getUpdateFieldStatement​(java.lang.String table, DataField old_field, DataField new_field)
      Returns an SQL statement to update old_field to match new_field.
      Parameters:
      thisTable -
      thisField -
      Returns:
    • getUpdateFieldStatement

      public static java.lang.String getUpdateFieldStatement​(java.lang.String table, DataField old_field, DataField new_field, DataSourceDriver driver)
      Returns an SQL statement to update old_field to match new_field.
      Parameters:
      thisTable -
      thisField -
      Returns:
    • getChangePrimaryKeyStatement

      public static java.lang.String getChangePrimaryKeyStatement​(java.lang.String table, DataField new_field)
      Returns an SQL statement to update table by adding or dropping a primary key for new_field. Dropping assumes the field is named "{field_name}_pkey"
      Parameters:
      thisTable -
      thisField -
      Returns:
    • getChangePrimaryKeyStatement

      public static java.lang.String getChangePrimaryKeyStatement​(java.lang.String table, DataField new_field, DataSourceDriver driver)
      Returns an SQL statement to update table by adding or dropping a primary key for new_field. Dropping assumes the field is named "{field_name}_pkey"
      Parameters:
      thisTable -
      thisField -
      Returns: