当前位置: 首页>>代码示例>>Python>>正文


Python URImanagement.get_uuid_from_oc_uri方法代码示例

本文整理汇总了Python中opencontext_py.apps.entities.uri.models.URImanagement.get_uuid_from_oc_uri方法的典型用法代码示例。如果您正苦于以下问题:Python URImanagement.get_uuid_from_oc_uri方法的具体用法?Python URImanagement.get_uuid_from_oc_uri怎么用?Python URImanagement.get_uuid_from_oc_uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opencontext_py.apps.entities.uri.models.URImanagement的用法示例。


在下文中一共展示了URImanagement.get_uuid_from_oc_uri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_list_cite_projects

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def make_list_cite_projects(self, json_ld):
     """ makes a string for citation of projects """
     projects_list = []
     cite_projects_list = []
     if 'dc-terms:source' in json_ld:
         for item in json_ld['dc-terms:source']:
             cite_projects_list.append(item['label'])
             proj_item = {}
             if 'rdfs:isDefinedBy' in item:
                 proj_item['uuid'] = URImanagement.get_uuid_from_oc_uri(item['rdfs:isDefinedBy'],
                                                                        False)
                 proj_item['uri'] = item['rdfs:isDefinedBy']
             else:
                 proj_item['uuid'] = URImanagement.get_uuid_from_oc_uri(item['id'],
                                                                        False)
                 proj_item['uri'] = item['id']
             proj_item['label'] = item['label']
             if 'count' in item:
                 proj_item['count'] = item['count']
             else:
                 proj_item['count'] = False
             projects_list.append(proj_item)
     self.cite_projects = ', '.join(cite_projects_list)
     self.projects_list = projects_list
     return self.cite_projects
开发者ID:ekansa,项目名称:open-context-py,代码行数:27,代码来源:templating.py

示例2: get_entity_parents

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def get_entity_parents(self, identifier):
     """
     Gets parent concepts for a given URI or UUID identified entity
     """
     self.loop_count += 1
     lequiv = LinkEquivalence()
     identifiers = lequiv.get_identifier_list_variants(identifier)
     p_for_superobjs = LinkAnnotation.PREDS_SBJ_IS_SUB_OF_OBJ
     preds_for_superobjs = lequiv.get_identifier_list_variants(p_for_superobjs)
     p_for_subobjs = LinkAnnotation.PREDS_SBJ_IS_SUPER_OF_OBJ
     preds_for_subobjs = lequiv.get_identifier_list_variants(p_for_subobjs)
     try:
         # look for superior items in the objects of the assertion
         # sorting by sort so we can privelage a certain hierarchy path
         superobjs_anno = LinkAnnotation.objects.filter(subject__in=identifiers,
                                                        predicate_uri__in=preds_for_superobjs)\
                                                .exclude(object_uri__in=identifiers)\
                                                .order_by('sort', 'object_uri')[:1]
         if(len(superobjs_anno) < 1):
             superobjs_anno = False
     except LinkAnnotation.DoesNotExist:
         superobjs_anno = False
     if(superobjs_anno is not False):
         parent_id = superobjs_anno[0].object_uri
         if(parent_id.count('/') > 1):
             oc_uuid = URImanagement.get_uuid_from_oc_uri(parent_id)
             if(oc_uuid is not False):
                 parent_id = oc_uuid
             if(parent_id not in self.parent_entities):
                 self.parent_entities.append(parent_id)
         if self.loop_count <= 50:
             self.parent_entities = self.get_entity_parents(parent_id)
     try:
         """
         Now look for superior entities in the subject, not the object
         sorting by sort so we can privelage a certain hierarchy path
         """
         supersubj_anno = LinkAnnotation.objects.filter(object_uri__in=identifiers,
                                                        predicate_uri__in=preds_for_subobjs)\
                                                .exclude(subject__in=identifiers)\
                                                .order_by('sort', 'subject')[:1]
         if(len(supersubj_anno) < 1):
             supersubj_anno = False
     except LinkAnnotation.DoesNotExist:
         supersubj_anno = False
     if supersubj_anno is not False:
         parent_id = supersubj_anno[0].subject
         if(parent_id.count('/') > 1):
             oc_uuid = URImanagement.get_uuid_from_oc_uri(parent_id)
             if(oc_uuid is not False):
                 parent_id = oc_uuid
             if(parent_id not in self.parent_entities):
                 self.parent_entities.append(parent_id)
         if self.loop_count <= 50:
             self.parent_entities = self.get_entity_parents(parent_id)
     return self.parent_entities
