Class RelationalStore

All Implemented Interfaces:
PopupActivationListener, Serializable, Comparable, EventListener, ListSelectionListener, TableModelListener, TableModel
Direct Known Subclasses:
GeoRelationalStore

public class RelationalStore extends AttributeStore implements TableModelListener
A RelationalStore is a table object that joins two other tables together using a relational mapping between two columns.

This class will be changed to implement a simpler method of joining tables.

See Also:
Serialized Form
  • Field Details

    • DIRECT

      public static final int DIRECT
      Specify a relational join where the key value from the first table provides the record number for the second table.
      See Also:
      Constant Field Values
    • INDIRECT

      public static final int INDIRECT
      Specify a relational join where the key value from the first table must match to the key in the second table.
      See Also:
      Constant Field Values
  • Constructor Details

  • Method Details

    • close

      public void close()
      Description copied from class: AttributeStore
      Close the table and release resources. The table should be used again after this method has been called.

      In many cases you do not need to call this method when you are finished using a table. Most tables will close automatically when they are no longer referenced.

      It is possible that this method will be deprecated or removed in a future release.

      Overrides:
      close in class AttributeStore
    • closeAllRelates

      public void closeAllRelates()
    • getSnapshot

      public AttributeStore getSnapshot(boolean useSelected, Observer progress)
      Description copied from class: AttributeStore
      Return a snapshot of the dataset at a given moment. The general behaviour of this method is to simply return the same datastore. Some specialized datastores (such as CrosstabStore), will compute an instance that can be used and then disposed.

      The default behaviour simply returns 'this'.

      Overrides:
      getSnapshot in class AttributeStore
      Parameters:
      useSelected - If true then only use the currently selected records in computing the snapshot.
      progress - An optional progress bar. This parameter may be null.
      Returns:
      An AttributeStore representing a materialization of the store.
    • allowsEditing

      public boolean allowsEditing()
      Description copied from class: AttributeStore
      Query if this layer supports extended editing of features. Extended editing usually means that values can be written out to disk.
      Overrides:
      allowsEditing in class AttributeStore
      Returns:
      true if the store allows editing
    • setEditMode

      public void setEditMode(boolean mode) throws IOException
      Description copied from class: AttributeStore
      Enable or disable the extended editing mode.
      Overrides:
      setEditMode in class AttributeStore
      Parameters:
      mode - the editing mode to use
      Throws:
      IOException - if an error occurs while trying to change the edit mode.
    • getEditMode

      public boolean getEditMode()
      Description copied from class: AttributeStore
      Get the status of the extended editing mode.
      Overrides:
      getEditMode in class AttributeStore
      Returns:
      the editing mode in use
    • setColumn1

      public void setColumn1(String columnName1)
      Change the column that the relate is being made with.
    • getColumnName1

      public String getColumnName1()
    • getColumnName2

      public String getColumnName2()
    • getColumn1

      public Expression getColumn1()
    • getColumn2

      public int getColumn2()
    • getRowDelta

      public int getRowDelta()
    • getBaseRelation

      public AttributeStore getBaseRelation()
      Return the base store belonging to this set of relations
    • getLeftRelate

      public AttributeStore getLeftRelate()
      Return the identity of the left branch of the join tree
    • getRightRelate

      public AttributeStore getRightRelate()
      Return the identity of the right branch of the join tree
    • removeRightRelates

      public void removeRightRelates()
      Drop all extraneous relations on the right hand branch of this join tree
    • getSynchronizer

      public Suspendable getSynchronizer()
      Description copied from class: AttributeStore
      Get the synchronizer object for this table. This object can be used to suspend the scheduling task as a set of calculations are carried out. Most tables will not have a synchronizer object. The only tables that will are tables that provide simulation results.
      Overrides:
      getSynchronizer in class AttributeStore
    • getRowNodeRemap

      public RowNodeRemap getRowNodeRemap()
      Overrides:
      getRowNodeRemap in class AttributeStore
    • getRowCount

      public int getRowCount()
      Description copied from class: AttributeStore
      Get the number of rows in this store
      Specified by:
      getRowCount in interface TableModel
      Specified by:
      getRowCount in class AttributeStore
      Returns:
      the number of rows in this store
    • getPeriodCount

      public int getPeriodCount()
      Description copied from class: AttributeStore
      Get the total number of periods that this store supports
      Specified by:
      getPeriodCount in class AttributeStore
      Returns:
      The number of periods in this store
    • getYearForPeriod

      public int getYearForPeriod(int period)
      Description copied from class: AttributeStore
      Get the ending year for a given period.
      Specified by:
      getYearForPeriod in class AttributeStore
      Parameters:
      period - The period of interest
      Returns:
      the year for a given period
    • getValueAt

      public Object getValueAt(int row, int column, int period)
      Override the getValue method
      Specified by:
      getValueAt in class AttributeStore
      Parameters:
      row - The row containing the cell
      column - The column containing the cell
      period - The period of interest
      Returns:
      An object containing the cell value.
    • setValueAt

      public void setValueAt(Object aValue, int row, int column, int period)
      Description copied from class: AttributeStore
      Set the value in a cell and notify listeners that the value has changed.

      Implementing classes that override must call this method to ensure that joins are properly maintained.

      Overrides:
      setValueAt in class AttributeStore
      Parameters:
      aValue - The value to be set.
      row - The row containing the cell
      column - The column containing the cell
      period - The period of interest
    • getFullColumnName

      public FullColumnName getFullColumnName(int column)
      Description copied from class: AttributeStore
      Return the full name of a column at a given position, including the short name of the table.
      Overrides:
      getFullColumnName in class AttributeStore
      Parameters:
      column - the column number of interest
      Returns:
      the name of the column
    • findColumn

      public int findColumn(String field, String shortName)
      Description copied from class: AttributeStore
      Get the column number of the given field in the given table. If the column is not found then return -1.
      Overrides:
      findColumn in class AttributeStore
      Parameters:
      field - The name of the field to look up
      shortName - The short name of the table to look up the the column in. If this attribute store has related tables, the column from the related table with the matching short name will be returned. If there is no table with a matching short name an exception will be thrown.
    • findBaseTable

      public AttributeStore findBaseTable(String shortName)
      Find a base table in this relation that has a matching short name. If the matching table is not found then return null.
      Parameters:
      shortName - the name to search for
    • canIndex

      public boolean canIndex(int column)
      Description copied from class: AttributeStore
      Test to see if the column can be indexed. The system will only allow joins on fields that can be indexed, such as integer and string keys. Column -1 is a special indicator that the join is a 'link by row number' relate.
      Overrides:
      canIndex in class AttributeStore
      Parameters:
      column - the column number to index
      Returns:
      true if the column can be indexed
    • buildIndex

      public void buildIndex(int column)
      Description copied from class: AttributeStore
      Build an index on the column. The index can then be used for speedy lookups. See AttributeStore.lookupRow(java.lang.Object, int).
      Overrides:
      buildIndex in class AttributeStore
      Parameters:
      column - the column of interest
    • hasIndex

      public boolean hasIndex(int column)
      Description copied from class: AttributeStore
      Indicate if an index has been build on a column
      Overrides:
      hasIndex in class AttributeStore
      Parameters:
      column - the column of interest
      Returns:
      true if this column has an index
    • lookupRow

      public int lookupRow(Object key, int column)
      Description copied from class: AttributeStore
      Look up the row number for a key value in given column number. This will search the column for a value, and return the row number that the value was found in. If the record is not found then -1 is returned. There is no guarantee of which record will be returned if there more than one record has the same value.
      Overrides:
      lookupRow in class AttributeStore
      Parameters:
      key - The data value to search for
      column - the column to search within
      Returns:
      the row number where the value was found
    • nativeLookupRow

      public int nativeLookupRow(Object key, int column)
    • addCellEditors

      public void addCellEditors(JTable table, int offset)
      Description copied from class: AttributeStore
      This method will be called by components that want to set up custom cell editors on JTables. If your table has custom editing behaviour then you can hook it in using this method.
      Overrides:
      addCellEditors in class AttributeStore
      Parameters:
      table - A JTable
      offset - the column number in the store that will have a custom cell editor
    • tableChanged

      public void tableChanged(TableModelEvent e)
      Propogate table events
      Specified by:
      tableChanged in interface TableModelListener