Class: QgsAbstractMetadataBase¶
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
.
Added in version 3.2.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: clone()
Class Hierarchy¶
Subclasses¶
A structured metadata store for a map layer. |
|
A structured metadata store for a project. |
Abstract Methods
Clones the metadata object. |
Methods
Returns a free-form description of the resource. |
|
Adds an individual contact to the existing contacts. |
|
Adds a single history text to the end of the existing history list. |
|
Adds a list of descriptive keywords for a specified vocabulary. |
|
Adds an individual link to the existing links. |
|
Returns categories of the resource. |
|
Returns a list of contact persons or entities associated with the resource. |
|
Returns the date for the specified date type. |
|
Tests whether the common metadata fields in this object are equal to other. |
|
Returns a freeform description of the history or lineage of the resource. |
|
A reference, URI, URL or some other mechanism to identify the resource. |
|
Returns a list of keyword vocabularies contained in the metadata. |
|
Returns the keywords map, which is a set of descriptive keywords associated with the resource. |
|
Returns the human language associated with the resource. |
|
Returns a list of online resources associated with the resource. |
|
A reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of. |
|
Remove a vocabulary from the list. |
|
Sets a free-form abstract (description) of the resource. |
|
Sets categories of the resource. |
|
Sets the list of contacts or entities associated with the resource. |
|
Sets a date value for the specified date type. |
|
Sets the freeform description of the history or lineage of the resource. |
|
Sets the reference, URI, URL or some other mechanism to identify the resource. |
|
Sets the keywords map, which is a set of descriptive keywords associated with the resource. |
|
Sets the human language associated with the resource. |
|
Sets the list of online resources associated with the resource. |
|
Sets a reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of. |
|
Sets the human readable title (name) of the resource, typically displayed in search results. |
|
Sets the type (nature) of the resource. |
|
Returns the human readable name of the resource, typically displayed in search results. |
|
Returns the nature of the resource. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsAbstractMetadataBase. See the FAQ for more details.
Combines the metadata from this object with the metadata from an other object. |
|
Sets state from DOM document. |
|
Stores state in a DOM node. |
- class qgis.core.QgsAbstractMetadataBase[source]¶
Bases:
object
- __init__()
Constructor for QgsAbstractMetadataBase.
QgsAbstractMetadataBase cannot be instantiated directly, it must be subclassed.
- __init__(a0: QgsAbstractMetadataBase)
- Parameters:
- class Address¶
Bases:
object
Metadata address structure.
Added in version 3.2.
- address: str¶
Free-form physical address component, e.g. ‘221B Baker St’ or ‘P.O. Box 196’.
- administrativeArea: str¶
Administrative area (state, province/territory, etc.).
- city: str¶
City or locality name.
- country: str¶
Free-form country string.
- postalCode: str¶
Postal (or ZIP) code.
- type: str¶
Type of address, e.g. ‘postal’.
- class Contact¶
Bases:
object
Metadata contact structure.
Added in version 3.2.
- addresses: List[QgsAbstractMetadataBase.Address]¶
List of addresses associated with this contact.
- email: str¶
Electronic mail address.
Note
Do not include mailto: protocol as part of the email address.
- fax: str¶
Facsimile telephone.
- name: str¶
Name of contact.
- organization: str¶
Organization contact belongs to/represents.
- position: str¶
Position/title of contact.
- role: str¶
Role of contact. Acceptable values are those from the ISO 19115 CI_RoleCode specifications (see http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml). E.g. ‘custodian’, ‘owner’, ‘distributor’, etc.
- voice: str¶
Voice telephone.
- class Link¶
Bases:
object
Metadata link structure.
Added in version 3.2.
- description: str¶
Abstract text about link.
- format: str¶
Format specification of online resource. It is strongly suggested to use GDAL/OGR format values.
- mimeType: str¶
MIME type representative of the online resource response (image/png, application/json, etc.)
- name: str¶
Short link name. E.g. WMS layer name.
- size: str¶
Estimated size (in bytes) of the online resource response.
- type: str¶
Link type. It is strongly suggested to use values from the ‘identifier’ column in https://github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv
- url: str¶
Link url. If the URL is an OWS server, specify the base URL only without parameters like service=xxx….
- abstract(self) str [source]¶
Returns a free-form description of the resource.
See also
- Return type:
str
- addContact(self, contact: QgsAbstractMetadataBase.Contact)[source]¶
Adds an individual
contact
to the existing contacts.See also
See also
- Parameters:
contact (QgsAbstractMetadataBase.Contact)
- addHistoryItem(self, text: str | None)[source]¶
Adds a single history
text
to the end of the existing history list.See also
See also
- Parameters:
text (Optional[str])
- addKeywords(self, vocabulary: str | None, keywords: Iterable[str | None])[source]¶
Adds a list of descriptive
keywords
for a specifiedvocabulary
. 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
- Parameters:
vocabulary (Optional[str])
keywords (Iterable[Optional[str]])
- addLink(self, link: QgsAbstractMetadataBase.Link)[source]¶
Adds an individual
link
to the existing links.See also
See also
- Parameters:
link (QgsAbstractMetadataBase.Link)
- categories(self) List[str] [source]¶
Returns categories of the resource. Categories are stored using a special vocabulary ‘gmd:topicCategory’ in keywords.
See also
- Return type:
List[str]
- abstract clone(self) QgsAbstractMetadataBase | None [source]¶
Clones the metadata object.
Added in version 3.2.
- Return type:
Optional[QgsAbstractMetadataBase]
- virtual combine(self, other: QgsAbstractMetadataBase | None)[source]¶
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
.Added in version 3.20.
- Parameters:
other (Optional[QgsAbstractMetadataBase])
- contacts(self) List[QgsAbstractMetadataBase.Contact] [source]¶
Returns a list of contact persons or entities associated with the resource.
See also
- Return type:
- dateTime(self, type: Qgis.MetadataDateType) QDateTime [source]¶
Returns the date for the specified date
type
.See also
Added in version 3.30.
- Parameters:
type (Qgis.MetadataDateType)
- Return type:
QDateTime
- equals(self, other: QgsAbstractMetadataBase) bool [source]¶
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.
Added in version 3.2.
- Parameters:
other (QgsAbstractMetadataBase)
- Return type:
bool
- history(self) List[str] [source]¶
Returns a freeform description of the history or lineage of the resource.
See also
- Return type:
List[str]
- identifier(self) str [source]¶
A reference, URI, URL or some other mechanism to identify the resource.
See also
- Return type:
str
- keywordVocabularies(self) List[str] [source]¶
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
- Return type:
List[str]
- keywords(self) Dict[str, List[str]] [source]¶
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
See also
- Return type:
Dict[str, List[str]]
- keywords(self, vocabulary: str | None) List[str] [source]
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
- Parameters:
vocabulary (Optional[str])
- Return type:
List[str]
- language(self) str [source]¶
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
- Return type:
str
- links(self) List[QgsAbstractMetadataBase.Link] [source]¶
Returns a list of online resources associated with the resource.
See also
- Return type:
- parentIdentifier(self) str [source]¶
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
- Return type:
str
- virtual readMetadataXml(self, metadataElement: QDomElement) bool [source]¶
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 | None) bool [source]¶
Remove a vocabulary from the list.
See also
See also
- Parameters:
vocabulary (Optional[str])
- Return type:
bool
- setAbstract(self, abstract: str | None)[source]¶
Sets a free-form
abstract
(description) of the resource.See also
- Parameters:
abstract (Optional[str])
- setCategories(self, categories: Iterable[str | None])[source]¶
Sets categories of the resource. Categories are stored using a special vocabulary ‘gmd:topicCategory’ in keywords.
See also
- Parameters:
categories (Iterable[Optional[str]])
- setContacts(self, contacts: Iterable[QgsAbstractMetadataBase.Contact])[source]¶
Sets the list of
contacts
or entities associated with the resource. Any existing contacts will be replaced.See also
See also
- Parameters:
contacts (Iterable[QgsAbstractMetadataBase.Contact])
- setDateTime(self, type: Qgis.MetadataDateType, date: QDateTime | datetime.datetime)[source]¶
Sets a date value for the specified date
type
.See also
Added in version 3.30.
- Parameters:
type (Qgis.MetadataDateType)
date (Union[QDateTime, datetime.datetime])
- setHistory(self, history: Iterable[str | None])[source]¶
Sets the freeform description of the
history
or lineage of the resource. Any existing history items will be overwritten.See also
See also
- Parameters:
history (Iterable[Optional[str]])
- setIdentifier(self, identifier: str | None)[source]¶
Sets the reference, URI, URL or some other mechanism to identify the resource.
See also
- Parameters:
identifier (Optional[str])
- setKeywords(self, keywords: Dict[str | None, Iterable[str | None]])[source]¶
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
See also
- Parameters:
keywords (Dict[Optional[str], Iterable[Optional[str]]])
- setLanguage(self, language: str | None)[source]¶
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
- Parameters:
language (Optional[str])
- setLinks(self, links: Iterable[QgsAbstractMetadataBase.Link])[source]¶
Sets the list of online resources associated with the resource. Any existing links will be replaced.
See also
See also
- Parameters:
links (Iterable[QgsAbstractMetadataBase.Link])
- setParentIdentifier(self, parentIdentifier: str | None)[source]¶
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
- Parameters:
parentIdentifier (Optional[str])
- setTitle(self, title: str | None)[source]¶
Sets the human readable
title
(name) of the resource, typically displayed in search results.See also
- Parameters:
title (Optional[str])
- setType(self, type: str | None)[source]¶
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
- Parameters:
type (Optional[str])
- title(self) str [source]¶
Returns the human readable name of the resource, typically displayed in search results.
See also
- Return type:
str
- type(self) str [source]¶
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
- Return type:
str
- virtual writeMetadataXml(self, metadataElement: QDomElement, document: QDomDocument) bool [source]¶
Stores state in a DOM node.
- Parameters:
metadataElement (QDomElement) – is a DOM element corresponding to
resourceMetadata
tagdocument (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.