开发者ID:mfindeisen,项目名称:open-context-py,代码行数:58,代码来源:recursion.py

示例3: _get_entity_children_db

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def _get_entity_children_db(self, identifier, recursive=True):
     """
     Gets child concepts for a given URI or UUID identified entity
     """
     if not self.child_entities:
         self.child_entities = LastUpdatedOrderedDict()
     if identifier in self.child_entities and recursive:
         output = self.child_entities[identifier]
     else:
         act_children = []
         p_for_superobjs = LinkAnnotation.PREDS_SBJ_IS_SUB_OF_OBJ
         p_for_subobjs = LinkAnnotation.PREDS_SBJ_IS_SUPER_OF_OBJ
         lequiv = LinkEquivalence()
         identifiers = lequiv.get_identifier_list_variants(identifier)
         try:
             # look for child items in the objects of the assertion
             subobjs_anno = LinkAnnotation.objects.filter(subject__in=identifiers,
                                                          predicate_uri__in=p_for_subobjs)
             if(len(subobjs_anno) < 1):
                 subobjs_anno = False
         except LinkAnnotation.DoesNotExist:
             subobjs_anno = False
         if subobjs_anno is not False:
             for sub_obj in subobjs_anno:
                 child_id = sub_obj.object_uri
                 act_children.append(child_id)
         try:
             """
             Now look for subordinate entities in the subject, not the object
             """
             subsubj_anno = LinkAnnotation.objects.filter(object_uri__in=identifiers,
                                                          predicate_uri__in=p_for_superobjs)
             if len(subsubj_anno) < 1:
                 subsubj_anno = False
         except LinkAnnotation.DoesNotExist:
             subsubj_anno = False
         if subsubj_anno is not False:
             for sub_sub in subsubj_anno:
                 child_id = sub_sub.subject
                 act_children.append(child_id)
         if len(act_children) > 0:
             identifier_children = []
             for child_id in act_children:
                 if child_id.count('/') > 1:
                     oc_uuid = URImanagement.get_uuid_from_oc_uri(child_id)
                     if oc_uuid:
                         child_id = oc_uuid
                 identifier_children.append(child_id)
                 # recursively get the children of the child
                 if recursive:
                     self.get_entity_children(child_id, recursive)
             # same the list of children of the current identified item
             if identifier not in self.child_entities:
                 self.child_entities[identifier] = identifier_children
         else:
             # save a False for the current identified item. it has no children
             if identifier not in self.child_entities:
                 self.child_entities[identifier] = []
         output = self.child_entities[identifier]
     return output
开发者ID:ekansa,项目名称:open-context-py,代码行数:62,代码来源:recursion.py

示例4: get_identifier_list_variants

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def get_identifier_list_variants(self, id_list):
     """ makes different variants of identifiers
         for a list of identifiers
     """
     output_list = []
     if not isinstance(id_list, list):
         id_list = [str(id_list)]
     for identifier in id_list:
         output_list.append(identifier)
         if(identifier.startswith('http://') or identifier.startswith('https://')):
             oc_uuid = URImanagement.get_uuid_from_oc_uri(identifier)
             if oc_uuid:
                 output_list.append(oc_uuid)
             prefix_id = URImanagement.prefix_common_uri(identifier)
             if prefix_id:
                 output_list.append(prefix_id)
         elif ':' in identifier:
             full_uri = URImanagement.convert_prefix_to_full_uri(identifier)
             output_list.append(full_uri)
         else:
             # probably an open context uuid or a slug
             m_cache = MemoryCache()
             ent = m_cache.get_entity(identifier)
             if ent:
                 full_uri = ent.uri
                 output_list.append(full_uri)
                 prefix_uri = URImanagement.prefix_common_uri(full_uri)
                 if prefix_uri != full_uri:
                     output_list.append(prefix_uri)
     return output_list
