def checkMetadataRequirements(self): import datacite if self.isDatacite and not self.isReserved: # If the identifier has DataCite or Crossref XML metadata, we # know automatically that metadata requirements are satisfied # (in the Crossref case, by virtue of the design of the # Crossref-to-DataCite transform, which always generates a # complete DataCite record). if "datacite" not in self.cm and\ (not self.usesCrossrefProfile or "crossref" not in self.cm): try: datacite.formRecord(self.identifier, self.cm, profile=self.profile.label) except AssertionError, e: raise django.core.exceptions.ValidationError( "Public DOI metadata requirements not satisfied: %s." % str(e))
def dataciteMetadata(self): # Returns citation metadata as a DataCite XML record. (The record # includes an encoding declaration, but is not actually encoded.) # This method does not check metadata requirements, and always # returns a record; missing attributes will be "(:unav)". The # mapping is based on the identifier's preferred metadata profile # but with priority given to the DataCite fields. import datacite return datacite.formRecord(self.identifier, self.cm, supplyMissing=True, profile=self.profile.label)
def _updateEzid(request, d, stts, m_to_upgrade=None): """ Takes data from form fields in /manage/edit and applies them to IDs metadata If m_to_upgrade is specified, converts record to advanced datacite Returns ezid.setMetadata (successful return is the identifier string) Also removes tags related to old profile if converting to advanced datacite """ m_dict = { '_target': request.POST['target'], '_status': stts, '_export': ('yes' if (not 'export' in d) or d['export'] == 'yes' else 'no') } if m_to_upgrade: d['current_profile'] = metadata.getProfile('datacite') # datacite_xml ezid profile is defined by presence of 'datacite' assigned to the # '_profile' key and XML present in the 'datacite' key m_dict['datacite'] = datacite.formRecord(d['id_text'], m_to_upgrade, True) m_dict['_profile'] = 'datacite' # Old tag cleanup if m_to_upgrade.get("_profile", "") == "datacite": m_dict['datacite.creator'] = '' m_dict['datacite.publisher'] = '' m_dict['datacite.publicationyear'] = '' m_dict['datacite.title'] = '' m_dict['datacite.type'] = '' if m_to_upgrade.get("_profile", "") == "dc": m_dict['dc.creator'] = '' m_dict['dc.date'] = '' m_dict['dc.publisher'] = '' m_dict['dc.title'] = '' m_dict['dc.type'] = '' if m_to_upgrade.get("_profile", "") == "erc": m_dict['erc.who'] = '' m_dict['erc.what'] = '' m_dict['erc.when'] = '' # ToDo: Using current_profile here, but isn't this confusing if executing simpleToAdvanced to_write = uic.assembleUpdateDictionary(request, d['current_profile'], m_dict) return ezid.setMetadata(d['id_text'], userauth.getUser(request, returnAnonymous=True), to_write)