智能数据加载器

数据存储

除了每个组件共有的参数之外 DataStore 配置,如 workspacenamedescription 中,该页在专用部分中显示以下连接参数:

  • Data store name :邮政地理信息系统的名称 DataStore 已在同一工作空间下创建。它将用于访问数据库并基于数据库元数据构建xsd和映射文件。

  • Root entity :将用作根FeatureType以构建xsd和映射文件的DB表的名称。

一旦选择了根实体,就会出现可用实体的图表。取消选中不应包含在XSD和映射文件中的属性。

气象站示例

本节提供了一个配置 DataStore 气象站信息。

备注

此示例旨在说明一般方法,并不反映正式定义的架构或信息模型。此外,更复杂的情况可能需要更多的工作。

涉及的实体示意图如下所示:

../../_images/stations-diagram.png

实体图

如图所示,数据集包括:

  • 之间的一对多关系 meteo_stationsmeteo_observations 桌子。

  • 之间的多对多关系 meteo_stationsmeteo_maintainers 表,由关系表映射 meteo_stations_maintainers

  • 两国之间的多对一关系 meteo_observations 以及 meteo_parameters 桌子。

假设st工作区下有一个名为meteos-Simple的PostGIS数据存储区,通过打开Smart Data Loader页面,我们必须选择所需的工作区和属于所选工作区的postgis数据存储区,在本例中为meteos-postgis:

../../_images/store-page.png

Smart Data Loader配置页

在选择根实体作为气象站之后,将出现一个用于生成XSD和映射文件的架构。可以取消选中每个属性/实体,以避免将其包括在生成的映射中。

..图::Image/store-relations.png

Smart Data Loader配置页面-实体树

按下保存按钮后,将在下的存储数据目录中自动生成文件 app-schema-mappings 目录。

下面将解释为该示例生成的映射文件。

