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


Python JsonConfigHelper.getList方法代码示例

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


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

示例1: __getStorageId

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]
 def __getStorageId(self, oid):
     req = SearchRequest('id:"%s"' % oid)
     req.addParam("fl", "storage_id")
     out = ByteArrayOutputStream()
     Services.indexer.search(req, out)
     json = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     return json.getList("response/docs").get(0).get("storage_id")
开发者ID:kiranba,项目名称:the-fascinator,代码行数:9,代码来源:download.py

示例2: test

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]
 def test(self):
     s = "data "
     json = JsonConfigHelper()
     try:
         l = json.getList("test")
         s += str(l.size())
         s += " '%s' " % json.get("test1")
     except Exception, e:
         s += "Error '%s'" % str(e)
开发者ID:kiranba,项目名称:the-fascinator,代码行数:11,代码来源:package.py

示例3: __activate__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]
 def __activate__(self, context):
     response = context["response"]
     writer = response.getPrintWriter("text/plain; charset=UTF-8")
     auth = context["page"].authentication
     result = JsonConfigHelper()
     result.set("status", "error")
     result.set("message", "An unknown error has occurred")
     if auth.is_logged_in() and auth.is_admin():
         services = context["Services"]
         formData = context["formData"]
         func = formData.get("func")
         oid = formData.get("oid")
         portalId = formData.get("portalId")
         portalManager = services.portalManager
         if func == "reharvest":
             if oid:
                 print "Reharvesting object '%s'" % oid
                 portalManager.reharvest("oid")
                 result.set("status", "ok")
                 result.set("message", "Object '%s' queued for reharvest")
             elif portalId:
                 print " Reharvesting view '%s'" % portalId
                 # TODO security filter
                 # TODO this should loop through the whole portal,
                 #      not just the first page of results
                 portal = portalManager.get(portalId)
                 req = SearchRequest(portal.query)
                 req.setParam("fq", 'item_type:"object"')
                 out = ByteArrayOutputStream();
                 services.indexer.search(req, out)
                 json = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
                 objectIds = json.getList("response/docs//id")
                 if not objectIds.isEmpty():
                     portalManager.reharvest(objectIds)
                 result.set("status", "ok")
                 result.set("message", "Objects in '%s' queued for reharvest" % portalId)
             else:
                 response.setStatus(500)
                 result.set("message", "No object or view specified for reharvest")
         elif func == "reindex":
             if oid:
                 print "Reindexing object '%s'" % oid
                 services.indexer.index(oid)
                 services.indexer.commit()
                 result.set("status", "ok")
                 result.set("message", "Objects in '%s' queued for reharvest" % portalId)
             else:
                 response.setStatus(500)
                 result.set("message", "No object specified to reindex")
         else:
             response.setStatus(500)
             result.set("message", "Unknown action '%s'" % func)
     else:
         response.setStatus(500)
         result.set("message", "Only administrative users can access this API")
     writer.println(result.toString())
     writer.close()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:59,代码来源:reharvest.py

示例4: __getNavDataUnedited

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]
 def __getNavDataUnedited(self):
     query = self.sessionState.get("query")
     if query == "":
         query = "*:*"
     req = SearchRequest(query)
     req.setParam("fl", "id dc_title")
     req.setParam("sort", "f_dc_title asc")
     req.setParam("rows", "10000")
     pq = self.services.portalManager.get(self.portalId).query
     req.setParam("fq", pq)
     req.addParam("fq", 'item_type:"object"')
     req.addParam("fq", "workflow_modified:false")
     fq = self.sessionState.get("fq")
     if fq:
         for q in fq:
             req.addParam("fq", q)
     out = ByteArrayOutputStream()
     self.__indexer.search(req, out)
     result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     oidList = result.getList("response/docs/id")
     nameList = result.getList("response/docs/dc_title")
     return oidList, nameList
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:24,代码来源:nameAuthority.py

