本文整理汇总了Python中au.edu.usq.fascinator.common.JsonConfigHelper.setJsonList方法的典型用法代码示例。如果您正苦于以下问题:Python JsonConfigHelper.setJsonList方法的具体用法?Python JsonConfigHelper.setJsonList怎么用?Python JsonConfigHelper.setJsonList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类au.edu.usq.fascinator.common.JsonConfigHelper
的用法示例。
在下文中一共展示了JsonConfigHelper.setJsonList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getJson
# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import setJsonList [as 别名]
def getJson(self, state = "open"):
title = "%s (%s)" % (self.getName(), self.getCount())
json = JsonConfigHelper()
json.set("attributes/id", self.getId())
json.set("attributes/fq", self.getFacetQuery())
json.set("attributes/title", title)
json.set("data", title)
hasSubFacets = not self.getSubFacets().isEmpty()
if hasSubFacets:
json.set("state", state)
subFacetList = ArrayList()
for subFacet in self.getSubFacets():
subFacetList.add(subFacet.getJson("closed"))
json.setJsonList("children", subFacetList)
return json
示例2: __getSolrData
# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import setJsonList [as 别名]
def __getSolrData(self):
prefix = self.getSearchTerms()
print "prefix='%s'" % prefix
if prefix:
query = "dc_title:%(prefix)s OR dc_title:%(prefix)s*" % {"prefix": prefix}
query += " OR f_dc_identifier:%(ns)s%(prefix)s OR f_dc_identifier:%(ns)s%(prefix)s*" % {
"prefix": prefix,
"ns": "http\://example.com/arc/",
}
else:
query = "*:*"
portal = self.services.portalManager.get(self.portalId)
if portal.searchQuery != "*:*" and portal.searchQuery != "":
query = query + " AND " + portal.searchQuery
req = SearchRequest(query)
req.setParam("fq", 'item_type:"object"')
if portal.query:
req.addParam("fq", portal.query)
req.setParam("fl", "score")
req.setParam("sort", "score desc")
req.setParam("start", self.getStartIndex())
req.setParam("rows", self.getItemsPerPage())
req.setParam("facet", "true")
req.setParam("facet.field", "repository_name")
req.setParam("facet.mincount", "1")
ns = self.getNamespace()
level = self.getFormData("level", None)
if level and level != "top":
req.addParam("fq", 'repository_name:"%s"' % level.replace(ns, ""))
try:
out = ByteArrayOutputStream()
indexer = self.services.getIndexer()
indexer.search(req, out)
results = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
if level == "top":
narrowerMap = {}
for doc in results.getJsonList("response/docs"):
value = doc.getList("repository_name").get(0)
hash = md5.md5(value).hexdigest()
if not narrowerMap.has_key(hash):
# print value, hash
narrowerMap[hash] = []
narrowerMap[hash].append(doc.get("id"))
docs = ArrayList()
facets = results.getList("facet_counts/facet_fields/repository_name")
for i in range(0, len(facets), 2):
value = facets[i]
hash = md5.md5(value).hexdigest()
# print value,hash
doc = JsonConfigHelper()
doc.set("score", "1")
doc.set("dc_identifier", "%s%s" % (ns, value))
doc.set("skos_inScheme", ns)
doc.set("skos_broader", "%s%s" % (ns, value))
doc.set("skos_narrower", '", "'.join(narrowerMap[hash]))
doc.set("skos_prefLabel", value)
docs.add(doc)
results.removePath("response/docs")
results.setJsonList("response/docs", docs)
return results
except Exception, e:
self.log.error("Failed to lookup '{}': {}", prefix, str(e))