com.atlassian.bamboo.deployments.results.persistence
Class DeploymentResultDaoImpl

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by com.atlassian.bamboo.persistence3.StatelessSessionHibernateDaoSupport
              extended by com.atlassian.bamboo.deployments.results.persistence.DeploymentResultDaoImpl
All Implemented Interfaces:
DeploymentResultDao, org.springframework.beans.factory.InitializingBean

public class DeploymentResultDaoImpl
extends StatelessSessionHibernateDaoSupport
implements DeploymentResultDao


Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
DeploymentResultDaoImpl(TransactionAndHibernateTemplate transactionTemplate)
           
 
Method Summary
 int countDeploymentResultsForEnvironment(long environmentId)
          Count deployment results for deployment.
 int delete(DeploymentResultDeletionAdapter deletionAdapter)
          Delete - DEPLOYMENT_RESULT_CUSTOMDATA (manual, JDBC) - DEPLOYMENT_RESULT (manual, JDBC)
 int delete(EnvironmentDeletionAdapter environmentDeletionAdapter)
          Delete - DEPLOYMENT_RESULT_CUSTOMDATA (manual, JDBC) - DEPLOYMENT_RESULT (manual, JDBC)
 void delete(MutableDeploymentResult deploymentResult)
          Delete Deployment Result.
 Set<Long> findEnvironmentIdsVersionWasDeployedOn(long deploymentVersionId)
           
 MutableDeploymentResult getDeploymentResult(long deploymentResultId)
          Get DeploymentResult by id
 List<MutableDeploymentResult> getDeploymentResults(long environmentId, long deploymentVersionId)
          Retrieve all deployment results that exist for an environment and version.
 List<MutableDeploymentResult> getDeploymentResultsByLifeCycleState(Collection<LifeCycleState> lifeCycleStates)
           
 List<MutableDeploymentResult> getDeploymentResultsForDeploymentVersion(long deploymentVersionId)
          Get a list of DeploymentResults for a DeploymentVersion.
 List<MutableDeploymentResult> getDeploymentResultsForDeploymentVersionFinishedBefore(long deploymentVersionId, Date finishedDate)
          Get a list of DeploymentResults for a DeploymentVersion.
 List<MutableDeploymentResult> getDeploymentResultsForEnvironment(long environmentId)
          Get a list of DeploymentResults for a Environment WARNING: This method will fetch all results, potentially creating performance problem.
 List<MutableDeploymentResult> getDeploymentResultsForEnvironment(long environmentId, int offset, int maxResults)
          Get a list of DeploymentResults for a Environment
 MutableDeploymentResult getLastResultBefore(DeploymentResult deploymentResult)
           
 MutableDeploymentResult getLastResultInStatesBefore(DeploymentResult deploymentResult, EnumSet<BuildState> buildStates)
           
 MutableDeploymentResult getLatestDeploymentResult(long environmentId, long deploymentVersionId)
          Retrieve the latest deployment result that exists for a version on an environment.
 MutableDeploymentResult getLatestDeploymentResultForEnvironment(long environmentId)
          Get the latest result that ran against an environment
 List<MutableDeploymentResult> getLatestDeploymentResultsForEnvironment(long environmentId, int startIndex, int maxResults)
          Get the latest deployment results for an Environment, limited to requested amount starting from requested start index.
 MutableDeploymentResult getLatestKnownDeploymentResultForEnvironment(long environmentId)
          Get the latest result that *actually* ran against an environments.
 MutableDeploymentResult getRollbackDeploymentResultBeforeStartedDate(DeploymentResult deploymentResult)
          Find the result successfully deployed on same environment before given deployment result coming from different deployment version
 MutableDeploymentResult getRollbackDeploymentResultForEnvironment(long environmentId, long latestVersionId)
          Find the result that you are trying to replicate by doing a rollback.
 List<MutableDeploymentResult> getSuccessfulDeploymentResultsForEnvironment(long environmentId, int offset, int maxResults)
          Get a list of DeploymentResults successfully deployed to an Environment
 long iterateResultsForExport(com.google.common.base.Function<MutableDeploymentResult,Void> function)
          Iterate through and execute function for each of MutableDeploymentResult
 void save(MutableDeploymentResult deploymentResult)
          Save DeploymentResult
 int unlinkFromVersion(DeploymentVersionDeletionAdapter deletionAdapter)
          Unlink DeploymentResults records limited by DeletionSQLAdapter.getInClause() from deployment version.
 void updateVersionName(long deploymentVersionId, String newVersionName)
          Updates version name in all results related to a vesion
 
Methods inherited from class com.atlassian.bamboo.persistence3.StatelessSessionHibernateDaoSupport
getCacheAwareHibernateTemplate
 
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, 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
 

Constructor Detail

DeploymentResultDaoImpl

public DeploymentResultDaoImpl(TransactionAndHibernateTemplate transactionTemplate)
Method Detail

getDeploymentResult

@Nullable
public MutableDeploymentResult getDeploymentResult(long deploymentResultId)
Description copied from interface: DeploymentResultDao
Get DeploymentResult by id

Specified by:
getDeploymentResult in interface DeploymentResultDao

