上载应用程序架构映射文件

Create a new app-schema store and update the feature type mappings of an existing app-schema store by uploading a mapping configuration file

备注

以下请求上载名为 LandCoverVector.xml 到一个名为 LandCoverVector . 如果没有 LandCoverVector 工作区中存在数据存储 lcv 在请求之前,它将被创建。

请求

卷曲

curl -v -X PUT -d @LandCoverVector.xml -H "Content-Type: text/xml"
-u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/lcv/datastores/LandCoverVector/file.appschema?configure=all

响应

201 Created

正在列出应用程序架构存储详细信息

请求

卷曲

curl -v -u admin:geoserver -X GET
http://localhost:8080/geoserver/rest/workspaces/lcv/datastores/LandCoverVector.xml

响应

<dataStore>
  <name>LandCoverVector</name>
  <type>Application Schema DataAccess</type>
  <enabled>true</enabled>
  <workspace>
    <name>lcv</name>
    <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/lcv.xml" type="application/xml"/>
  </workspace>
  <connectionParameters>
    <entry key="dbtype">app-schema</entry>
    <entry key="namespace">http://inspire.ec.europa.eu/schemas/lcv/3.0</entry>
    <entry key="url">file:/path/to/data_dir/data/lcv/LandCoverVector/LandCoverVector.appschema</entry>
  </connectionParameters>
  <__default>false</__default>
  <featureTypes>
    <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/lcv/datastores/LandCoverVector/featuretypes.xml" type="application/xml"/>
  </featureTypes>
</dataStore>

上载新的应用程序架构映射配置文件

Upload a new mapping configuration, stored in the mapping file "`LandCoverVector_alternative.xml", to the "LandCoverVector" data store

请求

卷曲

curl -v -X PUT -d @LandCoverVector_alternative.xml -H "Content-Type: text/xml"
  -u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/lcv/datastores/LandCoverVector/file.appschema?configure=none

响应

200 OK

备注

这次 configure 参数设置为 none ,因为我们不想再次配置功能类型,所以只需替换它们的映射配置。

备注

如果在新配置文件中映射的功能类型集与在旧配置文件中映射的功能类型集不同(有的丢失,有的是新的,或者两者都是),则继续操作的最佳方法是删除数据存储并在发出另一个放置请求后重新创建它。 as shown above .

上载多个应用程序架构映射文件

Create a new app-schema data store based on a complex mapping configuration split into multiple files, and show how to upload application schemas (i.e. XSD files) along with the mapping configuration.

备注

在上一个示例中,我们已经看到了如何通过上载存储在单个文件中的映射配置来创建新的应用程序架构数据存储区;这一次,由于映射已经分布在两个配置文件上,所以情况更加复杂:调用主配置文件 geosciml.appschema 并包含三种功能类型的映射: GeologicUnitMappedFeatureGeologicEvent ;调用第二个文件 cgi_termvalue.xml 并包含单个非特征类型的映射, CGI_TermValue .

备注

如中所述 REST API reference documentation for data stores ,当映射配置分布在多个文件上时,主配置文件的扩展名必须为 .appschema .

主配置文件包括第二个文件:

...
<includedTypes>
  <Include>cgi_termvalue.xml</Include>
</includedTypes>
...

我们还希望将定义映射所需的模式上载到geoserver,而不是让geoserver从Internet检索它们(这在我们的服务器无法访问Web时尤其有用)。主模式被调用 geosciml.xsd 和中提到的 geosciml.appschema 像这样的:

...
<targetTypes>
  <FeatureType>
    <schemaUri>geosciml.xsd</schemaUri>
  </FeatureType>
</targetTypes>
...

在这种情况下,主模式依赖于其他几个模式:

<include schemaLocation="geologicUnit.xsd"/>
<include schemaLocation="borehole.xsd"/>
<include schemaLocation="vocabulary.xsd"/>
<include schemaLocation="geologicRelation.xsd"/>
<include schemaLocation="fossil.xsd"/>
<include schemaLocation="value.xsd"/>
<include schemaLocation="geologicFeature.xsd"/>
<include schemaLocation="geologicAge.xsd"/>
<include schemaLocation="earthMaterial.xsd"/>
<include schemaLocation="collection.xsd"/>
<include schemaLocation="geologicStructure.xsd"/>

它们不需要列在 targetTypes 映射配置的一部分,但它们必须包含在要上载的zip存档中。

备注

