Commits

Anonymous committed 1ca2ae7

fixed didl feeds

Comments (0)

Files changed (3)

moai/metadata/dare_didl.py

 
     def __init__(self, prefix, config, db):
         super(DareDIDL, self).__init__(prefix, config, db)
-        self.prefix = 'nl_didl'
-
-        self.ns['nl_didl'] = self.ns['didl']
-        self.schemas['nl_didl'] = self.schemas['didl']
+        self.prefix = 'didl'
 
     def __call__(self, element, metadata):
         super(DareDIDL, self).__call__(element, metadata)

moai/metadata/didl.py

             self.prefix,
             data['id']))
 
+        id_url = data['metadata'].get('url', [None])[0]        
+
         # generate mods for this feed
         mods_data = DIDL.Resource(mimeType="application/xml")
         MODS('mods', self.config, self.db)(mods_data, metadata)
                )
               ),
              DIDL.Component(
-              DIDL.Resource(ref=oai_url,mimeType="application/xml")
+              DIDL.Resource(ref=id_url or oai_url,mimeType="application/xml")
               ),
              DIDL.Item(
               DIDL.Descriptor(
                DIDL.Statement(descriptive_metadata, mimeType="application/xml")
                ),
-              DIDL.Component(mods_data)
+              DIDL.Component(
+                DIDL.Descriptor(
+                   DIDL.Statement("mods", mimeType="text/plain")),
+                mods_data)
               ),
              )
             )
             'info:eu-repo/semantics/objectFile')
         for root_item in didl:
             for asset in data['metadata'].get('asset', []):
-                url = asset['url'][0]
+                url = asset['url']
                 if not url.startswith('http://'):
                     url = self.config.url.rstrip('/') + '/' + url.lstrip('/')
                 item = DIDL.Item(
                      DIDL.Statement(object_file, mimeType="application/xml")
                      )
                     )
-                for access in asset.get('access', []):
-                    if access == 'open':
-                        access = (
-                            'http://purl.org/eprint/accessRights/OpenAccess')
-                    elif access == 'restricted':
-                        access = (
-                            'http://purl.org/eprint/accessRights/RestrictedAccess')
-                    elif access == 'closed':
-                        access = (
-                            'http://purl.org/eprint/accessRights/ClosedAccess')
+                access = asset.get('access')
+                if access == 'open':
+                    access = (
+                        'http://purl.org/eprint/accessRights/OpenAccess')
+                elif access == 'restricted':
+                    access = (
+                        'http://purl.org/eprint/accessRights/RestrictedAccess')
+                elif access == 'closed':
+                    access = (
+                        'http://purl.org/eprint/accessRights/ClosedAccess')
+                if access:
                     item.append(
                         DIDL.Descriptor(
                         DIDL.Statement(DCTERMS.accessRights(access),
                     
                 item.append(
                     DIDL.Component(
-                     DIDL.Resource(mimeType=asset['mimetype'][0],
+                     DIDL.Resource(mimeType=asset['mimetype'],
                                    ref=url)
                      )
                     )

moai/metadata/mods.py

+import uuid
 
 from lxml.builder import ElementMaker
 
 
             dai_list = []
             for contributor in contributor_data:
-                unique_id = data['id'] + '_' + contributor.get(
-                    'id', contributor['name'][0])
+                contributor_name = contributor.get('surname', [''])[0]
+                unique_id = uuid.uuid4().hex
                 if unique_id[0].isdigit():
                     unique_id = '_'+unique_id
-                unique_id = unique_id.replace(':', '')
                 name = MODS.name(
-                    MODS.displayForm(contributor['name'][0]),
+                    MODS.displayForm(contributor_name),
                     type='personal',
                     ID=unique_id
                     )