Class EnvironmentDaoImpl
java.lang.Object
org.springframework.dao.support.DaoSupport
org.springframework.orm.hibernate5.support.HibernateDaoSupport
com.atlassian.bamboo.persistence3.StatelessSessionHibernateDaoSupport
com.atlassian.bamboo.persistence3.BambooHibernateObjectDao<MutableEnvironment>
com.atlassian.bamboo.deployments.environments.persistence.EnvironmentDaoImpl
- All Implemented Interfaces:
EnvironmentDao
,BambooObjectDao<MutableEnvironment>
,org.springframework.beans.factory.InitializingBean
public class EnvironmentDaoImpl
extends BambooHibernateObjectDao<MutableEnvironment>
implements EnvironmentDao
-
Field Summary
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
countAll()
@NotNull MutableEnvironment
void
delete
(@NotNull MutableEnvironment environment) Removes the given entity from the databasefindAll()
List<? extends MutableEnvironment>
findAll
(int firstResult, int maxResults) findAllByIds
(Collection<Long> ids) Returns a list of Environments which id values are in the ids collectionfindAllInternalEnvironments
(int firstResult, int maxResults) @NotNull List<EnvironmentStub>
findAllStubs
(int firstResult, int maxResults) @Nullable MutableEnvironment
findEnvironmentByName
(long deploymentProjectId, String name) Find environment with specified name in a deployment project@NotNull List<Pair<Requirement,
MutableEnvironment>> findEnvironmentsByRequirementKey
(@NotNull String requirementKey) Get requirements to environment mapping by requirement key.@Nullable InternalEnvironment
findInternalEnvironmentByName
(long deploymentProjectId, @NotNull String name) findInternalEnvironmentsByIds
(@NotNull List<Long> ids) Returns a list ofInternalEnvironment
which id values are in the ids collection@Nullable MutableEnvironment
getEnvironment
(long environmentId) Gets specific Environment by ID@Nullable MutableEnvironment
getEnvironment
(@NotNull DeploymentKey environmentKey) Gets specific Environment by keyint
int
getEnvironmentCountForProject
(long deploymentProjectId) @NotNull List<MutableEnvironment>
getEnvironmentsForDeploymentProject
(long deploymentProjectId) Retrieve all environments for a Deployment Project@NotNull List<EnvironmentStub>
getEnvironmentStubsForDeploymentProject
(long deploymentProjectId) Retrieve all environment stubs for a Deployment Project.int
getFirstEnvironmentPosition
(long deploymentProjectId) @NotNull List<InternalEnvironment>
getInternalEnvironmentsForDeploymentProject
(long deploymentProjectId) int
getLastEnvironmentPosition
(long deploymentProjectId) getNextEnvironment
(long deploymentProjectId, int position) getPaginatedDeploymentsWithEnvironmentsOnlyIdsAndRequirementSets
(int start, int limit, String filter) Retrieve paginated pairs of deployment project and environment ids together with the environment requirements, sorted by project ids and environment positions, matching the filter string anywhere within the name of the project or environment@NotNull List<MutableEnvironment>
getPaginatedEnvironmentsForDeploymentProject
(long deploymentProjectId, int start, int limit, String filter) Retrieve part of environments for a Deployment Project ordered by positiongetPreviousEnvironment
(long deploymentProjectId, int position) boolean
isEnvironmentNameConflicting
(@NotNull MutableDeploymentProject deploymentProject, @NotNull String name) Check if there is currently an environment with the given name in the given deployment Project.void
save
(@NotNull MutableEnvironment environment) Saves the given entity.void
shiftDownEnvPosition
(int fromPosition, int toPosition, long deploymentProjectId) Decrement by one all environments positions for given deployment project for environments which have position greater than fromPosition and lower than toPosition.void
shiftUpEnvPosition
(int fromPosition, int toPosition, long deploymentProjectId) Increment by one all environments positions for given deployment project for environments which have position greater than fromPosition and lower than toPosition.Methods inherited from class com.atlassian.bamboo.persistence3.BambooHibernateObjectDao
convertSearchTermToLikeExpression, countAll, countWithRestriction, deleteAll, executeCountQuery, findAll, findById, merge, saveAll
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 org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
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.deployments.environments.persistence.EnvironmentDao
saveAll
-
Constructor Details
-
EnvironmentDaoImpl
public EnvironmentDaoImpl()
-
-
Method Details
-
getEnvironment
Description copied from interface:EnvironmentDao
Gets specific Environment by ID- Specified by:
getEnvironment
in interfaceEnvironmentDao
- Parameters:
environmentId
- ID of the environment your looking for.- Returns:
- environment with given id or null if one with that ID could not be found.
-
save
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<MutableEnvironment>
- Specified by:
save
in interfaceEnvironmentDao
- Overrides:
save
in classBambooHibernateObjectDao<MutableEnvironment>
- Parameters:
environment
- entity to be saved
-
delete
Description copied from interface:BambooObjectDao
Removes the given entity from the database- Specified by:
delete
in interfaceBambooObjectDao<MutableEnvironment>
- Specified by:
delete
in interfaceEnvironmentDao
- Overrides:
delete
in classBambooHibernateObjectDao<MutableEnvironment>
- Parameters:
environment
- entity to be removed
-
getEnvironment
@Nullable public @Nullable MutableEnvironment getEnvironment(@NotNull @NotNull DeploymentKey environmentKey) Description copied from interface:EnvironmentDao
Gets specific Environment by key- Specified by:
getEnvironment
in interfaceEnvironmentDao
- Parameters:
environmentKey
- ket of the environment to find- Returns:
- Deployment Environment with given key or null if one with that key could not be found
-
getEnvironmentsForDeploymentProject
@NotNull public @NotNull List<MutableEnvironment> getEnvironmentsForDeploymentProject(long deploymentProjectId) Description copied from interface:EnvironmentDao
Retrieve all environments for a Deployment Project- Specified by:
getEnvironmentsForDeploymentProject
in interfaceEnvironmentDao
- Parameters:
deploymentProjectId
- of the Deployment Project- Returns:
- List of all environments in a Deployment Project
-
getEnvironmentStubsForDeploymentProject
@NotNull public @NotNull List<EnvironmentStub> getEnvironmentStubsForDeploymentProject(long deploymentProjectId) Description copied from interface:EnvironmentDao
Retrieve all environment stubs for a Deployment Project. Environment stubs contain only the data that is required for the UI.- Specified by:
getEnvironmentStubsForDeploymentProject
in interfaceEnvironmentDao
- Parameters:
deploymentProjectId
- of the Deployment Project- Returns:
- List of all environments in a Deployment Project
-
isEnvironmentNameConflicting
public boolean isEnvironmentNameConflicting(@NotNull @NotNull MutableDeploymentProject deploymentProject, @NotNull @NotNull String name) Description copied from interface:EnvironmentDao
Check if there is currently an environment with the given name in the given deployment Project.- Specified by:
isEnvironmentNameConflicting
in interfaceEnvironmentDao
- Parameters:
deploymentProject
- the project to check environments ofname
- to check for conflict- Returns:
- true if the name is already being used by an environment in the project, false if not.
-
findEnvironmentByName
@Nullable public @Nullable MutableEnvironment findEnvironmentByName(long deploymentProjectId, String name) Description copied from interface:EnvironmentDao
Find environment with specified name in a deployment project- Specified by:
findEnvironmentByName
in interfaceEnvironmentDao
-
findAll
- Specified by:
findAll
in interfaceEnvironmentDao
-
getLastEnvironmentPosition
public int getLastEnvironmentPosition(long deploymentProjectId) - Specified by:
getLastEnvironmentPosition
in interfaceEnvironmentDao
- Returns:
- position of the last environment associated with a deployment project or -1 if none.
-
getFirstEnvironmentPosition
public int getFirstEnvironmentPosition(long deploymentProjectId) - Specified by:
getFirstEnvironmentPosition
in interfaceEnvironmentDao
- Returns:
- position of the first environment associated with a deployment project or -1 if none.
-
getEnvironmentCount
public int getEnvironmentCount()- Specified by:
getEnvironmentCount
in interfaceEnvironmentDao
- Returns:
- number of all
Environment
s
-
getEnvironmentCountForProject
public int getEnvironmentCountForProject(long deploymentProjectId) - Specified by:
getEnvironmentCountForProject
in interfaceEnvironmentDao
- Returns:
- number of
Environment
defined for the project
-
countAll
public long countAll()- Specified by:
countAll
in interfaceEnvironmentDao
-
findAll
- Specified by:
findAll
in interfaceEnvironmentDao
-
findAllInternalEnvironments
- Specified by:
findAllInternalEnvironments
in interfaceEnvironmentDao
-
getInternalEnvironmentsForDeploymentProject
@NotNull public @NotNull List<InternalEnvironment> getInternalEnvironmentsForDeploymentProject(long deploymentProjectId) - Specified by:
getInternalEnvironmentsForDeploymentProject
in interfaceEnvironmentDao
-
findInternalEnvironmentByName
@Nullable public @Nullable InternalEnvironment findInternalEnvironmentByName(long deploymentProjectId, @NotNull @NotNull String name) - Specified by:
findInternalEnvironmentByName
in interfaceEnvironmentDao
-
findAllStubs
- Specified by:
findAllStubs
in interfaceEnvironmentDao
-
findEnvironmentsByRequirementKey
@NotNull public @NotNull List<Pair<Requirement,MutableEnvironment>> findEnvironmentsByRequirementKey(@NotNull @NotNull String requirementKey) Description copied from interface:EnvironmentDao
Get requirements to environment mapping by requirement key.- Specified by:
findEnvironmentsByRequirementKey
in interfaceEnvironmentDao
- Parameters:
requirementKey
- on which environments rely- Returns:
- pairs of environments or empty list
-
createNewEnvironmentInstance
- Specified by:
createNewEnvironmentInstance
in interfaceEnvironmentDao
-
getPaginatedEnvironmentsForDeploymentProject
@NotNull public @NotNull List<MutableEnvironment> getPaginatedEnvironmentsForDeploymentProject(long deploymentProjectId, int start, int limit, String filter) Description copied from interface:EnvironmentDao
Retrieve part of environments for a Deployment Project ordered by position- Specified by:
getPaginatedEnvironmentsForDeploymentProject
in interfaceEnvironmentDao
- Parameters:
deploymentProjectId
- of the Deployment Projectstart
- startlimit
- max size of result- Returns:
- List of environments in a Deployment Project no more than limit
-
getPaginatedDeploymentsWithEnvironmentsOnlyIdsAndRequirementSets
public List<EnvironmentWithProjectAndRequirementsDto> getPaginatedDeploymentsWithEnvironmentsOnlyIdsAndRequirementSets(int start, int limit, String filter) Description copied from interface:EnvironmentDao
Retrieve paginated pairs of deployment project and environment ids together with the environment requirements, sorted by project ids and environment positions, matching the filter string anywhere within the name of the project or environment- Specified by:
getPaginatedDeploymentsWithEnvironmentsOnlyIdsAndRequirementSets
in interfaceEnvironmentDao
- Parameters:
start
- startlimit
- max size of resultfilter
- string by which the names of project and environments will be filtered- Returns:
- List of id pairs and requirement sets
-
shiftUpEnvPosition
public void shiftUpEnvPosition(int fromPosition, int toPosition, long deploymentProjectId) Description copied from interface:EnvironmentDao
Increment by one all environments positions for given deployment project for environments which have position greater than fromPosition and lower than toPosition. Position for environments which position is equal to fromPosition or toPosition won't be change.- Specified by:
shiftUpEnvPosition
in interfaceEnvironmentDao
-
shiftDownEnvPosition
public void shiftDownEnvPosition(int fromPosition, int toPosition, long deploymentProjectId) Description copied from interface:EnvironmentDao
Decrement by one all environments positions for given deployment project for environments which have position greater than fromPosition and lower than toPosition. Position for environments which position is equal to fromPosition or toPosition won't be change.- Specified by:
shiftDownEnvPosition
in interfaceEnvironmentDao
-
getNextEnvironment
- Specified by:
getNextEnvironment
in interfaceEnvironmentDao
- Returns:
- sorted first
MutableEnvironment
in deploymentProject which has greater position than position
-
getPreviousEnvironment
- Specified by:
getPreviousEnvironment
in interfaceEnvironmentDao
- Returns:
- sorted first
MutableEnvironment
in deploymentProject which has lower position than position
-
findAllByIds
Description copied from interface:EnvironmentDao
Returns a list of Environments which id values are in the ids collection- Specified by:
findAllByIds
in interfaceEnvironmentDao
- Parameters:
ids
- list of id values- Returns:
- list of Environments
-
findInternalEnvironmentsByIds
Description copied from interface:EnvironmentDao
Returns a list ofInternalEnvironment
which id values are in the ids collection- Specified by:
findInternalEnvironmentsByIds
in interfaceEnvironmentDao
-