QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
QgsAbstractMetadataBase Class Referenceabstract

An abstract base class for metadata stores. More...

#include <qgsabstractmetadatabase.h>

Inheritance diagram for QgsAbstractMetadataBase:

Classes

struct  Address
 Metadata address structure. More...
struct  Contact
 Metadata contact structure. More...
 Metadata link structure. More...

Public Types

typedef QList< QgsAbstractMetadataBase::ContactContactList
 A list of contacts.
typedef QMap< QString, QStringList > KeywordMap
 Map of vocabulary string to keyword list.
typedef QList< QgsAbstractMetadataBase::LinkLinkList
 A list of links.

Public Member Functions

virtual ~QgsAbstractMetadataBase ()=default
QString abstract () const
 Returns a free-form description of the resource.
void addContact (const QgsAbstractMetadataBase::Contact &contact)
 Adds an individual contact to the existing contacts.
void addHistoryItem (const QString &text)
 Adds a single history text to the end of the existing history list.
void addKeywords (const QString &vocabulary, const QStringList &keywords)
 Adds a list of descriptive keywords for a specified vocabulary.
void addLink (const QgsAbstractMetadataBase::Link &link)
 Adds an individual link to the existing links.
QStringList categories () const
 Returns categories of the resource.
virtual QgsAbstractMetadataBaseclone () const =0
 Clones the metadata object.
virtual void combine (const QgsAbstractMetadataBase *other)
 Combines the metadata from this object with the metadata from an other object.
QgsAbstractMetadataBase::ContactList contacts () const
 Returns a list of contact persons or entities associated with the resource.
QDateTime dateTime (Qgis::MetadataDateType type) const
 Returns the date for the specified date type.
QStringList history () const
 Returns a freeform description of the history or lineage of the resource.
QString identifier () const
 A reference, URI, URL or some other mechanism to identify the resource.
QgsAbstractMetadataBase::KeywordMap keywords () const
 Returns the keywords map, which is a set of descriptive keywords associated with the resource.
QStringList keywords (const QString &vocabulary) const
 Returns a list of keywords for the specified vocabulary.
QStringList keywordVocabularies () const
 Returns a list of keyword vocabularies contained in the metadata.
QString language () const
 Returns the human language associated with the resource.
QgsAbstractMetadataBase::LinkList links () const
 Returns a list of online resources associated with the resource.
QString parentIdentifier () const
 A reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of.
virtual bool readMetadataXml (const QDomElement &metadataElement, const QgsReadWriteContext &context=QgsReadWriteContext())
 Sets state from DOM document.
virtual void registerTranslations (QgsTranslationContext *translationContext) const
 Registers metadata translation strings.
bool removeKeywords (const QString &vocabulary)
 Remove a vocabulary from the list.
void setAbstract (const QString &abstract)
 Sets a free-form abstract (description) of the resource.
void setCategories (const QStringList &categories)
 Sets categories of the resource.
void setContacts (const QgsAbstractMetadataBase::ContactList &contacts)
 Sets the list of contacts or entities associated with the resource.
void setDateTime (Qgis::MetadataDateType type, QDateTime date)
 Sets a date value for the specified date type.
void setHistory (const QStringList &history)
 Sets the freeform description of the history or lineage of the resource.
void setIdentifier (const QString &identifier)
 Sets the reference, URI, URL or some other mechanism to identify the resource.
void setKeywords (const QgsAbstractMetadataBase::KeywordMap &keywords)
 Sets the keywords map, which is a set of descriptive keywords associated with the resource.
void setLanguage (const QString &language)
 Sets the human language associated with the resource.
void setLinks (const QgsAbstractMetadataBase::LinkList &links)
 Sets the list of online resources associated with the resource.
void setParentIdentifier (const QString &parentIdentifier)
 Sets a reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of.
void setTitle (const QString &title)
 Sets the human readable title (name) of the resource, typically displayed in search results.
void setType (const QString &type)
 Sets the type (nature) of the resource.
QString title () const
 Returns the human readable name of the resource, typically displayed in search results.
QString type () const
 Returns the nature of the resource.
virtual bool writeMetadataXml (QDomElement &metadataElement, QDomDocument &document, const QgsReadWriteContext &context=QgsReadWriteContext()) const
 Stores state in a DOM node.

