import easyJ.system.data.SysUserCache;
import easyJ.system.service.HtmlClientComponentService;
public class ProjectAction extends SingleDataAction {
public void view() throws EasyJException {
Project project = (Project) object;
project = (Project) dp.get(project);
SysUserCache userCache = (SysUserCache) request.getSession()
.getAttribute(Globals.SYS_USER_CACHE);
Context context = new Context();
context.setProjectId(project.getProjectId());
context.setProjectName(project.getProjectName());
// 下面的程序用来确定此用户在此project中的角色
// 1.首先确定是不是owner。
if (project.getCreatorId().longValue() == user.getUserId().longValue()) {
context.setProjectRole(DictionaryConstant.OWNER);
} else {
// 2.判断用户是否是参与了当前项目
UserProjectRelation relation = new UserProjectRelation();
relation.setUserId(user.getUserId());
relation.setProjectId(project.getProjectId());
ArrayList relationList = dp.query(relation);
// 如果不存在数据,说明没有加入;否则根据状态来确定。
if (relationList.size() == 0) {
context.setProjectRole(DictionaryConstant.OTHER);
} else {
relation = (UserProjectRelation) relationList.get(0);
int applyState = relation.getUserProjectStateRelatedValue()
.intValue();
// 此状态请参见表dictionary中的PROJECT_APPLY_STATE 对应的related value部分。
switch (applyState) {
case 2:
context.setProjectRole(DictionaryConstant.GROUP);
break;
default:
context.setProjectRole(DictionaryConstant.OTHER);
break;
}
}
}
userCache.setContext(context);
HashMap<String,String> roles = context.getRoles();
roles.clear();
//将此项目所拥有的角色加入环境当中
Role role = new Role();
role.setProjectId(project.getProjectId());
ArrayList list = dp.query(role);
int size = list.size();
for(int i=0; i<size; i++) {
role = (Role)list.get(i);
roles.put(role.getRoleId().toString(),role.getRoleName());