'
return s
def displayItem(query, term, selected, field, language, count):
s = '\n' + space + ' '
s = s + escapeHtml(displayTerm(term, field, language)) + ' (' + str(count) + ')'
s = s + ' '
return s
def displayFilter(query, value, label, term):
s = '\n' + space + ' '
# s = s + label+ ': '
s = s + escapeHtml(term)
s = s + ' '
return s
def displayDrilldownFields(total, bitMatrixRow, httpQuery, arguments, language):
selectedFacets = arguments.get('drilldown', [])
selectedFieldNames = {}
if selectedFacets:
for drilldownItem in selectedFacets:
fieldName, value = fieldAndTermSplit(drilldownItem)
if not fieldName in selectedFieldNames: selectedFieldNames[fieldName] = []
selectedFieldNames[fieldName].append(value)
yield '\n' + space + '
'
sortKeys = arguments.get('sortKeys', [''])[0]
if total < 500000:
####### TP: result set is not too large, multilevel results will be calculated
multilevelResults = any.multiLevelDrilldown(bitMatrixRow, ['date', 'author'])
previousUpField = ""
for (fieldName, levelField), termCounts in multilevelResults:
upField = ""
if levelField == "drilldown.norm.date.decennium" and "drilldown.norm.date.centennium" in selectedFieldNames:
upField = "drilldown.norm.date.centennium"
elif levelField == "drilldown.norm.date.year" and "drilldown.norm.date.centennium" in selectedFieldNames:
upField = "drilldown.norm.date.centennium"
elif levelField == "drilldown.norm.date.year" and "drilldown.norm.date.decennium" in selectedFieldNames:
upField = "drilldown.norm.date.decennium"
elif levelField == "drilldown.norm.name.oneinitial" and "drilldown.norm.name.lastname" in selectedFieldNames:
upField = "drilldown.norm.name.lastname"
if upField:
for term in selectedFieldNames[upField]:
if not (upField == previousUpField):
label = drilldownFieldNames.get(upField, {'en':upField, 'nl':upField})[language]
yield '\n' + space + ' %s' % displayLabel(label)
yield '\n' + space + '
'
for term, count in termCounts:
if levelField in selectedFieldNames and term in selectedFieldNames[levelField]:
drilldownArgs = set(selectedFacets)
drilldownArgs.remove(levelField + ":" + term)
query = createDrilldownQuery(drilldownArgs, httpQuery, sortKeys)
yield displayItem(query, term, True, levelField, language, count)
else:
drilldownArgs = set(arguments.get('drilldown', []) + [fieldAndTermJoin(levelField, term)])
query = createDrilldownQuery(drilldownArgs, httpQuery, sortKeys)
yield displayItem(query, term, False, levelField, language, count)
yield '\n' + space + '
'
fields = drilldownFields
else:
####### TP: result set is too large, only one level of the multilevel facests will be calculated.
fields = drilldownFieldsNoMultiLevel
# fields = drilldownFields
drilldownResults = any.drilldown(bitMatrixRow, fields)
drilldownResultsAsDict = dict(drilldownResults)
for fieldName, number, sorted in fields:
termCounts = drilldownResultsAsDict.get(fieldName,[])
label = drilldownFieldNames.get(fieldName, {'en':fieldName, 'nl':fieldName})[language]
if termCounts == []:
continue
yield '\n' + space + ' %s' % displayLabel(label)
yield '\n' + space + '
'
for term, count in termCounts:
if fieldName in selectedFieldNames and term in selectedFieldNames[fieldName]:
drilldownArgs = set(selectedFacets)
drilldownArgs.remove(fieldName + ":" + term)
query = createDrilldownQuery(drilldownArgs, httpQuery, sortKeys)
yield displayItem(query, term, True, fieldName, language, count)
#yield '\n' + space + '