-
Notifications
You must be signed in to change notification settings - Fork 5
MetadataLayer
Every API has a different way of representing bibliographic metadata (facts about a book, like its title) and licensing data (facts about access to a book, like the number of patrons in its holds queue). The metadata layer abstracts away the differences between APIs, and hides the complexity of the underlying data model.
When you learn something about a title in the collection, you need to
find out as much bibliographic information about that title as
possible, and create an Identifier, Edition, LicensePool, and
Work for it. The simplest way to do this is through the metadata
layer.
The metadata layer is defined in core/metadata_layer.py.
A CirculationData object contains information about a license for a
book. This includes how many copies of the title are available and in
which formats. You can provide all the necessary items in the
constructor:
-
data_source: The name of the data source that provides the license. For your integration this will always be the constant you added to theDataSourceclass. -
primary_identifier: AnIdentifierDataobject that lets the circulation manager know how it should refer to the title when talking to the license provider. This is usually some sort of proprietary ID, but sometimes it's ISBN. -
licenses_owned: The number of licenses owned by the library that licensed this collection. If this collection doesn't track single-use licenses, it's okay to set this to 1 or 0, depending on whether the title is currently in the collection. -
licenses_available: The number of licenses that can be loaned out right now. If this collection doesn't track single-use licenses, it's okay to set this to 1 or 0, depending on whether the title can be loaned out right now. -
patrons_in_hold_queue: The number of patrons who are waiting in line to borrow this book. If this collection doesn't track single-use licenses, this will probably always be 0. -
licenses_reserved: The number of licenses that are in the following (somewhat specialized) state: someone put the book on hold waited for it, and is now at the front of the queue. The book is available for them to borrow, but no one else can borrow it.If you don't know how many titles are in this state, it's okay to set this to 0.
-
formats: A list ofFormatDataobjects that explain what formats have been licensed. There must be at least oneFormatDataobject, or there will be no way to deliver the title to a patron.
There are two other constructor arguments designed for use with open-access collections:
-
default_rights_uri: The terms under which this title is made available to the general public (not to the library that licensed this collection) This should be one of the constants defined incore/model.py:RightsStatus. The default isIN_COPYRIGHT, which is appropriate for any title that is not open-access. -
links: This list may contain one or moreLinkDataobjects which link to actual copies of the book.
A Metadata object contains bibliographic information about an item.
-
data_source: The name of the data source that provides the metadata. For your integration this will always be the constant you added to theDataSourceclass. -
title: The title of the item. -
subtitle: The item's subtitle, if any. -
sort_title: The item's sort title, if different from thetitle. -
language: The primary language of the item. This should be a three-character ISO 639-2 code like "eng". -
medium: The medium of the item. This is one of the_MEDIUMconstants fromcore/model.py:Edition; usuallyBOOK_MEDIUMorAUDIO_MEDIUM. -
series: If this item belongs to a series of items, the name of the series. -
series_position: The item's numeric position within its series, if it has one. -
publisher: The publisher that issued this electronic edition. -
imprint: The imprint ofpublisher, if any, that issued this electronic edition. -
issued: A `datetime object indicating when this electronic edition of the work was first made available. This date should be within the past few years. -
published: Adatetimeobject indicating when this work was originally published. This date might be hundreds of years in the past. -
primary_identifier: AnIdentifierDataobject that lets the circulation manager know how it should refer to the title when talking to the data provider. This is usually some sort of proprietary ID, but sometimes it's ISBN. -
identifiers: A list ofIdentifierDataobjects representing other ways the data provider has of referring to this title. There really ought to be an ISBN in here. -
subjects: A list ofSubjectDataobjects representing the subjects under which the data provider thinks this title should be filed. -
contributors: A list ofContributorDataobjects representing the authors and other people who contributed to this title. -
measurements: A list ofMeasurementDataobjects representing measurements the data provider has taken of this title. -
links: A list ofLinkDataobjects representing related resources such as cover images. -
recommendations: A list ofIdentifierDataobjects representing other titles that the data provider recommends for people who liked this title. -
circulation: An optionalCirculationData. If your API provides metadata and circulation information at the same time, you can create aCirculationDataobject and carry it around inside aMetadataobject.
TBD
TBD
TBD
TBD
TBD
TBD
When you create a Metadata or CirculationData object, you've captured the current state of affairs as described on some remote server. Now you need to make the local database reflect that state of affairs. The apply method will take your metadata-layer object and create or modify the necessary database objects to make the database reflect what the third party says.
-
collectionis aCollectionobject representing the collection that contains the book you're talking about. If necessary,applywill create aLicensePoolin that collection representing the fact that this book is available in this collection. -
replaceis aReplacementPolicyobject (see below).
-
editionis anEditionobject representing bibliographic information about this book. You can get an appropriate edition by callingedition(_db)on theMetadataobject. -
collectionis aCollectionobject representing the collection that contains the book you're talking about. If you're talking about the book in abstract terms, rather than any particular copies of the book, you can leave this blank.
When you call an apply method, you're supposed to pass in a
ReplacementPolicy object as well.
TBD