public void calculateProjectMetrics(Product product) {
   if (product != null && product.getProjects() != null && product.getProjects().size() > 0) {
     // ProjectData projectDataMap
     for (Project p : product.getProjects()) {
       ProjectMetrics metrics = new ProjectMetrics();
       metrics.setAssignees(backlogBusiness.getNumberOfAssignedUsers(p));
       if (p.getIterations() != null) {
         metrics.setNumberOfAllIterations(p.getIterations().size());
         int ongoingIters = 0;
         Date current = Calendar.getInstance().getTime();
         for (Iteration iter : p.getIterations()) {
           if (iter.getStartDate().getTime() < current.getTime()
               && iter.getEndDate().getTime() > current.getTime()) {
             ongoingIters++;
           }
         }
         metrics.setNumberOfOngoingIterations(ongoingIters);
       } else {
         metrics.setNumberOfAllIterations(0);
         metrics.setNumberOfOngoingIterations(0);
       }
       p.setMetrics(metrics);
     }
   }
 }
  protected JFreeChart constructChart(Iteration iteration, Integer timeZoneOffset) {
    // get server timezone
    Calendar cal = Calendar.getInstance();
    TimeZone localTimeZone = cal.getTimeZone();

    // server timezone offset in minutes
    int rawOffset = localTimeZone.getRawOffset() / 60000;

    // get offset difference in minutes
    timeDifferenceMinutes = rawOffset - timeZoneOffset.intValue();

    JFreeChart burndown =
        ChartFactory.createTimeSeriesChart(
            "'" + iteration.getName() + "' burndown",
            DATE_AXIS_LABEL,
            EFFORT_AXIS_LABEL,
            getDataset(iteration),
            true,
            true,
            false);

    formatChartAxes(
        burndown,
        new DateTime(iteration.getStartDate().minusMinutes(timeDifferenceMinutes)),
        new DateTime(iteration.getEndDate()).minusMinutes(timeDifferenceMinutes));

    formatChartStyle(burndown);

    return burndown;
  }
 /** {@inheritDoc} * */
 public Collection<BacklogItem> getBlisInProjectAndItsIterations(Project project) {
   Collection<BacklogItem> blis = new HashSet<BacklogItem>();
   blis.addAll(project.getBacklogItems());
   Collection<Iteration> iterations = iterationDAO.getAll();
   for (Iteration it : iterations) {
     if (it.getProject().getId() == project.getId()) {
       blis.addAll(it.getBacklogItems());
     }
   }
   return blis;
 }
  @Test
  @DirtiesContext
  public void testMoveStoryAndChildren() {
    Story parent = new Story();
    Story child1 = new Story();
    Story child2 = new Story();

    parent.getChildren().add(story);

    story.setParent(parent);
    story.getChildren().add(child1);

    child1.setParent(story);
    child1.getChildren().add(child2);

    child2.setParent(child1);

    parent.setBacklog(firstProject);
    story.setBacklog(firstProject);
    child1.setBacklog(firstProject);
    child2.setBacklog(firstIteration);

    firstIteration.setParent(firstProduct);

    expect(storyTreeIntegrityBusiness.hasParentStoryConflict(story, secondProject)).andReturn(true);
    storyHierarchyBusiness.updateChildrenTreeRanks(parent);

    expect(backlogBusiness.getParentProduct(firstProject)).andReturn(firstProduct).anyTimes();
    expect(backlogBusiness.getParentProduct(secondProject)).andReturn(firstProduct).anyTimes();

    storyDAO.store(child2);

    storyRankBusiness.removeRank(child2, firstIteration);
    storyRankBusiness.removeRank(child2, firstIteration.getParent());

    storyRankBusiness.rankToBottom(child2, secondProject);

    storyDAO.store(child1);
    storyDAO.store(story);

    backlogHistoryEntryBusiness.updateHistory(firstIteration.getId());
    backlogHistoryEntryBusiness.updateHistory(secondProject.getId());
    iterationHistoryBusiness.updateIterationHistory(firstIteration.getId());
    backlogHistoryEntryBusiness.updateHistory(firstProject.getId());
    EasyMock.expectLastCall().times(2);
    backlogHistoryEntryBusiness.updateHistory(secondProject.getId());
    EasyMock.expectLastCall().times(2);

    replayAll();
    storyBusiness.moveStoryAndChildren(story, secondProject);
    verifyAll();
  }
