def query_resource(self):
        qry = ResourceQuery(
            """ r.resourceId, r.title, r.href, r.fsize, r.createDate, 
          u.loginName, u.nickName, grad.gradeName, sc.name as scName """)
        pager = self.createPager()

        # 根据页面参数处理.
        type = self.params.getStringParam("type")
        if type == "rcmd":
            qry.rcmdState = True
        elif type == "hot":
            qry.orderType = ResourceQuery.ORDER_TYPE_DOWNLOADCOUNT_DESC
        elif type == "cmt":
            qry.orderType = ResourceQuery.ORDER_TYPE_COMMENTCOUNT_DESC
        else:
            type = "new"
        request.setAttribute("type", type)

        qry.subjectId = self.subject.subjectId
        qry.k = self.params.getStringParam("k")
        qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")

        # 查询数据.
        pager.totalRows = qry.count()
        resource_list = qry.query_map(pager)

        request.setAttribute("resource_list", resource_list)
        request.setAttribute("pager", pager)
Beispiel #2
0
 def get_rcmd_resource_list(self):
     qry = ResourceQuery(
         """ r.createDate, r.resourceId, r.href, r.title, u.loginName, u.nickName, u.userId """
     )
     qry.rcmdState = True
     qry.subjectId = self.get_subjectId()
     rcmd_resource_list = qry.query_map(11)
     request.setAttribute("rcmd_resource_list", rcmd_resource_list)
Beispiel #3
0
 def genernate_resoure_content(self, webpart):
     cache_key = "sbj" + str(self.subject.subjectId) + "_" + str(webpart.getSubjectWebpartId()) + self.cacheKeyFix
     content = cache.get(cache_key)
     if content != None:
         request.setAttribute(cache_key, content)
         return
     
     map = HashMap()        
     qry = ResourceQuery(""" r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
     u.loginName, u.nickName, r.subjectId as subjectId, grad.gradeName, sc.name as scName """)
     qry.subjectId = self.metaSubjectId
     qry.gradeId = self.metaGradeId
     qry.FuzzyMatch = True
     if self.unitId != None and self.unitId != 0:
         qry.custormAndWhereClause = " r.approvedPathInfo LIKE '%/" + str(self.unitId) + "/%'"
     new_resource_list = qry.query_map(10)
     map.put("new_resource_list", new_resource_list)
     
     qry = ResourceQuery(""" r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
     u.loginName, u.nickName, msubj.msubjName, grad.gradeName, sc.name as scName """)
     qry.orderType = 4       # downloadCount DESC
     qry.subjectId = self.metaSubjectId
     qry.gradeId = self.metaGradeId
     qry.FuzzyMatch = True
     if self.unitId != None and self.unitId != 0:
         qry.custormAndWhereClause = " r.approvedPathInfo LIKE '%/" + str(self.unitId) + "/%'"
     hot_resource_list = qry.query_map(10)
     map.put("hot_resource_list", hot_resource_list)
     
     #hot_resource_list = self.viewcount_svc.getViewCountListShared(12,7,10,self.unit.unitPath,self.unit.unitDepth);
     #map.put("hot_resource_list", hot_resource_list)
     
     # �Ƽ���Դ
     qry = ResourceQuery(""" r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
     u.loginName, u.nickName, msubj.msubjName, grad.gradeName, sc.name as scName """)
     qry.rcmdState = True
     qry.subjectId = self.metaSubjectId
     qry.gradeId = self.metaGradeId
     qry.FuzzyMatch = True
     if self.unitId != None and self.unitId != 0:
         qry.custormAndWhereClause = " r.rcmdPathInfo LIKE '%/" + str(self.unitId) + "/%'"
     rcmd_resource_list = qry.query_map(10)
     map.put("rcmd_resource_list", rcmd_resource_list)    
    
     map.put("subject", self.subject)
     map.put("SubjectRootUrl", self.subjectRootUrl)
     map.put("webpart", webpart)
     map.put("unitId", self.unitId)
     content = self.templateProcessor.processTemplate(map, "/WEB-INF/subjectpage/" + self.templateName + "/resource.ftl", "utf-8")
     request.setAttribute(cache_key, content)
     cache.put(cache_key, content)
