com.atlassian.bamboo.deployments.versions.persistence
Class DeploymentVersionDaoImpl

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate.support.HibernateDaoSupport
          extended by com.atlassian.bamboo.persistence3.StatelessSessionHibernateDaoSupport
              extended by com.atlassian.bamboo.deployments.versions.persistence.DeploymentVersionDaoImpl
All Implemented Interfaces:
DeploymentVersionDao, org.springframework.beans.factory.InitializingBean

public class DeploymentVersionDaoImpl
extends StatelessSessionHibernateDaoSupport
implements DeploymentVersionDao


Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
DeploymentVersionDaoImpl()
           
 
Method Summary
 MutableDeploymentVersionStatus createNewVersionStatus(long deploymentVersionId, DeploymentVersionState state, java.lang.String userName)
          Creates a new vesion status for the given deployment version.
 void delete(MutableDeploymentVersion deploymentVersion)
          Delete MutableDeploymentVersion
 int deleteForDeploymentProject(long deploymentProjectId)
          Affected tables: - DEPLOYMENT_VERSION (manual, JDBC) - DEPLOYMENT_VERSION_ITEM (manual, JDBC) - DEPLOYMENT_VERSION_ITEM_BA (manual, JDBC) - DEPLOYMENT_PLANRESULTKEYS (manual, JDBC)
 int deleteVersionItems(long deploymentVersionId)
          Affected tables: - DEPLOYMENT_VERSION_ITEM (manual, JDBC) - DEPLOYMENT_VERSION_ITEM_BA (manual, JDBC)
 int deleteVersionStatus(long deploymentVersionId)
          Delete DeploymentVersionStatus records related to a given version
 int deleteVersionStatuses(DeploymentVersionDeletionAdapter deletionAdapter)
          Delete DeploymentVersionStatus records related to a given versions
 java.util.List<MutableDeploymentVersion> findLatestKnownVersionsForEnvironmentsOfDeploymentProject(long deploymentProjectId)
          Find all the versions that are currently deployed on environments of a deployment projects.
 MutableDeploymentVersion findLatestVersionForProject(long deploymentProjectId)
          Find the latest version for a deployment project.
 MutableDeploymentVersion findLatestVersionForProject(long deploymentProjectId, PlanKey branchKey)
          Find the latest version for a deployment project.
 MutableDeploymentVersion 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)
 MutableDeploymentVersion findPreviousVersion(long deploymentProjectId, MutableDeploymentVersion deploymentVersion)
          Find the last version created before this one.
 java.util.List<MutableDeploymentVersion> findVersions(DeploymentVersionSearchCriteria searchCriteria)
          Search for versions using search criteria
 java.util.List<MutableDeploymentVersion> findVersionsAssociatedWithJiraIssue(long deploymentProjectId, java.lang.String issueKey)
          Find all the versions of a DeploymentProject that are associated with a JIRA issue
 java.util.List<MutableDeploymentVersion> findVersionsAssociatedWithJiraIssue(java.lang.String issueKey)
          Find all the versions that are associated with a JIRA issue
 java.lang.Iterable<MutableDeploymentVersion> findVersionsBetween(long deploymentProjectId, long version1Id, long version2Id)
          Find versions created between version1 and version2.
 MutableDeploymentVersion getDeploymentVersion(long deploymentVersionId)
          Get MutableDeploymentVersion by id
 MutableDeploymentVersion getDeploymentVersionByName(java.lang.String existingVersionName, long deploymentProjectId)
          Retrieve a specific version by name for a project
 java.util.List<MutableDeploymentVersion> getDeploymentVersionsForDeploymentProject(long deploymentProjectId)
          Get MutableDeploymentVersion by DeploymentProject id
 MutableDeploymentVersionStatus getLatestVersionStatus(long deploymentVersionId)
           
 java.util.Set<PlanResultKey> getRelatedPlanResultKeys(long deploymentVersionId)
           
 MutableDeploymentVersion getRelatedVersion(long deploymentProjectId, PlanResultKey planResultKey)
          Find latest version of a deployment project that is related to specific plan result.
 java.util.List<java.lang.String> getResultPlanKeysHavingDeploymentProjectVersions(long deploymentProjectId)
          Returns keys of result plans (branch) that have at least one deployment project version (release)
 int getVersionsCount()
          Count all versions
 int getVersionsCountForProject(long deploymentProjectId)
          Count versions related to deployment project
 java.util.List<MutableDeploymentVersionStatus> getVersionStatuses(long deploymentVersionId)
          Get MutableDeploymentVersionStatuses by DeploymentVersion id
 boolean hasVersions(DeploymentVersionSearchCriteria searchCriteria)
          Test if versions that match criteria do exist
 boolean isVersionNameConflicting(java.lang.String name, long deploymentProjectId)
          Check whether the version name is already being used by another version within this project
 void save(MutableDeploymentVersion deploymentVersion)
          MutableDeploymentVersionItem members of MutableDeploymentVersion.getItems() are persisted in a cascade
 void updatePlanKey(PlanKey originalPlanKey, PlanKey newPlanKey)
          Update planKey in DeploymentVersion's related entities when plan key has changed (ie after moving plan)
 