예제 #5
0
 @Test
 public void testGetTasksWithRankBetween_iterationEmptyCollection() {
   iter.setId(1);
   executeClassSql();
   Collection<Task> actual = taskDAO.getTasksWithRankBetween(2, 0, iter, null);
   assertEquals(0, actual.size());
 }
예제 #6
0
  @Test
  public void testDelete_deleteChoices_withChildren_deleteChildren() {
    Story child = new Story();
    child.setBacklog(storyInIteration.getBacklog());
    child.setIteration(iteration);
    child.setId(2333);
    child.setParent(storyInIteration);
    storyInIteration.getChildren().add(child);
    storyInIteration.setIteration(null);

    blheBusiness.updateHistory(child.getBacklog().getId());
    iheBusiness.updateIterationHistory(iteration.getId());

    hourEntryBusiness.deleteAll(child.getHourEntries());
    hourEntryBusiness.deleteAll(storyInIteration.getHourEntries());

    //        storyRankBusiness.removeStoryRanks(child);
    //        storyRankBusiness.removeStoryRanks(storyInIteration);

    //        expect(storyDAO.get(2333)).andReturn(child);

    storyDAO.remove(child.getId());
    storyDAO.remove(storyInIteration);

    replayAll();
    storyBusiness.delete(
        storyInIteration,
        TaskHandlingChoice.DELETE,
        HourEntryHandlingChoice.DELETE,
        HourEntryHandlingChoice.DELETE,
        ChildHandlingChoice.DELETE);
    //        assertNull(child.getParent());
    assertTrue(storyInIteration.getChildren().isEmpty());
    verifyAll();
  }
  @Test(expected = OperationNotPermittedException.class)
  @DirtiesContext
  public void testMoveStoryAndChildren_toIteration() {
    Story parent = new Story();
    Story child1 = new Story();
    Story child2 = new Story();

    parent.getChildren().add(story);

    story.setParent(parent);
    story.getChildren().add(child1);

    child1.setParent(story);
    child1.getChildren().add(child2);

    child2.setParent(child1);

    parent.setBacklog(firstProject);
    story.setBacklog(firstProject);
    child1.setBacklog(firstProject);
    child2.setBacklog(firstIteration);

    firstIteration.setParent(firstProduct);
    expect(backlogBusiness.getParentProduct(firstProject)).andReturn(firstProduct);
    expect(backlogBusiness.getParentProduct(secondIteration)).andReturn(firstProduct);
    replayAll();
    storyBusiness.moveStoryAndChildren(story, secondIteration);
    verifyAll();
  }
예제 #8
0
 @Test
 public void testGetNextTaskInRank_iteration() {
   iter.setId(1);
   executeClassSql();
   Task actual = taskDAO.getNextTaskInRank(0, iter, null);
   assertEquals(1, actual.getRank());
 }
예제 #9
0
 @Test
 public void testGetLastTaskInRank_iteration() {
   iter.setId(3);
   executeClassSql();
   Task actual = taskDAO.getLastTaskInRank(null, iter);
   assertEquals(17, actual.getId());
   assertEquals(1500, actual.getRank());
 }
