@Override public String apply(Label from) { return from.getLabel(); } });
public Label create(String labelName) { return new Label(null, null, null, labelName); } }
@Override public String apply(Label from) { return from.getLabel(); } });
@Override public Object getValueFromLuceneField(String documentValue) { if (StringUtils.isEmpty(documentValue) || FieldIndexer.LABELS_NO_VALUE_INDEX_VALUE.equals(documentValue)) { return null; } else { return new Label(null, null, documentValue); } }
@Override public String apply(Label from) { return from.getLabel(); } }));
public Set<Label> getLabels() { @SuppressWarnings("unchecked") final List<String> fields = getMultipleValuesFromField(IssueFieldConstants.LABELS); final List<Label> labels = new ArrayList<Label>(); for (String field : fields) { labels.add(new Label(null, getId(), field)); } Collections.sort(labels, LabelComparator.INSTANCE); return Collections.unmodifiableSet(new LinkedHashSet<Label>(labels)); }
@Override public String getStringFromSingularObject(final Label singularObject) { if (singularObject == null) { return null; } return singularObject.getLabel(); }
@Override protected Object getRelevantParams(final Map<String, String[]> params) { String[] value = params.get(getId()); if (value != null && value.length > 0) { final Set<Label> labels = new LinkedHashSet<Label>(); for (String labelString : value) { labels.add(new Label(null, null, labelString)); } return labels; } else { return Collections.<Label>emptySet(); } }
public String apply(Label label) { return label.getLabel(); } }
public void populateParamsFromString(final Map<String, Object> fieldValuesHolder, final String stringValue, final Issue issue) throws FieldValidationException { final String[] labels = StringUtils.split(stringValue, SEPARATOR_CHAR); if(labels != null) { final Set<Label> labelSet = new LinkedHashSet<Label>(); for (String label : labels) { labelSet.add(new Label(null, issue.getId(), label)); } fieldValuesHolder.put(getId(), labelSet); } }
@Override public String get(final Label input) { return input.getLabel(); } }));
public String getViewHtml(final FieldLayoutItem fieldLayoutItem, final Action action, final Issue issue, final Object value, final Map displayParameters) { final Map<String, Object> velocityParameters = getVelocityParams(fieldLayoutItem, action, issue, displayParameters); velocityParameters.put("canEdit", Boolean.FALSE); Set<Label> labels = (value instanceof Set ? (Set<Label>)value : CollectionBuilder.<Label>newBuilder(new Label(null, issue.getId(), (String)value)).asHashSet() ); velocityParameters.put("labels", labels); velocityParameters.put("fieldId", "label"); velocityParameters.put("i18n", authenticationContext.getI18nHelper()); velocityParameters.put("labelUtil", getLabelUtil()); return renderTemplate("labels-view.vm", velocityParameters); }
@Override protected String convertToString(final Label value) { return value.getLabel(); }
public Label get(final GenericValue input) { return new Label(input.getLong(ID), input.getLong(ISSUE_ID), input.getLong(CUSTOM_FIELD_ID), input.getString(LABEL)); } }
public String apply(final Label from) { return from.getLabel(); } });
@Override public Label getSingularObjectFromString(final String string) throws FieldValidationException { if (string == null) { return null; } final int labelLength = StringUtils.length(string.trim()); if (LabelParser.isValidLabelName(string) && labelLength <= LabelParser.MAX_LABEL_LENGTH) { return new Label(null, null, string); } else { if (labelLength > LabelParser.MAX_LABEL_LENGTH) { throw new FieldValidationException(authContext.getI18nHelper().getText("label.service.error.label.toolong", string)); } else { throw new FieldValidationException(authContext.getI18nHelper().getText("label.service.error.label.invalid", string)); } } }
private boolean containsLabel(final String label, final Set<Label> labels) { for (Label issueLabel : labels) { if (issueLabel.getLabel().equals(label)) { return true; } } return false; }