public String get(final IssueConstant input) { return input.getName(); } };
@Override public int compare(IssueConstant o1, IssueConstant o2) { if (o1 == null && o2 == null) { return 0; } else if (o2 == null) // any value is less than null { return -1; } else if (o1 == null) // null is greater than any value { return 1; } String name1 = o1.getName(); String name2 = o2.getName(); if (name1 == null && name2 == null) { return 0; } else if (name2 == null) // any value is less than null { return -1; } else if (name1 == null) // null is greater than any value { return 1; } return name1.compareToIgnoreCase(name2); } };
/** * For a Collection of Generic Values, return the one that has * <code>genericValue.getString("name")</code> equal to <code>name</code> */ protected static IssueConstant getIssueConstantByName(final Collection<? extends IssueConstant> values, String name) { for (final IssueConstant value : values) { if (name.equalsIgnoreCase(value.getName())) { return value; } } return null; }
public String get(final IssueConstant input) { return quoteName(input.getName()); } };
@Override public void appendNonNullItem(IssueConstant value, JqlClauseBuilder clauseBuilder) { clauseBuilder.addStringCondition(issueFieldConstant, EQUALS, value.getName()); }
public IssueConstant getIssueConstantByName(String constantType, String name) { ConstantsCache<? extends IssueConstant> constantsCache = getConstantsCache(constantType); for (IssueConstant issueConstant : constantsCache.getObjects()) { // TODO: Do we really allow null names? if (name == null) { if (issueConstant.getName() == null) return issueConstant; } else { if (name.equals(issueConstant.getName())) { return issueConstant; } } } // Not Found return null; }
private String handleIssueConstantField(final OrderableField orderableField, final String fieldValue) { final IssueConstant value = (IssueConstant) orderableField.getValueFromParams(ImmutableMap.of(orderableField.getId(), fieldValue)); if (value != null) { return value.getName(); } return fieldValue; }
public IssueConstant getConstantByNameIgnoreCase(final String constantType, final String name) { ConstantsCache<? extends IssueConstant> constantsCache = getConstantsCache(constantType); for (IssueConstant issueConstant : constantsCache.getObjects()) { // TODO: Do we really allow null names? if (name == null) { if (issueConstant.getName() == null) return issueConstant; } else { if (name.equalsIgnoreCase(issueConstant.getName())) { return issueConstant; } } } // Not Found return null; }
private boolean valueOnIssueConstantIsTheDefault(IssueConstant issueConstant, boolean name) { I18nHelper defaultI18n = beanFactory.getInstance(Locale.ROOT); String key = getI18NTranslationKey(issueConstant, name); String defaultValue = defaultI18n.getResourceBundle().containsKey(key) ? defaultI18n.getResourceBundle().getString(key) : null; if (name) { return issueConstant.getName() != null && issueConstant.getName().equals(defaultValue); } return issueConstant.getDescription() != null && issueConstant.getDescription().equals(defaultValue); }
private String getI18NTranslationKey(IssueConstant issueConstant, boolean name) { String translationPrefix = getTranslationPrefix(issueConstant); return translationPrefix + "." + makeNameIntoProperty(issueConstant.getName()) + "." + (name ? "name" : "desc"); }
private String getTranslationFromI18nResources(IssueConstant issueConstant, I18nHelper i18n, boolean name) { if (i18n == null) { i18n = authenticationContext.getI18nHelper(); } String key = getI18NTranslationKey(issueConstant, name); String translation = i18n.getText(key); if (translation != null && !translation.contains(key)) { return translation; } return name ? issueConstant.getName() : issueConstant.getDescription(); }
@Override protected SingleValueOperand createSingleValueOperandFromId(final String stringValue) { final long issueConstantId; try { issueConstantId = Long.parseLong(stringValue); } catch (NumberFormatException e) { return new SingleValueOperand(stringValue); } final IssueConstant issueConstant = issueConstantResolver.get(issueConstantId); if (issueConstant != null) { return new SingleValueOperand(issueConstant.getName()); } return new SingleValueOperand(issueConstantId); } }
protected void validateName() { if (isBlank(name)) { //NOTE-these translations mightn't work well in other languages :S addError("name", getText("admin.errors.must.specify.a.name.for.the.to.be.added",getNiceConstantName())); } else { for (T constant : getConstants()) { if (name.trim().equalsIgnoreCase(constant.getName())) { addError("name", getText("admin.errors.constant.already.exists", getNiceConstantName())); break; } } } }
public AbstractRemoteConstant(IssueConstant gv) { super(gv.getId(), gv.getName()); this.description = gv.getDescription(); this.icon = gv.getIconUrl(); if (TextUtils.stringSet(icon) && !this.icon.startsWith("http://")) { this.icon = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL) + icon; } }
public String doDefault() throws Exception { final T constant = getConstant(); if (constant == null) { addErrorMessage(getText("admin.errors.no.id.set")); return Action.ERROR; } else { name = constant.getName(); description = constant.getDescription(); iconurl = constant.getIconUrl(); } return super.doDefault(); }
return name ? issueConstant.getName() : issueConstant.getDescription();
public SearchRequest getSearchUrlSuffix(final IssueConstant value, final SearchRequest searchRequest) { if (searchRequest == null) { return null; } else { final JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder(searchRequest.getQuery()); if (value != null) { final String searchValue = value.getName(); queryBuilder.where().defaultAnd().addStringCondition(getIssueFieldConstant(), Operator.EQUALS, searchValue); } else { //this is only really for 'resolution'. All other constants should never be null; queryBuilder.where().defaultAnd().addEmptyCondition(getIssueFieldConstant()); } return new SearchRequest(queryBuilder.buildQuery()); } }