Ejemplo n.º 1
0
 def make_table_dc_creator_list(self, proj_uuid_counts):
     """ makes a list of dublin core creators
         from a project uuid + counts list """
     dc_creators = []
     for proj_uuid_count in proj_uuid_counts:
         project_uuid = proj_uuid_count['project_uuid']
         proj_count = proj_uuid_count['num_uuids']
         auth = Authorship()
         auth.get_project_authors(project_uuid)
         if len(auth.creators) < 1 and \
            len(auth.contributors) > 0:
             auth.creators = auth.contributors
         if len(auth.creators) > 0:
             for auth_uuid in auth.creators:
                 auth_man = False
                 try:
                     auth_man = Manifest.objects.get(uuid=auth_uuid)
                 except Manifest.DoesNotExist:
                     auth_man = False
                 if auth_man is not False:
                     i = len(dc_creators) + 1
                     item = LastUpdatedOrderedDict()
                     item['id'] = URImanagement.make_oc_uri(auth_uuid, 'persons')
                     item['count'] = proj_count
                     dc_creators.append(item)
     return dc_creators
Ejemplo n.º 2
0
 def save_authorship(self, row_num, man):
     """ Saves authorship information """
     authors = ''
     auth = Authorship()
     found = auth.get_authors(man.uuid,
                              man.project_uuid)
     if found:
         # save counts of different dc-terms:creator for use as table metadata
         for auth_id in auth.creators:
             if auth_id not in self.dc_creator_ids:
                 self.dc_creator_ids[auth_id] = 0
             self.dc_creator_ids[auth_id] += 1
         # save counts of different dc-terms:contributor for use as table metadata    
         for auth_id in auth.contributors:
             if auth_id not in self.dc_contributor_ids:
                 self.dc_contributor_ids[auth_id] = 0
             self.dc_contributor_ids[auth_id] += 1    
         all_author_ids = auth.creators + auth.contributors
         all_authors = []
         for auth_id in all_author_ids:
             author = self.deref_entity_label(auth_id)
             all_authors.append(author)
         authors = '; '.join(all_authors)
     # save Authors
     cell = ExpCell()
     cell.table_id = self.table_id
     cell.uuid = man.uuid
     cell.project_uuid = man.project_uuid
     cell.row_num = row_num
     cell.field_num = 7
     cell.record = authors
     cell.save()
     cell = None
Ejemplo n.º 3
0
 def get_predicate_link_annotations(self):
     """ Gets the link data annotations for predicates used on a table """
     auth = Authorship()
     for pred_uuid, pred in self.predicate_uuids.items():
         la_s = LinkAnnotation.objects\
                              .filter(subject=pred_uuid)
         if len(la_s) > 0:
             self.predicate_uuids[pred_uuid]['annotations'] = []
             self.predicate_uuids[pred_uuid]['ld-equiv'] = []
         for la in la_s:
             link_anno = {'pred': la.predicate_uri,
                          'obj': la.object_uri}
             self.predicate_uuids[pred_uuid]['annotations'].append(link_anno)
             if la.predicate_uri in self.EQUIV_PREDICATES:
                 authorship = auth.check_authorship_object(la.object_uri)
                 if authorship is False:  # only keep predicates not related to authorship
                     pred_ld_equiv_uri = la.object_uri  # the object_uri is equivalent to
                                                        # the predicate_uuid
                     self.predicate_uuids[pred_uuid]['ld-equiv'].append(pred_ld_equiv_uri)
                     if la.object_uri not in self.ld_predicates:
                         pred_equiv_label = self.deref_entity_label(pred_ld_equiv_uri)
                         self.ld_predicates[pred_ld_equiv_uri] = {'uuids': [pred_uuid],
                                                                  'obj_uuids': {},
                                                                  'obj_uris': [],
                                                                  'label': pred_equiv_label}
                     else:
                         self.ld_predicates[pred_ld_equiv_uri]['uuids'].append(pred_uuid)
     return self.ld_predicates
