Exemplo n.º 1
0
  /**
   * This method will remap the current {@link BulkEditBean} Map to be keyed by the <em>target</em>
   * {@link IssueContext} rather than the originating {@link IssueContext}.
   */
  public void remapBulkEditBeansByTargetContext() {
    Map bulkEditBeans = getBulkEditBeans();
    ListOrderedMap targetKeyedBulkEditBeans = new ListOrderedMap();
    Set entries = bulkEditBeans.entrySet();
    for (final Object entry1 : entries) {
      Map.Entry entry = (Map.Entry) entry1;
      BulkEditBean bulkEditBean = (BulkEditBean) entry.getValue();

      // Build Target Issue contexts
      IssueContext targetIssueContext =
          new IssueContextImpl(
              bulkEditBean.getTargetProject(), bulkEditBean.getTargetIssueTypeObject());

      if (targetKeyedBulkEditBeans.containsKey(targetIssueContext)) {
        // Add to to the bulk edit bean
        BulkEditBean finalBulkEditBean =
            (BulkEditBean) targetKeyedBulkEditBeans.get(targetIssueContext);
        // We add the top-level issues now. Affected subtasks will be calculated later
        // by calling BulkMoveOperation().finishChooseContext()
        finalBulkEditBean.addIssues(bulkEditBean.getSelectedIssues());
      } else {
        targetKeyedBulkEditBeans.put(targetIssueContext, bulkEditBean);
      }
    }

    // Set the BulkEditBean Map to our new map (keyed by Target Context)
    setBulkEditBeans(targetKeyedBulkEditBeans);
  }
Exemplo n.º 2
0
  public String availableForBulkEdit(BulkEditBean bulkEditBean) {
    String rendererType = null;

    // Ensure that this field is not hidden in any Field Layouts the selected issues belong to
    for (FieldLayout fieldLayout : bulkEditBean.getFieldLayouts()) {
      if (fieldLayout.isFieldHidden(getId())) {
        return "bulk.edit.unavailable.hidden";
      }

      // Check for different renderer type
      if (StringUtils.isBlank(rendererType)) {
        rendererType = fieldLayout.getRendererTypeForField(IssueFieldConstants.COMMENT);
      } else if (!rendererType.equals(
          fieldLayout.getRendererTypeForField(IssueFieldConstants.COMMENT))) {
        return "bulk.edit.unavailable.different.renderers";
      }
    }

    // If we got here then the field is visible in all field layouts
    // So check for permissions
    // Have to loop through all the issues incase the permission has been granted to current
    // assignee/reporter (i.e. assigned to a role)
    for (Issue issue : bulkEditBean.getSelectedIssues()) {
      if (!isShown(issue)) {
        return "bulk.edit.unavailable.permission";
      }
    }

    // This field is available for bulk-editing, return null (i.e no unavailble message)
    return null;
  }