示例5: __getNavData

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]
 def __getNavData(self):
     query = self.sessionState.get("query")
     if query == "":
         query = "*:*"
     req = SearchRequest(query)
     req.setParam("fl", "id dc_title")
     req.setParam("sort", "f_dc_title asc")
     req.setParam("rows", "10000")   ## TODO there could be more than this
     req.setParam("facet", "true")
     req.addParam("facet.field", "workflow_step")
     req.setParam("facet.sort", "false")
     
     pq = self.services.portalManager.get(self.portalId).query
     req.setParam("fq", pq)
     req.addParam("fq", 'item_type:"object"')
     fq = self.sessionState.get("fq")
     if fq:
         for q in fq:
             req.addParam("fq", q)
     
     out = ByteArrayOutputStream()
     self.__indexer.search(req, out)
     result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     oidList = result.getList("response/docs/id")
     nameList = result.getList("response/docs/dc_title")
     
     wfStep = result.getList("facet_counts/facet_fields/workflow_step")
     self.pending = 0
     self.confirmed = 0
     for i in range(len(wfStep)):
         if wfStep[i] == "pending":
             self.pending = wfStep[i+1]
         if wfStep[i] == "live":
             self.confirmed = wfStep[i+1]
     
     self.total = self.pending + self.confirmed
     return oidList, nameList
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:39,代码来源:nameAuthority.py

示例6: __search

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]
    def __search(self, searchField):
        indexer = self.services.getIndexer()
        portalQuery = self.services.getPortalManager().get(self.portal.getName()).getQuery()
        portalSearchQuery = self.services.getPortalManager().get(self.portal.getName()).getSearchQuery()

        # Security prep work
        current_user = self.page.authentication.get_username()
        security_roles = self.page.authentication.get_roles_list()
        security_filter = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
        security_exceptions = 'security_exception:"' + current_user + '"'
        owner_query = 'owner:"' + current_user + '"'
        security_query = "(" + security_filter + ") OR (" + security_exceptions + ") OR (" + owner_query + ")"

        startRow = 0
        numPerPage = 25
        numFound = 0

        req = SearchRequest(searchField)
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        if not self.page.authentication.is_admin():
            req.addParam("fq", security_query)

        objectIdList = []
        while True:
            req.addParam("fq", 'item_type:"object"')
            req.addParam("rows", str(numPerPage))
            req.addParam("start", str(startRow))

            out = ByteArrayOutputStream()
            indexer.search(req, out)
            result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))

            docs = result.getList("response/docs/storage_id")

            objectIdList.extend(docs)

            startRow += numPerPage
            numFound = int(result.get("response/numFound"))

            if startRow > numFound:
                break

        return objectIdList
开发者ID:kiranba,项目名称:the-fascinator,代码行数:48,代码来源:batchprocess.py

