com.atlassian.bamboo.deployments.versions.service
Class DeploymentVersionServiceImpl

java.lang.Object
  extended by com.atlassian.bamboo.deployments.versions.service.DeploymentVersionServiceImpl
All Implemented Interfaces:
DeploymentVersionService

public class DeploymentVersionServiceImpl
extends java.lang.Object
implements DeploymentVersionService


Constructor Summary
DeploymentVersionServiceImpl(DeploymentProjectDao deploymentProjectDao, DeploymentVersionDao deploymentVersionDao, ResultsSummaryManager resultsSummaryManager, DeploymentVersionChainResultDataCollector deploymentVersionChainResultDataCollector, com.opensymphony.xwork.TextProvider textProvider, DeploymentVersionVcsChangesetDao deploymentVersionVcsChangesetDao, DeploymentVersionLinkedJiraIssueDao deploymentVersionLinkedJiraIssueDao, VersionNamingService versionNamingService, EnvironmentService environmentService, BambooPermissionManager bambooPermissionManager, GravatarService gravatarService, BambooUserManager bambooUserService, VariableDefinitionManager variableDefinitionManager, VariableDefinitionFactory variableDefinitionFactory)
           
 
Method Summary
 DeploymentVersion createDeploymentVersion(long deploymentProjectId, PlanResultKey planResultKey)
          Create a deployment version out of a deployment project and plan result.
 DeploymentVersion createDeploymentVersion(long deploymentProjectId, PlanResultKey planResultKey, com.atlassian.user.User user, java.lang.String versionName, java.lang.String nextVersionName)
          Create a deployment version with a specific name.
 DeploymentVersion findNextVersionContainingResult(long deploymentProjectId, PlanResultKey planResultKey)
          Find the first version that is created from a result which is later than current result (not taking custom revision into account)
 DeploymentVersion findPreviousVersion(long deploymentProjectId, long versionId)
           
 java.util.List<DeploymentVersion> findVersionsBetween(long deploymentProjectId, DeploymentVersion version1, DeploymentVersion version2)
          Find versions created between version1 and version2.
 java.util.List<DeploymentVersion> getDeploymentProjectVersions(long deploymentProjectId)
          Retrieves the list of all the version for the deployment project, sorted by CreationDate (the most recent Deployment Versions will be returned as firsts)
 DeploymentVersion getDeploymentVersion(long deploymentVersionId)
          Get DeploymentVersion by id
 DeploymentVersion getDeploymentVersionByName(java.lang.String existingVersionName, long deploymentProjectId)
          Get a specific version by name
 java.lang.String getIncrementedVersionName(java.lang.String versionName)
          Calculates an increment of a version name.
 DeploymentVersion getLatestVersionForProject(long id)
          Find the latest version for a deployment project.
 DeploymentVersionStatus getLatestVersionStatus(long deploymentVersionId)
           
 java.util.Map<java.lang.String,VariableDefinitionContext> getPossibleVersionVariables(ImmutablePlan linkedPlan, boolean includeUndeterminable)
          Provides a map of variables which might show up on a version.
 java.util.Set<PlanResultKey> getRelatedPlanResultKeys(long deploymentVersionId)
           
 DeploymentVersion getRelatedVersion(long deploymentProjectId, PlanResultKey planResultKey)
          Find latest version of a deployment project that is related to specific plan result.
 java.util.Map<java.lang.String,Artifact> getVersionArtifacts(DeploymentVersion deploymentVersion)
          Find all Artifact related to a version.
 int getVersionsCountForProject(long deploymentProjectId)
           
 DeploymentVersion renameVersion(long deploymentProjectId, DeploymentVersion deploymentVersion, java.lang.String newVersionName)
          Rename a version.
 java.util.List<DeploymentVersion> searchVersionsByName(long deploymentProjectId, java.lang.String searchTerm)
          Search for deployment versions in a project whose name contains the searchTerm
 void updatePlanKey(PlanKey originalPlanKey, PlanKey newPlanKey)
          Update planKey in DeploymentVersion's related entities when plan key has changed (ie after moving plan)
 DeploymentVersionStatus updateVersionStatus(long deploymentVersionId, DeploymentVersionState status, java.lang.String userName)
           
 ErrorCollection validateCreateDeploymentVersion(long deploymentProjectId, PlanResultKey planResultKey, java.lang.String name, java.lang.String nextVersionName)
          Validates values to be used for creating a new version.
 ErrorCollection validateDeploymentVersionRename(long deploymentProjectId, DeploymentVersion deploymentVersion, java.lang.String name)
          Validates values to be used for renaming version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeploymentVersionServiceImpl

public DeploymentVersionServiceImpl(@NotNull
                                    DeploymentProjectDao deploymentProjectDao,
                                    @NotNull
                                    DeploymentVersionDao deploymentVersionDao,
                                    @NotNull
                                    ResultsSummaryManager resultsSummaryManager,
                                    @NotNull
                                    DeploymentVersionChainResultDataCollector deploymentVersionChainResultDataCollector,
                                    @NotNull
                                    com.opensymphony.xwork.TextProvider textProvider,
                                    @NotNull
                                    DeploymentVersionVcsChangesetDao deploymentVersionVcsChangesetDao,
                                    @NotNull
                                    DeploymentVersionLinkedJiraIssueDao deploymentVersionLinkedJiraIssueDao,
                                    @NotNull
                                    VersionNamingService versionNamingService,
                                    @NotNull
                                    EnvironmentService environmentService,
                                    @NotNull
                                    BambooPermissionManager bambooPermissionManager,
                                    @NotNull
                                    GravatarService gravatarService,
                                    @NotNull
                                    BambooUserManager bambooUserService,
                                    @NotNull
                                    VariableDefinitionManager variableDefinitionManager,
                                    @NotNull
                                    VariableDefinitionFactory variableDefinitionFactory)
Method Detail

validateDeploymentVersionRename

@NotNull
public ErrorCollection validateDeploymentVersionRename(long deploymentProjectId,
                                                               @NotNull
                                                               DeploymentVersion deploymentVersion,
                                                               @Nullable
                                                               java.lang.String name)
Description copied from interface: DeploymentVersionService
Validates values to be used for renaming version.

Specified by:
validateDeploymentVersionRename in interface DeploymentVersionService
Returns:
errorCollection containing any errors found. If no errors, an empty errorCollection will be returned.

renameVersion

@NotNull
public DeploymentVersion renameVersion(long deploymentProjectId,
                                               @NotNull
                                               DeploymentVersion deploymentVersion,
                                               @NotNull
                                               java.lang.String newVersionName)
                                throws WebValidationException
Description copied from interface: DeploymentVersionService
Rename a version.

Specified by:
renameVersion in interface DeploymentVersionService
Returns:
deploymentVersion with the name changed
Throws:
WebValidationException

validateCreateDeploymentVersion

@NotNull
public ErrorCollection validateCreateDeploymentVersion(long deploymentProjectId,
                                                               @NotNull
                                                               PlanResultKey planResultKey,
                                                               @Nullable
                                                               java.lang.String name,
                                                               @Nullable
                                                               java.lang.String nextVersionName)
Description copied from interface: DeploymentVersionService
Validates values to be used for creating a new version.

Specified by:
validateCreateDeploymentVersion in interface DeploymentVersionService
Returns:
errorCollection containing any errors found. If no errors, an empty errorCollection will be returned.

createDeploymentVersion

@NotNull
public DeploymentVersion createDeploymentVersion(long deploymentProjectId,
                                                         @NotNull
                                                         PlanResultKey planResultKey)
                                          throws WebValidationException
Description copied from interface: DeploymentVersionService
Create a deployment version out of a deployment project and plan result. Automatic naming

