Ejemplo n.º 1
0
    @Override
    public String getValue(TreeItem object) {
      String penImageResource =
          "<img src=\""
              + JaggerResources.INSTANCE.getPencilImage().getSafeUri().asString()
              + "\" height=\"15\" width=\"15\">"
              + "<ins font-size='10px'>double click to edit</ins><br><br>";
      String toShow;

      // Only for columns with data
      if (!field.equals(NAME)) {
        if (webClientProperties.isUserCommentEditAvailable()) {
          if (object.get(NAME).equals(USER_COMMENT)) {
            toShow = object.get(field).replaceAll("\n", "<br>");
            return penImageResource + toShow;
          }
        }
        if (webClientProperties.isTagsAvailable()) {
          if (object.get(NAME).equals(SESSION_TAGS)) {
            toShow = object.get(field).replaceAll("\n", "<br>");
            return penImageResource + toShow;
          }
        }
      }

      return object.get(field);
    }
Ejemplo n.º 2
0
  public void removeTestInfo(TaskDataDto test) {

    String id = getTestItemId(test);
    TreeItem testItem = treeStore.findModelWithKey(id);
    if (testItem == null) {
      return;
    }
    TreeItem testInfo = treeStore.getFirstChild(testItem);
    if (testInfo != null && TEST_INFO.equals(testInfo.get(NAME))) removeWithParent(testInfo);
  }
Ejemplo n.º 3
0
  private void addItemToStore(TreeItem record, SummarySingleDto metricDto) {

    TreeItem taskItem = getTestItem(metricDto.getMetricName().getTest());
    for (TreeItem rec : treeStore.getChildren(taskItem)) {
      if (rec.getKey().equals(record.getKey())) {
        return;
      }
    }
    treeStore.add(taskItem, record);
  }
Ejemplo n.º 4
0
 private TreeItem getTestDescriptionItem(String descriptionStr) {
   for (TreeItem item : treeStore.getRootItems()) {
     if (descriptionStr.equals(item.get(NAME))) {
       return item;
     }
   }
   TreeItem description = new TreeItem(descriptionStr);
   description.put(NAME, descriptionStr);
   treeStore.add(description);
   return description;
 }
Ejemplo n.º 5
0
  private void removeRecord(SummarySingleDto metric) {

    TreeItem testItem = getTestItem(metric.getMetricName().getTest());
    String key = testItem.getKey() + metric.getMetricName().getMetricName();

    for (TreeItem item : treeStore.getChildren(testItem)) {
      if (item.getKey().equals(key)) {
        removeWithParent(item);
        return;
      }
    }
  }
Ejemplo n.º 6
0
  private TreeItem getTestItem(TaskDataDto tdd) {

    String key = getTestItemId(tdd);
    TreeItem taskItem = treeStore.findModelWithKey(key);
    if (taskItem != null) {
      return taskItem;
    }

    TreeItem description = getTestDescriptionItem(tdd.getDescription());

    taskItem = new TreeItem(key);
    taskItem.put(NAME, getTestItemName(tdd));
    taskItem.put(TEST_DESCRIPTION, tdd.getDescription());
    treeStore.add(description, taskItem);
    return taskItem;
  }
Ejemplo n.º 7
0
  // clear everything but Session Information
  public void clearTreeStore() {

    for (TreeItem root : treeStore.getRootItems()) {
      if (root.getKey().equals(SESSION_INFO_ID)) {
        continue;
      }
      for (TreeItem test : treeStore.getChildren(root)) {
        for (TreeItem item : treeStore.getChildren(test)) {
          if (TEST_INFO.equals(item.get(NAME))) {
            continue;
          }
          removeWithParent(item);
        }
      }
    }
  }
  public void writeDataToExcel(Sheet sheet) {
    LOGGER.debug("[{}] Exporting data to excel", getText());

    List<ExcelColumnRenderer> columnRendererList = new ArrayList<>();
    columnRendererList.add(new TaskStatusExcelColumn());
    columnRendererList.add(new TaskDescriptionExcelColumn());

    TimerangeProvider timerangeProvider = fetchTimereportContext.get().getTimerangeProvider();
    LocalDate startDate = timerangeProvider.getStartDate();
    LocalDate endDate = timerangeProvider.getEndDate();

    long amountOfDaysToDisplay = ChronoUnit.DAYS.between(startDate, endDate);
    for (int days = 0; days <= amountOfDaysToDisplay; days++) {
      LocalDate currentColumnDate = timerangeProvider.getStartDate().plus(days, ChronoUnit.DAYS);
      String displayDate = FormattingUtil.formatDate(currentColumnDate);
      columnRendererList.add(new WorklogExcelColumn(displayDate, currentColumnDate));
    }

    columnRendererList.add(new TaskWorklogSummaryExcelColumn());

    TreeItem<DisplayRow> root = taskTableView.getRoot();
    ObservableList<TreeItem<DisplayRow>> children = root.getChildren();

    for (int columnIndex = 0; columnIndex < columnRendererList.size(); columnIndex++) {
      ExcelColumnRenderer excelColumnRenderer = columnRendererList.get(columnIndex);
      excelColumnRenderer.renderCells(
          columnIndex,
          sheet,
          children,
          fetchTimereportContext.get().getGroupByCategory().isPresent());
    }

    // autosize column widths
    for (int i = 0; i < columnRendererList.size(); i++) {
      sheet.autoSizeColumn(i);
    }
  }
