com.atlassian.bamboo.deployments.results.service
Class DeploymentResultServiceImpl

java.lang.Object
  extended by com.atlassian.bamboo.deployments.results.service.DeploymentResultServiceImpl
All Implemented Interfaces:
DeploymentResultService

public class DeploymentResultServiceImpl
extends Object
implements DeploymentResultService


Constructor Summary
DeploymentResultServiceImpl(DeploymentResultDao deploymentResultDao, DeploymentVersionDao deploymentVersionDao, EnvironmentDao environmentDao, EnvironmentService environmentService, DeploymentVersionService deploymentVersionService, VariableContextBaselineDao variableContextBaselineDao, DeploymentVariableSubstitutionDao deploymentVariableSubstitutionDao, DeploymentsInProgressService deploymentsInProgressService)
           
 
Method Summary
 int countDeploymentResultsForEnvironment(long environmentId)
          Count deployment results for deployment.
 DeploymentResult createDeploymentResult(long environmentId, long deploymentVersionId, VariableContext variableContext, TriggerReason triggerReason)
           
 Set<Long> findEnvironmentIdsVersionWasDeployedOn(long deploymentVersionId)
           
 DeploymentResult getDeploymentResult(long deploymentResultId)
          Retrieve a specific deployment result.
 List<DeploymentResult> getDeploymentResultsByLifeCycleState(Collection<LifeCycleState> lifeCycleStates)
           
 List<DeploymentResult> getDeploymentResultsForDeploymentVersion(long deploymentVersionId)
          Get all deployment results for deployment version.
 List<DeploymentResult> getDeploymentResultsForDeploymentVersionAndEnvironment(long deploymentVersionId, long environmentId)
          Get all deployment results for deployment versions that ran against the specified environment.
 List<DeploymentResult> getDeploymentResultsForDeploymentVersionFinishedBefore(long deploymentVersionId, Date finishDate)
          Get all deployment results for deployment version finished before given date.
 List<DeploymentResult> getDeploymentResultsForEnvironment(long environmentId)
          Get all deployment results for environment.
 List<DeploymentResult> getDeploymentResultsForEnvironment(long environmentId, int offset, int maxResults)
          Get deployment results for environment.
 DeploymentResult getLastResultBefore(DeploymentResult deploymentResult)
           
 DeploymentResult getLastResultInStatesBefore(DeploymentResult deploymentResult, EnumSet<BuildState> buildStates)
           
 DeploymentResult getLatestDeploymentResult(long environmentId, long deploymentVersionId)
          Retrieve a specific deployment result for an environment and version.
 DeploymentResult getLatestDeploymentResultForEnvironment(long environmentId)
          Get the latest result that ran against an environment
 List<EnvironmentStatus> getLatestKnownDeploymentResultForEnvironments(Iterable<? extends Environment> environments)
          Get the latest results that *actually* ran against a list of environments.
 List<DeploymentResult> getResultsWhereDeploymentVersionIsDeployedNow(List<Long> environmentsId, long deploymentVersionId)
           
 DeploymentVersion getRollbackVersion(DeploymentResult deploymentResult)
          For a given deployment result find the version that existed on the environment before that deployment.
 DeploymentVersion getRollbackVersion(long environmentId)
          For a given environment find the version that existed on the environment prior to the last deployment.
 List<DeploymentResult> getSuccessfulDeploymentResultsForEnvironment(long environmentId, int offset, int maxResults)
          Get successful deployment results for environment.
 void logSubstitutedVariables(long deploymentResultId, Map<String,VariableSubstitutionContext> substitutions)
          Adds variable substitution result to DeploymentResult This method logs substitution after it was performed and will use only REALLY substituted values
 void setExecutingAgent(long deploymentResultId, long agentId)
          Set the agent that the deployment is executing on.
 void updateDeploymentState(long deploymentResultId, BuildState deploymentState, Map<String,String> customData)
          Update the build state of the Deployment Result
 void updateLifeCycleState(DeploymentTimingPoint timingPoint, LifeCycleState lifeCycleState)
          Update lifecycle state of the DeploymentResult
 void updateLifeCycleState(long deploymentResultId, LifeCycleState lifeCycleState)
          Update lifecycle state of the DeploymentResult.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeploymentResultServiceImpl

public DeploymentResultServiceImpl(DeploymentResultDao deploymentResultDao,
                                   DeploymentVersionDao deploymentVersionDao,
                                   EnvironmentDao environmentDao,
                                   EnvironmentService environmentService,
                                   DeploymentVersionService deploymentVersionService,
                                   @NotNull
                                   VariableContextBaselineDao variableContextBaselineDao,
                                   @NotNull
                                   DeploymentVariableSubstitutionDao deploymentVariableSubstitutionDao,
                                   @NotNull
                                   DeploymentsInProgressService deploymentsInProgressService)
Method Detail

createDeploymentResult

public DeploymentResult createDeploymentResult(long environmentId,
                                               long deploymentVersionId,
                                               @NotNull
                                               VariableContext variableContext,
                                               @NotNull
                                               TriggerReason triggerReason)
Specified by:
createDeploymentResult in interface DeploymentResultService

getDeploymentResult

@Nullable
public DeploymentResult getDeploymentResult(long deploymentResultId)
Description copied from interface: DeploymentResultService
Retrieve a specific deployment result.

Specified by:
getDeploymentResult in interface DeploymentResultService
Parameters:
deploymentResultId - of the result
Returns:
deployment result with given id

getLatestDeploymentResult

@Nullable
public DeploymentResult getLatestDeploymentResult(long environmentId,
                                                           long deploymentVersionId)
Description copied from interface: DeploymentResultService
Retrieve a specific deployment result for an environment and version. There should only be one result per environment/version combination. Entirely possible it has not executed yet so will return null;

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

getLatestDeploymentResultForEnvironment

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

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

getLatestKnownDeploymentResultForEnvironments

@NotNull
public List<EnvironmentStatus> getLatestKnownDeploymentResultForEnvironments(Iterable<? extends Environment> environments)
Description copied from interface: DeploymentResultService
Get the latest results that *actually* ran against a list of environments. Any NOT_BUILT results are skipped, so you can see the state of that particular environment. Wraps the return into EnvironmentStatus'

Specified by:
getLatestKnownDeploymentResultForEnvironments in interface DeploymentResultService
Parameters:
environments - we want to retrieve latest DeploymentResult
Returns:
the List of EnvironmentStatus that contain latest results.

getDeploymentResultsForEnvironment

@NotNull
public List<DeploymentResult> getDeploymentResultsForEnvironment(long environmentId)
Description copied from interface: DeploymentResultService
Get all deployment results for environment. Sorted by started date, newest first. todo pagination

Specified by:
getDeploymentResultsForEnvironment in interface DeploymentResultService
Parameters:
environmentId - id of environment to get results from
Returns:
List of deployment results

getDeploymentResultsForEnvironment

@NotNull
public List<DeploymentResult> getDeploymentResultsForEnvironment(long environmentId,
                                                                         int offset,
                                                                         int maxResults)
Description copied from interface: DeploymentResultService
Get deployment results for environment. Sorted by started date, newest first, skips a number of results defined in 'offset' parameter, limits to 'maxResults'

Specified by:
getDeploymentResultsForEnvironment in interface DeploymentResultService
Parameters:
environmentId - id of environment to get results from
Returns:
List of deployment results

getSuccessfulDeploymentResultsForEnvironment

@NotNull
public List<DeploymentResult> getSuccessfulDeploymentResultsForEnvironment(long environmentId,
                                                                                   int offset,
                                                                                   int maxResults)
Description copied from interface: DeploymentResultService
Get successful deployment results for environment. Sorted by started date, newest first, skips a number of results defined in 'offset' parameter, limits to 'maxResults'

Specified by:
getSuccessfulDeploymentResultsForEnvironment in interface DeploymentResultService
Parameters:
environmentId - id of environment to get results from
Returns:
List of successful deployment results

getDeploymentResultsForDeploymentVersion

@NotNull
public List<DeploymentResult> getDeploymentResultsForDeploymentVersion(long deploymentVersionId)
Description copied from interface: DeploymentResultService
Get all deployment results for deployment version. Sorted by started date, newest first. This method could return significant sets of data and is a potential problem due to performance reasons

Specified by:
getDeploymentResultsForDeploymentVersion in interface DeploymentResultService
Parameters:
deploymentVersionId - id of deployment version to get results from
Returns:
List of deployment results sorted by started data (newest first)

getDeploymentResultsForDeploymentVersionAndEnvironment

@NotNull
public List<DeploymentResult> getDeploymentResultsForDeploymentVersionAndEnvironment(long deploymentVersionId,
                                                                                             long environmentId)
Description copied from interface: DeploymentResultService
Get all deployment results for deployment versions that ran against the specified environment.