开发者ID:ekansa,项目名称:open-context-py,代码行数:32,代码来源:equivalence.py

示例5: get_identifier_list_variants

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def get_identifier_list_variants(self, id_list):
     """ makes different variants of identifiers
         for a list of identifiers
     """
     output_list = []
     if not isinstance(id_list, list):
         id_list = [str(id_list)]
     for identifier in id_list:
         output_list.append(identifier)
         if(identifier[:7] == 'http://' or identifier[:8] == 'https://'):
             oc_uuid = URImanagement.get_uuid_from_oc_uri(identifier)
             if oc_uuid is not False:
                 output_list.append(oc_uuid)
             else:
                 prefix_id = URImanagement.prefix_common_uri(identifier)
                 output_list.append(prefix_id)
         elif ':' in identifier:
             full_uri = URImanagement.convert_prefix_to_full_uri(identifier)
             output_list.append(full_uri)
         else:
             # probably an open context uuid or a slug
             ent = Entity()
             found = ent.dereference(identifier)
             if found:
                 full_uri = ent.uri
                 output_list.append(full_uri)
                 prefix_uri = URImanagement.prefix_common_uri(full_uri)
                 if prefix_uri != full_uri:
                     output_list.append(prefix_uri)
     return output_list
开发者ID:portableant,项目名称:open-context-py,代码行数:32,代码来源:models.py

示例6: process_id

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def process_id(self, identifier):
     # check for identifier
     query_dict = {'fq': [],
                   'facet.field': []}
     fq_terms = []
     escape_id = self.escape_solr_arg(identifier)
     fq_terms.append('persistent_uri:' + escape_id)
     # now make a DOI URI in case this is just a naked DOI
     doi_uri = self.escape_solr_arg('http://dx.doi.org/' + identifier)
     fq_terms.append('persistent_uri:' + doi_uri)
     # now make an ARK URI in case this is just a naked ARK
     ark_uri = self.escape_solr_arg('http://n2t.net/' + identifier)
     fq_terms.append('persistent_uri:' + ark_uri)
     # now make an ORCID URI in case this is just a naked ORCID
     orcid_uri = self.escape_solr_arg('http://orcid.org/' + identifier)
     fq_terms.append('persistent_uri:' + orcid_uri)
     fq_terms.append('uuid:' + escape_id)
     tcheck = URImanagement.get_uuid_from_oc_uri(identifier, True)
     if tcheck is not False:
         uuid = tcheck['uuid']
         fq_terms.append('uuid:' + uuid)
     fq_final = ' OR '.join(fq_terms)
     fq_final = '(' + fq_final + ')'
     query_dict['fq'].append(fq_final)
     # print(fq_final)
     return query_dict
开发者ID:mfindeisen,项目名称:open-context-py,代码行数:28,代码来源:querymaker.py

