org.geotools.data.complex
Class DataAccessMappingFeatureIterator

Object
  extended by AbstractMappingFeatureIterator
      extended by DataAccessMappingFeatureIterator
All Implemented Interfaces:
Closeable, Iterator<Feature>, IMappingFeatureIterator, FeatureIterator<Feature>
Direct Known Subclasses:
FilteringMappingFeatureIterator, MappingAttributeIterator, XmlMappingFeatureIterator

public class DataAccessMappingFeatureIterator
extends AbstractMappingFeatureIterator

A Feature iterator that operates over the FeatureSource of a FeatureTypeMapping and produces Features of the output schema by applying the mapping rules to the Features of the source schema.

This iterator acts like a one-to-one mapping, producing a Feature of the target type for each feature of the source type.

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), Russell Petty (GeoScience Victoria)

Field Summary
protected  Feature curSrcFeature
          This is the feature that will be processed in next()
protected  List<Expression> foreignIds
           
protected  FeatureSource<? extends FeatureType,? extends Feature> mappedSource
           
protected  CoordinateReferenceSystem reprojection
          Reprojected CRS from the source simple features, or null
protected  FeatureCollection<? extends FeatureType,? extends Feature> sourceFeatures
           
protected  AttributeDescriptor targetFeature
           
 
Fields inherited from class AbstractMappingFeatureIterator
attf, dataMaxFeatures, featureCounter, ftf, includeMandatory, LOGGER, mapping, namespaceAwareFilterFactory, namespaces, requestMaxFeatures, RESOLVE_TIMEOUT_POLL_INTERVAL, resolveDepth, resolveTimeOut, selectedMapping, selectedProperties, store, XLINK_HREF_NAME, xpathAttributeBuilder
 
Constructor Summary
DataAccessMappingFeatureIterator(AppSchemaDataAccess store, FeatureTypeMapping mapping, Query query)
           
DataAccessMappingFeatureIterator(AppSchemaDataAccess store, FeatureTypeMapping mapping, Query query, boolean isFiltered, boolean removeQueryLimitIfDenormalised)
           
DataAccessMappingFeatureIterator(AppSchemaDataAccess store, FeatureTypeMapping mapping, Query query, Query unrolledQuery)
           
 
Method Summary
 boolean checkForeignIdValues(List<Object> foreignIdValues)
          Only used for Joining, to make sure that rows with different foreign id's aren't interpreted as one feature and merged.
protected  boolean checkForeignIdValues(List<Object> foreignIdValues, Feature next)
          Only used for Joining, to make sure that rows with different foreign id's aren't interpreted as one feature and merged.
protected  void cleanEmptyElements(Feature target)
           
protected  void closeSourceFeatures()
           
protected  Feature computeNext()
           
protected  String extractIdForAttribute(Expression idExpression, Object sourceInstance)
          Based on the set of xpath expression/id extracting expression, finds the ID for the attribute idExpression from the source complex attribute.
protected  String extractIdForFeature(Feature feature)
           
 List<Object> getForeignIdValues(Object source)
          Only used for Joining, to make sure that rows with different foreign id's aren't interpreted as one feature and merged.
 List<Object> getIdValues(Object source)
          Only used for Joining, to make sure that rows with different foreign id's aren't interpreted as one feature and merged.
protected  String getNextFeatureId()
           
protected  FeatureIterator<? extends Feature> getSourceFeatureIterator()
           
protected  List<Feature> getSources(String id)
          Get all source features of the provided id.
protected  Object getValue(Expression expression, Object sourceFeature)
           
protected  Object getValues(boolean isMultiValued, Expression expression, Object sourceFeatureInput)
           
 boolean hasNext()
          Does another Feature exist in this Iteration.
protected  void initialiseSourceFeatures(FeatureTypeMapping mapping, Query query, CoordinateReferenceSystem targetCRS)
           
protected  boolean isByReference(Map<Name,Expression> clientPropsMappings, boolean isNested)
          Checks if client property has xlink:ref in it, if the attribute is for chained features.
protected  boolean isNextSourceFeatureNull()
           
 boolean isReprojectionCrsEqual(CoordinateReferenceSystem source, CoordinateReferenceSystem target)
           
protected  boolean isSourceFeatureIteratorNull()
           
 Object peekNextValue(Expression prop)
           
protected  Object peekValue(Object source, Expression prop)
           
protected  Feature populateFeatureData(String id)
           
protected  Attribute setAttributeValue(Attribute target, String id, Object source, AttributeMapping attMapping, Object values, XPathUtil.StepList inputXpath, List<PropertyName> selectedProperties)
          Sets the values of grouping attributes.
 void setForeignIds(List<Expression> ids)
          Only used for Joining, to make sure that rows with different foreign id's aren't interpreted as one feature and merged.
 void setListFilter(Filter filter)
           
