数据访问集成¶
本页假定事先了解 应用程序架构 和 特征链 .要使用功能链接,嵌套功能可以来自任何复杂的功能数据访问,只要:
它具有“容器”功能类型所引用的有效数据,
数据访问通过dataaccessregistry注册,
如果将要素链接用作链接字段,则要素类型是通过complexFeatureTypeFactoryImpl创建的。
但是,“容器”功能必须来自应用程序模式数据访问。本文的其余部分将描述如何从现有的非应用程序模式数据访问创建应用程序数据访问,以便“链接”特性。本文中提到的输入数据访问被假定为非应用程序模式数据访问。
如何连接到输入数据访问¶
像往常一样在“sourcedatastores”标记中配置数据存储连接,但还要指定附加的“isdataaccess”标记。此标志标记我们在处理源数据存储时要获取指定“sourceType”的已注册复杂功能源。这假定输入数据访问在创建时注册在DataAccessRegistry中,以便系统找到它。
例子 ::
<sourceDataStores>
<DataStore>
<id>EarthResource</id>
<parameters>
<Parameter>
<name>directory</name>
<value>file:./</value>
</Parameter>
</parameters>
<isDataAccess>true</isDataAccess>
</DataStore>
</sourceDataStores>
...
<typeMappings>
<FeatureTypeMapping>
<sourceDataStore>EarthResource</sourceDataStore>
<sourceType>EarthResource</sourceType>
...
如何配置映射¶
使用“inputAttribute”代替“sourceExpression”中的“ocql”标记,指定输入的xpath表达式。
例子 ::
<AttributeMapping>
<targetAttribute>gsml:classifier/gsml:ControlledConcept/gsml:preferredName</targetAttribute>
<sourceExpression>
<inputAttribute>mo:classification/mo:MineralDepositModel/mo:mineralDepositGroup</inputAttribute>
</sourceExpression>
</AttributeMapping>
如何链接功能¶
对于重新映射的复杂特征,特征链可以双向工作。您可以在这些特性中链接其他特性,反之亦然。唯一的区别是对输入xpath表达式使用“inputAttribute”,而不是如上所述的“ocql”。
例子 ::
<AttributeMapping>
<targetAttribute>gsml:occurence</targetAttribute>
<sourceExpression>
<inputAttribute>mo:commodityDescription</inputAttribute>
<linkElement>gsml:MappedFeature</linkElement>
<linkField>gml:name[2]</linkField>
</sourceExpression>
<isMultiple>true</isMultiple>
</AttributeMapping>
如何使用过滤器¶
从用户的角度来看,使用映射/输出目标属性xpath表达式,按照正常方式配置过滤器。但是,当表达式中的一个或多个属性是多值属性时,我们需要在过滤器中指定一个函数,例如“contains_text”。这是因为当返回多个值时,将它们与单个值进行比较只会在只返回一个值且该值相同的情况下返回true。请注意,以下示例中使用的“contains_text”函数在geoserver api中不可用,而是在数据库中定义的。
例子:
组合是多值属性:
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="contains_text">
<ogc:PropertyName>gsml:composition/gsml:CompositionPart/gsml:proportion/gsml:CGI_TermValue/gsml:value</ogc:PropertyName>
<ogc:Literal>Olivine basalt, tuff, microgabbro, minor sedimentary rocks</ogc:Literal>
</ogc:Function>
<ogc:Literal>1</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>