示例7: _get_parent_id_db

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def _get_parent_id_db(self, identifier):
     """Get the parent id for the current identifier """
     parent_id = None
     lequiv = LinkEquivalence()
     identifiers = lequiv.get_identifier_list_variants(identifier)
     # print('identifiers: {}'.format(identifiers))
     p_for_superobjs = LinkAnnotation.PREDS_SBJ_IS_SUB_OF_OBJ
     preds_for_superobjs = lequiv.get_identifier_list_variants(p_for_superobjs)
     p_for_subobjs = LinkAnnotation.PREDS_SBJ_IS_SUPER_OF_OBJ
     preds_for_subobjs = lequiv.get_identifier_list_variants(p_for_subobjs)
     try:
         # look for superior items in the objects of the assertion
         # sorting by sort so we can privelage a certain hierarchy path
         superobjs_anno = LinkAnnotation.objects.filter(subject__in=identifiers,
                                                        predicate_uri__in=preds_for_superobjs)\
                                                .exclude(object_uri__in=identifiers)\
                                                .order_by('sort', 'object_uri')[:1]
         if len(superobjs_anno) < 1:
             superobjs_anno = False
     except LinkAnnotation.DoesNotExist:
         superobjs_anno = False
     if superobjs_anno:
         parent_id = superobjs_anno[0].object_uri
         # print('Subject {} is child of {}'.format(identifiers, parent_id))
         oc_uuid = URImanagement.get_uuid_from_oc_uri(parent_id)
         if oc_uuid:
             parent_id = oc_uuid
     try:
         """
         Now look for superior entities in the subject, not the object
         sorting by sort so we can privelage a certain hierarchy path
         """
         supersubj_anno = LinkAnnotation.objects.filter(object_uri__in=identifiers,
                                                        predicate_uri__in=preds_for_subobjs)\
                                                .exclude(subject__in=identifiers)\
                                                .order_by('sort', 'subject')[:1]
         if len(supersubj_anno) < 1:
             supersubj_anno = False
     except LinkAnnotation.DoesNotExist:
         supersubj_anno = False
     if supersubj_anno:
         parent_id = supersubj_anno[0].subject
         # print('Subject {} is parent of {}'.format(parent_id, identifiers))
         oc_uuid = URImanagement.get_uuid_from_oc_uri(parent_id)
         if oc_uuid:
             parent_id = oc_uuid
     return parent_id
开发者ID:ekansa,项目名称:open-context-py,代码行数:49,代码来源:recursion.py

示例8: parse_json_record

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def parse_json_record(self, json_rec):
     """ parses json for a
         geo-json feature of the record
     """
     if 'properties' in json_rec:
         props = json_rec['properties']
     else:
         props = json_rec
     if isinstance(props, dict):
         if 'id' in props:
             self.id = props['id'].replace('#', '')
         if 'label' in props:
             self.label = props['label']
         if 'href' in props:
             self.href = props['href']
         if 'uri' in props:
             item_type_output = URImanagement.get_uuid_from_oc_uri(props['uri'], True)
             if isinstance(item_type_output, dict):
                 self.item_type = item_type_output['item_type']
                 self.uuid = item_type_output['uuid']
         if 'project label' in props:
             self.project = props['project label']
         if 'context label' in props:
             self.context = props['context label']
         if 'early bce/ce' in props:
             self.early_bce_ce = props['early bce/ce']
             if self.early_bce_ce < 0:
                 self.early_bce_ce = int(round(self.early_bce_ce * -1, 0))
                 self.early_suffix = 'BCE'
             else:
                 self.early_bce_ce = int(round(self.early_bce_ce, 0))
                 self.early_suffix = False
         if 'late bce/ce' in props:
             self.late_bce_ce = props['late bce/ce']
             if self.late_bce_ce < 0:
                 self.late_bce_ce = int(round(self.late_bce_ce * -1, 0))
                 self.late_suffix = 'BCE'
             else:
                 self.late_bce_ce = int(round(self.late_bce_ce, 0))
                 self.late_suffix = False
         if 'item category' in props:
             self.category = props['item category']
         if 'snippet' in props:
             self.snippet = props['snippet']
             self.snippet = self.snippet.replace('<em>', '[[[[mark]]]]')
             self.snippet = self.snippet.replace('</em>', '[[[[/mark]]]]')
             self.snippet = strip_tags(self.snippet)
             self.snippet = self.snippet.replace('</', '')
             self.snippet = self.snippet.replace('<', '')
             self.snippet = self.snippet.replace('>', '')
             self.snippet = self.snippet.replace('[[[[mark]]]]', '<mark>')
             self.snippet = self.snippet.replace('[[[[/mark]]]]', '</mark>')
         if 'thumbnail' in props:
             self.thumbnail = props['thumbnail']
         if 'published' in props:
             self.published = QueryMaker().make_human_readable_date(props['published'])
         if 'updated' in props:
             self.updated = QueryMaker().make_human_readable_date(props['updated'])