protected  List<Feature> setNextFeature(String fId, List<Object> foreignIdValues)
           
protected  void setXlinkReference(Attribute target, Map<Name,Expression> clientPropsMappings, Object value, XPathUtil.StepList xpath, AttributeType targetNodeType)
          Set xlink:href client property for multi-valued chained features.
 List<Feature> skip()
           
 void skipNestedMapping(AttributeMapping attMapping, List<Feature> sources)
           
protected  boolean skipTopElement(Name topElement, AttributeMapping attMapping, AttributeType type)
           
protected  boolean sourceFeatureIteratorHasNext()
           
protected  boolean unprocessedFeatureExists()
           
 
Methods inherited from class AbstractMappingFeatureIterator
close, getClientProperties, getDataMaxFeatures, getRequestMaxFeatures, getUnrolledQuery, isHasNextCalled, next, referenceToIdentifier, remove, setAttributeContent, setClientProperties, setGeometryUserData, setHasNextCalled
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reprojection

protected CoordinateReferenceSystem reprojection
Reprojected CRS from the source simple features, or null


curSrcFeature

protected Feature curSrcFeature
This is the feature that will be processed in next()


mappedSource

protected FeatureSource<? extends FeatureType,? extends Feature> mappedSource

sourceFeatures

protected FeatureCollection<? extends FeatureType,? extends Feature> sourceFeatures

foreignIds

protected List<Expression> foreignIds

targetFeature

protected AttributeDescriptor targetFeature
Constructor Detail

DataAccessMappingFeatureIterator

public DataAccessMappingFeatureIterator(AppSchemaDataAccess store,
                                        FeatureTypeMapping mapping,
                                        Query query,
                                        boolean isFiltered,
                                        boolean removeQueryLimitIfDenormalised)
                                 throws IOException
Throws:
IOException

DataAccessMappingFeatureIterator

public DataAccessMappingFeatureIterator(AppSchemaDataAccess store,
                                        FeatureTypeMapping mapping,
                                        Query query)
                                 throws IOException
Throws:
IOException

DataAccessMappingFeatureIterator

public DataAccessMappingFeatureIterator(AppSchemaDataAccess store,
                                        FeatureTypeMapping mapping,
                                        Query query,
                                        Query unrolledQuery)
                                 throws IOException
Parameters:
store -
mapping - place holder for the target type, the surrogate FeatureSource and the mappings between them.
query - the query over the target feature type, that is to be unpacked to its equivalent over the surrogate feature type.
Throws:
IOException
Method Detail

hasNext

public boolean hasNext()
Description copied from interface: FeatureIterator
Does another Feature exist in this Iteration.

Iterator defin: Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Specified by:
hasNext in interface Iterator<Feature>
Specified by:
hasNext in interface FeatureIterator<Feature>
Specified by:
hasNext in class AbstractMappingFeatureIterator
Returns:
true if more Features exist, false otherwise.

getSourceFeatureIterator

protected FeatureIterator<? extends Feature> getSourceFeatureIterator()
Specified by:
getSourceFeatureIterator in class AbstractMappingFeatureIterator

isSourceFeatureIteratorNull

protected boolean isSourceFeatureIteratorNull()
Specified by:
isSourceFeatureIteratorNull in class AbstractMappingFeatureIterator

peekValue

protected Object peekValue(Object source,
                           Expression prop)

peekNextValue

public Object peekNextValue(Expression prop)

setForeignIds

public void setForeignIds(List<Expression> ids)
Only used for Joining, to make sure that rows with different foreign id's aren't interpreted as one feature and merged.


getForeignIdValues

public List<Object> getForeignIdValues(Object source)
Only used for Joining, to make sure that rows with different foreign id's aren't interpreted as one feature and merged.


checkForeignIdValues

protected boolean checkForeignIdValues(List<Object> foreignIdValues,
                                       Feature next)
Only used for Joining, to make sure that rows with different foreign id's aren't interpreted as one feature and merged.


getIdValues

public List<Object> getIdValues(Object source)
Only used for Joining, to make sure that rows with different foreign id's aren't interpreted as one feature and merged.


checkForeignIdValues

public boolean checkForeignIdValues(List<Object> foreignIdValues)
Only used for Joining, to make sure that rows with different foreign id's aren't interpreted as one feature and merged.


initialiseSourceFeatures

protected void initialiseSourceFeatures(FeatureTypeMapping mapping,
                                        Query query,
                                        CoordinateReferenceSystem targetCRS)
                                 throws IOException