上面列出的geosciml模式,以及几乎所有的应用程序模式,都引用了基本的gml模式(特别是, http://schemas.opengis.net/gml/3.1.1/base/gml.xsd )以及其他一些远程托管模式(例如 http://www.geosciml.org/cgiutilities/1.0/xsd/cgiUtilities.xsd )。为了在完全脱机的环境中工作,必须用本地引用替换所有远程引用,或者用远程架构的副本预填充应用程序架构缓存。 GeoServer's user manual 包含有关应用程序架构缓存的详细信息。

总之,我们将向geoserver上载一个包含以下内容的zip存档:

geosciml.appschema      # main mapping file
cgi_termvalue.xml       # secondary mapping file
geosciml.xsd            # main schema
borehole.xsd
collection.xsd
earthMaterial.xsd
fossil.xsd
geologicAge.xsd
geologicFeature.xsd
geologicRelation.xsd
geologicStructure.xsd
geologicUnit.xsd
value.xsd
vocabulary.xsd

请求

卷曲

curl -X PUT --data-binary @geosciml.zip -H "Content-Type: application/zip"
-u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/gsml/datastores/geosciml/file.appschema?configure=all

响应

200 OK

一个新的 geosciml 将创建数据存储,其中包含三种功能类型:

<featureTypes>
  <featureType>
    <name>MappedFeature</name>
    <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/gsml/datastores/geosciml/featuretypes/MappedFeature.xml" type="application/xml"/>
  </featureType>
  <featureType>
    <name>GeologicEvent</name>
    <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/gsml/datastores/geosciml/featuretypes/GeologicEvent.xml" type="application/xml"/>
  </featureType>
  <featureType>
    <name>GeologicUnit</name>
    <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/gsml/datastores/geosciml/featuretypes/GeologicUnit.xml" type="application/xml"/>
  </featureType>
</featureTypes>

正在清除内部MongoDB存储上的架构

清除内部MongoDB存储上的持久化模式,允许它从数据生成新的模式。

请求模板

卷曲

curl -v -X POST
  -u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/{WORKSPACE}/appschemastores/{APP_SCHEMA_STORE_NAME}/datastores/{INTERNAL_STORE_ID}/cleanSchemas

请求

卷曲

curl -v -X POST
  -u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/st/appschemastores/AppSchemaStoreName/datastores/store_id/cleanSchemas

响应

200 OK

清除所有内部MongoDB存储上的持久化模式,允许它从数据生成它们。

请求模板

卷曲

curl -v -X POST
  -u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/{WORKSPACE}/appschemastores/{APP_SCHEMA_STORE_NAME}/cleanSchemas

请求

卷曲

curl -v -X POST
  -u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/st/appschemastores/AppSchemaStoreName/cleanSchemas

响应

200 OK

在内部MongoDB存储上重建持久化模式,允许它从数据和查询参数生成它们。

请求模板

卷曲

curl -v -X POST
  -u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/{WORKSPACE}/appschemastores/{APP_SCHEMA_STORE_NAME}/datastores/{INTERNAL_STORE_ID}/rebuildMongoSchemas?ids={ID_1},{ID_2}&max={MAX_OBJECTS}
  • id:comma分隔的mongodb json对象id,用于查询以生成架构。如果设置了“max”,则不需要。

  • max:生成模式时要获取的MongoDB JSON对象的最大数目。如果设置了“ID”,则不需要。

请求

卷曲

curl -v -X POST
  -u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/st/appschemastores/AppSchemaStoreName/datastores/store_id/rebuildMongoSchemas?ids=58e5889ce4b02461ad5af081,58e5889ce4b02461ad5af080&max=5

响应

200 OK

在所有内部MongoDB存储上重建持久化模式,允许它从数据和查询参数生成它们。

请求模板

卷曲

curl -v -X POST
  -u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/{WORKSPACE}/appschemastores/{APP_SCHEMA_STORE_NAME}/rebuildMongoSchemas?ids={ID_1},{ID_2}&max={MAX_OBJECTS}
  • id:comma分隔的mongodb json对象id,用于查询以生成架构。如果设置了“max”,则不需要。

  • max:生成模式时要获取的MongoDB JSON对象的最大数目。如果设置了“ID”,则不需要。

请求

卷曲

curl -v -X POST
  -u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/st/appschemastores/AppSchemaStoreName/rebuildMongoSchemas?ids=58e5889ce4b02461ad5af081,58e5889ce4b02461ad5af080&max=5

响应

200 OK

备注

只有在geoserver上安装了app-schema和mongodb模块,并且所涉及的app-schema存储在映射定义中具有内部mongodb存储时,此endpoin才可用。