示例7: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]
class HomeData:
    def __init__(self):
        action = formData.get("verb")
        portalName = formData.get("value")
        sessionState.remove("fq")
        if action == "delete-portal":
            print " * home.py: delete portal %s" % portalName
            Services.portalManager.remove(portalName)
        self.__latest = JsonConfigHelper()
        self.__mine = JsonConfigHelper()
        self.__workflows = JsonConfigHelper()
        self.__result = JsonConfigHelper()
        self.__search()
    
    def __search(self):
        indexer = Services.getIndexer()
        portalQuery = Services.getPortalManager().get(portalId).getQuery()
        portalSearchQuery = Services.getPortalManager().get(portalId).getSearchQuery()
        
        # Security prep work
        current_user = page.authentication.get_username()
        security_roles = page.authentication.get_roles_list()
        security_query = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
        owner_query = 'owner:"' + current_user + '"'

        req = SearchRequest("last_modified:[NOW-1MONTH TO *]")
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.setParam("rows", "10")
        req.setParam("sort", "last_modified desc, f_dc_title asc");
        if not page.authentication.is_admin():
            req.addParam("fq", "(" + security_query + ") OR (" + owner_query + ")")
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        self.__latest = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        
        req = SearchRequest(owner_query)
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.setParam("rows", "10")
        req.setParam("sort", "last_modified desc, f_dc_title asc");
        if not page.authentication.is_admin():
            req.addParam("fq", "(" + security_query + ") OR (" + owner_query + ")")
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        self.__mine = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))

        req = SearchRequest('workflow_security:"' + current_user + '"')
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.setParam("rows", "10")
        req.setParam("sort", "last_modified desc, f_dc_title asc");
        if not page.authentication.is_admin():
            req.addParam("fq", "(" + security_query + ") OR (" + owner_query + ")")
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        self.__workflows = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))

        req = SearchRequest("*:*")
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.addParam("fq", "")
        req.setParam("rows", "0")
        if not page.authentication.is_admin():
            req.addParam("fq", "(" + security_query + ") OR (" + owner_query + ")")
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        
        sessionState.set("fq", 'item_type:"object"')
        #sessionState.set("query", portalQuery.replace("\"", "'"))
        
        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
    
    def getLatest(self):
        return self.__latest.getList("response/docs")
    
    def getMine(self):
        return self.__mine.getList("response/docs")

    def getWorkflows(self):
        return self.__workflows.getList("response/docs")

    def getItemCount(self):
        return self.__result.get("response/numFound")
开发者ID:kiranba,项目名称:the-fascinator,代码行数:98,代码来源:home.py

示例8: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]

#.........这里部分代码省略.........
        out = ByteArrayOutputStream()
        Services.indexer.search(req, out)
        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        if self.__result is not None:
            self.__paging = Pagination(self.__pageNum,
                                       int(self.__result.get("response/numFound")),
                                       self.__portal.recordsPerPage)


    def canManage(self, wfSecurity):
        user_roles = page.authentication.get_roles_list()
        for role in user_roles:
            if role in wfSecurity:
                return True
        return False

    def getQueryTime(self):
        return int(self.__result.get("responseHeader/QTime")) / 1000.0;
    
    def getPaging(self):
        return self.__paging
    
    def getResult(self):
        return self.__result
    
    def getFacetField(self, key):
        return self.__portal.facetFields.get(key)
    
    def getFacetName(self, key):
        return self.__portal.facetFields.get(key).get("label")
    
    def getFacetCounts(self, key):
        values = LinkedHashMap()
        valueList = self.__result.getList("facet_counts/facet_fields/%s" % key)
        for i in range(0,len(valueList),2):
            name = valueList[i]
            count = valueList[i+1]
            if count > 0:
                values.put(name, count)
        return values
    
    def hasSelectedFacets(self):
        return (self.__selected is not None and len(self.__selected) > 1) and \
            not (self.__portal.query in self.__selected and len(self.__selected) == 2)
    
    def getSelectedFacets(self):
        return self.__selected
    
    def isPortalQueryFacet(self, fq):
        return fq == self.__portal.query
    
    def isSelected(self, fq):
        return fq in self.__selected
    
    def getSelectedFacetIds(self):
        return [md5.new(fq).hexdigest() for fq in self.__selected]
    
    def getFileName(self, path):
        return os.path.splitext(os.path.basename(path))[0]
    
    def getFacetQuery(self, name, value):
        return '%s:"%s"' % (name, value)
    
    def isImage(self, format):
        return format.startswith("image/")
开发者ID:kiranba,项目名称:the-fascinator,代码行数:69,代码来源:search.py

示例9: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]

