Class AppSchemaDataAccess
- Object
-
- AppSchemaDataAccess
-
- All Implemented Interfaces:
DataAccess<FeatureType,Feature>
public class AppSchemaDataAccess extends Object implements DataAccess<FeatureType,Feature>
ADataAccess
that maps a "simple" sourceDataStore
into a source of full Feature features conforming to an application schema.- Since:
- 2.4
- Author:
- Gabriel Roldan (Axios Engineering), Ben Caradoc-Davies (CSIRO Earth Science and Resource Engineering), Rini Angreani (CSIRO Earth Science and Resource Engineering)
-
-
Constructor Summary
Constructors Constructor Description AppSchemaDataAccess(Set<FeatureTypeMapping> mappings)
Constructor.AppSchemaDataAccess(Set<FeatureTypeMapping> mappings, boolean hidden)
Two args constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createSchema(FeatureType featureType)
Not a supported operation.void
dispose()
Disposes of this data store and releases any resource that it is using.Feature
findFeature(FeatureId id, Hints hints)
protected ReferencedEnvelope
getBounds(Query query)
Computes the bounds of the features for the specified feature type that satisfy the query provided that there is a fast way to get that result.protected int
getCount(Query targetQuery)
Gets the number of the features that would be returned by this query for the specified feature type.FeatureSource<FeatureType,Feature>
getFeatureSource(Name typeName)
Return a feature source that can be used to obtain features of a particular type.FeatureSource<FeatureType,Feature>
getFeatureSourceByName(Name typeName)
Return a feature source that can be used to obtain features of a particular name.ServiceInfo
getInfo()
Not a supported operation.FeatureTypeMapping
getMappingByName(Name typeName)
Returns the mapping suite for the given targetElement name or mappingName.FeatureTypeMapping
getMappingByNameOrElement(Name typeName)
Returns the mapping suite for the given target type name.List<Name>
getNames()
Return the names of the target features.URL
getParentUrl()
FeatureType
getSchema(Name typeName)
Finds the target FeatureType namedtypeName
in this ComplexDatastore's internal list of FeatureType mappings and returns it.Name[]
getTypeNames()
Returns the set of target type names this DataAccess holds, where the term 'target type name' refers to the name of one of the types this DataAccess produces by mapping another ones through the definitions stored in its FeatureTypeMappingsprotected Filter
getUnsupportedFilter(String typeName, Filter filter)
ReturnsFilter.INCLUDE
, as the whole filter is unrolled and passed back to the underlying DataStore to be treated.URL
getUrl()
boolean
hasElement(Name typeName)
boolean
hasName(Name name)
static boolean
matchProperty(String requestedProperty, XPathUtil.StepList target)
Helper method for getSurrogatePropertyNames to match a requested single step property with a target x-path, ignoring namespacesstatic boolean
matchProperty(XPathUtil.StepList requestedProperty, XPathUtil.StepList target)
Helper method for getSurrogatePropertyNames to match a requested x-path property with a target x-pathprotected void
register()
Registers this data access to the registry so the mappings can be retrieved globallyvoid
removeSchema(Name typeName)
Not a supported operation.static Filter
unrollFilter(Filter complexFilter, FeatureTypeMapping mapping)
Takes a filter that operates against a FeatureTypeMapping's target FeatureType, and unrolls it creating a new Filter that operates against the mapping's source FeatureType.Query
unrollQuery(Query query, FeatureTypeMapping mapping)
Creates aorg.geotools.api.data.Query
that operates over the surrogate DataStore, by unrolling theorg.geotools.filter.Filter
contained in the passedquery
, and replacing the list of required attributes by the ones of the mapped FeatureType.void
updateSchema(Name typeName, FeatureType featureType)
Not a supported operation.
-
-
-
Constructor Detail
-
AppSchemaDataAccess
public AppSchemaDataAccess(Set<FeatureTypeMapping> mappings) throws IOException
Constructor.- Parameters:
mappings
- a Set containing a FeatureTypeMapping for each FeatureType this DataAccess is going to produce.- Throws:
IOException
-
AppSchemaDataAccess
public AppSchemaDataAccess(Set<FeatureTypeMapping> mappings, boolean hidden) throws IOException
Two args constructor.- Parameters:
mappings
- a Set containing a FeatureTypeMapping for each FeatureType this DataAccess is going to produce.hidden
- marks this data access as non-accessible, which makes it a candidate for automatic disposal- Throws:
IOException
-
-
Method Detail
-
register
protected void register()
Registers this data access to the registry so the mappings can be retrieved globally
-
getTypeNames
public Name[] getTypeNames() throws IOException
Returns the set of target type names this DataAccess holds, where the term 'target type name' refers to the name of one of the types this DataAccess produces by mapping another ones through the definitions stored in its FeatureTypeMappings- Throws:
IOException
-
getSchema
public FeatureType getSchema(Name typeName) throws IOException
Finds the target FeatureType namedtypeName
in this ComplexDatastore's internal list of FeatureType mappings and returns it.- Specified by:
getSchema
in interfaceDataAccess<FeatureType,Feature>
- Parameters:
typeName
- Type name a the resource from getNames()- Returns:
- Description of the FeatureType being made avaialble
- Throws:
IOException
-
getMappingByName
public FeatureTypeMapping getMappingByName(Name typeName) throws IOException
Returns the mapping suite for the given targetElement name or mappingName.Note this method is public just for unit testing purposes
- Throws:
IOException
-
getMappingByNameOrElement
public FeatureTypeMapping getMappingByNameOrElement(Name typeName) throws IOException
Returns the mapping suite for the given target type name. This name would be the mappingName in the TypeMapping if it exists, otherwise it's the target element name.Note this method is public just for unit testing purposes
- Throws:
IOException
-
hasName
public boolean hasName(Name name)
- Parameters:
name
- mappingName or targetElement- Returns:
- true if this data access contains mapping with for provided name
-
hasElement
public boolean hasElement(Name typeName)
- Parameters:
typeName
- targetElement name- Returns:
- true if this data access contains mapping for provided targetElement name
-
getBounds
protected ReferencedEnvelope getBounds(Query query) throws IOException
Computes the bounds of the features for the specified feature type that satisfy the query provided that there is a fast way to get that result.Will return null if there is not fast way to compute the bounds. Since it's based on some kind of header/cached information, it's not guaranteed to be real bound of the features
- Returns:
- the bounds, or null if too expensive
- Throws:
IOException
-
getCount
protected int getCount(Query targetQuery) throws IOException
Gets the number of the features that would be returned by this query for the specified feature type.If getBounds(Query) returns
-1
due to expense consider usinggetFeatures(Query).getCount()
as a an alternative.- Parameters:
targetQuery
- Contains the Filter and MaxFeatures to find the bounds for.- Returns:
- The number of Features provided by the Query or
-1
if count is too expensive to calculate or any errors or occur. - Throws:
IOException
- if there are errors getting the count
-
getUnsupportedFilter
protected Filter getUnsupportedFilter(String typeName, Filter filter)
ReturnsFilter.INCLUDE
, as the whole filter is unrolled and passed back to the underlying DataStore to be treated.- Returns:
Filter.INLCUDE
-
unrollQuery
public Query unrollQuery(Query query, FeatureTypeMapping mapping)
Creates aorg.geotools.api.data.Query
that operates over the surrogate DataStore, by unrolling theorg.geotools.filter.Filter
contained in the passedquery
, and replacing the list of required attributes by the ones of the mapped FeatureType.
-
matchProperty
public static boolean matchProperty(XPathUtil.StepList requestedProperty, XPathUtil.StepList target)
Helper method for getSurrogatePropertyNames to match a requested x-path property with a target x-path- Parameters:
requestedProperty
- requested property x-pathtarget
- target x-path steps- Returns:
- whether they match, i.e. when one of them is completely contained in the other
-
matchProperty
public static boolean matchProperty(String requestedProperty, XPathUtil.StepList target)
Helper method for getSurrogatePropertyNames to match a requested single step property with a target x-path, ignoring namespaces- Parameters:
requestedProperty
- requested property x-pathtarget
- target x-path steps- Returns:
- whether they match, i.e. when one of them is completely contained in the other
-
unrollFilter
public static Filter unrollFilter(Filter complexFilter, FeatureTypeMapping mapping)
Takes a filter that operates against a FeatureTypeMapping's target FeatureType, and unrolls it creating a new Filter that operates against the mapping's source FeatureType.- Returns:
- TODO: implement filter unrolling
-
dispose
public void dispose()
Description copied from interface:DataAccess
Disposes of this data store and releases any resource that it is using.A
DataStore
cannot be used afterdispose
has been called, neither can any data access object it helped create, such asFeatureReader
,FeatureSource
orFeatureCollection
.This operation can be called more than once without side effects.
There is no thread safety assurance associated with this method. For example, client code will have to make sure this method is not called while retrieving/saving data from/to the storage, or be prepared for the consequences.
- Specified by:
dispose
in interfaceDataAccess<FeatureType,Feature>
-
getInfo
public ServiceInfo getInfo()
Not a supported operation.- Specified by:
getInfo
in interfaceDataAccess<FeatureType,Feature>
- Returns:
- SeviceInfo
- See Also:
DataAccess.getInfo()
-
getNames
public List<Name> getNames()
Return the names of the target features.- Specified by:
getNames
in interfaceDataAccess<FeatureType,Feature>
- Returns:
- Names of the available contents.
- See Also:
DataAccess.getNames()
-
createSchema
public void createSchema(FeatureType featureType) throws IOException
Not a supported operation.- Specified by:
createSchema
in interfaceDataAccess<FeatureType,Feature>
- Parameters:
featureType
- FetureType to add to DataStore- Throws:
IOException
- If featureType cannot be created- See Also:
DataAccess.createSchema(org.geotools.api.feature.type.FeatureType)
-
getFeatureSource
public FeatureSource<FeatureType,Feature> getFeatureSource(Name typeName) throws IOException
Return a feature source that can be used to obtain features of a particular type.- Specified by:
getFeatureSource
in interfaceDataAccess<FeatureType,Feature>
- Returns:
- Access to the named resource being made available
- Throws:
IOException
- See Also:
DataAccess.getFeatureSource(org.geotools.api.feature.type.Name)
-
updateSchema
public void updateSchema(Name typeName, FeatureType featureType) throws IOException
Not a supported operation.- Specified by:
updateSchema
in interfaceDataAccess<FeatureType,Feature>
- Throws:
IOException
- if the operation failed- See Also:
DataAccess.updateSchema(org.geotools.api.feature.type.Name, org.geotools.api.feature.type.FeatureType)
-
removeSchema
public void removeSchema(Name typeName) throws IOException
Not a supported operation.- Specified by:
removeSchema
in interfaceDataAccess<FeatureType,Feature>
- Throws:
IOException
- if the operation failed- See Also:
DataAccess.removeSchema(org.geotools.api.feature.type.Name)
-
getFeatureSourceByName
public FeatureSource<FeatureType,Feature> getFeatureSourceByName(Name typeName) throws IOException
Return a feature source that can be used to obtain features of a particular name. This name would be the mappingName in the TypeMapping if it exists, otherwise it's the target element name.- Parameters:
typeName
- mappingName or targetElement- Returns:
- Mapping feature source
- Throws:
IOException
-
findFeature
public Feature findFeature(FeatureId id, Hints hints) throws IOException
- Throws:
IOException
-
getUrl
public URL getUrl()
-
getParentUrl
public URL getParentUrl()
-
-