Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Page Properties
hiddentrue
idrDEV

Product Version
Report Note
Assignee

Resources & Remarks

Modification History

NameDateProduct VersionAction
Antje11 JUN 20212021 SummerPage created and writing started.
Agnieszka26 JUL 20212021 SummerrLANG



Excerpt

This example tutorial provides explanations and code examples to get an idea on how to define and specify structured data properties and on how to query them.

...

yuuvis® Momentum offers a property type for the storage of structured data in JSON format. Thus, it is possible to store interleaved data structures in a queryable way without defining each single sub-property in the schema. The structured data properties should NOT be considered to replace the concept of a well-defined schema. They should be used only if the handling of objects' metadata via the conventional property definitions is not reasonable. Especially, if the structure of metadata and/or the availability of properties differs a lot for the individual object instances, the schema might grow up to a really long list of scarcely used properties. This can be avoided by the usage of a property field that can store a JSON structure as value. In this tutorial, the bibliographic information of media in a library is considered an example use case. For this purpose, the set of information for each medium is provided in JSON structure following the concept of BibJSON.

...

This property will be used for the storage of the BibJSON structure containing the bibliographic information of the corresponding medium. The second property bibjsonsample:locations allows for the assignment of a list of strings indicating storage locations if a printed version is available for the corresponding medium. In the object type definition of bibjsonsample:medium, both properties are referenced. Additionally, a binary content file can be assigned if necessary as defined in line 25 with the value allowed for the contentStreamAllowed attribute contentStreamAllowed.

Code Block
languagexml
titleExample Schema
linenumberstrue
<?xml version="1.0" encoding="utf-8"?>
<schema xmlns="http://optimal-systems.org/ns/dmscloud/schema/v5.0/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://optimal-systems.org/ns/dmscloud/schema/v5.0/ dmsCloud-schema.xsd">

    <propertyStructuredDataDefinition>
        <id>bibjsonsample:bibjson</id>
        <description>field for the BibJSON structure identifying and describing the medium</description>
        <propertyType>structureddata</propertyType>
        <cardinality>single</cardinality>
        <required>false</required>
    </propertyStructuredDataDefinition>
    <propertyStringDefinition>
        <id>bibjsonsample:locations</id>
        <description>field for storage locations of printed versions of the medium</description>
        <propertyType>string</propertyType>
        <cardinality>multi</cardinality>
        <required>false</required>
    </propertyStringDefinition>
    <typeDocumentDefinition>
        <id>bibjsonsample:medium</id>
        <baseId>system:document</baseId>
        <propertyReference>bibjsonsample:bibjson</propertyReference>
        <propertyReference>bibjsonsample:locations</propertyReference>
        <contentStreamAllowed>allowed</contentStreamAllowed>
    </typeDocumentDefinition>

</schema>

The schema for the bibjsonsample app bibjsonsample is imported via the endpoint  POST /api/system/apps/{app}/schema endpoint.

More details and further examples on schema handling are provided in the following tutorial:
>> Managing the Schema

...

Specifying Values during Import

Two example objects will be created as instances of the object type abbBibjsonsample:medium object typeBoth of them get are assigned a BibJSON value for the property appbibjsonsample:bibjson assigned to themproperty.
>> Structured Data in Import Bodies

...

The first example object is a book. The bibliographic information stored in the property appBibjsonsample:bibjson, property contains one integer value specified in line 21, all . All other sub-values are stored as strings. In addition to the property appBibjsonsample:bibjson property, two storage locations for printed versions are specified.

...

The second example object is a collection of articles without corresponding printed versions. The structure of the JSON value for the property appBibjsonsample:bibjson looks  property looks completely different.

