public T getValueFromCustomFieldParams(CustomFieldParams parameters) throws FieldValidationException { Object o = parameters.getFirstValueForKey(null); // This method mandates that it cannot be a collection object. To provide backwards compatability I have assumed T == S. // If not it will break at run time. And hopefully plugin developers will see it. I'm assuming the method doesn't get used though, cause surely it would have broken before now // ParticipantsCustomField is an example of one which is actually a collection. return (T) getSingularObjectFromString((String) o); }
/** * Retrieve the first value of the given param key and convert it to a Long object if it's a valid long in String format. * @return the parsed Long object, or null if invalid */ private Long getLongFromParamsByKey(final CustomFieldParams relevantParams, final String key) { final Object obj = relevantParams.getFirstValueForKey(key); if (obj != null && obj instanceof String) { final long parsedLong = NumberUtils.toLong(obj.toString(), -1); if (parsedLong != -1) { return parsedLong; } } return null; }
if (customFieldParams.containsKey(NumberRangeSearcher.LESS_THAN_PARAM)) String s = (String) customFieldParams.getFirstValueForKey(NumberRangeSearcher.LESS_THAN_PARAM); if (s != null) String s = (String) customFieldParams.getFirstValueForKey(NumberRangeSearcher.GREATER_THAN_PARAM); if (s != null)
private CustomFieldParams handleInvalidFunctionOperand(final TerminalClause clause) { CustomFieldParams customFieldParams = null; FunctionOperand fop = (FunctionOperand)clause.getOperand(); if (fop.getName().equals(CascadeOptionFunction.FUNCTION_CASCADE_OPTION)) { if (fop.getArgs().size() == 2) { customFieldParams = new CustomFieldParamsImpl(customField); customFieldParams.put(CascadingSelectCFType.PARENT_KEY, Collections.singleton(fop.getArgs().get(0))); customFieldParams.put(CascadingSelectCFType.CHILD_KEY, Collections.singleton(fop.getArgs().get(1))); } else if (fop.getArgs().size() == 1) { customFieldParams = new CustomFieldParamsImpl(customField); customFieldParams.put(CascadingSelectCFType.PARENT_KEY, Collections.singleton(fop.getArgs().get(0))); } if (customFieldParams != null) { String parentValue = (String) customFieldParams.getFirstValueForKey(CascadingSelectCFType.PARENT_KEY); final List<Option> options = jqlSelectOptionsUtil.getOptions(customField, new QueryLiteral(clause.getOperand(), parentValue), true); if (options.isEmpty() || options.get(0) == null) { return null; } } } return customFieldParams; }
@Override public void validateParams(final ApplicationUser user, final SearchContext searchContext, final FieldValuesHolder fieldValuesHolder, final I18nHelper i18nHelper, final ErrorCollection errors) { CustomFieldParams params = (CustomFieldParams) fieldValuesHolder.get(getCustomField().getId()); if (params != null) { String[] rangeParams = { NumberRangeSearcher.LESS_THAN_PARAM, NumberRangeSearcher.GREATER_THAN_PARAM}; for (String rangeParam : rangeParams) { final String numberString = (String) params.getFirstValueForKey(rangeParam); if (StringUtils.isNotEmpty(numberString)) { try { doubleConverter.getDouble(numberString); } catch (FieldValidationException e) { errors.addError(getCustomField().getId(), e.getMessage()); } } } } }
final Object requireProjectIds = relevantParams.getFirstValueForKey(CustomFieldUtils.getParamKeyRequireProjectIds()); if (requireProjectIds == null || !Boolean.parseBoolean(requireProjectIds.toString()))