Class DatabaseSource
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.gui.tools.spreadsheetprocessor.AbstractWidget
-
- adams.gui.tools.spreadsheetprocessor.sources.AbstractSource
-
- adams.gui.tools.spreadsheetprocessor.sources.DatabaseSource
-
- All Implemented Interfaces:
LoggingLevelHandler,LoggingSupporter,SizeOfHandler,Serializable,Comparable<AbstractWidget>
public class DatabaseSource extends AbstractSource
For retrieving data from a database.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringKEY_DATAROWstatic StringKEY_PASSWORDstatic StringKEY_QUERYstatic StringKEY_TYPEMAPPERstatic StringKEY_URLstatic StringKEY_USERprotected BaseButtonm_ButtonExecutethe button for executing the query.protected SpreadSheetm_Datathe data.protected SqlConnectionPanelm_PanelConnectionthe connection panel.protected GenericObjectEditorPanelm_PanelDataRowthe panel for the row class.protected SQLStatementPanelm_PanelQuerythe query panel.protected GenericObjectEditorPanelm_PanelTypeMapperthe panel for the type mapper.protected BasePanelm_Widgetthe widget.-
Fields inherited from class adams.gui.tools.spreadsheetprocessor.AbstractWidget
m_Owner
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description DatabaseSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassign(AbstractWidget other)Retrieves the values from the other widget, if possible.voiddeserialize(Object data, MessageCollection errors)Deserializes the setup and maps it onto the widget. /** Deserializes the setup and maps it onto the widget.protected voidexecute()Loads the dataAbstractDatabaseConnectiongetCurrentConnection()Returns the current connection.DataRowgetCurrentDataRow()Returns the current data row.SQLStatementgetCurrentQuery()Returns the current query.AbstractTypeMappergetCurrentTypeMapper()Returns the current type mapper.SpreadSheetgetData()Returns the currently available dataStringgetName()Returns the name of the widget.ComponentgetWidget()Returns the widget.booleanhasData()Checks whether data is available.Objectserialize()Serializes the setup from the widget.voidsetCurrentConnection(AbstractDatabaseConnection value)Sets the current connection.voidsetCurrentDataRow(DataRow value)Sets the current data row.voidsetCurrentQuery(SQLStatement value)Sets the current query.voidsetCurrentTypeMapper(AbstractTypeMapper value)Sets the current type mapper.voidupdate()Updates the widget.-
Methods inherited from class adams.gui.tools.spreadsheetprocessor.AbstractWidget
compareTo, equals, getOwner, notifyOwner, setOwner, toString
-
Methods inherited from class adams.core.logging.CustomLoggingLevelObject
setLoggingLevel
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
KEY_URL
public static final String KEY_URL
- See Also:
- Constant Field Values
-
KEY_USER
public static final String KEY_USER
- See Also:
- Constant Field Values
-
KEY_PASSWORD
public static final String KEY_PASSWORD
- See Also:
- Constant Field Values
-
KEY_QUERY
public static final String KEY_QUERY
- See Also:
- Constant Field Values
-
KEY_TYPEMAPPER
public static final String KEY_TYPEMAPPER
- See Also:
- Constant Field Values
-
KEY_DATAROW
public static final String KEY_DATAROW
- See Also:
- Constant Field Values
-
m_Widget
protected BasePanel m_Widget
the widget.
-
m_PanelConnection
protected SqlConnectionPanel m_PanelConnection
the connection panel.
-
m_PanelTypeMapper
protected GenericObjectEditorPanel m_PanelTypeMapper
the panel for the type mapper.
-
m_PanelDataRow
protected GenericObjectEditorPanel m_PanelDataRow
the panel for the row class.
-
m_PanelQuery
protected SQLStatementPanel m_PanelQuery
the query panel.
-
m_ButtonExecute
protected BaseButton m_ButtonExecute
the button for executing the query.
-
m_Data
protected SpreadSheet m_Data
the data.
-
-
Method Detail
-
getName
public String getName()
Returns the name of the widget.- Specified by:
getNamein classAbstractWidget- Returns:
- the name
-
getWidget
public Component getWidget()
Returns the widget.- Specified by:
getWidgetin classAbstractWidget- Returns:
- the widget
-
execute
protected void execute()
Loads the data
-
hasData
public boolean hasData()
Checks whether data is available.- Specified by:
hasDatain classAbstractSource- Returns:
- true if available
-
getData
public SpreadSheet getData()
Returns the currently available data- Specified by:
getDatain classAbstractSource- Returns:
- the data, null if none available
-
setCurrentQuery
public void setCurrentQuery(SQLStatement value)
Sets the current query.- Parameters:
value- the current query
-
getCurrentQuery
public SQLStatement getCurrentQuery()
Returns the current query.- Returns:
- the current query
-
setCurrentConnection
public void setCurrentConnection(AbstractDatabaseConnection value)
Sets the current connection.- Parameters:
value- the connection
-
getCurrentConnection
public AbstractDatabaseConnection getCurrentConnection()
Returns the current connection.- Returns:
- the connection
-
setCurrentTypeMapper
public void setCurrentTypeMapper(AbstractTypeMapper value)
Sets the current type mapper.- Parameters:
value- the mapper
-
getCurrentTypeMapper
public AbstractTypeMapper getCurrentTypeMapper()
Returns the current type mapper.- Returns:
- the mapper
-
setCurrentDataRow
public void setCurrentDataRow(DataRow value)
Sets the current data row.- Parameters:
value- the data row
-
getCurrentDataRow
public DataRow getCurrentDataRow()
Returns the current data row.- Returns:
- the data row
-
assign
public void assign(AbstractWidget other)
Retrieves the values from the other widget, if possible.- Specified by:
assignin classAbstractWidget- Parameters:
other- the other widget to get the values from
-
serialize
public Object serialize()
Serializes the setup from the widget.- Specified by:
serializein classAbstractWidget- Returns:
- the generated setup representation
-
deserialize
public void deserialize(Object data, MessageCollection errors)
Deserializes the setup and maps it onto the widget. /** Deserializes the setup and maps it onto the widget.- Specified by:
deserializein classAbstractWidget- Parameters:
data- the setup representation to useerrors- for collecting errors
-
update
public void update()
Updates the widget.- Specified by:
updatein classAbstractWidget
-
-