clients/ckanDraft.py
def patchGeneral(self, metadata, collPath = 'irods'):
        '''
        Adds and updates metadata to a CKAN draft.
        Mandatory metadata entries: CREATOR, TITLE, ABSTRACT, SUBJECT
        If data is not uploaded it is advised to provide pids pointing to the data in iRODS or
        to provide tickets for anonym ous data download.
        NOTE: If the draft already contains files, the update of metadata will fail.
        Parameters:
        metadata = ipc.mdGet()
        collPath = iRODS path or webdav access to collection or data object
        '''
        errorMsg = []
        curMeta = self.data
        print curMeta

        # CREATOR --> author
        curMeta['author'] = metadata['CREATOR'] 
    
        # ABSTRACT --> notes
        curMeta['notes'] = metadata['ABSTRACT']

        curMeta['url'] = collPath
        if 'extras' not in curMeta:
            curMeta['extras'] = []
        # TECHNICALINFO
        #if 'TECHNICALINFO' in metadata:
        #    curMeta['extras'].append({'key': 'iRODS ticket access with icommands', 'value': metadata['TECHNICALINFO']})
        # OTHER
        if 'OTHER' in metadata:
            curMeta['extras'].append({'key': 'Web access to iRODS instance', 'value': metadata['OTHER']})

        # collection iRODS path, PID and ticket --> otherId
        if 'PID' in metadata:
            curMeta['extras'].append({'key': 'Handle', 'value': 'hdl.handle.net/'+metadata['PID']})
        if 'TICKET' in metadata:
            curMeta['extras'].append({'key': 'Other ID', 'value': metadata['TICKET']})
 
        print curMeta
        #update CKAN entry
        action = 'package_update'
        action_url = 'http://{api}/action/{action}'.format(api=self.apiUrl, action=action)
        data_string = quote(json.dumps(curMeta))
        request = Request(action_url, data_string)
        request.add_header('Authorization', self.apiToken)    
        try:
            response = urlopen(request) # if name already exists or is not given throws 409
            self.data = curMeta
            errorMsg.append('CKAN PUBLISH INFO: Draft patched')
        except:
            errorMsg.append('CKAN PUBLISH ERROR: Draft not patched with with new metadata:' +
                'CREATOR, ABSTRACT, TECHNICALINFO, OTHER, PID or TICKET.')        
        return errorMsg

        Adds and updates metadata to a CKAN draft.
        Mandatory metadata entries: CREATOR, TITLE, ABSTRACT, SUBJECT
        If data is not uploaded it is advised to provide pids pointing to the data in iRODS or
        to provide tickets for anonym ous data download.
        NOTE: If the draft already contains files, the update of metadata will fail.
        Parameters:
        metadata = ipc.mdGet()
        collPath = iRODS path or webdav access to collection or data object
        
Adds and updates metadata to a CKAN draft.
Mandatory metadata entries: CREATOR, TITLE, ABSTRACT, SUBJECT
If data is not uploaded it is advised to provide pids pointing to the data in iRODS or
to provide tickets for anonym ous data download.
NOTE: If the draft already contains files, the update of metadata will fail.
Parameters:
metadata = ipc.mdGet()
collPath = iRODS path or webdav access to collection or data object
Adds and updates metadata to a CKAN draft . Mandatory metadata entries : CREATOR TITLE ABSTRACT SUBJECT If data is not uploaded it is advised to provide pids pointing to the data in iRODS or to provide tickets for anonym ous data download . NOTE : If the draft already contains files the update of metadata will fail . Parameters : metadata = ipc . mdGet () collPath = iRODS path or webdav access to collection or data object
def patchGeneral(self, metadata, collPath = 'irods'):
        errorMsg = []
        curMeta = self.data
        print curMeta
        curMeta['author'] = metadata['CREATOR'] 
        curMeta['notes'] = metadata['ABSTRACT']
        curMeta['url'] = collPath
        if 'extras' not in curMeta:
            curMeta['extras'] = []
        if 'OTHER' in metadata:
            curMeta['extras'].append({'key': 'Web access to iRODS instance', 'value': metadata['OTHER']})
        if 'PID' in metadata:
            curMeta['extras'].append({'key': 'Handle', 'value': 'hdl.handle.net/'+metadata['PID']})
        if 'TICKET' in metadata:
            curMeta['extras'].append({'key': 'Other ID', 'value': metadata['TICKET']})
        print curMeta
        action = 'package_update'
        action_url = 'http://{api}/action/{action}'.format(api=self.apiUrl, action=action)
        data_string = quote(json.dumps(curMeta))
        request = Request(action_url, data_string)
        request.add_header('Authorization', self.apiToken)    
        try:
            response = urlopen(request) 
            self.data = curMeta
            errorMsg.append('CKAN PUBLISH INFO: Draft patched')
        except:
            errorMsg.append('CKAN PUBLISH ERROR: Draft not patched with with new metadata:' +
                'CREATOR, ABSTRACT, TECHNICALINFO, OTHER, PID or TICKET.')        
        return errorMsg
def patchGeneral ( self , metadata , collPath = 'irods' ) : errorMsg = [ ] curMeta = self . data print curMeta curMeta [ 'author' ] = metadata [ 'CREATOR' ] curMeta [ 'notes' ] = metadata [ 'ABSTRACT' ] curMeta [ 'url' ] = collPath if 'extras' not in curMeta : curMeta [ 'extras' ] = [ ] if 'OTHER' in metadata : curMeta [ 'extras' ] . append ( { 'key' : 'Web access to iRODS instance' , 'value' : metadata [ 'OTHER' ] } ) if 'PID' in metadata : curMeta [ 'extras' ] . append ( { 'key' : 'Handle' , 'value' : 'hdl.handle.net/' + metadata [ 'PID' ] } ) if 'TICKET' in metadata : curMeta [ 'extras' ] . append ( { 'key' : 'Other ID' , 'value' : metadata [ 'TICKET' ] } ) print curMeta action = 'package_update' action_url = 'http://{api}/action/{action}' . format ( api = self . apiUrl , action = action ) data_string = quote ( json . dumps ( curMeta ) ) request = Request ( action_url , data_string ) request . add_header ( 'Authorization' , self . apiToken ) try : response = urlopen ( request ) self . data = curMeta errorMsg . append ( 'CKAN PUBLISH INFO: Draft patched' ) except : errorMsg . append ( 'CKAN PUBLISH ERROR: Draft not patched with with new metadata:' + 'CREATOR, ABSTRACT, TECHNICALINFO, OTHER, PID or TICKET.' ) return errorMsg
Adds and updates metadata to a CKAN draft.
Adds and updates metadata to a CKAN draft .
'''
        Adds and updates metadata to a CKAN draft.
        Mandatory metadata entries: CREATOR, TITLE, ABSTRACT, SUBJECT
        If data is not uploaded it is advised to provide pids pointing to the data in iRODS or
        to provide tickets for anonym ous data download.
        NOTE: If the draft already contains files, the update of metadata will fail.
        Parameters:
        metadata = ipc.mdGet()
        collPath = iRODS path or webdav access to collection or data object
        ''' # CREATOR --> author # ABSTRACT --> notes # TECHNICALINFO #if 'TECHNICALINFO' in metadata: #    curMeta['extras'].append({'key': 'iRODS ticket access with icommands', 'value': metadata['TECHNICALINFO']}) # OTHER # collection iRODS path, PID and ticket --> otherId #update CKAN entry # if name already exists or is not given throws 409
self
metadata
collPath