GML模式定义::

 <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:st="http://www.stations.org/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.stations.org/1.0" version="1.0">
 <xs:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>
 <xs:complexType name="MeteoStationsType">
   <xs:complexContent>
     <xs:extension base="gml:AbstractFeatureType">
       <xs:sequence>
         <xs:element maxOccurs="1" minOccurs="0" name="id" type="xs:int"/>
         <xs:element maxOccurs="1" minOccurs="0" name="code" type="xs:string"/>
         <xs:element maxOccurs="1" minOccurs="0" name="common_name" type="xs:string"/>
         <xs:element maxOccurs="1" minOccurs="0" name="position" type="gml:GeometryPropertyType"/>
         <xs:element maxOccurs="unbounded" minOccurs="0" name="meteoObservations" type="st:MeteoObservationsPropertyType"/>
         <xs:element maxOccurs="unbounded" minOccurs="0" name="meteoStationsMaintainers" type="st:MeteoStationsMaintainersPropertyType"/>
       </xs:sequence>
     </xs:extension>
   </xs:complexContent>
 </xs:complexType>
 <xs:element name="MeteoStationsFeature" substitutionGroup="gml:AbstractFeature" type="st:MeteoStationsType"/>
 <xs:complexType name="MeteoObservationsType">
   <xs:complexContent>
     <xs:extension base="gml:AbstractFeatureType">
       <xs:sequence>
         <xs:element maxOccurs="1" minOccurs="0" name="id" type="xs:int"/>
         <xs:element maxOccurs="1" minOccurs="0" name="time" type="xs:dateTime"/>
         <xs:element maxOccurs="1" minOccurs="0" name="value" type="xs:double"/>
         <xs:element maxOccurs="unbounded" minOccurs="0" name="meteoParameters" type="st:MeteoParametersPropertyType"/>
       </xs:sequence>
     </xs:extension>
   </xs:complexContent>
 </xs:complexType>
 <xs:element name="MeteoObservationsFeature" substitutionGroup="gml:AbstractFeature" type="st:MeteoObservationsType"/>
 <xs:complexType name="MeteoObservationsPropertyType">
   <xs:sequence minOccurs="0">
     <xs:element ref="st:MeteoObservationsFeature"/>
   </xs:sequence>
   <xs:attributeGroup ref="gml:AssociationAttributeGroup"/>
 </xs:complexType>
 <xs:complexType name="MeteoParametersType">
   <xs:complexContent>
     <xs:extension base="gml:AbstractFeatureType">
       <xs:sequence>
         <xs:element maxOccurs="1" minOccurs="0" name="id" type="xs:int"/>
         <xs:element maxOccurs="1" minOccurs="0" name="param_name" type="xs:string"/>
         <xs:element maxOccurs="1" minOccurs="0" name="param_unit" type="xs:string"/>
       </xs:sequence>
     </xs:extension>
   </xs:complexContent>
 </xs:complexType>
 <xs:element name="MeteoParametersFeature" substitutionGroup="gml:AbstractFeature" type="st:MeteoParametersType"/>
 <xs:complexType name="MeteoParametersPropertyType">
   <xs:sequence minOccurs="0">
     <xs:element ref="st:MeteoParametersFeature"/>
   </xs:sequence>
   <xs:attributeGroup ref="gml:AssociationAttributeGroup"/>
 </xs:complexType>
 <xs:complexType name="MeteoStationsMaintainersType">
   <xs:complexContent>
     <xs:extension base="gml:AbstractFeatureType">
       <xs:sequence>
         <xs:element maxOccurs="1" minOccurs="0" name="id" type="xs:int"/>
         <xs:element maxOccurs="unbounded" minOccurs="0" name="meteoMaintainers" type="st:MeteoMaintainersPropertyType"/>
       </xs:sequence>
     </xs:extension>
   </xs:complexContent>
 </xs:complexType>
 <xs:element name="MeteoStationsMaintainersFeature" substitutionGroup="gml:AbstractFeature" type="st:MeteoStationsMaintainersType"/>
 <xs:complexType name="MeteoStationsMaintainersPropertyType">
   <xs:sequence minOccurs="0">
     <xs:element ref="st:MeteoStationsMaintainersFeature"/>
   </xs:sequence>
   <xs:attributeGroup ref="gml:AssociationAttributeGroup"/>
 </xs:complexType>
 <xs:complexType name="MeteoMaintainersType">
   <xs:complexContent>
     <xs:extension base="gml:AbstractFeatureType">
       <xs:sequence>
         <xs:element maxOccurs="1" minOccurs="0" name="id" type="xs:int"/>
         <xs:element maxOccurs="1" minOccurs="0" name="name" type="xs:string"/>
         <xs:element maxOccurs="1" minOccurs="0" name="surname" type="xs:string"/>
         <xs:element maxOccurs="1" minOccurs="0" name="company" type="xs:string"/>
       </xs:sequence>
     </xs:extension>
   </xs:complexContent>
 </xs:complexType>
 <xs:element name="MeteoMaintainersFeature" substitutionGroup="gml:AbstractFeature" type="st:MeteoMaintainersType"/>
 <xs:complexType name="MeteoMaintainersPropertyType">
   <xs:sequence minOccurs="0">
     <xs:element ref="st:MeteoMaintainersFeature"/>
   </xs:sequence>
   <xs:attributeGroup ref="gml:AssociationAttributeGroup"/>
 </xs:complexType>
</xs:schema>

