Class StreamThing

All Implemented Interfaces:
ISupportsAccessModifier, IConfigurableObject, INotScriptFriendly, ISupportsDeprecation, IDiffableObject, IAlertProvider, IAvatar, IEntityLifeCycleEvent, IEventMetadataProvider, IEventProvider, IPersistable, IPropertyProvider, IServiceMetadataProvider, IServiceProvider, IShapeProvider, ITaggableObject, IDependencyScannableObject, IImportDependencyHandler, IData, IDynamicServiceShape, IHierarchicalEntity, IEntityDefinition, IPersistableObject<String>, IDesignTimeSecurable, IDesignTimeSecurableEntity, IRunTimeSecurable, IRunTimeSecurableEntity, ISecurable, IVisibilitySecurable, IVisibilitySecurableEntity, IStream, IEventProcessor, IAspectContainer, IFeed, INamedObject, Serializable

See Also:
  • Field Details

    • _logger

      protected static org.slf4j.Logger _logger
    • PURGE_BLOCK_SIZE

      public static final int PURGE_BLOCK_SIZE
      See Also:
  • Constructor Details

  • Method Details

    • getEntryIterator

      @ThingworxExtensionApiMethod(since={7,0,1}) public IDataEntryCloseableIterator<StreamEntry> getEntryIterator(Timespan timespan) throws Exception


      Returns an iterator over all entries inside this stream thing added over the provided timespan. If the timespan's start and end dates are both null, all entries will be iterated. The iterator must be closed when no longer used.
      Parameters:
      timespan - the timespan of interest
      Returns:
      a closeable iterator
      Throws:
      Exception - if an exception occurred creating the iterator
    • validateConfiguration

      @ThingworxExtensionApiMethod(since={6,6}, canOverride=true, requiresSuper=true) public void validateConfiguration(ImportedEntityCollection importedEntityCollections) throws Exception
      Description copied from class: Thing


      Validates the configuration of the thing during the import process. This method is called whenever a thing is created or modified via the REST APIs. During the validation step, there may be other associated entities (including thing shapes and templates) that are being imported. These can be accessed via the importedEntities collection if needed.

      Note that some resources belonging to the thing or other associated entities may not be available during this step in the lifecycle.

      It is required for all subclasses of Thing to call super.validateConfiguration(importedEntities) if they override this method.

      Overrides:
      validateConfiguration in class Thing
      Parameters:
      importedEntityCollections - - a typed collection of entities currently being imported
      Throws:
      Exception - If an error occurs
    • initializeThing

      @ThingworxExtensionApiMethod(since={9,0}, canOverride=true, requiresSuper=true) public void initializeThing(ContextType contextType) throws Exception
      Description copied from class: Thing


      An initialization hook for subclasses of Thing. Some resources of Thing may not be available at this point in the lifecycle.

      Overrides:
      initializeThing in class Thing
      Throws:
      Exception - If an error occurs
    • dispose

      @ThingworxExtensionApiMethod(since={6,6}, canOverride=true, requiresSuper=true) public void dispose() throws Exception
      Description copied from class: RootEntity


      Removes any remaining references of this entity and disposes any resources that were not cleaned up earlier in the lifecycle. This method is only invoked when the entity is in the process of deletion.

      Overrides:
      dispose in class Thing
      Throws:
      Exception - If an error occurs
    • getDataShapeName

      @ThingworxExtensionApiMethod(since={6,6}) public String getDataShapeName()
      Specified by:
      getDataShapeName in interface IData
    • GetDataShape

      @ThingworxExtensionApiMethod(since={6,6}) public String GetDataShape()
      Service Category:
      DataShape
      Service Description:
      Get the currently assigned data shape.
      Returns:
      result Data shape name - DATASHAPENAME
    • SetDataShape

      @ThingworxExtensionApiMethod(since={6,6}) public void SetDataShape(String name) throws Exception
      Service Category:
      DataShape
      Service Description:
      Sets the currently assigned data shape.
      Parameters:
      name - Data shape name - DATASHAPENAME
      Throws:
      Exception - If an error occurs
    • getDataShape

      Specified by:
      getDataShape in interface IData
      Specified by:
      getDataShape in interface IDynamicServiceShape
      Specified by:
      getDataShape in interface IStream
    • getAccumulatedDataShape

      @ThingworxExtensionApiMethod(since={6,6}, canOverride=true) public DataShapeDefinition getAccumulatedDataShape()
    • DeleteStreamEntry

      @ThingworxExtensionApiMethod(since={6,6}) public void DeleteStreamEntry(String streamEntryId) throws Exception
      Service Category:
      StreamEntries
      Service Description:
      Delete a specific stream entry given a stream entry ID.
      Parameters:
      streamEntryId - Stream entry ID - STRING
      Throws:
      Exception - If an error occurs
    • GetStreamEntry

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetStreamEntry(String streamEntryId) throws Exception
      Service Category:
      StreamEntries
      Service Description:
      Retrieve a specific stream entry given a stream entry ID.
      Parameters:
      streamEntryId - Stream entry ID - STRING
      Returns:
      result Stream entry - INFOTABLE - Aspects {isEntityDataShape:true, isStreamEntry:true}
      Throws:
      Exception - If an error occurs
    • GetStreamEntryCount

      @ThingworxExtensionApiMethod(since={6,6}) public Double GetStreamEntryCount() throws Exception
      Service Category:
      StreamEntries
      Service Description:
      Retrieve a count of stream entries.
      Returns:
      result Stream entry count - NUMBER
      Throws:
      Exception - If an error occurs
    • GetFieldNames

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetFieldNames() throws Exception
      Service Category:
      Fields
      Service Description:
      Retrieve a list of field names for the data shape associated with this stream.
      Returns:
      result Field names - INFOTABLE - Aspects {dataShape:EntityList}
      Throws:
      Exception - If an error occurs
    • GetFieldNamesByType

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetFieldNamesByType(String type) throws Exception
      Service Category:
      Fields
      Service Description:
      Retrieve a list of field names for the data shape associated with this stream, of a specific type.
      Parameters:
      type - Base type name - BASETYPENAME
      Returns:
      result Field names - INFOTABLE - Aspects {dataShape:EntityList}
      Throws:
      Exception - If an error occurs
    • AddStreamEntries

      @ThingworxExtensionApiMethod(since={6,6}) public void AddStreamEntries(InfoTable values) throws Exception
      Service Category:
      StreamEntries
      Service Description:
      Add multiple stream entries.
      Parameters:
      values - Stream entry values - INFOTABLE
      Throws:
      Exception - If an error occurs
    • AddStreamEntry

      @ThingworxExtensionApiMethod(since={6,6}) public void AddStreamEntry(org.joda.time.DateTime timestamp, Location location, String source, String sourceType, TagCollection tags, InfoTable values) throws Exception
      Service Category:
      StreamEntries
      Service Description:
      Add a new stream entry.
      Parameters:
      timestamp - Event time (optional) - DATETIME
      location - Location of the entry (optional) - LOCATION
      source - Source of the event - STRING
      sourceType - Source type (User,Thing) - STRING
      tags - Tags (optional) - TAGS
      values - Data values - INFOTABLE
      Throws:
      Exception - If an error occurs
    • addStreamEntry

      @ThingworxExtensionApiMethod(since={6,6}) public void addStreamEntry(org.joda.time.DateTime timestamp, Location location, String source, String sourceType, TagCollection tags, ValueCollection values) throws Exception
      Specified by:
      addStreamEntry in interface IStream
      Throws:
      Exception - If an error occurs
    • UpdateStreamEntry

      @ThingworxExtensionApiMethod(since={6,6}) public void UpdateStreamEntry(String streamEntryId, Location location, String source, TagCollection tags, InfoTable values) throws Exception
      Service Category:
      StreamEntries
      Service Description:
      Update an existing stream entry.
      Parameters:
      streamEntryId - Stream entry ID - STRING
      location - Location of the entry (optional) - LOCATION
      source - Source of the event - STRING
      tags - Tags (optional) - TAGS
      values - Data values - INFOTABLE
      Throws:
      Exception - If an error occurs
    • CreateValues

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable CreateValues() throws Exception
      Service Category:
      Values
      Service Description:
      Create an empty info table of the correct datashape for this stream.
      Returns:
      Values Created Infotable - INFOTABLE - Aspects {isEntityDataShape:true}
      Throws:
      Exception - If an error occurs
    • CreateValuesWithData

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable CreateValuesWithData(org.json.JSONObject values) throws Exception
      Service Category:
      Values
      Service Description:
      Create an info table of the correct datashape for this stream and include data values.
      Parameters:
      values - Data values (JSON Object) - JSON
      Returns:
      Values Created Infotable - INFOTABLE - Aspects {isEntityDataShape:true}
      Throws:
      Exception - If an error occurs
    • PurgeStreamEntries

      @ThingworxExtensionApiMethod(since={6,6}) public void PurgeStreamEntries(org.joda.time.DateTime startDate, org.joda.time.DateTime endDate, Boolean immediate) throws Exception
      Service Category:
      Maintenance
      Service Description:
      Purge stream entries for a specified date range.
      Parameters:
      startDate - Start time - DATETIME
      endDate - End time - DATETIME
      immediate - Delete immediately - BOOLEAN
      Throws:
      Exception - If an error occurs
    • GetStreamEntries

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetStreamEntries(Double maxItems, Boolean oldestFirst) throws Exception
      Service Category:
      Queries
      Service Description:
      Get all stream entries (without data).
      Parameters:
      maxItems - Maximum number of items to return - NUMBER
      oldestFirst - Search/sort from oldest to newest - BOOLEAN
      Returns:
      result Table entries - INFOTABLE - Aspects {isStreamEntry:true}
      Throws:
      Exception - If an error occurs
    • GetStreamEntriesWithData

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetStreamEntriesWithData(Double maxItems, Boolean oldestFirst) throws Exception
      Service Category:
      Queries
      Service Description:
      Get all stream entries (with data).
      Parameters:
      maxItems - Maximum number of items to return - NUMBER
      oldestFirst - Search/sort from oldest to newest - BOOLEAN
      Returns:
      result Table entries - INFOTABLE - Aspects {isEntityDataShape:true, isStreamEntry:true}
      Throws:
      Exception - If an error occurs
    • GetStreamData

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetStreamData(Double maxItems, Boolean oldestFirst) throws Exception
      Service Category:
      Queries
      Service Description:
      Get all stream data (no entry detail).
      Parameters:
      maxItems - Maximum number of items to return - NUMBER
      oldestFirst - Search/sort from oldest to newest - BOOLEAN
      Returns:
      result Table entries - INFOTABLE - Aspects {isEntityDataShape:true}
      Throws:
      Exception - If an error occurs
    • QueryStreamEntriesWithData

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable QueryStreamEntriesWithData(Double maxItems, String source, TagCollection tags, TagCollection sourceTags, org.joda.time.DateTime startDate, org.joda.time.DateTime endDate, Boolean oldestFirst, org.json.JSONObject query) throws Exception
      Service Category:
      Queries
      Service Description:
      Query stream entries (with data), along with filter and sort criteria.
      Parameters:
      maxItems - Maximum number of items to return - NUMBER
      source - Source of this entry (optional) - STRING
      tags - Tags - TAGS
      sourceTags - Source Tags - TAGS
      startDate - Start time - DATETIME
      endDate - End time - DATETIME
      oldestFirst - Search/sort from oldest to newest - BOOLEAN
      query - Query definition - QUERY
      Returns:
      result Table entries - INFOTABLE - Aspects {isEntityDataShape:true, isStreamEntry:true}
      Throws:
      Exception - If an error occurs
    • QueryStreamData

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable QueryStreamData(Double maxItems, String source, TagCollection tags, TagCollection sourceTags, org.joda.time.DateTime startDate, org.joda.time.DateTime endDate, Boolean oldestFirst, org.json.JSONObject query) throws Exception
      Service Category:
      Queries
      Service Description:
      Query stream data (no stream entry details), along with filter and sort criteria.
      Parameters:
      maxItems - Maximum number of items to return - NUMBER
      source - Source of this entry (optional) - STRING
      tags - Tags - TAGS
      sourceTags - Source Tags - TAGS
      startDate - Start time - DATETIME
      endDate - End time - DATETIME
      oldestFirst - Search/sort from oldest to newest - BOOLEAN
      query - Query definition - QUERY
      Returns:
      result Table entries - INFOTABLE - Aspects {isEntityDataShape:true}
      Throws:
      Exception - If an error occurs
    • QueryStreamEntries

      @ThingworxExtensionApiMethod(since={6,6}) public InfoTable QueryStreamEntries(Double maxItems, String source, TagCollection tags, TagCollection sourceTags, org.joda.time.DateTime startDate, org.joda.time.DateTime endDate, Boolean oldestFirst, org.json.JSONObject query) throws Exception
      Service Category:
      Queries
      Service Description:
      Query stream entries (without data), along with filter and sort criteria.
      Parameters:
      maxItems - Maximum number of items to return - NUMBER
      source - Source of this entry (optional) - STRING
      tags - Tags - TAGS
      sourceTags - Source Tags - TAGS
      startDate - Start time - DATETIME
      endDate - End time - DATETIME
      oldestFirst - Search/sort from oldest to newest - BOOLEAN
      query - Query definition - QUERY
      Returns:
      result Table entries - INFOTABLE - Aspects {isStreamEntry:true}
      Throws:
      Exception - If an error occurs
    • getItemEntityName

      @ThingworxExtensionApiMethod(since={6,6}) public String getItemEntityName()
      Specified by:
      getItemEntityName in interface IFeed
    • getItemCollectionName

      @ThingworxExtensionApiMethod(since={6,6}) public String getItemCollectionName()
      Specified by:
      getItemCollectionName in interface IFeed
    • getDependencies

      Description copied from class: Thing


      Returns a map containing references to all entities that the Thing is dependent on.

      Overrides:
      getDependencies in class Thing
      Returns:
      a map of up-stream dependencies
    • getDataType

    • getItemEntityType

    • addStreamEntryImmediately

      @ThingworxExtensionApiMethod(since={6,6}) public void addStreamEntryImmediately(org.joda.time.DateTime timestamp, Location location, String source, String sourceType, TagCollection tags, ValueCollection values) throws Exception
      Throws:
      Exception - If an error occurs