CDCAGG Common
This package contains common code shared among all CDC Aggregator components.
- cdcagg_common.list_collection_names()[source]
List all collection names
- Returns:
List of all collection names.
- Return type:
list
- cdcagg_common.list_records()[source]
List all record classes.
- Returns:
List of record classes
- Return type:
list
- cdcagg_common.record_by_collection_name(collname)[source]
Get record class by collection name
- Parameters:
collname (str) – Collection name for lookup.
- Returns:
Record class matching collname or None if no match found.
- Return type:
None or
cdcagg_common.records.Study
mappings.py
XML parsers that read XML and map the metadata to CDCAGG records.
- class cdcagg_common.mappings.DDI122NesstarRecordParser(root_element)[source]
Parse OAI-PMH record containing DDI122 Nesstar metadata and map it to CDCAGG records.
- class cdcagg_common.mappings.DDI25RecordParser(root_element)[source]
Parse OAI-PMH record containing DDI2.5 metadata and map it to CDCAGG records.
- class cdcagg_common.mappings.DDI31RecordParser(root_element)[source]
Parse OAI-PMH record containing DDI3.1 metadata and map it to CDCAGG records.
- class cdcagg_common.mappings.DDI32RecordParser(root_element)[source]
Parse OAI-PMH record containing DDI3.2. metadata and map it to CDCAGG records.
- class cdcagg_common.mappings.DDI33RecordParser(root_element)[source]
Parse OAI-PMH record containing DDI3.3. metadata and map it to CDCAGG records.
- class cdcagg_common.mappings.ProvenanceInfo(root_element, metadata_namespace)[source]
Helper class to map OAI-PMH source envelope XML to provenance info.
This is used for mapping purposes only. The provenance in
cdcagg_common.recordsis accessible via record instances and does not use this class.- __init__(root_element, metadata_namespace)[source]
Initiate ProvenanceInfo object with XML root element and direct source metadata namespace
- Parameters:
root_element (
xml.etree.ElementTree.Element) – XML root node.metadata_namespace (str) – Direct metadata namespace.
- Returns:
Instance of ProvenanceInfo
- Return type:
- property base_url
Get direct base url.
- Returns:
Direct base url
- Return type:
str
- full()[source]
Get full provenance info including indirect provenances.
Returned value is a list in which the first item is the direct provenance.
- Returns:
Full provenance.
- Return type:
list
- property identifier
Get direct identifier.
- Returns:
Direct identifier.
- Return type:
str
records.py
Define CDC Aggregator records.
These records define the internal data model for CDC Aggregator. They are reflected to the MongoDB database and DocStore record validation is dynamically constructed by consulting the record properties.
- class cdcagg_common.records.RecordBase(document_store_dictionary=None)[source]
Base class for all CDC Aggregator records.
Subclass of
kuha_common.document_store.records, which defines additional_provenance,_direct_base_urland_aggregator_identifierattributes.- __init__(document_store_dictionary=None)[source]
Instantiate a record instance.
If document_store_dictionary is given on init, the object is assumed an existing record and no attributes for new record are created.
- Note:
Do not instantiate directly but use from a subclass.
- Parameters:
document_store_dictionary (dict or None) – Record response from DocStore converted from JSON by Python dict.
- Returns:
Instance of a record subclass.
- export_dict(include_provenance=True, **kwargs)[source]
Export record as a dict.
Additional keyword arguments are passed to parent method
kuha_common.document_store.records.RecordBase.export_dict()- Parameters:
include_provenance (bool) – Include provenance in export.
- Returns:
Record as dictionary.
- Return type:
dict
- export_provenance_dict()[source]
Export provenance info as a dictionary.
- Returns:
Record’s provenance info.
- Return type:
dict
- class cdcagg_common.records.Study(document_store_dictionary=None)[source]
CDC Aggregator Study record.
Subclass that multi-inherits
RecordBaseandkuha_common.document_store.records.Study
mdb_const.py
Defines constants used in MongoDB