Protected Member Functions

 QgsAbstractMetadataBase ()=default
 Constructor for QgsAbstractMetadataBase.
bool equals (const QgsAbstractMetadataBase &other) const
 Tests whether the common metadata fields in this object are equal to other.

Protected Attributes

QString mAbstract
QgsAbstractMetadataBase::ContactList mContacts
QMap< Qgis::MetadataDateType, QDateTime > mDates
 Metadata dates.
QStringList mHistory
QString mIdentifier
QgsAbstractMetadataBase::KeywordMap mKeywords
 Keywords map.
QString mLanguage
QgsAbstractMetadataBase::LinkList mLinks
QString mParentIdentifier
QString mTitle
QString mType

Detailed Description

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.

Since
QGIS 3.2

Definition at line 60 of file qgsabstractmetadatabase.h.

Member Typedef Documentation

◆ KeywordMap

typedef QMap< QString, QStringList > QgsAbstractMetadataBase::KeywordMap

Map of vocabulary string to keyword list.

Definition at line 82 of file qgsabstractmetadatabase.h.

Constructor & Destructor Documentation

◆ ~QgsAbstractMetadataBase()

virtual QgsAbstractMetadataBase::~QgsAbstractMetadataBase ( )
virtualdefault

◆ QgsAbstractMetadataBase()

QgsAbstractMetadataBase::QgsAbstractMetadataBase ( )
protecteddefault

Constructor for QgsAbstractMetadataBase.

QgsAbstractMetadataBase cannot be instantiated directly, it must be subclassed.

Member Function Documentation

◆ abstract()

QString QgsAbstractMetadataBase::abstract ( ) const

Returns a free-form description of the resource.

See also
setAbstract()

Definition at line 63 of file qgsabstractmetadatabase.cpp.

◆ addContact()

void QgsAbstractMetadataBase::addContact ( const QgsAbstractMetadataBase::Contact & contact)

Adds an individual contact to the existing contacts.

See also
contacts()
setContacts()

Definition at line 145 of file qgsabstractmetadatabase.cpp.

◆ addHistoryItem()

void QgsAbstractMetadataBase::addHistoryItem ( const QString & text)

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

See also
history()
setHistory()

Definition at line 83 of file qgsabstractmetadatabase.cpp.

◆ addKeywords()

void QgsAbstractMetadataBase::addKeywords ( const QString & vocabulary,
const QStringList & keywords )

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()

Definition at line 98 of file qgsabstractmetadatabase.cpp.

◆ addLink()

void QgsAbstractMetadataBase::addLink ( const QgsAbstractMetadataBase::Link & link)

Adds an individual link to the existing links.

See also
links()
setLinks()

Definition at line 160 of file qgsabstractmetadatabase.cpp.

◆ categories()

QStringList QgsAbstractMetadataBase::categories ( ) const

Returns categories of the resource.

Categories are stored using a special vocabulary 'gmd:topicCategory' in keywords.

See also
keywords()

Definition at line 118 of file qgsabstractmetadatabase.cpp.

◆ clone()

virtual QgsAbstractMetadataBase * QgsAbstractMetadataBase::clone ( ) const
pure virtual

Clones the metadata object.

Since
QGIS 3.2

Implemented in QgsLayerMetadata, and QgsProjectMetadata.

◆ combine()

void QgsAbstractMetadataBase::combine ( const QgsAbstractMetadataBase * other)
virtual

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.

Since
QGIS 3.20

Reimplemented in QgsLayerMetadata, and QgsProjectMetadata.

Definition at line 506 of file qgsabstractmetadatabase.cpp.

◆ contacts()

QList< QgsAbstractMetadataBase::Contact > QgsAbstractMetadataBase::contacts ( ) const

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

See also
setContacts()

Definition at line 135 of file qgsabstractmetadatabase.cpp.

◆ dateTime()

QDateTime QgsAbstractMetadataBase::dateTime ( Qgis::MetadataDateType type) const

Returns the date for the specified date type.

See also
setDateTime()
Since
QGIS 3.30

Definition at line 165 of file qgsabstractmetadatabase.cpp.

◆ equals()

bool QgsAbstractMetadataBase::equals ( const QgsAbstractMetadataBase & other) const
protected

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.

Since
QGIS 3.2