Ejemplo n.º 9
0
 @Override
 public String getKey(TreeItem item) {
   return String.valueOf(item.getKey());
 }
Ejemplo n.º 10
0
 @Override
 public void setValue(TreeItem object, String value) {
   object.put(field, value);
 }
Ejemplo n.º 11
0
  public void addTestInfo(TaskDataDto test, Map<String, TestInfoDto> testInfoMap) {

    TreeItem testItem = getTestItem(test);

    String testInfoId = testItem.getKey() + TEST_INFO;
    if (treeStore.findModelWithKey(testInfoId) != null) {
      return;
    }

    String testItemName = getTestItemName(test);
    TreeItem testInfo = new TreeItem(testInfoId);
    testInfo.put(NAME, TEST_INFO);
    testInfo.put(TEST_DESCRIPTION, test.getDescription());
    testInfo.put(TEST_NAME, testItemName);
    treeStore.insert(testItem, 0, testInfo);

    TreeItem clock = new TreeItem(testItem.getKey() + "Clock");
    clock.put(NAME, "Clock");
    clock.put(TEST_DESCRIPTION, test.getDescription());
    clock.put(TEST_NAME, testItemName);
    clock.put(TEST_INFO, TEST_INFO);
    for (SessionDataDto session : chosenSessions) {
      if (testInfoMap.get(session.getSessionId()) != null)
        clock.put(
            SESSION_HEADER + session.getSessionId(),
            testInfoMap.get(session.getSessionId()).getClock());
    }
    treeStore.add(testInfo, clock);

    TreeItem termination = new TreeItem(testItem.getKey() + "Termination");
    termination.put(NAME, "Termination");
    termination.put(TEST_DESCRIPTION, test.getDescription());
    termination.put(TEST_NAME, testItemName);
    termination.put(TEST_INFO, TEST_INFO);
    for (SessionDataDto session : chosenSessions) {
      if (testInfoMap.get(session.getSessionId()) != null)
        termination.put(
            SESSION_HEADER + session.getSessionId(),
            testInfoMap.get(session.getSessionId()).getTermination());
    }
    treeStore.add(testInfo, termination);

    TreeItem startTime = new TreeItem(testItem.getKey() + "Start time");
    startTime.put(NAME, "Start time");
    startTime.put(TEST_DESCRIPTION, test.getDescription());
    startTime.put(TEST_NAME, testItemName);
    startTime.put(TEST_INFO, TEST_INFO);
    for (SessionDataDto session : chosenSessions) {
      if (testInfoMap.get(session.getSessionId()) != null) {
        Date date = testInfoMap.get(session.getSessionId()).getStartTime();
        startTime.put(SESSION_HEADER + session.getSessionId(), dateFormatter.format(date));
      }
    }
    treeStore.add(testInfo, startTime);
  }
