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 Details

    • PARAM_SHOW_YES

      public static int PARAM_SHOW_YES
      flag for showing a parameter
    • PARAM_SHOW_HIDE

      public static int PARAM_SHOW_HIDE
      flag for hiding a parameter
    • PARAM_SHOW_NO

      public static int PARAM_SHOW_NO
      flag for hiding a parameter
    • dataCacheKey

      protected Object dataCacheKey
      Use this so this object is unique in the data cache
    • dataChoices

      protected List<DataChoice> dataChoices
      List of associated DataChoices
    • changeDataPathsCbx

      protected JCheckBox changeDataPathsCbx
      change data paths checkbox
    • geoSelectionPanel

      protected GeoSelectionPanel geoSelectionPanel
      geoselection panel
    • haveBeenUnPersisted

      protected boolean haveBeenUnPersisted
      Has this data source been created from a bundle
    • okToContinue

      protected boolean okToContinue
      flag for continuation
  • Constructor Details

    • DataSourceImpl

      public DataSourceImpl()
      Bean constructor
    • DataSourceImpl

      public DataSourceImpl(DataSourceDescriptor descriptor)
      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 DataSource
      name - the name for this
      description - the description
      properties - extra properties
  • Method Details

    • reloadData

      public void reloadData(Object object, Hashtable properties)
      Reload data
      Specified by:
      reloadData in interface DataSource
      Parameters:
      object - the object
      properties - the properties
    • reloadProperties

      public void reloadProperties(Hashtable newProperties)
      Reload properties
      Parameters:
      newProperties - new properties
    • convertSourceFile

      public String convertSourceFile(String source) throws Exception
      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 interface DataSource
      Returns:
      true
    • getIdv

      public IntegratedDataViewer 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

      protected void loadFieldMask(String maskFile)
      Load the field mask
      Parameters:
      maskFile - the field mask
    • applyFieldMask

      protected void applyFieldMask(Element root)
      Load any parameter nodes in the given mask xml
      Parameters:
      root - xml root
    • canAddCurrentName

      public boolean canAddCurrentName(DataChoice dataChoice)
      Can we add the data choice name to the global list of parameter names (used in the station model editor)
      Specified by:
      canAddCurrentName in interface DataSource
      Parameters:
      dataChoice - the data choice
      Returns:
      can add to global name list
    • writeFieldMaskFile

      public void writeFieldMaskFile()
      Write a mask file
    • writeFieldMaskFile

      protected void writeFieldMaskFile(Document doc, Element root)
      Write the field mask file. Subclasses should implement
      Parameters:
      doc - document to write to
      root - root element
    • canShowParameter

      public int canShowParameter(String name)
      Should we show the given parameter name
      Parameters:
      name - parameter name
      Returns:
      should show the parameter as a data choice
    • setObjectProperties

      public void setObjectProperties(Hashtable properties)
      Description copied from interface: DataSource
      set the properties
      Specified by:
      setObjectProperties in interface DataSource
      Parameters:
      properties - Specification of the name=value properties.
    • setObjectProperty

      public void setObjectProperty(String name, String value)
      Set the property on this object. Use reflection to find the appropriate set method
      Parameters:
      name - property name
      value - value
    • getCompositeDataChoices

      public List getCompositeDataChoices(CompositeDataChoice compositeDataChoice, List dataChoices)
      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 interface DataSource
      Parameters:
      compositeDataChoice - The composite
      dataChoices - 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 interface DataSource
    • initAfterCreation

      public void initAfterCreation()
      Gets called after creation. Initialize the polling.
      Specified by:
      initAfterCreation in interface DataSource
    • setNewFiles

      public void setNewFiles(List files)
      Used for when we dynamically change the data source files form a bundle or from image generation
      Specified by:
      setNewFiles in interface DataSource
      Parameters:
      files - List of new files to use
    • createElement

      public Element createElement(XmlEncoder encoder)
      Create the XML element for persisting this DataSource
      Specified by:
      createElement in interface XmlPersistable
      Parameters:
      encoder - encoder to use
      Returns:
      this as XML
    • initFromXml

      public boolean initFromXml(XmlEncoder encoder, Element element)
      Initialize this from XML
      Specified by:
      initFromXml in interface XmlPersistable
      Parameters:
      encoder - encoder for XML
      element - the XML representation
      Returns:
      true
    • getProperties

      public Hashtable getProperties()
      Get the associated properties
      Returns:
      the properties
    • setProperties

      public void setProperties(Hashtable p)
      Get the associated properties
      Parameters:
      p - the new properties
    • removeProperty

      public void removeProperty(String name)
      Remove the property
      Parameters:
      name - property name to remove
    • getProperty

      public Object getProperty(String name)
      Get a property.
      Specified by:
      getProperty in interface DataSource
      Parameters:
      name - name of property
      Returns:
      the associated property value or null
    • setProperty

      public void setProperty(String prop, Object value)
      Set a string property.
      Parameters:
      prop - property name
      value - property value
    • getProperty

      public String getProperty(String name, String dflt)
      Get the named String property.
      Parameters:
      name - name of property
      dflt - default value
      Returns:
      the value of the property or the default
    • getProperty

      public long getProperty(String name, long dflt)
      Get the named long property
      Parameters:
      name - name of property
      dflt - default value
      Returns:
      the value of the property or the default
    • getProperty

      public int getProperty(String name, int dflt)
      Get the named int property
      Parameters:
      name - name of property
      dflt - default value
      Returns:
      the value of the property or the default
    • getProperty

      public double getProperty(String name, double dflt)
      Get the named double property
      Parameters:
      name - name of property
      dflt - default value
      Returns:
      the value of the property or the default
    • getProperty

      public Object getProperty(String name, Object dflt)
      Get the object property
      Parameters:
      name - name of property
      dflt - default value
      Returns:
      the value of the property or the default
    • getProperty

      public boolean getProperty(String name, boolean dflt)
      Get the named boolean property
      Parameters:
      name - name of property
      dflt - default value
      Returns:
      the value of the property or the default
    • setProperty

      public void setProperty(String prop, boolean value)
      Set a boolean property.
      Parameters:
      prop - name of property
      value - 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 interface DataSource
      Returns:
      Should show error
    • getInError

      public boolean getInError()
      Return whether this DataSource is in error
      Specified by:
      getInError in interface DataSource
      Returns:
      true if in error
    • setInError

      public void setInError(boolean e, String msg)
      Set whether this DataSource is in error
      Parameters:
      e - true for error
      msg - error message
    • setInError

      public void setInError(boolean inError, boolean needToShowErrorToUser, String msg)
      Set the inError
      Parameters:
      inError - Is in error
      needToShowErrorToUser - SHould show to user
      msg - Any message
    • setInError

      public void setInError(boolean e)
      Set whether this DataSource is in error
      Specified by:
      setInError in interface DataSource
      Parameters:
      e - true for error
    • getErrorMessage

      public String getErrorMessage()
      Get the error message (if there is one) or create one.
      Specified by:
      getErrorMessage in interface DataSource
      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 interface DataSource
    • flushCache

      protected void flushCache()
      Flush the data cache for this DataSource
    • putCache

      public void putCache(Object key, Object value)
      Put an object in the cache if caching is enabled.
      Parameters:
      key - cache key
      value - associated key value
    • putCache

      public void putCache(Object key, Object value, boolean force)
      Put an object in the cache.
      Parameters:
      key - cache key
      value - associated key value
      force - force a cache
    • getCache

      public Object getCache(Object key)
      Get an Object from the cache.
      Parameters:
      key - key for the object
      Returns:
      the key value, or null
    • getCache

      public Object getCache(Object key, boolean force)
      Get an Object from the cache.
      Parameters:
      key - key for the object
      force - force a lookup even if not caching
      Returns:
      the key value, or null
    • removeCache

      public void removeCache(Object key)
      Remove an Object from the cache.
      Parameters:
      key - key for the object
    • shouldCache

      protected boolean shouldCache(DataChoice dataChoice, Data data)
      See if this DataSource should cache or not
      Parameters:
      dataChoice - The data choice we got this data from
      data - Data to cache
      Returns:
      true
    • shouldCache

      protected boolean shouldCache(Data data)
      See if this DataSource should cache or not
      Parameters:
      data - Data to cache
      Returns:
      true
    • doRemove

      public void doRemove()
      Gets called by the DataManager when this DataSource has been removed.
      Specified by:
      doRemove in interface DataSource
    • loadLatestFile

      protected File loadLatestFile(File file)
      Load the latest file.
      Parameters:
      file - file to load
      Returns:
      name of file loaded.
    • doDirectory

      protected File doDirectory(File file)
      Get the most recent file in a direcdtory
      Parameters:
      file - directory
      Returns:
      the most recent file in the directory deprecated Use loadLatestFile
    • newFilesFromPolling

      public void newFilesFromPolling(List files)
      This gets called by the FilePoller ActionListener to notify DataSource-s of a change to the file system.
      Parameters:
      files - List of files
    • newFileFromPolling

      public void newFileFromPolling(File f)
      This gets called by the FilePoller ActionListener to notify DataSource-s of a change to the file system.
      Parameters:
      f - new file
    • toString

      public String toString()
      Return a String representation of this DataSource
      Overrides:
      toString in class Object
      Returns:
      string represenation
    • toStringTruncated

      public String toStringTruncated()
      Return a truncated string for the name if too long
      Returns:
      toString truncated to 30 chars
    • getid

      public String getid()
      Get a unique id for this DataSource
      Returns:
      a unique id
    • setDescriptor

      public void setDescriptor(DataSourceDescriptor d)
      Set the DataSourceDescriptor for this DataSource.
      Parameters:
      d - new descriptor
    • getDescriptor

      public DataSourceDescriptor getDescriptor()
      Get the DataSourceDescriptor for this DataSource.
      Returns:
      the descriptor
    • getDataChangeListeners

      protected List getDataChangeListeners()
      Get the data change listeners
      Returns:
      Data change listeners
    • addDataChangeListener

      public void addDataChangeListener(DataChangeListener listener)
      Add the data change listener
      Specified by:
      addDataChangeListener in interface DataSource
      Parameters:
      listener - listener to add
    • removeDataChangeListener

      public void removeDataChangeListener(DataChangeListener listener)
      Remove the data change listener
      Specified by:
      removeDataChangeListener in interface DataSource
      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 interface DataSource
    • clearFileCache

      protected void clearFileCache()
      Clear the cache
    • notifyDataChange

      public void notifyDataChange()
      Notify all DataChangeListeners of some change to the data
      Specified by:
      notifyDataChange in interface DataSource
    • getDataContext

      public DataContext getDataContext()
      Get the DataContext for this DataSource.
      Returns:
      the DataContext or null.
    • getDataSource

      public DataSource getDataSource()
      This is the method defined for the DataSourceFactory interface. Just return ourself.
      Specified by:
      getDataSource in interface DataSourceFactory
      Returns:
      this
    • equals

      public boolean equals(Object o)
      See if the Object in question is equal to this DataSource.
      Overrides:
      equals in class Object
      Parameters:
      o - Object in question
      Returns:
      true if they are equal
    • identifiedByName

      public boolean identifiedByName(String name)
      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 interface DataSource
      Parameters:
      name - the name.
      Returns:
      true if it is
    • identifiedBy

      public boolean identifiedBy(Object definingObject)
      See if this DataSource is identified by the definingObject.
      Specified by:
      identifiedBy in interface DataSource
      Parameters:
      definingObject - definingObject to check
      Returns:
      true if this is defined by definingObject
    • getTypeName

      public final String getTypeName()
      Get the type name for this DataSource
      Specified by:
      getTypeName in interface DataSource
      Returns:
      the type name or null
    • createAutoDisplay

      public void createAutoDisplay(String displayType, DataContext dataContext)
      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 interface DataSource
      Parameters:
      displayType - The display control type id.
      dataContext - Really, the IDV
    • initDataChoice

      public void initDataChoice(DataChoice dataChoice)
      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

      public DataChoice findDataChoice(Object id)
      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 interface DataSource
      Parameters:
      id - id of DataChoice
      Returns:
      the DataChoice which has id or null
    • findDataChoices

      public List findDataChoices(Object id)
      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 interface DataSource
      Parameters:
      id - id of DataChoice
      Returns:
      the DataChoice which has id or null
    • checkForInitAfterUnPersistence

      protected void checkForInitAfterUnPersistence()
      some method to initialize
    • makeDerivedDataChoices

      protected void makeDerivedDataChoices(List dataChoices)
      Add to the given list the set of derived data choices
      Parameters:
      dataChoices - base list of choices
    • getDataChoices

      public List 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 interface DataSource
      Returns:
      List of DataChoices
    • getAllLevels

      public List getAllLevels(DataChoice dataChoice)
      Get the list of all levels available from this DataSource
      Specified by:
      getAllLevels in interface DataSource
      Parameters:
      dataChoice - The data choice to get levels for
      Returns:
      List of all available levels
    • getAllLevels

      public List getAllLevels(DataChoice dataChoice, DataSelection dataSelection)
      Get all of the levels
      Specified by:
      getAllLevels in interface DataSource
      Parameters:
      dataChoice - The data choice to get levels for
      dataSelection - data selection
      Returns:
      list of levels.
    • clearTimes

      public void clearTimes()
      Clear the times list
    • getAllDateTimes

      public 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 interface DataSource
      Returns:
      array of DateTimes (may be null)
    • getSelectedDateTimes

      public List getSelectedDateTimes()
      Get the list of selected times.
      Specified by:
      getSelectedDateTimes in interface DataSource
      Returns:
      list of selected times
    • getSelectedDateTimes

      public List getSelectedDateTimes(DataChoice dataChoice)
      Get the selected times for the given DataChoice.
      Specified by:
      getSelectedDateTimes in interface DataSource
      Parameters:
      dataChoice - DataChoice in question
      Returns:
      List of selected times
    • getAllDateTimes

      public List getAllDateTimes(DataChoice dataChoice)
      Get all the times for the given DataChoice
      Specified by:
      getAllDateTimes in interface DataSource
      Parameters:
      dataChoice - DataChoice in question
      Returns:
      List of all times for that choice
    • getDataSelection

      public DataSelection 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 interface DataSource
      Returns:
      the DataSelection for this DataSource
    • setDataSelection

      public void setDataSelection(DataSelection s)
      Set the DataSelection for this DataSource.
      Parameters:
      s - new selection
    • holdsDateTimes

      public static boolean holdsDateTimes(List selectedTimes)
      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

      public static boolean holdsIndices(List selectedTimes)
      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

      public static List getDateTimes(List selected, List allTimes)
      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

      public List getAbsoluteDateTimes(List selected)
      Get the absolute times.
      Parameters:
      selected - list of selected times
      Returns:
      List of absolute times
    • setDateTimeSelection

      public void setDateTimeSelection(List selectedTimes)
      Set the list of selected times for this data source. This is used for XML persistence.
      Specified by:
      setDateTimeSelection in interface DataSource
      Parameters:
      selectedTimes - List of selected times
    • getDateTimeSelection

      public List getDateTimeSelection()
      Return the list of times held by the DataSelection member.
      Specified by:
      getDateTimeSelection in interface DataSource
      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 objects
      selectionTimes - The selection times
      Returns:
      List of times from sourceTimes that correspond to the selectionTimes
      Throws:
      Exception - On badness
    • getTimesFromDataSelection

      protected List getTimesFromDataSelection(DataSelection givenDataSelection, DataChoice dataChoice)
      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 DataSelection
      dataChoice - 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 choice
      selection - 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 interface DataSource
      Parameters:
      dataChoice - choice that defines the data
      dataCategory - the data category
      requestProperties - extra request properties
      Returns:
      the associated data
      Throws:
      RemoteException - Java RMI problem
      VisADException - 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 choice
      dataSelection - data selection
      requestProperties - 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 interface DataSource
      Parameters:
      dataChoice - choice that defines the data
      category - the data category
      incomingDataSelection - DataSelection for subsetting
      requestProperties - extra request properties
      Returns:
      the associated data
      Throws:
      RemoteException - Java RMI problem
      VisADException - 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 problem
      VisADException - 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 problem
      VisADException - VisAD problem
    • getNextId

      public int getNextId()
      A unique identifier for DataSource objects.
      Returns:
      the next unique id
    • setName

      public void setName(String n)
      Set the name of this DataSource
      Parameters:
      n - new name
    • setTemplateName

      public void setTemplateName(String n)
      Keep around for legacy bundles
      Parameters:
      n - template name
    • getName

      public String getName()
      Returns the human readable name of this DataSource. This is the second argument of DataSourceImpl(DataSourceDescriptor, String, String, Hashtable).
      Specified by:
      getName in interface DataSource
      Returns:
      The human-readable specification of this data-source.
    • setDescription

      public void setDescription(String n)
      Set the description for this DataSource
      Parameters:
      n - the description
    • getDescription

      public String getDescription()
      Return the human readable description of this DataSource
      Specified by:
      getDescription in interface DataSource
      Returns:
      the description
    • getPartialDescription

      public String getPartialDescription()
      Return the human readable description of this DataSource
      Specified by:
      getPartialDescription in interface DataSource
      Returns:
      the description
    • getFullDescription

      public String 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 interface DataSource
      Returns:
      the full description of this data source (description + name)
    • addDataChoice

      protected void addDataChoice(DataChoice choice)
      Insert the new DataChoice into the dataChoice list.
      Parameters:
      choice - new choice to add
    • expandIfNeeded

      public void expandIfNeeded(CompositeDataChoice cdc)
      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 interface DataSource
      Parameters:
      cdc - the data choice
    • removeDataChoice

      protected void removeDataChoice(DataChoice choice)
      Remove the choice
      Parameters:
      choice - the choice
    • replaceDataChoice

      public void replaceDataChoice(DataChoice oldDataChoice, DataChoice newDataChoice)
      Replace the given child with the given chold
      Parameters:
      oldDataChoice - The old data choice
      newDataChoice - 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

      protected List 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

      public void logException(String msg, Exception exc)
      Shortcut to logging facility for subclasses to use
      Parameters:
      msg - error message
      exc - error Exception
    • logException

      public void logException(String msg, Exception exc, byte[] fileBytes)
      Log the exception with the file bytes
      Parameters:
      msg - message
      exc - exception
      fileBytes - bytes to write to a tmp file. May be null.
    • setAlias

      public void setAlias(String value)
      Set the Alias property.
      Specified by:
      setAlias in interface DataSource
      Parameters:
      value - The new value for Alias
    • getAlias

      public String getAlias()
      Get the Alias property.
      Specified by:
      getAlias in interface DataSource
      Returns:
      The Alias
    • getActions

      public List getActions()
      Get any Action-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 interface DataSource
      Returns:
      list of actions
    • showPropertiesDialog

      public boolean showPropertiesDialog()
      Show the properties dialog
      Specified by:
      showPropertiesDialog in interface DataSource
      Returns:
      Was ok pressed
    • showPropertiesDialog

      public boolean showPropertiesDialog(String initTabName)
      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 interface DataSource
      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 it
      loadId - For stopping the load through the JobManager
      changeLinks - Should this data source also change its internal data references
      Returns:
      List of the files that were written
      Throws:
      Exception - On badness
    • saveDataToLocalDisk

      public List saveDataToLocalDisk()
      Save dat to local disk
      Returns:
      list of files?
    • saveDataToLocalDisk

      public List saveDataToLocalDisk(boolean changeLinks, String uniqueFilePath)
      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 interface DataSource
      Parameters:
      changeLinks - Should this data source also change its internal data references
      uniqueFilePath - Where to write the files to
      Returns:
      List of the files that were written
    • getSaveDataFileLabel

      protected String getSaveDataFileLabel()
      Get the save data to a file label
      Returns:
      the save data to a file label
    • beginWritingDataToLocalDisk

      protected Object beginWritingDataToLocalDisk(String msg)
      Start the JobManager load dialog
      Parameters:
      msg - Message to show in dialog
      Returns:
      The JobManager load id
    • endWritingDataToLocalDisk

      protected void endWritingDataToLocalDisk(Object loadId)
      Stop the JobManager load dialog
      Parameters:
      loadId - The JobManager load id
    • getDataPrefix

      protected String getDataPrefix()
      Get the file prefix to use for when saving data to local disk
      Returns:
      File prefix to use
    • getLocalDirectory

      protected String getLocalDirectory(String label, String prefix)
      Get the directory to write the localized data files to
      Parameters:
      label - Label to show user
      prefix - File prefix
      Returns:
      Path with the file prefix that the user specified appended
    • showPropertiesDialog

      public boolean showPropertiesDialog(String initTabName, boolean modal)
      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

      public void handlePropertiesAction(String cmd)
      Handle the properties action
      Parameters:
      cmd - Action
    • getPropertiesHeader

      protected JComponent getPropertiesHeader(String label)
      Utility to create a header for the properties dialog
      Parameters:
      label - Header label
      Returns:
      Header
    • getPropertiesComponents

      public void getPropertiesComponents(List comps)
      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 interface DataSource
      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

      public List<DataSelectionComponent> getDataSelectionComponents(DataChoice dataChoice)
      A hook to allow this data source to add data selection components to the IDV field selector
      Specified by:
      getDataSelectionComponents in interface DataSource
      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 components
      dataChoice - the data choice
    • getExtraTimesComponent

      protected JComponent getExtraTimesComponent()
      This gets pu at the bottom of the times properties tab
      Returns:
      extra comp
    • addPropertiesTabs

      public void addPropertiesTabs(JTabbedPane tabbedPane)
      Add any extra tabs into the properties tab
      Parameters:
      tabbedPane - The properties tab
    • addReloadTab

      protected void addReloadTab(JTabbedPane tabbedPane)
      Add a reload tab
      Parameters:
      tabbedPane - the reload tab
    • doMakeGeoSubsetPropertiesComponent

      protected JComponent doMakeGeoSubsetPropertiesComponent()
      Make the geo subset properties component
      Returns:
      the component
    • updateDetailsText

      protected void updateDetailsText()
      Update the properties dialog details page
    • doMakeGeoSelectionPanel

      public GeoSelectionPanel doMakeGeoSelectionPanel()
      Make the subset component
      Returns:
      The subset properties component
    • doMakeGeoSelectionPanel

      public GeoSelectionPanel doMakeGeoSelectionPanel(boolean forProperties)
      Make the geoselection panel
      Parameters:
      forProperties - true if for the properties widget
      Returns:
      the panel
    • doMakeGeoSelectionPanel

      public GeoSelectionPanel doMakeGeoSelectionPanel(boolean forProperties, GeoSelection geoSelection)
      Make the geoselection panel
      Parameters:
      forProperties - true if for the properties widget
      geoSelection - geoselection to populate the panel
      Returns:
      the panel
    • getExtraGeoSelectionComponent

      protected JComponent 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

      protected void addActions(List actions)
      Get any Action-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

      protected void makeSaveLocalActions(List actions)
      Make save local actions
      Parameters:
      actions - list of actions
    • getFileFilterForPolling

      protected FileFilter getFileFilterForPolling()
      Return the file fitler that the polling info uses.
      Returns:
      Polling file filter
    • getLocationForPolling

      protected File getLocationForPolling()
      Get the location, either a file or a directory, that is where we poll on.
      Returns:
      File or dir to poll.
    • getLocationsForPolling

      protected List 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

      public void setPollingInfo(PollingInfo value)
      Set the PollingInfo property.
      Parameters:
      value - The new value for PollingInfo
    • getPollingInfo

      public 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

      public void setDirectory(String n)
      noop. Keep around for legacy bundles.
      Parameters:
      n - directory name deprecated
    • setPollLocation

      public void setPollLocation(String value)
      noop. Keep around for legacy bundles.
      Parameters:
      value - The new value for PollLocation deprecated
    • convertToFilesIfDirectory

      protected 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. 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

      protected List getMostRecentFiles(File dir, int cnt)
      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 interface DataSource
      Parameters:
      value - The new value for DataIsEditable
    • getDataIsEditable

      public boolean getDataIsEditable()
      Get the DataIsEditable property.
      Specified by:
      getDataIsEditable in interface DataSource
      Returns:
      The DataIsEditable
    • getDataPaths

      public List 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 interface DataSource
      Returns:
      file paths to changed
    • setDataEditableStrings

      public void setDataEditableStrings(List strings)
      Set the changed file or url paths
      Parameters:
      strings - List of paths
    • setDataRelativeStrings

      public void setDataRelativeStrings(List strings)
      Used when loading from a bundle with relative file paths
      Parameters:
      strings - Relative file paths
    • getPathsThatCanBeRelative

      public List 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

      public void setRelativePaths(List value)
      Set the RelativePaths property.
      Parameters:
      value - The new value for RelativePaths
    • getRelativePaths

      public List getRelativePaths()
      Get the RelativePaths property.
      Returns:
      The RelativePaths
    • updateState

      public void updateState(Object newObject, Hashtable newProperties)
      Update the state
      Specified by:
      updateState in interface DataSource
      Parameters:
      newObject - new object
      newProperties - 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 interface DataSource
    • setTmpPaths

      public void setTmpPaths(List value)
      Set the TmpPaths property.
      Specified by:
      setTmpPaths in interface DataSource
      Parameters:
      value - The new value for TmpPaths
    • getTmpPaths

      public List getTmpPaths()
      Get the TmpPaths property.
      Specified by:
      getTmpPaths in interface DataSource
      Returns:
      The TmpPaths
    • getNameForDataSource

      public static String getNameForDataSource(DataSource ds, int length, boolean alwaysDoIt)
      A helper method to find the label to use for the given DataSource. 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 for
      length - String length to clip to
      alwaysDoIt - 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

      public String 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

      public boolean showPasswordDialog(String title, String label)
      Show the password dialog
      Parameters:
      title - title
      label - label
      Returns:
      true if successful
    • setUserName

      public void setUserName(String value)
      Set the UserName property.
      Parameters:
      value - The new value for UserName
    • getUserName

      public String getUserName()
      Get the UserName property.
      Returns:
      The UserName
    • setPassword

      public void setPassword(String value)
      Set the Password property.
      Parameters:
      value - The new value for Password
    • getPassword

      public String 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 interface DataSource
      Parameters:
      defaultsave - the new default save
    • getDefaultSave

      public boolean getDefaultSave()
      Gets the default save.
      Returns:
      the default save