@Override public List<Tag> getTagsForAccount( final UUID accountId, final boolean includedDeleted, final TenantContext context) { return withModelTransform( tagDao.getTagsForAccount( includedDeleted, internalCallContextFactory.createInternalTenantContext(accountId, context))); }
@Override public List<Tag> getTagsForObject( final UUID objectId, final ObjectType objectType, final boolean includedDeleted, final TenantContext context) { return withModelTransform( tagDao.getTagsForObject( objectId, objectType, includedDeleted, internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(context))); }
@Override public void removeTag( final UUID objectId, final ObjectType objectType, final UUID tagDefinitionId, final CallContext context) throws TagApiException { tagDao.deleteTag( objectId, objectType, tagDefinitionId, internalCallContextFactory.createInternalCallContext(objectId, objectType, context)); }
@Override public void removeTags( final UUID objectId, final ObjectType objectType, final Collection<UUID> tagDefinitionIds, final CallContext context) throws TagApiException { // TODO: consider making this batch for (final UUID tagDefinitionId : tagDefinitionIds) { tagDao.deleteTag( objectId, objectType, tagDefinitionId, internalCallContextFactory.createInternalCallContext(objectId, objectType, context)); } }
@Override public void addTag( final UUID objectId, final ObjectType objectType, final UUID tagDefinitionId, final CallContext context) throws TagApiException { final InternalCallContext internalContext = internalCallContextFactory.createInternalCallContext(objectId, objectType, context); final TagModelDao tag = new TagModelDao(context.getCreatedDate(), tagDefinitionId, objectId, objectType); try { tagDao.create(tag, internalContext); } catch (TagApiException e) { // Be lenient here and make the addTag method idempotent if (ErrorCode.TAG_ALREADY_EXISTS.getCode() != e.getCode()) { throw e; } } }