Ejemplo n.º 12
0
  public void addSessionInfo() {
    TreeItem sessionInfo = new TreeItem(SESSION_INFO_ID);
    sessionInfo.put(NAME, "Session Info");
    treeStore.insert(0, sessionInfo);

    String tagsStr = "";
    TreeItem itemActiveKernels = new TreeItem(ACTIVE_KERNELS);
    TreeItem itemTaskExecuted = new TreeItem(TASKS_EXECUTED);
    TreeItem itemTaskFailed = new TreeItem(TASKS_FAILED);
    TreeItem itemDateStart = new TreeItem(START_DATE);
    TreeItem itemDateEnd = new TreeItem(END_DATE);
    TreeItem itemComment = new TreeItem(COMMENT);
    TreeItem itemUserComment = new TreeItem(USER_COMMENT);
    TreeItem itemTags = new TreeItem(SESSION_TAGS);

    itemActiveKernels.put(NAME, ACTIVE_KERNELS);
    itemTaskExecuted.put(NAME, TASKS_EXECUTED);
    itemTaskFailed.put(NAME, TASKS_FAILED);
    itemDateStart.put(NAME, START_DATE);
    itemDateEnd.put(NAME, END_DATE);
    itemComment.put(NAME, COMMENT);
    if (webClientProperties.isUserCommentStoreAvailable()) itemUserComment.put(NAME, USER_COMMENT);
    if (webClientProperties.isTagsStoreAvailable()) itemTags.put(NAME, SESSION_TAGS);

    for (SessionDataDto session : chosenSessions) {
      itemActiveKernels.put(
          SESSION_HEADER + session.getSessionId(), session.getActiveKernelsCount() + "");
      itemTaskExecuted.put(
          SESSION_HEADER + session.getSessionId(), session.getTasksExecuted() + "");
      itemTaskFailed.put(SESSION_HEADER + session.getSessionId(), session.getTasksFailed() + "");
      itemDateStart.put(
          SESSION_HEADER + session.getSessionId(), dateFormatter.format(session.getStartDate()));
      itemDateEnd.put(
          SESSION_HEADER + session.getSessionId(), dateFormatter.format(session.getEndDate()));
      itemComment.put(SESSION_HEADER + session.getSessionId(), session.getComment());
      if (webClientProperties.isUserCommentStoreAvailable()) {
        String userComment = session.getUserComment() == null ? "" : session.getUserComment();
        itemUserComment.put(SESSION_HEADER + session.getSessionId(), userComment);
      }
      if (webClientProperties.isTagsStoreAvailable()) {
        for (int i = 0; i < session.getTags().size(); i++) {
          if (i == session.getTags().size() - 1) tagsStr += session.getTags().get(i).getName();
          else tagsStr += session.getTags().get(i).getName() + ", ";
        }
        itemTags.put(SESSION_HEADER + session.getSessionId(), tagsStr);
        tagsStr = "";
      }
    }
    treeStore.add(sessionInfo, itemComment);
    if (webClientProperties.isUserCommentStoreAvailable())
      treeStore.add(sessionInfo, itemUserComment);
    if (webClientProperties.isTagsStoreAvailable()) treeStore.add(sessionInfo, itemTags);
    treeStore.add(sessionInfo, itemDateStart);
    treeStore.add(sessionInfo, itemDateEnd);

    treeStore.add(sessionInfo, itemActiveKernels);
    treeStore.add(sessionInfo, itemTaskExecuted);
    treeStore.add(sessionInfo, itemTaskFailed);
  }
