def get_rcmd_group_list(self): qry = GroupQuery( """ g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce,g.parentId,g.XKXDName,g.XKXDId """ ) qry.isRecommend = True rcmd_group_list = qry.query_map(10) request.setAttribute("rcmd_group_list", rcmd_group_list)
def get_group_list(self): qry = GroupQuery(""" subj.subjectId, g.createUserId, g.groupId, g.groupIcon, g.groupTitle, g.createDate, u.loginName, u.nickName, g.userCount, g.visitCount, g.articleCount, g.topicCount, g.resourceCount, g.groupTitle , g.groupIntroduce """) pager = self.createPager() # 根据页面参数处理. type = self.params.getStringParam("type") if type == "rcmd": qry.isRecommend = True elif type == "hot": qry.orderType = GroupQuery.ORDER_BY_VISITCOUNT_DESC elif type == "rcmd": qry.isRecommend = True else: type = "new" request.setAttribute("type", type) qry.subjectId = self.get_current_subjectId() qry.gradeId = self.get_current_gradeId() qry.k = self.params.getStringParam("k") #qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId") pager.totalRows = qry.count() group_list = qry.query_map(pager) request.setAttribute("group_list", group_list) request.setAttribute("pager", pager)
def get_hot_group_list(self): qry = GroupQuery( """ g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce, g.createUserId,g.parentId,g.XKXDName,g.XKXDId, u.loginName, u.nickName """) qry.orderType = GroupQuery.ORDER_BY_VISITCOUNT_DESC # visitCount DESC hot_group_list = qry.query_map() request.setAttribute("hot_group_list", hot_group_list)
def get_new_group_list(self): qry = GroupQuery( """ g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce """ ) qry.subjectId = self.get_subjectId() new_group_list = qry.query_map(3) request.setAttribute("new_group_list", new_group_list)
def get_hot_list(self): qry = GroupQuery(""" subj.subjectId, g.createUserId, g.groupIcon, g.groupId, g.groupTitle, g.createDate, g.groupIntroduce, u.loginName, u.nickName """) qry.orderType = 2 qry.subjectId = self.subject.subjectId hot_list = qry.query_map() request.setAttribute("hot_list", hot_list)
def resolveEntity(self, qctx, entity): if entity == "gm": qctx.addEntity("GroupMember", "gm", "g.groupId = gm.groupId") elif entity == "gmu": # 协作组成员. qctx.addEntity("User", "gmu", "gm.userId = gmu.userId") elif entity == "inv": # 邀请人. qctx.addEntity("User", "inv", "gm.inviterId = inv.userId") else: GroupQuery.resolveEntity(self, qctx, entity);
def __init__(self, fields): GroupQuery.__init__(self, fields) self.groupState = None # 不需要基类处理 groupState, 我们使用更复杂的 arrGroupState. self.arrGroupId = None # 多个协作组的标识 [1, 3, 8] self.gmUserId = None # GroupMember.userId - 协作组成员标识. self.arrGroupState = None # 协作组状态 [normal, hidden, etc.] self.arrMemberState = None # 成员状态 [normal, invite, etc.] self.arrGroupRole = None # 成员角色 [manager, member ...] self.inviterId = None # 邀请人.
def get_new_group_list(self): cache_key = "new_group_list" new_group_list = cache.get(cache_key) if new_group_list == None: qry = GroupQuery( " g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce " ) new_group_list = qry.query_map(7) cache.put(cache_key, new_group_list) request.setAttribute("new_group_list", new_group_list)
def get_hot_group_list(self): cache_key = "hot_group_list" hot_group_list = cache.get(cache_key) if hot_group_list == None: qry = GroupQuery( " g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce " ) qry.orderType = GroupQuery.ORDER_BY_VISITCOUNT_DESC # visitCount DESC hot_group_list = qry.query_map(7) cache.put(cache_key, hot_group_list) request.setAttribute("hot_group_list", hot_group_list)
def get_rcmd_group_list(self): cache_key = "rcmd_group_list" rcmd_group_list = cache.get(cache_key) if rcmd_group_list == None: qry = GroupQuery( " g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce " ) qry.isRecommend = True rcmd_group_list = qry.query_map(7) cache.put(cache_key, rcmd_group_list) request.setAttribute("rcmd_group_list", rcmd_group_list)
def get_rcmd_group_list(self): qry = GroupQuery( """ g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce """ ) qry.subjectId = self.get_subjectId() qry.isBestGroup = True rcmd_group_list = qry.query_map(3) request.setAttribute("rcmd_group_list", rcmd_group_list) # 高亮显示项目. self.setData("head_nav", "index") return "success"
def get_rcmd_list(self): qry = GroupQuery(""" subj.subjectId, g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce """) qry.isRecommend = True qry.subjectId = self.get_current_subjectId() qry.gradeId = self.get_current_gradeId() rcmd_list = qry.query_map(4) request.setAttribute("rcmd_list", rcmd_list)
def execute(self): self.params = ParamUtil(request) k = self.params.safeGetStringParam("k") gid = self.params.safeGetStringParam("gid") if gid == "": self.addActionError(u"请选择id的接收者.") self.addActionLink(u"关闭", "javascript:window.close();") return ActionResult.ERROR pager = self.params.createPager() pager.itemName = u"协作组" pager.itemUnit = u"个" pager.pageSize = 10 qry = GroupQuery("g.groupId,g.groupTitle") if k != "": qry.k = k request.setAttribute("k", k) pager.totalRows = qry.count() group_list = qry.query_map(pager) request.setAttribute("group_list", group_list) request.setAttribute("pager", pager) request.setAttribute("gid", gid) return "/WEB-INF/ftl/admin/show_group_list.ftl"
def best_group(self): qry = GroupQuery( """g.groupId, g.groupName, g.groupTitle, g.groupIcon """) qry.isBestGroup = True best_group = qry.query_map(-1) count = best_group.size() if count > 4: s = [] iLoop = 0 ff = [] while iLoop < 4: iLoop = iLoop + 1 rnd = Math.random() * best_group.size() index = int(rnd) while index in s: rnd = Math.random() * best_group.size() index = int(rnd) s.append(index) ff.append(best_group[index]) best_group = ff best_group_list = best_group request.setAttribute("best_group_list", best_group_list)
def get_new_group_list(self): qry = GroupQuery(""" subj.subjectId, g.createUserId, g.groupId, g.groupIcon, g.groupTitle, g.createDate, u.loginName, u.nickName """) qry.orderType = 1 qry.subjectId = self.get_current_subjectId() qry.gradeId = self.get_current_gradeId() new_group_list = qry.query_map(4) request.setAttribute("new_group_list", new_group_list)
def get_hot_group_list(self): qry = GroupQuery( """ g.groupIcon, g.createDate, g.groupId, g.groupTitle, g.groupIntroduce """ ) qry.subjectId = self.get_current_subjectId() qry.gradeId = self.get_current_gradeId() qry.orderType = 8 hot_group_list = qry.query_map(3) request.setAttribute("hot_group_list", hot_group_list)
def applyWhereCondition(self, qctx): GroupQuery.applyWhereCondition(self, qctx) if self.arrGroupId != None and len(self.arrGroupId) > 0: if len(self.arrGroupId) == 1: qctx.addAndWhere("g.groupId = :arrGroupId") qctx.setInteger("arrGroupId", self.arrGroupId[0]) else: qctx.addAndWhere("g.groupId IN " + self.__toInSql(self.arrGroupId)) if self.gmUserId != None: qctx.addAndWhere("gm.userId = :gmUserId") qctx.setInteger("gmUserId", self.gmUserId) if self.arrGroupState != None and len(self.arrGroupState) > 0: qctx.addAndWhere("g.groupState IN " + self.__toInSql(self.arrGroupState)) if self.arrMemberState != None and len(self.arrMemberState) > 0: if len(self.arrMemberState) == 1: qctx.addAndWhere("gm.status = :arrMemberState") qctx.setInteger("arrMemberState", self.arrMemberState[0]) else: qctx.addAndWhere("gm.status IN " + self.__toInSql(self.arrMemberState)) if self.arrGroupRole != None and len(self.arrGroupRole) > 0: qctx.addAndWhere("gm.groupRole IN " + self.__toInSql(self.arrGroupRole)) if self.inviterId != None: qctx.addAndWhere("gm.inviterId = :inviterId") qctx.setInteger("inviterId", self.inviterId)
def groupList(self): # 构造查询对象. qry = GroupQuery( """ g.groupId, g.groupName, g.groupTitle, g.groupIcon, g.createDate, g.subjectId, g.gradeId, g.createUserId, g.groupTags, g.groupIntroduce, g.groupState, g.userCount, g.visitCount, g.isBestGroup, g.isRecommend, u.trueName, u.loginName, subj.subjectName, sc.name as categoryName """) qry.groupState = 0 qry.kk = self.params.getStringParam("k") request.setAttribute("k", qry.kk) # 构造分页并查询数据. pager = self.createPager() pager.totalRows = qry.count() group_list = qry.query_map(pager) request.setAttribute("group_list", group_list) request.setAttribute("pager", pager)
def query_group_list(self): qry = GroupQuery( """ g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.userCount,g.parentId, g.visitCount, g.articleCount, g.topicCount, g.resourceCount, g.groupIntroduce,g.XKXDName,g.XKXDId, g.groupTags, subj.subjectName, grad.gradeName, sc.name as scName """ ) qry.subjectId = self.params.getIntParamZeroAsNull('subjectId') qry.categoryId = self.params.getIntParamZeroAsNull('categoryId') qry.gradeId = self.params.getIntParamZeroAsNull('gradeId') qry.k = self.params.getStringParam("k") if self.qrytype != None: if self.qrytype == "best": qry.isBestGroup = True if self.qrytype == "rcmd": qry.isRecommend = True if self.qrytype == "hot": qry.orderType = GroupQuery.ORDER_BY_VISITCOUNT_DESC if self.qrytype == "new": qry.orderType = GroupQuery.ORDER_BY_ID_DESC pager = self.createPager() pager.totalRows = qry.count() group_list = qry.query_map(pager) request.setAttribute("group_list", group_list) #print "group_list = ", group_list request.setAttribute("pager", pager) request.setAttribute("subjectId", qry.subjectId) request.setAttribute("categoryId", qry.categoryId) request.setAttribute("gradeId", qry.gradeId) request.setAttribute("k", qry.k)
def get_new_group_list(self): qry = GroupQuery( """ g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce,g.parentId,g.XKXDName,g.XKXDId """ ) new_group_list = qry.query_map() request.setAttribute("new_group_list", new_group_list)
def list(self): # 构造查询对象. qry = GroupQuery( """ g.groupId, g.groupName, g.groupTitle, g.groupIcon, g.createDate, g.subjectId, g.gradeId, g.createUserId, g.groupTags, g.groupIntroduce, g.groupState, g.userCount, g.visitCount,g.XKXDName,g.XKXDId, g.isBestGroup, g.isRecommend, u.nickName, u.loginName, sc.name as categoryName """) qry.groupState = None # 缺省为列出所有. # 获得限定参数. # print "params = ", self.params type = self.params.getStringParam("type") request.setAttribute("type", type) request.setAttribute("typeTitle", self.typeToTitle(type)) if type == "unaudit": qry.groupState = Group.GROUP_STATE_WAIT_AUDIT qry.parentId = None elif type == "locked": qry.groupState = Group.GROUP_STATE_LOCKED elif type == "deleted": qry.groupState = Group.GROUP_STATE_DELETED elif type == "hided": qry.groupState = Group.GROUP_STATE_HIDED elif type == "best": qry.isBestGroup = True elif type == "rcmd": qry.isRecommend = True qry.k = self.params.getStringParam("k", None) request.setAttribute("k", qry.k) qry.categoryId = self.params.getIntParamZeroAsNull("sc") #print "qry.categoryId="+str(qry.categoryId) request.setAttribute("sc", qry.categoryId) #多学科多学段导致的问题无法使用下面的方法搜索 qry.subjectId = self.params.getIntParamZeroAsNull("subj") qry.gradeId = self.params.getIntParamZeroAsNull("gradeId") qry.parentId = None #print "qry.gradeId="+str(qry.gradeId) #print "qry.subjectId="+str(qry.subjectId) request.setAttribute("subj", qry.subjectId) request.setAttribute("gradeId", qry.gradeId) # 构造分页并查询数据. pager = self.createPager() pager.totalRows = qry.count() group_list = qry.query_map(pager) request.setAttribute("group_list", group_list) request.setAttribute("pager", pager) self.putGroupCategoryTree() self.putSubjectList() self.putGradeList() return "/WEB-INF/ftl/admin/group_list.ftl"
def applyOrderCondition(self, qctx): if self.orderType == __ComplexGroupQuery.ORDER_TYPE_JOINDATE_DESC: qctx.addOrder("gm.joinDate DESC") return GroupQuery.applyOrderCondition(self, qctx)
def genernate_xiezuozu_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 = GroupQuery( """ g.groupName,g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce """ ) qry.subjectId = self.metaSubjectId qry.gradeId = self.metaGradeId new_group_list = qry.query_map(4) map.put("new_group_list", new_group_list) qry = GroupQuery( """ g.groupName,g.groupIcon, g.createDate, g.groupId, g.groupTitle, g.groupIntroduce """ ) qry.subjectId = self.metaSubjectId qry.gradeId = self.metaGradeId qry.orderType = 8 hot_group_list = qry.query_map(4) map.put("hot_group_list", hot_group_list) Qry = GroupQuery( """ g.groupName,g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.groupIntroduce """ ) qry.subjectId = self.metaSubjectId qry.gradeId = self.metaGradeId qry.isRecommend = True rcmd_group_list = qry.query_map(4) map.put("rcmd_group_list", rcmd_group_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 + "/xiezuozu.ftl", "utf-8") request.setAttribute(cache_key, content) cache.put(cache_key, content)
def query_group_list(self): qry = GroupQuery( """ g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.userCount, g.visitCount, g.articleCount, g.topicCount, g.resourceCount, g.groupIntroduce, g.groupTags, subj.subjectName, grad.gradeName, sc.name as scName """ ) qry.subjectId = self.params.getIntParamZeroAsNull('subjectId') qry.categoryId = self.categoryId qry.gradeId = self.params.getIntParamZeroAsNull('gradeId') qry.searchtype = self.params.getStringParam('searchtype') qry.kk = self.params.getStringParam("k") pager = self.createPager() pager.totalRows = qry.count() group_list = qry.query_map(pager) request.setAttribute("group_list", group_list) ggg = [] for gg in group_list: gid = gg["groupId"] subqry = GroupQuery( """ g.groupId, g.groupIcon, g.groupTitle, g.createDate, g.userCount, g.visitCount, g.articleCount, g.topicCount, g.resourceCount, g.groupIntroduce, g.groupTags """) subqry.parentId = gid subgroup_list = subqry.query_map() ggg.append(subgroup_list) request.setAttribute("subgroups", ggg) request.setAttribute("pager", pager) request.setAttribute("subjectId", qry.subjectId) request.setAttribute("categoryId", qry.categoryId) request.setAttribute("gradeId", qry.gradeId) request.setAttribute("searchtype", qry.searchtype) request.setAttribute("k", qry.kk)