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 JCheckBoxchange data paths checkboxprotected ObjectUse this so this object is unique in the data cacheprotected List<DataChoice> List of associated DataChoicesprotected GeoSelectionPanelgeoselection panelprotected booleanHas this data source been created from a bundleprotected booleanflag for continuationstatic intflag for hiding a parameterstatic intflag for hiding a parameterstatic intflag 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 voidaddActions(List actions) Get anyAction-s associated with this DataSource.voidaddDataChangeListener(DataChangeListener listener) Add the data change listenerprotected voidaddDataChoice(DataChoice choice) Insert the new DataChoice into the dataChoice list.voidaddPropertiesTabs(JTabbedPane tabbedPane) Add any extra tabs into the properties tabprotected voidaddReloadTab(JTabbedPane tabbedPane) Add a reload tabprotected voidapplyFieldMask(Element root) Load any parameter nodes in the given mask xmlbooleanApply properties componentsprotected ObjectStart the JobManager load dialogbooleancanAddCurrentName(DataChoice dataChoice) Can we add the data choice name to the global list of parameter names (used in the station model editor)booleanCan this data source cache itsbooleanCan the data be changed? Subclasses should override if they can't.booleanCan this handle "All levels"?protected booleanCan this do a field mask?booleanCan this datasource do the geoselection subsetting and decimationprotected booleanUsed for the geo subsetting property gui as to whether to show the map selection or notprotected booleanUsed for the geo subsetting property gui as to whether to show the stride or notbooleancanPoll()See if this data source can pollbooleanIs this data source capable of saving its data to local diskintcanShowParameter(String name) Should we show the given parameter nameprotected voidsome method to initializevoidThis is called when the CacheManager detects the need ot clear memory.protected voidClear the cachevoidClear 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 ListconvertToFilesIfDirectory(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.voidcreateAutoDisplay(String displayType, DataContext dataContext) Automatically create the given display on initialization.protected ObjectcreateCacheKey(DataChoice dataChoice, DataSelection dataSelection, Hashtable requestProperties) Utility to create the key used when cachingcreateElement(XmlEncoder encoder) Create the XML element for persisting this DataSourcestatic voidDecrement the static count of get data callsprotected FiledoDirectory(File file) Get the most recent file in a direcdtoryprotected voidA stub for the derived classes to overwrite.protected ListA 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 JComponentMake the geo subset properties componentvoiddoRemove()Gets called by theDataManagerwhen this DataSource has been removed.protected voidendWritingDataToLocalDisk(Object loadId) Stop the JobManager load dialogbooleanSee if the Object in question is equal to this DataSource.voidGets 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 voidFlush 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.longGet the CacheClearDelay property.booleanGet 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 ListGet 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 theDataContextfor this DataSource.protected DatagetDataInner(DataChoice dataChoice, DataCategory category, DataSelection dataSelection) Have this one around for other, non-unidata, datasource implementations.protected DatagetDataInner(DataChoice dataChoice, DataCategory category, DataSelection dataSelection, Hashtable requestProperties) Actually get the data identified by the given DataChoce.booleanGet 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 StringGet 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 ListgetDateTimes(List selected, List allTimes) A utility method that returns a list of times.Return the list of times held by the DataSelection member.booleanGets the default save.Return the human readable description of this DataSourceGet theDataSourceDescriptorfor this DataSource.Get the error message (if there is one) or create one.booleanGet the EverChangedName property.protected JComponentReturn the extra component for the geo selection panel.protected JComponentThis gets pu at the bottom of the times properties tabprotected FileFilterReturn 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 IDVbooleanReturn whether this DataSource is in errorprotected StringgetLocalDirectory(String label, String prefix) Get the directory to write the localized data files toprotected FileGet the location, either a file or a directory, that is where we poll on.protected ListGet the locations to use for pollingprotected ListgetMostRecentFiles(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 StringgetNameForDataSource(DataSource ds, int length, boolean alwaysDoIt) A helper method to find the label to use for the givenDataSource.booleanShould we show the error to the user.intA unique identifier for DataSource objects.static intHow 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 propertiesvoidgetPropertiesComponents(List comps) Add the gui components into the list for the properties dialogprotected JComponentgetPropertiesHeader(String label) Utility to create a header for the properties dialoggetProperty(String name) Get a property.booleangetProperty(String name, boolean dflt) Get the named boolean propertydoublegetProperty(String name, double dflt) Get the named double propertyintgetProperty(String name, int dflt) Get the named int propertylonggetProperty(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.ProjectionImplUsed for the geo subsetting property guiprotected StringGet the save data to a file labelGet the list of selected times.getSelectedDateTimes(DataChoice dataChoice) Get the selected times for the given DataChoice.protected ListgetTimesFromDataSelection(DataSelection givenDataSelection, DataChoice dataChoice) If givenDataSelection is non-null and has a non-null times list then return that.Get the TmpPaths property.final StringGet the type name for this DataSourceGet the UserName property.voidHandle the properties actionprotected booleanDo we have polling info objectstatic booleanholdsDateTimes(List selectedTimes) See if the selection list is a set of times or indicesstatic booleanholdsIndices(List selectedTimes) A utility to determine whether the given list holds a set of Integer indices.booleanidentifiedBy(Object definingObject) See if this DataSource is identified by the definingObject.booleanidentifiedByName(String name) Is this datasource identified by the given label.static voidIncrement the static count of get data callsprotected voidInit aftervoidGets called after creation.voidImplement the XmlPersistable interface method that is called after this object has been fully created and initialized after being unpersisted by the XmlEncoder.voidinitDataChoice(DataChoice dataChoice) Sets the global id of the given dataChoice to be a per process unique string value.protected voidinitDataSelectionComponents(List<DataSelectionComponent> components, DataChoice dataChoice) Add any data selection componentsbooleaninitFromXml(XmlEncoder encoder, Element element) Initialize this from XMLprotected booleanAre we currently polling.protected voidCheck to see if there is a field maskfile defined.protected voidloadFieldMask(String maskFile) Load the field maskprotected FileloadLatestFile(File file) Load the latest file.voidlogException(String msg, Exception exc) Shortcut to logging facility for subclasses to usevoidlogException(String msg, Exception exc, byte[] fileBytes) Log the exception with the file bytesprotected voidmakeDerivedDataChoices(List dataChoices) Add to the given list the set of derived data choicesprotected voidmakeSaveLocalActions(List actions) Make save local actionsvoidThis gets called by the FilePoller ActionListener to notify DataSource-s of a change to the file system.voidnewFilesFromPolling(List files) This gets called by the FilePoller ActionListener to notify DataSource-s of a change to the file system.voidNotify allDataChangeListeners of some change to the dataprotected voidThe properties changedvoidPut an object in the cache if caching is enabled.voidPut an object in the cache.voidFlush the cache and tell listeners we have changed.voidreloadData(Object object, Hashtable properties) Reload datavoidreloadProperties(Hashtable newProperties) Reload propertiesvoidremoveCache(Object key) Remove an Object from the cache.voidremoveDataChangeListener(DataChangeListener listener) Remove the data change listenerprotected voidremoveDataChoice(DataChoice choice) Remove the choicevoidremoveProperty(String name) Remove the propertyvoidreplaceDataChoice(DataChoice oldDataChoice, DataChoice newDataChoice) Replace the given child with the given choldvoidThis 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 ListsaveDataToLocalDisk(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 sourceTimesvoidSet the Alias property.voidsetAskToUpdate(boolean value) Set the AskToUpdate property.voidsetCacheClearDelay(long value) Set the CacheClearDelay property.voidsetCacheDataToDisk(boolean value) Set the CacheFlatFields property.voidsetDataEditableStrings(List strings) Set the changed file or url pathsvoidsetDataIsEditable(boolean value) Set the DataIsEditable property.voidsetDataIsRelative(boolean value) Set the DataIsEditable property.voidsetDataRelativeStrings(List strings) Used when loading from a bundle with relative file pathsvoidSet the DataSelection for this DataSource.voidsetDateTimeSelection(List selectedTimes) Set the list of selected times for this data source.voidsetDefaultSave(boolean defaultsave) Sets the default save.voidSet the description for this DataSourcevoidSet theDataSourceDescriptorfor this DataSource.voidnoop.voidsetEverChangedName(boolean value) Set the EverChangedName property.voidsetInError(boolean e) Set whether this DataSource is in errorvoidsetInError(boolean inError, boolean needToShowErrorToUser, String msg) Set the inErrorvoidsetInError(boolean e, String msg) Set whether this DataSource is in errorvoidSet the name of this DataSourcevoidsetNewFiles(List files) Used for when we dynamically change the data source files form a bundle or from image generationvoidsetObjectProperties(Hashtable properties) set the propertiesvoidsetObjectProperty(String name, String value) Set the property on this object.voidsetPassword(String value) Set the Password property.voidsetPollingInfo(PollingInfo value) Set the PollingInfo property.voidsetPollLocation(String value) noop.voidGet the associated propertiesvoidsetProperty(String prop, boolean value) Set a boolean property.voidsetProperty(String prop, Object value) Set a string property.voidsetRelativePaths(List value) Set the RelativePaths property.voidKeep around for legacy bundlesvoidsetTmpPaths(List value) Set the TmpPaths property.voidsetUserName(String value) Set the UserName property.protected booleanshouldCache(DataChoice dataChoice, Data data) See if this DataSource should cache or notprotected booleanshouldCache(Data data) See if this DataSource should cache or notbooleanshowPasswordDialog(String title, String label) Show the password dialogbooleanShow the properties dialogbooleanshowPropertiesDialog(String initTabName) Show the properties dialogbooleanshowPropertiesDialog(String initTabName, boolean modal) Show the dialogprotected voidshowWaitDialog(int count) Show a wait dialog.protected voidtick()Stub method.toString()Return a String representation of this DataSourceReturn a truncated string for the name if too longprotected voidUpdate the properties dialog details pagevoidupdateState(Object newObject, Hashtable newProperties) Update the statevoidWrite a mask fileprotected voidwriteFieldMaskFile(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, showSharableDialogMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
reloadDatain 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:
canDoAllLevelsin 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:
canAddCurrentNamein 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:DataSourceset the properties- Specified by:
setObjectPropertiesin 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:
getCompositeDataChoicesin 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:
initAfterUnpersistencein interfaceDataSource
-
initAfterCreation
public void initAfterCreation()Gets called after creation. Initialize the polling.- Specified by:
initAfterCreationin interfaceDataSource
-
setNewFiles
Used for when we dynamically change the data source files form a bundle or from image generation- Specified by:
setNewFilesin interfaceDataSource- Parameters:
files- List of new files to use
-
createElement
Create the XML element for persisting this DataSource- Specified by:
createElementin interfaceXmlPersistable- Parameters:
encoder- encoder to use- Returns:
- this as XML
-
initFromXml
Initialize this from XML- Specified by:
initFromXmlin 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:
getPropertyin 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:
getNeedToShowErrorToUserin interfaceDataSource- Returns:
- Should show error
-
getInError
public boolean getInError()Return whether this DataSource is in error- Specified by:
getInErrorin 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:
setInErrorin interfaceDataSource- Parameters:
e- true for error
-
getErrorMessage
Get the error message (if there is one) or create one.- Specified by:
getErrorMessagein 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:
clearCachedDatain 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 theDataManagerwhen this DataSource has been removed.- Specified by:
doRemovein 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 theDataSourceDescriptorfor this DataSource.- Parameters:
d- new descriptor
-
getDescriptor
Get theDataSourceDescriptorfor this DataSource.- Returns:
- the descriptor
-
getDataChangeListeners
Get the data change listeners- Returns:
- Data change listeners
-
addDataChangeListener
Add the data change listener- Specified by:
addDataChangeListenerin interfaceDataSource- Parameters:
listener- listener to add
-
removeDataChangeListener
Remove the data change listener- Specified by:
removeDataChangeListenerin 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:
reloadDatain interfaceDataSource
-
clearFileCache
protected void clearFileCache()Clear the cache -
notifyDataChange
public void notifyDataChange()Notify allDataChangeListeners of some change to the data- Specified by:
notifyDataChangein interfaceDataSource
-
getDataContext
Get theDataContextfor this DataSource.- Returns:
- the DataContext or
null.
-
getDataSource
This is the method defined for the DataSourceFactory interface. Just return ourself.- Specified by:
getDataSourcein 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:
identifiedByNamein interfaceDataSource- Parameters:
name- the name.- Returns:
- true if it is
-
identifiedBy
See if this DataSource is identified by the definingObject.- Specified by:
identifiedByin interfaceDataSource- Parameters:
definingObject- definingObject to check- Returns:
- true if this is defined by
definingObject
-
getTypeName
Get the type name for this DataSource- Specified by:
getTypeNamein 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:
createAutoDisplayin 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:
findDataChoicein 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:
findDataChoicesin 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:
getDataChoicesin interfaceDataSource- Returns:
- List of DataChoices
-
getAllLevels
Get the list of all levels available from this DataSource- Specified by:
getAllLevelsin interfaceDataSource- Parameters:
dataChoice- The data choice to get levels for- Returns:
- List of all available levels
-
getAllLevels
Get all of the levels- Specified by:
getAllLevelsin 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:
getAllDateTimesin interfaceDataSource- Returns:
- array of DateTimes (may be null)
-
getSelectedDateTimes
Get the list of selected times.- Specified by:
getSelectedDateTimesin interfaceDataSource- Returns:
- list of selected times
-
getSelectedDateTimes
Get the selected times for the given DataChoice.- Specified by:
getSelectedDateTimesin interfaceDataSource- Parameters:
dataChoice- DataChoice in question- Returns:
- List of selected times
-
getAllDateTimes
Get all the times for the given DataChoice- Specified by:
getAllDateTimesin 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:
getDataSelectionin 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:
setDateTimeSelectionin interfaceDataSource- Parameters:
selectedTimes- List of selected times
-
getDateTimeSelection
Return the list of times held by the DataSelection member.- Specified by:
getDateTimeSelectionin 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:
getDatain 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:
getDatain 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:
getNamein 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:
getDescriptionin interfaceDataSource- Returns:
- the description
-
getPartialDescription
Return the human readable description of this DataSource- Specified by:
getPartialDescriptionin 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:
getFullDescriptionin 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:
expandIfNeededin 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:
setAliasin interfaceDataSource- Parameters:
value- The new value for Alias
-
getAlias
Get the Alias property.- Specified by:
getAliasin 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:
getActionsin interfaceDataSource- Returns:
- list of actions
-
showPropertiesDialog
public boolean showPropertiesDialog()Show the properties dialog- Specified by:
showPropertiesDialogin 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:
canSaveDataToLocalDiskin 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:
saveDataToLocalDiskin 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:
canDoGeoSelectionin 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:
getDataSelectionComponentsin 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:
setDataIsEditablein interfaceDataSource- Parameters:
value- The new value for DataIsEditable
-
getDataIsEditable
public boolean getDataIsEditable()Get the DataIsEditable property.- Specified by:
getDataIsEditablein 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:
getDataPathsin 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:
updateStatein 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:
resetTmpStatein interfaceDataSource
-
setTmpPaths
Set the TmpPaths property.- Specified by:
setTmpPathsin interfaceDataSource- Parameters:
value- The new value for TmpPaths
-
getTmpPaths
Get the TmpPaths property.- Specified by:
getTmpPathsin 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:
setDefaultSavein interfaceDataSource- Parameters:
defaultsave- the new default save
-
getDefaultSave
public boolean getDefaultSave()Gets the default save.- Returns:
- the default save
-