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


Python Concept.check_if_concept_in_use方法代码示例

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


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

示例1: concept

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

#.........这里部分代码省略.........
                        "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,
        )

        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:
            ret.append({"_type": id, "_source": concept_graph})
        else:
            ret.append(concept_graph)

        if emulate_elastic_search:
            ret = {"hits": {"hits": ret}}

        return JSONResponse(ret, indent=4 if pretty else None)

    if request.method == "POST":

        if len(request.FILES) > 0:
            skosfile = request.FILES.get("skosfile", None)
            imagefile = request.FILES.get("file", None)

            if imagefile:
                value = models.FileValues(
                    valueid=str(uuid.uuid4()),
                    value=request.FILES.get("file", None),
                    conceptid_id=conceptid,
                    valuetype_id="image",
                    languageid_id=settings.LANGUAGE_CODE,
                )
                value.save()
                return JSONResponse(value)

            elif skosfile:
                skos = SKOSReader()
                rdf = skos.read_file(skosfile)
                ret = skos.save_concepts_from_skos(rdf)
                return JSONResponse(ret)

        else:
            data = JSONDeserializer().deserialize(request.body)
            if data:
                with transaction.atomic():
                    concept = Concept(data)
                    concept.save()
                    concept.index()

                    return JSONResponse(concept)

    if request.method == "DELETE":
        data = JSONDeserializer().deserialize(request.body)

        if data:
            with transaction.atomic():

                concept = Concept(data)

                delete_self = data["delete_self"] if "delete_self" in data else False
                if not (delete_self and concept.id in CORE_CONCEPTS):
                    in_use = False
                    if delete_self:
                        check_concept = Concept().get(data["id"], include_subconcepts=True)
                        in_use = check_concept.check_if_concept_in_use()
                    if "subconcepts" in data:
                        for subconcept in data["subconcepts"]:
                            if in_use == False:
                                check_concept = Concept().get(subconcept["id"], include_subconcepts=True)
                                in_use = check_concept.check_if_concept_in_use()

                    if in_use == False:
                        concept.delete_index(delete_self=delete_self)
                        concept.delete(delete_self=delete_self)
                    else:
                        return JSONResponse({"in_use": in_use})

                return JSONResponse(concept)

    return HttpResponseNotFound
开发者ID:oswalpalash,项目名称:arches,代码行数:104,代码来源:concept.py

示例2: concept

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

#.........这里部分代码省略.........
                    '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:
            ret.append({'_type': id, '_source': concept_graph})
        else:
            ret.append(concept_graph)

        if emulate_elastic_search:
            ret = {'hits':{'hits':ret}}

        return JSONResponse(ret, indent=4 if pretty else None)

    if request.method == 'POST':

        if len(request.FILES) > 0:
            skosfile = request.FILES.get('skosfile', None)
            imagefile = request.FILES.get('file', None)

            if imagefile:
                value = models.FileValue(valueid = str(uuid.uuid4()), value = request.FILES.get('file', None), conceptid_id = conceptid, valuetype_id = 'image',languageid_id = settings.LANGUAGE_CODE)
                value.save()
                return JSONResponse(value)

            elif skosfile:
                skos = SKOSReader()
                rdf = skos.read_file(skosfile)
                ret = skos.save_concepts_from_skos(rdf)
                return JSONResponse(ret)

        else:
            data = JSONDeserializer().deserialize(request.body)
            if data:
                with transaction.atomic():
                    concept = Concept(data)
                    concept.save()
                    concept.index()

                    return JSONResponse(concept)


    if request.method == 'DELETE':
        data = JSONDeserializer().deserialize(request.body)

        if data:
            with transaction.atomic():

                concept = Concept(data)

                delete_self = data['delete_self'] if 'delete_self' in data else False
                if not (delete_self and concept.id in CORE_CONCEPTS):
                    in_use = False
                    if delete_self:
                        check_concept = Concept().get(data['id'], include_subconcepts=True)
                        in_use = check_concept.check_if_concept_in_use()
                    if 'subconcepts' in data:
                        for subconcept in data['subconcepts']:
                            if in_use == False:
                                check_concept = Concept().get(subconcept['id'], include_subconcepts=True)
                                in_use = check_concept.check_if_concept_in_use()

                    if in_use == False:
                        concept.delete_index(delete_self=delete_self)
                        concept.delete(delete_self=delete_self)
                    else:
                        return JSONResponse({"in_use": in_use})

                return JSONResponse(concept)

    return HttpResponseNotFound
开发者ID:cropandsave,项目名称:arches,代码行数:104,代码来源:concept.py


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