开发者ID:portableant,项目名称:open-context-py,代码行数:60,代码来源:templating.py

示例9: process_equivalent_linked_data

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def process_equivalent_linked_data(self):
     """ Types are useful for entity reconciliation
         this checks for linked data associated
         with a type
     """
     for equiv_uri in self.LD_EQUIVALENT_PREDICATES:
         if equiv_uri in self.oc_item.json_ld and "foaf" not in equiv_uri:
             # for now, default to a close match
             fname = "skos_closematch___pred_id"
             allname = "obj_all___skos_closematch___pred_id"
             if fname not in self.fields:
                 self.fields[fname] = []
                 if self.ROOT_LINK_DATA_SOLR not in self.fields:
                     self.fields[self.ROOT_LINK_DATA_SOLR] = []
                 item = self._concat_solr_string_value(
                     "skos-closematch", "id", "http://www.w3.org/2004/02/skos/core#closeMatch", "Close Match"
                 )
                 self.fields[self.ROOT_LINK_DATA_SOLR].append(item)
             if allname not in self.fields:
                 self.fields[allname] = []
             for entity in self.oc_item.json_ld[equiv_uri]:
                 if "http://" in entity["id"] or "https://" in entity["id"]:
                     self.fields["text"] += entity["label"] + "\n"
                     self.fields["text"] += entity["id"] + "\n"
                     item = self._concat_solr_string_value(entity["slug"], "id", entity["id"], entity["label"])
                     self.fields[fname].append(item)
                     self.fields[allname].append(item)
                     self.process_object_uri(entity["id"])
     if "skos:related" in self.oc_item.json_ld:
         fname = "skos_related___pred_id"
         allname = "obj_all___skos_related___pred_id"
         if fname not in self.fields:
             self.fields[fname] = []
             if self.ROOT_LINK_DATA_SOLR not in self.fields:
                 self.fields[self.ROOT_LINK_DATA_SOLR] = []
             item = self._concat_solr_string_value(
                 "skos-related", "id", "http://www.w3.org/2004/02/skos/core#related", "Related"
             )
             self.fields[self.ROOT_LINK_DATA_SOLR].append(item)
         if allname not in self.fields:
             self.fields[allname] = []
         for entity in self.oc_item.json_ld["skos:related"]:
             if "http://" in entity["id"] or "https://" in entity["id"]:
                 self.fields["text"] += entity["label"] + "\n"
                 self.fields["text"] += entity["id"] + "\n"
                 item = self._concat_solr_string_value(entity["slug"], "id", entity["id"], entity["label"])
                 self.fields[fname].append(item)
                 self.fields[allname].append(item)
                 self.process_object_uri(entity["id"])
             elif "oc-pred:" in entity["id"] and "owl:sameAs" in entity:
                 pred_uuid = URImanagement.get_uuid_from_oc_uri(entity["owl:sameAs"])
                 self.fields["text"] += entity["label"] + "\n"
                 self.fields["text"] += entity["id"] + "\n"
                 item = self._concat_solr_string_value(
                     entity["slug"], "id", "/predicates/" + pred_uuid, entity["label"]
                 )
                 self.fields[fname].append(item)
                 self.fields[allname].append(item)
开发者ID:portableant,项目名称:open-context-py,代码行数:60,代码来源:solrdocument.py

