Exemplo n.º 1
0
    def _run_import(self, xml, job):
        if not model.User.get('harvest'):
            model.User(name='harvest', sysadmin=True).save()
        if not model.Group.get('test'):
            get_action('organization_create')({
                'user': '******'
            }, {
                'name': 'test'
            })

        record = _get_record(xml)

        metadata = CmdiReader()(record)
        metadata['unified']['owner_org'] = "test"

        harvest_object = HarvestObject()
        harvest_object.content = json.dumps(metadata.getMap())
        harvest_object.id = xml
        harvest_object.guid = xml
        harvest_object.source = job.source
        harvest_object.harvest_source_id = None
        harvest_object.job = job
        harvest_object.save()

        self.harvester.import_stage(harvest_object)
        return harvest_object
Exemplo n.º 2
0
 def test_reader(self):
     record = _get_record("cmdi_1.xml")
     metadata = CmdiReader("http://localhost/test")(record)
     content= metadata.getMap()
     package = content['unified']
     self.assertEquals(package.get('name', None), 'urn-nbn-fi-lb-20140730180')
     self.assertEquals(package.get('notes', None), '{"eng": "Test description"}')
     self.assertEquals(package.get('version', None), '2012-09-07')
     self.assertEquals(package.get('title', []), '{"eng": "Longi Corpus"}')
Exemplo n.º 3
0
 def test_reader(self):
     record = _get_record("cmdi_1.xml")
     metadata = CmdiReader("http://localhost/test")(record)
     content = metadata.getMap()
     package = content['unified']
     self.assertEquals(package.get('name', None),
                       utils.pid_to_name(package.get('id', None)))
     self.assertEquals(utils.get_primary_pid(package),
                       u'http://urn.fi/urn:nbn:fi:lb-20140730180')
     self.assertEquals(package.get('notes', None),
                       '{"eng": "Test description"}')
     self.assertEquals(package.get('version', None), '2012-09-07')
     self.assertEquals(package.get('title', []), '{"eng": "Longi Corpus"}')
Exemplo n.º 4
0
    def _run_import(self, xml, job):
        if not model.User.get('harvest'):
            model.User(name='harvest', sysadmin=True).save()
        if not model.Group.get('test'):
            get_action('organization_create')({'user': '******'}, {'name': 'test'})

        record = _get_record(xml)

        metadata = CmdiReader()(record)
        metadata['unified']['owner_org'] = "test"

        harvest_object = HarvestObject()
        harvest_object.content = json.dumps(metadata.getMap())
        harvest_object.id = xml
        harvest_object.guid = xml
        harvest_object.source = job.source
        harvest_object.harvest_source_id = None
        harvest_object.job = job
        harvest_object.save()

        self.harvester.import_stage(harvest_object)
        return harvest_object
Exemplo n.º 5
0
def create_metadata_registry(harvest_type=None, service_url=None):
    '''Return new metadata registry with all common metadata readers

    The readers currently implemented are for metadataPrefixes
    oai_dc, nrd, rdf and xml.

    :returns: metadata registry instance
    :rtype: oaipmh.metadata.MetadataRegistry
    '''
    registry = om.MetadataRegistry()
    registry.registerReader('oai_dc',
                            dc_metadata_reader(harvest_type or 'default'))
    registry.registerReader('cmdi0571', CmdiReader(service_url))
    registry.registerReader('oai_datacite3', DataCiteReader())
    registry.registerReader('nrd', nrd_metadata_reader)
    registry.registerReader('rdf', rdf_reader)
    registry.registerReader('xml', xml_reader)
    return registry