Beispiel #4
0
    def query_resource(self):
        qry = ResourceQuery(
            """ r.resourceId, r.title, r.href, r.fsize, r.createDate, 
              u.loginName, u.nickName, grad.gradeName, sc.name as scName """)
        pager = self.createPager()
        if self.unitId != None and self.unitId != 0:
            qry.custormAndWhereClause = " r.approvedPathInfo LIKE '%/" + str(
                self.unitId) + "/%'"
        # 根据页面参数处理.
        type = self.params.getStringParam("type")
        if type == "rcmd":
            qry.rcmdState = True
            if self.unitId != None and self.unitId != 0:
                # 覆盖掉前面的设置
                qry.custormAndWhereClause = " r.rcmdPathInfo LIKE '%/" + str(
                    self.unitId) + "/%'"
        elif type == "hot":
            qry.orderType = ResourceQuery.ORDER_TYPE_DOWNLOADCOUNT_DESC
        elif type == "cmt":
            qry.orderType = ResourceQuery.ORDER_TYPE_COMMENTCOUNT_DESC
        else:
            type = "new"

        request.setAttribute("type", type)
        qry.subjectId = self.get_current_subjectId()

        #qry.gradeId = self.get_current_gradeId()
        qry.gradeId = self.levelGradeId
        qry.gradelevel = self.params.getIntParamZeroAsNull("level")
        qry.FuzzyMatch = True

        qry.k = self.params.getStringParam("k")
        qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")

        # 查询数据.
        pager.totalRows = qry.count()
        resource_list = qry.query_map(pager)

        request.setAttribute("resource_list", resource_list)
        request.setAttribute("pager", pager)
Beispiel #5
0
    def list(self):
        # 构造查询.
        query = ResourceQuery(
            """ r.resourceId, r.title, r.shareMode, r.createDate, r.href, r.subjectId, r.gradeId, 
            r.downloadCount, r.commentCount, r.fsize, r.auditState, r.recommendState, r.tags, r.addIp, r.pushState,
            u.userId, u.loginName, u.nickName, sc.name as sysCateName, subj.subjectName """
        )

        query.auditState = None
        query.delState = False  # 过滤被删除了的.

        recommendState = self.params.safeGetStringParam("recommendState")
        if recommendState == "1":
            query.rcmdState = 1
        elif recommendState == "0":
            query.rcmdState = 0

        auditState = self.params.safeGetStringParam("auditState")
        if auditState == "1":
            query.auditState = 1
        elif auditState == "0":
            query.auditState = 0

        query.shareMode = None
        query.unitId = self.unit.unitId

        # 根据参数设置过滤条件.
        type = self.params.getStringParam("type")
        request.setAttribute("type", type)
        if type == "rcmd":  # 推荐.
            query.rcmdState = True
        elif type == "unaudit":  # 待审核.
            query.auditState = Resource.AUDIT_STATE_WAIT_AUDIT

        query.subjectId = self.params.getIntParamZeroAsNull("su")
        request.setAttribute("su", query.subjectId)
        query.gradeId = self.params.getIntParamZeroAsNull("gradeId")
        request.setAttribute("gradeId", query.gradeId)
        query.sysCateId = self.params.getIntParamZeroAsNull("sc")
        request.setAttribute("sc", query.sysCateId)
        query.kk = self.params.getStringParam("k")
        request.setAttribute("k", query.kk)
        query.f = self.params.getStringParam("f")
        request.setAttribute("f", query.f)

        # 计算总量.
        pager = self.createPager()
        pager.pageSize = 10
        pager.totalRows = query.count()

        # 得到资源.
        resource_list = query.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("resource_list", resource_list)
        self.putSubjectList()
        self.putGradeList()
        self.putResourceCategoryTree()

        request.setAttribute("recommendState", recommendState)
        request.setAttribute("auditState", auditState)
        return "/WEB-INF/unitsmanage/unit_owner_resource.ftl"