Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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));
          }
        }
      }
    }
  }