Пример #1
0
  @Override
  public int addProject(Project project) {
    project.setUpdateTime(new Date());
    project.setCreateDate(new Date());
    List<User> usersInformed = new ArrayList<User>();
    for (String account : project.getMemberAccountList()) {
      User user = accountDao.getUser(account);
      if (user != null) {
        boolean addSuccess = project.addMember(user);
        if (addSuccess) {
          usersInformed.add(user);
        }
      }
    }
    int result = projectDao.addProject(project);
    for (User u : usersInformed) {
      Notification o = new Notification();
      o.setTypeId((short) 2);
      o.setTargetUser(project.getUser());
      o.setUser(u);
      o.setParam1(new Integer(result).toString());
      o.setParam2(project.getName());
      accountMgr.addNotification(o);
    }

    Group g = organizationDao.getGroup(project.getGroupId());
    if (g.getProductionLineId() > 0) {
      organizationDao.updateCountersInProductionLine(g.getProductionLineId());
    }

    return result;
  }
Пример #2
0
  @Override
  public List<Corporation> getCorporationListWithPager(int pageNum, int pageSize) {

    List<Corporation> list = organizationDao.getCorporationListWithPager(pageNum, pageSize);

    for (Corporation c : list) {
      long memberNum = organizationDao.getMemberNumOfCorporation(c.getId());
      c.setMemberNum(memberNum + 1); // +1 project creator
      c.setHasAccess(true);
      c.setCreatorName(accountMgr.getUser(c.getUserId()).getName());
    }
    return list;
  }
Пример #3
0
 @Override
 public int removeProject(int id) {
   Project p = getProject(id);
   Group g = organizationDao.getGroup(p.getGroupId());
   int result = projectDao.removeProject(id);
   if (g != null) {
     int pId = g.getProductionLineId();
     if (pId > 0) {
       organizationDao.updateCountersInProductionLine(pId);
     }
   }
   return result;
 }
Пример #4
0
 @Override
 public int addTeam(Corporation team) {
   int corpId = organizationDao.addCorporation(team);
   for (String account : team.getAccountList()) {
     if (account == null || account.trim().isEmpty()) continue;
     User u = accountMgr.getUser(account);
     if (u.getId() == team.getUserId()) {
       // if the user is creator, there's no need to add again
       continue;
     }
     organizationDao.addUserToCorp(corpId, u.getId(), 3); // 3, normal member
   }
   return corpId;
 }
Пример #5
0
 @Override
 public List<Corporation> getCorporationListWithPager(long userId, int pageNum, int pageSize) {
   User user = accountMgr.getUser(userId);
   if (user.isAdmin()) {
     return getCorporationListWithPager(pageNum, pageSize);
   }
   List<Corporation> list = organizationDao.getCorporationListWithPager(userId, pageNum, pageSize);
   for (Corporation c : list) {
     long memberNum = organizationDao.getMemberNumOfCorporation(c.getId());
     c.setMemberNum(memberNum + 1); // +1 project creator
     c.setHasAccess(canUserManageCorp(userId, c.getId()));
     c.setCreatorName(accountMgr.getUser(c.getUserId()).getName());
   }
   return list;
 }
Пример #6
0
  @Override
  public boolean addTeamMembers(long curUserId, int corpId, String accountList) {
    if (!canUserManageCorp(curUserId, corpId)) return false;

    String[] accs = accountList.split(",");
    Corporation c = getCorporation(corpId);
    for (String acc : accs) {
      User u = accountMgr.getUser(acc);
      if (u != null) {
        if (!organizationDao.isUserInCorp(u.getId(), corpId) && u.getId() != c.getUserId()) {
          organizationDao.addUserToCorp(corpId, u.getId(), 3);
        }
      }
    }

    return true;
  }
Пример #7
0
 @Override
 public long getCorporationListWithPagerNum(long userId) {
   User user = accountMgr.getUser(userId);
   if (user.isAdmin()) {
     return getCorporationListWithPagerNum();
   }
   return organizationDao.getCorporationListWithPagerNum(userId);
 }
Пример #8
0
 @Override
 public boolean canUserAccessCorp(long userId, int corpId) {
   Corporation c = getCorporation(corpId);
   if (c == null) return false;
   if (c.getUserId() == userId) return true;
   User user = accountMgr.getUser(userId);
   if (user != null && user.isAdmin()) return true;
   return organizationDao.isUserInCorp(userId, corpId);
 }