应用程序-架构映射文件::

 <?xml version="1.0" encoding="UTF-8"?><ns3:AppSchemaDataAccess xmlns:ns2="http://www.opengis.net/ogc" xmlns:ns3="http://www.geotools.org/app-schema">
 <namespaces>
   <Namespace>
     <prefix>gml</prefix>
     <uri>http://www.opengis.net/gml/3.2</uri>
   </Namespace>
   <Namespace>
     <prefix>st</prefix>
     <uri>http://www.stations.org/1.0</uri>
   </Namespace>
 </namespaces>
 <includedTypes/>
 <targetTypes>
   <FeatureType>
     <schemaUri>./meteo_stations-gml.xsd</schemaUri>
   </FeatureType>
 </targetTypes>
 <typeMappings>
   <FeatureTypeMapping>
     <sourceDataStore>smartappschematest</sourceDataStore>
     <sourceType>meteo_stations</sourceType>
     <targetElement>st:MeteoStationsFeature</targetElement>
     <attributeMappings>
       <AttributeMapping>
         <targetAttribute>st:MeteoStationsFeature</targetAttribute>
         <idExpression>
           <OCQL>strConcat('MeteoStationsFeature.',id)</OCQL>
         </idExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:id</targetAttribute>
         <sourceExpression>
           <OCQL>id</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:code</targetAttribute>
         <sourceExpression>
           <OCQL>code</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:common_name</targetAttribute>
         <sourceExpression>
           <OCQL>common_name</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:position</targetAttribute>
         <sourceExpression>
           <OCQL>position</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>meteoObservations</targetAttribute>
         <sourceExpression>
           <linkField>FEATURE_LINK[1]</linkField>
           <linkElement>st:MeteoObservationsFeature</linkElement>
           <OCQL>id</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>meteoStationsMaintainers</targetAttribute>
         <sourceExpression>
           <linkField>FEATURE_LINK[1]</linkField>
           <linkElement>st:MeteoStationsMaintainersFeature</linkElement>
           <OCQL>id</OCQL>
         </sourceExpression>
       </AttributeMapping>
     </attributeMappings>
   </FeatureTypeMapping>
   <FeatureTypeMapping>
     <sourceDataStore>smartappschematest</sourceDataStore>
     <sourceType>meteo_observations</sourceType>
     <targetElement>st:MeteoObservationsFeature</targetElement>
     <attributeMappings>
       <AttributeMapping>
         <targetAttribute>FEATURE_LINK[1]</targetAttribute>
         <sourceExpression>
           <OCQL>station_id</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:MeteoObservationsFeature</targetAttribute>
         <idExpression>
           <OCQL>strConcat('MeteoObservationsFeature.',id)</OCQL>
         </idExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:id</targetAttribute>
         <sourceExpression>
           <OCQL>id</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:time</targetAttribute>
         <sourceExpression>
           <OCQL>time</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:value</targetAttribute>
         <sourceExpression>
           <OCQL>value</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>meteoParameters</targetAttribute>
         <sourceExpression>
           <linkField>FEATURE_LINK[1]</linkField>
           <linkElement>st:MeteoParametersFeature</linkElement>
           <OCQL>parameter_id</OCQL>
         </sourceExpression>
       </AttributeMapping>
     </attributeMappings>
   </FeatureTypeMapping>
   <FeatureTypeMapping>
     <sourceDataStore>smartappschematest</sourceDataStore>
     <sourceType>meteo_parameters</sourceType>
     <targetElement>st:MeteoParametersFeature</targetElement>
     <attributeMappings>
       <AttributeMapping>
         <targetAttribute>FEATURE_LINK[1]</targetAttribute>
         <sourceExpression>
           <OCQL>id</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:MeteoParametersFeature</targetAttribute>
         <idExpression>
           <OCQL>strConcat('MeteoParametersFeature.',id)</OCQL>
         </idExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:id</targetAttribute>
         <sourceExpression>
           <OCQL>id</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:param_name</targetAttribute>
         <sourceExpression>
           <OCQL>param_name</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:param_unit</targetAttribute>
         <sourceExpression>
           <OCQL>param_unit</OCQL>
         </sourceExpression>
       </AttributeMapping>
     </attributeMappings>
   </FeatureTypeMapping>
   <FeatureTypeMapping>
     <sourceDataStore>smartappschematest</sourceDataStore>
     <sourceType>meteo_stations_maintainers</sourceType>
     <targetElement>st:MeteoStationsMaintainersFeature</targetElement>
     <attributeMappings>
       <AttributeMapping>
         <targetAttribute>FEATURE_LINK[1]</targetAttribute>
         <sourceExpression>
           <OCQL>station_id</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:MeteoStationsMaintainersFeature</targetAttribute>
         <idExpression>
           <OCQL>strConcat('MeteoStationsMaintainersFeature.',id)</OCQL>
         </idExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:id</targetAttribute>
         <sourceExpression>
           <OCQL>id</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>meteoMaintainers</targetAttribute>
         <sourceExpression>
           <linkField>FEATURE_LINK[1]</linkField>
           <linkElement>st:MeteoMaintainersFeature</linkElement>
           <OCQL>maintainer_id</OCQL>
         </sourceExpression>
       </AttributeMapping>
     </attributeMappings>
   </FeatureTypeMapping>
   <FeatureTypeMapping>
     <sourceDataStore>smartappschematest</sourceDataStore>
     <sourceType>meteo_maintainers</sourceType>
     <targetElement>st:MeteoMaintainersFeature</targetElement>
     <attributeMappings>
       <AttributeMapping>
         <targetAttribute>FEATURE_LINK[1]</targetAttribute>
         <sourceExpression>
           <OCQL>id</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:MeteoMaintainersFeature</targetAttribute>
         <idExpression>
           <OCQL>strConcat('MeteoMaintainersFeature.',id)</OCQL>
         </idExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:id</targetAttribute>
         <sourceExpression>
           <OCQL>id</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:name</targetAttribute>
         <sourceExpression>
           <OCQL>name</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:surname</targetAttribute>
         <sourceExpression>
           <OCQL>surname</OCQL>
         </sourceExpression>
       </AttributeMapping>
       <AttributeMapping>
         <targetAttribute>st:company</targetAttribute>
         <sourceExpression>
           <OCQL>company</OCQL>
         </sourceExpression>
       </AttributeMapping>
     </attributeMappings>
   </FeatureTypeMapping>
 </typeMappings>
 <sourceDataStores>
   <DataStore>
     <id>smartappschematest</id>
     <parameters>
       <Parameter>
         <name>schema</name>
         <value>smartappschematest</value>
       </Parameter>
       <Parameter>
         <name>database</name>
         <value>mock?sslmode=DISABLE&amp;binaryTransferEnable=bytea</value>
       </Parameter>
       <Parameter>
         <name>port</name>
         <value>5432</value>
       </Parameter>
       <Parameter>
         <name>passwd</name>
         <value>postgres</value>
       </Parameter>
       <Parameter>
         <name>Expose primary keys</name>
         <value>true</value>
       </Parameter>
       <Parameter>
         <name>dbtype</name>
         <value>postgis</value>
       </Parameter>
       <Parameter>
         <name>host</name>
         <value>localhost</value>
       </Parameter>
       <Parameter>
         <name>user</name>
         <value>postgres</value>
       </Parameter>
     </parameters>
   </DataStore>
 </sourceDataStores>
</ns3:AppSchemaDataAccess>

定制智能数据加载器生成的映射和xsd定义

Smart Data Loader不允许直接修改映射和XSD类型定义。但是,它可以用作生成配置文件的起点,这些配置文件可以根据需要进行定制。以下是针对此类用例的建议工作流:

  • 创建一个新的智能数据加载器存储,选择所需的PostGIS存储,然后选择根实体并保存它。

  • 转到Geoserver数据目录,并在配置时选择的工作空间下标识Smart Data Loader存储文件夹。一个 app-schema-mappings 目录应位于该存储文件夹中。

  • 将该目录中包含的文件复制并粘贴到另一个目录,然后根据需要进行修改。

  • 删除Smart Data Loader存储,并使用指向包含已修改文件的文件夹的uri参数创建新的App-Schema存储。