public Label addLabel(final Long issueId, final Long customFieldId, final String label) { final CacheKey key = new CacheKey(issueId, customFieldId); try { return delegateStore.addLabel(issueId, customFieldId, label); } finally { cache.remove(key); } }
@Override public Set<Label> load(final CacheKey key) { return CachingLabelStore.this.delegateStore.getLabels(key.getIssueId(), key.getFieldId()); } }
public void removeLabel(final Long labelId, final Long issueId, final Long customFieldId) { final CacheKey key = new CacheKey(issueId, customFieldId); try { delegateStore.removeLabel(labelId, issueId, customFieldId); //clear the cache so that the next read will fix up the cache again. } finally { cache.remove(key); } }
public Set<Label> setLabels(final Long issueId, final Long customFieldId, final Set<String> labels) { notNull("issueId", issueId); notNull("labels", labels); //first remove all labels for the issue and customfield. ofBizDelegator.removeByAnd(TABLE, MapBuilder.<String, Object>newBuilder(). add(ISSUE_ID, issueId).add(CUSTOM_FIELD_ID, customFieldId).toMap()); final List<GenericValue> createdGvs = new ArrayList<GenericValue>(); for (String label : labels) { if (StringUtils.isNotBlank(label)) { createdGvs.add(ofBizDelegator.createValue(TABLE, MapBuilder.<String, Object>newBuilder(). add(ISSUE_ID, issueId).add(CUSTOM_FIELD_ID, customFieldId). add(LABEL, StringUtils.trim(label)).toMap())); } else { log.error("Blank label cannot be stored!"); } } return getSortedLabelSet(createdGvs); }
public Set<Long> removeLabelsForCustomField(final Long customFieldId) { try { return delegateStore.removeLabelsForCustomField(customFieldId); } finally { //not properly synchronized, but this should only be called very rarely! Clear the entire //cache to ensure no stale entries for custom fields are left. cache.removeAll(); } }
public Set<Label> setLabels(final Long issueId, final Long customFieldId, final Set<String> labels) { final CacheKey key = new CacheKey(issueId, customFieldId); try { return delegateStore.setLabels(issueId, customFieldId, labels); } finally { cache.remove(key); } }
public Set<Label> getLabels(final Long issueId, final Long customFieldId) { notNull("issueId", issueId); final List<GenericValue> labelGvs = ofBizDelegator.findByAnd(TABLE, MapBuilder.<String, Object>newBuilder(). add(ISSUE_ID, issueId). add(CUSTOM_FIELD_ID, customFieldId).toMap()); return getSortedLabelSet(labelGvs); }