#.........这里部分代码省略.........
            req.removeParam("fq", URLDecoder.decode(value, "UTF-8"))
        elif action == "clear_fq":
            self.__pageNum = 1
            req.removeParam("fq")
        elif action == "select-page":
            self.__pageNum = int(value)
        req.addParam("fq", 'item_type:"object"')

        portalQuery = self.__portal.query
        print " * portalQuery=%s" % portalQuery
        if portalQuery:
            req.addParam("fq", portalQuery)

        self.__selected = req.getParams("fq")

        sessionState.set("fq", self.__selected)
        sessionState.set("pageNum", self.__pageNum)

        req.setParam("start", str((self.__pageNum - 1) * recordsPerPage))

        print " * single.py:", req.toString(), self.__pageNum

        out = ByteArrayOutputStream()
        Services.indexer.search(req, out)
        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        if self.__result is not None:
            self.__paging = Pagination(
                self.__pageNum, int(self.__result.get("response/numFound")), self.__portal.recordsPerPage
            )
            print " * single.py: updating manifest..."
            portal = self.getPortal()
            manifest = portal.getJsonMap("manifest")
            # add new items from search
            for doc in self.__result.getList("response/docs"):
                hashId = md5.new(doc.get("id")).hexdigest()
                node = portal.get("manifest//node-%s" % hashId)
                if node is None:
                    portal.set("manifest/node-%s/title" % hashId, doc.get("dc_title").get(0))
                    portal.set("manifest/node-%s/id" % hashId, doc.get("id"))
            # remove manifest items missing from search result
            # print manifest
            for key in manifest.keySet():
                item = manifest.get(key)
                id = item.get("id")
                doc = self.__result.getList('response/docs[@id="%s"]' % id)
                if len(doc) == 0:
                    portal.removePath("manifest//%s" % key)
            Services.getPortalManager().save(portal)

    def getQueryTime(self):
        return int(self.__result.get("responseHeader/QTime")) / 1000.0

    def getPaging(self):
        return self.__paging

    def getResult(self):
        return self.__result

    def getFacetField(self, key):
        return self.__portal.facetFields.get(key)

    def getFacetName(self, key):
        return self.__portal.facetFields.get(key).get("label")

    def getFacetCounts(self, key):
        values = LinkedHashMap()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:70,代码来源:single.py

示例10: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]

#.........这里部分代码省略.........
            owner_query = 'owner:"' + current_user + '"'
            security_query = "(" + security_filter + ") OR (" + security_exceptions + ") OR (" + owner_query + ")"
            req.addParam("fq", security_query)
        
        req.setParam("start", str((self.__pageNum - 1) * recordsPerPage))
        
        print " * search.py:", req.toString(), self.__pageNum
        
        out = ByteArrayOutputStream()
        self.services.indexer.search(req, out)
        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        if self.__result is not None:
            self.__paging = Pagination(self.__pageNum,
                                       int(self.__result.get("response/numFound")),
                                       self.__portal.recordsPerPage)
    
    def getQueryTime(self):
        return int(self.__result.get("responseHeader/QTime")) / 1000.0;
    
    def getPaging(self):
        return self.__paging
    
    def getResult(self):
        return self.__result
    
    def getFacetField(self, key):
        return self.__portal.facetFields.get(key)
    
    def getFacetName(self, key):
        return self.__portal.facetFields.get(key).get("label")
    
    def getFacetCounts(self, key):
        values = LinkedHashMap()
        valueList = self.__result.getList("facet_counts/facet_fields/%s" % key)
        for i in range(0,len(valueList),2):
            name = valueList[i]
            count = valueList[i+1]
            if (name.find("/") == -1 or self.hasSelectedFacets()) and count > 0:
                values.put(name, count)
        return values
    
    def hasSelectedFacets(self):
        return (self.__selected is not None and len(self.__selected) > 1) and \
            not (self.__portal.query in self.__selected and len(self.__selected) == 2)
    
    def getSelectedFacets(self):
        return self.__selected
    
    def isPortalQueryFacet(self, fq):
        return fq == self.__portal.query
    
    def isSelected(self, fq):
        return fq in self.__selected
    
    def getSelectedFacetIds(self):
        return [md5.new(fq).hexdigest() for fq in self.__selected]
    
    def getFileName(self, path):
        return os.path.splitext(os.path.basename(path))[0]
    
    def getFacetQuery(self, name, value):
        return '%s:"%s"' % (name, value)
    
    # Packaging support
    def getActiveManifestTitle(self):
        return self.__getActiveManifest().get("title")
