Beispiel #1
0
  @Override
  public int updateProject(Project outerProject) {
    Project project = getProject(outerProject.getId());
    project.setName(outerProject.getName());
    project.setIntroduction(outerProject.getIntroduction());
    project.setUpdateTime(new Date());

    if (outerProject.getMemberAccountList() != null) {
      // adding new ones
      for (String account : outerProject.getMemberAccountList()) {
        User user = accountDao.getUser(account);
        if (user != null) {
          boolean addSuccess = project.addMember(user);
          if (addSuccess) {
            Notification o = new Notification();
            o.setTypeId((short) 2);
            o.setTargetUser(outerProject.getUser());
            o.setUser(user);
            o.setParam1(new Integer(outerProject.getId()).toString());
            o.setParam2(outerProject.getName());
            accountMgr.addNotification(o);
          }
        }
      }

      if (project.getUserList() != null) {
        // remove old ones
        List<User> userListToBeRemoved = new ArrayList<User>();
        for (User user : project.getUserList()) {
          if (!outerProject.getMemberAccountList().contains(user.getAccount())) {
            userListToBeRemoved.add(user);
          }
        }

        for (User user : userListToBeRemoved) {
          project.removeMember(user);
        }
      }
    }

    return projectDao.updateProject(project);
  }
Beispiel #2
0
 public void update(Project project) {
   setIntroduction(project.getIntroduction());
   setName(project.getName());
 }