/** {@inheritDoc} */ public void moveToTop(int projectId) { Project project = projectDAO.get(projectId); if (project != null && project.getRank() != 1) { if (project.getRank() == 0) { projectDAO.raiseRankBetween(1, null); } else { projectDAO.raiseRankBetween(1, project.getRank()); } project.setRank(1); projectDAO.store(project); } }
/** {@inheritDoc} */ public void moveDown(int projectId) { Project project = projectDAO.get(projectId); if (project != null) { Project upperRankedProject = projectDAO.findFirstUpperRankedOngoingProject(project); if (upperRankedProject != null) { int upperRank = upperRankedProject.getRank(); projectDAO.raiseRankBetween(upperRank + 1, null); project.setRank(upperRank + 1); projectDAO.store(project); } } }
/** {@inheritDoc} */ public void moveUp(int projectId) { Project project = projectDAO.get(projectId); if (project != null) { Project lowerRankedProject = projectDAO.findFirstLowerRankedOngoingProject(project); if (lowerRankedProject != null) { int lowerRank = lowerRankedProject.getRank(); projectDAO.raiseRankBetween(lowerRank, project.getRank()); project.setRank(lowerRank); projectDAO.store(project); } } }