Specified by:
createDeploymentVersion in interface DeploymentVersionService
Parameters:
deploymentProjectId - of project to create version for
planResultKey - of the result to pull artifacts from
Returns:
created Deployment Version
Throws:
WebValidationException

createDeploymentVersion

@NotNull
public DeploymentVersion createDeploymentVersion(long deploymentProjectId,
                                                         @NotNull
                                                         PlanResultKey planResultKey,
                                                         @Nullable
                                                         com.atlassian.user.User user,
                                                         @Nullable
                                                         java.lang.String versionName,
                                                         @Nullable
                                                         java.lang.String nextVersionName)
                                          throws WebValidationException
Description copied from interface: DeploymentVersionService
Create a deployment version with a specific name. From deployment project and plan result. Assumes validation of name has been done.

Specified by:
createDeploymentVersion in interface DeploymentVersionService
Parameters:
deploymentProjectId - project the version is getting created for
planResultKey - of the result to pull artifacts from
user - the person who is creating this version
versionName - name for the version to create
nextVersionName - the name for the next version (to be udpated in version naming scheme)
Returns:
created Deployment Version.
Throws:
WebValidationException

getPossibleVersionVariables

@NotNull
public java.util.Map<java.lang.String,VariableDefinitionContext> getPossibleVersionVariables(@NotNull
                                                                                                     ImmutablePlan linkedPlan,
                                                                                                     boolean includeUndeterminable)
Description copied from interface: DeploymentVersionService
Provides a map of variables which might show up on a version.

Specified by:
getPossibleVersionVariables in interface DeploymentVersionService
Parameters:
linkedPlan - plan the deployment project is linked to
includeUndeterminable - if true include variables that we don't currently know the value, with a nice example (used for display purposes)
Returns:
a map of variables which might show up on a version.

getDeploymentVersion

@Nullable
public DeploymentVersion getDeploymentVersion(long deploymentVersionId)
Description copied from interface: DeploymentVersionService
Get DeploymentVersion by id

Specified by:
getDeploymentVersion in interface DeploymentVersionService

getDeploymentProjectVersions

@NotNull
public java.util.List<DeploymentVersion> getDeploymentProjectVersions(long deploymentProjectId)
Description copied from interface: DeploymentVersionService
Retrieves the list of all the version for the deployment project, sorted by CreationDate (the most recent Deployment Versions will be returned as firsts)

Specified by:
getDeploymentProjectVersions in interface DeploymentVersionService
Parameters:
deploymentProjectId - if of the deployment project
Returns:
all the versions for the specified deployment project. Empty list if deployment project not found or if there is no versions for it.

getLatestVersionForProject

public DeploymentVersion getLatestVersionForProject(long id)
Description copied from interface: DeploymentVersionService
Find the latest version for a deployment project. Comparison based on creation date.

Specified by:
getLatestVersionForProject in interface DeploymentVersionService
Parameters:
id - of the deployment project
Returns:
the latest version for a deployment project

getDeploymentVersionByName

@Nullable
public DeploymentVersion getDeploymentVersionByName(@NotNull
                                                             java.lang.String existingVersionName,
                                                             long deploymentProjectId)
Description copied from interface: DeploymentVersionService
Get a specific version by name

Specified by:
getDeploymentVersionByName in interface DeploymentVersionService
Parameters:
existingVersionName - name of the version
Returns:
the Deployment version with given name if found, otherwise null.

searchVersionsByName

@NotNull
public java.util.List<DeploymentVersion> searchVersionsByName(long deploymentProjectId,
                                                                      @NotNull
                                                                      java.lang.String searchTerm)
Description copied from interface: DeploymentVersionService
Search for deployment versions in a project whose name contains the searchTerm

Specified by:
searchVersionsByName in interface DeploymentVersionService
Parameters:
deploymentProjectId - deployment project to search within
searchTerm - term to look for.
Returns:
list of Deployment Versions matching the search criteria