Methods inherited from class com.atlassian.bamboo.persistence3.StatelessSessionHibernateDaoSupport
getCacheAwareHibernateTemplate
 
Methods inherited from class org.springframework.orm.hibernate.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

DeploymentVersionDaoImpl

public DeploymentVersionDaoImpl()
Method Detail

getResultPlanKeysHavingDeploymentProjectVersions

public java.util.List<java.lang.String> getResultPlanKeysHavingDeploymentProjectVersions(long deploymentProjectId)
Description copied from interface: DeploymentVersionDao
Returns keys of result plans (branch) that have at least one deployment project version (release)

Specified by:
getResultPlanKeysHavingDeploymentProjectVersions in interface DeploymentVersionDao
Parameters:
deploymentProjectId - id of the deployment project
Returns:

getDeploymentVersionsForDeploymentProject

@NotNull
public java.util.List<MutableDeploymentVersion> getDeploymentVersionsForDeploymentProject(long deploymentProjectId)
Description copied from interface: DeploymentVersionDao
Get MutableDeploymentVersion by DeploymentProject id

Specified by:
getDeploymentVersionsForDeploymentProject in interface DeploymentVersionDao

getDeploymentVersion

public MutableDeploymentVersion getDeploymentVersion(long deploymentVersionId)
Description copied from interface: DeploymentVersionDao
Get MutableDeploymentVersion by id

Specified by:
getDeploymentVersion in interface DeploymentVersionDao

save

public void save(@NotNull
                 MutableDeploymentVersion deploymentVersion)
MutableDeploymentVersionItem members of MutableDeploymentVersion.getItems() are persisted in a cascade

Specified by:
save in interface DeploymentVersionDao
Parameters:
deploymentVersion - MutableDeploymentVersion to be persisted

delete

public void delete(MutableDeploymentVersion deploymentVersion)
Description copied from interface: DeploymentVersionDao
Delete MutableDeploymentVersion

Specified by:
delete in interface DeploymentVersionDao

deleteForDeploymentProject

public int deleteForDeploymentProject(long deploymentProjectId)
Affected tables: - DEPLOYMENT_VERSION (manual, JDBC) - DEPLOYMENT_VERSION_ITEM (manual, JDBC) - DEPLOYMENT_VERSION_ITEM_BA (manual, JDBC) - DEPLOYMENT_PLANRESULTKEYS (manual, JDBC)

Specified by:
deleteForDeploymentProject in interface DeploymentVersionDao
Parameters:
deploymentProjectId - id of DeploymentProject
Returns:
number of deleted DeploymentVersion records

deleteVersionItems

public int deleteVersionItems(long deploymentVersionId)
Affected tables: - DEPLOYMENT_VERSION_ITEM (manual, JDBC) - DEPLOYMENT_VERSION_ITEM_BA (manual, JDBC)

