Skip to content

oarepo_oaipmh_harvester.oai_harvester.models

oarepo_oaipmh_harvester.oai_harvester.models

Database models for OAI-PMH harvester metadata.

OAIHarvester

Bases: Model, Timestamp

Metadata about an OAI-PMH harvester.

Source code in oarepo_oaipmh_harvester/oai_harvester/models.py
class OAIHarvester(db.Model, db.Timestamp):
    """Metadata about an OAI-PMH harvester."""

    __tablename__ = "oai_harvesters"

    id = db.Column(db.String(30), primary_key=True)
    """ID of the harvester."""

    base_url = db.Column(db.String(255), nullable=False)
    """The base URL of the OAI-PMH service."""

    name = db.Column(db.String(255), nullable=False)
    """The name of the harvester."""

    comment = db.Column(db.Text, nullable=True)
    """Comment."""

    metadata_prefix = db.Column(db.String(64), nullable=False)
    """The metadata prefix to harvest."""

    setspec = db.Column(db.String(255), nullable=True)
    """The set specifications to harvest."""

    loader = db.Column(db.String(255), nullable=False)
    """The definition of the loader."""

    transformers = db.Column(
        JSONType(),
        default=list,
        nullable=False,
    )
    """The list of transformers."""

    writers = db.Column(
        JSONType(),
        default=list,
        nullable=False,
    )
    """The list of writers."""

    harvest_managers = db.Column(
        JSONType(),
        default=list,
        nullable=False,
    )
    """The list of harvest managers. An array of {"user": user_id} dicts."""

id = db.Column(db.String(30), primary_key=True) class-attribute instance-attribute

ID of the harvester.

base_url = db.Column(db.String(255), nullable=False) class-attribute instance-attribute

The base URL of the OAI-PMH service.

name = db.Column(db.String(255), nullable=False) class-attribute instance-attribute

The name of the harvester.

comment = db.Column(db.Text, nullable=True) class-attribute instance-attribute

Comment.

metadata_prefix = db.Column(db.String(64), nullable=False) class-attribute instance-attribute

The metadata prefix to harvest.

setspec = db.Column(db.String(255), nullable=True) class-attribute instance-attribute

The set specifications to harvest.

loader = db.Column(db.String(255), nullable=False) class-attribute instance-attribute

The definition of the loader.

transformers = db.Column(JSONType(), default=list, nullable=False) class-attribute instance-attribute

The list of transformers.

writers = db.Column(JSONType(), default=list, nullable=False) class-attribute instance-attribute

The list of writers.

harvest_managers = db.Column(JSONType(), default=list, nullable=False) class-attribute instance-attribute

The list of harvest managers. An array of {"user": user_id} dicts.

OAIHarvesterAggregateModel

Bases: AggregateMetadata

Aggregate data model for OAI-PMH harvesters.

Source code in oarepo_oaipmh_harvester/oai_harvester/models.py
class OAIHarvesterAggregateModel(AggregateMetadata):
    """Aggregate data model for OAI-PMH harvesters."""

    _model_obj: OAIHarvester | None

    # If you add properties here you likely also want to add a ModelField on
    # the OAIHarvesterAggregate API class.
    _properties = (
        "id",
        "base_url",
        "name",
        "comment",
        "metadata_prefix",
        "setspec",
        "loader",
        "transformers",
        "writers",
        "harvest_managers",
        "created",
        "updated",
    )
    """Properties of this object that can be accessed."""

    _set_properties = (
        "base_url",
        "name",
        "comment",
        "metadata_prefix",
        "setspec",
        "loader",
        "transformers",
        "writers",
        "harvest_managers",
    )
    """Properties of this object that can be set."""

    @property
    def model_obj(self) -> OAIHarvester:
        """The actual model object behind this harvester aggregate."""
        if self._model_obj is None:
            _id = (self._data or {}).get("id")
            with db.session.no_autoflush:
                self._model_obj = OAIHarvester.query.get(_id)
        if self._model_obj is None:
            raise ValueError("OAIHarvester not found")  # pragma: no cover
        return self._model_obj

    @property
    def version_id(self) -> int:
        """Return the version ID of the record."""
        return 1

model_obj: OAIHarvester property

The actual model object behind this harvester aggregate.

version_id: int property

Return the version ID of the record.