本文整理汇总了Python中arches.app.models.concept.Concept.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Concept.delete方法的具体用法?Python Concept.delete怎么用?Python Concept.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arches.app.models.concept.Concept
的用法示例。
在下文中一共展示了Concept.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_concept
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import delete [as 别名]
def test_create_concept(self):
"""
Test of basic CRUD on a Concept model
"""
concept_in = Concept()
concept_in.nodetype = 'Concept'
concept_in.values = [ConceptValue({
#id: '',
#conceptid: '',
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label',
'language': 'en-US'
})]
concept_in.save()
concept_out = Concept().get(id=concept_in.id)
self.assertEqual(concept_out.id, concept_in.id)
self.assertEqual(concept_out.values[0].value, 'test pref label')
label = concept_in.values[0]
label.value = 'updated pref label'
concept_in.values[0] = label
concept_in.save()
concept_out = Concept().get(id=concept_in.id)
self.assertEqual(concept_out.values[0].value, 'updated pref label')
concept_out.delete(delete_self=True)
with self.assertRaises(models.Concept.DoesNotExist):
deleted_concept = Concept().get(id=concept_out.id)
示例2: manage_parents
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import delete [as 别名]
def manage_parents(request, conceptid):
# need to check user credentials here
if request.method == "POST":
json = request.body
if json != None:
data = JSONDeserializer().deserialize(json)
with transaction.atomic():
if len(data["deleted"]) > 0:
concept = Concept({"id": conceptid})
for deleted in data["deleted"]:
concept.addparent(deleted)
concept.delete()
if len(data["added"]) > 0:
concept = Concept({"id": conceptid})
for added in data["added"]:
concept.addparent(added)
concept.save()
return JSONResponse(data)
else:
return HttpResponseNotAllowed(["POST"])
return HttpResponseNotFound()
示例3: manage_parents
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import delete [as 别名]
def manage_parents(request, conceptid):
if request.method == 'POST':
json = request.body
if json != None:
data = JSONDeserializer().deserialize(json)
with transaction.atomic():
if len(data['deleted']) > 0:
concept = Concept().get(id=conceptid, include=None)
for deleted in data['deleted']:
concept.addparent(deleted)
concept.delete()
concept.bulk_index()
if len(data['added']) > 0:
concept = Concept().get(id=conceptid)
for added in data['added']:
concept.addparent(added)
concept.save()
concept.bulk_index()
return JSONResponse(data)
else:
return HttpResponseNotAllowed(['POST'])
return HttpResponseNotFound()
示例4: concept
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import delete [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
示例5: concept
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import delete [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