Class JooqSink

java.lang.Object
ch.ergon.adam.jooq.JooqSink
All Implemented Interfaces:
ch.ergon.adam.core.db.interfaces.SchemaSink, AutoCloseable

public class JooqSink extends Object implements ch.ergon.adam.core.db.interfaces.SchemaSink
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.jooq.DSLContext
     
    protected final String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
     
     
    JooqSink(String url, String schema)
     
     
    JooqSink(Connection connection, org.jooq.SQLDialect dialect)
     
    protected
    JooqSink(Connection dbConnection, org.jooq.SQLDialect dialect, String schema)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addField(ch.ergon.adam.core.db.schema.Field field)
     
    void
    adjustSequences(ch.ergon.adam.core.db.schema.Table table)
     
    protected String
    castIfNeeded(ch.ergon.adam.core.db.schema.Field sourceField, ch.ergon.adam.core.db.schema.Field targetField, org.jooq.DSLContext renderContext)
     
    void
    changeFieldType(ch.ergon.adam.core.db.schema.Field oldField, ch.ergon.adam.core.db.schema.Field newField, ch.ergon.adam.core.db.schema.DataType targetDataType)
     
    void
     
    void
     
    void
    copyData(ch.ergon.adam.core.db.schema.Table sourceTable, ch.ergon.adam.core.db.schema.Table targetTable, String sourceTableName)
     
    void
    createConstraint(ch.ergon.adam.core.db.schema.Constraint constraint)
     
    void
    createEnum(ch.ergon.adam.core.db.schema.DbEnum dbEnum)
     
    void
    createForeignKey(ch.ergon.adam.core.db.schema.ForeignKey foreignKey)
     
    void
    createIndex(ch.ergon.adam.core.db.schema.Index index)
     
    void
    createSequence(ch.ergon.adam.core.db.schema.Sequence sequence)
     
    void
    createTable(ch.ergon.adam.core.db.schema.Table table)
     
    void
    createView(ch.ergon.adam.core.db.schema.View view)
     
    void
    dropConstraint(ch.ergon.adam.core.db.schema.Constraint constraint)
     
    void
    dropDefault(ch.ergon.adam.core.db.schema.Field field)
     
    void
    dropEnum(ch.ergon.adam.core.db.schema.DbEnum dbEnum)
     
    void
    dropField(ch.ergon.adam.core.db.schema.Field field, ch.ergon.adam.core.db.schema.Table table)
     
    void
    dropForeignKey(ch.ergon.adam.core.db.schema.ForeignKey foreignKey)
     
    void
    dropIndex(ch.ergon.adam.core.db.schema.Index index)
     
    void
    dropSequence(ch.ergon.adam.core.db.schema.Sequence sequence)
     
    void
    dropSequencesAndDefaults(ch.ergon.adam.core.db.schema.Table table)
     
    void
    dropTable(ch.ergon.adam.core.db.schema.Table table)
     
    void
    dropView(ch.ergon.adam.core.db.schema.View view)
     
    protected Object
    getDefaultValue(ch.ergon.adam.core.db.schema.Field field)
     
    protected org.jooq.Name
    getFieldName(ch.ergon.adam.core.db.schema.Field field)
     
    protected org.jooq.Name
    getTableName(ch.ergon.adam.core.db.schema.Table table)
     
    protected org.jooq.DataType<?>
    mapFieldToJooqType(ch.ergon.adam.core.db.schema.Field field)
     
    protected org.jooq.DataType<?>
    mapRawType(ch.ergon.adam.core.db.schema.DataType type)
     
    protected org.jooq.DataType<?>
    mapType(ch.ergon.adam.core.db.schema.Field field)
     
    void
    renameTable(ch.ergon.adam.core.db.schema.Table oldTable, String targetTableName)
     
    void
     
    void
    setDefault(ch.ergon.adam.core.db.schema.Field field)
     
    void
    setTargetSchema(ch.ergon.adam.core.db.schema.Schema targetSchema)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface ch.ergon.adam.core.db.interfaces.SchemaSink

    supportAlterAndDropField
  • Field Details

    • context

      protected final org.jooq.DSLContext context
    • schema

      protected final String schema
  • Constructor Details

    • JooqSink

      public JooqSink(String url, String schema)
    • JooqSink

      public JooqSink(String url)
    • JooqSink

      public JooqSink(Connection connection, org.jooq.SQLDialect dialect)
    • JooqSink

      protected JooqSink(Connection dbConnection, org.jooq.SQLDialect dialect, String schema)
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getTableName

      protected org.jooq.Name getTableName(ch.ergon.adam.core.db.schema.Table table)
    • getFieldName

      protected org.jooq.Name getFieldName(ch.ergon.adam.core.db.schema.Field field)
    • setTargetSchema

      public void setTargetSchema(ch.ergon.adam.core.db.schema.Schema targetSchema)
      Specified by:
      setTargetSchema in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • commitChanges

      public void commitChanges()
      Specified by:
      commitChanges in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • rollback

      public void rollback()
      Specified by:
      rollback in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • dropForeignKey

      public void dropForeignKey(ch.ergon.adam.core.db.schema.ForeignKey foreignKey)
      Specified by:
      dropForeignKey in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • createForeignKey

      public void createForeignKey(ch.ergon.adam.core.db.schema.ForeignKey foreignKey)
      Specified by:
      createForeignKey in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • dropIndex

      public void dropIndex(ch.ergon.adam.core.db.schema.Index index)
      Specified by:
      dropIndex in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • createIndex

      public void createIndex(ch.ergon.adam.core.db.schema.Index index)
      Specified by:
      createIndex in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • addField

      public void addField(ch.ergon.adam.core.db.schema.Field field)
      Specified by:
      addField in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • dropField

      public void dropField(ch.ergon.adam.core.db.schema.Field field, ch.ergon.adam.core.db.schema.Table table)
      Specified by:
      dropField in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • dropDefault

      public void dropDefault(ch.ergon.adam.core.db.schema.Field field)
      Specified by:
      dropDefault in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • setDefault

      public void setDefault(ch.ergon.adam.core.db.schema.Field field)
      Specified by:
      setDefault in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • createTable

      public void createTable(ch.ergon.adam.core.db.schema.Table table)
      Specified by:
      createTable in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • dropTable

      public void dropTable(ch.ergon.adam.core.db.schema.Table table)
      Specified by:
      dropTable in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • createView

      public void createView(ch.ergon.adam.core.db.schema.View view)
      Specified by:
      createView in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • dropView

      public void dropView(ch.ergon.adam.core.db.schema.View view)
      Specified by:
      dropView in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • dropEnum

      public void dropEnum(ch.ergon.adam.core.db.schema.DbEnum dbEnum)
      Specified by:
      dropEnum in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • createEnum

      public void createEnum(ch.ergon.adam.core.db.schema.DbEnum dbEnum)
      Specified by:
      createEnum in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • changeFieldType

      public void changeFieldType(ch.ergon.adam.core.db.schema.Field oldField, ch.ergon.adam.core.db.schema.Field newField, ch.ergon.adam.core.db.schema.DataType targetDataType)
      Specified by:
      changeFieldType in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • dropConstraint

      public void dropConstraint(ch.ergon.adam.core.db.schema.Constraint constraint)
      Specified by:
      dropConstraint in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • createConstraint

      public void createConstraint(ch.ergon.adam.core.db.schema.Constraint constraint)
      Specified by:
      createConstraint in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • dropSequence

      public void dropSequence(ch.ergon.adam.core.db.schema.Sequence sequence)
      Specified by:
      dropSequence in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • createSequence

      public void createSequence(ch.ergon.adam.core.db.schema.Sequence sequence)
      Specified by:
      createSequence in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • dropSequencesAndDefaults

      public void dropSequencesAndDefaults(ch.ergon.adam.core.db.schema.Table table)
      Specified by:
      dropSequencesAndDefaults in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • adjustSequences

      public void adjustSequences(ch.ergon.adam.core.db.schema.Table table)
      Specified by:
      adjustSequences in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • renameTable

      public void renameTable(ch.ergon.adam.core.db.schema.Table oldTable, String targetTableName)
      Specified by:
      renameTable in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • copyData

      public void copyData(ch.ergon.adam.core.db.schema.Table sourceTable, ch.ergon.adam.core.db.schema.Table targetTable, String sourceTableName)
      Specified by:
      copyData in interface ch.ergon.adam.core.db.interfaces.SchemaSink
    • castIfNeeded

      protected String castIfNeeded(ch.ergon.adam.core.db.schema.Field sourceField, ch.ergon.adam.core.db.schema.Field targetField, org.jooq.DSLContext renderContext)
    • mapType

      protected org.jooq.DataType<?> mapType(ch.ergon.adam.core.db.schema.Field field)
    • getDefaultValue

      protected Object getDefaultValue(ch.ergon.adam.core.db.schema.Field field)
    • mapFieldToJooqType

      protected org.jooq.DataType<?> mapFieldToJooqType(ch.ergon.adam.core.db.schema.Field field)
    • mapRawType

      protected org.jooq.DataType<?> mapRawType(ch.ergon.adam.core.db.schema.DataType type)