public StringBuffer getProblemvalue(Problemvalue problemvalue,
HttpServletRequest request, boolean vote) throws EasyJException {
// 这个方法输出问题的价值界面
ProblemvalueTypeValue pvtv = new ProblemvalueTypeValue();
StringBuffer buffer = new StringBuffer();
CompositeDataProxy cdp = CompositeDataProxy.getInstance();
Object o = BeanUtil
.getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.Problemvalue");
Class clazz = o.getClass();
SelectCommand scmd = DAOFactory.getSelectCommand(clazz);
Long problemId = problemvalue.getProblemId();
Filter filter = DAOFactory.getFilter("problemId", SQLOperator.EQUAL,
problemId);
scmd.setFilter(filter);
Session session = SessionFactory.openSession();
ArrayList problemvalues = session.query(scmd);
// 标题
buffer
.append("<div class=\"t1\"><div class=\"ico\"><div class=\"icomment\"></div></div>");
buffer.append("对于问题的价值现有<span style=\"color:#FF0000\">"
+ problemvalues.size() + "</span>个讨论</div>");
// 投票面板,先从缓存中得到目前用户的信息,然后查看ProblemvalueTypeValue表,是否已经投过票了,这里更高的效率应该是用主子表查询
SysUserCache userCache = (SysUserCache) request.getSession()
.getAttribute(Globals.SYS_USER_CACHE);
Long userId = userCache.getUser().getUserId();
pvtv.setProblemId(problemvalue.getProblemId());
// evaluation所有人的关于这个问题可理解行的没有过期的投票结果。
ArrayList evaluation_num = cdp.query(pvtv);
pvtv.setCreatorId(userId);
// 当前登陆者关于这个问题可理解行的没有过期的投票结果。
ArrayList myevaluation = cdp.query(pvtv);
o = BeanUtil
.getEmptyObject("cn.edu.pku.dr.requirement.elicitation.data.ProblemvalueTypeValue");
clazz = o.getClass();
scmd = DAOFactory.getSelectCommand(clazz);
Filter filter2 = DAOFactory.getFilter("creatorId", SQLOperator.EQUAL,
userId);
scmd.setFilter(filter2);
// 查询当前用户是否有或者有过评论
ArrayList myallevaluation = session.query(scmd);
session.close();
// todo:有没有问题应该是针对problem版本的,现在是针problemId,以后需要修改
if (myallevaluation.size() > 0) {
if (myevaluation.size() == 0) {
buffer
.append("<div class=\"bc0\" style=\"padding:0px 0pt;\" id=\"notyetvoting\"><div class=\"t2\">问题已修改,请重新投票 <span class=\"f12 gray\" style=\"font-weight:normal\">目前有 "
+ evaluation_num.size() + "个人投票</span>");
// 已经有过评论,当前评论对应着当前版本。如果版本变化,会对ProblemvalueTypeValue中problemId选到的所有的项的use_state置位为N
buffer.append(displayProblemvalueTypeEvaluating(myevaluation,
evaluation_num, problemvalue, userId).toString());
} else {
buffer.append(displayProblemvalueTypeEvaluation(myevaluation,
evaluation_num, userId).toString());
// 已有评论,但是当前版本已经过期
}
} else {
// 目前还没有评论
buffer
.append("<div class=\"bc0\" style=\"padding:0px 0pt;\" id=\"notyetvoting\"><div class=\"t2\">您觉得这个问题的价值有多大,请投票 <span class=\"f12 gray\" style=\"font-weight:normal\">目前有 "
+ evaluation_num.size() + "个人投票</span>");
buffer.append(displayProblemvalueTypeEvaluating(myevaluation,
evaluation_num, problemvalue, userId).toString());
}
// 下面是用户讨论的页面
buffer.append("<div class=\"t2\">对于问题具有价值多少的讨论:</div>");
buffer
.append("<a id=\"problemvalue_order1\" href=\"javascript:Problem.problemvalueOrderByGroup("
+ problemvalue.getProblemId()
+ ") \" style=\"padding :5px 10px 5px 10px!important;padding:4px 10px 4px 10px;height:1px;border:1px solid#7AA9DF;background-color:#EAF3FC;font-size:12px \">按分类排序</a>");
buffer
.append("<div id=\"problemvalue_order11\" style=\"display:none\">false</div>");
buffer
.append("<a id=\"problemvalue_order2\" href=\"javascript:Problem.problemvalueOrderByGoodNum("
+ problemvalue.getProblemId()
+ ")\" style=\"padding:5px 10px 5px 10px!important;padding:4px 10px 4px 10px;height:1px;border:1px solid#7AA9DF;background-color:#EAF3FC;font-size:12px \">按好评升序</a>");
buffer
.append("<div id=\"problemvalue_order22\" style=\"display:none\">false</div>");
buffer.append("<div id=\"viewAllProblemvalue\">");
String group = "false";
String good_num = "false";
Problem problem = new Problem();
problem.setProblemId(problemvalue.getProblemId());
problem = (Problem) cdp.get(problem);
ArrayList problemvalues2 = problem.getProblemvalues();
if (good_num.equals("true")) {
Collections.sort(problemvalues2);
}
String content = "";