Ejemplo n.º 1
0
 /**
  * Get user specified by the Custom Field
  *
  * @param ctx permission context
  * @param customFieldId eg. 'customfield_10000'
  * @return the set of users stored in the given custom field in the given context; an empty set is
  *     returned if the context could not provide values (i.e. there was no issue specified).
  */
 @Override
 public Set<User> getUsers(PermissionContext ctx, String customFieldId) {
   // JRA-15063: just return EMPTY SET (like GroupCF does) because throwing an
   // IllegalArgumentException is unnecessary.
   if (ctx.getIssue() == null) {
     log.debug(
         "Could not retrieve users for UserCF '"
             + customFieldId
             + "' since provided PermissionContext has no issue.");
     return Collections.emptySet();
   }
   Issue issue = ctx.getIssue();
   FieldManager fieldManager = getFieldManager();
   CustomField field = fieldManager.getCustomField(customFieldId);
   return convertToUserSet(getValuesFromIssue(field, issue));
 }
Ejemplo n.º 2
0
 boolean isDateTypeField(Field field) {
   if (fieldManager.isCustomField(field)) {
     final CustomFieldType customFieldType = ((CustomField) field).getCustomFieldType();
     return customFieldType instanceof DateField;
   } else {
     return field instanceof DateField;
   }
 }
  private void noProblems() throws Exception {
    resetMocks();
    ctrlFieldManager.expectAndReturn(mockFieldManager.isOrderableField("customfield_1"), true);

    replayMocks();

    List amendments = flCheck.preview();
    assertEquals(0, amendments.size());

    verifyMocks();
  }
Ejemplo n.º 4
0
  public boolean doValidation(String key, Map parameters) {
    String value = (String) parameters.get(key);
    if (value == null || value.length() == 0) return false;

    try {
      fieldManager.getCustomField(value);
    } catch (IllegalArgumentException ex) {
      return false;
    }
    return true;
  }
Ejemplo n.º 5
0
  public List<Field> getDisplayFields() {
    FieldManager fieldManager = getFieldManager();
    Set<NavigableField> fieldSet;
    try {
      fieldSet = fieldManager.getAllAvailableNavigableFields();
    } catch (FieldException e) {
      return Collections.emptyList();
    }

    final List<Field> fields = new ArrayList<Field>();
    for (Field field : fieldSet) {
      if (fieldManager.isCustomField(field)) {
        final CustomFieldType<?, ?> type = ((CustomField) field).getCustomFieldType();
        if (type instanceof UserCFType || type instanceof MultiUserCFType) {
          fields.add(field);
        }
      }
    }
    return fields;
  }
  protected void setUp() throws Exception {
    super.setUp();
    CoreTransactionUtil.setUseTransactions(false);
    setUpMocks();

    ctrlFieldManager.expectAndReturn(mockFieldManager.isOrderableField("customfield_1"), true);
    ctrlFieldManager.expectAndReturn(mockFieldManager.isOrderableField("customfield_2"), false);
    ctrlFieldManager.expectAndReturn(mockFieldManager.isOrderableField("customfield_3"), false);

    replayMocks();

    UtilsForTests.getTestEntity(
        "FieldLayoutItem", EasyMap.build("id", new Long(1001), "fieldidentifier", "customfield_1"));
    UtilsForTests.getTestEntity(
        "FieldLayoutItem", EasyMap.build("id", new Long(1002), "fieldidentifier", "customfield_2"));
    UtilsForTests.getTestEntity(
        "FieldLayoutItem", EasyMap.build("id", new Long(1003), "fieldidentifier", "customfield_3"));

    flCheck = new FieldLayoutCheck(ofBizDelegator, 1);
    flCheck.setFieldManager(mockFieldManager);
  }
Ejemplo n.º 7
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()));
 }
Ejemplo n.º 8
0
  // Determine whether there are available target subtasks
  public boolean isSubTaskTypesAvailable() {
    IssueTypeSystemField issueTypeField =
        (IssueTypeSystemField) fieldManager.getField(IssueFieldConstants.ISSUE_TYPE);
    Collection selectedIssues = getBulkEditBean().getSelectedIssues();
    Collection selectedSubTasks = new ArrayList();

    for (Iterator iterator = selectedIssues.iterator(); iterator.hasNext(); ) {
      Issue issue = (Issue) iterator.next();
      if (issue.isSubTask()) {
        selectedSubTasks.add(issue);
      }
    }
    return !issueTypeField.isHasCommonIssueTypes(selectedSubTasks);
  }
Ejemplo n.º 9
0
 Field validateDateField(String fieldId, Collection<ValidationError> errors) {
   final Field field = fieldManager.getField(fieldId);
   if (field == null) {
     final ValidationError error =
         new ValidationError(DAYS, "gadget.time.since.invalid.date.field", fieldId);
     errors.add(error);
   } else {
     if (!isDateTypeField(field)) {
       final List<String> params = Arrays.asList(fieldId, field.getName());
       final ValidationError error =
           new ValidationError(DAYS, "gadget.time.since.not.date.field", params);
       errors.add(error);
     }
   }
   return field;
 }
Ejemplo n.º 10
0
 public boolean isIssueTypesAvailable() {
   IssueTypeSystemField issueTypeField =
       (IssueTypeSystemField) fieldManager.getField(IssueFieldConstants.ISSUE_TYPE);
   return !issueTypeField.isHasCommonIssueTypes(getBulkEditBean().getSelectedIssues());
 }
Ejemplo n.º 11
0
 public String getArgumentDisplay(String argument) {
   CustomField field = fieldManager.getCustomField(argument);
   return field.getName();
 }