Definition at line 553 of file qgsabstractmetadatabase.cpp.

◆ history()

QStringList QgsAbstractMetadataBase::history ( ) const

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

See also
setHistory()

Definition at line 73 of file qgsabstractmetadatabase.cpp.

◆ identifier()

QString QgsAbstractMetadataBase::identifier ( ) const

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

See also
setIdentifier()

Definition at line 23 of file qgsabstractmetadatabase.cpp.

◆ keywords() [1/2]

QMap< QString, QStringList > QgsAbstractMetadataBase::keywords ( ) const

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()
keywordVocabularies()

Definition at line 88 of file qgsabstractmetadatabase.cpp.

◆ keywords() [2/2]

QStringList QgsAbstractMetadataBase::keywords ( const QString & vocabulary) const

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.

See also
keywordVocabularies()

Definition at line 113 of file qgsabstractmetadatabase.cpp.

◆ keywordVocabularies()

QStringList QgsAbstractMetadataBase::keywordVocabularies ( ) const

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()

Definition at line 108 of file qgsabstractmetadatabase.cpp.

◆ language()

QString QgsAbstractMetadataBase::language ( ) const

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()

Definition at line 178 of file qgsabstractmetadatabase.cpp.

◆ links()

QList< QgsAbstractMetadataBase::Link > QgsAbstractMetadataBase::links ( ) const

Returns a list of online resources associated with the resource.

See also
setLinks()

Definition at line 150 of file qgsabstractmetadatabase.cpp.

◆ parentIdentifier()

QString QgsAbstractMetadataBase::parentIdentifier ( ) const

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.

See also
setParentIdentifier()

Definition at line 33 of file qgsabstractmetadatabase.cpp.

◆ readMetadataXml()

bool QgsAbstractMetadataBase::readMetadataXml ( const QDomElement & metadataElement,
const QgsReadWriteContext & context = QgsReadWriteContext() )
virtual

Sets state from DOM document.

Parameters
metadataElementThe DOM element corresponding to resourceMetadata tag
contextThe context object to handle project translation (since QGIS 4.0)
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.

Reimplemented in QgsLayerMetadata, and QgsProjectMetadata.

Definition at line 188 of file qgsabstractmetadatabase.cpp.

◆ registerTranslations()

void QgsAbstractMetadataBase::registerTranslations ( QgsTranslationContext * translationContext) const
virtual

Registers metadata translation strings.

Since
QGIS 4.0

Reimplemented in QgsLayerMetadata, and QgsProjectMetadata.

Definition at line 490 of file qgsabstractmetadatabase.cpp.

◆ removeKeywords()

bool QgsAbstractMetadataBase::removeKeywords ( const QString & vocabulary)

Remove a vocabulary from the list.

See also
setKeywords()
addKeywords()

Definition at line 103 of file qgsabstractmetadatabase.cpp.

◆ setAbstract()

void QgsAbstractMetadataBase::setAbstract ( const QString & abstract)

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

See also
abstract()

Definition at line 68 of file qgsabstractmetadatabase.cpp.

◆ setCategories()

void QgsAbstractMetadataBase::setCategories ( const QStringList & categories)

Sets categories of the resource.

Categories are stored using a special vocabulary 'gmd:topicCategory' in keywords.

See also
keywords()

Definition at line 130 of file qgsabstractmetadatabase.cpp.

◆ setContacts()

void QgsAbstractMetadataBase::setContacts ( const QgsAbstractMetadataBase::ContactList & contacts)

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

Any existing contacts will be replaced.

See also
contacts()
addContact()

Definition at line 140 of file qgsabstractmetadatabase.cpp.

◆ setDateTime()

void QgsAbstractMetadataBase::setDateTime ( Qgis::MetadataDateType type,
QDateTime date )

Sets a date value for the specified date type.

See also
dateTime()
Since
QGIS 3.30

Definition at line 170 of file qgsabstractmetadatabase.cpp.

◆ setHistory()

void QgsAbstractMetadataBase::setHistory ( const QStringList & history)

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

Any existing history items will be overwritten.

See also
addHistoryItem()
history()

Definition at line 78 of file qgsabstractmetadatabase.cpp.

◆ setIdentifier()

void QgsAbstractMetadataBase::setIdentifier ( const QString & identifier)

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

See also
identifier()

