public Set<Label> getLabels() { if (labels == null) { if (genericValue != null) { labels = labelManager.getLabels(getId()); } else { labels = Collections.emptySet(); } } return labels; }
@Override public Set<Label> getValueFromIssue(CustomField field, Issue issue) { final Set<Label> labels = labelManager.getLabels(issue.getId(), field.getIdAsLong()); // We should return null if there are no labels. if (labels.isEmpty()) { return null; } return labels; }
public String getEditHtml(final FieldLayoutItem fieldLayoutItem, final OperationContext operationContext, final Action action, final Issue issue, final Map displayParameters) { Map<String, Object> velocityParams = getVelocityParams(fieldLayoutItem, action, issue, displayParameters); final Map fieldValuesHolder = operationContext.getFieldValuesHolder(); if (fieldValuesHolder.containsKey(getId())) { velocityParams.put("labels", fieldValuesHolder.get(getId())); } else if (!(issue == null || issue.getId() == null)) { // Values to edit weren't passed in the action, e.g., bulk edit. velocityParams.put("labels", labelManager.getLabels(issue.getId())); } return renderTemplate("labels-edit.vm", velocityParams); }
@Override public LabelsResult getLabels(final ApplicationUser user, final Long issueId) { notNull("issueId", issueId); final ErrorCollection errorCollection = validateBrowseIssuePermission(user, issueId); if (errorCollection.hasAnyErrors()) { return new LabelsResult(Collections.<Label>emptySet(), errorCollection); } return new LabelsResult(labelManager.getLabels(issueId), new SimpleErrorCollection()); }
@Override public LabelsResult getLabels(final ApplicationUser user, final Long issueId, final Long customFieldId) { notNull("issueId", issueId); notNull("customFieldId", customFieldId); final ErrorCollection errorCollection = validateBrowseIssuePermission(user, issueId); final CustomField field = customFieldManager.getCustomFieldObject(customFieldId); if (field == null) { final I18nHelper i18n = beanFactory.getInstance(user); errorCollection.addErrorMessage(i18n.getText("label.service.error.custom.field.doesnt.exist", customFieldId)); } if (errorCollection.hasAnyErrors()) { return new LabelsResult(Collections.<Label>emptySet(), errorCollection); } return new LabelsResult(labelManager.getLabels(issueId, customFieldId), new SimpleErrorCollection()); }