开发者ID:kiranba,项目名称:the-fascinator,代码行数:70,代码来源:search.py

示例11: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]

#.........这里部分代码省略.........
            Services.portalManager.remove(portalName)
        self.__latest = JsonConfigHelper()
        self.__mine = JsonConfigHelper()
        self.__workflows = JsonConfigHelper()
        self.__result = JsonConfigHelper()
        self.__search()

    # Get from velocity context
    def vc(self, index):
        if self.velocityContext[index] is not None:
            return self.velocityContext[index]
        else:
            print "ERROR: Requested context entry '" + index + "' doesn't exist"
            return None

    def __search(self):
        indexer = Services.getIndexer()
        portalQuery = Services.getPortalManager().get(self.vc("portalId")).getQuery()
        portalSearchQuery = Services.getPortalManager().get(self.vc("portalId")).getSearchQuery()

        # Security prep work
        current_user = self.vc("page").authentication.get_username()
        security_roles = self.vc("page").authentication.get_roles_list()
        security_filter = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
        security_exceptions = 'security_exception:"' + current_user + '"'
        owner_query = 'owner:"' + current_user + '"'
        security_query = "(" + security_filter + ") OR (" + security_exceptions + ") OR (" + owner_query + ")"
        isAdmin = self.vc("page").authentication.is_admin()

        req = SearchRequest("last_modified:[NOW-1MONTH TO *]")
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.setParam("rows", "10")
        req.setParam("sort", "last_modified desc, f_dc_title asc")
        if not isAdmin:
            req.addParam("fq", security_query)
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        self.__latest = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))

        req = SearchRequest(owner_query)
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.setParam("rows", "10")
        req.setParam("sort", "last_modified desc, f_dc_title asc")
        if not isAdmin:
            req.addParam("fq", security_query)
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        self.__mine = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))

        req = SearchRequest('workflow_security:"' + current_user + '"')
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.setParam("rows", "10")
        req.setParam("sort", "last_modified desc, f_dc_title asc")
        if not isAdmin:
            req.addParam("fq", security_query)
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        self.__workflows = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))

        req = SearchRequest("*:*")
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.addParam("fq", "")
        req.setParam("rows", "0")
        if not isAdmin:
            req.addParam("fq", security_query)
        out = ByteArrayOutputStream()
        indexer.search(req, out)

        self.vc("sessionState").set("fq", 'item_type:"object"')
        # sessionState.set("query", portalQuery.replace("\"", "'"))

        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))

    def getLatest(self):
        return self.__latest.getList("response/docs")

    def getMine(self):
        return self.__mine.getList("response/docs")

    def getWorkflows(self):
        return self.__workflows.getList("response/docs")

    def getItemCount(self):
        return self.__result.get("response/numFound")
开发者ID:kiranba,项目名称:the-fascinator,代码行数:104,代码来源:home.py

示例12: __getSolrData

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [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))
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:67,代码来源:lookup.py

