Class: QgsAbstractMetadataBase

class qgis.core.QgsAbstractMetadataBase

Bases: sip.wrapper

An abstract base class for metadata stores.

QgsAbstractMetadataBase is the base class for handling storage and management of the metadata for various map related assets. This class is an internal QGIS format with a common metadata structure. It is subclassed by layer and project specific metadata classes, such as QgsLayerMetadata and QgsProjectMetadata.

The metadata store is designed to be compatible with the Dublin Core metadata specifications, and will be expanded to allow compatibility with ISO specifications in future releases. However, the QGIS internal schema does not represent a superset of all existing metadata schemas and accordingly conversion from specific metadata formats to QgsAbstractMetadataBase may result in a loss of information.

This class is designed to follow the specifications detailed in the schema definition available at resources/qgis-base-metadata.xsd within the QGIS source code.

Metadata can be validated through the use of QgsAbstractMetadataBaseValidator subclasses. E.g. validating against the native QGIS metadata schema can be performed using QgsNativeMetadataValidator.

New in version 3.2.

QgsAbstractMetadataBase() Constructor for QgsAbstractMetadataBase.

QgsAbstractMetadataBase cannot be instantiated directly, it must be subclassed.

QgsAbstractMetadataBase(QgsAbstractMetadataBase)

Methods

abstract

Returns a free-form description of the resource.

addContact

Adds an individual contact to the existing contacts.

addHistoryItem

Adds a single history text to the end of the existing history list.

addKeywords

Adds a list of descriptive keywords for a specified vocabulary.

addLink

Adds an individual link to the existing links.

categories

Returns categories of the resource.

clone

Clones the metadata object.

combine

Combines the metadata from this object with the metadata from an other object.

contacts

Returns a list of contact persons or entities associated with the resource.

equals

Tests whether the common metadata fields in this object are equal to other.

history

Returns a freeform description of the history or lineage of the resource.

identifier

A reference, URI, URL or some other mechanism to identify the resource.

keywordVocabularies

Returns a list of keyword vocabularies contained in the metadata.

keywords

Returns the keywords map, which is a set of descriptive keywords associated with the resource.

language

Returns the human language associated with the resource.

links

Returns a list of online resources associated with the resource.

parentIdentifier

A reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of.

readMetadataXml

Sets state from DOM document.

removeKeywords

Remove a vocabulary from the list.

setAbstract

Sets a free-form abstract (description) of the resource.

setCategories

Sets categories of the resource.

setContacts

Sets the list of contacts or entities associated with the resource.

setHistory

Sets the freeform description of the history or lineage of the resource.

setIdentifier

Sets the reference, URI, URL or some other mechanism to identify the resource.

setKeywords

Sets the keywords map, which is a set of descriptive keywords associated with the resource.

setLanguage

Sets the human language associated with the resource.

setLinks

Sets the list of online resources associated with the resource.

setParentIdentifier

Sets a reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of.

setTitle

Sets the human readable title (name) of the resource, typically displayed in search results.

setType

Sets the type (nature) of the resource.

title

Returns the human readable name of the resource, typically displayed in search results.

type

Returns the nature of the resource.

writeMetadataXml

Stores state in a DOM node.

class Address(type: str = '', address: str = '', city: str = '', administrativeArea: str = '', postalCode: str = '', country: str = '')

Bases: sip.wrapper

Constructor for Address.

QgsAbstractMetadataBase.Address(QgsAbstractMetadataBase.Address)

address
administrativeArea
city
country
postalCode
type
class Contact(name: str = '')

Bases: sip.wrapper

Constructor for Contact.

QgsAbstractMetadataBase.Contact(QgsAbstractMetadataBase.Contact)

addresses
email
fax
name
organization
position
role
voice

Bases: sip.wrapper

Constructor for Link.

QgsAbstractMetadataBase.Link(QgsAbstractMetadataBase.Link)

description
format
mimeType
name
size
type
url
abstract(self) str

Returns a free-form description of the resource.

See also

setAbstract()

Return type:

str

addContact(self, contact: QgsAbstractMetadataBase.Contact)

Adds an individual contact to the existing contacts.

See also

contacts()

See also

setContacts()

Parameters:

contact (QgsAbstractMetadataBase.Contact) –

addHistoryItem(self, text: str)

Adds a single history text to the end of the existing history list.

See also

history()

See also

setHistory()

Parameters:

text (str) –

addKeywords(self, vocabulary: str, keywords: Iterable[str])

Adds a list of descriptive keywords for a specified vocabulary. Any existing keywords for the same vocabulary will be replaced. Other vocabularies will not be affected.

The vocabulary string is a reference (URI/URL preferred) to a codelist or vocabulary associated with keyword list.

See also

setKeywords()

Parameters:
  • vocabulary (str) –

  • keywords (Iterable[str]) –

Adds an individual link to the existing links.

See also

links()

See also

setLinks()

Parameters:

link (QgsAbstractMetadataBase.Link) –

categories(self) List[str]

Returns categories of the resource. Categories are stored using a special vocabulary ‘gmd:topicCategory’ in keywords.

See also

keywords()

Return type:

List[str]

clone(self) QgsAbstractMetadataBase

Clones the metadata object.

New in version 3.2.

Return type:

QgsAbstractMetadataBase

combine(self, other: QgsAbstractMetadataBase)

Combines the metadata from this object with the metadata from an other object.

Any existing values in this object will be overwritten by non-empty values from other.

New in version 3.20.

Parameters:

other (QgsAbstractMetadataBase) –

contacts(self) List[QgsAbstractMetadataBase.Contact]

Returns a list of contact persons or entities associated with the resource.

See also

setContacts()

Return type:

List[QgsAbstractMetadataBase.Contact]

equals(self, other: QgsAbstractMetadataBase) bool