getDeploymentResultsByLifeCycleState

@NotNull
public List<MutableDeploymentResult> getDeploymentResultsByLifeCycleState(Collection<LifeCycleState> lifeCycleStates)
Specified by:
getDeploymentResultsByLifeCycleState in interface DeploymentResultDao

save

public void save(MutableDeploymentResult deploymentResult)
Description copied from interface: DeploymentResultDao
Save DeploymentResult

Specified by:
save in interface DeploymentResultDao

getDeploymentResultsForEnvironment

@NotNull
public List<MutableDeploymentResult> getDeploymentResultsForEnvironment(long environmentId)
Description copied from interface: DeploymentResultDao
Get a list of DeploymentResults for a Environment WARNING: This method will fetch all results, potentially creating performance problem.

Specified by:
getDeploymentResultsForEnvironment in interface DeploymentResultDao
Parameters:
environmentId - id of Environment

getDeploymentResultsForEnvironment

@NotNull
public List<MutableDeploymentResult> getDeploymentResultsForEnvironment(long environmentId,
                                                                                int offset,
                                                                                int maxResults)
Description copied from interface: DeploymentResultDao
Get a list of DeploymentResults for a Environment

Specified by:
getDeploymentResultsForEnvironment in interface DeploymentResultDao
Parameters:
environmentId - id of Environment

getSuccessfulDeploymentResultsForEnvironment

@NotNull
public List<MutableDeploymentResult> getSuccessfulDeploymentResultsForEnvironment(long environmentId,
                                                                                          int offset,
                                                                                          int maxResults)
Description copied from interface: DeploymentResultDao
Get a list of DeploymentResults successfully deployed to an Environment

Specified by:
getSuccessfulDeploymentResultsForEnvironment in interface DeploymentResultDao
Parameters:
environmentId - id of Environment

countDeploymentResultsForEnvironment

public int countDeploymentResultsForEnvironment(long environmentId)
Description copied from interface: DeploymentResultDao
Count deployment results for deployment.

Specified by:
countDeploymentResultsForEnvironment in interface DeploymentResultDao
Returns:

getLatestDeploymentResultsForEnvironment

@NotNull
public List<MutableDeploymentResult> getLatestDeploymentResultsForEnvironment(long environmentId,
                                                                                      int startIndex,
                                                                                      int maxResults)
Description copied from interface: DeploymentResultDao
Get the latest deployment results for an Environment, limited to requested amount starting from requested start index.

Specified by:
getLatestDeploymentResultsForEnvironment in interface DeploymentResultDao
Parameters:
environmentId - of the environment
startIndex - the index to which start. Latest deployment is at index 0; (ignored if below zero)
maxResults - how many results to retrieve, (ignored if equal to or below zero)
Returns:
subset of latest deployment results

getDeploymentResultsForDeploymentVersion

@NotNull
public List<MutableDeploymentResult> getDeploymentResultsForDeploymentVersion(long deploymentVersionId)
Description copied from interface: DeploymentResultDao
Get a list of DeploymentResults for a DeploymentVersion. Records are sorted by deployment start date. TODO: this method is a potential problem due to performance reasons

Specified by:
getDeploymentResultsForDeploymentVersion in interface DeploymentResultDao
Parameters:
deploymentVersionId - id of DeploymentVersion

getDeploymentResultsForDeploymentVersionFinishedBefore

@NotNull
public List<MutableDeploymentResult> getDeploymentResultsForDeploymentVersionFinishedBefore(long deploymentVersionId,
                                                                                                    Date finishedDate)
Description copied from interface: DeploymentResultDao
Get a list of DeploymentResults for a DeploymentVersion. Records are sorted by deployment start date. TODO: this method is a potential problem due to performance reasons

Specified by:
getDeploymentResultsForDeploymentVersionFinishedBefore in interface DeploymentResultDao
Parameters:
deploymentVersionId - id of DeploymentVersion
finishedDate - only select results finished before this date

getDeploymentResults

@NotNull
public List<MutableDeploymentResult> getDeploymentResults(long environmentId,
                                                                  long deploymentVersionId)
Description copied from interface: DeploymentResultDao
Retrieve all deployment results that exist for an environment and version. There are no restrictions for how many times. Performance should not be a huge problem with this method as we do not expect too many results for one version going to an specific environment you can deploy a version to an environment.

Specified by:
getDeploymentResults in interface DeploymentResultDao
Parameters:
environmentId - of the environment
deploymentVersionId - of the version
Returns:
deployment result for a version against an environment.

getLatestDeploymentResult

@Nullable
public MutableDeploymentResult getLatestDeploymentResult(long environmentId,
                                                                  long deploymentVersionId)
Description copied from interface: DeploymentResultDao
Retrieve the latest deployment result that exists for a version on an environment.

Specified by:
getLatestDeploymentResult in interface DeploymentResultDao
Parameters:
environmentId - of the environment
deploymentVersionId - of the version
Returns:
Latest deployment result if exists

getLatestDeploymentResultForEnvironment

@Nullable
public MutableDeploymentResult getLatestDeploymentResultForEnvironment(long environmentId)
Description copied from interface: DeploymentResultDao
Get the latest result that ran against an environment