Ejemplo n.º 4
0
 def save_authorship(self, row_num, man):
     """ Saves authorship information """
     authors = ''
     auth = Authorship()
     found = auth.get_authors(man.uuid, man.project_uuid)
     if found:
         # save counts of different dc-terms:creator for use as table metadata
         for auth_id in auth.creators:
             if auth_id not in self.dc_creator_ids:
                 self.dc_creator_ids[auth_id] = 0
             self.dc_creator_ids[auth_id] += 1
         # save counts of different dc-terms:contributor for use as table metadata
         for auth_id in auth.contributors:
             if auth_id not in self.dc_contributor_ids:
                 self.dc_contributor_ids[auth_id] = 0
             self.dc_contributor_ids[auth_id] += 1
         all_author_ids = auth.creators + auth.contributors
         all_authors = []
         for auth_id in all_author_ids:
             author = self.deref_entity_label(auth_id)
             all_authors.append(author)
         authors = '; '.join(all_authors)
     # save Authors
     cell = ExpCell()
     cell.table_id = self.table_id
     cell.uuid = man.uuid
     cell.project_uuid = man.project_uuid
     cell.row_num = row_num
     cell.field_num = 7
     cell.record = authors
     cell.save()
     cell = None
Ejemplo n.º 5
0
 def get_predicate_link_annotations(self):
     """ Gets the link data annotations for predicates used on a table """
     auth = Authorship()
     for pred_uuid, pred in self.predicate_uuids.items():
         la_s = LinkAnnotation.objects\
                              .filter(subject=pred_uuid)
         if len(la_s) > 0:
             self.predicate_uuids[pred_uuid]['annotations'] = []
             self.predicate_uuids[pred_uuid]['ld-equiv'] = []
         for la in la_s:
             link_anno = {'pred': la.predicate_uri, 'obj': la.object_uri}
             self.predicate_uuids[pred_uuid]['annotations'].append(
                 link_anno)
             if la.predicate_uri in self.EQUIV_PREDICATES:
                 authorship = auth.check_authorship_object(la.object_uri)
                 if authorship is False:  # only keep predicates not related to authorship
                     pred_ld_equiv_uri = la.object_uri  # the object_uri is equivalent to
                     # the predicate_uuid
                     self.predicate_uuids[pred_uuid]['ld-equiv'].append(
                         pred_ld_equiv_uri)
                     if la.object_uri not in self.ld_predicates:
                         pred_equiv_label = self.deref_entity_label(
                             pred_ld_equiv_uri)
                         self.ld_predicates[pred_ld_equiv_uri] = {
                             'uuids': [pred_uuid],
                             'obj_uuids': {},
                             'obj_uris': [],
                             'label': pred_equiv_label
                         }
                     else:
                         self.ld_predicates[pred_ld_equiv_uri][
                             'uuids'].append(pred_uuid)
     return self.ld_predicates
Ejemplo n.º 6
0
 def make_table_dc_creator_list(self, proj_uuid_counts):
     """ makes a list of dublin core creators
         from a project uuid + counts list """
     dc_creators = []
     for proj_uuid_count in proj_uuid_counts:
         project_uuid = proj_uuid_count['project_uuid']
         proj_count = proj_uuid_count['num_uuids']
         auth = Authorship()
         auth.get_project_authors(project_uuid)
         if len(auth.creators) < 1 and \
            len(auth.contributors) > 0:
             auth.creators = auth.contributors
         if len(auth.creators) > 0:
             for auth_uuid in auth.creators:
                 auth_man = False
                 try:
                     auth_man = Manifest.objects.get(uuid=auth_uuid)
                 except Manifest.DoesNotExist:
                     auth_man = False
                 if auth_man is not False:
                     i = len(dc_creators) + 1
                     item = LastUpdatedOrderedDict()
                     item['id'] = URImanagement.make_oc_uri(
                         auth_uuid, 'persons')
                     item['count'] = proj_count
                     dc_creators.append(item)
     return dc_creators