Code Block
languageyml
titleimport request for a collection
linenumberstrue
{
  "objects": [{
    "properties": {
      "objectTypeId": {
        "value": "appBibjsonsample:medium"
      },
      "appBibjsonsample:bibjson": {
        "value": {
          "metadata": {
            "collection": "ym_concepts",
            "label": "yuuvis(R) Momentum Core Concepts",
            "description": "Documentation for yuuvis(R) Momentum Core in a structured, theoretical way, with links to the tutorial section.",
            "id": "ID_of_collection",
            "owner": "OS",
            "created": "2020-06-09T15:04:12.944Z",
            "modified": "2021-06-10T11:05:17.166Z",
            "source": "https://help.optimal-systems.com/yuuvis_develop/display/YMY/Concepts",
            "records": 2
          },
          "records": [
            {
              "collection": "ym_concepts",
              "type": "article",
              "title": "Schema - Defining Object Types",
              "id": "ID_of_schema_article",
              "link": "https://help.optimal-systems.com/yuuvis_develop/display/YMY/Schema+-+Defining+Object+Types",
              "author":[
                {"name": "Heinrich Schuetzel"},
                {"name": "George Trader"},
                {"name": "Johann Fluss"}
              ],
              "created": "2020-06-09T15:04:12.944Z",
              "modified": "2021-06-10T08:53:23.532Z"
            },
            {
              "collection": "ym_concepts",
              "type": "article",
              "title": "Search Query Language",
              "id": "ID_of_query_article",
              "link": "https://help.optimal-systems.com/yuuvis_develop/display/YMY/Search+Query+Language",
              "author":[
                {"name": "Andrea Schumann"},
                {"name": "Franz Lissner"},
                {"name": "Hans Kammer"},
                {"name": "Johann Fluss"}
              ],
              "created": "2020-06-16T14:03:01.833Z",
              "modified": "2021-06-02T09:54:12.643Z"
            }
          ]
        }
      }
    }
  }]
}

...

The individual sub-values within the JSON value for the property  appBibjsonsample:bibjson property are queryable.
>> Queries on Structured Data

...

In order to return only the bibliographic information in the result list of the search request, select the property appBibjsonsample:bibjsonbibjson property.

Code Block
languagesql
SELECT appBibjsonsample:bibjson FROM appBibjsonsample:medium

...

It is even possible to return specified sub-values of the JSON structure stored in the property appBibjsonsample:bibjson propertyIf you specify an index within a list, the values for the list elements with lower indices will be replaced by null in the return statement as can be seen in line 9.

...

If you want to search for an object having with a specific sub-value but the unknown path is unknown, a * wildcard can be used. Each object containing the string ID_of_schema_article as a sub-value for the property appBibjsonsample:bibjson property will match the query.

Code Block
languagesql
SELECT appBibjsonsample:bibjson.metadata.id FROM appBibjsonsample:medium WHERE appBibjsonsample:bibjson.* = 'ID_of_schema_article'

...

Example 6

The * wildcard can also be used also instead of a specific index within a list. Thus, the condition will be checked for each list entry. Furthermore, full-text search with CONTAINS is possible in case of string sub-values.

...

Use .. in order to replace unknown parts of a path. The query below specifies a search for objects where the property appBibjsonsample:bibjson contains  property contains Schuetzel in the value for the key author[*].name that key which can be located at any hierarchical level within the JSON. Furthermore, only key-value mappings for keys named id will be displayed in the response body.

...

Code Block
languageyml
titleresponse body
linenumberstrue
collapsetrue
{
    "objects": [
        {
            "properties": {
                "appBibjsonsample:bibjson": {
                    "value": {
                        "id": "ID_of_book",
                        "identifier": [
                            {
                                "id": "0002-9327"
                            }
                        ]
                    }
                }
            }
        },
        {
            "properties": {
                "appBibjsonsample:bibjson": {
                    "value": {
                        "metadata": {
                            "id": "ID_of_collection"
                        },
                        "records": [
                            {
                                "id": "ID_of_schema_article"
                            },
                            {
                                "id": "ID_of_query_article"
                            }
                        ]
                    }
                }
            }
        }
    ],
    "numItems": 2,
    "hasMoreItems": false,
    "totalNumItems": 2
}

Summary

The property structureddata property type structureddata allows allows for the storage of interleaved data structures in a queryable way without defining each single sub-property in the schema. This tutorial gave some explanations on how to define such a property in the schema, how to set a value during an object creation and how to address the individual sub-values in search queries, in the example context of a library.

...