Exemplo n.º 1
0
def main():
  collection_ids = [0]
  #collection_ids = [13,10,6,9,14,8]
  #collection_ids = [14] # Bob Day
  #collection_ids = [13] # 30th General Hospital
  #collection_ids = [8] # speck
  #collection_ids = [9] # School_of_Dentistry_130
  nx = utils.Nuxeo()
  pp = pprint.PrettyPrinter()

  links = {} 
  with open(hardlinks, "r") as h:
    for line in h:
      line = line.rstrip('\n')
      line = line.split(' ')
      links[line[0]] = line[1]
  
  for collection_id in collection_ids:
      # get items metadata 
      items_metadata = omnux.extract_items(api_url, collection_id)
      print 'Number of items in items_metadata', collection_id, ':', len(items_metadata)
 
      # transform and load
      for item in items_metadata:
        payload = omnux.transform_omeka_to_ucldc(item, collection_id, omnux_fieldmap_json, collection_mapping_json, links, corpnames)
        pp.pprint(payload)
        '''
Exemplo n.º 2
0
def main():
    collection_id = 15
    with open('omeka_md_berne.json', 'r') as f:
        items_metadata = json.load(f)
    print 'Number of items in items_metadata', collection_id, ':', len(items_metadata)

    nx = utils.Nuxeo()
    # transform and load
    missing = {}
    for item in items_metadata:
        #pp.pprint(item)
        #print '\n----------------------------------\n'
        identifier = get_identifier(item)
        nxuid = get_nuxeo_uid(identifier)
        if nxuid is None:
            missing[identifier] = item['id'] 
        else:
            nxpath = nx.get_metadata(uid=nxuid)['path']
            collection = get_nx_collection(nxpath)

            payload = omnux.transform_omeka_to_ucldc(item, collection, FIELDMAP, COLLECTION_MAP, {}, CORPNAMES)
            payload['path'] = nxpath
            #pp.pprint(payload)

            print "Will update {}".format(nxuid)
            nx.update_nuxeo_properties(payload, path=payload['path']) 
            print 'updated: {}'.format(payload['path'])

    with open('missing_berne.json', 'w') as f:
        json.dump(missing, f, indent=3)
Exemplo n.º 3
0
def main(argv=None):
    parser = argparse.ArgumentParser(description='batch load metadata from Omeka onto existing collection of objects in Nuxeo')
    parser.add_argument('path', help='Nuxeo path to collection')

    if argv is None:
        argv = parser.parse_args()

    nuxeo_path = argv.path
    print "Loading metadata for objects at Nuxeo path: {}\n".format(nuxeo_path)

    with open(OMEKA_ID_MAP_FILE) as mapfile:
        omeka_id_map = json.load(mapfile)

    with open(FIELDMAP) as fieldmapfile:
        omeka_field_map = json.load(fieldmapfile)

    nx = utils.Nuxeo()
    children = nx.children(nuxeo_path)

    for child in children:
        nxpath = child['path']
        print "\n", nxpath 
        dc_identifier = os.path.splitext(os.path.basename(nxpath))[0] 

        try:
            omeka_id = omeka_id_map[dc_identifier]['omeka_id']
        except KeyError:
            print "No corresponding Omeka ID found for {} -- Skipping.".format(dc_identifier)
            continue

        omeka_md = omnux.extract_single_item(OMEKA_API, omeka_id)
        payload = omnux.transform_omeka_to_ucldc(omeka_md, nuxeo_path, FIELDMAP, COLLECTION_MAP, {}, CORPNAMES)

        payload['path'] = nxpath

        '''
        import pprint
        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(payload)
        '''

        #try:
        uid = nx.get_uid(payload['path'])
        print "Will update {}".format(uid)
        nx.update_nuxeo_properties(payload, path=payload['path'])
        print 'updated: {}'.format(payload['path'])
        '''