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


Python Concept.get_node_and_links方法代码示例

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


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

示例1: concept

# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import get_node_and_links [as 别名]

#.........这里部分代码省略.........
                    labels.append(value)

            if mode == "" and (
                this_concept.nodetype == "Concept"
                or this_concept.nodetype == "ConceptScheme"
                or this_concept.nodetype == "EntityType"
            ):
                if concept_graph.nodetype == "ConceptScheme":
                    parent_relations = relationtypes.filter(category="Properties")
                else:
                    parent_relations = (
                        relationtypes.filter(category="Semantic Relations")
                        .exclude(relationtype="related")
                        .exclude(relationtype="broader")
                        .exclude(relationtype="broaderTransitive")
                    )
                return render_to_response(
                    "views/rdm/concept-report.htm",
                    {
                        "lang": lang,
                        "prefLabel": prefLabel,
                        "labels": labels,
                        "concept": concept_graph,
                        "languages": languages,
                        "sparql_providers": get_sparql_providers(),
                        "valuetype_labels": valuetypes.filter(category="label"),
                        "valuetype_notes": valuetypes.filter(category="note"),
                        "valuetype_related_values": valuetypes.filter(category="undefined"),
                        "parent_relations": parent_relations,
                        "related_relations": relationtypes.filter(
                            Q(category="Mapping Properties") | Q(relationtype="related")
                        ),
                        "concept_paths": concept_graph.get_paths(lang=lang),
                        "graph_json": JSONSerializer().serialize(concept_graph.get_node_and_links(lang=lang)),
                        "direct_parents": [parent.get_preflabel(lang=lang) for parent in concept_graph.parentconcepts],
                    },
                    context_instance=RequestContext(request),
                )
            else:
                return render_to_response(
                    "views/rdm/entitytype-report.htm",
                    {
                        "lang": lang,
                        "prefLabel": prefLabel,
                        "labels": labels,
                        "concept": concept_graph,
                        "languages": languages,
                        "valuetype_labels": valuetypes.filter(category="label"),
                        "valuetype_notes": valuetypes.filter(category="note"),
                        "valuetype_related_values": valuetypes.filter(category="undefined"),
                        "related_relations": relationtypes.filter(relationtype="member"),
                        "concept_paths": concept_graph.get_paths(lang=lang),
                    },
                    context_instance=RequestContext(request),
                )

        concept_graph = Concept().get(
            id=conceptid,
            include_subconcepts=include_subconcepts,
            include_parentconcepts=include_parentconcepts,
            include_relatedconcepts=include_relatedconcepts,
            depth_limit=depth_limit,
            up_depth_limit=None,
            lang=lang,
        )
开发者ID:oswalpalash,项目名称:arches,代码行数:69,代码来源:concept.py

示例2: concept

# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import get_node_and_links [as 别名]
def concept(request, conceptid):
    f = request.GET.get('f', 'json')
    mode = request.GET.get('mode', '')
    lang = request.GET.get('lang', settings.LANGUAGE_CODE)
    pretty = request.GET.get('pretty', False)

    if request.method == 'GET':

        include_subconcepts = request.GET.get('include_subconcepts', 'true') == 'true'
        include_parentconcepts = request.GET.get('include_parentconcepts', 'true') == 'true'
        include_relatedconcepts = request.GET.get('include_relatedconcepts', 'true') == 'true'
        emulate_elastic_search = request.GET.get('emulate_elastic_search', 'false') == 'true'
        depth_limit = request.GET.get('depth_limit', None)

        if f == 'html':
            depth_limit = 1
            if not conceptid:
                return render(request, 'views/rdm/concept-report.htm', {
                    'lang': lang,
                    'concept_count': models.Concept.objects.filter(nodetype='Concept').count(),
                    'collection_count': models.Concept.objects.filter(nodetype='Collection').count(),
                    'scheme_count': models.Concept.objects.filter(nodetype='ConceptScheme').count(),
                    'entitytype_count': models.Concept.objects.filter(nodetype='EntityType').count(),
                    'default_report': True
                })

        ret = []
        labels = []
        this_concept = Concept().get(id=conceptid)

        if f == 'html':
            if mode == '' and (this_concept.nodetype == 'Concept' or this_concept.nodetype == 'ConceptScheme' or this_concept.nodetype == 'EntityType'):
                concept_graph = Concept().get(id=conceptid, include_subconcepts=include_subconcepts,
                    include_parentconcepts=include_parentconcepts, include_relatedconcepts=include_relatedconcepts,
                    depth_limit=depth_limit, up_depth_limit=None, lang=lang)
            else:
                concept_graph = Concept().get(id=conceptid, include_subconcepts=include_subconcepts,
                    include_parentconcepts=include_parentconcepts, include_relatedconcepts=include_relatedconcepts,
                    depth_limit=depth_limit, up_depth_limit=None, lang=lang, semantic=False)

            languages = models.DLanguage.objects.all()
            valuetypes = models.DValueType.objects.all()
            relationtypes = models.DRelationType.objects.all()
            prefLabel = concept_graph.get_preflabel(lang=lang)
            for subconcept in concept_graph.subconcepts:
                subconcept.prefLabel = subconcept.get_preflabel(lang=lang)
            for relatedconcept in concept_graph.relatedconcepts:
                relatedconcept.prefLabel = relatedconcept.get_preflabel(lang=lang)
            for value in concept_graph.values:
                if value.category == 'label':
                    labels.append(value)

            if mode == '' and (this_concept.nodetype == 'Concept' or this_concept.nodetype == 'ConceptScheme' or this_concept.nodetype == 'EntityType'):
                if concept_graph.nodetype == 'ConceptScheme':
                    parent_relations = relationtypes.filter(category='Properties')
                else:
                    parent_relations = relationtypes.filter(category='Semantic Relations').exclude(relationtype = 'related').exclude(relationtype='broader').exclude(relationtype='broaderTransitive')
                return render(request, 'views/rdm/concept-report.htm', {
                    'lang': lang,
                    'prefLabel': prefLabel,
                    'labels': labels,
                    'concept': concept_graph,
                    'languages': languages,
                    'sparql_providers': get_sparql_providers(),
                    'valuetype_labels': valuetypes.filter(category='label'),
                    'valuetype_notes': valuetypes.filter(category='note'),
                    'valuetype_related_values': valuetypes.filter(category='undefined'),
                    'parent_relations': parent_relations,
                    'related_relations': relationtypes.filter(Q(category='Mapping Properties') | Q(relationtype = 'related')),
                    'concept_paths': concept_graph.get_paths(lang=lang),
                    'graph_json': JSONSerializer().serialize(concept_graph.get_node_and_links(lang=lang)),
                    'direct_parents': [parent.get_preflabel(lang=lang) for parent in concept_graph.parentconcepts]
                })
            else:
                return render(request, 'views/rdm/entitytype-report.htm', {
                    'lang': lang,
                    'prefLabel': prefLabel,
                    'labels': labels,
                    'concept': concept_graph,
                    'languages': languages,
                    'valuetype_labels': valuetypes.filter(category='label'),
                    'valuetype_notes': valuetypes.filter(category='note'),
                    'valuetype_related_values': valuetypes.filter(category='undefined'),
                    'related_relations': relationtypes.filter(relationtype = 'member'),
                    'concept_paths': concept_graph.get_paths(lang=lang)
                })


        concept_graph = Concept().get(id=conceptid, include_subconcepts=include_subconcepts,
                include_parentconcepts=include_parentconcepts, include_relatedconcepts=include_relatedconcepts,
                depth_limit=depth_limit, up_depth_limit=None, lang=lang)

        if f == 'skos':
            include_parentconcepts = False
            include_subconcepts = True
            depth_limit = None
            skos = SKOSWriter()
            return HttpResponse(skos.write(concept_graph, format="pretty-xml"), content_type="application/xml")

        if emulate_elastic_search:
#.........这里部分代码省略.........
开发者ID:cropandsave,项目名称:arches,代码行数:103,代码来源:concept.py


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