예제 #10
0
 @Test
 public void testGetNextTaskInRank_iteration_largeCap() {
   iter.setId(3);
   executeClassSql();
   Task actual = taskDAO.getNextTaskInRank(25, iter, null);
   assertEquals(17, actual.getId());
   assertEquals(1500, actual.getRank());
 }
  /** Assembles all the needed <code>TimeSeries</code>. */
  protected TimeSeriesCollection getDataset(Iteration iteration) {
    TimeSeriesCollection chartDataset = new TimeSeriesCollection();

    List<IterationHistoryEntry> iterationEntries =
        iterationHistoryEntryBusiness.getHistoryEntriesForIteration(iteration);

    LocalDate yesterday = new LocalDate().minusDays(1);
    LocalDate today = new LocalDate();
    IterationHistoryEntry yesterdayEntry = getHistoryEntryForDate(iterationEntries, yesterday);
    IterationHistoryEntry todayEntry = getHistoryEntryForDate(iterationEntries, today);
    DateTime iterationStartDate = new DateTime(iteration.getStartDate());
    DateTime iterationEndDate = new DateTime(iteration.getEndDate());

    chartDataset.addSeries(
        getBurndownTimeSeries(
            iterationEntries,
            new LocalDate(iteration.getStartDate()),
            determineEndDate(new LocalDate(iteration.getEndDate()))));

    chartDataset.addSeries(getCurrentDayTimeSeries(yesterdayEntry, todayEntry));

    chartDataset.addSeries(
        getScopingTimeSeries(
            iterationEntries, iterationStartDate.toLocalDate(), iterationEndDate.toLocalDate()));

    chartDataset.addSeries(
        getReferenceVelocityTimeSeries(
            iterationStartDate,
            iterationEndDate,
            new ExactEstimate(todayEntry.getOriginalEstimateSum())));

    TimeSeries predictedVelocity =
        getPredictedVelocityTimeSeries(
            iterationStartDate.toLocalDate(),
            iterationEndDate.toLocalDate(),
            yesterdayEntry,
            todayEntry);
    if (predictedVelocity != null) {
      chartDataset.addSeries(predictedVelocity);
    }

    return chartDataset;
  }
예제 #12
0
  @Test(expected = IllegalArgumentException.class)
  public void testRankStoryUnder_invalidbacklogs() {
    Project proj1 = new Project();
    Iteration iter = new Iteration();
    iter.setParent(proj1);

    Project proj2 = new Project();
    Iteration iter2 = new Iteration();
    iter2.setParent(proj2);

    Story story1 = new Story();
    story1.setBacklog(proj1);
    Story story2 = new Story();
    story2.setBacklog(proj2);

    replayAll();
    storyBusiness.rankStoryUnder(story1, story2, proj1);
    verifyAll();
  }
  @Before
  public void createModels() {
    story = new Story();
    story.setId(1);

    firstIteration = new Iteration();
    firstIteration.setId(1);

    secondIteration = new Iteration();
    secondIteration.setId(2);

    firstProject = new Project();
    firstProject.setId(3);

    secondProject = new Project();
    secondProject.setId(4);

    firstProduct = new Product();
    firstProduct.setId(5);
  }
  @Test
  @DirtiesContext
  public void moveFromProjectToIteration_iterationInProject() {
    firstIteration.setParent(firstProject);
    story.setBacklog(firstProject);
    expect(storyTreeIntegrityBusiness.canStoryBeMovedToBacklog(story, firstIteration))
        .andReturn(true);
    storyDAO.store(story);
    storyRankBusiness.rankToBottom(story, firstIteration);

    backlogHistoryEntryBusiness.updateHistory(firstProject.getId());
    backlogHistoryEntryBusiness.updateHistory(firstIteration.getId());

    iterationHistoryBusiness.updateIterationHistory(firstIteration.getId());

    replayAll();
    storyBusiness.moveStoryToBacklog(story, firstIteration);
    verifyAll();
    assertEquals(firstIteration, story.getBacklog());
  }
예제 #15
0
  @Before
  public void setUp() {
    backlog = new Product();
    iteration = new Iteration();
    iteration.setId(5834);
    story1 = new Story();
    story1.setId(666);
    story2 = new Story();

    storyPriorityUpdated = false;
    storyBacklogUpdated = false;
  }
  private void constructBacklogs() {
    product = new Product();
    project1 = new Project();
    project2 = new Project();
    iteration = new Iteration();

    product.setChildren(new HashSet<Backlog>(Arrays.asList(project1, project2)));

    project1.setParent(product);
    project1.setChildren(new HashSet<Backlog>(Arrays.asList(iteration)));
    iteration.setParent(project1);

    project2.setParent(product);
  }
