コード例 #1
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;
  }
コード例 #2
0
 @Override
 public void setTargetProject(Project targetProject) {
   for (final Object o : getBulkEditBeans().values()) {
     BulkEditBean bulkEditBean = (BulkEditBean) o;
     bulkEditBean.setTargetProject(targetProject);
   }
 }
コード例 #3
0
 public String getMappingViewHtml(
     BulkEditBean bulkEditBean, OrderableField field, Long id, final boolean showProject) {
   final FieldLayoutItem fieldLayoutItem =
       bulkEditBean.getTargetFieldLayout().getFieldLayoutItem(field);
   final Issue baseIssue = bulkEditBean.getFirstTargetIssueObject();
   return getViewHtmlForId(baseIssue, fieldLayoutItem, field, id, showProject);
 }
コード例 #4
0
 public BulkEditBean getBulkEditBean() {
   final BulkEditBean bulkEditBean = getRootBulkEditBean();
   if (!isSubTaskPhase()) {
     return bulkEditBean;
   } else {
     return bulkEditBean != null ? bulkEditBean.getSubTaskBulkEditBean() : null;
   }
 }
コード例 #5
0
  public int getNumberOfStatusChangeRequired(BulkMoveOperation bulkMoveOperation) {
    int i = 0;
    for (final Object o : bulkEditBeans.values()) {
      BulkEditBean bulkEditBean = (BulkEditBean) o;
      if (bulkEditBean.getTargetPid() != null && !bulkMoveOperation.isStatusValid(bulkEditBean)) {
        i++;
      }
    }

    return i;
  }
コード例 #6
0
 public String getNewViewHtml(BulkEditBean bulkEditBean, OrderableField field) {
   final Map<String, Object> displayParameters =
       MapBuilder.<String, Object>newBuilder("readonly", Boolean.TRUE)
           .add("nolink", Boolean.TRUE)
           .add(
               "prefix",
               bulkEditBean.getProject().getString("id")
                   + "_"
                   + bulkEditBean.getIssueType().getString("id")
                   + "_")
           .toMap();
   return field.getViewHtml(
       bulkEditBean.getTargetFieldLayout().getFieldLayoutItem(field),
       this,
       bulkEditBean.getFirstTargetIssueObject(),
       displayParameters);
 }
コード例 #7
0
  // Verify selection of issues - parents or subtasks
  public String doDetails() {
    BulkEditBean bulkEditBean = getRootBulkEditBean();

    // Check that we have a BulkEditBean - i.e. the user got here by following the wizard - not by
    // clicking the "back" button of the browser (or something like that)
    if (bulkEditBean == null) {
      // If we do not have BulkEditBean, send the user to the first step of the wizard
      return redirectToStart();
    }

    // Reset the collection to contain only parent issues (subtasks can't be "moved" only migrated)
    resetIssueCollection(PARENT_SELECTION);

    bulkEditBean.resetMoveData();
    bulkEditBean.clearAvailablePreviousSteps();
    bulkEditBean.addAvailablePreviousStep(1);
    bulkEditBean.addAvailablePreviousStep(2);
    bulkEditBean.setCurrentStep(3);
    return INPUT;
  }
コード例 #8
0
 /**
  * Only invoked when displaying the Project and Issue type as part of the bulk move operation
  *
  * @return Field HTML
  */
 public String getFieldHtml(String fieldId, BulkEditBean bulkEditBean) {
   OrderableField orderableField = (OrderableField) fieldManager.getField(fieldId);
   return orderableField.getBulkEditHtml(
       bulkEditBean,
       this,
       bulkEditBean,
       EasyMap.build(
           OrderableField.NO_HEADER_PARAM_KEY,
           Boolean.TRUE,
           "fieldNamePrefix",
           bulkEditBean.getKey()));
 }
コード例 #9
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);
  }
コード例 #10
0
  /**
   * Adds to the given velocity parameters using the given fieldValuesHolder and fieldLayoutItem (to
   * determine the renderer).
   *
   * @param fieldLayoutItem the FieldLayoutItem in play
   * @param fieldValuesHolder the fields values holder in play
   * @param velocityParams the velocity parameters to which values will be added
   */
  private void populateVelocityParams(
      FieldLayoutItem fieldLayoutItem, Map fieldValuesHolder, Map<String, Object> velocityParams) {
    if (fieldValuesHolder != null) {
      Map commentParams = (Map) fieldValuesHolder.get(getId());
      if (commentParams != null) {
        velocityParams.put(getId(), commentParams.get(getId()));
      }
    }

    velocityParams.put("rendererParams", new HashMap());
    String rendererType = (fieldLayoutItem != null) ? fieldLayoutItem.getRendererType() : null;
    velocityParams.put(
        "rendererDescriptor", rendererManager.getRendererForType(rendererType).getDescriptor());
    velocityParams.put("groupLevels", getGroupLevels());
    velocityParams.put(
        "mentionable", mentionService.isUserAbleToMention(authenticationContext.getLoggedInUser()));

    Issue issue = (Issue) velocityParams.get("issue");
    if (issue != null) {
      velocityParams.put("roleLevels", getRoleLevels(issue));
    } else {
      // We are possibly in a bulk screen
      Object action = velocityParams.get("action");
      if (action != null && action instanceof BulkWorkflowTransition) {
        BulkWorkflowTransition bulkWorkflowTransition = (BulkWorkflowTransition) action;
        BulkEditBean bulkEditBean = bulkWorkflowTransition.getBulkEditBean();
        if (bulkEditBean != null) {
          // TODO: what if there are multiple projects? We should get the intersection of all roles.
          GenericValue project = bulkEditBean.getProject();
          if (project != null) {
            velocityParams.put("roleLevels", getRoleLevels(project));
          }
        }
      }
    }
  }
