Package ca.spatial.table
Class RelationalStore
java.lang.Object
javax.swing.table.AbstractTableModel
ca.spatial.table.AttributeStore
ca.spatial.table.RelationalStore
- All Implemented Interfaces:
PopupActivationListener
,Serializable
,Comparable
,EventListener
,ListSelectionListener
,TableModelListener
,TableModel
- Direct Known Subclasses:
GeoRelationalStore
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 Summary
FieldsModifier and TypeFieldDescriptionstatic int
Specify a relational join where the key value from the first table provides the record number for the second table.static int
Specify a relational join where the key value from the first table must match to the key in the second table.Fields inherited from class ca.spatial.table.AttributeStore
SELECT_ADD, SELECT_FROM, SELECT_NEW
-
Constructor Summary
ConstructorsConstructorDescriptionRelationalStore(AttributeStore a1, AttributeStore a2, String columnName1, String columnName2)
RelationalStore(AttributeStore a1, AttributeStore a2, String columnName1, String columnName2, int rowDelta)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCellEditors(JTable table, int offset)
This method will be called by components that want to set up custom cell editors on JTables.boolean
Query if this layer supports extended editing of features.void
buildIndex(int column)
Build an index on the column.boolean
canIndex(int column)
Test to see if the column can be indexed.void
close()
Close the table and release resources.void
findBaseTable(String shortName)
Find a base table in this relation that has a matching short name.int
findColumn(String field, String shortName)
Get the column number of the given field in the given table.Return the base store belonging to this set of relationsint
boolean
Get the status of the extended editing mode.getFullColumnName(int column)
Return the full name of a column at a given position, including the short name of the table.Return the identity of the left branch of the join treeint
Get the total number of periods that this store supportsReturn the identity of the right branch of the join treeint
Get the number of rows in this storeint
getSnapshot(boolean useSelected, Observer progress)
Return a snapshot of the dataset at a given moment.Get the synchronizer object for this table.getValueAt(int row, int column, int period)
Override the getValue methodint
getYearForPeriod(int period)
Get the ending year for a given period.boolean
hasIndex(int column)
Indicate if an index has been build on a columnint
Look up the row number for a key value in given column number.int
nativeLookupRow(Object key, int column)
void
Drop all extraneous relations on the right hand branch of this join treevoid
setColumn1(String columnName1)
Change the column that the relate is being made with.void
setEditMode(boolean mode)
Enable or disable the extended editing mode.void
setValueAt(Object aValue, int row, int column, int period)
Set the value in a cell and notify listeners that the value has changed.void
Propogate table eventsMethods inherited from class ca.spatial.table.AttributeStore
absoluteFile, absoluteFile, absolutePath, absolutePath, addMenuItems, addPopupActivationListener, addRelate, addRelate, addTableModelListener, addToGlobalStoreList, booleanValue, booleanValue, calculate, calculateField, calculateField, changeSelection, clearSelection, compareTo, decodeCharset, doubleValue, doubleValue, exportCSV, exportCSV, exportCSV, exportCSV, exportCSV, exportCSV, exportDBF, exportDBF, exportDBF, exportDBF, exportDBF, findColumn, findSimilarColumnNames, getAttributeFormat, getCacheParent, getCachingLayer, getCachingLayer, getCanonicalName, getColumnClass, getColumnCount, getColumnName, getColumnNames, getContextPeriods, getCwd, getListSelectionModel, getMinMax, getMinMax, getMinMax, getMinMax, getMinMax, getOpenStore, getOpenStore, getOpenStore, getOpenStores, getPeriod, getPeriodWidth, getSelectedRowCount, getSelection, getSelection, getSelection, getShortName, getSnapshot, getStoreByShortName, getStoreByTitle, getTableName, getTableSpec, getTitle, getValueAt, identifyRecords, integerValue, integerValue, isCellEditable, isSelectedIndex, isSelectionEmpty, listify, listValue, listValue, makeLu, maybePopup, notifyPopupActivationListeners, openOrReuse, openOrReuse, queryTable, queryTable, quoteIfRequired, relativePath, removeFromGlobalStoreList, removePopupActivationListener, removeTableModelListener, select, select, selectAdd, selectFrom, selectNew, setCwd, setCwd, setListSelectionModel, setPeriod, setRowNodeRemap, setShortName, setTableSpec, setTitle, setValueAt, showCube, showTable, toString, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, valueChanged
Methods inherited from class javax.swing.table.AbstractTableModel
fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners
-
Field Details
-
DIRECT
public static final int DIRECTSpecify 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 INDIRECTSpecify 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
-
RelationalStore
public RelationalStore(AttributeStore a1, AttributeStore a2, String columnName1, String columnName2) throws Exception- Throws:
Exception
-
RelationalStore
public RelationalStore(AttributeStore a1, AttributeStore a2, String columnName1, String columnName2, int rowDelta) throws Exception- Throws:
Exception
-
-
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 classAttributeStore
-
closeAllRelates
public void closeAllRelates() -
getSnapshot
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 asCrosstabStore
), will compute an instance that can be used and then disposed.The default behaviour simply returns 'this'.
- Overrides:
getSnapshot
in classAttributeStore
- 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 classAttributeStore
- Returns:
- true if the store allows editing
-
setEditMode
Description copied from class:AttributeStore
Enable or disable the extended editing mode.- Overrides:
setEditMode
in classAttributeStore
- 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 classAttributeStore
- Returns:
- the editing mode in use
-
setColumn1
Change the column that the relate is being made with. -
getColumnName1
-
getColumnName2
-
getColumn1
-
getColumn2
public int getColumn2() -
getRowDelta
public int getRowDelta() -
getBaseRelation
Return the base store belonging to this set of relations -
getLeftRelate
Return the identity of the left branch of the join tree -
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
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 classAttributeStore
-
getRowNodeRemap
- Overrides:
getRowNodeRemap
in classAttributeStore
-
getRowCount
public int getRowCount()Description copied from class:AttributeStore
Get the number of rows in this store- Specified by:
getRowCount
in interfaceTableModel
- Specified by:
getRowCount
in classAttributeStore
- 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 classAttributeStore
- 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 classAttributeStore
- Parameters:
period
- The period of interest- Returns:
- the year for a given period
-
getValueAt
Override the getValue method- Specified by:
getValueAt
in classAttributeStore
- Parameters:
row
- The row containing the cellcolumn
- The column containing the cellperiod
- The period of interest- Returns:
- An object containing the cell value.
-
setValueAt
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 classAttributeStore
- Parameters:
aValue
- The value to be set.row
- The row containing the cellcolumn
- The column containing the cellperiod
- The period of interest
-
getFullColumnName
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 classAttributeStore
- Parameters:
column
- the column number of interest- Returns:
- the name of the column
-
findColumn
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 classAttributeStore
- Parameters:
field
- The name of the field to look upshortName
- 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
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 classAttributeStore
- 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. SeeAttributeStore.lookupRow(java.lang.Object, int)
.- Overrides:
buildIndex
in classAttributeStore
- 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 classAttributeStore
- Parameters:
column
- the column of interest- Returns:
- true if this column has an index
-
lookupRow
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 classAttributeStore
- Parameters:
key
- The data value to search forcolumn
- the column to search within- Returns:
- the row number where the value was found
-
nativeLookupRow
-
addCellEditors
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 classAttributeStore
- Parameters:
table
- AJTable
offset
- the column number in the store that will have a custom cell editor
-
tableChanged
Propogate table events- Specified by:
tableChanged
in interfaceTableModelListener
-