Specified by:
deleteVersionItems in interface DeploymentVersionDao
Parameters:
deploymentVersionId - id of DeploymentVersion
Returns:
number of deleted DeploymentVersionItem records

findVersions

@NotNull
public java.util.List<MutableDeploymentVersion> findVersions(@NotNull
                                                                     DeploymentVersionSearchCriteria searchCriteria)
Description copied from interface: DeploymentVersionDao
Search for versions using search criteria

Specified by:
findVersions in interface DeploymentVersionDao
Parameters:
searchCriteria - search criteria
Returns:
list of versions that match the criteria

hasVersions

public boolean hasVersions(@NotNull
                           DeploymentVersionSearchCriteria searchCriteria)
Description copied from interface: DeploymentVersionDao
Test if versions that match criteria do exist

Specified by:
hasVersions in interface DeploymentVersionDao
Parameters:
searchCriteria - search criteria
Returns:
true if there are versions that match criteria

isVersionNameConflicting

public boolean isVersionNameConflicting(@NotNull
                                        java.lang.String name,
                                        long deploymentProjectId)
Description copied from interface: DeploymentVersionDao
Check whether the version name is already being used by another version within this project

Specified by:
isVersionNameConflicting in interface DeploymentVersionDao
Parameters:
name - to check
deploymentProjectId - project to filter by
Returns:
true if name is already being used.

getDeploymentVersionByName

@Nullable
public MutableDeploymentVersion getDeploymentVersionByName(@NotNull
                                                                    java.lang.String existingVersionName,
                                                                    long deploymentProjectId)
Description copied from interface: DeploymentVersionDao
Retrieve a specific version by name for a project

Specified by:
getDeploymentVersionByName in interface DeploymentVersionDao
Parameters:
existingVersionName - name of version to find
deploymentProjectId - of project to look in
Returns:
version with specified name in the given project. Null if could not be found.

findPreviousVersion

@Nullable
public MutableDeploymentVersion findPreviousVersion(long deploymentProjectId,
                                                             @NotNull
                                                             MutableDeploymentVersion deploymentVersion)
Description copied from interface: DeploymentVersionDao
Find the last version created before this one. If version is related to any DeploymentVersionPlanResultKey then previous version would also be related to the same plan key (so we can find previous version created off the same branch).

Specified by:
findPreviousVersion in interface DeploymentVersionDao

findLatestVersionForProject

@Nullable
public MutableDeploymentVersion findLatestVersionForProject(long deploymentProjectId)
Description copied from interface: DeploymentVersionDao
Find the latest version for a deployment project. Comparison based on creation date.

Specified by:
findLatestVersionForProject in interface DeploymentVersionDao
Parameters:
deploymentProjectId - id of the deployment project
Returns:
the latest version for a deployment project

findLatestVersionForProject

@Nullable
public MutableDeploymentVersion findLatestVersionForProject(long deploymentProjectId,
                                                                     @NotNull
                                                                     PlanKey branchKey)
Description copied from interface: DeploymentVersionDao
Find the latest version for a deployment project. Comparison based on creation date.

Specified by:
findLatestVersionForProject in interface DeploymentVersionDao
Parameters:
deploymentProjectId - id of the deployment project
branchKey - key of the PlanBranch
Returns:
the latest version created for a branch for a deployment project

getRelatedPlanResultKeys

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

getLatestVersionStatus

@Nullable
public MutableDeploymentVersionStatus getLatestVersionStatus(long deploymentVersionId)
Specified by:
getLatestVersionStatus in interface DeploymentVersionDao

createNewVersionStatus

@NotNull
public MutableDeploymentVersionStatus createNewVersionStatus(long deploymentVersionId,
                                                                     DeploymentVersionState state,
                                                                     @NotNull
                                                                     java.lang.String userName)
Description copied from interface: DeploymentVersionDao
Creates a new vesion status for the given deployment version.

Specified by:
createNewVersionStatus in interface DeploymentVersionDao

