Class AbstractDataAdapter

java.lang.Object
ch.nolix.system.middata.adapter.AbstractDataAdapter
All Implemented Interfaces:
IDatabaseNameHolder, Closeable, CloseStateRequestable, GroupCloseable, ChangeRequestable, IChangeSaver, IResettableChangeSaver, Resettable, IDataAdapter, IDataReader, IDataWriter, AutoCloseable
Direct Known Subclasses:
AbstractDataAdapterAndSchemaReader, AbstractSqlDataAdapter, NodeDataAdapter

public abstract class AbstractDataAdapter extends Object implements IDataAdapter
Author:
Silvan Wyss
  • Method Details

    • clearMultiReference

      public final void clearMultiReference(String tableName, String entityId, String multiReferenceColumnName)
      Deletes the references of the multi reference, that is in the multi reference column with the given multiReferenceColumnName and belongs to the entity, that has the given entityId and belongs to the table with the given tableName, from the database.
      Specified by:
      clearMultiReference in interface IDataWriter
      Parameters:
      tableName -
      entityId -
      multiReferenceColumnName -
    • clearMultiValue

      public final void clearMultiValue(String tableName, String entityId, String multiFieldColumn)
      Deletes the values of the multi value, that is in the multi value column with the given multiValueColumnName and belongs to the entity, that has the given entityId and belongs to the table with the given tableName, from the database.
      Specified by:
      clearMultiValue in interface IDataWriter
      Parameters:
      tableName -
      entityId -
      multiFieldColumn -
    • createCloseDependencyTo

      public final void createCloseDependencyTo(GroupCloseable element)
      Creates a close dependency between the current GroupCloseable and the given element. When a GroupCloseable is closed, all elements, the current GroupCloseable has a close dependency to, will be closed too and vice versa.
      Specified by:
      createCloseDependencyTo in interface GroupCloseable
      Parameters:
      element -
    • deleteEntity

      public final void deleteEntity(String tableName, EntityDeletionDto entity)
      Deletes the given entity from the database. Will cause an error by saving if the given entity was deleted or changed on the database in the meanwhile.
      Specified by:
      deleteEntity in interface IDataWriter
      Parameters:
      tableName -
      entity -
    • deleteMultiBackReferenceEntry

      public final void deleteMultiBackReferenceEntry(MultiBackReferenceEntryDeletionDto multiBackReferenceEntry)
      Deletes the given multiBackReferenceEntry from the database.
      Specified by:
      deleteMultiBackReferenceEntry in interface IDataWriter
      Parameters:
      multiBackReferenceEntry -
    • deleteMultiReferenceEntry

      public final void deleteMultiReferenceEntry(MultiReferenceEntryDeletionDto multiReferenceEntry)
      Deletes the given multiReferenceEntry from the database.
      Specified by:
      deleteMultiReferenceEntry in interface IDataWriter
      Parameters:
      multiReferenceEntry -
    • deleteMultiValueEntry

      public final void deleteMultiValueEntry(MultiValueEntryDto multiValueEntry)
      Deletes the given multiValueEntry from the database.
      Specified by:
      deleteMultiValueEntry in interface IDataWriter
      Parameters:
      multiValueEntry -
    • expectSchemaTimestamp

      public final void expectSchemaTimestamp(ITime schemaTimestamp)
      Will cause an error by saving if the database does not have the given schemaTimestamp. This method can be used to prevent from saving changes when the schemaTimestamp was changed in the meanwhile
      Specified by:
      expectSchemaTimestamp in interface IDataWriter
      Parameters:
      schemaTimestamp -
    • expectTableContainsEntity

      public final void expectTableContainsEntity(String tableName, String entityId)
      Will cause an error by saving if on the database the table with the given tableName does not contain an entity with the given entityId. This method can be used to prevent from referencing an entity that was deleted in the meanwhile.
      Specified by:
      expectTableContainsEntity in interface IDataWriter
      Parameters:
      tableName -
      entityId -
    • getDatabaseName

      public final String getDatabaseName()
      Specified by:
      getDatabaseName in interface IDatabaseNameHolder
      Returns:
      the database name of the current IDatabaseNameHolder.
    • getEntityCount

      public final int getEntityCount(String tableName)
      Specified by:
      getEntityCount in interface IDataReader
      Parameters:
      tableName -
      Returns:
      the number of the entities of the table with the given tableName from the database.
    • getSaveCount

      public final int getSaveCount()
      Specified by:
      getSaveCount in interface IResettableChangeSaver
    • getSchemaTimestamp

      public final ITime getSchemaTimestamp()
      Specified by:
      getSchemaTimestamp in interface IDataReader
      Returns:
      the schema timestamp from the database.
    • getStoredCloseController

      public final ICloseController getStoredCloseController()
      Specified by:
      getStoredCloseController in interface GroupCloseable
      Returns:
      the ICloseController of the current GroupCloseable.
    • hasChanges

      public final boolean hasChanges()
      Specified by:
      hasChanges in interface ChangeRequestable
      Returns:
      true if the current ChangeRequestable has uncomitted changes, false otherwise.
    • loadEntities

      public final IContainer<EntityLoadingDto> loadEntities(String tableName)
      Specified by:
      loadEntities in interface IDataReader
      Parameters:
      tableName -
      Returns:
      the entities, that are in the table with the given tableName, from the database.
    • loadEntity

      public final EntityLoadingDto loadEntity(String tableName, String id)
      Specified by:
      loadEntity in interface IDataReader
      Parameters:
      tableName -
      id -
      Returns:
      the entity, that is in the table with the given tableName and has the given entityId, from the database.
    • insertEntity

      public final void insertEntity(String tableName, EntityCreationDto newEntity)
      Inserts the given entity into the table with the given tableName on the database.
      Specified by:
      insertEntity in interface IDataWriter
      Parameters:
      tableName -
      newEntity -
    • insertMultiBackReferenceEntry

      public final void insertMultiBackReferenceEntry(MultiBackReferenceEntryDto multiBackReferenceEntry)
      Inserts the given multiBackReferenceEntry into the database.
      Specified by:
      insertMultiBackReferenceEntry in interface IDataWriter
      Parameters:
      multiBackReferenceEntry -
    • insertMultiReferenceEntry

      public void insertMultiReferenceEntry(MultiReferenceEntryDto multiReferenceEntry)
      Inserts the given multiReferenceEntry into the database.
      Specified by:
      insertMultiReferenceEntry in interface IDataWriter
      Parameters:
      multiReferenceEntry -
    • insertMultiValueEntry

      public final void insertMultiValueEntry(MultiValueEntryDto multiValueEntry)
      Inserts the given multiValueEntry into the database.
      Specified by:
      insertMultiValueEntry in interface IDataWriter
      Parameters:
      multiValueEntry -
    • loadMultiBackReferenceBackReferencedEntityIds

      public final IContainer<String> loadMultiBackReferenceBackReferencedEntityIds(String tableName, String entityId, String multiBackReferenceColumnName)
      Specified by:
      loadMultiBackReferenceBackReferencedEntityIds in interface IDataReader
      Parameters:
      tableName -
      entityId -
      multiBackReferenceColumnName -
      Returns:
      the entity ids of the multi back reference, that is in the multi back reference column with the given multiBackReferenceColumnName and belongs to the entity, that has the given entityId and is in the table with the given tableName, from the database.
    • loadMultiBackReferenceEntries

      public IContainer<MultiBackReferenceEntryDto> loadMultiBackReferenceEntries(TableIdentification table, String entityId, ColumnIdentification multiBackReferenceColumn)
      Specified by:
      loadMultiBackReferenceEntries in interface IDataReader
      Parameters:
      table -
      entityId -
      multiBackReferenceColumn -
      Returns:
      the multi back reference entries of the multi back reference that is in the given table and in the entity with the given entityId and in the given multiBackReferenceColumn.
    • loadMultiReferenceEntries

      public final IContainer<MultiReferenceEntryDto> loadMultiReferenceEntries(String tableName, String entityId, String multiReferenceColumnName)
      Specified by:
      loadMultiReferenceEntries in interface IDataReader
      Parameters:
      tableName -
      entityId -
      multiReferenceColumnName -
      Returns:
      the multi reference entries of the the multi reference field, that is in the multi reference column with the given multiReferenceColumnName and belongs to the entity, that has the given entityId and is in the table with the given tableName, from the database.
    • loadMultiValueValues

      public final IContainer<Object> loadMultiValueValues(String tableName, String entityId, String multiFieldColumnName)
      Specified by:
      loadMultiValueValues in interface IDataReader
      Parameters:
      tableName -
      entityId -
      multiFieldColumnName -
      Returns:
      the values of the multi value, that is in the multi value column with the given multiValueColumnName and belongs to the entity, that has the given entityId and is in the table with the given tableName, from the database.
    • noteClose

      public final void noteClose()
      Lets the current GroupCloseable note a close.
      Specified by:
      noteClose in interface GroupCloseable
    • reset

      public final void reset()
      Resets the current Resettable.
      Specified by:
      reset in interface Resettable
    • saveChanges

      public final void saveChanges()
      Saves the changes of the current IChangeSaver.
      Specified by:
      saveChanges in interface IChangeSaver
    • tableContainsEntity

      public final boolean tableContainsEntity(String tableName, String entityId)
      Specified by:
      tableContainsEntity in interface IDataReader
      Parameters:
      tableName -
      entityId -
      Returns:
      true if the table with the given tableName contains an entity with the given entityId on the database, false otherwise.
    • tableContainsEntityWithValueAtColumn

      public final boolean tableContainsEntityWithValueAtColumn(String tableName, String columnName, String value)
      Specified by:
      tableContainsEntityWithValueAtColumn in interface IDataReader
      Parameters:
      tableName -
      columnName -
      value -
      Returns:
      true if the table with the given tableName contains in the column with the given columnName the given value on the database, false otherwise.
    • tableContainsEntityWithValueAtColumnIgnoringEntities

      public final boolean tableContainsEntityWithValueAtColumnIgnoringEntities(String tableName, String columnName, String value, IContainer<String> entitiesToIgnoreIds)
      Specified by:
      tableContainsEntityWithValueAtColumnIgnoringEntities in interface IDataReader
      Parameters:
      tableName -
      columnName -
      value -
      entitiesToIgnoreIds -
      Returns:
      true if the table with the given tableName contains in the column with the given columnName the given value ignoring the entities with the given entitiesToIgnoreIds on the database, false otherwise.
    • updateEntity

      public final void updateEntity(String tableName, EntityUpdateDto entityUpdate)
      Updates the entity, that belongs to the table with the given tableName, in the database according to the given entityUpdate.
      Specified by:
      updateEntity in interface IDataWriter
      Parameters:
      tableName -
      entityUpdate -