Inherit Metadata - Fluid Topics - 3.7 - Technical Notes

Develop Connectors with the Fluid Topics API

Product
Fluid Topics
Fluid Topics Version
3.7
Category
Technical Notes
Language
English
Target Audience
public

By default, when using the Fluid Topics Python API to create metadata at the book level, the book’s topics do not inherit the metadata.

It is possible to override the API's default behavior so that a book’s topics inherit metadata created at the book level, as well as a topic's child topics inherit the metadata created at the topic level. For this purpose, the API provides a MetadataInheritor object.

Semantic Metadata cannot be inherited.

As an example, when a topic already has a metadata, the MetadataInheritor object adds the metadata of the book:

  • Before inheritance: Book(meta = value1) > Topic(meta = value2)
  • After inheritance: Book(meta = value1) > Topic(meta = value1, value2)

The following lines show how to enable metadata inheritance for a given book:

from fluidtopics.connector import Topic, EditorialType, StructuredDocument, Metadata, MetadataInheritor


meta_simple_37 = Metadata("version", "3.7")
meta_simple_rhel = Metadata("Operating System", "RHEL")

topic_B = Topic.create(
topic_id="topic-b-id",
title="Topic B title",
body="<p>Body of the topic <strong>B</strong></p>"
)

book_B = StructuredDocument.create(
document_id="my-structured-document-book-b",
title="My Structured Document - BookB",
locale="en-US",
pretty_url="my-pretty-structured-document-book-b",
toc=[topicA, topicB],
editorial_type=EditorialType.BOOK,
metadata=[meta_simple_37, meta_simple_rhel]
)

book_B_final = MetadataInheritor().inherit_metadata(book_B)

It is also possible to select the metadata that will not be inherited:

book_B_final = MetadataInheritor(['version', 'release_date']).inherit_metadata(book_B)

The following screenshots illustrate how metadata inheritance is displayed in the Metadata journal:

meta_inheritance_book

meta_inheritance_topic