コード例 #11
0
  /**
   * Initialises this MultiBulkMoveBean given a list of issues.
   *
   * <p>If this MultiBulkMoveBean links a BulkEditBean with parent issues to BulkEditBeans with
   * subtasks, then include the parent BulkEditBean in the parentBulkEditBean parameter. Otherwise
   * you can pass null.
   *
   * @param issues Issues for this MultiBulkMoveBean.
   * @param parentBulkEditBean If this MultiBulkMoveBean represents subtasks, then this is the
   *     BulkEditBean that contains the parents of the subtasks, otherwise null.
   */
  public void initFromIssues(List issues, BulkEditBean parentBulkEditBean) {
    // Ensure that the order is kept
    issuesInContext = (ListOrderedMap) ListOrderedMap.decorate(new MultiHashMap());
    regularIssues = new ListOrderedMap();
    subTaskIssues = new ArrayList<Issue>();

    // First pass stores att the
    for (final Object issue2 : issues) {
      MutableIssue issue = (MutableIssue) issue2;
      if (!issue.isSubTask()) {
        regularIssues.put(issue.getId(), issue);
      } else {
        subTaskIssues.add(issue);
      }
    }

    // Split it up by context, also check special rule that you can't move sub tasks & its parent
    // all in the same go
    for (final Object issue1 : issues) {
      MutableIssue issue = (MutableIssue) issue1;
      // NOTE: we only do this for the bulk move operation, this is likely the correct behavior for
      // the
      // bulk move operation but I am certain that it is not correct for the bulk migrate operation
      // JRA-10244.
      // In bulk move the wizard will prompt the user with subtask information once it has collected
      // the project
      // information about the parent issues, this is not need in the the issue type scheme
      // migration since you
      // will never be changing the project
      // TODO: Why test for operation name?
      if (BulkMigrateOperation.OPERATION_NAME.equals(operationName)
          && issue.isSubTask()
          && regularIssues.containsKey(issue.getParentId())) {
        log.info(
            "Sub issue: "
                + issue.getKey()
                + " : discarded since parent was also present in the bulk move");
        subTasksDiscarded++;
      } else {
        issuesInContext.put(
            new IssueContextImpl(issue.getProjectObject(), issue.getIssueTypeObject()), issue);
      }
    }

    // Set the bulk edit bean.. sort the keys by project
    bulkEditBeans = new ListOrderedMap();
    List keys = new ArrayList(issuesInContext.keySet());
    Collections.sort(keys);

    for (final Object key : keys) {
      IssueContext context = (IssueContext) key;
      Collection issuesForContext = (Collection) issuesInContext.get(context);

      BulkEditBean bulkEditBean = new BulkEditBeanImpl(issueManager);
      bulkEditBean.initSelectedIssues(issuesForContext);
      bulkEditBean.setOperationName(operationName);
      bulkEditBean.setTargetProject(context.getProjectObject());
      bulkEditBean.setTargetIssueTypeId(
          context.getIssueTypeObject() != null ? context.getIssueTypeObject().getId() : null);
      // Set the Parent BulkEditBean - used by subtask BulkEditBean's to get to the new version of
      // the subtask's parents.
      bulkEditBean.setParentBulkEditBean(parentBulkEditBean);

      bulkEditBeans.put(context, bulkEditBean);
    }
  }
コード例 #12
0
 public boolean isAllowProjectEdit(BulkEditBean bulkEditBean) {
   return !bulkEditBean.isSubTaskCollection();
 }
コード例 #13
0
 public Map<Long, Long> getSubstitutionsForField(BulkEditBean bulkEditBean, OrderableField field) {
   return bulkEditBean.getFieldSubstitutionMap().get(field.getId());
 }
コード例 #14
0
 public boolean isFieldUsingSubstitutions(BulkEditBean bulkEditBean, OrderableField field) {
   final Map<Long, Long> substitutions = bulkEditBean.getFieldSubstitutionMap().get(field.getId());
   return substitutions != null;
 }