def getRecord(self, metadataPrefix, identifier): #pylint: disable=no-self-use,invalid-name """Returns pyoai data tuple for specific record""" # Should we implement this based on source_url and local_identifier the way we currently do for the harvester? result = frdr.get_metadata(identifier, db=config.POSTGRES_DB, user=config.POSTGRES_USER, password=config.POSTGRES_PASSWORD, server=config.POSTGRES_SERVER, port=config.POSTGRES_PORT) if not result: raise error.IdDoesNotExistError( "\"%s\" is unknown or illegal in this repository" % identifier) # Build metadata based on requested format and result metadata = self.build_metadata_map(result) header = self.build_header(result) record = self.build_record(metadata) data = ( header, record, None # About string - not used ) return data
def getRecord(self, metadataPrefix, identifier): self._check_metadata_prefix(metadataPrefix) doc_id = identifier.rsplit(":")[-1] record = self.session.documents.fetch(doc_id=doc_id) if not record: raise error.IdDoesNotExistError() return record.header(), record.metadata(), None
def listMetadataFormats(self, identifier=None): result = [i[:3] for i in self.formats] if identifier: result = [i for i in result if i[0] == identifier] if not result: raise error.IdDoesNotExistError() return result
def getRecord(self, **kw): """Returns (header, metadata, about) for given record.""" slug = self.identifier_to_slug(kw['identifier']) try: book = Book.objects.get(slug=slug) return self.record_for_book(book) except Book.DoesNotExist: book_type = ContentType.objects.get_for_model(Book) try: deleted_book = Deleted.objects.get(content_type=book_type, slug=slug) except: raise error.IdDoesNotExistError("No item for this identifier") return self.record_for_book(deleted_book)
def listMetadataFormats(self, **kw): formats = [ ('oai_dc', 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd', server.NS_OAIDC), ('qdc', 'http://dublincore.org/schemas/xmls/qdc/2006/01/06/dcterms.xsd', NS_DCTERMS)] if 'identifier' in kw: slug = self.identifier_to_slug(kw['identifier']) try: Book.objects.get(slug=slug) return formats except Book.DoesNotExist: try: Deleted.objects.get(slug=slug) return [] except Deleted.DoesNotExist: raise error.IdDoesNotExistError("This id does not exist") else: return formats
def getRecord(self, metadataPrefix, identifier): #pylint: disable=no-self-use,invalid-name """Returns pyoai data tuple for specific record""" # We just want the DOI out of the OAI identifier. _, doi = identifier.split(':', 1) result = datacite.get_metadata(doi) if not result: raise error.IdDoesNotExistError( "\"%s\" is unknown or illegal in this repository" % identifier) # Build metadata based on requested format and result metadata = self.build_metadata_map(result) header = self.build_header(result) record = self.build_record(metadata) data = ( header, record, None # About string - not used ) return data
def getRecord(self, metadataPrefix, identifier): try: return self._data[int(identifier)] except IndexError: raise error.IdDoesNotExistError("Id does not exist: %s" % identifier)