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.

__init__(root_element)[source]

Initiate DDI122NesstarRecordParser with XML root node.

Parameters:

root_element (xml.etree.ElementTree.Element) – XML root node.

Returns:

Instance of DDI122NesstarRecordParser

Return type:

DDI122NesstarRecordParser

class cdcagg_common.mappings.DDI25RecordParser(root_element)[source]

Parse OAI-PMH record containing DDI2.5 metadata and map it to CDCAGG records.

__init__(root_element)[source]

Initiate DDI25RecordParser with XML root node.

Parameters:

root_element (xml.etree.ElementTree.Element) – XML root node.

Returns:

Instance of DDI25RecordParser

Return type:

DDI25RecordParser

class cdcagg_common.mappings.DDI31RecordParser(root_element)[source]

Parse OAI-PMH record containing DDI3.1 metadata and map it to CDCAGG records.

__init__(root_element)[source]

Initiate DDI31RecordParser with XML root node.

Parameters:

root_element (xml.etree.ElementTree.Element) – XML root node.

Returns:

Instance of DDI31RecordParser

Return type:

DDI31RecordParser

class cdcagg_common.mappings.DDI32RecordParser(root_element)[source]

Parse OAI-PMH record containing DDI3.2. metadata and map it to CDCAGG records.

__init__(root_element)[source]

Initiate DDI32RecordParser with XML root node.

Parameters:

root_element (xml.etree.ElementTree.Element) – XML root node.

Returns:

Instance of DDI32RecordParser

Return type:

DDI32RecordParser

class cdcagg_common.mappings.DDI33RecordParser(root_element)[source]

Parse OAI-PMH record containing DDI3.3. metadata and map it to CDCAGG records.

__init__(root_element)[source]

Initiate DDI33RecordParser with XML root node.

Parameters:

root_element (xml.etree.ElementTree.Element) – XML root node.

Returns:

Instance of DDI33RecordParser

Return type:

DDI33RecordParser

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.records is 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:

ProvenanceInfo

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_url and _aggregator_identifier attributes.

__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

set_aggregator_identifier(value)[source]

Set aggregator identifier.

Silently overwrites previous value, if any.

Parameters:

value (str) – Aggregator identifier

set_direct_base_url(value)[source]

Set direct base url

Parameters:

value (str) – direct base url

Raises:

ValueError if direct base url is already set

class cdcagg_common.records.Study(document_store_dictionary=None)[source]

CDC Aggregator Study record.

Subclass that multi-inherits RecordBase and kuha_common.document_store.records.Study

classmethod iterate_record_fields()[source]

Override iterate_record_fields to include fields from both inherited classes.

Returns:

iterator yielding record fields.

Return type:

iterator

mdb_const.py

Defines constants used in MongoDB