getRelatedVersion

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

Specified by:
getRelatedVersion in interface DeploymentVersionDao
Returns:

findNextVersionContainingResult

public MutableDeploymentVersion findNextVersionContainingResult(long deploymentProjectId,
                                                                @NotNull
                                                                PlanResultKey planResultKey)
Description copied from interface: DeploymentVersionDao
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 DeploymentVersionDao
Returns:

getVersionStatuses

@NotNull
public java.util.List<MutableDeploymentVersionStatus> getVersionStatuses(long deploymentVersionId)
Description copied from interface: DeploymentVersionDao
Get MutableDeploymentVersionStatuses by DeploymentVersion id

Specified by:
getVersionStatuses in interface DeploymentVersionDao

findVersionsBetween

public java.lang.Iterable<MutableDeploymentVersion> findVersionsBetween(long deploymentProjectId,
                                                                        long version1Id,
                                                                        long version2Id)
Description copied from interface: DeploymentVersionDao
Find versions created between version1 and version2. The order of the argument is irrelevant. 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 DeploymentVersionDao
Returns:

findVersionsAssociatedWithJiraIssue

@NotNull
public java.util.List<MutableDeploymentVersion> findVersionsAssociatedWithJiraIssue(long deploymentProjectId,
                                                                                            @NotNull
                                                                                            java.lang.String issueKey)
Description copied from interface: DeploymentVersionDao
Find all the versions of a DeploymentProject that are associated with a JIRA issue

Specified by:
findVersionsAssociatedWithJiraIssue in interface DeploymentVersionDao

findVersionsAssociatedWithJiraIssue

@NotNull
public java.util.List<MutableDeploymentVersion> findVersionsAssociatedWithJiraIssue(@NotNull
                                                                                            java.lang.String issueKey)
Description copied from interface: DeploymentVersionDao
Find all the versions that are associated with a JIRA issue

Specified by:
findVersionsAssociatedWithJiraIssue in interface DeploymentVersionDao

findLatestKnownVersionsForEnvironmentsOfDeploymentProject

public java.util.List<MutableDeploymentVersion> findLatestKnownVersionsForEnvironmentsOfDeploymentProject(long deploymentProjectId)
Description copied from interface: DeploymentVersionDao
Find all the versions that are currently deployed on environments of a deployment projects. Return duplicates if deployed on more than one environments.

Specified by:
findLatestKnownVersionsForEnvironmentsOfDeploymentProject in interface DeploymentVersionDao
Returns:

deleteVersionStatus

public int deleteVersionStatus(long deploymentVersionId)
Description copied from interface: DeploymentVersionDao
Delete DeploymentVersionStatus records related to a given version

Specified by:
deleteVersionStatus in interface DeploymentVersionDao
Parameters:
deploymentVersionId - id of the DeploymentVersion
Returns:
number of deleted DeploymentVersionStatus records

deleteVersionStatuses

public int deleteVersionStatuses(@NotNull
                                 DeploymentVersionDeletionAdapter deletionAdapter)
Description copied from interface: DeploymentVersionDao
Delete DeploymentVersionStatus records related to a given versions

Specified by:
deleteVersionStatuses in interface DeploymentVersionDao
Parameters:
deletionAdapter - DeletionSQLAdapter.getInClause() should provide range of DeploymentVersions to remove
Returns:
number of deleted DeploymentVersionStatus records

getVersionsCount

public int getVersionsCount()
Description copied from interface: DeploymentVersionDao
Count all versions

Specified by:
getVersionsCount in interface DeploymentVersionDao
Returns:
number of versions created in all deployment projects

getVersionsCountForProject

public int getVersionsCountForProject(long deploymentProjectId)
Description copied from interface: DeploymentVersionDao
Count versions related to deployment project

Specified by:
getVersionsCountForProject in interface DeploymentVersionDao
Parameters:
deploymentProjectId - id of deployment project
Returns:
number of versions existing for a deployment project

updatePlanKey

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

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


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