Class LocationDatumDataSource

java.lang.Object
net.solarnetwork.node.service.support.LocationDatumDataSource
All Implemented Interfaces:
DatumDataSource, DeviceInfoProvider, MultiDatumDataSource, net.solarnetwork.service.Identifiable, net.solarnetwork.settings.SettingSpecifierProvider

public class LocationDatumDataSource extends Object implements DatumDataSource, MultiDatumDataSource, net.solarnetwork.settings.SettingSpecifierProvider
DatumDataSource that augments some other data source's datum values with location IDs.

This is to be used to easily augment various datum that relate to a location with the necessary DatumLocation.getLocationId() ID. This class also implements the MultiDatumDataSource API, and will call the methods of that API on the configured delegate if that also implements MultiDatumDataSource. If the delegate does not implement MultiDatumDataSource this class will "fake" that API by calling DatumDataSource.readCurrentDatum() and returning that object in a Collection.

Since:
2.0
Version:
1.0
Author:
matt
  • Field Details

    • DEFAULT_LOCATION_ID_PROP_NAME

      public static final String DEFAULT_LOCATION_ID_PROP_NAME
      Default value for the locationIdPropertyName property.
      See Also:
    • DEFAULT_SOURCE_ID_PROP_NAME

      public static final String DEFAULT_SOURCE_ID_PROP_NAME
      Default value for the sourceIdPropertyName property.
      See Also:
    • PRICE_LOCATION_MESSAGE_BUNDLE

      public static final String PRICE_LOCATION_MESSAGE_BUNDLE
      Bundle name for price location lookup messages.
      See Also:
  • Constructor Details

    • LocationDatumDataSource

      public LocationDatumDataSource()
  • Method Details

    • getDatumType

      public Class<? extends NodeDatum> getDatumType()
      Description copied from interface: DatumDataSource
      Get the class supported by this DataSource.
      Specified by:
      getDatumType in interface DatumDataSource
      Returns:
      class
    • getMultiDatumType

      public Class<? extends NodeDatum> getMultiDatumType()
      Description copied from interface: MultiDatumDataSource
      Get the class supported by this DataSource.
      Specified by:
      getMultiDatumType in interface MultiDatumDataSource
      Returns:
      class
    • readMultipleDatum

      public Collection<NodeDatum> readMultipleDatum()
      Description copied from interface: MultiDatumDataSource
      Read multiple values from the data source, returning as a collection of unpersisted NodeDatum objects.
      Specified by:
      readMultipleDatum in interface MultiDatumDataSource
      Returns:
      Datum
    • readCurrentDatum

      public NodeDatum readCurrentDatum()
      Description copied from interface: DatumDataSource
      Read the current value from the data source, returning as an unpersisted NodeDatum object.
      Specified by:
      readCurrentDatum in interface DatumDataSource
      Returns:
      Datum
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getUid

      public String getUid()
      Specified by:
      getUid in interface net.solarnetwork.service.Identifiable
    • getGroupUid

      public String getGroupUid()
      Specified by:
      getGroupUid in interface net.solarnetwork.service.Identifiable
    • getSettingUid

      public String getSettingUid()
      Specified by:
      getSettingUid in interface net.solarnetwork.settings.SettingSpecifierProvider
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface net.solarnetwork.service.Identifiable
      Specified by:
      getDisplayName in interface net.solarnetwork.settings.SettingSpecifierProvider
    • getMessageSource

      public org.springframework.context.MessageSource getMessageSource()
      Specified by:
      getMessageSource in interface net.solarnetwork.settings.SettingSpecifierProvider
    • setMessageSource

      public void setMessageSource(org.springframework.context.MessageSource messageSource)
      Set the message source.
      Parameters:
      messageSource - the message source to set
    • getSettingSpecifiers

      public List<net.solarnetwork.settings.SettingSpecifier> getSettingSpecifiers()
      Specified by:
      getSettingSpecifiers in interface net.solarnetwork.settings.SettingSpecifierProvider
    • getDelegate

      public DatumDataSource getDelegate()
      Get the delegate.
      Returns:
      the delegate
    • setDelegate

      public void setDelegate(DatumDataSource delegate)
      Set the delegate.
      Parameters:
      delegate - the delegate to set
    • getLocationService

      public net.solarnetwork.service.OptionalService<LocationService> getLocationService()
      Get the LocationService to use to lookup DatumLocation instances via the configured locationId property.
      Returns:
      the location service
    • setLocationService

      public void setLocationService(net.solarnetwork.service.OptionalService<LocationService> locationService)
      Set the LocationService to use to lookup DatumLocation instances via the configured locationId property.
      Parameters:
      locationService - the service to use
    • getLocationIdPropertyName

      public String getLocationIdPropertyName()
      Get the JavaBean property name to set the found DatumLocation.getLocationId() to on the NodeDatum returned from the configured delegate.
      Returns:
      the location ID property name; defaults to DEFAULT_LOCATION_ID_PROP_NAME
    • setLocationIdPropertyName

      public void setLocationIdPropertyName(String locationIdPropertyName)
      Set the JavaBean property name to set the found DatumLocation.getLocationId() to on the NodeDatum returned from the configured delegate.

      The object must support a JavaBean setter method for this property.

      Parameters:
      locationIdPropertyName - the property name to use
    • isRequireLocationService

      public boolean isRequireLocationService()
      Get the "location service required" flag.
      Returns:
      the location service reqiured flag; defaults to false
    • setRequireLocationService

      public void setRequireLocationService(boolean requireLocationService)
      Get the "location service required" flag.

      If configured as true then return null data only instead of calling the delegate. This is designed for services that require a location ID to be set, for example a Location Datum logger.

      Parameters:
      requireLocationService - the required setting to use
    • getLocationType

      public String getLocationType()
      Get the type of location to search for.
      Returns:
      the type; defaults to PriceLocation
    • setLocationType

      public void setLocationType(String locationType)
      Set the type of location to search for.
      Parameters:
      locationType - the location type
    • getMessageBundleBasename

      public String getMessageBundleBasename()
      Get the message bundle basename to use.
      Returns:
      the basename; defaults to PRICE_LOCATION_MESSAGE_BUNDLE
    • setMessageBundleBasename

      public void setMessageBundleBasename(String messageBundleBaseName)
      Set the message bundle basename to use.

      This can be customized so different messages can be shown for different uses of this proxy.

      Parameters:
      messageBundleBaseName - the basename to use
    • getLocationKey

      public String getLocationKey()
      Get the location ID and source ID as a single string value. The format of the key is locationId:sourceId.
      Returns:
      the location key, or null if both the location ID and source ID values are null
    • setLocationKey

      public void setLocationKey(String key)
      Set the location ID and source ID as a single string value. The format of the key is locationId:sourceId.
      Parameters:
      key - the location and source ID key
    • getLocationId

      public Long getLocationId()
      Get the DatumLocation ID to assign to datum.
      Returns:
      the location ID
    • setLocationId

      public void setLocationId(Long locationId)
      Set the DatumLocation ID to assign to datum.
      Parameters:
      locationId - the location ID
    • getLocation

      public DatumLocation getLocation()
      Get the location.
      Returns:
      the location
    • getDatumClassNameIgnore

      public Set<String> getDatumClassNameIgnore()
      Get the datum class names to ignore.
      Returns:
      the ignore set
    • setDatumClassNameIgnore

      public void setDatumClassNameIgnore(Set<String> datumClassNameIgnore)
      Set the datum class names to ignore.
      Parameters:
      datumClassNameIgnore - the ignore set
    • getSourceId

      public String getSourceId()
      Get the source ID.
      Returns:
      the source ID
    • setSourceId

      public void setSourceId(String sourceId)
      Set the source ID.
      Parameters:
      sourceId - the source ID to use
    • getSourceIdPropertyName

      public String getSourceIdPropertyName()
      Get the JavaBean property name to set the found DatumLocation.getSourceId() to on the NodeDatum returned from the configured delegate.
      Returns:
      the source ID property name; defaults to DEFAULT_SOURCE_ID_PROP_NAME
    • setSourceIdPropertyName

      public void setSourceIdPropertyName(String sourceIdPropertyName)
      Set the JavaBean property name to set the found DatumLocation.getSourceId() to on the NodeDatum returned from the configured delegate.

      The object must support a JavaBean setter method for this property.

      Parameters:
      sourceIdPropertyName - the source ID property name to use