Definition at line 28 of file qgsabstractmetadatabase.cpp.

◆ setKeywords()

void QgsAbstractMetadataBase::setKeywords ( const QgsAbstractMetadataBase::KeywordMap & keywords)

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()
addKeywords()

Definition at line 93 of file qgsabstractmetadatabase.cpp.

◆ setLanguage()

void QgsAbstractMetadataBase::setLanguage ( const QString & language)

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()

Definition at line 183 of file qgsabstractmetadatabase.cpp.

◆ setLinks()

void QgsAbstractMetadataBase::setLinks ( const QgsAbstractMetadataBase::LinkList & links)

Sets the list of online resources associated with the resource.

Any existing links will be replaced.

See also
links()
addLink()

Definition at line 155 of file qgsabstractmetadatabase.cpp.

◆ setParentIdentifier()

void QgsAbstractMetadataBase::setParentIdentifier ( const QString & parentIdentifier)

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.

See also
parentIdentifier()

Definition at line 38 of file qgsabstractmetadatabase.cpp.

◆ setTitle()

void QgsAbstractMetadataBase::setTitle ( const QString & title)

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

See also
title()

Definition at line 58 of file qgsabstractmetadatabase.cpp.

◆ setType()

void QgsAbstractMetadataBase::setType ( const QString & type)

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()

Definition at line 48 of file qgsabstractmetadatabase.cpp.

◆ title()

QString QgsAbstractMetadataBase::title ( ) const

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

See also
setTitle()

Definition at line 53 of file qgsabstractmetadatabase.cpp.

◆ type()

QString QgsAbstractMetadataBase::type ( ) const

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()

Definition at line 43 of file qgsabstractmetadatabase.cpp.

◆ writeMetadataXml()

bool QgsAbstractMetadataBase::writeMetadataXml ( QDomElement & metadataElement,
QDomDocument & document,
const QgsReadWriteContext & context = QgsReadWriteContext() ) const
virtual

Stores state in a DOM node.

Parameters
metadataElementis a DOM element corresponding to resourceMetadata tag
documentis a the DOM document being written
contextThe context object to handle project translation (since QGIS 4.0)
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.

Reimplemented in QgsLayerMetadata, and QgsProjectMetadata.

Definition at line 324 of file qgsabstractmetadatabase.cpp.

Member Data Documentation

◆ mAbstract

QString QgsAbstractMetadataBase::mAbstract
protected

Definition at line 590 of file qgsabstractmetadatabase.h.

◆ mContacts

QgsAbstractMetadataBase::ContactList QgsAbstractMetadataBase::mContacts
protected

Definition at line 600 of file qgsabstractmetadatabase.h.

◆ mDates

QMap< Qgis::MetadataDateType, QDateTime > QgsAbstractMetadataBase::mDates
protected

Metadata dates.

Definition at line 605 of file qgsabstractmetadatabase.h.

◆ mHistory

QStringList QgsAbstractMetadataBase::mHistory
protected

Definition at line 591 of file qgsabstractmetadatabase.h.

◆ mIdentifier

QString QgsAbstractMetadataBase::mIdentifier
protected

Definition at line 585 of file qgsabstractmetadatabase.h.

◆ mKeywords

QgsAbstractMetadataBase::KeywordMap QgsAbstractMetadataBase::mKeywords
protected

Keywords map.

Key is the vocabulary, value is a list of keywords for that vocabulary.

Definition at line 598 of file qgsabstractmetadatabase.h.

◆ mLanguage

QString QgsAbstractMetadataBase::mLanguage
protected

Definition at line 587 of file qgsabstractmetadatabase.h.

◆ mLinks

QgsAbstractMetadataBase::LinkList QgsAbstractMetadataBase::mLinks
protected

Definition at line 602 of file qgsabstractmetadatabase.h.

◆ mParentIdentifier

QString QgsAbstractMetadataBase::mParentIdentifier
protected

Definition at line 586 of file qgsabstractmetadatabase.h.

◆ mTitle

QString QgsAbstractMetadataBase::mTitle
protected

Definition at line 589 of file qgsabstractmetadatabase.h.

◆ mType

QString QgsAbstractMetadataBase::mType
protected

Definition at line 588 of file qgsabstractmetadatabase.h.


The documentation for this class was generated from the following files: