private TagDefinitionModelDao getTagDefinitionFromTransaction(final UUID tagDefinitionId, final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final InternalTenantContext context) throws TagApiException { TagDefinitionModelDao tagDefintion = SystemTags.lookup(tagDefinitionId); if (tagDefintion == null) { final TagDefinitionSqlDao transTagDefintionSqlDao = entitySqlDaoWrapperFactory.become(TagDefinitionSqlDao.class); tagDefintion = transTagDefintionSqlDao.getById(tagDefinitionId.toString(), context); } if (tagDefintion == null) { throw new TagApiException(ErrorCode.TAG_DEFINITION_DOES_NOT_EXIST, tagDefinitionId); } return tagDefintion; }
@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 public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { final TagDefinitionSqlDao tagDefinitionSqlDao = entitySqlDaoWrapperFactory.become(TagDefinitionSqlDao.class); // Make sure the tag definition exists final TagDefinitionModelDao tagDefinition = tagDefinitionSqlDao.getById(definitionId.toString(), context); if (tagDefinition == null) { throw new TagDefinitionApiException(ErrorCode.TAG_DEFINITION_DOES_NOT_EXIST, definitionId); } // Make sure it is not used currently if (tagDefinitionSqlDao.tagDefinitionUsageCount(definitionId.toString(), context) > 0) { throw new TagDefinitionApiException(ErrorCode.TAG_DEFINITION_IN_USE, definitionId); } // Delete it tagDefinitionSqlDao.markTagDefinitionAsDeleted(definitionId.toString(), context); postBusEventFromTransaction(tagDefinition, tagDefinition, ChangeType.DELETE, entitySqlDaoWrapperFactory, context); return null; } });
private TagDefinitionModelDao getTagDefinitionFromTransaction(final UUID tagDefinitionId, final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final InternalTenantContext context) throws TagApiException { TagDefinitionModelDao tagDefintion = SystemTags.lookup(tagDefinitionId); if (tagDefintion == null) { final TagDefinitionSqlDao transTagDefintionSqlDao = entitySqlDaoWrapperFactory.become(TagDefinitionSqlDao.class); tagDefintion = transTagDefintionSqlDao.getById(tagDefinitionId.toString(), context); } if (tagDefintion == null) { throw new TagApiException(ErrorCode.TAG_DEFINITION_DOES_NOT_EXIST, tagDefinitionId); } return tagDefintion; }
@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 public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { final TagDefinitionSqlDao tagDefinitionSqlDao = entitySqlDaoWrapperFactory.become(TagDefinitionSqlDao.class); // Make sure the tag definition exists final TagDefinitionModelDao tagDefinition = tagDefinitionSqlDao.getById(definitionId.toString(), context); if (tagDefinition == null) { throw new TagDefinitionApiException(ErrorCode.TAG_DEFINITION_DOES_NOT_EXIST, definitionId); } // Make sure it is not used currently if (tagDefinitionSqlDao.tagDefinitionUsageCount(definitionId.toString(), context) > 0) { throw new TagDefinitionApiException(ErrorCode.TAG_DEFINITION_IN_USE, definitionId); } // Delete it tagDefinitionSqlDao.markTagDefinitionAsDeleted(definitionId.toString(), context); postBusEventFromTransaction(tagDefinition, tagDefinition, ChangeType.DELETE, entitySqlDaoWrapperFactory, context); return null; } });