Ejemplo n.º 13
0
 public Path getSelectedTabPath() {
   TreeItem<Item> selectedItem = controller.getTreeView().getSelectionModel().getSelectedItem();
   Item value = selectedItem.getValue();
   Path path = value.getPath();
   return path;
 }
  private void processWithGrouping(List<TaskWithWorklogs> tasks, DisplayData displayData) {
    LOGGER.debug("Processing with grouping");
    List<String> distinctGroupByCriteria =
        tasks
            .stream()
            .map(TaskWithWorklogs::getDistinctGroupByCriteriaValues)
            .flatMap(Collection::stream)
            .distinct()
            .sorted(COLLATOR)
            .collect(Collectors.toList());

    distinctGroupByCriteria.forEach(
        groupByCriteria -> {
          LOGGER.debug("Gathering data for group criteria value {}", groupByCriteria);
          DisplayRow groupCaptionRow = new DisplayRow();
          groupCaptionRow.setIsGroupContainer(true);
          groupCaptionRow.setLabel(groupByCriteria);

          TreeItem<DisplayRow> groupRow = new TreeItem<>(groupCaptionRow);
          groupRow.setExpanded(true);
          Map<String, DisplayRow> ticketIdToDisplayRow = Maps.newHashMap();

          // add sub rows to groupRow
          tasks
              .stream()
              .filter(
                  taskWithWorklogs ->
                      taskWithWorklogs.getDistinctGroupByCriteriaValues().contains(groupByCriteria))
              .sorted((o1, o2) -> COLLATOR.compare(o1.getIssue(), o2.getIssue()))
              .forEach(
                  taskWithWorklogs -> {
                    // this task with worklogs contains at least one workitem
                    // having the group by criteria

                    DisplayRow ticketRowWithinThisGroup =
                        ticketIdToDisplayRow.get(taskWithWorklogs.getIssue());
                    if (ticketRowWithinThisGroup == null) {
                      ticketRowWithinThisGroup = new DisplayRow();
                      ticketRowWithinThisGroup.setLabel(taskWithWorklogs.getSummary());
                      ticketRowWithinThisGroup.setIssueId(taskWithWorklogs.getIssue());
                      ticketRowWithinThisGroup.setResolvedDate(taskWithWorklogs.getResolved());
                      groupRow.getChildren().add(new TreeItem<>(ticketRowWithinThisGroup));
                      ticketIdToDisplayRow.put(
                          taskWithWorklogs.getIssue(), ticketRowWithinThisGroup);
                    }

                    DisplayRow ticketRowWithinThisGroupAsFinal = ticketRowWithinThisGroup;

                    taskWithWorklogs
                        .getWorklogItemList()
                        .stream()
                        .filter(
                            worklogItem ->
                                StringUtils.equals(worklogItem.getGroup(), groupByCriteria))
                        .sorted((o1, o2) -> o1.getDate().compareTo(o2.getDate()))
                        .forEach(
                            worklogItem -> {
                              // this worklog item matches the critera
                              // add workday entry to current row
                              LocalDate date = worklogItem.getDate();

                              DisplayDayEntry workdayEntry =
                                  ticketRowWithinThisGroupAsFinal
                                      .getWorkdayEntry(date)
                                      .orElseGet(
                                          () -> {
                                            DisplayDayEntry displayDayEntry = new DisplayDayEntry();
                                            displayDayEntry.setDate(date);
                                            ticketRowWithinThisGroupAsFinal.addDisplayDayEntry(
                                                displayDayEntry);

                                            return displayDayEntry;
                                          });

                              workdayEntry
                                  .getSpentTime()
                                  .addAndGet(worklogItem.getDurationInMinutes());

                              // also add up the spent time in the group header per group
                              workdayEntry =
                                  groupCaptionRow
                                      .getWorkdayEntry(date)
                                      .orElseGet(
                                          () -> {
                                            DisplayDayEntry newWorkdayEntry = new DisplayDayEntry();
                                            newWorkdayEntry.setDate(date);
                                            groupCaptionRow.addDisplayDayEntry(newWorkdayEntry);
                                            return newWorkdayEntry;
                                          });
                              workdayEntry
                                  .getSpentTime()
                                  .addAndGet(worklogItem.getDurationInMinutes());
                            });
                  });

          // add groupRow to result
          displayData.addRow(groupRow);
        });
  }
  protected void refreshWorklogTableViewAndResults() {

    // return early if no data present or still the same data
    // as the last time this tab was active
    Optional<FetchTimereportContext> reportContextOptional = this.fetchTimereportContext;
    if (!reportContextOptional.isPresent()
        || !reportContextOptional.get().getResult().isPresent()
        || !resultToDisplayChangedSinceLastRender) {
      LOGGER.debug(
          "[{}] No results to display or data not changed. Not refreshing TableView and data",
          getText());
      return;
    }

    SettingsUtil.Settings settings = SettingsUtil.loadSettings();
    if (settings.isShowStatistics() && statisticsView == null
        || !settings.isShowStatistics() && statisticsView != null) {
      // statistics are disabled and were previously rendered
      // or statistics are enabled and weren't rendered before
      // update content view
      LOGGER.debug("Updating contentView since settings for statistics seemed to have changed");
      setContent(getContentNode());
    }

    FetchTimereportContext timereportContext = reportContextOptional.get();
    TimerangeProvider timerangeProvider = timereportContext.getTimerangeProvider();

    // render the table columns if the timerange changed from last result
    if (!lastUsedTimerangeProvider.isPresent()
        || !lastUsedTimerangeProvider.get().equals(timerangeProvider)
        || (lastCollapseState.isPresent() && lastCollapseState.get() != settings.getCollapseState())
        || (lastHighlightState.isPresent()
            && lastHighlightState.get() != settings.getHighlightState())) {

      LOGGER.debug(
          "[{}] Regenerating columns for timerange {}",
          getText(),
          timerangeProvider.getReportTimerange().name());
      taskTableView.getColumns().clear();
      taskTableView.getColumns().add(taskStatusTreeTableColumn);
      taskTableView.getColumns().add(taskDescriptionTreeTableColumn);

      // render tables for all days in the selected timerange
      // e.g. timerange current month renders a column for
      // each day of the current month
      long amountOfDaysToDisplay =
          ChronoUnit.DAYS.between(timerangeProvider.getStartDate(), timerangeProvider.getEndDate());

      for (int days = 0; days <= amountOfDaysToDisplay; days++) {
        LocalDate currentColumnDate = timerangeProvider.getStartDate().plus(days, ChronoUnit.DAYS);
        String displayDate = FormattingUtil.formatDate(currentColumnDate);

        // worklog column
        taskTableView.getColumns().add(new WorklogTreeTableColumn(displayDate, currentColumnDate));
      }

      // also add another summary per task column
      taskTableView.getColumns().add(new TaskWorklogSummaryTreeTableColumn());

      lastUsedTimerangeProvider = Optional.of(timerangeProvider);
      lastCollapseState = Optional.of(settings.getCollapseState());
      lastHighlightState = Optional.of(settings.getHighlightState());
    }

    // refresh data
    LOGGER.debug("[{}] Refreshing items in TableView", getText());

    TreeItem<DisplayRow> root = taskTableView.getRoot();
    root.getChildren().clear();

    DisplayData displayData =
        getDisplayData(timereportContext, resultToDisplayChangedSinceLastRender);
    root.getChildren().addAll(displayData.getTreeRows());

    resultToDisplayChangedSinceLastRender = false;
  }