Пример #9
0
 @Override
 public boolean setUserRoleInCorp(long curUserId, long userId, int corpId, int roleId) {
   if (canUserManageUserInCorp(curUserId, userId, corpId)) {
     organizationDao.setUserRoleInCorp(userId, corpId, roleId);
     return true;
   } else {
     return false;
   }
 }
Пример #10
0
 @Override
 public RapError removeProductionLine(int productionLineId) {
   if (!productionLineCanBeDeleted(productionLineId)) {
     return new RapError(RapError.ERR_HAS_CHILDREN, "为确保您的数据安全,请先删除业务线下的分组及项目,再删除该业务线。");
   } else {
     organizationDao.removeProductionLine(productionLineId);
     return new RapError();
   }
 }
Пример #11
0
 @Override
 public RapError removeGroup(int groupId) {
   if (!groupCanBeDeleted(groupId)) {
     return new RapError(RapError.ERR_HAS_CHILDREN, "为确保您的数据安全,请先删除分组下的项目,再删除该分组。");
   } else {
     organizationDao.removeGroup(groupId);
     return new RapError();
   }
 }
Пример #12
0
  @Override
  public boolean removeMemberFromCorp(long curUserId, long userId, int corpId) {
    int roleId = getUserRoleInCorp(userId, corpId);

    // if user can't manage team, or the user to be deleted is super admin, failed
    if (!canUserManageCorp(curUserId, corpId) || roleId == 1) {
      return false;
    }

    organizationDao.deleteMembershipFromCorp(curUserId, userId, corpId);

    return true;
  }
Пример #13
0
 @Override
 public List<User> getUserLisOfCorp(int corpId) {
   List<User> list = organizationDao.getUserLisOfCorp(corpId);
   Corporation c = getCorporation(corpId);
   User u = accountMgr.getUser(c.getUserId());
   list.add(u);
   for (User user : list) {
     int roleId = getUserRoleInCorp(user.getId(), corpId);
     if (user.isAdmin()) {
       roleId = 1; // user is the RAP platform admin
     } else if (user.getId() == c.getUserId()) {
       roleId = 1; // user is the author
     }
     user.setRoleId(roleId);
   }
   return list;
 }
Пример #14
0
 @Override
 public List<ProductionLine> getProductionLineList(int corpId) {
   return organizationDao.getProductionLineList(corpId);
 }
Пример #15
0
 @Override
 public List<Group> getGroupList(int productionLineId) {
   return organizationDao.getGroupList(productionLineId);
 }
Пример #16
0
 @Override
 public long getCorporationListWithPagerNum() {
   return organizationDao.getCorporationListWithPagerNum();
 }
Пример #17
0
 @Override
 public int addGroup(Group group) {
   return organizationDao.addGroup(group);
 }
Пример #18
0
 @Override
 public List<Corporation> getCorporationList() {
   return organizationDao.getCorporationList();
 }
Пример #19
0
 @Override
 public int addProductionLine(ProductionLine productionLine) {
   return organizationDao.addProductionLine(productionLine);
 }
Пример #20
0
 @Override
 public void updateGroup(Group group) {
   organizationDao.updateGroup(group);
 }
Пример #21
0
 @Override
 public void updateCorporation(Corporation c) {
   organizationDao.updateCorporation(c);
 }
Пример #22
0
 @Override
 public void updateProductionLine(ProductionLine productionLine) {
   organizationDao.updateProductionLine(productionLine);
 }
Пример #23
0
 @Override
 public ProductionLine getProductionLine(int plid) {
   return organizationDao.getProductionLine(plid);
 }
Пример #24
0
 @Override
 public Corporation getCorporation(int id) {
   return organizationDao.getCorporation(id);
 }
Пример #25
0
 @Override
 public int getUserRoleInCorp(long userId, int corpId) {
   return organizationDao.getUserRoleInCorp(userId, corpId);
 }
Пример #26
0
 @Override
 public boolean canUserManageCorp(long userId, int corpId) {
   int roleId = organizationDao.getUserRoleInCorp(userId, corpId);
   return (roleId >= 1 && roleId <= 2 || userId == getCorporation(corpId).getUserId())
       || accountMgr.getUser(userId).isAdmin();
 }