示例13: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]
class SearchData:
    def __init__(self):
        self.__result = JsonConfigHelper()
        self.__portal = Services.getPortalManager().get(portalId)
        pageNum = sessionState.get("pageNum")
        if pageNum is None:
            self.__pageNum = 1
        else:
            self.__pageNum = int(pageNum)
        self.__search()

    def __search(self):
        recordsPerPage = self.__portal.recordsPerPage

        query = formData.get("query")
        if query is None or query == "":
            query = "*:*"
        req = SearchRequest(query)
        req.setParam("facet", "true")
        req.setParam("rows", str(recordsPerPage))
        req.setParam("facet.field", self.__portal.facetFieldList)
        req.setParam("facet.sort", "true")
        req.setParam("facet.limit", str(self.__portal.facetCount))
        req.setParam("sort", "f_dc_title asc")
        
        # setup facets
        action = formData.get("action")
        value = formData.get("value")
        fq = sessionState.get("fq")
        if fq is not None:
            self.__pageNum = 1
            req.setParam("fq", fq)
        if action == "add_fq":
            self.__pageNum = 1
            name = formData.get("name")
            print " * add_fq: %s" % value
            req.addParam("fq", URLDecoder.decode(value, "UTF-8"))
        elif action == "remove_fq":
            self.__pageNum = 1
            req.removeParam("fq", URLDecoder.decode(value, "UTF-8"))
        elif action == "clear_fq":
            self.__pageNum = 1
            req.removeParam("fq")
        elif action == "select-page":
            self.__pageNum = int(value)
        req.addParam("fq", 'item_type:"object"')
        
        portalQuery = self.__portal.query
        print " * portalQuery=%s" % portalQuery
        if portalQuery:
            req.addParam("fq", portalQuery)
        
        self.__selected = req.getParams("fq")

        sessionState.set("fq", self.__selected)
        sessionState.set("pageNum", self.__pageNum)

        req.setParam("start", str((self.__pageNum - 1) * recordsPerPage))
        
        print " * search.py:", req.toString(), self.__pageNum

        out = ByteArrayOutputStream()
        Services.indexer.search(req, out)
        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        if self.__result is not None:
            self.__paging = Pagination(self.__pageNum,
                                       int(self.__result.get("response/numFound")),
                                       self.__portal.recordsPerPage)

    def getQueryTime(self):
        return int(self.__result.get("responseHeader/QTime")) / 1000.0;

    def getPaging(self):
        return self.__paging

    def getResult(self):
        return self.__result

    def getFacetName(self, key):
        return self.__portal.facetFields.get(key)

    def getFacetCounts(self, key):
        values = HashMap()
        valueList = self.__result.getList("facet_counts/facet_fields/%s" % key)
        for i in range(0,len(valueList),2):
            name = valueList[i]
            count = valueList[i+1]
            if count > 0:
                values.put(name, count)
        return values

    def hasSelectedFacets(self):
        return self.__selected is not None and self.__selected.size() > 1

    def getSelectedFacets(self):
        return self.__selected

    def isPortalQueryFacet(self, fq):
        return fq == self.__portal.query

#.........这里部分代码省略.........
开发者ID:kiranba,项目名称:the-fascinator,代码行数:103,代码来源:search.py

示例14: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]
class HomeData:
    def __init__(self):
        action = formData.get("verb")
        portalName = formData.get("value")
        sessionState.remove("fq")
        if action == "delete-portal":
            print " * home.py: delete portal %s" % portalName
            Services.portalManager.remove(portalName)
        if action == "backup-portal":
            print "Backing up: ", portalName
            backupPath = ""
            email = ""
            portal = Services.portalManager.get(portalName)
            if portal:
                email = portal.email
                if portal.backupPaths:
                    for key in portal.backupPaths:
                        if portal.backupPaths[key]=="default":
                            backupPath = key
                portalQuery = portal.getQuery()
                #print " ***** portalQuery: ", portalQuery
                #print " ***** backupPath: ", backupPath
                #print " ***** email: ", email
                #print " ***** description: ", description
            if backupPath is None:
                " ** Default backup path configured in system-config.json will be used "
            Services.portalManager.backup(email, backupPath, portalQuery)
        self.__latest = JsonConfigHelper()
        self.__result = JsonConfigHelper()
        self.__search()
    
    def __search(self):
        indexer = Services.getIndexer()
        portalQuery = Services.getPortalManager().get(portalId).getQuery()
        
        req = SearchRequest("last_modified:[NOW-1MONTH TO *]")
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        req.setParam("rows", "10")
        req.setParam("sort", "last_modified desc, f_dc_title asc");
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        self.__latest = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        
        req = SearchRequest("*:*")
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        req.addParam("fq", "")
        req.setParam("rows", "0")
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        
        sessionState.set("fq", 'item_type:"object"')
        #sessionState.set("query", portalQuery.replace("\"", "'"))
        
        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
    
    def getLatest(self):
        return self.__latest.getList("response/docs")
    
    def getItemCount(self):
        return self.__result.get("response/numFound")
