QgsAbstractMetadataBase class
An abstract base class for metadata stores.
Contents
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.
Derived classes
- class QgsLayerMetadata
- A structured metadata store for a map layer.
- class QgsProjectMetadata
- A structured metadata store for a map layer.
Public types
- struct Address
- Metadata address structure.
- struct Contact
- Metadata contact structure.
- struct Link
- Metadata link structure.
-
using ContactList = QList<QgsAbstractMetadataBase::
Contact> - A list of contacts.
- using KeywordMap = QMap<QString, QStringList>
- Map of vocabulary string to keyword list.
-
using LinkList = QList<QgsAbstractMetadataBase::
Link> - A list of links.
Constructors, destructors, conversion operators
- QgsAbstractMetadataBase() protected defaulted
- Constructor for QgsAbstractMetadataBase.
Public functions
- auto abstract() const -> QString
- 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.
- auto categories() const -> QStringList
- Returns categories of the resource.
- auto clone() const -> QgsAbstractMetadataBase* pure virtual
- Clones the metadata object.
-
auto contacts() const -> QgsAbstractMetadataBase::
ContactList - Returns a list of contact persons or entities associated with the resource.
- auto history() const -> QStringList
- Returns a freeform description of the history or lineage of the resource.
- auto identifier() const -> QString
- A reference, URI, URL or some other mechanism to identify the resource.
-
auto keywords() const -> QgsAbstractMetadataBase::
KeywordMap - Returns the keywords map, which is a set of descriptive keywords associated with the resource.
- auto keywords(const QString& vocabulary) const -> QStringList
- Returns a list of keywords for the specified vocabulary.
- auto keywordVocabularies() const -> QStringList
- Returns a list of keyword vocabularies contained in the metadata.
- auto language() const -> QString
- Returns the human language associated with the resource.
-
auto links() const -> QgsAbstractMetadataBase::
LinkList - Returns a list of online resources associated with the resource.
- auto parentIdentifier() const -> QString
- A reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of.
- auto readMetadataXml(const QDomElement& metadataElement) -> bool virtual
- Sets state from DOM document.
- auto removeKeywords(const QString& vocabulary) -> bool
- 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 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.
- auto title() const -> QString
- Returns the human readable name of the resource, typically displayed in search results.
- auto type() const -> QString
- Returns the nature of the resource.
- auto writeMetadataXml(QDomElement& metadataElement, QDomDocument& document) const -> bool virtual
- Stores state in a DOM node.
Protected functions
- auto equals(const QgsAbstractMetadataBase& other) const -> bool
- Tests whether the common metadata fields in this object are equal to other.
Protected variables
-
QgsAbstractMetadataBase::
KeywordMap mKeywords - Keywords map.
Function documentation
QgsAbstractMetadataBase:: QgsAbstractMetadataBase() protected defaulted
Constructor for QgsAbstractMetadataBase.
QgsAbstractMetadataBase cannot be instantiated directly, it must be subclassed.
QString QgsAbstractMetadataBase:: abstract() const
Returns a free-form description of the resource.
void QgsAbstractMetadataBase:: addContact(const QgsAbstractMetadataBase:: Contact& contact)
Adds an individual contact to the existing contacts.
void QgsAbstractMetadataBase:: addHistoryItem(const QString& text)
Adds a single history text to the end of the existing history list.
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.
void QgsAbstractMetadataBase:: addLink(const QgsAbstractMetadataBase:: Link& link)
Adds an individual link to the existing links.
QStringList QgsAbstractMetadataBase:: categories() const
Returns categories of the resource.
Categories are stored using a special vocabulary 'gmd:topicCategory' in keywords.
QgsAbstractMetadataBase* QgsAbstractMetadataBase:: clone() const pure virtual
Clones the metadata object.
QgsAbstractMetadataBase:: ContactList QgsAbstractMetadataBase:: contacts() const
Returns a list of contact persons or entities associated with the resource.
QStringList QgsAbstractMetadataBase:: history() const
Returns a freeform description of the history or lineage of the resource.
QString QgsAbstractMetadataBase:: identifier() const
A reference, URI, URL or some other mechanism to identify the resource.
QgsAbstractMetadataBase:: KeywordMap 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.
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.
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.
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.
QgsAbstractMetadataBase:: LinkList QgsAbstractMetadataBase:: links() const
Returns a list of online resources associated with the resource.
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.
bool QgsAbstractMetadataBase:: readMetadataXml(const QDomElement& metadataElement) virtual
Sets state from DOM document.
| Parameters | |
|---|---|
| metadataElement | The DOM element corresponding to ``resourceMetadata'' tag |
| 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.
bool QgsAbstractMetadataBase:: removeKeywords(const QString& vocabulary)
Remove a vocabulary from the list.
void QgsAbstractMetadataBase:: setAbstract(const QString& abstract)
Sets a free-form abstract (description) of the resource.
void QgsAbstractMetadataBase:: setCategories(const QStringList& categories)
Sets categories of the resource.
Categories are stored using a special vocabulary 'gmd:topicCategory' in keywords.
void QgsAbstractMetadataBase:: setContacts(const QgsAbstractMetadataBase:: ContactList& contacts)
Sets the list of contacts or entities associated with the resource.
Any existing contacts will be replaced.
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.
void QgsAbstractMetadataBase:: setIdentifier(const QString& identifier)
Sets the reference, URI, URL or some other mechanism to identify the resource.
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.
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).
void QgsAbstractMetadataBase:: setLinks(const QgsAbstractMetadataBase:: LinkList& links)
Sets the list of online resources associated with the resource.
Any existing links will be replaced.
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.
void QgsAbstractMetadataBase:: setTitle(const QString& title)
Sets the human readable title (name) of the resource, typically displayed in search results.
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'.
QString QgsAbstractMetadataBase:: title() const
Returns the human readable name of the resource, typically displayed in search results.
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'.
bool QgsAbstractMetadataBase:: writeMetadataXml(QDomElement& metadataElement,
QDomDocument& document) const virtual
Stores state in a DOM node.
| Parameters | |
|---|---|
| metadataElement | is a DOM element corresponding to ``resourceMetadata'' tag |
| document | is a the DOM document being written |
| 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.
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.
Variable documentation
QgsAbstractMetadataBase:: KeywordMap QgsAbstractMetadataBase:: mKeywords protected
Keywords map.
Key is the vocabulary, value is a list of keywords for that vocabulary.