예제 #1
0
    def genernate_resoure_content(self, webpart):
        cache_key = "unit" + str(self.unit.unitId) + "_" + str(
            webpart.getUnitWebpartId())
        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, 
            r.userId, r.subjectId as subjectId, grad.gradeName, sc.name as scName """
        )
        #qry.unitId = self.unit.unitId
        qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
            self.unit.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, 
            r.userId, msubj.msubjName, grad.gradeName, sc.name as scName """)
        qry.orderType = 4  # downloadCount DESC
        #qry.unitId = self.unit.unitId
        qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
            self.unit.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, 
            r.userId,msubj.msubjName, grad.gradeName, sc.name as scName """)
        #qry.rcmdState = True
        #qry.unitId = self.unit.unitId
        qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
            self.unit.unitId) + "/%' And r.rcmdPathInfo Like '%/" + str(
                self.unit.unitId) + "/%' "
        rcmd_resource_list = qry.query_map(10)
        map.put("rcmd_resource_list", rcmd_resource_list)

        map.put("unit", self.unit)
        map.put("webpart", webpart)
        map.put("UnitRootUrl", self.unitRootUrl)
        content = self.templateProcessor.processTemplate(
            map, "/WEB-INF/unitspage/" + self.templateName + "/resource.ftl",
            "utf-8")
        request.setAttribute(cache_key, content)
        cache.put(cache_key, content)
예제 #2
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)
예제 #3
0
    def get_resource_list(self):
        qry = ResourceQuery(
            " r.resourceId, r.href, r.title, r.fsize, r.createDate, u.loginName, u.nickName, r.subjectId as subjectId, grad.gradeName, sc.name as scName "
        )
        type = self.params.getStringParam("type")

        if type == None or type == "": type = "new"
        list_type = ""
        if type == "hot":
            qry.orderType = ResourceQuery.ORDER_TYPE_VIEWCOUNT_DESC
            qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
                self.unit.unitId) + "/%' "
            list_type = u"最高人气"
        elif type == "rcmd":
            #qry.rcmdState = True
            qry.custormAndWhereClause = " r.rcmdPathInfo Like '%/" + str(
                self.unit.unitId
            ) + "/%' And r.approvedPathInfo Like '%/" + str(
                self.unit.unitId) + "/%' "
            list_type = u"编辑推荐"
        elif type == "cmt":
            qry.orderType = ResourceQuery.ORDER_TYPE_COMMENTCOUNT_DESC
            qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
                self.unit.unitId) + "/%' "
            list_type = u"评论最多"
        else:
            type = "new"
            qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
                self.unit.unitId) + "/%' "
            list_type = u"最新资源"
        request.setAttribute("type", type)
        request.setAttribute("list_type", list_type)

        qry.gradelevel = self.params.getIntParamZeroAsNull("level")
        qry.subjectId = self.params.getIntParamZeroAsNull("subjectId")
        qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")
        qry.gradeId = self.params.getIntParamZeroAsNull("gradeId")
        qry.k = self.params.getStringParam("k")

        pager = self.createPager()

        pager.totalRows = qry.count()
        resource_list = qry.query_map(pager)

        request.setAttribute("resource_list", resource_list)
        request.setAttribute("pager", pager)
        request.setAttribute("subjectId", qry.subjectId)
        request.setAttribute("categoryId", qry.sysCateId)
예제 #4
0
    def get_list(self):
        query = ResourceQuery(
            """ r.resourceId, r.title, r.shareMode, r.createDate, r.href, r.subjectId, r.gradeId, r.rcmdPathInfo,
            r.delState, r.unitPathInfo, r.approvedPathInfo, 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 """
        )

        multiPushState = self.params.safeGetStringParam("multiPushState")
        recommendState = self.params.safeGetStringParam("recommendState")
        auditState = self.params.safeGetStringParam("auditState")

        query.shareMode = None
        query.unitId = None  #不使用该字段

        custormAndWhereClause = "r.unitPathInfo LIKE '%/" + str(
            self.unit.unitId) + "/%' And r.unitId != " + str(
                self.unit.unitId) + " And"
        if multiPushState == "1":
            custormAndWhereClause += " r.unitPathInfo LIKE '%/" + str(
                self.unit.parentId) + "/%' And"
        elif multiPushState == "0":
            custormAndWhereClause += " r.unitPathInfo NOT LIKE '%/" + str(
                self.unit.parentId) + "/%' And"

        if recommendState == "1":
            custormAndWhereClause += " r.rcmdPathInfo LIKE '%/" + str(
                self.unit.unitId) + "/%' And"
        elif recommendState == "0":
            custormAndWhereClause += " (r.rcmdPathInfo Is Null or r.rcmdPathInfo Not LIKE '%/" + str(
                self.unit.unitId) + "/%') And"

        if auditState == "0":
            custormAndWhereClause += " r.approvedPathInfo LIKE '%/" + str(
                self.unit.unitId) + "/%' And"
        elif auditState == "1":
            custormAndWhereClause += " (r.approvedPathInfo Is Null or r.approvedPathInfo NOT LIKE '%/" + str(
                self.unit.unitId) + "/%') And"

        if custormAndWhereClause[len(custormAndWhereClause) - 3:] == "And":
            custormAndWhereClause = custormAndWhereClause[
                0:len(custormAndWhereClause) - 3]

        query.custormAndWhereClause = custormAndWhereClause

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

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

        request.setAttribute("pager", pager)
        request.setAttribute("resource_list", resource_list)
        request.setAttribute("multiPushState", multiPushState)
        request.setAttribute("recommendState", recommendState)
        request.setAttribute("auditState", auditState)
예제 #5
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)
예제 #6
0
파일: index.py 프로젝트: yxxcrtd/jitar2.0
 def get_new_resource_list(self):
     cache_key = "new_resource_list"
     new_resource_list = cache.get(cache_key)
     if new_resource_list == None:
         qry = ResourceQuery(
             """ r.userId, r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
             u.loginName, u.trueName, r.createDate """)
         # qry.unit = self.unit
         qry.unitId = None
         qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
             self.unit.unitId) + "/%' "
         new_resource_list = qry.query_map(10)
         cache.put(cache_key, new_resource_list)
     request.setAttribute("new_resource_list", new_resource_list)
예제 #7
0
파일: index.py 프로젝트: yxxcrtd/jitar2.0
 def get_rcmd_resource_list(self):
     cache_key = "rcmd_resource_list"
     rcmd_resource_list = cache.get(cache_key)
     if rcmd_resource_list == None:
         qry = ResourceQuery(
             " r.userId, r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, r.subjectId as subjectId, grad.gradeName, sc.name as scName "
         )
         # qry.unit = self.unit
         qry.unitId = None
         # qry.rcmdState = True
         qry.custormAndWhereClause = " r.rcmdPathInfo Like '%/" + str(
             self.unit.unitId
         ) + "/%' and r.approvedPathInfo Like '%/" + str(
             self.unit.unitId) + "/%' "
         rcmd_resource_list = qry.query_map(10)
         cache.put(cache_key, rcmd_resource_list)
     request.setAttribute("rcmd_resource_list", rcmd_resource_list)
예제 #8
0
파일: index.py 프로젝트: yxxcrtd/jitar2.0
 def get_hot_resource_list(self):
     cache_key = "hot_resource_list"
     hot_resource_list = cache.get(cache_key)
     # hot_resource_list=None
     if hot_resource_list == None:
         qry = ResourceQuery(
             """ r.userId, r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
             u.loginName, u.trueName, msubj.msubjName, grad.gradeName, sc.name as scName """
         )
         # qry.unit = self.unit
         qry.unitId = None
         qry.custormAndWhereClause = " r.approvedPathInfo Like '%/" + str(
             self.unit.unitId) + "/%' "
         qry.orderType = 4  # downloadCount DESC
         hot_resource_list = qry.query_map(10)
         cache.put(cache_key, hot_resource_list)
     request.setAttribute("hot_resource_list", hot_resource_list)
예제 #9
0
    def get_request(self):
        query = ResourceQuery(
            """ r.resourceId, r.title, r.shareMode, r.createDate, r.href, r.subjectId, r.gradeId, r.rcmdPathInfo,r.unitId,
            r.delState, r.unitPathInfo, r.approvedPathInfo, r.downloadCount, r.commentCount, r.fsize, r.auditState, r.recommendState, r.tags, r.addIp, 
            u.userId, u.loginName, u.nickName, sc.name as sysCateName """)

        query.unitId = None
        query.auditState = None
        query.delState = None

        multiPushState = self.params.safeGetStringParam("multiPushState")
        recommendState = self.params.safeGetStringParam("recommendState")
        auditState = self.params.safeGetStringParam("auditState")
        delState = self.params.safeGetStringParam("delState")

        custormAndWhereClause = "r.orginPathInfo LIKE '%/" + str(
            self.unit.unitId) + "/%' And r.unitId <> " + str(
                self.unit.unitId) + " And"

        # 得到全部的下级单位
        unitList = self.unitService.getDownUnitList(self.unit)

        if recommendState == "1":
            strRcmd = ""
            for ut in unitList:
                strRcmd = strRcmd + " r.rcmdPathInfo LIKE '%/" + str(
                    ut.unitId) + "/%' or"
            if strRcmd != "":
                strRcmd = strRcmd[0:len(strRcmd) - 2]
                custormAndWhereClause += " (" + strRcmd + ") And"
        elif recommendState == "0":
            strRcmd = ""
            for ut in unitList:
                strRcmd = strRcmd + " r.rcmdPathInfo Not LIKE '%/" + str(
                    ut.unitId) + "/%' And"
            if strRcmd != "":
                strRcmd = strRcmd[0:len(strRcmd) - 3]
                custormAndWhereClause += " (r.rcmdPathInfo Is Null or (" + strRcmd + ")) And"

        if auditState == "0":
            strApprove = ""
            for ut in unitList:
                strApprove = strApprove + " r.approvedPathInfo LIKE '%/" + str(
                    ut.unitId) + "/%' or"
            if strApprove != "":
                strApprove = strApprove[0:len(strApprove) - 2]
                custormAndWhereClause += "(" + strApprove + ") And"
        elif auditState == "1":
            strApprove = ""
            for ut in unitList:
                strApprove = strApprove + " r.approvedPathInfo NOT LIKE '%/" + str(
                    ut.unitId) + "/%' And"
            if strApprove != "":
                strApprove = strApprove[0:len(strApprove) - 3]
                custormAndWhereClause += " (r.approvedPathInfo Is Null or (" + strApprove + ")) And"
        """
        if auditState == "0":
            custormAndWhereClause += " r.approvedPathInfo LIKE '%/" + str(self.unit.unitId) + "/%' And"
        elif auditState == "1":
            custormAndWhereClause += " (r.approvedPathInfo Is NUll or r.approvedPathInfo NOT LIKE '%/" + str(self.unit.unitId) + "/%') And"
        
        if multiPushState == "1":
            custormAndWhereClause += " r.unitPathInfo LIKE '%/" + str(self.unit.parentId) + "/%' And"
        elif multiPushState == "0":
            custormAndWhereClause += " r.unitPathInfo NOT LIKE '%/" + str(self.unit.parentId) + "/%' And"
        
        if recommendState == "1":
            custormAndWhereClause += " r.rcmdPathInfo LIKE '%/" + str(self.unit.unitId) + "/%' And"
        elif recommendState == "0":
            custormAndWhereClause += " (r.rcmdPathInfo Is NULL or r.rcmdPathInfo NOT LIKE '%/" + str(self.unit.unitId) + "/%') And"
        """

        if delState == "0":
            query.delState = False
        elif delState == "1":
            query.delState = True

        if custormAndWhereClause[len(custormAndWhereClause) - 3:] == "And":
            custormAndWhereClause = custormAndWhereClause[
                0:len(custormAndWhereClause) - 3]
        query.custormAndWhereClause = custormAndWhereClause
        #print custormAndWhereClause

        # 计算总量.
        pager = self.createPager()
        pager.pageSize = 20
        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("delState", delState)
        request.setAttribute("multiPushState", multiPushState)
        request.setAttribute("recommendState", recommendState)
        request.setAttribute("auditState", auditState)
        #self.putSubjectList()
        #self.putGradeList()
        self.putResourceCategoryTree()