示例10: get_project_authors

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def get_project_authors(self, project_uuid):
     """ Gets author information for a project """
     output = False
     creator_links = LinkAnnotation.objects\
                                   .filter(Q(subject=project_uuid),
                                           Q(predicate_uri=self.URI_DC_CREATE)
                                           | Q(predicate_uri=self.PRF_DC_CREATE))\
                                   .order_by('sort')
     if len(creator_links) < 1:
         # look for creators from the parent project
         par_proj = Project.objects\
                           .filter(uuid=project_uuid)\
                           .exclude(project_uuid=project_uuid)[:1]
         if len(par_proj) > 0:
             creator_links = LinkAnnotation.objects\
                                           .filter(Q(subject=par_proj[0].project_uuid),
                                                   Q(predicate_uri=self.URI_DC_CREATE)
                                                   | Q(predicate_uri=self.PRF_DC_CREATE))\
                                           .order_by('sort')
     if len(creator_links) > 0:
         for creator in creator_links:
             pid = URImanagement.get_uuid_from_oc_uri(creator.object_uri)
             if not pid:
                 pid = creator.object_uri
             if pid not in self.creators:
                 self.creators.append(pid)
     contrib_links = LinkAnnotation.objects\
                                   .filter(Q(subject=project_uuid),
                                           Q(predicate_uri=self.URI_DC_CONTRIB)
                                           | Q(predicate_uri=self.PRF_DC_CONTRIB))\
                                   .order_by('sort')
     for contrib in contrib_links:
         pid = URImanagement.get_uuid_from_oc_uri(contrib.object_uri)
         if not pid:
             pid = contrib.object_uri
         if pid not in self.contributors:
             if pid not in self.creators \
                or self.consolidate_authorship is False\
                or contrib.sort > 0:
                 self.contributors.append(pid)  # add to contrib if not a creator    
     if len(self.contributors) > 0 or len(self.creators) > 0:
         output = True
     return output
开发者ID:ekansa,项目名称:open-context-py,代码行数:45,代码来源:authorship.py

示例11: check_opencontext_uri

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def check_opencontext_uri(self, cell):
     """ looks for a valid opencontext uri in a cell """
     oc_item = False
     if 'http://opencontext.' in cell\
        or 'https://opencontext.' in cell:
         uuid = URImanagement.get_uuid_from_oc_uri(cell)
         if uuid is not False:
             # appears to be an Open Context URI
             # now check we actually have that entity in the database
             try:
                 oc_item = Manifest.objects.get(uuid=uuid)
             except Manifest.DoesNotExist:
                 oc_item = False
     return oc_item
开发者ID:mfindeisen,项目名称:open-context-py,代码行数:16,代码来源:manage.py

示例12: add_json_ld_link_annotations

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def add_json_ld_link_annotations(self, json_ld):
     """
     adds linked data annotations (typically referencing URIs from
     outside Open Context)
     """
     if not self.link_annotations or not len(self.link_annotations):
         # No link annotations, so skip out.
         return json_ld
     # We have link annotations.
     parts_json_ld = PartsJsonLD()
     parts_json_ld.proj_context_json_ld = self.proj_context_json_ld
     parts_json_ld.manifest_obj_dict = self.manifest_obj_dict
     for la in self.link_annotations:
         tcheck = URImanagement.get_uuid_from_oc_uri(la.object_uri, True)
         if not tcheck:
             # this item is NOT from open context
             item_type = False
         else:
             # an Open Context item
             item_type = tcheck['item_type']
         if item_type == 'persons':
             # add a stable ID to person items, but only if they are ORCID IDs
             parts_json_ld.stable_id_predicate = ItemKeys.PREDICATES_FOAF_PRIMARYTOPICOF
             parts_json_ld.stable_id_prefix_limit = StableIdentifer.ID_TYPE_PREFIXES['orcid']
         # this shortens URIs in item-context declared namespaces
         # to make a compact URI (prefixed), as the act_pred
         act_pred = URImanagement.prefix_common_uri(la.predicate_uri)
         if act_pred not in self.dc_author_preds \
            and act_pred not in self.dc_inherit_preds \
            and act_pred not in self.dc_metadata_preds:
             # the act_prec is not a dublin core predicate, so we're OK to add it
             # now, not later.
             json_ld = parts_json_ld.addto_predicate_list(
                 json_ld,
                 act_pred,
                 la.object_uri,
                 item_type
             )
         else:
             # we've got dublin core assertions, cache these in the dict_object
             # dc_assertions so they get added LAST, after other asserttions
             self.dc_assertions = parts_json_ld.addto_predicate_list(
                 self.dc_assertions,
                 act_pred,
                 la.object_uri,
                 item_type
             )
     return json_ld
