Package com.atlassian.bamboo.repository
Class RepositoryDefinitionHibernateDao
- java.lang.Object
-
- org.springframework.dao.support.DaoSupport
-
- org.springframework.orm.hibernate5.support.HibernateDaoSupport
-
- com.atlassian.bamboo.persistence3.StatelessSessionHibernateDaoSupport
-
- com.atlassian.bamboo.persistence3.BambooHibernateObjectDao<T>
-
- com.atlassian.bamboo.persistence3.BambooHibernateVersionAwareObjectDao<E,R>
-
- com.atlassian.bamboo.persistence3.BambooHibernateVersionAwareObjectWithOidDao<RepositoryDataEntity,Object>
-
- com.atlassian.bamboo.repository.RepositoryDefinitionHibernateDao
-
- All Implemented Interfaces:
BambooObjectDao<RepositoryDataEntity>
,BambooObjectWithOidDao<RepositoryDataEntity>
,RepositoryDefinitionDao
,org.springframework.beans.factory.InitializingBean
public class RepositoryDefinitionHibernateDao extends BambooHibernateVersionAwareObjectWithOidDao<RepositoryDataEntity,Object> implements RepositoryDefinitionDao
-
-
Constructor Summary
Constructors Constructor Description RepositoryDefinitionHibernateDao(@NotNull TransactionAndHibernateTemplate bambooTransactionHibernateTemplate, @NotNull BambooOptimisticLockingSettings bambooOptimisticLockingSettings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
countAll()
long
countAllByParent(@Nullable Long parentId)
@NotNull Long
countAllProjectsRepositories()
Count project, non-deleted repositories.long
countRepositoriesByPluginKey(@NotNull String pluginKey)
long
countTopLevelGlobalRepositories()
Count global, non-deleted repositories without any parent repository.void
delete(@NotNull RepositoryDataEntity repositoryDataEntity)
Removes the given entity from the database@NotNull Collection<? extends RepositoryDataEntity>
findAll()
@NotNull List<RepositoryDataEntity>
findAll(boolean includeMarkedForDeletion)
@NotNull Collection<? extends RepositoryDataEntity>
findAll(int firstResult, int maxResults)
@NotNull Collection<? extends RepositoryDataEntity>
findAllByParent(@Nullable Long parentId, int firstResult, int maxResults)
@NotNull List<Long>
findAllProjectsIdsUsingProjectRepositories()
Get IDs of all projects which are using project repositories.@NotNull Set<Long>
findAllRepositoryIds()
@NotNull Set<Long>
findAllRepositoryIds(boolean includeMarkedForDeletion)
@NotNull Set<Long>
findAllTopLevelRepositoriesIds()
Get ids of all repositories that doesn't have parent repository (are either linked or are created on plan level)@Nullable RepositoryDataEntityImpl
findById(long id)
@Nullable RepositoryDataEntity
findLinkedRepositoryByName(@NotNull String name)
Find a linked repository by name;@Nullable RepositoryDataEntity
findProjectRepositoryByName(@NotNull String name, @NotNull Long projectId)
Find a project repository by name in project associated with given projectId.@NotNull List<RepositoryDataEntity>
findRepositoriesByPluginKey(@NotNull String pluginKey)
@NotNull List<RepositoryDataEntity>
findRepositoriesByPluginKey(@NotNull String pluginKey, int firstResult, int maxResults)
@NotNull List<RepositoryDataEntity>
getGlobalRepositoryDefinitions()
protected @NotNull Optional<VersioningSupplement<RepositoryDataEntity>>
getMainVersioningSupplement()
@Nullable BambooEntityOid
getMaxRepositoryOid(int serverKey)
Returns the maxBambooEntityOid
that's currently in use ofBambooEntityType.REPOSITORY
type, with the given server key.@NotNull Collection<RepositoryDataEntity>
getPrivateRepositoryDefinitionsByPlan(Plan plan)
@NotNull List<RepositoryDataEntity>
getProjectRepositoryDefinitions(Long projectId)
Get all project repositories associated with given projectId.@NotNull List<RepositoryDataEntity>
getTopLevelGlobalRepositories(int firstResult, int maxResults)
Return a list of global, non-deleted repositories without any parent repository.void
markForDeletionByParentId(long parentId)
Mark all direct children of repository with given id for deletion.void
markForDeletionByProjectId(long projectId)
Mark all project repositories with given projectId for deletion.void
removeRepositoryIfUnused(RepositoryDataEntity repositoryDataEntity)
void
removeUnusedRepositories()
void
save(@NotNull RepositoryDataEntity repositoryDataEntity)
Saves the given entity.-
Methods inherited from class com.atlassian.bamboo.persistence3.BambooHibernateVersionAwareObjectWithOidDao
findByOid
-
Methods inherited from class com.atlassian.bamboo.persistence3.BambooHibernateVersionAwareObjectDao
deleteAll, getRootVersioningSupplement, incrementMainVersion, incrementMainVersion, incrementRootVersion, incrementRootVersion, saveAll
-
Methods inherited from class com.atlassian.bamboo.persistence3.BambooHibernateObjectDao
convertSearchTermToLikeExpression, countAll, countWithRestriction, executeCountQuery, findAll, findById, merge
-
Methods inherited from class com.atlassian.bamboo.persistence3.StatelessSessionHibernateDaoSupport
getCacheAwareHibernateTemplate
-
Methods inherited from class org.springframework.orm.hibernate5.support.HibernateDaoSupport
checkDaoConfig, createHibernateTemplate, currentSession, getHibernateTemplate, getSessionFactory, setHibernateTemplate, setSessionFactory
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.bamboo.persistence3.BambooObjectDao
countAll, countWithRestriction, deleteAll, findAll, findById, merge, saveAll
-
Methods inherited from interface com.atlassian.bamboo.persistence3.BambooObjectWithOidDao
findByOid
-
-
-
-
Constructor Detail
-
RepositoryDefinitionHibernateDao
public RepositoryDefinitionHibernateDao(@NotNull @NotNull TransactionAndHibernateTemplate bambooTransactionHibernateTemplate, @NotNull @NotNull BambooOptimisticLockingSettings bambooOptimisticLockingSettings)
-
-
Method Detail
-
getMainVersioningSupplement
@NotNull protected @NotNull Optional<VersioningSupplement<RepositoryDataEntity>> getMainVersioningSupplement()
- Overrides:
getMainVersioningSupplement
in classBambooHibernateVersionAwareObjectDao<RepositoryDataEntity,Object>
-
findById
@Nullable public @Nullable RepositoryDataEntityImpl findById(long id)
- Specified by:
findById
in interfaceRepositoryDefinitionDao
-
findAll
@NotNull public @NotNull Collection<? extends RepositoryDataEntity> findAll()
- Specified by:
findAll
in interfaceRepositoryDefinitionDao
-
findAll
@NotNull public @NotNull Collection<? extends RepositoryDataEntity> findAll(int firstResult, int maxResults)
- Specified by:
findAll
in interfaceRepositoryDefinitionDao
-
findAllByParent
@NotNull public @NotNull Collection<? extends RepositoryDataEntity> findAllByParent(@Nullable @Nullable Long parentId, int firstResult, int maxResults)
- Specified by:
findAllByParent
in interfaceRepositoryDefinitionDao
-
countAll
public long countAll()
- Specified by:
countAll
in interfaceRepositoryDefinitionDao
-
countAllByParent
public long countAllByParent(@Nullable @Nullable Long parentId)
- Specified by:
countAllByParent
in interfaceRepositoryDefinitionDao
-
countTopLevelGlobalRepositories
public long countTopLevelGlobalRepositories()
Description copied from interface:RepositoryDefinitionDao
Count global, non-deleted repositories without any parent repository.- Specified by:
countTopLevelGlobalRepositories
in interfaceRepositoryDefinitionDao
-
getTopLevelGlobalRepositories
@NotNull public @NotNull List<RepositoryDataEntity> getTopLevelGlobalRepositories(int firstResult, int maxResults)
Description copied from interface:RepositoryDefinitionDao
Return a list of global, non-deleted repositories without any parent repository.- Specified by:
getTopLevelGlobalRepositories
in interfaceRepositoryDefinitionDao
-
countRepositoriesByPluginKey
public long countRepositoriesByPluginKey(@NotNull @NotNull String pluginKey)
-
findRepositoriesByPluginKey
@NotNull public @NotNull List<RepositoryDataEntity> findRepositoriesByPluginKey(@NotNull @NotNull String pluginKey)
- Specified by:
findRepositoriesByPluginKey
in interfaceRepositoryDefinitionDao
-
findRepositoriesByPluginKey
@NotNull public @NotNull List<RepositoryDataEntity> findRepositoriesByPluginKey(@NotNull @NotNull String pluginKey, int firstResult, int maxResults)
-
getGlobalRepositoryDefinitions
@NotNull public @NotNull List<RepositoryDataEntity> getGlobalRepositoryDefinitions()
- Specified by:
getGlobalRepositoryDefinitions
in interfaceRepositoryDefinitionDao
-
getProjectRepositoryDefinitions
@NotNull public @NotNull List<RepositoryDataEntity> getProjectRepositoryDefinitions(Long projectId)
Description copied from interface:RepositoryDefinitionDao
Get all project repositories associated with given projectId.- Specified by:
getProjectRepositoryDefinitions
in interfaceRepositoryDefinitionDao
- Returns:
- List of RepositoryDataEntity which are project repositories associated with given projectId
-
countAllProjectsRepositories
@NotNull public @NotNull Long countAllProjectsRepositories()
Description copied from interface:RepositoryDefinitionDao
Count project, non-deleted repositories.- Specified by:
countAllProjectsRepositories
in interfaceRepositoryDefinitionDao
-
findAllProjectsIdsUsingProjectRepositories
@NotNull public @NotNull List<Long> findAllProjectsIdsUsingProjectRepositories()
Description copied from interface:RepositoryDefinitionDao
Get IDs of all projects which are using project repositories.- Specified by:
findAllProjectsIdsUsingProjectRepositories
in interfaceRepositoryDefinitionDao
- Returns:
- a list of IDs of all projects which are using project repositories.
-
getPrivateRepositoryDefinitionsByPlan
@NotNull public @NotNull Collection<RepositoryDataEntity> getPrivateRepositoryDefinitionsByPlan(Plan plan)
- Specified by:
getPrivateRepositoryDefinitionsByPlan
in interfaceRepositoryDefinitionDao
-
removeRepositoryIfUnused
public void removeRepositoryIfUnused(RepositoryDataEntity repositoryDataEntity)
- Specified by:
removeRepositoryIfUnused
in interfaceRepositoryDefinitionDao
-
delete
public void delete(@NotNull @NotNull RepositoryDataEntity repositoryDataEntity)
Description copied from interface:BambooObjectDao
Removes the given entity from the database- Specified by:
delete
in interfaceBambooObjectDao<RepositoryDataEntity>
- Overrides:
delete
in classBambooHibernateVersionAwareObjectDao<RepositoryDataEntity,Object>
- Parameters:
repositoryDataEntity
- entity to be removed
-
save
public void save(@NotNull @NotNull RepositoryDataEntity repositoryDataEntity)
Description copied from interface:BambooObjectDao
Saves the given entity. If the entity implementation is an instance ofEntityObject
this method will: - updateEntityObject.getLastModificationDate()
- setEntityObject.getCreationDate()
if the object has not been saved- Specified by:
save
in interfaceBambooObjectDao<RepositoryDataEntity>
- Overrides:
save
in classBambooHibernateVersionAwareObjectDao<RepositoryDataEntity,Object>
- Parameters:
repositoryDataEntity
- entity to be saved
-
removeUnusedRepositories
public void removeUnusedRepositories()
- Specified by:
removeUnusedRepositories
in interfaceRepositoryDefinitionDao
-
findAllRepositoryIds
@NotNull public @NotNull Set<Long> findAllRepositoryIds()
- Specified by:
findAllRepositoryIds
in interfaceRepositoryDefinitionDao
-
findAllRepositoryIds
@NotNull public @NotNull Set<Long> findAllRepositoryIds(boolean includeMarkedForDeletion)
- Specified by:
findAllRepositoryIds
in interfaceRepositoryDefinitionDao
-
findAll
@NotNull public @NotNull List<RepositoryDataEntity> findAll(boolean includeMarkedForDeletion)
- Specified by:
findAll
in interfaceRepositoryDefinitionDao
-
findAllTopLevelRepositoriesIds
@NotNull public @NotNull Set<Long> findAllTopLevelRepositoriesIds()
Description copied from interface:RepositoryDefinitionDao
Get ids of all repositories that doesn't have parent repository (are either linked or are created on plan level)- Specified by:
findAllTopLevelRepositoriesIds
in interfaceRepositoryDefinitionDao
-
getMaxRepositoryOid
@Nullable public @Nullable BambooEntityOid getMaxRepositoryOid(int serverKey)
Description copied from interface:RepositoryDefinitionDao
Returns the maxBambooEntityOid
that's currently in use ofBambooEntityType.REPOSITORY
type, with the given server key. Returns null if no OIDs are in use of this type with the given server key.- Specified by:
getMaxRepositoryOid
in interfaceRepositoryDefinitionDao
-
findLinkedRepositoryByName
@Nullable public @Nullable RepositoryDataEntity findLinkedRepositoryByName(@NotNull @NotNull String name)
Description copied from interface:RepositoryDefinitionDao
Find a linked repository by name;- Specified by:
findLinkedRepositoryByName
in interfaceRepositoryDefinitionDao
- Returns:
-
markForDeletionByParentId
public void markForDeletionByParentId(long parentId)
Description copied from interface:RepositoryDefinitionDao
Mark all direct children of repository with given id for deletion.- Specified by:
markForDeletionByParentId
in interfaceRepositoryDefinitionDao
-
markForDeletionByProjectId
public void markForDeletionByProjectId(long projectId)
Description copied from interface:RepositoryDefinitionDao
Mark all project repositories with given projectId for deletion.- Specified by:
markForDeletionByProjectId
in interfaceRepositoryDefinitionDao
-
findProjectRepositoryByName
@Nullable public @Nullable RepositoryDataEntity findProjectRepositoryByName(@NotNull @NotNull String name, @NotNull @NotNull Long projectId)
Description copied from interface:RepositoryDefinitionDao
Find a project repository by name in project associated with given projectId.- Specified by:
findProjectRepositoryByName
in interfaceRepositoryDefinitionDao
- Returns:
- RepositoryDataEntity if repository exists otherwise null.
-
-