예제 #17
0
  @Before
  public void setUpStorysProjectResponsiblesData() {
    Iteration iter = new Iteration();
    Project proj = new Project();
    Product prod = new Product();
    iter.setParent(proj);
    proj.setParent(prod);

    assignedUser = new User();
    assignedUser.setId(2233);

    storyInIteration = new Story();
    storyInProject = new Story();
    storyInProduct = new Story();

    storyInIteration.setId(868);
    storyInProduct.setId(951);
    storyInProject.setId(3);

    storyInIteration.setIteration(iter);
    storyInIteration.setBacklog(proj);
    storyInProject.setBacklog(proj);
    storyInProduct.setBacklog(prod);
  }
  @Test
  @DirtiesContext
  public void testHasParentStoryConflict_toIteration() {
    Product product = new Product();
    Project project = new Project();
    Iteration iteration = new Iteration();

    Story parentStory = new Story();
    Story story = new Story();

    iteration.setParent(project);
    project.setParent(product);

    parentStory.setBacklog(project);
    story.setBacklog(project);
    story.setParent(parentStory);

    expect(this.backlogBusiness.getParentProduct(iteration)).andReturn(product);
    expect(this.backlogBusiness.getParentProduct(project)).andReturn(product);

    replayAll();
    assertFalse(this.testable.hasParentStoryConflict(story, iteration));
    verifyAll();
  }
  public List<Backlog> getProjectsAndIterationsInTimeFrame(
      List<Backlog> backlogs, Date startDate, Date endDate) {
    List<Backlog> list = new ArrayList<Backlog>(0);

    for (Backlog blog : backlogs) {
      Project pro = null;
      Iteration it = null;

      // Backlog is Project
      if (blog.getClass().equals(Project.class)) {
        pro = (Project) blog;
        if ((pro.getEndDate().after(startDate) && pro.getEndDate().before(endDate))
            || (pro.getStartDate().after(startDate) && pro.getStartDate().before(endDate))
            || (pro.getStartDate().before(startDate) && pro.getEndDate().after(endDate))
            || (pro.getStartDate().compareTo(startDate) == 0)
            || (pro.getEndDate().compareTo(endDate) == 0)) {
          list.add(blog);
          log.debug("IN timeframe, project");
        } else {
          log.debug("NOT in timeframe");
        }
      }

      // Backlog is Iteration
      if (blog.getClass().equals(Iteration.class)) {
        it = (Iteration) blog;
        if ((it.getEndDate().after(startDate) && it.getEndDate().before(endDate))
            || (it.getStartDate().after(startDate) && it.getStartDate().before(endDate))
            || (it.getStartDate().before(startDate) && it.getEndDate().after(endDate))
            || (it.getStartDate().compareTo(startDate) == 0)
            || (it.getEndDate().compareTo(endDate) == 0)) {
          list.add(blog);
          log.debug("IN timeframe, iteration");
        } else {
          log.debug("NOT in timeframe");
        }
      }
    }
    return list;
  }
  public HashMap<Integer, String> calculateEffortLefts(
      Date from, int weeksAhead, Map<Backlog, List<BacklogItem>> items) {
    GregorianCalendar cal = new GregorianCalendar();
    CalendarUtils cUtils = new CalendarUtils();
    HashMap<Integer, String> effortLefts = new HashMap<Integer, String>();

    Date start = from;
    Date end = cUtils.nextMonday(start);
    cal.setTime(start);
    Integer week = cal.get(GregorianCalendar.WEEK_OF_YEAR);
    for (int i = 1; i <= weeksAhead; i++) {
      // 1. Get Backlogs that hit for the week
      log.debug("Projects searched from :" + start);
      log.debug("Projects searched ending :" + end);
      cal.setTime(start);
      week = cal.get(GregorianCalendar.WEEK_OF_YEAR);
      log.debug("Calculating sums for week" + week);

      // 2. Get projects that hit current week
      List<Backlog> list =
          this.getProjectsAndIterationsInTimeFrame(
              new ArrayList<Backlog>(items.keySet()), start, end);
      log.debug(list.size() + " projects found for given time frame");

      // 3. Calculate effort sum from items in those projects
      AFTime total = new AFTime(0);
      for (Backlog blog : list) {
        Project pro = null;
        Iteration it = null;
        if (blog.getClass().equals(Project.class)) {
          pro = (Project) blog;
          List<BacklogItem> blis = items.get((Backlog) pro);
          if (blis != null) {
            // Dividing for weeks that project hits
            AFTime sum =
                this.backlogBusiness.getEffortLeftResponsibleDividedSum(blis).getEffortHours();
            int projectLength = CalendarUtils.getLengthInDays(pro.getStartDate(), pro.getEndDate());
            log.debug("Week Project length: " + projectLength + " days");
            int weekEndDaysInProject = cUtils.getWeekEndDays(pro.getStartDate(), pro.getEndDate());
            log.debug("Excluding " + weekEndDaysInProject + " days from project as week end days");
            projectLength = projectLength - weekEndDaysInProject;
            if (projectLength == 0) { // TODO Find better way to
              // prevent null divination
              // if project on weekend
              projectLength = 1;
            }
            List<Date> dates =
                cUtils.getProjectDaysList(
                    pro.getStartDate(),
                    pro.getEndDate(),
                    start,
                    new Date(end.getTime() - 86400000L),
                    false);
            int projectDaysOnWeek = 0;
            if (dates != null) {
              projectDaysOnWeek = dates.size();
            }
            log.debug("Week Project length (modified): " + projectLength + " days");
            log.debug("Week Project days:" + projectDaysOnWeek);
            log.debug(
                "Week Project effort per day: " + new AFTime(sum.getTime() / (long) projectLength));
            sum = new AFTime((sum.getTime() / (long) projectLength) * projectDaysOnWeek);
            if (sum != null) {
              total.add(sum);
              log.debug("Week effort sum: " + sum);
            }
          }
        }
        if (blog.getClass().equals(Iteration.class)) {
          it = (Iteration) blog;
          List<BacklogItem> blis = items.get((Backlog) it);
          if (blis != null) {
            // Dividing for weeks that project hits
            AFTime sum =
                this.backlogBusiness.getEffortLeftResponsibleDividedSum(blis).getEffortHours();
            int projectLength = CalendarUtils.getLengthInDays(it.getStartDate(), it.getEndDate());
            log.debug("Week Project length: " + projectLength + " days");
            int weekEndDaysInProject = cUtils.getWeekEndDays(it.getStartDate(), it.getEndDate());
            log.debug("Excluding " + weekEndDaysInProject + " days from project as week end days");
            projectLength = projectLength - weekEndDaysInProject;
            if (projectLength == 0) { // TODO Find better way to
              // prevent null division if
              // project on weekend
              projectLength = 1;
            }
            List<Date> dates =
                cUtils.getProjectDaysList(
                    it.getStartDate(),
                    it.getEndDate(),
                    start,
                    new Date(end.getTime() - 86400000L),
                    false);
            int projectDaysOnWeek = 0;
            if (dates != null) {
              projectDaysOnWeek = dates.size();
            }
            log.debug("Week Project length(modified): " + projectLength + " days");
            log.debug("Week Project days:" + projectDaysOnWeek);
            log.debug(
                "Week Project effort per day: " + new AFTime(sum.getTime() / (long) projectLength));
            sum = new AFTime((sum.getTime() / (long) projectLength) * projectDaysOnWeek);
            if (sum != null) {
              total.add(sum);
              log.debug("Week effort sum: " + sum);
            }
          }
        }
      }

      effortLefts.put(week, total.toString());
      start = cUtils.nextMonday(start);
      end = cUtils.nextMonday(start);
      cal.setTime(start);
      week = cal.get(GregorianCalendar.WEEK_OF_YEAR);
    }

    return effortLefts;
  }
예제 #21
0
 @Test
 public void testGetNextTaskInRank_iteration_notFound() {
   iter.setId(1);
   executeClassSql();
   assertNull(taskDAO.getNextTaskInRank(999, iter, null));
 }