开发者ID:ekansa,项目名称:open-context-py,代码行数:50,代码来源:attributes.py

示例13: get_solr_record_uuid_type

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def get_solr_record_uuid_type(self, solr_rec):
     """ get item uuid, label, and type from a solr_rec """
     output = False
     if isinstance(solr_rec, dict):
         output = {'uuid': False,
                   'label': False,
                   'item_type': False}
         if 'uuid' in solr_rec:
             output['uuid'] = solr_rec['uuid']
         if 'slug_type_uri_label' in solr_rec:
             id_parts = self.parse_solr_value_parts(solr_rec['slug_type_uri_label'])
             if id_parts is not False:
                 uri = self.make_url_from_val_string(id_parts['uri'], True)
                 item_type_output = URImanagement.get_uuid_from_oc_uri(uri, True)
                 output['item_type'] = item_type_output['item_type']
                 output['label'] = id_parts['label']
     return output
开发者ID:mfindeisen,项目名称:open-context-py,代码行数:19,代码来源:recordprops.py

示例14: get_item_json_ld

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def get_item_json_ld(self, item):
     """ gets metadata and uris
     """
     output = False
     if 'uri' in item:
         tcheck = URImanagement.get_uuid_from_oc_uri(item['uri'], True)
         if tcheck is False:
             item_type = False
         else:
             uuid = tcheck['uuid']
             item_type = tcheck['item_type']
             ocitem = OCitem()
             ocitem.get_item(uuid)
             if ocitem.manifest is not False:
                 output = ocitem.json_ld
             else:
                 output = False
     return output
开发者ID:mfindeisen,项目名称:open-context-py,代码行数:20,代码来源:models.py

示例15: load_csv

# 需要导入模块: from opencontext_py.apps.entities.uri.models import URImanagement [as 别名]
# 或者: from opencontext_py.apps.entities.uri.models.URImanagement import get_uuid_from_oc_uri [as 别名]
 def load_csv(self, filename, after=0, add_path=False):
     """ loads CSV dump from Merritt """
     if add_path:
         filename_path = os.path.join(settings.STATIC_ROOT,
                                      self.DEFAULT_DIRECTORY,
                                      filename)
     else:
         filename_path = filename
     data = csv.reader(open(filename_path))
     i = 0
     for row in data:
         manifest = False
         if 'ark:/' in row[0]:
             i += 0
             if i >= after:
                 uuid = URImanagement.get_uuid_from_oc_uri(row[1])
                 if uuid is not False:
                     try:
                         manifest = Manifest.objects.get(uuid=uuid,
                                                         archived__isnull=True)
                     except Manifest.DoesNotExist:
                         manifest = False
                 if manifest is not False:
                     ok_new = True
                     try:
                         sid = StableIdentifer()
                         sid.stable_id = row[0].replace('ark:/', '')
                         sid.stable_type = 'ark'
                         sid.uuid = manifest.uuid
                         sid.project_uuid = manifest.project_uuid
                         sid.item_type = manifest.item_type
                         sid.save()
                     except:
                         ok_new = False
                     # note when the item was last archived
                     try:
                         manifest.archived = self.validate_date(row[3])
                         manifest.archived_save()
                     except:
                         manifest.archived = time.strftime('%Y-%m-%d %H:%M:%S')
                         manifest.archived_save()
                     if ok_new:
                         self.id_recorded += 1
                     print('Saved ids: ' + str(self.id_recorded))
开发者ID:mfindeisen,项目名称:open-context-py,代码行数:46,代码来源:mediafiles.py


注:本文中的opencontext_py.apps.entities.uri.models.URImanagement.get_uuid_from_oc_uri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。