Specified by:
getLatestDeploymentResultForEnvironment in interface DeploymentResultDao
Parameters:
environmentId - id of the environment
Returns:
the latest result. Null if not run

getLatestKnownDeploymentResultForEnvironment

@Nullable
public MutableDeploymentResult getLatestKnownDeploymentResultForEnvironment(long environmentId)
Description copied from interface: DeploymentResultDao
Get the latest result that *actually* ran against an environments. Any NOT_BUILT results are skipped, so you can see the latest known state of that particular environment.

Specified by:
getLatestKnownDeploymentResultForEnvironment in interface DeploymentResultDao
Parameters:
environmentId - id of the environment
Returns:
the latest results.

getRollbackDeploymentResultForEnvironment

@Nullable
public MutableDeploymentResult getRollbackDeploymentResultForEnvironment(long environmentId,
                                                                                  long latestVersionId)
Description copied from interface: DeploymentResultDao
Find the result that you are trying to replicate by doing a rollback. Looks back until it finds a successful result that is not the same version as the one currently deployed

Specified by:
getRollbackDeploymentResultForEnvironment in interface DeploymentResultDao
Parameters:
environmentId - if the environment to find rollback for
latestVersionId - id of the version currently on the environment
Returns:
result

getRollbackDeploymentResultBeforeStartedDate

@Nullable
public MutableDeploymentResult getRollbackDeploymentResultBeforeStartedDate(@NotNull
                                                                                     DeploymentResult deploymentResult)
Description copied from interface: DeploymentResultDao
Find the result successfully deployed on same environment before given deployment result coming from different deployment version

Specified by:
getRollbackDeploymentResultBeforeStartedDate in interface DeploymentResultDao
Returns:

delete

public void delete(MutableDeploymentResult deploymentResult)
Description copied from interface: DeploymentResultDao
Delete Deployment Result.

Specified by:
delete in interface DeploymentResultDao
Parameters:
deploymentResult - to be deleted

delete

public int delete(@NotNull
                  DeploymentResultDeletionAdapter deletionAdapter)
Delete - DEPLOYMENT_RESULT_CUSTOMDATA (manual, JDBC) - DEPLOYMENT_RESULT (manual, JDBC)

Specified by:
delete in interface DeploymentResultDao
Parameters:
deletionAdapter - DeletionSQLAdapter.getInClause() should provide range of DeploymentResults
Returns:
number of deleted records

delete

public int delete(@NotNull
                  EnvironmentDeletionAdapter environmentDeletionAdapter)
Delete - DEPLOYMENT_RESULT_CUSTOMDATA (manual, JDBC) - DEPLOYMENT_RESULT (manual, JDBC)

Specified by:
delete in interface DeploymentResultDao
Parameters:
environmentDeletionAdapter - EnvironmentDeletionAdapter should provide range of DeploymentResults
Returns:
number of deleted records

unlinkFromVersion

public int unlinkFromVersion(@NotNull
                             DeploymentVersionDeletionAdapter deletionAdapter)
Description copied from interface: DeploymentResultDao
Unlink DeploymentResults records limited by DeletionSQLAdapter.getInClause() from deployment version. Unlinking is performed using UPDATE queries

Specified by:
unlinkFromVersion in interface DeploymentResultDao
Parameters:
deletionAdapter - DeletionSQLAdapter.getInClause() should provide range of DeploymentVersions to unlink from
Returns:
number of unlinked records

iterateResultsForExport

public long iterateResultsForExport(@NotNull
                                    com.google.common.base.Function<MutableDeploymentResult,Void> function)
Description copied from interface: DeploymentResultDao
Iterate through and execute function for each of MutableDeploymentResult

Specified by:
iterateResultsForExport in interface DeploymentResultDao
Parameters:
function - function to be executed on each of the MutableDeploymentResult
Returns:
number of traversed rows

findEnvironmentIdsVersionWasDeployedOn

@NotNull
public Set<Long> findEnvironmentIdsVersionWasDeployedOn(long deploymentVersionId)
Specified by:
findEnvironmentIdsVersionWasDeployedOn in interface DeploymentResultDao
Returns:
ids of all environments a version was ever deployed on

getLastResultBefore

@Nullable
public MutableDeploymentResult getLastResultBefore(@NotNull
                                                            DeploymentResult deploymentResult)
Specified by:
getLastResultBefore in interface DeploymentResultDao
Returns:
result of the last deployment performed on an environment before given result

getLastResultInStatesBefore

@Nullable
public MutableDeploymentResult getLastResultInStatesBefore(@NotNull
                                                                    DeploymentResult deploymentResult,
                                                                    @NotNull
                                                                    EnumSet<BuildState> buildStates)
Specified by:
getLastResultInStatesBefore in interface DeploymentResultDao
Returns:
result of the last deployment performed on an environment before given result in one of given build states

updateVersionName

public void updateVersionName(long deploymentVersionId,
                              @NotNull
                              String newVersionName)
Description copied from interface: DeploymentResultDao
Updates version name in all results related to a vesion

Specified by:
updateVersionName in interface DeploymentResultDao


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.