{ "cells": [ { "cell_type": "markdown", "id": "64e0639b-c024-49eb-93ef-3c67539dec34", "metadata": { "tags": [] }, "source": [ "# gCube CMS\n", "\n", "gCube CMS is a software application that allows users to collaborate in the creation, editing, and production of complex digital components called Projects." ] }, { "cell_type": "markdown", "id": "be945c2c-1b00-44a9-890f-bde5be45ad38", "metadata": {}, "source": [ "The application is built on top of gCube Infrastructure features, for maximum integration with Virtual Research Environments (VREs) and supports : \n", "- Complex Data Management : Projects are made of core Metadata, custom Metadata, multiple linked FileSets\n", "- Versioning, Workflows, Access Policies integrated with the Infrastructure User Role Management\n", "- Materializations (e.g. SDI Layer, Image Thumbnail, DBMS)\n", "- Indexing (e.g. GIS Catalogues, Centroids Layer, CKAN catalogue)\n", "- Event Triggering (e.g. Notifications)\n", "\n", "The application is comprised of various components, including : \n", "- GUIs to facilitate end users in managing and consuming Projects\n", "- Service implemented the core business logic\n", "- Plugins set of modular logic implementations (both general-purpose and custom-made) aimed at dealing with Projects Lifecycle Phases and Events\n", "\n", "![Concept](https://gcube.wiki.gcube-system.org/images_gcube/a/a3/DataCube.png)" ] }, { "cell_type": "markdown", "id": "6c2330c5-12d7-49c6-ad50-c66e6d548e7d", "metadata": { "tags": [] }, "source": [ "## Parameters Init\n", "\n", "Customize this section for different notebook behaviour and initialization." ] }, { "cell_type": "code", "execution_count": 1, "id": "fcc15ae5-fc3f-4146-b77c-bf23231c9ae6", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: simplejson in /opt/conda/lib/python3.9/site-packages (3.17.6)\n", "Requirement already satisfied: rich[jupyter] in /opt/conda/lib/python3.9/site-packages (12.2.0)\n", "Requirement already satisfied: commonmark<0.10.0,>=0.9.0 in /opt/conda/lib/python3.9/site-packages (from rich[jupyter]) (0.9.1)\n", "Requirement already satisfied: pygments<3.0.0,>=2.6.0 in /opt/conda/lib/python3.9/site-packages (from rich[jupyter]) (2.11.2)\n", "Requirement already satisfied: ipywidgets<8.0.0,>=7.5.1 in /opt/conda/lib/python3.9/site-packages (from rich[jupyter]) (7.7.0)\n", "Requirement already satisfied: jupyterlab-widgets>=1.0.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (1.1.0)\n", "Requirement already satisfied: ipython-genutils~=0.2.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.2.0)\n", "Requirement already satisfied: nbformat>=4.2.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (5.2.0)\n", "Requirement already satisfied: traitlets>=4.3.1 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (5.1.1)\n", "Requirement already satisfied: ipython>=4.0.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (8.2.0)\n", "Requirement already satisfied: widgetsnbextension~=3.6.0 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (3.6.0)\n", "Requirement already satisfied: ipykernel>=4.5.1 in /opt/conda/lib/python3.9/site-packages (from ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (6.11.0)\n", "Requirement already satisfied: jupyter-client>=6.1.12 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (7.2.1)\n", "Requirement already satisfied: tornado>=6.1 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (6.1)\n", "Requirement already satisfied: psutil in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (5.9.0)\n", "Requirement already satisfied: setuptools>=60 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (61.3.1)\n", "Requirement already satisfied: matplotlib-inline>=0.1 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.1.3)\n", "Requirement already satisfied: debugpy>=1.0 in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (1.5.1)\n", "Requirement already satisfied: nest-asyncio in /opt/conda/lib/python3.9/site-packages (from ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (1.5.5)\n", "Requirement already satisfied: pexpect>4.3 in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (4.8.0)\n", "Requirement already satisfied: jedi>=0.16 in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.18.1)\n", "Requirement already satisfied: backcall in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.2.0)\n", "Requirement already satisfied: stack-data in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.2.0)\n", "Requirement already satisfied: pickleshare in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.7.5)\n", "Requirement already satisfied: decorator in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (5.1.1)\n", "Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /opt/conda/lib/python3.9/site-packages (from ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (3.0.27)\n", "Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /opt/conda/lib/python3.9/site-packages (from nbformat>=4.2.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (4.4.0)\n", "Requirement already satisfied: jupyter-core in /opt/conda/lib/python3.9/site-packages (from nbformat>=4.2.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (4.9.2)\n", "Requirement already satisfied: notebook>=4.4.1 in /opt/conda/lib/python3.9/site-packages (from widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (6.4.10)\n", "Requirement already satisfied: parso<0.9.0,>=0.8.0 in /opt/conda/lib/python3.9/site-packages (from jedi>=0.16->ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.8.3)\n", "Requirement already satisfied: attrs>=17.4.0 in /opt/conda/lib/python3.9/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (21.4.0)\n", "Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /opt/conda/lib/python3.9/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.18.1)\n", "Requirement already satisfied: python-dateutil>=2.8.2 in /opt/conda/lib/python3.9/site-packages (from jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (2.8.2)\n", "Requirement already satisfied: entrypoints in /opt/conda/lib/python3.9/site-packages (from jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.4)\n", "Requirement already satisfied: pyzmq>=22.3 in /opt/conda/lib/python3.9/site-packages (from jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (22.3.0)\n", "Requirement already satisfied: terminado>=0.8.3 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.13.3)\n", "Requirement already satisfied: Send2Trash>=1.8.0 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (1.8.0)\n", "Requirement already satisfied: jinja2 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (3.1.1)\n", "Requirement already satisfied: argon2-cffi in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (21.3.0)\n", "Requirement already satisfied: nbconvert>=5 in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (6.4.5)\n", "Requirement already satisfied: prometheus-client in /opt/conda/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.13.1)\n", "Requirement already satisfied: ptyprocess>=0.5 in /opt/conda/lib/python3.9/site-packages (from pexpect>4.3->ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.7.0)\n", "Requirement already satisfied: wcwidth in /opt/conda/lib/python3.9/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.2.5)\n", "Requirement already satisfied: asttokens in /opt/conda/lib/python3.9/site-packages (from stack-data->ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (2.0.5)\n", "Requirement already satisfied: executing in /opt/conda/lib/python3.9/site-packages (from stack-data->ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.8.3)\n", "Requirement already satisfied: pure-eval in /opt/conda/lib/python3.9/site-packages (from stack-data->ipython>=4.0.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.2.2)\n", "Requirement already satisfied: beautifulsoup4 in /opt/conda/lib/python3.9/site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (4.10.0)\n", "Requirement already satisfied: bleach in /opt/conda/lib/python3.9/site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (4.1.0)\n", "Requirement already satisfied: mistune<2,>=0.8.1 in /opt/conda/lib/python3.9/site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.8.4)\n", "Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in /opt/conda/lib/python3.9/site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.5.13)\n", "Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.9/site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (2.1.1)\n", "Requirement already satisfied: testpath in /opt/conda/lib/python3.9/site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.6.0)\n", "Requirement already satisfied: defusedxml in /opt/conda/lib/python3.9/site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.7.1)\n", "Requirement already satisfied: jupyterlab-pygments in /opt/conda/lib/python3.9/site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.1.2)\n", "Requirement already satisfied: pandocfilters>=1.4.1 in /opt/conda/lib/python3.9/site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (1.5.0)\n", "Requirement already satisfied: six>=1.5 in /opt/conda/lib/python3.9/site-packages (from python-dateutil>=2.8.2->jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (1.16.0)\n", "Requirement already satisfied: argon2-cffi-bindings in /opt/conda/lib/python3.9/site-packages (from argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (21.2.0)\n", "Requirement already satisfied: cffi>=1.0.1 in /opt/conda/lib/python3.9/site-packages (from argon2-cffi-bindings->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (1.15.0)\n", "Requirement already satisfied: soupsieve>1.2 in /opt/conda/lib/python3.9/site-packages (from beautifulsoup4->nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (2.3.1)\n", "Requirement already satisfied: webencodings in /opt/conda/lib/python3.9/site-packages (from bleach->nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (0.5.1)\n", "Requirement already satisfied: packaging in /opt/conda/lib/python3.9/site-packages (from bleach->nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (21.3)\n", "Requirement already satisfied: pycparser in /opt/conda/lib/python3.9/site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (2.21)\n", "Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /opt/conda/lib/python3.9/site-packages (from packaging->bleach->nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.6.0->ipywidgets<8.0.0,>=7.5.1->rich[jupyter]) (3.0.7)\n" ] } ], "source": [ "%run commons.ipynb" ] }, { "cell_type": "markdown", "id": "2b565fd2-4884-4a01-a6f7-300ea8fd7028", "metadata": { "tags": [] }, "source": [ "# Projects\n", "\n", "Projects are the main entities in gCube CMS. They represent a complex document comprising of its metadata, its datasets, and related information aimed at properly consume them.\\ \n", "The present section guides through the management of CMS Projects, explaining it's model and all supported operations." ] }, { "cell_type": "markdown", "id": "be47ca27-fc7b-42f5-9a54-0d01d59221e3", "metadata": {}, "source": [ "Projects enacapsulate user's JSON Document in a richer format comprising : \n", "- Core Metadata : Metadata information used by the service to manage the project lifecycle\n", "- The Document : A JSON Object compliant to user's defined schema, reporting both \n", " - The actual metadata regarding the managed documents\n", " - Attachments references to payloads and generated materializations\n", "\n", "Projects are linked to Use Case Descriptors (UCD), which define how its Document contents are gonna be treated in the system.\n", "\n", "More detailed informations can be found at https://gcube.wiki.gcube-system.org/gcube/GeoPortal_Service\n", "\n", "NB: In this notebook we are going to use the UCD \"basicUCD\". If you want to learn more about UCDs, please refer to wiki pages or related notebooks.\n", "\n", "NB: User can experiment with different UCDs but they need to be published in the current infrastructure's Context." ] }, { "cell_type": "markdown", "id": "0a949821-435a-4b33-8ed0-2e45049be441", "metadata": { "tags": [] }, "source": [ "## Create New\n", "Start This tutorial by creating your new Project." ] }, { "cell_type": "markdown", "id": "ecabb6d7-d86c-4682-8c01-5024e7bf76a1", "metadata": {}, "source": [ "In this section we are going to create a new simple document and inspect the result. \n", "You will learn the basic sections of a Project Metadata and their meaning.\n", "\n", "It is sufficient to perform a post operation with our document as the body.\n", "\n", "The REST base endpoint for managing projects is SERVICE_BASE_ENDPOINT/projects/UCID where:\\\n", "- SERVICE_BASE_ENDPOINT should be discovered from the infrastructure's Information System\n", "- UCID is the ID of the Use Case Descriptor to be used with this project" ] }, { "cell_type": "code", "execution_count": 2, "id": "1cf34b3e-56ca-43c7-8206-3e16cebb80e0", "metadata": {}, "outputs": [], "source": [ "# Edit this section to customize your document\n", "doc={\"myTitle\":\"Some Big Title\"}" ] }, { "cell_type": "code", "execution_count": 3, "id": "ba665887-9718-44ee-be51-62283fa2dbb2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "GOING TO SEND POST REQUEST TO https://geoportal.dev.int.d4science.net/geoportal-service/srv/projects/basic\n", "Data is {\"myTitle\": \"Some Big Title\"}\n", "RESPONSE STATUS 200\n", "Resulting project is \n" ] }, { "data": { "text/html": [ "
{\n", " \"_id\": \"625042b202ad3d6126dfe5b5\",\n", " \"_version\": \"1.0.0\",\n", " \"_info\": {\n", " \"_creationInfo\": {\n", " \"_user\": {\n", " \"_username\": \"FAKE\"\n", " },\n", " \"_context\": {\n", " \"_id\": \"/gcube/devsec/devVRE\",\n", " \"_name\": \"/devVRE\"\n", " },\n", " \"_instant\": \"2022-04-08T16:12:01.449\"\n", " },\n", " \"_lastEditInfo\": null,\n", " \"_access\": {\n", " \"_policy\": \"OPEN\",\n", " \"_license\": \"\"\n", " }\n", " },\n", " \"_profileID\": \"basic\",\n", " \"_profileVersion\": \"1.0.0\",\n", " \"_lifecycleInformation\": {\n", " \"_phase\": \"DRAFT\",\n", " \"_lastInvokedStep\": null,\n", " \"_lastOperationStatus\": \"OK\",\n", " \"_errorMessages\": [],\n", " \"_warningMessages\": [],\n", " \"_triggeredEvents\": [\n", " {\n", " \"event\": \"INIT_DOCUMENT\",\n", " \"lastOperationStatus\": \"OK\",\n", " \"errorMessages\": null,\n", " \"warningMessages\": null\n", " }\n", " ],\n", " \"_notes\": null\n", " },\n", " \"_relationships\": null,\n", " \"_spatialReference\": null,\n", " \"_temporalReference\": null,\n", " \"_theDocument\": {\n", " \"myTitle\": \"Some Big Title\"\n", " },\n", " \"_lock\": null\n", "}\n", "\n" ], "text/plain": [ "\u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_id\"\u001b[0m: \u001b[32m\"625042b202ad3d6126dfe5b5\"\u001b[0m,\n", " \u001b[1;34m\"_version\"\u001b[0m: \u001b[32m\"1.0.0\"\u001b[0m,\n", " \u001b[1;34m\"_info\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_creationInfo\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_user\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_username\"\u001b[0m: \u001b[32m\"FAKE\"\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1;34m\"_context\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_id\"\u001b[0m: \u001b[32m\"/gcube/devsec/devVRE\"\u001b[0m,\n", " \u001b[1;34m\"_name\"\u001b[0m: \u001b[32m\"/devVRE\"\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1;34m\"_instant\"\u001b[0m: \u001b[32m\"2022-04-08T16:12:01.449\"\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1;34m\"_lastEditInfo\"\u001b[0m: \u001b[3;35mnull\u001b[0m,\n", " \u001b[1;34m\"_access\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_policy\"\u001b[0m: \u001b[32m\"OPEN\"\u001b[0m,\n", " \u001b[1;34m\"_license\"\u001b[0m: \u001b[32m\"\"\u001b[0m\n", " \u001b[1m}\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1;34m\"_profileID\"\u001b[0m: \u001b[32m\"basic\"\u001b[0m,\n", " \u001b[1;34m\"_profileVersion\"\u001b[0m: \u001b[32m\"1.0.0\"\u001b[0m,\n", " \u001b[1;34m\"_lifecycleInformation\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_phase\"\u001b[0m: \u001b[32m\"DRAFT\"\u001b[0m,\n", " \u001b[1;34m\"_lastInvokedStep\"\u001b[0m: \u001b[3;35mnull\u001b[0m,\n", " \u001b[1;34m\"_lastOperationStatus\"\u001b[0m: \u001b[32m\"OK\"\u001b[0m,\n", " \u001b[1;34m\"_errorMessages\"\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", " \u001b[1;34m\"_warningMessages\"\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", " \u001b[1;34m\"_triggeredEvents\"\u001b[0m: \u001b[1m[\u001b[0m\n", " \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"event\"\u001b[0m: \u001b[32m\"INIT_DOCUMENT\"\u001b[0m,\n", " \u001b[1;34m\"lastOperationStatus\"\u001b[0m: \u001b[32m\"OK\"\u001b[0m,\n", " \u001b[1;34m\"errorMessages\"\u001b[0m: \u001b[3;35mnull\u001b[0m,\n", " \u001b[1;34m\"warningMessages\"\u001b[0m: \u001b[3;35mnull\u001b[0m\n", " \u001b[1m}\u001b[0m\n", " \u001b[1m]\u001b[0m,\n", " \u001b[1;34m\"_notes\"\u001b[0m: \u001b[3;35mnull\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1;34m\"_relationships\"\u001b[0m: \u001b[3;35mnull\u001b[0m,\n", " \u001b[1;34m\"_spatialReference\"\u001b[0m: \u001b[3;35mnull\u001b[0m,\n", " \u001b[1;34m\"_temporalReference\"\u001b[0m: \u001b[3;35mnull\u001b[0m,\n", " \u001b[1;34m\"_theDocument\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"myTitle\"\u001b[0m: \u001b[32m\"Some Big Title\"\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1;34m\"_lock\"\u001b[0m: \u001b[3;35mnull\u001b[0m\n", "\u001b[1m}\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "project= send(method=\"POST\",dest=projects_endpoint,data=json.dumps(doc))\n", "\n", "print(\"Resulting project is \")\n", "print_json(data=project)" ] }, { "cell_type": "markdown", "id": "6c58326a-7f6f-45cf-a963-4fdb19fe42e0", "metadata": { "tags": [] }, "source": [ "## Core Metadata Section\n", "Registered JSON Documents are wrapped in Projects, which Let's inspect the registered JSON object structure and the most useful information in it." ] }, { "cell_type": "markdown", "id": "62cbd63b-0007-428c-82d6-643b6da4577e", "metadata": {}, "source": [ "The field _theDocument represents our document of interest.\n", "\n", "NB : Depending on the linked UCD, the returned document might be different from the output.\\\n", "This is due to the fact that the UCD is configured to automatically perform some operation at creation time (e.g. \"set defaults values\")" ] }, { "cell_type": "code", "execution_count": 4, "id": "2b0076fa-0ab5-44a5-b069-2fdc0d6d70be", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
{\n", " \"myTitle\": \"Some Big Title\"\n", "}\n", "\n" ], "text/plain": [ "\u001b[1m{\u001b[0m\n", " \u001b[1;34m\"myTitle\"\u001b[0m: \u001b[32m\"Some Big Title\"\u001b[0m\n", "\u001b[1m}\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "print_json(data=project[\"_theDocument\"])" ] }, { "cell_type": "markdown", "id": "e2388067-b608-4932-8a9a-573bb07547c4", "metadata": { "tags": [] }, "source": [ "### ID\n", "The field _id is the unique identifier of the project.\\\n", "We are gonna use it for all REST operations that involves our project." ] }, { "cell_type": "code", "execution_count": 5, "id": "8e2fd339-4117-49d4-9a3c-d9463d35ba2d", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\"625042b202ad3d6126dfe5b5\"\n",
"
\n"
],
"text/plain": [
"\u001b[32m\"625042b202ad3d6126dfe5b5\"\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"print_json(data=project[\"_id\"])"
]
},