@Override public boolean apply(final TagModelDao input) { return input.getObjectType() == objectType; } }));
@Override public void removeTag(final UUID objectId, final ObjectType objectType, final UUID tagDefinitionId, final InternalCallContext context) throws TagApiException { tagDao.deleteTag(objectId, objectType, tagDefinitionId, context); }
@Override public void create(final TagModelDao entity, final InternalCallContext context) throws TagApiException { validateApplicableObjectTypes(entity.getTagDefinitionId(), entity.getObjectType()); transactionalSqlDao.execute(false, TagApiException.class, getCreateEntitySqlDaoTransactionWrapper(entity, context)); }
@Override public TagDefinition getTagDefinition(final UUID tagDefinitionId, final TenantContext context) throws TagDefinitionApiException { final TagDefinitionModelDao tagDefinitionModelDao = tagDefinitionDao.getById(tagDefinitionId, internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(context)); return new DefaultTagDefinition(tagDefinitionModelDao, TagModelDaoHelper.isControlTag(tagDefinitionModelDao.getName())); }
@Override public TagDefinition apply(final TagDefinitionModelDao input) { return new DefaultTagDefinition(input, TagModelDaoHelper.isControlTag(input.getName())); } }));
@Override public boolean apply(final TagDefinitionModelDao input) { return input.getId().equals(tagDefinitionId); } });
@Override public TagDefinition getTagDefinitionForName(final String tagDefinitionName, final TenantContext context) throws TagDefinitionApiException { return new DefaultTagDefinition(tagDefinitionDao.getByName(tagDefinitionName, internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(context)), TagModelDaoHelper.isControlTag(tagDefinitionName)); }
@Override public List<TagModelDao> inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { final TagSqlDao tagSqlDao = entitySqlDaoWrapperFactory.become(TagSqlDao.class); if (includedDeleted) { return tagSqlDao.getTagsForObjectIncludedDeleted(objectId, objectType, internalTenantContext); } else { return tagSqlDao.getTagsForObject(objectId, objectType, internalTenantContext); } } });
@Override public List<TagModelDao> inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { final TagSqlDao tagSqlDao = entitySqlDaoWrapperFactory.become(TagSqlDao.class); if (includedDeleted) { return tagSqlDao.getByAccountRecordIdIncludedDeleted(internalTenantContext); } else { return tagSqlDao.getByAccountRecordId(internalTenantContext); } } });
@Override public TagDefinitionModelDao inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { final TagDefinitionModelDao systemTag = SystemTags.lookup(definitionName); final TagDefinitionModelDao tag = systemTag != null ? systemTag : entitySqlDaoWrapperFactory.become(TagDefinitionSqlDao.class).getByName(definitionName, context); if (tag == null) { throw new TagDefinitionApiException(ErrorCode.TAG_DEFINITION_DOES_NOT_EXIST, definitionName); } return tag; } });
@Override public TagDefinitionModelDao inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { final TagDefinitionModelDao systemTag = SystemTags.lookup(definitionId); final TagDefinitionModelDao tag = systemTag != null ? systemTag : entitySqlDaoWrapperFactory.become(TagDefinitionSqlDao.class).getById(definitionId.toString(), context); if (tag == null) { throw new TagDefinitionApiException(ErrorCode.TAG_DEFINITION_DOES_NOT_EXIST, definitionId); } return tag; } });
@Override protected TagApiException generateAlreadyExistsException(final TagModelDao entity, final InternalCallContext context) { // Print the tag details, not the id here, as we throw this exception when checking if a tag already exists // by using the isSame(TagModelDao) method (see above) return new TagApiException(ErrorCode.TAG_ALREADY_EXISTS, entity.toString()); }
@Override public Pagination<TagModelDao> build() { return tagDao.searchTags(searchKey, offset, limit, internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(context)); } },
@Override public Pagination<TagModelDao> build() { return tagDao.get(offset, limit, internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(context)); } },
@Override public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { entitySqlDaoWrapperFactory.become(TagSqlDao.class).create(modelDao, internalCallContext); return null; } });
@Override public TagDefinition apply(final TagDefinitionModelDao input) { return new DefaultTagDefinition(input, TagModelDaoHelper.isControlTag(input.getName())); } }));
@Override public boolean apply(final TagModelDao input) { return objectType.equals(input.getObjectType()); } }));
@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 TagDefinition apply(final TagDefinitionModelDao input) { return new DefaultTagDefinition(input, TagModelDaoHelper.isControlTag(input.getName())); } }));