Class AzureDigitalTwinsPersistenceProvider

  • All Implemented Interfaces:
    PersistenceProvider

    public class AzureDigitalTwinsPersistenceProvider
    extends java.lang.Object
    implements PersistenceProvider
    AzureDigitalTwinsPersistenceProvider is a persistence provider implementation that is backed by Azure Digital Twins.
    • Method Summary

      Modifier and Type Method Description
      java.lang.String getInstance​(java.lang.String adtModelName, java.lang.String instanceId)
      Retrieves a twin instance or null if it doesn't exist.
      java.util.concurrent.CompletableFuture<java.lang.String> getInstanceAsync​(java.lang.String modelName, java.lang.String instanceId)
      Retrieves a future that when complete will return a twin instance or null if it doesn't exist.
      java.util.List<java.lang.String> getInstanceIds​(java.lang.String adtModelName)
      Retrieves a list of instance IDs for a DTMI otherwise returns an empty list if no instances exist.
      java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> getInstanceIdsAsync​(java.lang.String adtModelName)
      Retrieves a future that when complete will return a list of instance IDs for a DTMI otherwise returns an empty list if no instances exist.
      <T> T getProperty​(java.lang.String componentName, java.lang.String twinId, java.lang.String propertyName, java.lang.Class<T> clazz)
      Retrieves a property or null if the property does not exist.
      <T> java.util.concurrent.CompletableFuture<T> getPropertyAsync​(java.lang.String componentName, java.lang.String twinId, java.lang.String propertyName, java.lang.Class<T> clazz)
      Retrieves a future that will return a property or null if the property does not exist.
      java.util.Map<java.lang.String,​java.lang.String> getPropertyMap​(java.lang.String adtModelName)
      Retrieves a map of property names to property, or an empty map.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.String>> getPropertyMapAsync​(java.lang.String adtModelName)
      Retrieves a future that will return a map of property names to property, or an empty map.
      PersistenceProviderType getProviderType()
      Retrieves this persistence providers type.
      <T> T getRtdtProperty​(java.lang.String twinId, java.lang.String propertyName, java.lang.Class<T> clazz)
      Retrieves a property for a RTDT instance or null if the property does not exist.
      <T> java.util.concurrent.CompletableFuture<T> getRtdtPropertyAsync​(java.lang.String twinId, java.lang.String propertyName, java.lang.Class<T> clazz)
      Retrieves a future that will return a property value for a RTDT instance or null if the property doesn't exist.
      boolean isActive()
      Returns true if this PersistenceProvider is active, false otherwise.
      void updateProperty​(java.lang.String adtModelName, java.lang.String twinId, java.lang.String propertyName, java.lang.Object propertyValue)
      Updates a property for the provided instance id in the provided container specified by the property name and property value.
      java.util.concurrent.CompletableFuture<java.lang.Void> updatePropertyAsync​(java.lang.String adtModelName, java.lang.String twinId, java.lang.String propertyName, java.lang.Object propertyValue)
      Retrieves a future that will complete exceptionally or return void if the twin instance's property was successfully updated.
      void updateRtdtProperty​(java.lang.String twinId, java.lang.String propertyName, java.lang.Object propertyValue)
      Updates a RTDT property for the provided instance id specified by the property name and property value.
      java.util.concurrent.CompletableFuture<java.lang.Void> updateRtdtPropertyAsync​(java.lang.String twinId, java.lang.String propertyName, java.lang.Object propertyValue)
      Retrieves a future that will complete exceptionally or return void if the RTDT's property was successfully updated.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AzureDigitalTwinsPersistenceProvider

        public AzureDigitalTwinsPersistenceProvider​(java.lang.String adtModelName)
    • Method Detail

      • isActive

        public boolean isActive()
        Returns true if this PersistenceProvider is active, false otherwise.
        Specified by:
        isActive in interface PersistenceProvider
        Returns:
        true if this PersistenceProvider is active, false otherwise.
      • getInstanceIdsAsync

        public java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> getInstanceIdsAsync​(java.lang.String adtModelName)
        Retrieves a future that when complete will return a list of instance IDs for a DTMI otherwise returns an empty list if no instances exist.
        Specified by:
        getInstanceIdsAsync in interface PersistenceProvider
        Parameters:
        adtModelName - the Azure Digital Twins model name (DTMI).
        Returns:
        a future that will return a list of instance IDs.
      • getInstanceIds

        public java.util.List<java.lang.String> getInstanceIds​(java.lang.String adtModelName)
        Retrieves a list of instance IDs for a DTMI otherwise returns an empty list if no instances exist.
        Specified by:
        getInstanceIds in interface PersistenceProvider
        Parameters:
        adtModelName - the Azure Digital Twins model name (DTMI).
        Returns:
        a list of instance IDs.
      • getInstanceAsync

        public java.util.concurrent.CompletableFuture<java.lang.String> getInstanceAsync​(java.lang.String modelName,
                                                                                         java.lang.String instanceId)
        Retrieves a future that when complete will return a twin instance or null if it doesn't exist. If found, the returned instance is the JSON serialized BasicDigitalTwin.
        Specified by:
        getInstanceAsync in interface PersistenceProvider
        Parameters:
        modelName - the Azure Digital Twins model name (DTMI).
        instanceId - the twin identifier.
        Returns:
        a future that will return an instance or null.
      • getInstance

        public java.lang.String getInstance​(java.lang.String adtModelName,
                                            java.lang.String instanceId)
        Retrieves a twin instance or null if it doesn't exist. If found, the returned instance is the JSON serialized BasicDigitalTwin.
        Specified by:
        getInstance in interface PersistenceProvider
        Parameters:
        adtModelName - the Azure Digital Twins model name (DTMI).
        instanceId - the twin identifier.
        Returns:
        an instance or null.
      • getPropertyMapAsync

        public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.String>> getPropertyMapAsync​(java.lang.String adtModelName)
        Retrieves a future that will return a map of property names to property, or an empty map. Complex schemas will only return the schema name.
        Specified by:
        getPropertyMapAsync in interface PersistenceProvider
        Parameters:
        adtModelName - the Azure Digital Twins Model name (DTMI).
        Returns:
        a future that will return a map of property names to property types.
      • getPropertyMap

        public java.util.Map<java.lang.String,​java.lang.String> getPropertyMap​(java.lang.String adtModelName)
        Retrieves a map of property names to property, or an empty map. Complex schemas will only return the schema name.
        Specified by:
        getPropertyMap in interface PersistenceProvider
        Parameters:
        adtModelName - the Azure Digital Twins Model name (DTMI)
        Returns:
        a map of property names to property types.
      • updatePropertyAsync

        public java.util.concurrent.CompletableFuture<java.lang.Void> updatePropertyAsync​(java.lang.String adtModelName,
                                                                                          java.lang.String twinId,
                                                                                          java.lang.String propertyName,
                                                                                          java.lang.Object propertyValue)
        Retrieves a future that will complete exceptionally or return void if the twin instance's property was successfully updated. Updates a property for the provided instance id for the provided model specified by the property name and property value.
        Specified by:
        updatePropertyAsync in interface PersistenceProvider
        Parameters:
        adtModelName - the Azure Digital Twins Model name (DTMI)
        twinId - the twin id.
        propertyName - the property name.
        propertyValue - the property value.
        Returns:
        a future that will complete exceptionally or return void.
      • updateProperty

        public void updateProperty​(java.lang.String adtModelName,
                                   java.lang.String twinId,
                                   java.lang.String propertyName,
                                   java.lang.Object propertyValue)
        Updates a property for the provided instance id in the provided container specified by the property name and property value. Updates a property for the provided instance id for the provided model specified by the property name and property value.
        Specified by:
        updateProperty in interface PersistenceProvider
        Parameters:
        adtModelName - the Azure Digital Twins Model name (DTMI).
        twinId - the twin id.
        propertyName - the property name.
        propertyValue - the property value.
      • getPropertyAsync

        public <T> java.util.concurrent.CompletableFuture<T> getPropertyAsync​(java.lang.String componentName,
                                                                              java.lang.String twinId,
                                                                              java.lang.String propertyName,
                                                                              java.lang.Class<T> clazz)
        Retrieves a future that will return a property or null if the property does not exist.
        Specified by:
        getPropertyAsync in interface PersistenceProvider
        Type Parameters:
        T - the type of the property to return
        Parameters:
        componentName - the component name name, or null.
        twinId - the twin id.
        propertyName - the property name.
        clazz - the class representing the property.
        Returns:
        the property or null if the property does not exist.
      • getProperty

        public <T> T getProperty​(java.lang.String componentName,
                                 java.lang.String twinId,
                                 java.lang.String propertyName,
                                 java.lang.Class<T> clazz)
        Retrieves a property or null if the property does not exist.
        Specified by:
        getProperty in interface PersistenceProvider
        Type Parameters:
        T - the type of the property to return.
        Parameters:
        componentName - the container name.
        twinId - the twin id.
        propertyName - the property name
        clazz - the class representing the property.
        Returns:
        the property or null if the property does not exist.
      • updateRtdtPropertyAsync

        public java.util.concurrent.CompletableFuture<java.lang.Void> updateRtdtPropertyAsync​(java.lang.String twinId,
                                                                                              java.lang.String propertyName,
                                                                                              java.lang.Object propertyValue)
        Retrieves a future that will complete exceptionally or return void if the RTDT's property was successfully updated. Updates a RTDT property for the provided instance id specified by the property name and property value.
        Specified by:
        updateRtdtPropertyAsync in interface PersistenceProvider
        Parameters:
        twinId - the twin id.
        propertyName - the property name.
        propertyValue - the property value.
        Returns:
        a future that will complete exceptionally or return void.
      • updateRtdtProperty

        public void updateRtdtProperty​(java.lang.String twinId,
                                       java.lang.String propertyName,
                                       java.lang.Object propertyValue)
        Updates a RTDT property for the provided instance id specified by the property name and property value.
        Specified by:
        updateRtdtProperty in interface PersistenceProvider
        Parameters:
        twinId - the twin id.
        propertyName - the property name.
        propertyValue - the property value.
      • getRtdtPropertyAsync

        public <T> java.util.concurrent.CompletableFuture<T> getRtdtPropertyAsync​(java.lang.String twinId,
                                                                                  java.lang.String propertyName,
                                                                                  java.lang.Class<T> clazz)
        Retrieves a future that will return a property value for a RTDT instance or null if the property doesn't exist.
        Specified by:
        getRtdtPropertyAsync in interface PersistenceProvider
        Type Parameters:
        T - the type of the property to return.
        Parameters:
        twinId - the twin id.
        propertyName - the property name.
        clazz - the class of the property type
        Returns:
        a future that will return a property value for a RTDT instance.
      • getRtdtProperty

        public <T> T getRtdtProperty​(java.lang.String twinId,
                                     java.lang.String propertyName,
                                     java.lang.Class<T> clazz)
        Retrieves a property for a RTDT instance or null if the property does not exist.
        Specified by:
        getRtdtProperty in interface PersistenceProvider
        Type Parameters:
        T - the type of the property to return.
        Parameters:
        twinId - the instance id.
        propertyName - the property name.
        clazz - the class of the property type.
        Returns:
        the property value.