Class DataWriter

java.lang.Object
ch.nolix.system.nodemiddata.datawriter.DataWriter
All Implemented Interfaces:
Closeable, CloseStateRequestable, GroupCloseable, ChangeRequestable, IChangeSaver, IResettableChangeSaver, Resettable, IDataWriter, AutoCloseable

public final class DataWriter extends Object implements IDataWriter
Author:
Silvan Wyss
  • Field Details

    • INITIAL_ENTITY_SAVE_STAMP

      public static final int INITIAL_ENTITY_SAVE_STAMP
      See Also:
  • Method Details

    • forNodeDatabaseAndDatabaseView

      public static DataWriter forNodeDatabaseAndDatabaseView(IMutableNode<?> nodeDatabase, DatabaseViewDto databaseView)
    • clearMultiReference

      public 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 void clearMultiValue(String tableName, String entityId, String multiValueColumnName)
      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 -
      multiValueColumnName -
    • deleteEntity

      public 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 void deleteMultiBackReferenceEntry(MultiBackReferenceEntryDeletionDto multiBackReferenceEntry)
      Deletes the given multiBackReferenceEntry from the database.
      Specified by:
      deleteMultiBackReferenceEntry in interface IDataWriter
      Parameters:
      multiBackReferenceEntry -
    • deleteMultiReferenceEntry

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

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

      public 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 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 -
    • getSaveCount

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

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

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

      public 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 void insertMultiValueEntry(MultiValueEntryDto multiValueEntry)
      Inserts the given multiValueEntry into the database.
      Specified by:
      insertMultiValueEntry in interface IDataWriter
      Parameters:
      multiValueEntry -
    • getStoredCloseController

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

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

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

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

      public 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 -