public void updateBacklogItemStatePriorityAndEffortLeft( int backlogItemId, State newState, AFTime newEffortLeft, Priority newPriority) throws ObjectNotFoundException { BacklogItem backlogItem = backlogItemDAO.get(backlogItemId); if (backlogItem == null) { throw new ObjectNotFoundException("backlogItem.notFound"); } /* * Set the effort left as original estimate if backlog item's * original estimate is null in database */ if (backlogItem.getOriginalEstimate() == null) { backlogItem.setEffortLeft(newEffortLeft); backlogItem.setOriginalEstimate(newEffortLeft); } else if (backlogItem.getEffortLeft() != null && newEffortLeft == null) { backlogItem.setEffortLeft(new AFTime(0)); } else { backlogItem.setEffortLeft(newEffortLeft); } backlogItem.setState(newState); backlogItem.setPriority(newPriority); // set effortleft to 0 if state changed to done if (newState == State.DONE) backlogItem.setEffortLeft(new AFTime(0)); backlogItemDAO.store(backlogItem); historyBusiness.updateBacklogHistory(backlogItem.getBacklog().getId()); }
public void resetBliOrigEstAndEffortLeft(int backlogItemId) throws ObjectNotFoundException { BacklogItem backlogItem = backlogItemDAO.get(backlogItemId); if (backlogItem == null) { throw new ObjectNotFoundException("backlogItem.notFound"); } else { // Set effort left and original estimate to null backlogItem.setEffortLeft(null); backlogItem.setOriginalEstimate(null); backlogItemDAO.store(backlogItem); historyBusiness.updateBacklogHistory(backlogItem.getBacklog().getId()); } }
public BacklogItem storeBacklogItem( BacklogItem storable, Backlog backlog, BacklogItem dataItem, Set<User> responsibles, IterationGoal iterationGoal) { boolean historyUpdated = false; if (backlog == null) { throw new IllegalArgumentException("Backlog must not be null."); } if (dataItem == null) { throw new IllegalArgumentException("No data given."); } if (storable == null) { storable = new BacklogItem(); storable.setCreatedDate(Calendar.getInstance().getTime()); try { storable.setCreator(SecurityUtil.getLoggedUser()); // may fail if request is multithreaded } catch (Exception e) { } // however, saving item should not fail. } storable.setDescription(dataItem.getDescription()); storable.setEffortLeft(dataItem.getEffortLeft()); storable.setName(dataItem.getName()); if (storable.getOriginalEstimate() == null) { if (dataItem.getOriginalEstimate() == null) { storable.setOriginalEstimate(dataItem.getEffortLeft()); } else { storable.setOriginalEstimate(dataItem.getOriginalEstimate()); } } storable.setPriority(dataItem.getPriority()); storable.setState(dataItem.getState()); if (dataItem.getState() == State.DONE) { storable.setEffortLeft(new AFTime(0)); } else if (dataItem.getEffortLeft() == null) { storable.setEffortLeft(storable.getOriginalEstimate()); } Backlog originalBacklog = storable.getBacklog(); boolean isBeingMoved = false; if (storable.getBacklog() != null && storable.getBacklog() != backlog) { isBeingMoved = true; this.moveItemToBacklog(storable, backlog, false); historyUpdated = true; } else if (storable.getBacklog() == null) { storable.setBacklog(backlog); } storable.setResponsibles(responsibles); if (iterationGoal == null && isBeingMoved) { // Down stepping from Product/Project Story to Iteration Task boolean isTargetIteration = backlog instanceof fi.hut.soberit.agilefant.model.Iteration; boolean isSourceIteration = originalBacklog instanceof fi.hut.soberit.agilefant.model.Iteration; if (isTargetIteration && !isSourceIteration) { // Not using iterationGoalBusiness because of circular dependency in Spring. iterationGoal = new IterationGoal(); iterationGoal.setName(storable.getName()); iterationGoal.setIteration((Iteration) backlog); iterationGoalDAO.store(iterationGoal); } } this.setBacklogItemIterationGoal(storable, iterationGoal); BacklogItem persisted; if (storable.getId() == 0) { int persistedId = (Integer) backlogItemDAO.create(storable); persisted = backlogItemDAO.get(persistedId); } else { backlogItemDAO.store(storable); persisted = storable; } if (!historyUpdated) { historyBusiness.updateBacklogHistory(backlog.getId()); } return persisted; }