本文整理汇总了Python中arches.app.models.concept.Concept.get_parent_concept方法的典型用法代码示例。如果您正苦于以下问题:Python Concept.get_parent_concept方法的具体用法?Python Concept.get_parent_concept怎么用?Python Concept.get_parent_concept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arches.app.models.concept.Concept
的用法示例。
在下文中一共展示了Concept.get_parent_concept方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_search_results_dsl
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import get_parent_concept [as 别名]
def build_search_results_dsl(request):
# Results are sorted ascendingly by the value of SITE_ID.E42, which is displayed as primary name of Heritage Resources.
# Must go back to this method once new Automatic Resource ID has been fully developed (AZ 10/08/16) Update 06/09/16: EAMENA_ID.E42 now used as sorting criterion.
sorting = {
"child_entities.label": {
"order" : "asc",
"nested_path": "child_entities",
"nested_filter": {
"term": {"child_entities.entitytypeid" : "EAMENA_ID.E42"}
}
}
}
term_filter = request.GET.get('termFilter', '')
spatial_filter = JSONDeserializer().deserialize(request.GET.get('spatialFilter', None))
export = request.GET.get('export', None)
page = 1 if request.GET.get('page') == '' else int(request.GET.get('page', 1))
temporal_filter = JSONDeserializer().deserialize(request.GET.get('temporalFilter', None))
boolean_search = request.GET.get('booleanSearch', '')
filter_and_or = JSONDeserializer().deserialize(request.GET.get('termFilterAndOr', ''))
filter_grouping = JSONDeserializer().deserialize(request.GET.get('termFilterGroup', ''))
filter_combine_flags = JSONDeserializer().deserialize(request.GET.get('termFilterCombineWithPrev', ''))
#Ignore first entry as it is a dummy
filter_combine_flags = filter_combine_flags[1:]
# filter_combine_flags = [False, True, False, False, False]
# filter_groups = JSONDeserializer().deserialize(request.GET.get('termFilterGroups', ''))
# Not here yet, so put in some bogus data
# filter_groups = [
# 'NAME.E41',
# 'NAME.E41',
# 'DISTURBANCE_STATE.E3',
# 'THREAT_STATE.E3'
# ]
se = SearchEngineFactory().create()
if export != None:
limit = settings.SEARCH_EXPORT_ITEMS_PER_PAGE
else:
limit = settings.SEARCH_ITEMS_PER_PAGE
query = Query(se, start=limit*int(page-1), limit=limit)
boolquery = Bool()
boolfilter = Bool()
is_empty_temporal_filter = True
# store each search term in an initially. These will be combined based on the global and/or and the optional groupings
terms_queries = [];
# logging.warning("-------QUERY-------")
if term_filter != '' or not is_empty_temporal_filter:
for index, select_box in enumerate(JSONDeserializer().deserialize(term_filter)):
selectbox_boolfilter = Bool()
groupid = filter_grouping[index]
if not groupid == 'No group':
# build a nested query against the nested_entities
# trace the path from each term to the group root
term_paths = []
for term in select_box:
# trace path from group root to this term
if term['type'] == 'concept':
# get the parent concept for this value i.e. the field
term_parent_concept = Concept.get_parent_concept(term['value'])
# get the steps from the root to that concept
if term_parent_concept.nodetype.nodetype == "Collection":
term_schema = Entity.get_mapping_schema_to(term_parent_concept.legacyoid)
elif term_parent_concept.nodetype.nodetype == 'Concept':
# need to get at the parent until we reach the root collection. concepts are arranged hierarchically
parent_relations_to = models.ConceptRelations.objects.filter(conceptidto=term_parent_concept.conceptid, relationtype='member')
grandparent = models.Concepts.objects.filter(conceptid=parent_relations_to[0].conceptidfrom)
term_schema = Entity.get_mapping_schema_to(grandparent[0].legacyoid)
#this path begins at the root, and ends up at the node in question
term_path = term_schema['HERITAGE_RESOURCE_GROUP.E27']['steps']
term_paths.append({
'term': term,
'path': term_path
})
elif term['type'] == 'term':
concept = models.Concepts.objects.get(conceptid=term['context'])
term_schema = Entity.get_mapping_schema_to(concept.legacyoid)
term_path = term_schema['HERITAGE_RESOURCE_GROUP.E27']['steps']
term_paths.append({
'term': term,
'path': term_path
#.........这里部分代码省略.........