
{
"cell_type": "markdown",
"id": "d6e89eb2-8eaa-40c3-a058-dd9f44de3d12",
"metadata": {
"tags": []
},
"source": [
"### Accounting Information\n",
"\n",
"The field _info contains the following accounting information related to the project : \n",
"- _creationInfo : user, context and instant of creation\n",
"- _lastEditInfo : user, context and instant of last edit operation\n",
"- _access : project access policy (can be OPEN, RESTRICTED or EMBARGOED), project license"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "228daf3a-ec36-403c-84f4-dc7ff1fde026",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"{\n", " \"_creationInfo\": {\n", " \"_user\": {\n", " \"_username\": \"FAKE\"\n", " },\n", " \"_context\": {\n", " \"_id\": \"/gcube/devsec/devVRE\",\n", " \"_name\": \"/devVRE\"\n", " },\n", " \"_instant\": \"2022-04-08T16:12:01.449\"\n", " },\n", " \"_lastEditInfo\": null,\n", " \"_access\": {\n", " \"_policy\": \"OPEN\",\n", " \"_license\": \"\"\n", " }\n", "}\n", "\n" ], "text/plain": [ "\u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_creationInfo\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_user\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_username\"\u001b[0m: \u001b[32m\"FAKE\"\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1;34m\"_context\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_id\"\u001b[0m: \u001b[32m\"/gcube/devsec/devVRE\"\u001b[0m,\n", " \u001b[1;34m\"_name\"\u001b[0m: \u001b[32m\"/devVRE\"\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1;34m\"_instant\"\u001b[0m: \u001b[32m\"2022-04-08T16:12:01.449\"\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1;34m\"_lastEditInfo\"\u001b[0m: \u001b[3;35mnull\u001b[0m,\n", " \u001b[1;34m\"_access\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_policy\"\u001b[0m: \u001b[32m\"OPEN\"\u001b[0m,\n", " \u001b[1;34m\"_license\"\u001b[0m: \u001b[32m\"\"\u001b[0m\n", " \u001b[1m}\u001b[0m\n", "\u001b[1m}\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "print_json(data=project[\"_info\"])" ] }, { "cell_type": "markdown", "id": "5153e2ae-931c-4040-bb15-481a58a6d755", "metadata": { "tags": [] }, "source": [ "### Lifecycle Information \n", "The field _lifecycleInformation contains the a structured report of the status of the project containing: \n", "- _phase : The workflow phase in which the document is at the moment\n", "- _lastInvokedStep : Report on the last executed workflow STEP\n", "- _triggeredEvents : Collections of reports regarding the triggered events\n", "- _notes : User defined notes on the status of the project\n", "- _errorMessages : Human readable error messages, if any\n", "- _warningMessages : Human readable warning messages, if any\n", "\n", "See Plugins section for more information." ] }, { "cell_type": "code", "execution_count": 7, "id": "d2059a6e-b1a5-484a-a48e-16158d6015d5", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
{\n", " \"_phase\": \"DRAFT\",\n", " \"_lastInvokedStep\": null,\n", " \"_lastOperationStatus\": \"OK\",\n", " \"_errorMessages\": [],\n", " \"_warningMessages\": [],\n", " \"_triggeredEvents\": [\n", " {\n", " \"event\": \"INIT_DOCUMENT\",\n", " \"lastOperationStatus\": \"OK\",\n", " \"errorMessages\": null,\n", " \"warningMessages\": null\n", " }\n", " ],\n", " \"_notes\": null\n", "}\n", "\n" ], "text/plain": [ "\u001b[1m{\u001b[0m\n", " \u001b[1;34m\"_phase\"\u001b[0m: \u001b[32m\"DRAFT\"\u001b[0m,\n", " \u001b[1;34m\"_lastInvokedStep\"\u001b[0m: \u001b[3;35mnull\u001b[0m,\n", " \u001b[1;34m\"_lastOperationStatus\"\u001b[0m: \u001b[32m\"OK\"\u001b[0m,\n", " \u001b[1;34m\"_errorMessages\"\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", " \u001b[1;34m\"_warningMessages\"\u001b[0m: \u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n", " \u001b[1;34m\"_triggeredEvents\"\u001b[0m: \u001b[1m[\u001b[0m\n", " \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"event\"\u001b[0m: \u001b[32m\"INIT_DOCUMENT\"\u001b[0m,\n", " \u001b[1;34m\"lastOperationStatus\"\u001b[0m: \u001b[32m\"OK\"\u001b[0m,\n", " \u001b[1;34m\"errorMessages\"\u001b[0m: \u001b[3;35mnull\u001b[0m,\n", " \u001b[1;34m\"warningMessages\"\u001b[0m: \u001b[3;35mnull\u001b[0m\n", " \u001b[1m}\u001b[0m\n", " \u001b[1m]\u001b[0m,\n", " \u001b[1;34m\"_notes\"\u001b[0m: \u001b[3;35mnull\u001b[0m\n", "\u001b[1m}\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "print_json(data=project[\"_lifecycleInformation\"])" ] }, { "cell_type": "markdown", "id": "14e0d68a-df8f-434c-9f82-d04bd2ea31d2", "metadata": {}, "source": [ "### Spatial Reference\n", "The field _spatialReference contains a GEOJSON geometry identifying the Project." ] }, { "cell_type": "markdown", "id": "454d5dab-73aa-4fe7-ac44-f42aff1ba679", "metadata": {}, "source": [ "E.g. like the following : \n", "\n", "```json\n", "\"_spatialReference\":\n", " {\n", " \"type\": \"Point\",\n", " \"bbox\":\n", " [\n", " 8.621178639172953,\n", " 40.62975046683799,\n", " 40.630257904721645,\n", " 8.62091913167495\n", " ],\n", " \"coordinates\":\n", " [\n", " -32.00907926554869,\n", " -32.00883133516304\n", " ]\n", " }\n", "```\n" ] }, { "cell_type": "markdown", "id": "a533d6f9-6b3d-429f-acfd-d35c6f1f83c1", "metadata": {}, "source": [ "### Temporal Reference \n", "TBD" ] }, { "cell_type": "markdown", "id": "83850b57-8d2c-47e5-ba48-c213f53493fa", "metadata": { "tags": [] }, "source": [ "## Editing a project\n", "Edit the Document section of a Project. " ] }, { "cell_type": "markdown", "id": "e38ae8ec-6aa9-4932-b052-69f8a6a9132a", "metadata": {}, "source": [ "The Document section is the actual document that needs to be managed, and the most basic operation is updating it.\\\n", "To do this it's sufficient to perform a put operation with our document as the body, specifying our project's ID\n", "\n", "The endpoint for this operation is going to be SERVICE_BASE_ENDPOINT/projects/UCID/ID where:\n", "- SERVICE_BASE_ENDPOINT should be discovered from the infrastructure's Information System\n", "- UCID is the ID of the Use Case Descriptor to be used with this project\n", "- ID is our project Unique Identifier" ] }, { "cell_type": "code", "execution_count": 8, "id": "4323986d-218f-4997-9fe0-c9ba9e3e3c84", "metadata": {}, "outputs": [], "source": [ "#We update our document nesting a sub section in it\n", "doc={\n", " \"myTitle\":\"My newer edited title\",\n", " \"section\":{\"sectionTitle\":\"My new SubSection\"}\n", "}" ] }, { "cell_type": "code", "execution_count": 9, "id": "6123e5e5-9150-47bd-a49a-b2bc21915d34", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "GOING TO SEND PUT REQUEST TO https://geoportal.dev.int.d4science.net/geoportal-service/srv/projects/basic/625042b202ad3d6126dfe5b5\n", "Data is {\"myTitle\": \"My newer edited title\", \"section\": {\"sectionTitle\": \"My new SubSection\"}}\n", "RESPONSE STATUS 200\n" ] }, { "data": { "text/html": [ "
{\n", " \"myTitle\": \"My newer edited title\",\n", " \"section\": {\n", " \"sectionTitle\": \"My new SubSection\"\n", " }\n", "}\n", "\n" ], "text/plain": [ "\u001b[1m{\u001b[0m\n", " \u001b[1;34m\"myTitle\"\u001b[0m: \u001b[32m\"My newer edited title\"\u001b[0m,\n", " \u001b[1;34m\"section\"\u001b[0m: \u001b[1m{\u001b[0m\n", " \u001b[1;34m\"sectionTitle\"\u001b[0m: \u001b[32m\"My new SubSection\"\u001b[0m\n", " \u001b[1m}\u001b[0m\n", "\u001b[1m}\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# NB uncomment to actually perform edit\n", "project = send(method=\"PUT\",data=json.dumps(doc),dest=projects_endpoint+\"/\"+str(project[\"_id\"]))\n", "print_json(data=project[\"_theDocument\"])" ] }, { "cell_type": "markdown", "id": "5a3d20fc-dd8a-4d14-ab9b-36d80bad77fc", "metadata": { "tags": [] }, "source": [ "## Upload Attachments : FileSets\n", "Projects' documents can contain multiple collections of files called FileSet." ] }, { "cell_type": "markdown", "id": "11dfedd2-bebd-420e-87b5-06b37bdd9327", "metadata": {}, "source": [ "We use the concept of FileSet to identify a collection of files that should be managed together (e.g. GIS shape file along with its SHX file).\\\n", "In this section we are going to register a FileSet in our project.\\\n", "\n", "The operations triggers :\n", "- the upload and archive of passed data streams\n", "- registration of the file in \"_theDocument\", precisely at the JSON path declared in the request\n", "\n", "NB Please beware that FileSet JSON paths MUST be deined in our UCD schema section." ] }, { "cell_type": "markdown", "id": "e2bdb963-6746-4131-9607-de84b1f8a035", "metadata": {}, "source": [ "In order to perform this operation we are going to create a JSON object request with at least the following information : \n", "- fieldDefinitionPath : a JSON path pointing to the field definition in UCD schema [NB root is \"schema\"]\n", "- parentPath : a JSON path pointing to the parent of our target element [NB root is \"_theDocument\"]\n", "- fieldName : the target element name at which the FileSet is going to be registered\n", "- streams : a collection of JSON objects, each containing\n", " - id : the infrastructure STORAGE volatile ID of our File\n", " - url : [Alternative to ID] the url at which our File can be downloaded.\n", " - filename : our File name" ] }, { "cell_type": "code", "execution_count": 10, "id": "07965581-532d-45e8-bbf8-0bbec1a15273", "metadata": {}, "outputs": [], "source": [ "registerFilesetRequest={\n", " \"fieldDefinitionPath\":\"$.section._children[?(@.fileset)]\",\n", " \"parentPath\":\"$.section\",\n", " \"fieldName\":\"fileset\",\n", " \"streams\":[{\"url\":\"https://www.cnr.it/sites/all/themes/custom/cnr03_theme/img/cnrlogo.svg\",\"filename\":\"myLogo.svg\"}]\n", "}" ] }, { "cell_type": "markdown", "id": "1ee75f2a-1db1-497a-8ec3-cb51fd11a1f1", "metadata": {}, "source": [ "Once our request is ready we can send it to server with a POST request at SERVICE_BASE_ENDPOINT/projects/UCID/registerFiles/ID where:\\\n", "- SERVICE_BASE_ENDPOINT should be discovered from the infrastructure's Information System\n", "- UCID is the ID of the Use Case Descriptor to be used with this project\n", "- ID is our project Unique Identifier" ] }, { "cell_type": "code", "execution_count": 11, "id": "832e043c-870b-4509-be92-d90865cfd105", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "GOING TO SEND POST REQUEST TO https://geoportal.dev.int.d4science.net/geoportal-service/srv/projects/basic/registerFiles/625042b202ad3d6126dfe5b5\n", "Data is {\"fieldDefinitionPath\": \"$.section._children[?(@.fileset)]\", \"parentPath\": \"$.section\", \"fieldName\": \"fileset\", \"streams\": [{\"url\": \"https://www.cnr.it/sites/all/themes/custom/cnr03_theme/img/cnrlogo.svg\", \"filename\": \"myLogo.svg\"}]}\n", "RESPONSE STATUS 500\n", "CAUSE \n", "
Type Status Report
Message Internal Server Error
Description The server encountered an unexpected condition that prevented it from fulfilling the request.