Package ucar.unidata.data
Class DataSourceImpl
java.lang.Object
ucar.unidata.collab.SharableImpl
ucar.unidata.data.DataSourceImpl
- All Implemented Interfaces:
Sharable
,DataSource
,DataSourceFactory
,XmlPersistable
- Direct Known Subclasses:
AddeProfilerDataSource
,AddeTextDataSource
,CacheDataSource
,DescriptorDataSource
,EOLProfilerDataSource
,FilesDataSource
,GeodasDataSource
,ImageDataSource
,ListDataSource
,RaobDataSource
,WmsDataSource
public class DataSourceImpl
extends SharableImpl
implements DataSource, DataSourceFactory, XmlPersistable
An abstract class that implements the DataSource interface.
Holds a DataContext, name and description and manages a list of DataChoice-s.
This class is thread-compatible but not thread-safe. Concurrent access to instances of this class should be externally symchronized by the client.
- Version:
- $Revision: 1.221 $
- Author:
- IDV Development Team
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JCheckBox
change data paths checkboxprotected Object
Use this so this object is unique in the data cacheprotected List
<DataChoice> List of associated DataChoicesprotected GeoSelectionPanel
geoselection panelprotected boolean
Has this data source been created from a bundleprotected boolean
flag for continuationstatic int
flag for hiding a parameterstatic int
flag for hiding a parameterstatic int
flag for showing a parameterFields inherited from interface ucar.unidata.data.DataSource
DATAPATH_DATE_FORMAT, DATAPATH_DATE_PATTERN, MOST_RECENT, ordinalNames, PROP_AUTOCREATEDISPLAY, PROP_BASEDIRECTORY, PROP_CACHEABLE, PROP_DATACHOICENAME, PROP_DISPLAYPROPERTIES, PROP_DOCUMENTLINKS, PROP_FILEPATTERN, PROP_GEOLOCATION, PROP_ICON, PROP_NAME, PROP_POLLINFO, PROP_RESOLVERURL, PROP_SERVICE_HTTP, PROP_SUBPROPERTIES, PROP_TIMELABELS, PROP_TIMESTRIDE, PROP_TITLE
-
Constructor Summary
ConstructorsConstructorDescriptionBean constructorDataSourceImpl
(DataSourceDescriptor descriptor) Create a DataSourceImplDataSourceImpl
(DataSourceDescriptor descriptor, String name, String description, Hashtable properties) Create this DataSourceImpl, setting the dataContext, name and description attributes. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addActions
(List actions) Get anyAction
-s associated with this DataSource.void
addDataChangeListener
(DataChangeListener listener) Add the data change listenerprotected void
addDataChoice
(DataChoice choice) Insert the new DataChoice into the dataChoice list.void
addPropertiesTabs
(JTabbedPane tabbedPane) Add any extra tabs into the properties tabprotected void
addReloadTab
(JTabbedPane tabbedPane) Add a reload tabprotected void
applyFieldMask
(Element root) Load any parameter nodes in the given mask xmlboolean
Apply properties componentsprotected Object
Start the JobManager load dialogboolean
canAddCurrentName
(DataChoice dataChoice) Can we add the data choice name to the global list of parameter names (used in the station model editor)boolean
Can this data source cache itsboolean
Can the data be changed? Subclasses should override if they can't.boolean
Can this handle "All levels"?protected boolean
Can this do a field mask?boolean
Can this datasource do the geoselection subsetting and decimationprotected boolean
Used for the geo subsetting property gui as to whether to show the map selection or notprotected boolean
Used for the geo subsetting property gui as to whether to show the stride or notboolean
canPoll()
See if this data source can pollboolean
Is this data source capable of saving its data to local diskint
canShowParameter
(String name) Should we show the given parameter nameprotected void
some method to initializevoid
This is called when the CacheManager detects the need ot clear memory.protected void
Clear the cachevoid
Clear the times listconvertSourceFile
(String source) If this datasource has an ncml template this method will wrap the actual data file in ncml and return the ncmlprotected List
convertToFilesIfDirectory
(List sources) If the given list is of size 1 and it is a directory then find all files in the directory that match the filePatternForPolling and return them.void
createAutoDisplay
(String displayType, DataContext dataContext) Automatically create the given display on initialization.protected Object
createCacheKey
(DataChoice dataChoice, DataSelection dataSelection, Hashtable requestProperties) Utility to create the key used when cachingcreateElement
(XmlEncoder encoder) Create the XML element for persisting this DataSourcestatic void
Decrement the static count of get data callsprotected File
doDirectory
(File file) Get the most recent file in a direcdtoryprotected void
A stub for the derived classes to overwrite.protected List
A stub for the derived classes to overwrite.Make the subset componentdoMakeGeoSelectionPanel
(boolean forProperties) Make the geoselection paneldoMakeGeoSelectionPanel
(boolean forProperties, GeoSelection geoSelection) Make the geoselection panelprotected JComponent
Make the geo subset properties componentvoid
doRemove()
Gets called by theDataManager
when this DataSource has been removed.protected void
endWritingDataToLocalDisk
(Object loadId) Stop the JobManager load dialogboolean
See if the Object in question is equal to this DataSource.void
Gets called by the DataSelection tree gui when a CompositeDataChoice is first opened.findDataChoice
(Object id) Search through the list of DataChoice-s and return the DataChoice object whose id equals the given id parameter.Search through the list of DataChoice-s and return the DataChoice object whose id equals the given id parameter.protected void
Flush the data cache for this DataSourcegetAbsoluteDateTimes
(List selected) Get the absolute times.Get anyAction
-s associated with this DataSource.getAlias()
Get the Alias property.Return an array of DateTimes representing all the times in the DataSource.getAllDateTimes
(DataChoice dataChoice) Get all the times for the given DataChoicegetAllLevels
(DataChoice dataChoice) Get the list of all levels available from this DataSourcegetAllLevels
(DataChoice dataChoice, DataSelection dataSelection) Get all of the levelsgetAllTimesForTimeDriver
(DataChoice dataChoice, DataSelection selection, List<DateTime> timeDriverTimes) Get the list of times to compare to the time driver timesGet an Object from the cache.Get an Object from the cache.long
Get the CacheClearDelay property.boolean
Get the CacheFlatFields property.getCompositeDataChoices
(CompositeDataChoice compositeDataChoice, List dataChoices) This is called by the composite data choice to update the list of children.getData
(DataChoice dataChoice, DataCategory dataCategory, Hashtable requestProperties) Get the data applicable to the DataChoice and selection criteria.getData
(DataChoice dataChoice, DataCategory category, DataSelection incomingDataSelection, Hashtable requestProperties) Get the data applicable to the DataChoice and selection criteria.Where do we write cached data toprotected List
Get the data change listenersThis will lazily create the actual list of DataChoice-s with a call to doMakeDataChoices which creates the DataChoice objects concretely defined by this DataSource (e.g., the fields within an netCdf file).Get theDataContext
for this DataSource.protected Data
getDataInner
(DataChoice dataChoice, DataCategory category, DataSelection dataSelection) Have this one around for other, non-unidata, datasource implementations.protected Data
getDataInner
(DataChoice dataChoice, DataCategory category, DataSelection dataSelection, Hashtable requestProperties) Actually get the data identified by the given DataChoce.boolean
Get the DataIsEditable property.Get the file paths (or urls or whatever) that are to be changed when we re unpersisted and are in data editable modeprotected String
Get the file prefix to use for when saving data to local diskReturn the DataSelection for this DataSource.getDataSelectionComponents
(DataChoice dataChoice) A hook to allow this data source to add data selection components to the IDV field selectorThis is the method defined for the DataSourceFactory interface.static List
getDateTimes
(List selected, List allTimes) A utility method that returns a list of times.Return the list of times held by the DataSelection member.boolean
Gets the default save.Return the human readable description of this DataSourceGet theDataSourceDescriptor
for this DataSource.Get the error message (if there is one) or create one.boolean
Get the EverChangedName property.protected JComponent
Return the extra component for the geo selection panel.protected JComponent
This gets pu at the bottom of the times properties tabprotected FileFilter
Return the file fitler that the polling info uses.Get the full description for this data source.getid()
Get a unique id for this DataSourcegetIdv()
Get the IDVboolean
Return whether this DataSource is in errorprotected String
getLocalDirectory
(String label, String prefix) Get the directory to write the localized data files toprotected File
Get the location, either a file or a directory, that is where we poll on.protected List
Get the locations to use for pollingprotected List
getMostRecentFiles
(File dir, int cnt) Find the most recent cnt number of files in the given directory that match the fileFIlterForPollinggetName()
Returns the human readable name of this DataSource.static String
getNameForDataSource
(DataSource ds, int length, boolean alwaysDoIt) A helper method to find the label to use for the givenDataSource
.boolean
Should we show the error to the user.int
A unique identifier for DataSource objects.static int
How many get data calls are we currently waiting onReturn the human readable description of this DataSourceGet the Password property.Return the paths that can be saved off relative to wehre the bundle is.Get the PollingInfo property.Get the associated propertiesvoid
getPropertiesComponents
(List comps) Add the gui components into the list for the properties dialogprotected JComponent
getPropertiesHeader
(String label) Utility to create a header for the properties dialoggetProperty
(String name) Get a property.boolean
getProperty
(String name, boolean dflt) Get the named boolean propertydouble
getProperty
(String name, double dflt) Get the named double propertyint
getProperty
(String name, int dflt) Get the named int propertylong
getProperty
(String name, long dflt) Get the named long propertygetProperty
(String name, Object dflt) Get the object propertygetProperty
(String name, String dflt) Get the named String property.Get the RelativePaths property.protected ucar.unidata.geoloc.ProjectionImpl
Used for the geo subsetting property guiprotected String
Get the save data to a file labelGet the list of selected times.getSelectedDateTimes
(DataChoice dataChoice) Get the selected times for the given DataChoice.protected List
getTimesFromDataSelection
(DataSelection givenDataSelection, DataChoice dataChoice) If givenDataSelection is non-null and has a non-null times list then return that.Get the TmpPaths property.final String
Get the type name for this DataSourceGet the UserName property.void
Handle the properties actionprotected boolean
Do we have polling info objectstatic boolean
holdsDateTimes
(List selectedTimes) See if the selection list is a set of times or indicesstatic boolean
holdsIndices
(List selectedTimes) A utility to determine whether the given list holds a set of Integer indices.boolean
identifiedBy
(Object definingObject) See if this DataSource is identified by the definingObject.boolean
identifiedByName
(String name) Is this datasource identified by the given label.static void
Increment the static count of get data callsprotected void
Init aftervoid
Gets called after creation.void
Implement the XmlPersistable interface method that is called after this object has been fully created and initialized after being unpersisted by the XmlEncoder.void
initDataChoice
(DataChoice dataChoice) Sets the global id of the given dataChoice to be a per process unique string value.protected void
initDataSelectionComponents
(List<DataSelectionComponent> components, DataChoice dataChoice) Add any data selection componentsboolean
initFromXml
(XmlEncoder encoder, Element element) Initialize this from XMLprotected boolean
Are we currently polling.protected void
Check to see if there is a field maskfile defined.protected void
loadFieldMask
(String maskFile) Load the field maskprotected File
loadLatestFile
(File file) Load the latest file.void
logException
(String msg, Exception exc) Shortcut to logging facility for subclasses to usevoid
logException
(String msg, Exception exc, byte[] fileBytes) Log the exception with the file bytesprotected void
makeDerivedDataChoices
(List dataChoices) Add to the given list the set of derived data choicesprotected void
makeSaveLocalActions
(List actions) Make save local actionsvoid
This gets called by the FilePoller ActionListener to notify DataSource-s of a change to the file system.void
newFilesFromPolling
(List files) This gets called by the FilePoller ActionListener to notify DataSource-s of a change to the file system.void
Notify allDataChangeListener
s of some change to the dataprotected void
The properties changedvoid
Put an object in the cache if caching is enabled.void
Put an object in the cache.void
Flush the cache and tell listeners we have changed.void
reloadData
(Object object, Hashtable properties) Reload datavoid
reloadProperties
(Hashtable newProperties) Reload propertiesvoid
removeCache
(Object key) Remove an Object from the cache.void
removeDataChangeListener
(DataChangeListener listener) Remove the data change listenerprotected void
removeDataChoice
(DataChoice choice) Remove the choicevoid
removeProperty
(String name) Remove the propertyvoid
replaceDataChoice
(DataChoice oldDataChoice, DataChoice newDataChoice) Replace the given child with the given choldvoid
This gets called after we have been saved in a zidv bundle to reset us back to any original stateSave dat to local disksaveDataToLocalDisk
(boolean changeLinks, String uniqueFilePath) Save the data to local disk.protected List
saveDataToLocalDisk
(String filePrefix, Object loadId, boolean changeLinks) Save the data source files to local diskselectTimesFromList
(DataSelection dataSelection, List sourceTimes, List<DateTime> selectionTimes) For each time in selectionTimes this method finds the closest time in sourceTimesvoid
Set the Alias property.void
setAskToUpdate
(boolean value) Set the AskToUpdate property.void
setCacheClearDelay
(long value) Set the CacheClearDelay property.void
setCacheDataToDisk
(boolean value) Set the CacheFlatFields property.void
setDataEditableStrings
(List strings) Set the changed file or url pathsvoid
setDataIsEditable
(boolean value) Set the DataIsEditable property.void
setDataIsRelative
(boolean value) Set the DataIsEditable property.void
setDataRelativeStrings
(List strings) Used when loading from a bundle with relative file pathsvoid
Set the DataSelection for this DataSource.void
setDateTimeSelection
(List selectedTimes) Set the list of selected times for this data source.void
setDefaultSave
(boolean defaultsave) Sets the default save.void
Set the description for this DataSourcevoid
Set theDataSourceDescriptor
for this DataSource.void
noop.void
setEverChangedName
(boolean value) Set the EverChangedName property.void
setInError
(boolean e) Set whether this DataSource is in errorvoid
setInError
(boolean inError, boolean needToShowErrorToUser, String msg) Set the inErrorvoid
setInError
(boolean e, String msg) Set whether this DataSource is in errorvoid
Set the name of this DataSourcevoid
setNewFiles
(List files) Used for when we dynamically change the data source files form a bundle or from image generationvoid
setObjectProperties
(Hashtable properties) set the propertiesvoid
setObjectProperty
(String name, String value) Set the property on this object.void
setPassword
(String value) Set the Password property.void
setPollingInfo
(PollingInfo value) Set the PollingInfo property.void
setPollLocation
(String value) noop.void
Get the associated propertiesvoid
setProperty
(String prop, boolean value) Set a boolean property.void
setProperty
(String prop, Object value) Set a string property.void
setRelativePaths
(List value) Set the RelativePaths property.void
Keep around for legacy bundlesvoid
setTmpPaths
(List value) Set the TmpPaths property.void
setUserName
(String value) Set the UserName property.protected boolean
shouldCache
(DataChoice dataChoice, Data data) See if this DataSource should cache or notprotected boolean
shouldCache
(Data data) See if this DataSource should cache or notboolean
showPasswordDialog
(String title, String label) Show the password dialogboolean
Show the properties dialogboolean
showPropertiesDialog
(String initTabName) Show the properties dialogboolean
showPropertiesDialog
(String initTabName, boolean modal) Show the dialogprotected void
showWaitDialog
(int count) Show a wait dialog.protected void
tick()
Stub method.toString()
Return a String representation of this DataSourceReturn a truncated string for the name if too longprotected void
Update the properties dialog details pagevoid
updateState
(Object newObject, Hashtable newProperties) Update the statevoid
Write a mask fileprotected void
writeFieldMaskFile
(Document doc, Element root) Write the field mask file.Methods inherited from class ucar.unidata.collab.SharableImpl
applySharableProperties, doShare, doShare, doShareExternal, doShareInternal, getReceiveShareTime, getSharablePropertiesComponent, getShareGroup, getSharing, getUniqueId, initSharable, receiveShareData, removeSharable, setReceiveShareTime, setShareGroup, setSharing, setUniqueId, showSharableDialog
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ucar.unidata.data.DataSource
getUniqueId
-
Field Details
-
PARAM_SHOW_YES
public static int PARAM_SHOW_YESflag for showing a parameter -
PARAM_SHOW_HIDE
public static int PARAM_SHOW_HIDEflag for hiding a parameter -
PARAM_SHOW_NO
public static int PARAM_SHOW_NOflag for hiding a parameter -
dataCacheKey
Use this so this object is unique in the data cache -
dataChoices
List of associated DataChoices -
changeDataPathsCbx
change data paths checkbox -
geoSelectionPanel
geoselection panel -
haveBeenUnPersisted
protected boolean haveBeenUnPersistedHas this data source been created from a bundle -
okToContinue
protected boolean okToContinueflag for continuation
-
-
Constructor Details
-
DataSourceImpl
public DataSourceImpl()Bean constructor -
DataSourceImpl
Create a DataSourceImpl- Parameters:
descriptor
- the descriptor for this DataSource
-
DataSourceImpl
public DataSourceImpl(DataSourceDescriptor descriptor, String name, String description, Hashtable properties) Create this DataSourceImpl, setting the dataContext, name and description attributes.- Parameters:
descriptor
- the descriptor for this DataSourcename
- the name for thisdescription
- the descriptionproperties
- extra properties
-
-
Method Details
-
reloadData
Reload data- Specified by:
reloadData
in interfaceDataSource
- Parameters:
object
- the objectproperties
- the properties
-
reloadProperties
Reload properties- Parameters:
newProperties
- new properties
-
convertSourceFile
If this datasource has an ncml template this method will wrap the actual data file in ncml and return the ncml- Parameters:
source
- the original file or url- Returns:
- The wrapped file or url if we have an ncml template. Else the source
- Throws:
Exception
- On badness
-
canDoFieldMask
protected boolean canDoFieldMask()Can this do a field mask?- Returns:
- false
-
canDoAllLevels
public boolean canDoAllLevels()Can this handle "All levels"?- Specified by:
canDoAllLevels
in interfaceDataSource
- Returns:
- true
-
getIdv
Get the IDV- Returns:
- the IDV
-
loadFieldMask
protected void loadFieldMask()Check to see if there is a field maskfile defined. If so load it in. -
loadFieldMask
Load the field mask- Parameters:
maskFile
- the field mask
-
applyFieldMask
Load any parameter nodes in the given mask xml- Parameters:
root
- xml root
-
canAddCurrentName
Can we add the data choice name to the global list of parameter names (used in the station model editor)- Specified by:
canAddCurrentName
in interfaceDataSource
- Parameters:
dataChoice
- the data choice- Returns:
- can add to global name list
-
writeFieldMaskFile
public void writeFieldMaskFile()Write a mask file -
writeFieldMaskFile
Write the field mask file. Subclasses should implement- Parameters:
doc
- document to write toroot
- root element
-
canShowParameter
Should we show the given parameter name- Parameters:
name
- parameter name- Returns:
- should show the parameter as a data choice
-
setObjectProperties
Description copied from interface:DataSource
set the properties- Specified by:
setObjectProperties
in interfaceDataSource
- Parameters:
properties
- Specification of the name=value properties.
-
setObjectProperty
Set the property on this object. Use reflection to find the appropriate set method- Parameters:
name
- property namevalue
- value
-
getCompositeDataChoices
This is called by the composite data choice to update the list of children. The default is to just return the given list but derived classes might do something different.- Specified by:
getCompositeDataChoices
in interfaceDataSource
- Parameters:
compositeDataChoice
- The compositedataChoices
- List of children choices- Returns:
- The dataChoices list
-
initAfter
protected void initAfter()Init after -
initAfterUnpersistence
public void initAfterUnpersistence()Implement the XmlPersistable interface method that is called after this object has been fully created and initialized after being unpersisted by the XmlEncoder.- Specified by:
initAfterUnpersistence
in interfaceDataSource
-
initAfterCreation
public void initAfterCreation()Gets called after creation. Initialize the polling.- Specified by:
initAfterCreation
in interfaceDataSource
-
setNewFiles
Used for when we dynamically change the data source files form a bundle or from image generation- Specified by:
setNewFiles
in interfaceDataSource
- Parameters:
files
- List of new files to use
-
createElement
Create the XML element for persisting this DataSource- Specified by:
createElement
in interfaceXmlPersistable
- Parameters:
encoder
- encoder to use- Returns:
- this as XML
-
initFromXml
Initialize this from XML- Specified by:
initFromXml
in interfaceXmlPersistable
- Parameters:
encoder
- encoder for XMLelement
- the XML representation- Returns:
- true
-
getProperties
Get the associated properties- Returns:
- the properties
-
setProperties
Get the associated properties- Parameters:
p
- the new properties
-
removeProperty
Remove the property- Parameters:
name
- property name to remove
-
getProperty
Get a property.- Specified by:
getProperty
in interfaceDataSource
- Parameters:
name
- name of property- Returns:
- the associated property value or
null
-
setProperty
Set a string property.- Parameters:
prop
- property namevalue
- property value
-
getProperty
Get the named String property.- Parameters:
name
- name of propertydflt
- default value- Returns:
- the value of the property or the default
-
getProperty
Get the named long property- Parameters:
name
- name of propertydflt
- default value- Returns:
- the value of the property or the default
-
getProperty
Get the named int property- Parameters:
name
- name of propertydflt
- default value- Returns:
- the value of the property or the default
-
getProperty
Get the named double property- Parameters:
name
- name of propertydflt
- default value- Returns:
- the value of the property or the default
-
getProperty
Get the object property- Parameters:
name
- name of propertydflt
- default value- Returns:
- the value of the property or the default
-
getProperty
Get the named boolean property- Parameters:
name
- name of propertydflt
- default value- Returns:
- the value of the property or the default
-
setProperty
Set a boolean property.- Parameters:
prop
- name of propertyvalue
- value of property
-
getNeedToShowErrorToUser
public boolean getNeedToShowErrorToUser()Should we show the error to the user. Normally this is true but some data sources handle their own errors. By setting this to false the error message won't show up twice.- Specified by:
getNeedToShowErrorToUser
in interfaceDataSource
- Returns:
- Should show error
-
getInError
public boolean getInError()Return whether this DataSource is in error- Specified by:
getInError
in interfaceDataSource
- Returns:
- true if in error
-
setInError
Set whether this DataSource is in error- Parameters:
e
- true for errormsg
- error message
-
setInError
Set the inError- Parameters:
inError
- Is in errorneedToShowErrorToUser
- SHould show to usermsg
- Any message
-
setInError
public void setInError(boolean e) Set whether this DataSource is in error- Specified by:
setInError
in interfaceDataSource
- Parameters:
e
- true for error
-
getErrorMessage
Get the error message (if there is one) or create one.- Specified by:
getErrorMessage
in interfaceDataSource
- Returns:
- the error message
-
clearCachedData
public void clearCachedData()This is called when the CacheManager detects the need ot clear memory. It is intended to be overwritten by derived classes that are holding cached data that is not in the normal putCache facilities provided by this class since that data is actually managed by the CacheManager- Specified by:
clearCachedData
in interfaceDataSource
-
flushCache
protected void flushCache()Flush the data cache for this DataSource -
putCache
Put an object in the cache if caching is enabled.- Parameters:
key
- cache keyvalue
- associated key value
-
putCache
Put an object in the cache.- Parameters:
key
- cache keyvalue
- associated key valueforce
- force a cache
-
getCache
Get an Object from the cache.- Parameters:
key
- key for the object- Returns:
- the key value, or
null
-
getCache
Get an Object from the cache.- Parameters:
key
- key for the objectforce
- force a lookup even if not caching- Returns:
- the key value, or
null
-
removeCache
Remove an Object from the cache.- Parameters:
key
- key for the object
-
shouldCache
See if this DataSource should cache or not- Parameters:
dataChoice
- The data choice we got this data fromdata
- Data to cache- Returns:
- true
-
shouldCache
See if this DataSource should cache or not- Parameters:
data
- Data to cache- Returns:
- true
-
doRemove
public void doRemove()Gets called by theDataManager
when this DataSource has been removed.- Specified by:
doRemove
in interfaceDataSource
-
loadLatestFile
Load the latest file.- Parameters:
file
- file to load- Returns:
- name of file loaded.
-
doDirectory
Get the most recent file in a direcdtory- Parameters:
file
- directory- Returns:
- the most recent file in the directory deprecated Use loadLatestFile
-
newFilesFromPolling
This gets called by the FilePoller ActionListener to notify DataSource-s of a change to the file system.- Parameters:
files
- List of files
-
newFileFromPolling
This gets called by the FilePoller ActionListener to notify DataSource-s of a change to the file system.- Parameters:
f
- new file
-
toString
Return a String representation of this DataSource -
toStringTruncated
Return a truncated string for the name if too long- Returns:
- toString truncated to 30 chars
-
getid
Get a unique id for this DataSource- Returns:
- a unique id
-
setDescriptor
Set theDataSourceDescriptor
for this DataSource.- Parameters:
d
- new descriptor
-
getDescriptor
Get theDataSourceDescriptor
for this DataSource.- Returns:
- the descriptor
-
getDataChangeListeners
Get the data change listeners- Returns:
- Data change listeners
-
addDataChangeListener
Add the data change listener- Specified by:
addDataChangeListener
in interfaceDataSource
- Parameters:
listener
- listener to add
-
removeDataChangeListener
Remove the data change listener- Specified by:
removeDataChangeListener
in interfaceDataSource
- Parameters:
listener
- listener to remove
-
reloadData
public void reloadData()Flush the cache and tell listeners we have changed. Derived classes should overwrite this method and clear out any state they may be holding. Then they should call this method to do the notification.- Specified by:
reloadData
in interfaceDataSource
-
clearFileCache
protected void clearFileCache()Clear the cache -
notifyDataChange
public void notifyDataChange()Notify allDataChangeListener
s of some change to the data- Specified by:
notifyDataChange
in interfaceDataSource
-
getDataContext
Get theDataContext
for this DataSource.- Returns:
- the DataContext or
null
.
-
getDataSource
This is the method defined for the DataSourceFactory interface. Just return ourself.- Specified by:
getDataSource
in interfaceDataSourceFactory
- Returns:
- this
-
equals
See if the Object in question is equal to this DataSource. -
identifiedByName
Is this datasource identified by the given label. The name may be of the form "class:classpattern" or just a pattern to match the name by- Specified by:
identifiedByName
in interfaceDataSource
- Parameters:
name
- the name.- Returns:
- true if it is
-
identifiedBy
See if this DataSource is identified by the definingObject.- Specified by:
identifiedBy
in interfaceDataSource
- Parameters:
definingObject
- definingObject to check- Returns:
- true if this is defined by
definingObject
-
getTypeName
Get the type name for this DataSource- Specified by:
getTypeName
in interfaceDataSource
- Returns:
- the type name or
null
-
createAutoDisplay
Automatically create the given display on initialization. This used to be in the IDV but we moved it here to allow different data sources to do different things.- Specified by:
createAutoDisplay
in interfaceDataSource
- Parameters:
displayType
- The display control type id.dataContext
- Really, the IDV
-
initDataChoice
Sets the global id of the given dataChoice to be a per process unique string value. Used (for now) for persistence.- Parameters:
dataChoice
- dataChoice to initialize
-
findDataChoice
Search through the list of DataChoice-s and return the DataChoice object whose id equals the given id parameter. If the id based search is unsuccessful then check using the name of the DataChoice.- Specified by:
findDataChoice
in interfaceDataSource
- Parameters:
id
- id of DataChoice- Returns:
- the DataChoice which has id or
null
-
findDataChoices
Search through the list of DataChoice-s and return the DataChoice object whose id equals the given id parameter. If the id based search is unsuccessful then check using the name of the DataChoice.- Specified by:
findDataChoices
in interfaceDataSource
- Parameters:
id
- id of DataChoice- Returns:
- the DataChoice which has id or
null
-
checkForInitAfterUnPersistence
protected void checkForInitAfterUnPersistence()some method to initialize -
makeDerivedDataChoices
Add to the given list the set of derived data choices- Parameters:
dataChoices
- base list of choices
-
getDataChoices
This will lazily create the actual list of DataChoice-s with a call to doMakeDataChoices which creates the DataChoice objects concretely defined by this DataSource (e.g., the fields within an netCdf file). Any DerivedDataChoices that are applicable to the initial set of DataChoice-s is added to the list. Then each DataChoice is initialized with a call to initDataChoice.- Specified by:
getDataChoices
in interfaceDataSource
- Returns:
- List of DataChoices
-
getAllLevels
Get the list of all levels available from this DataSource- Specified by:
getAllLevels
in interfaceDataSource
- Parameters:
dataChoice
- The data choice to get levels for- Returns:
- List of all available levels
-
getAllLevels
Get all of the levels- Specified by:
getAllLevels
in interfaceDataSource
- Parameters:
dataChoice
- The data choice to get levels fordataSelection
- data selection- Returns:
- list of levels.
-
clearTimes
public void clearTimes()Clear the times list -
getAllDateTimes
Return an array of DateTimes representing all the times in the DataSource. This lazily creates a list, timesList, using a call to doMakeDateTimes.- Specified by:
getAllDateTimes
in interfaceDataSource
- Returns:
- array of DateTimes (may be null)
-
getSelectedDateTimes
Get the list of selected times.- Specified by:
getSelectedDateTimes
in interfaceDataSource
- Returns:
- list of selected times
-
getSelectedDateTimes
Get the selected times for the given DataChoice.- Specified by:
getSelectedDateTimes
in interfaceDataSource
- Parameters:
dataChoice
- DataChoice in question- Returns:
- List of selected times
-
getAllDateTimes
Get all the times for the given DataChoice- Specified by:
getAllDateTimes
in interfaceDataSource
- Parameters:
dataChoice
- DataChoice in question- Returns:
- List of all times for that choice
-
getDataSelection
Return the DataSelection for this DataSource. The DataSelection represents the default criteria used for refining the getData calls. For example, the user can set the date/times to be used for this DataSource. This list of times is held in the DataSelection member.- Specified by:
getDataSelection
in interfaceDataSource
- Returns:
- the DataSelection for this DataSource
-
setDataSelection
Set the DataSelection for this DataSource.- Parameters:
s
- new selection
-
holdsDateTimes
See if the selection list is a set of times or indices- Parameters:
selectedTimes
- list to check- Returns:
- true if there are any times
-
holdsIndices
A utility to determine whether the given list holds a set of Integer indices.- Parameters:
selectedTimes
- A list of Integer indices or DateTime.- Returns:
- Does the given list hold indices.
-
getDateTimes
A utility method that returns a list of times. If selected holds DateTime objects then just return selected. Else selected holds Integer indices into the allTimes list.- Parameters:
selected
- Either a list of DateTime or a list of Integer indices.allTimes
- The source list of DataTimes that may be indexed by selected.- Returns:
- A list of DateTime-s.
-
getAbsoluteDateTimes
Get the absolute times.- Parameters:
selected
- list of selected times- Returns:
- List of absolute times
-
setDateTimeSelection
Set the list of selected times for this data source. This is used for XML persistence.- Specified by:
setDateTimeSelection
in interfaceDataSource
- Parameters:
selectedTimes
- List of selected times
-
getDateTimeSelection
Return the list of times held by the DataSelection member.- Specified by:
getDateTimeSelection
in interfaceDataSource
- Returns:
- DataSelection times
-
selectTimesFromList
public List<DateTime> selectTimesFromList(DataSelection dataSelection, List sourceTimes, List<DateTime> selectionTimes) throws Exception For each time in selectionTimes this method finds the closest time in sourceTimes- Parameters:
dataSelection
- The data selection. Not used right now.sourceTimes
- Needs to be a list of DateTime or Date objectsselectionTimes
- The selection times- Returns:
- List of times from sourceTimes that correspond to the selectionTimes
- Throws:
Exception
- On badness
-
getTimesFromDataSelection
If givenDataSelection is non-null and has a non-null times list then return that. Else return the times list from the myDataSelection member variable.- Parameters:
givenDataSelection
- the given DataSelectiondataChoice
- the given DataChoice- Returns:
- appropriate list of times
-
getAllTimesForTimeDriver
protected List<DateTime> getAllTimesForTimeDriver(DataChoice dataChoice, DataSelection selection, List<DateTime> timeDriverTimes) Get the list of times to compare to the time driver times- Parameters:
dataChoice
- the data choiceselection
- the selection (for things like level)timeDriverTimes
- the time driver times (use range for server query)- Returns:
- the list of times for comparison
-
getData
public Data getData(DataChoice dataChoice, DataCategory dataCategory, Hashtable requestProperties) throws VisADException, RemoteException Get the data applicable to the DataChoice and selection criteria.- Specified by:
getData
in interfaceDataSource
- Parameters:
dataChoice
- choice that defines the datadataCategory
- the data categoryrequestProperties
- extra request properties- Returns:
- the associated data
- Throws:
RemoteException
- Java RMI problemVisADException
- VisAD problem
-
showWaitDialog
protected void showWaitDialog(int count) Show a wait dialog. Subclasses should implement to use.- Parameters:
count
- wait time
-
tick
protected void tick()Stub method. Subclasses should implement. -
getOutstandingGetDataCalls
public static int getOutstandingGetDataCalls()How many get data calls are we currently waiting on- Returns:
- Outstanding calls
-
incrOutstandingGetDataCalls
public static void incrOutstandingGetDataCalls()Increment the static count of get data calls -
decrOutstandingGetDataCalls
public static void decrOutstandingGetDataCalls()Decrement the static count of get data calls -
createCacheKey
protected Object createCacheKey(DataChoice dataChoice, DataSelection dataSelection, Hashtable requestProperties) Utility to create the key used when caching- Parameters:
dataChoice
- data choicedataSelection
- data selectionrequestProperties
- properties on request- Returns:
- The object to cache on
-
getData
public Data getData(DataChoice dataChoice, DataCategory category, DataSelection incomingDataSelection, Hashtable requestProperties) throws VisADException, RemoteException Get the data applicable to the DataChoice and selection criteria.- Specified by:
getData
in interfaceDataSource
- Parameters:
dataChoice
- choice that defines the datacategory
- the data categoryincomingDataSelection
- DataSelection for subsettingrequestProperties
- extra request properties- Returns:
- the associated data
- Throws:
RemoteException
- Java RMI problemVisADException
- VisAD problem
-
getDataInner
protected Data getDataInner(DataChoice dataChoice, DataCategory category, DataSelection dataSelection) throws VisADException, RemoteException Have this one around for other, non-unidata, datasource implementations.- Parameters:
dataChoice
- The data choice that identifies the requested data.category
- The data category of the request.dataSelection
- Identifies any subsetting of the data.- Returns:
- The visad.Data object
- Throws:
RemoteException
- Java RMI problemVisADException
- VisAD problem
-
getDataInner
protected Data getDataInner(DataChoice dataChoice, DataCategory category, DataSelection dataSelection, Hashtable requestProperties) throws VisADException, RemoteException Actually get the data identified by the given DataChoce. The default is to call the getDataInner that does not take the requestProperties. This allows other, non unidata.data DataSource-s (that follow the old API) to work.- Parameters:
dataChoice
- The data choice that identifies the requested data.category
- The data category of the request.dataSelection
- Identifies any subsetting of the data.requestProperties
- Hashtable that holds any detailed request properties.- Returns:
- The visad.Data object
- Throws:
RemoteException
- Java RMI problemVisADException
- VisAD problem
-
getNextId
public int getNextId()A unique identifier for DataSource objects.- Returns:
- the next unique id
-
setName
Set the name of this DataSource- Parameters:
n
- new name
-
setTemplateName
Keep around for legacy bundles- Parameters:
n
- template name
-
getName
Returns the human readable name of this DataSource. This is the second argument ofDataSourceImpl(DataSourceDescriptor, String, String, Hashtable)
.- Specified by:
getName
in interfaceDataSource
- Returns:
- The human-readable specification of this data-source.
-
setDescription
Set the description for this DataSource- Parameters:
n
- the description
-
getDescription
Return the human readable description of this DataSource- Specified by:
getDescription
in interfaceDataSource
- Returns:
- the description
-
getPartialDescription
Return the human readable description of this DataSource- Specified by:
getPartialDescription
in interfaceDataSource
- Returns:
- the description
-
getFullDescription
Get the full description for this data source. Subclasses should override if they want something other than the default. This is what gets displayed in the details.- Specified by:
getFullDescription
in interfaceDataSource
- Returns:
- the full description of this data source (description + name)
-
addDataChoice
Insert the new DataChoice into the dataChoice list.- Parameters:
choice
- new choice to add
-
expandIfNeeded
Gets called by the DataSelection tree gui when a CompositeDataChoice is first opened. This allows us to incrementally expand these nested data choices.- Specified by:
expandIfNeeded
in interfaceDataSource
- Parameters:
cdc
- the data choice
-
removeDataChoice
Remove the choice- Parameters:
choice
- the choice
-
replaceDataChoice
Replace the given child with the given chold- Parameters:
oldDataChoice
- The old data choicenewDataChoice
- The new one
-
doMakeDataChoices
protected void doMakeDataChoices()A stub for the derived classes to overwrite. This is not abstract because there are some derived classes (e.g., ListDataSource) that do not create any DataChoice-s -
doMakeDateTimes
A stub for the derived classes to overwrite. This is not abstract because there are some derived classes (e.g., TextDataSource) that do not create have any times- Returns:
- empty list from this class
-
logException
Shortcut to logging facility for subclasses to use- Parameters:
msg
- error messageexc
- error Exception
-
logException
Log the exception with the file bytes- Parameters:
msg
- messageexc
- exceptionfileBytes
- bytes to write to a tmp file. May be null.
-
setAlias
Set the Alias property.- Specified by:
setAlias
in interfaceDataSource
- Parameters:
value
- The new value for Alias
-
getAlias
Get the Alias property.- Specified by:
getAlias
in interfaceDataSource
- Returns:
- The Alias
-
getActions
Get anyAction
-s associated with this DataSource. The actions can be used to create menus, buttons, etc. Subclasses should implement this method making sure to call super.getActions()- Specified by:
getActions
in interfaceDataSource
- Returns:
- list of actions
-
showPropertiesDialog
public boolean showPropertiesDialog()Show the properties dialog- Specified by:
showPropertiesDialog
in interfaceDataSource
- Returns:
- Was ok pressed
-
showPropertiesDialog
Show the properties dialog- Parameters:
initTabName
- If non null then show this tab- Returns:
- Was ok pressed
-
canSaveDataToLocalDisk
public boolean canSaveDataToLocalDisk()Is this data source capable of saving its data to local disk- Specified by:
canSaveDataToLocalDisk
in interfaceDataSource
- Returns:
- Can save to local disk
-
canChangeData
public boolean canChangeData()Can the data be changed? Subclasses should override if they can't.- Returns:
- true
-
saveDataToLocalDisk
protected List saveDataToLocalDisk(String filePrefix, Object loadId, boolean changeLinks) throws Exception Save the data source files to local disk- Parameters:
filePrefix
- This is the directory path to write the files to with the unique file identifier append to itloadId
- For stopping the load through the JobManagerchangeLinks
- Should this data source also change its internal data references- Returns:
- List of the files that were written
- Throws:
Exception
- On badness
-
saveDataToLocalDisk
Save dat to local disk- Returns:
- list of files?
-
saveDataToLocalDisk
Save the data to local disk. If the uniqueFilePath is null this prompts the user for a directory and a file prefix.- Specified by:
saveDataToLocalDisk
in interfaceDataSource
- Parameters:
changeLinks
- Should this data source also change its internal data referencesuniqueFilePath
- Where to write the files to- Returns:
- List of the files that were written
-
getSaveDataFileLabel
Get the save data to a file label- Returns:
- the save data to a file label
-
beginWritingDataToLocalDisk
Start the JobManager load dialog- Parameters:
msg
- Message to show in dialog- Returns:
- The JobManager load id
-
endWritingDataToLocalDisk
Stop the JobManager load dialog- Parameters:
loadId
- The JobManager load id
-
getDataPrefix
Get the file prefix to use for when saving data to local disk- Returns:
- File prefix to use
-
getLocalDirectory
Get the directory to write the localized data files to- Parameters:
label
- Label to show userprefix
- File prefix- Returns:
- Path with the file prefix that the user specified appended
-
showPropertiesDialog
Show the dialog- Parameters:
initTabName
- What tab should we show. May be null.modal
- Is dialog modal- Returns:
- success
-
propertiesChanged
protected void propertiesChanged()The properties changed -
handlePropertiesAction
Handle the properties action- Parameters:
cmd
- Action
-
getPropertiesHeader
Utility to create a header for the properties dialog- Parameters:
label
- Header label- Returns:
- Header
-
getPropertiesComponents
Add the gui components into the list for the properties dialog- Parameters:
comps
- List of components
-
canCacheDataToDisk
public boolean canCacheDataToDisk()Can this data source cache its- Returns:
- can cache data to disk
-
canDoGeoSelection
public boolean canDoGeoSelection()Can this datasource do the geoselection subsetting and decimation- Specified by:
canDoGeoSelection
in interfaceDataSource
- Returns:
- _can do geo subsetting
-
canDoGeoSelectionStride
protected boolean canDoGeoSelectionStride()Used for the geo subsetting property gui as to whether to show the stride or not- Returns:
- default is true
-
getDataSelectionComponents
A hook to allow this data source to add data selection components to the IDV field selector- Specified by:
getDataSelectionComponents
in interfaceDataSource
- Parameters:
dataChoice
- the data choice- Returns:
- list of components
-
initDataSelectionComponents
protected void initDataSelectionComponents(List<DataSelectionComponent> components, DataChoice dataChoice) Add any data selection components- Parameters:
components
- list of componentsdataChoice
- the data choice
-
getExtraTimesComponent
This gets pu at the bottom of the times properties tab- Returns:
- extra comp
-
addPropertiesTabs
Add any extra tabs into the properties tab- Parameters:
tabbedPane
- The properties tab
-
addReloadTab
Add a reload tab- Parameters:
tabbedPane
- the reload tab
-
doMakeGeoSubsetPropertiesComponent
Make the geo subset properties component- Returns:
- the component
-
updateDetailsText
protected void updateDetailsText()Update the properties dialog details page -
doMakeGeoSelectionPanel
Make the subset component- Returns:
- The subset properties component
-
doMakeGeoSelectionPanel
Make the geoselection panel- Parameters:
forProperties
- true if for the properties widget- Returns:
- the panel
-
doMakeGeoSelectionPanel
Make the geoselection panel- Parameters:
forProperties
- true if for the properties widgetgeoSelection
- geoselection to populate the panel- Returns:
- the panel
-
getExtraGeoSelectionComponent
Return the extra component for the geo selection panel. Example: This is ued by the grid data source to show the grid size label- Returns:
- null_
-
getSampleDataProjection
protected ucar.unidata.geoloc.ProjectionImpl getSampleDataProjection()Used for the geo subsetting property gui- Returns:
- default is null
-
canDoGeoSelectionMap
protected boolean canDoGeoSelectionMap()Used for the geo subsetting property gui as to whether to show the map selection or not- Returns:
- default is true
-
applyProperties
public boolean applyProperties()Apply properties components- Returns:
- false if something failed and we need to keep showing the dialog
-
addActions
Get anyAction
-s associated with this DataSource. The actions can be used to create menus, buttons, etc. Subclasses should implement this method making sure to call super.getActions()- Parameters:
actions
- List of actions
-
makeSaveLocalActions
Make save local actions- Parameters:
actions
- list of actions
-
getFileFilterForPolling
Return the file fitler that the polling info uses.- Returns:
- Polling file filter
-
getLocationForPolling
Get the location, either a file or a directory, that is where we poll on.- Returns:
- File or dir to poll.
-
getLocationsForPolling
Get the locations to use for polling- Returns:
- locations for polling
-
canPoll
public boolean canPoll()See if this data source can poll- Returns:
- true if can poll
-
isPolling
protected boolean isPolling()Are we currently polling.- Returns:
- Are we polling
-
setPollingInfo
Set the PollingInfo property.- Parameters:
value
- The new value for PollingInfo
-
getPollingInfo
Get the PollingInfo property.- Returns:
- The PollingInfo
-
hasPollingInfo
protected boolean hasPollingInfo()Do we have polling info object- Returns:
- have polling info object
-
setDirectory
noop. Keep around for legacy bundles.- Parameters:
n
- directory name deprecated
-
setPollLocation
noop. Keep around for legacy bundles.- Parameters:
value
- The new value for PollLocation deprecated
-
convertToFilesIfDirectory
If the given list is of size 1 and it is a directory then find all files in the directory that match the filePatternForPolling and return them. Else just return the list.- Parameters:
sources
- List of File-s or String file names- Returns:
- List of file names or the given list
-
getMostRecentFiles
Find the most recent cnt number of files in the given directory that match the fileFIlterForPolling- Parameters:
dir
- Directory to look at. If it is not a directory then use its parent.cnt
- Number of files to find.- Returns:
- List of cnt File-s
-
setAskToUpdate
public void setAskToUpdate(boolean value) Set the AskToUpdate property.- Parameters:
value
- The new value for AskToUpdate deprecated Keep around for bundles
-
setDataIsRelative
public void setDataIsRelative(boolean value) Set the DataIsEditable property.- Parameters:
value
- The new value for DataIsEditable
-
setDataIsEditable
public void setDataIsEditable(boolean value) Set the DataIsEditable property.- Specified by:
setDataIsEditable
in interfaceDataSource
- Parameters:
value
- The new value for DataIsEditable
-
getDataIsEditable
public boolean getDataIsEditable()Get the DataIsEditable property.- Specified by:
getDataIsEditable
in interfaceDataSource
- Returns:
- The DataIsEditable
-
getDataPaths
Get the file paths (or urls or whatever) that are to be changed when we re unpersisted and are in data editable mode- Specified by:
getDataPaths
in interfaceDataSource
- Returns:
- file paths to changed
-
setDataEditableStrings
Set the changed file or url paths- Parameters:
strings
- List of paths
-
setDataRelativeStrings
Used when loading from a bundle with relative file paths- Parameters:
strings
- Relative file paths
-
getPathsThatCanBeRelative
Return the paths that can be saved off relative to wehre the bundle is. The default here is to return null.- Returns:
- File paths that can be relative
-
setRelativePaths
Set the RelativePaths property.- Parameters:
value
- The new value for RelativePaths
-
getRelativePaths
Get the RelativePaths property.- Returns:
- The RelativePaths
-
updateState
Update the state- Specified by:
updateState
in interfaceDataSource
- Parameters:
newObject
- new objectnewProperties
- new properties to add
-
resetTmpState
public void resetTmpState()This gets called after we have been saved in a zidv bundle to reset us back to any original state- Specified by:
resetTmpState
in interfaceDataSource
-
setTmpPaths
Set the TmpPaths property.- Specified by:
setTmpPaths
in interfaceDataSource
- Parameters:
value
- The new value for TmpPaths
-
getTmpPaths
Get the TmpPaths property.- Specified by:
getTmpPaths
in interfaceDataSource
- Returns:
- The TmpPaths
-
getNameForDataSource
A helper method to find the label to use for the givenDataSource
. If the length of the toString of the data source is less than 30 just use that. Else be a bit smart about truncating it.- Parameters:
ds
- The data soruce to get a label forlength
- String length to clip toalwaysDoIt
- If false then we only lip if this is a file or url- Returns:
- The label
-
setCacheDataToDisk
public void setCacheDataToDisk(boolean value) Set the CacheFlatFields property.- Parameters:
value
- The new value for CacheFlatFields
-
getCacheDataToDisk
public boolean getCacheDataToDisk()Get the CacheFlatFields property.- Returns:
- The CacheFlatFields
-
getDataCachePath
Where do we write cached data to- Returns:
- cache path
-
setCacheClearDelay
public void setCacheClearDelay(long value) Set the CacheClearDelay property.- Parameters:
value
- The new value for CacheClearDelay
-
getCacheClearDelay
public long getCacheClearDelay()Get the CacheClearDelay property.- Returns:
- The CacheClearDelay
-
showPasswordDialog
Show the password dialog- Parameters:
title
- titlelabel
- label- Returns:
- true if successful
-
setUserName
Set the UserName property.- Parameters:
value
- The new value for UserName
-
getUserName
Get the UserName property.- Returns:
- The UserName
-
setPassword
Set the Password property.- Parameters:
value
- The new value for Password
-
getPassword
Get the Password property.- Returns:
- The Password
-
setEverChangedName
public void setEverChangedName(boolean value) Set the EverChangedName property.- Parameters:
value
- The new value for EverChangedName
-
getEverChangedName
public boolean getEverChangedName()Get the EverChangedName property.- Returns:
- The EverChangedName
-
setDefaultSave
public void setDefaultSave(boolean defaultsave) Sets the default save. The idea here is the user should just be allowed to select a default option when saving a zidv bundle rather than being asked additional questions.- Specified by:
setDefaultSave
in interfaceDataSource
- Parameters:
defaultsave
- the new default save
-
getDefaultSave
public boolean getDefaultSave()Gets the default save.- Returns:
- the default save
-