开发者ID:kiranba,项目名称:the-fascinator,代码行数:66,代码来源:home.py

示例15: __init__

# 需要导入模块: from au.edu.usq.fascinator.common import JsonConfigHelper [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonConfigHelper import getList [as 别名]

#.........这里部分代码省略.........
                if portal.backupPaths:
                    for key in portal.backupPaths:
                        if portal.backupPaths[key]=="default":
                            backupPath = key
                portalQuery = portal.getQuery()
                #print " ***** portalQuery: ", portalQuery
                #print " ***** backupPath: ", backupPath
                #print " ***** email: ", email
                #print " ***** description: ", description
            if backupPath is None:
                " ** Default backup path configured in system-config.json will be used "
            Services.portalManager.backup(email, backupPath, portalQuery)
        self.__latest = JsonConfigHelper()
        self.__mine = JsonConfigHelper()
        self.__workflows = JsonConfigHelper()
        self.__result = JsonConfigHelper()
        self.__search()
    
    def __search(self):
        indexer = Services.getIndexer()
        portalQuery = Services.getPortalManager().get(portalId).getQuery()
        portalSearchQuery = Services.getPortalManager().get(portalId).getSearchQuery()
        
        # Security prep work
        current_user = page.authentication.get_username()
        security_roles = page.authentication.get_roles_list()
        security_query = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
        owner_query = 'owner:"' + current_user + '"'

        req = SearchRequest("last_modified:[NOW-1MONTH TO *]")
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.setParam("rows", "10")
        req.setParam("sort", "last_modified desc, f_dc_title asc");
        if not page.authentication.is_admin():
            req.addParam("fq", "(" + security_query + ") OR (" + owner_query + ")")
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        self.__latest = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        
        req = SearchRequest(owner_query)
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.setParam("rows", "10")
        req.setParam("sort", "last_modified desc, f_dc_title asc");
        if not page.authentication.is_admin():
            req.addParam("fq", "(" + security_query + ") OR (" + owner_query + ")")
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        self.__mine = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))

        req = SearchRequest('workflow_security:"' + current_user + '"')
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.setParam("rows", "10")
        req.setParam("sort", "last_modified desc, f_dc_title asc");
        if not page.authentication.is_admin():
            req.addParam("fq", "(" + security_query + ") OR (" + owner_query + ")")
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        self.__workflows = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))

        req = SearchRequest("*:*")
        req.setParam("fq", 'item_type:"object"')
        if portalQuery:
            req.addParam("fq", portalQuery)
        if portalSearchQuery:
            req.addParam("fq", portalSearchQuery)
        req.addParam("fq", "")
        req.setParam("rows", "0")
        if not page.authentication.is_admin():
            req.addParam("fq", "(" + security_query + ") OR (" + owner_query + ")")
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        
        sessionState.set("fq", 'item_type:"object"')
        #sessionState.set("query", portalQuery.replace("\"", "'"))
        
        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
    
    def getLatest(self):
        return self.__latest.getList("response/docs")
    
    def getMine(self):
        return self.__mine.getList("response/docs")

    def getWorkflows(self):
        return self.__workflows.getList("response/docs")

    def getItemCount(self):
        return self.__result.get("response/numFound")
开发者ID:kiranba,项目名称:the-fascinator,代码行数:104,代码来源:home.py


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