Specified by:
getDeploymentResultsForDeploymentVersionAndEnvironment in interface DeploymentResultService
Parameters:
deploymentVersionId - id of deployment version
environmentId - id of environment
Returns:
List of deployment results sorted by started date (newest first)

getDeploymentResultsForDeploymentVersionFinishedBefore

@NotNull
public List<DeploymentResult> getDeploymentResultsForDeploymentVersionFinishedBefore(long deploymentVersionId,
                                                                                             Date finishDate)
Description copied from interface: DeploymentResultService
Get all deployment results for deployment version finished before given date. Sorted by started date, newest first. This method could return significant sets of data and is a potential problem due to performance reasons

Specified by:
getDeploymentResultsForDeploymentVersionFinishedBefore in interface DeploymentResultService
Parameters:
deploymentVersionId - id of deployment version to get results from
finishDate - only select results finished before this date
Returns:
List of deployment results sorted by started data (newest first)

countDeploymentResultsForEnvironment

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

Specified by:
countDeploymentResultsForEnvironment in interface DeploymentResultService
Returns:

getDeploymentResultsByLifeCycleState

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

getRollbackVersion

public DeploymentVersion getRollbackVersion(long environmentId)
Description copied from interface: DeploymentResultService
For a given environment find the version that existed on the environment prior to the last deployment. This is the version that you would "Roll back" to in the case of problems.

Specified by:
getRollbackVersion in interface DeploymentResultService
Parameters:
environmentId - to find rollback version for.
Returns:
the version that is considered the rollback version for this environment

getRollbackVersion

@Nullable
public DeploymentVersion getRollbackVersion(@NotNull
                                                     DeploymentResult deploymentResult)
Description copied from interface: DeploymentResultService
For a given deployment result find the version that existed on the environment before that deployment.

Specified by:
getRollbackVersion in interface DeploymentResultService
Parameters:
deploymentResult - deployment result that was deployed at some time on some environment
Returns:
deployment that was previously on same environment

updateDeploymentState

public void updateDeploymentState(long deploymentResultId,
                                  @NotNull
                                  BuildState deploymentState,
                                  Map<String,String> customData)
Description copied from interface: DeploymentResultService
Update the build state of the Deployment Result

Specified by:
updateDeploymentState in interface DeploymentResultService
Parameters:
deploymentResultId - if of result to update
deploymentState - new value of the build state to save

updateLifeCycleState

public void updateLifeCycleState(long deploymentResultId,
                                 @NotNull
                                 LifeCycleState lifeCycleState)
Description copied from interface: DeploymentResultService
Update lifecycle state of the DeploymentResult. This method expects only PENDING and NOT_BUILD lifeCycleState.

Specified by:
updateLifeCycleState in interface DeploymentResultService
Parameters:
deploymentResultId - id of DeploymentResult
lifeCycleState - lifecycle state to be set

updateLifeCycleState

public void updateLifeCycleState(@NotNull
                                 DeploymentTimingPoint timingPoint,
                                 @NotNull
                                 LifeCycleState lifeCycleState)
Description copied from interface: DeploymentResultService
Update lifecycle state of the DeploymentResult

Specified by:
updateLifeCycleState in interface DeploymentResultService
Parameters:
timingPoint - deployment timing point
lifeCycleState - lifecycle state to be set

logSubstitutedVariables

public void logSubstitutedVariables(long deploymentResultId,
                                    Map<String,VariableSubstitutionContext> substitutions)
Description copied from interface: DeploymentResultService
Adds variable substitution result to DeploymentResult This method logs substitution after it was performed and will use only REALLY substituted values

Specified by:
logSubstitutedVariables in interface DeploymentResultService

setExecutingAgent

public void setExecutingAgent(long deploymentResultId,
                              long agentId)
Description copied from interface: DeploymentResultService
Set the agent that the deployment is executing on.

Specified by:
setExecutingAgent in interface DeploymentResultService
Parameters:
deploymentResultId - id of the deployment result
agentId - if of the agent

findEnvironmentIdsVersionWasDeployedOn

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

getLastResultBefore

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

getLastResultInStatesBefore

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

getResultsWhereDeploymentVersionIsDeployedNow

public List<DeploymentResult> getResultsWhereDeploymentVersionIsDeployedNow(List<Long> environmentsId,
                                                                            long deploymentVersionId)
Specified by:
getResultsWhereDeploymentVersionIsDeployedNow in interface DeploymentResultService
Parameters:
environmentsId - list of environments to check
Returns:
list of deployment results that are now deployed on given environments


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