Tests whether the common metadata fields in this object are equal to other.

Subclasses should utilize this method from their equality operators to test equality of base class members.

New in version 3.2.

Parameters:

other (QgsAbstractMetadataBase) –

Return type:

bool

history(self) List[str]

Returns a freeform description of the history or lineage of the resource.

See also

setHistory()

Return type:

List[str]

identifier(self) str

A reference, URI, URL or some other mechanism to identify the resource.

See also

setIdentifier()

Return type:

str

keywordVocabularies(self) List[str]

Returns a list of keyword vocabularies contained in the metadata.

The vocabulary string is a reference (URI/URL preferred) to a codelist or vocabulary associated with keyword list.

See also

keywords()

Return type:

List[str]

keywords(self) Dict[str, List[str]]

Returns the keywords map, which is a set of descriptive keywords associated with the resource.

The map key is the vocabulary string and map value is a list of keywords for that vocabulary.

The vocabulary string is a reference (URI/URL preferred) to a codelist or vocabulary associated with keyword list.

See also

setKeywords()

keywords(self, vocabulary: str) -> List[str] Returns a list of keywords for the specified vocabulary. If the vocabulary is not contained in the metadata, an empty list will be returned.

The vocabulary string is a reference (URI/URL preferred) to a codelist or vocabulary associated with keyword list.

Return type:

Dict[str, List[str]]

language(self) str

Returns the human language associated with the resource. Usually the returned string will follow either the ISO 639.2 or ISO 3166 specifications, e.g. ‘ENG’ or ‘SPA’, however this is not a hard requirement and the caller must account for non compliant values.

See also

setLanguage()

Return type:

str

Returns a list of online resources associated with the resource.

See also

setLinks()

Return type:

List[QgsAbstractMetadataBase.Link]

parentIdentifier(self) str

A reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of. Returns an empty string if no parent identifier is set.

Return type:

str

readMetadataXml(self, metadataElement: QDomElement) bool

Sets state from DOM document.

Parameters:

metadataElement (QDomElement) – The DOM element corresponding to ``resourceMetadata’’ tag

Return type:

bool

Returns:

True if successful

Subclasses which override this method should take care to also call the base class method in order to read common metadata properties.

removeKeywords(self, vocabulary: str) bool

Remove a vocabulary from the list.

See also

setKeywords()

See also

addKeywords()

Parameters:

vocabulary (str) –

Return type:

bool

setAbstract(self, abstract: str)

Sets a free-form abstract (description) of the resource.

See also

abstract()

Parameters:

abstract (str) –

setCategories(self, categories: Iterable[str])

Sets categories of the resource. Categories are stored using a special vocabulary ‘gmd:topicCategory’ in keywords.

See also

keywords()

Parameters:

categories (Iterable[str]) –

setContacts(self, contacts: Iterable[QgsAbstractMetadataBase.Contact])

Sets the list of contacts or entities associated with the resource. Any existing contacts will be replaced.

See also

contacts()

See also

addContact()

Parameters:

contacts (Iterable[QgsAbstractMetadataBase.Contact]) –

setHistory(self, history: Iterable[str])

Sets the freeform description of the history or lineage of the resource. Any existing history items will be overwritten.

See also

addHistoryItem()

See also

history()

Parameters:

history (Iterable[str]) –

setIdentifier(self, identifier: str)

Sets the reference, URI, URL or some other mechanism to identify the resource.

See also

identifier()

Parameters:

identifier (str) –

setKeywords(self, keywords: Dict[str, Iterable[str]])

Sets the keywords map, which is a set of descriptive keywords associated with the resource.

The map key is the vocabulary string and map value is a list of keywords for that vocabulary. Calling this replaces any existing keyword vocabularies.

The vocabulary string is a reference (URI/URL preferred) to a codelist or vocabulary associated with keyword list.

See also

keywords()

See also

addKeywords()

Parameters:

keywords (Dict[str) –

setLanguage(self, language: str)

Sets the human language associated with the resource. While a formal vocabulary is not imposed, ideally values should be taken from the ISO 639.2 or ISO 3166 specifications, e.g. ‘ENG’ or ‘SPA’ (ISO 639.2) or ‘EN-AU’ (ISO 3166).

See also

language()

Parameters:

language (str) –

Sets the list of online resources associated with the resource. Any existing links will be replaced.

See also

links()

See also

addLink()

Parameters:

links (Iterable[QgsAbstractMetadataBase.Link]) –

setParentIdentifier(self, parentIdentifier: str)

Sets a reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of. Set an empty string if no parent identifier is required.

Parameters:

parentIdentifier (str) –

setTitle(self, title: str)

Sets the human readable title (name) of the resource, typically displayed in search results.

See also

title()

Parameters:

title (str) –

setType(self, type: str)

Sets the type (nature) of the resource. While a formal vocabulary is not imposed, it is advised to use the ISO 19115 MD_ScopeCode values. E.g. ‘dataset’ or ‘series’.

See also

type()

Parameters:

type (str) –

title(self) str

Returns the human readable name of the resource, typically displayed in search results.

See also

setTitle()

Return type:

str

type(self) str

Returns the nature of the resource. While a formal vocabulary is not imposed, it is advised to use the ISO 19115 MD_ScopeCode values. E.g. ‘dataset’ or ‘series’.

See also

setType()

Return type:

str

writeMetadataXml(self, metadataElement: QDomElement, document: QDomDocument) bool

Stores state in a DOM node.

Parameters:
  • metadataElement (QDomElement) – is a DOM element corresponding to ``resourceMetadata’’ tag

  • document (QDomDocument) – is a the DOM document being written

Return type:

bool

Returns:

True if successful

Subclasses which override this method should take care to also call the base class method in order to write common metadata properties.