@Override public long getProjectListNum(User user) { if (user != null && user.isUserInRole("admin")) { user = null; } return projectDao.getProjectListNum(user); }
@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; }
@Override public List<Project> getProjectList(User user, int curPageNum, int pageSize) { List<Project> projectList = projectDao.getProjectList(user, curPageNum, pageSize); for (Project p : projectList) { if (user.isUserInRole("admin") || p.getUser().getId() == user.getId()) p.setIsManagable(true); } return projectList; }
@Override public List<Action> getMatchedActionList(int projectId, String pattern) { List<Action> actionList = projectDao.getMatchedActionList(projectId, pattern); if (actionList == null || actionList.size() == 0) { Project project = projectDao.getProject(projectId); if (project != null) { String ids = project.getRelatedIds(); if (ids != null && !ids.isEmpty()) { String[] arr = ids.split(","); for (String id : arr) { actionList = projectDao.getMatchedActionList(Integer.parseInt(id), pattern); if (actionList != null && actionList.size() != 0) { return actionList; } } } } } return actionList; }
@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; }
@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); }
@Override public List<Project> selectMockNumTopNProjectList(int limit) { return projectDao.selectMockNumTopNProjectList(limit); }
@Override public long getMockNumInTotal() { return projectDao.getMockNumInTotal(); }
@Override public long getCheckInNum() { return projectDao.getCheckInNum(); }
@Override public long getParametertNum() { return projectDao.getParametertNum(); }
@Override public long getActionNum() { return projectDao.getActionNum(); }
@Override public long getPageNum() { return projectDao.getPageNum(); }
@Override public Page getPage(int id) { return projectDao.getPage(id); }
@Override public long getProjectNum() { return projectDao.getProjectListNum(); }
@Override public Action getAction(long id) { return projectDao.getAction(id); }
@Override public List<Project> search(String key) { return projectDao.search(key); }
@Override public List<Project> getProjectListByGroup(int id) { return projectDao.getProjectListByGroup(id); }
@Override public Module getModule(int id) { return projectDao.getModule(id); }
@Override public Project getProject(int id) { return projectDao.getProject(id); }
@Override public long getModuleNum() { return projectDao.getModuleNum(); }
@Override public List<Project> getProjectList() { return projectDao.getProjectList(); }
@Override public String updateProject( int id, String projectData, String deletedObjectListData, Map<Long, Long> actionIdMap) { return projectDao.updateProject(id, projectData, deletedObjectListData, actionIdMap); }