// 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);