Specified by:
initialiseSourceFeatures in class AbstractMappingFeatureIterator
Throws:
IOException

unprocessedFeatureExists

protected boolean unprocessedFeatureExists()
Specified by:
unprocessedFeatureExists in class AbstractMappingFeatureIterator

extractIdForFeature

protected String extractIdForFeature(Feature feature)

extractIdForAttribute

protected String extractIdForAttribute(Expression idExpression,
                                       Object sourceInstance)
Description copied from class: AbstractMappingFeatureIterator
Based on the set of xpath expression/id extracting expression, finds the ID for the attribute idExpression from the source complex attribute.

Specified by:
extractIdForAttribute in class AbstractMappingFeatureIterator
Parameters:
idExpression - the location path of the attribute to be created, for which to obtain the id by evaluating the corresponding org.geotools.filter.Expression from sourceInstance.
sourceInstance - a complex attribute which is the source of the mapping.
Returns:
the ID to be applied to a new attribute instance addressed by attributeXPath, or null if there is no an id mapping for that attribute.

isNextSourceFeatureNull

protected boolean isNextSourceFeatureNull()
Specified by:
isNextSourceFeatureNull in class AbstractMappingFeatureIterator

sourceFeatureIteratorHasNext

protected boolean sourceFeatureIteratorHasNext()
Specified by:
sourceFeatureIteratorHasNext in class AbstractMappingFeatureIterator

getValues

protected Object getValues(boolean isMultiValued,
                           Expression expression,
                           Object sourceFeatureInput)

setAttributeValue

protected Attribute setAttributeValue(Attribute target,
                                      String id,
                                      Object source,
                                      AttributeMapping attMapping,
                                      Object values,
                                      XPathUtil.StepList inputXpath,
                                      List<PropertyName> selectedProperties)
                               throws IOException
Sets the values of grouping attributes.

Parameters:
target -
source -
attMapping -
values -
Returns:
Feature. Target feature sets with simple attributes
Throws:
IOException

setXlinkReference

protected void setXlinkReference(Attribute target,
                                 Map<Name,Expression> clientPropsMappings,
                                 Object value,
                                 XPathUtil.StepList xpath,
                                 AttributeType targetNodeType)
Set xlink:href client property for multi-valued chained features. This has to be specially handled because we don't want to encode the nested features attributes, since it's already an xLink. Also we need to eliminate duplicates.

Parameters:
target - The target attribute
clientPropsMappings - Client properties mappings
value - Nested features
xpath - Attribute xPath where the client properties are to be set
targetNodeType - Target node type
attMapping -
list -
Throws:
IOException

setNextFeature

protected List<Feature> setNextFeature(String fId,
                                       List<Object> foreignIdValues)
                                throws IOException
Throws:
IOException

skipNestedMapping

public void skipNestedMapping(AttributeMapping attMapping,
                              List<Feature> sources)
                       throws IOException
Throws:
IOException

skip

public List<Feature> skip()
                   throws IOException
Throws:
IOException

computeNext

protected Feature computeNext()
                       throws IOException
Specified by:
computeNext in class AbstractMappingFeatureIterator
Throws:
IOException

getSources

protected List<Feature> getSources(String id)
                            throws IOException
Get all source features of the provided id. This assumes the source features are grouped by id.

Parameters:
id - The feature id
Returns:
list of source features
Throws:
IOException

getNextFeatureId

protected String getNextFeatureId()

cleanEmptyElements

protected void cleanEmptyElements(Feature target)
                           throws DataSourceException
Throws:
DataSourceException

skipTopElement

protected boolean skipTopElement(Name topElement,
                                 AttributeMapping attMapping,
                                 AttributeType type)

populateFeatureData

protected Feature populateFeatureData(String id)
                               throws IOException
Specified by:
populateFeatureData in class AbstractMappingFeatureIterator
Throws:
IOException

closeSourceFeatures

protected void closeSourceFeatures()
Specified by:
closeSourceFeatures in class AbstractMappingFeatureIterator

getValue

protected Object getValue(Expression expression,
                          Object sourceFeature)
Specified by:
getValue in class AbstractMappingFeatureIterator

isByReference

protected boolean isByReference(Map<Name,Expression> clientPropsMappings,
                                boolean isNested)
Checks if client property has xlink:ref in it, if the attribute is for chained features.

Parameters:
clientPropsMappings - the client properties mappings
isNested - true if we're dealing with chained/nested features
Returns:

isReprojectionCrsEqual

public boolean isReprojectionCrsEqual(CoordinateReferenceSystem source,
                                      CoordinateReferenceSystem target)

setListFilter

public void setListFilter(Filter filter)


Copyright © 1996-2014 Geotools. All Rights Reserved.