getVersionsCountForProject

public int getVersionsCountForProject(long deploymentProjectId)
Specified by:
getVersionsCountForProject in interface DeploymentVersionService

getRelatedPlanResultKeys

@NotNull
public java.util.Set<PlanResultKey> getRelatedPlanResultKeys(long deploymentVersionId)
Specified by:
getRelatedPlanResultKeys in interface DeploymentVersionService
Returns:
Retrieve the PlanResultKeys of ResultSummaries related to a particular DeploymentVersion

getLatestVersionStatus

@Nullable
public DeploymentVersionStatus getLatestVersionStatus(long deploymentVersionId)
Specified by:
getLatestVersionStatus in interface DeploymentVersionService

updateVersionStatus

@Nullable
public DeploymentVersionStatus updateVersionStatus(long deploymentVersionId,
                                                            @NotNull
                                                            DeploymentVersionState status,
                                                            @NotNull
                                                            java.lang.String userName)
Specified by:
updateVersionStatus in interface DeploymentVersionService

findVersionsBetween

@NotNull
public java.util.List<DeploymentVersion> findVersionsBetween(long deploymentProjectId,
                                                                     @NotNull
                                                                     DeploymentVersion version1,
                                                                     @NotNull
                                                                     DeploymentVersion version2)
Description copied from interface: DeploymentVersionService
Find versions created between version1 and version2. The versions must be different but belong to the same DeploymentProject The order of the argument is irrelevant: the method will determine which of the versions is the lower bound. Lower bound is not included in result but upper bound is. The result is sorted by creation date (newest first)

Specified by:
findVersionsBetween in interface DeploymentVersionService
Returns:

findPreviousVersion

@Nullable
public DeploymentVersion findPreviousVersion(long deploymentProjectId,
                                                      @NotNull
                                                      long versionId)
Specified by:
findPreviousVersion in interface DeploymentVersionService

getVersionArtifacts

@NotNull
public java.util.Map<java.lang.String,Artifact> getVersionArtifacts(@NotNull
                                                                            DeploymentVersion deploymentVersion)
Description copied from interface: DeploymentVersionService
Find all Artifact related to a version.

Specified by:
getVersionArtifacts in interface DeploymentVersionService
Returns:

getRelatedVersion

@Nullable
public DeploymentVersion getRelatedVersion(long deploymentProjectId,
                                                    PlanResultKey planResultKey)
Description copied from interface: DeploymentVersionService
Find latest version of a deployment project that is related to specific plan result.

Specified by:
getRelatedVersion in interface DeploymentVersionService
Returns:

findNextVersionContainingResult

public DeploymentVersion findNextVersionContainingResult(long deploymentProjectId,
                                                         @NotNull
                                                         PlanResultKey planResultKey)
Description copied from interface: DeploymentVersionService
Find the first version that is created from a result which is later than current result (not taking custom revision into account)

Specified by:
findNextVersionContainingResult in interface DeploymentVersionService
Returns:

getIncrementedVersionName

@NotNull
public java.lang.String getIncrementedVersionName(@NotNull
                                                          java.lang.String versionName)
Description copied from interface: DeploymentVersionService
Calculates an increment of a version name. Increments last number in the name. If nothing found to increment will return passed in value.

Specified by:
getIncrementedVersionName in interface DeploymentVersionService
Parameters:
versionName - to increment
Returns:
incremented version name.

updatePlanKey

public void updatePlanKey(@NotNull
                          PlanKey originalPlanKey,
                          @NotNull
                          PlanKey newPlanKey)
Description copied from interface: DeploymentVersionService
Update planKey in DeploymentVersion's related entities when plan key has changed (ie after moving plan)

Specified by:
updatePlanKey in interface DeploymentVersionService
Parameters:
originalPlanKey - original PlanKey
newPlanKey - new PlanKey


Copyright © 2013 Atlassian Software Systems Pty Ltd. All Rights Reserved.