Skip to content

Commit

Permalink
[GEOS-9241] Enhance mongodb schema generation. (#3561)
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandor777 authored and Nuno Oliveira committed Jun 24, 2019
1 parent c808fe1 commit 94856e3
Show file tree
Hide file tree
Showing 12 changed files with 745 additions and 4 deletions.
115 changes: 114 additions & 1 deletion doc/en/api/1.0.0/datastores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,120 @@ paths:
responses:
405:
description: Method Not Allowed

/workspaces/{workspaceName}/appschemastores/{storeName}/cleanSchemas:
post:
operationId: cleanAllMongoSchemas
summary: Cleans all MongoDB internal stores Schemas for an App-Schema store.
description: Cleans all MongoDB internal stores Schemas for an App-Schema store.
produces:
- text/plain
parameters:
- name: workspaceName
in: path
required: true
type: string
description: The name of the worskpace containing the data stores.
- name: storeName
in: path
required: true
description: The name of the App-Schema store
type: string
responses:
200:
description: OK
/workspaces/{workspaceName}/appschemastores/{storeName}/datastores/{internalStoreId}/cleanSchemas:
post:
operationId: cleanMongoSchema
summary: Cleans a MongoDB internal store Schemas for an App-Schema store.
description: Cleans a MongoDB internal store Schemas for an App-Schema store.
produces:
- text/plain
parameters:
- name: workspaceName
in: path
required: true
type: string
description: The name of the worskpace containing the data stores.
- name: storeName
in: path
required: true
description: The name of the App-Schema store
type: string
- name: internalStoreId
in: path
required: true
description: The store ID for the internal MongoDB store as specified on App-Schema Mappings.
type: string
responses:
200:
description: OK
/workspaces/{workspaceName}/appschemastores/{storeName}/rebuildMongoSchemas:
post:
operationId: rebuildAllMongoSchemas
summary: Rebuilds all MongoDB internal stores Schemas for an App-Schema store.
description: Rebuilds all MongoDB internal stores Schemas for an App-Schema store.
produces:
- text/plain
parameters:
- name: workspaceName
in: path
required: true
type: string
description: The name of the worskpace containing the data stores.
- name: storeName
in: path
required: true
description: The name of the App-Schema store
type: string
- name: ids
in: query
required: false
description: Comma separated MongoDB object IDs for use in new generated schema.
type: string
- name: max
in: query
required: false
description: Max number of objects for use in new generated schema.
type: integer
responses:
200:
description: OK
/workspaces/{workspaceName}/appschemastores/{storeName}/datastores/{internalStoreId}/rebuildMongoSchemas:
post:
operationId: rebuildMongoSchema
summary: Rebuilds a MongoDB internal store Schemas for an App-Schema store.
description: Rebuilds a MongoDB internal store Schemas for an App-Schema store.
produces:
- text/plain
parameters:
- name: workspaceName
in: path
required: true
type: string
description: The name of the worskpace containing the data stores.
- name: storeName
in: path
required: true
description: The name of the App-Schema store
type: string
- name: internalStoreId
in: path
required: true
description: The store ID for the internal MongoDB store as specified on App-Schema Mappings.
type: string
- name: ids
in: query
required: false
description: Comma separated MongoDB object IDs for use in new generated schema.
type: string
- name: max
in: query
required: false
description: Max number of objects for use in new generated schema.
type: integer
responses:
200:
description: OK
parameters:
dataStorePost:
name: dataStoreBody
Expand Down
117 changes: 116 additions & 1 deletion doc/en/user/source/rest/appschema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,119 @@ A new ``geosciml`` data store will be created with three feature types in it:
<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>
</featureTypes>
Cleaning schemas on internal MongoDB stores
-------------------------------------------

**Clean persisted schema on an internal MongoDB Store, allowing it to generate a new one from data.**

*Request template*

.. admonition:: curl

::

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

.. admonition:: curl

::

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

*Response*

::

200 OK
**Clean persisted schema on all internal MongoDB Stores, allowing it to generate them from data.**

*Request template*

.. admonition:: curl

::

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

.. admonition:: curl

::

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

*Response*

::

200 OK
**Rebuild persisted schema on internal MongoDB Store, allowing it to generate them from data and query parameters.**

*Request template*

.. admonition:: curl

::

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}
- ids: Comma separated MongoDB JSON objects ids to query for generating schemas. Not required if the 'max' is setted.
- max: Max number of MongoDB JSON objects to get for generating schemas. Not required if the 'ids' is setted.

*Request*

.. admonition:: curl

::

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

*Response*

::

200 OK
**Rebuild persisted schema on all internal MongoDB Stores, allowing it to generate them from data and query parameters.**

*Request template*

.. admonition:: curl

::

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}
- ids: Comma separated MongoDB JSON objects ids to query for generating schemas. Not required if the 'max' is setted.
- max: Max number of MongoDB JSON objects to get for generating schemas. Not required if the 'ids' is setted.

*Request*

.. admonition:: curl

::

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

*Response*

::

200 OK
.. note:: This endpoins are only available when App-Schema and MongoDB modules are installed on Geoserver, and involved app-schema store have internal MongoDB stores in mappings definition.
5 changes: 5 additions & 0 deletions src/extension/app-schema/app-schema-mongo-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<groupId>org.geoserver</groupId>
<artifactId>gs-wfs</artifactId>
</dependency>
<dependency>
<groupId>org.geoserver.extension</groupId>
<artifactId>gs-mongodb</artifactId>
<version>${gs.version}</version>
</dependency>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>gs-wms</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ public abstract class ComplexMongoDBSupport extends GeoServerSystemTestSupport {
private static final Logger LOGGER =
org.geotools.util.logging.Logging.getLogger(ComplexMongoDBSupport.class);

private static final Path ROOT_DIRECTORY = createTempDir();
protected static final Path ROOT_DIRECTORY = createTempDir();

private static File APP_SCHEMA_MAPPINGS;

protected static final String STATIONS_STORE_NAME = UUID.randomUUID().toString();
private static final String STATIONS_DATA_BASE_NAME = UUID.randomUUID().toString();
private static final String STATIONS_COLLECTION_NAME = "stations";

Expand Down Expand Up @@ -141,7 +142,7 @@ protected void onSetUp(SystemTestData testData) throws Exception {
params.put("dbtype", "app-schema");
params.put("url", "file:" + APP_SCHEMA_MAPPINGS.getAbsolutePath());
DataStoreInfoImpl dataStore = new DataStoreInfoImpl(getCatalog());
dataStore.setName(UUID.randomUUID().toString());
dataStore.setName(STATIONS_STORE_NAME);
dataStore.setType("app-schema");
dataStore.setConnectionParameters(params);
dataStore.setWorkspace(workspace);
Expand Down

0 comments on commit 94856e3

Please sign in to comment.