Class DataAccessRegistry

  • All Implemented Interfaces:
    Repository
    Direct Known Subclasses:
    AppSchemaDataAccessRegistry

    public class DataAccessRegistry
    extends Object
    implements Repository
    A registry that stores data access instances per application. This allows feature sources from different data accesses to be accessed globally.
    Author:
    Rini Angreani (CSIRO Earth Science and Resource Engineering), Niels Charlier (Curtin University Of Technology)
    • Constructor Detail

      • DataAccessRegistry

        protected DataAccessRegistry()
        Sole constructor
    • Method Detail

      • getInstance

        public static DataAccessRegistry getInstance()
        Public method to get singleton instance to registry.
        Returns:
        An instance of this class
      • featureSource

        public FeatureSource<FeatureType,​Feature> featureSource​(Name name)
                                                               throws IOException
        Get a feature source for built features with supplied feature type name.
        Returns:
        feature source
        Throws:
        IOException
      • access

        public DataAccess<FeatureType,​Feature> access​(Name name)
        Description copied from interface: Repository
        Search for the DataAccess (may be a DataStore) by name.
        Specified by:
        access in interface Repository
        Parameters:
        name - The Name (namespace and name) to search for
        Returns:
        DataAccess
      • dataStore

        public DataStore dataStore​(Name name)
        Description copied from interface: Repository
        Search for the DataStore by name.
        Specified by:
        dataStore in interface Repository
        Parameters:
        name - The typeName (namespace and name) to search for
        Returns:
        DataAccess api providing access to the indicatedTypeName (or null if not found)
      • getDataStores

        public List<DataStore> getDataStores()
        Description copied from interface: Repository
        List of available DataStore instances; these are considered to be live/connected datastores under the management of the application and should not be closed or otherwise harmed by client code.

        Specified by:
        getDataStores in interface Repository
        Returns:
        List of Managed DataStore instances
      • registerAccess

        public void registerAccess​(DataAccess<FeatureType,​Feature> dataAccess)
        Registers a data access
        Parameters:
        dataAccess - Data access to be registered
      • unregisterAccess

        public void unregisterAccess​(DataAccess<FeatureType,​Feature> dataAccess)
        Unregister a data access. This is important especially at the end of test cases, so that the mappings contained in the data access do not conflict with mappings of the same type used in other tests.
        Parameters:
        dataAccess - Data access to be unregistered
      • disposeAndUnregisterAll

        public void disposeAndUnregisterAll()
        Dispose and unregister all data accesses in the registry. This is may be needed to prevent unit tests from conflicting with data accesses with the same type name registered for other tests.
      • hasAccessName

        public boolean hasAccessName​(Name name)
                              throws IOException
        Return true if a type name is mapped in one of the registered data accesses. If the type mapping has mappingName, then it will be the key that is matched in the search. If it doesn't, then it will match the targetElementName.
        Parameters:
        name - Feature type name
        Throws:
        IOException
      • hasAppSchemaAccessName

        public boolean hasAppSchemaAccessName​(Name name)
                                       throws IOException
        Return true if a type name is mapped in one of the registered app-schema data accesses. If the type mapping has mappingName, then it will be the key that is matched in the search. If it doesn't, then it will match the targetElementName.
        Parameters:
        name - Feature type name
        Throws:
        IOException
      • mappingByName

        public FeatureTypeMapping mappingByName​(Name name)
                                         throws IOException
        Get a feature type mapping from a registered app-schema data access. Please note that this is only possible for app-schema data access instances.
        Returns:
        feature type mapping
        Throws:
        IOException
      • mappingByElement

        public FeatureTypeMapping mappingByElement​(Name name)
                                            throws IOException
        Throws:
        IOException
      • hasAppSchemaTargetElement

        public boolean hasAppSchemaTargetElement​(Name name)
                                          throws IOException
        Return true if a type name is mapped in one of the registered app-schema data accesses as targetElementName, regardless whether or not mappingName exists.
        Throws:
        IOException
      • clearProperties

        public void clearProperties()
        Clean-up properties, mainly used for cleaning up after tests
      • getFeatureSource

        public static FeatureSource<FeatureType,​Feature> getFeatureSource​(Name featureTypeName)
                                                                         throws IOException
        Get a feature source for built features with supplied feature type name.
        Returns:
        feature source
        Throws:
        IOException
      • register

        public static void register​(DataAccess<FeatureType,​Feature> dataAccess)
        Registers a data access
        Parameters:
        dataAccess - Data access to be registered
      • unregister

        public static void unregister​(DataAccess<FeatureType,​Feature> dataAccess)
        Unregister a data access. This is important especially at the end of test cases, so that the mappings contained in the data access do not conflict with mappings of the same type used in other tests. * Does not dispose * This method should not be called directly, instead use dispose method from DataAccess
        Parameters:
        dataAccess - Data access to be unregistered
      • unregisterAndDisposeAll

        public static void unregisterAndDisposeAll()
        Unregister * and dispose * all data accesses in the registry. This is may be needed to prevent unit tests from conflicting with data accesses with the same type name registered for other tests.
      • hasName

        public static boolean hasName​(Name featureTypeName)
                               throws IOException
        Return true if a type name is mapped in one of the registered data accesses. If the type mapping has mappingName, then it will be the key that is matched in the search. If it doesn't, then it will match the targetElementName.
        Parameters:
        featureTypeName - Feature type name
        Throws:
        IOException
      • throwDataSourceException

        protected void throwDataSourceException​(Name featureTypeName)
                                         throws IOException
        Throws data source exception if mapping is not found.
        Parameters:
        featureTypeName - Name of feature type
        Throws:
        IOException
      • findFeature

        public Feature findFeature​(FeatureId id,
                                   Hints hints)
                            throws IOException
        Throws:
        IOException