com.atlassian.jira.project.version
Class DefaultVersionManager

java.lang.Object
  extended by com.atlassian.jira.project.version.DefaultVersionManager
All Implemented Interfaces:
VersionManager

public class DefaultVersionManager
extends Object
implements VersionManager


Field Summary
protected  AssociationManager associationManager
           
protected  CollectionReorderer collectionReorderer
           
protected  IssueIndexManager issueIndexManager
           
protected  IssueManager issueManager
           
protected  ProjectManager projectManager
           
protected  VersionStore versionStore
           
 
Fields inherited from interface com.atlassian.jira.project.version.VersionManager
ALL_RELEASED_VERSIONS, ALL_UNRELEASED_VERSIONS, NO_VERSIONS
 
Constructor Summary
DefaultVersionManager(IssueManager issueManager, CollectionReorderer collectionReorderer, AssociationManager associationManager, IssueIndexManager issueIndexManager, ProjectManager projectManager, VersionStore versionStore)
           
 
Method Summary
 void archiveVersion(Version version, boolean archive)
          Archive/Un-archive a single version depending on the archive flag.
 void archiveVersions(String[] idsToArchive, String[] idsToUnarchive)
          Method used to archive and un-archive a number of versions.
 Version createVersion(String name, Date releaseDate, String description, org.ofbiz.core.entity.GenericValue project, Long scheduleAfterVersion)
           
 Version createVersion(String name, Date releaseDate, String description, Long projectId, Long scheduleAfterVersion)
          Creates a new Version object.
 void decreaseVersionSequence(Version version)
          Move a version to have a higher sequence number - ie make it later
 void deleteVersion(Version version)
          Removes a specific version from the system.
 void editVersionDetails(Version version, String name, String description)
          Updates details of an existing version.
 void editVersionDetails(Version version, String versionName, String description, org.ofbiz.core.entity.GenericValue project)
          Updates details for an existing version.
 void editVersionReleaseDate(Version version, Date duedate)
          Update the release date of a version.
 Collection<Version> getAffectedVersionsByIssue(org.ofbiz.core.entity.GenericValue issue)
           
 Collection<Version> getAffectedVersionsFor(Issue issue)
          Get all affected versions of the specified issue.
 Collection<org.ofbiz.core.entity.GenericValue> getAffectsIssues(Version version)
          Return 'Affects' Issues
 Collection<org.ofbiz.core.entity.GenericValue> getAllAffectedIssues(Collection<Version> versions)
          Return all Issues that are associated with the specified versions
 Collection<Version> getAllVersions()
           
 Collection<Version> getAllVersionsReleased(boolean includeArchived)
           
 Collection<Version> getAllVersionsUnreleased(boolean includeArchived)
           
 Collection<org.ofbiz.core.entity.GenericValue> getFixIssues(Version version)
          Return Fix Issues
 Collection<Version> getFixVersionsByIssue(org.ofbiz.core.entity.GenericValue issue)
           
 Collection<Version> getFixVersionsFor(Issue issue)
          Get all fix for versions of the specified issue.
protected  IssueFactory getIssueFactory()
          NB: This is done because we can't inject a IssueFactory, this would cause circular dependency.
 Collection<Issue> getIssuesWithAffectsVersion(Version version)
          Return all the issues in which the affected version matches the specified version.
 Collection<Issue> getIssuesWithFixVersion(Version version)
          Return all the issues in which the fix for version matches the specified version.
 Collection<Version> getOtherUnarchivedVersions(Version version)
          Return all unarchived versions except this one
 Collection<Version> getOtherVersions(Version version)
          Return all other versions in the project except this one
 Version getVersion(Long id)
          Returns a single version.
 Version getVersion(Long projectId, String versionName)
          Retrieve a specific Version in a project given the project id, or null if no such version exists in that project.
 List<Version> getVersions(org.ofbiz.core.entity.GenericValue project)
          Gets all the versions for a project.
 Collection<Version> getVersions(List<Long> ids)
          Return a collection of Versions matching the ids passed in.
 List<Version> getVersions(Long projectId)
          Return a list of Versions for the given project.
 List<Version> getVersions(Project project)
          Return a list of Versions for the given project.
 Collection<Version> getVersionsArchived(org.ofbiz.core.entity.GenericValue projectGV)
          Return all archived versions for a particular project.
 Collection<Version> getVersionsArchived(Project project)
          Return all archived versions for a particular project.
protected  Collection<Version> getVersionsByIssue(org.ofbiz.core.entity.GenericValue issue, String relationName)
           
 Collection<Version> getVersionsByName(String versionName)
          Return a collection of Versions that have the specified name.
 Collection<Version> getVersionsReleased(Long projectId, boolean includeArchived)
          Gets a list of released versions for a project.
 Collection<Version> getVersionsReleasedDesc(Long projectId, boolean includeArchived)
          Gets a list of released versions for a project in reverse order.
 Collection<Version> getVersionsUnarchived(Long projectId)
          Return all un-archived versions for a particular project
 Collection<Version> getVersionsUnreleased(Long projectId, boolean includeArchived)
          Gets a list of un-released versions for a particular project.
 void increaseVersionSequence(Version version)
          Move a version to have a lower sequence number - ie make it earlier
 boolean isDuplicateName(Version currentVersion, String name)
          Check that the version name we are changing to is not a duplicate.
 boolean isDuplicateName(Version currentVersion, String name, org.ofbiz.core.entity.GenericValue project)
          Checks if a version in the current project already exists with the same name
 boolean isVersionOverDue(Version version)
          Checks to see if a version is overdue.
 void moveIssuesToNewVersion(List issues, Version currentVersion, Version swapToVersion)
          Swaps the list of issues supplied from one Fix version to another.
 void moveToEndVersionSequence(Version version)
          Move a version to the end of the version sequence
 void moveToStartVersionSequence(Version version)
          Move a version to the start of the version list
 void moveVersionAfter(Version version, Long scheduleAfterVersionId)
          Move a version after another version
 void releaseVersion(Version version, boolean release)
          Used to release or unrelease a version, depending on the release flag.
 void releaseVersions(Collection<Version> versions, boolean release)
          Used to release versions depending on the release flag.
 void storeReorderedVersionList(List<Version> versions)
          Given a re-ordered list of versions, commit the changes to the backend datastore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

issueManager

protected final IssueManager issueManager

collectionReorderer

protected final CollectionReorderer collectionReorderer

associationManager

protected final AssociationManager associationManager

issueIndexManager

protected final IssueIndexManager issueIndexManager

projectManager

protected final ProjectManager projectManager

versionStore

protected final VersionStore versionStore
Constructor Detail

DefaultVersionManager

public DefaultVersionManager(IssueManager issueManager,
                             CollectionReorderer collectionReorderer,
                             AssociationManager associationManager,
                             IssueIndexManager issueIndexManager,
                             ProjectManager projectManager,
                             VersionStore versionStore)
Method Detail

createVersion

public Version createVersion(String name,
                             Date releaseDate,
                             String description,
                             org.ofbiz.core.entity.GenericValue project,
                             Long scheduleAfterVersion)
                      throws CreateException
Throws:
CreateException

createVersion

public Version createVersion(String name,
                             Date releaseDate,
                             String description,
                             Long projectId,
                             Long scheduleAfterVersion)
                      throws CreateException
Description copied from interface: VersionManager
Creates a new Version object.

Specified by:
createVersion in interface VersionManager
Parameters:
name - the Name
releaseDate - date of release or null if not released.
description - the Description
projectId - the id of the Project of the version.
scheduleAfterVersion - id of the version after which this should be sequenced or null.
Returns:
the new Version.
Throws:
CreateException - If there was a problem creating the version.

moveToStartVersionSequence

public void moveToStartVersionSequence(Version version)
Description copied from interface: VersionManager
Move a version to the start of the version list

Specified by:
moveToStartVersionSequence in interface VersionManager
Parameters:
version - the Version to move

increaseVersionSequence

public void increaseVersionSequence(Version version)
Description copied from interface: VersionManager
Move a version to have a lower sequence number - ie make it earlier

Specified by:
increaseVersionSequence in interface VersionManager
Parameters:
version - the Version

decreaseVersionSequence

public void decreaseVersionSequence(Version version)
Description copied from interface: VersionManager
Move a version to have a higher sequence number - ie make it later

Specified by:
decreaseVersionSequence in interface VersionManager
Parameters:
version - the Version

moveToEndVersionSequence

public void moveToEndVersionSequence(Version version)
Description copied from interface: VersionManager
Move a version to the end of the version sequence

Specified by:
moveToEndVersionSequence in interface VersionManager
Parameters:
version - the Version

moveVersionAfter

public void moveVersionAfter(Version version,
                             Long scheduleAfterVersionId)
Description copied from interface: VersionManager
Move a version after another version

Specified by:
moveVersionAfter in interface VersionManager
Parameters:
version - version to reschedule
scheduleAfterVersionId - id of the version to schedule after the given version object

deleteVersion

public void deleteVersion(Version version)
Description copied from interface: VersionManager
Removes a specific version from the system.

Specified by:
deleteVersion in interface VersionManager
Parameters:
version - The version to be removed.

editVersionDetails

public void editVersionDetails(Version version,
                               String name,
                               String description)
Description copied from interface: VersionManager
Updates details of an existing version.

Specified by:
editVersionDetails in interface VersionManager
Parameters:
version - The version to update
name - The new version name, cannot be empty.
description - The description of this version.

editVersionDetails

public void editVersionDetails(Version version,
                               String versionName,
                               String description,
                               org.ofbiz.core.entity.GenericValue project)
Description copied from interface: VersionManager
Updates details for an existing version.

Specified by:
editVersionDetails in interface VersionManager
Parameters:
version - The version to update
versionName - new name
description - new description
project - Used to check for duplicate version names in a project.

releaseVersion

public void releaseVersion(Version version,
                           boolean release)
Description copied from interface: VersionManager
Used to release or unrelease a version, depending on the release flag.

Specified by:
releaseVersion in interface VersionManager
Parameters:
version - Version to be released (or unreleased)
release - True to release a version. False to 'unrelease' a version

releaseVersions

public void releaseVersions(Collection<Version> versions,
                            boolean release)
Description copied from interface: VersionManager
Used to release versions depending on the release flag.

Specified by:
releaseVersions in interface VersionManager
Parameters:
versions - Collection of Versions
release - True to release a version. False to 'unrelease' a version

moveIssuesToNewVersion

public void moveIssuesToNewVersion(List issues,
                                   Version currentVersion,
                                   Version swapToVersion)
                            throws IndexException
Description copied from interface: VersionManager
Swaps the list of issues supplied from one Fix version to another.

Specified by:
moveIssuesToNewVersion in interface VersionManager
Parameters:
issues - the Issues
currentVersion - Current fix version they will be swapped from
swapToVersion - New fix version they will be swapped to.
Throws:
IndexException - if an error occurs will indexing these new issue values.

archiveVersions

public void archiveVersions(String[] idsToArchive,
                            String[] idsToUnarchive)
Description copied from interface: VersionManager
Method used to archive and un-archive a number of versions.

Specified by:
archiveVersions in interface VersionManager
Parameters:
idsToArchive - Archive all these Versions
idsToUnarchive - Unarchive these Versions

archiveVersion

public void archiveVersion(Version version,
                           boolean archive)
Description copied from interface: VersionManager
Archive/Un-archive a single version depending on the archive flag.

Specified by:
archiveVersion in interface VersionManager
Parameters:
version - the Version to archive or unarchive
archive - new archive value

editVersionReleaseDate

public void editVersionReleaseDate(Version version,
                                   Date duedate)
Description copied from interface: VersionManager
Update the release date of a version.

Specified by:
editVersionReleaseDate in interface VersionManager
Parameters:
version - the Version to edit
duedate - new release date

isVersionOverDue

public boolean isVersionOverDue(Version version)
Description copied from interface: VersionManager
Checks to see if a version is overdue. Note: This method checks if the due date set for a version is previous to last midnight. (not now()).

Specified by:
isVersionOverDue in interface VersionManager
Parameters:
version - the Version
Returns:
True if the version is overdue. (i.e. releaseDate is before last midnight)

getVersionsUnarchived

public Collection<Version> getVersionsUnarchived(Long projectId)
Description copied from interface: VersionManager
Return all un-archived versions for a particular project

Specified by:
getVersionsUnarchived in interface VersionManager
Parameters:
projectId - id of the project.
Returns:
A collection of Versions

getVersionsArchived

public Collection<Version> getVersionsArchived(org.ofbiz.core.entity.GenericValue projectGV)
Description copied from interface: VersionManager
Return all archived versions for a particular project.

Specified by:
getVersionsArchived in interface VersionManager
Parameters:
projectGV - the Project
Returns:
A collections of Versions

getVersionsArchived

public Collection<Version> getVersionsArchived(Project project)
Description copied from interface: VersionManager
Return all archived versions for a particular project.

Specified by:
getVersionsArchived in interface VersionManager
Parameters:
project - the Project
Returns:
Archived versions for this project.

getVersions

public List<Version> getVersions(org.ofbiz.core.entity.GenericValue project)
Description copied from interface: VersionManager
Gets all the versions for a project.

Specified by:
getVersions in interface VersionManager
Parameters:
project - the Project
Returns:
a List of Version objects.

getVersions

public List<Version> getVersions(Long projectId)
Description copied from interface: VersionManager
Return a list of Versions for the given project.

Specified by:
getVersions in interface VersionManager
Parameters:
projectId - the Project
Returns:
a list of Versions for the given project.
See Also:
VersionManager.getVersions(Project)

getVersions

public List<Version> getVersions(Project project)
Description copied from interface: VersionManager
Return a list of Versions for the given project.

Specified by:
getVersions in interface VersionManager
Parameters:
project - the Project
Returns:
a list of Versions for the given project.
See Also:
VersionManager.getVersions(Long)

getVersionsByName

public Collection<Version> getVersionsByName(String versionName)
Description copied from interface: VersionManager
Return a collection of Versions that have the specified name.

Specified by:
getVersionsByName in interface VersionManager
Parameters:
versionName - the name of the version (case-insensitive)
Returns:
a Collection of Version objects. Never null.

getAffectedVersionsByIssue

public Collection<Version> getAffectedVersionsByIssue(org.ofbiz.core.entity.GenericValue issue)
Specified by:
getAffectedVersionsByIssue in interface VersionManager
Parameters:
issue - the Issue
Returns:
A collection of 'affects' Versions for an issue.

getAffectedVersionsFor

public Collection<Version> getAffectedVersionsFor(Issue issue)
Description copied from interface: VersionManager
Get all affected versions of the specified issue.

Specified by:
getAffectedVersionsFor in interface VersionManager
Parameters:
issue - the issue
Returns:
all affected versions of the specified issue.

getFixVersionsByIssue

public Collection<Version> getFixVersionsByIssue(org.ofbiz.core.entity.GenericValue issue)
Specified by:
getFixVersionsByIssue in interface VersionManager
Parameters:
issue - the Issue
Returns:
A collection of 'fix for' Versions for an issue.

getFixVersionsFor

public Collection<Version> getFixVersionsFor(Issue issue)
Description copied from interface: VersionManager
Get all fix for versions of the specified issue.

Specified by:
getFixVersionsFor in interface VersionManager
Parameters:
issue - the Issue
Returns:
all fix for versions of the specified issue.

getAllVersions

public Collection<Version> getAllVersions()
Specified by:
getAllVersions in interface VersionManager
Returns:
all versions in JIRA. Never null.

getAllVersionsReleased

public Collection<Version> getAllVersionsReleased(boolean includeArchived)
Specified by:
getAllVersionsReleased in interface VersionManager
Parameters:
includeArchived - whether or not to include archived versions
Returns:
all released versions in JIRA. Never null.

getAllVersionsUnreleased

public Collection<Version> getAllVersionsUnreleased(boolean includeArchived)
Specified by:
getAllVersionsUnreleased in interface VersionManager
Parameters:
includeArchived - whether or not to include archived versions
Returns:
all released versions in JIRA. Never null.

getVersionsByIssue

protected Collection<Version> getVersionsByIssue(org.ofbiz.core.entity.GenericValue issue,
                                                 String relationName)
Parameters:
issue - the issue
relationName - IssueRelationConstants.VERSION or IssueRelationConstants.FIX_VERSION.
Returns:
A collection of Versions for this issue.

getVersions

public Collection<Version> getVersions(List<Long> ids)
Description copied from interface: VersionManager
Return a collection of Versions matching the ids passed in.

Specified by:
getVersions in interface VersionManager
Parameters:
ids - Version IDs
Returns:
a collection of Versions matching the ids passed in.

getVersionsUnreleased

public Collection<Version> getVersionsUnreleased(Long projectId,
                                                 boolean includeArchived)
Description copied from interface: VersionManager
Gets a list of un-released versions for a particular project.

Specified by:
getVersionsUnreleased in interface VersionManager
Parameters:
projectId - The id of the project for which to return versions
includeArchived - True if archived versions should be included
Returns:
A Collection of Versions, never null

getVersionsReleased

public Collection<Version> getVersionsReleased(Long projectId,
                                               boolean includeArchived)
Description copied from interface: VersionManager
Gets a list of released versions for a project. This list will include archived versions if the 'includeArchived' flag is set to true.

Specified by:
getVersionsReleased in interface VersionManager
Parameters:
projectId - project id
includeArchived - flag to indicate whether to include archived versions in the result.
Returns:
A collection of Version objects

getVersionsReleasedDesc

public Collection<Version> getVersionsReleasedDesc(Long projectId,
                                                   boolean includeArchived)
Description copied from interface: VersionManager
Gets a list of released versions for a project in reverse order. This list will include archived versions if the 'includeArchived' flag is set to true.

Specified by:
getVersionsReleasedDesc in interface VersionManager
Parameters:
projectId - project id
includeArchived - flag to indicate whether to include archived versions in the result.
Returns:
A collection of Version objects

getVersion

public Version getVersion(Long id)
Description copied from interface: VersionManager
Returns a single version.

Specified by:
getVersion in interface VersionManager
Parameters:
id - the Version ID
Returns:
A Version object.

getVersion

public Version getVersion(Long projectId,
                          String versionName)
Retrieve a specific Version in a project given the project id, or null if no such version exists in that project.

Specified by:
getVersion in interface VersionManager
Parameters:
projectId - the Project
versionName - the Version name
Returns:
A Version object.

getAllAffectedIssues

public Collection<org.ofbiz.core.entity.GenericValue> getAllAffectedIssues(Collection<Version> versions)
Description copied from interface: VersionManager
Return all Issues that are associated with the specified versions

Specified by:
getAllAffectedIssues in interface VersionManager
Parameters:
versions - a collection of Version objects
Returns:
A collection of issue GenericValues

getIssueFactory

protected IssueFactory getIssueFactory()
NB: This is done because we can't inject a IssueFactory, this would cause circular dependency.


getOtherVersions

public Collection<Version> getOtherVersions(Version version)
Return all other versions in the project except this one

Specified by:
getOtherVersions in interface VersionManager
Parameters:
version - the Version
Returns:
all other versions in the project except this one

getOtherUnarchivedVersions

public Collection<Version> getOtherUnarchivedVersions(Version version)
Return all unarchived versions except this one

Specified by:
getOtherUnarchivedVersions in interface VersionManager
Parameters:
version - the Version
Returns:
all unarchived versions except this one

getFixIssues

public Collection<org.ofbiz.core.entity.GenericValue> getFixIssues(Version version)
Description copied from interface: VersionManager
Return Fix Issues

Specified by:
getFixIssues in interface VersionManager
Parameters:
version - the Version
Returns:
A collection of issue GenericValues

getIssuesWithFixVersion

public Collection<Issue> getIssuesWithFixVersion(Version version)
Description copied from interface: VersionManager
Return all the issues in which the fix for version matches the specified version.

Specified by:
getIssuesWithFixVersion in interface VersionManager
Parameters:
version - the fixed for version.
Returns:
all the issues in which the fix for version matches the specified version.

getAffectsIssues

public Collection<org.ofbiz.core.entity.GenericValue> getAffectsIssues(Version version)
Description copied from interface: VersionManager
Return 'Affects' Issues

Specified by:
getAffectsIssues in interface VersionManager
Parameters:
version - the Version
Returns:
A collection of issue GenericValues

getIssuesWithAffectsVersion

public Collection<Issue> getIssuesWithAffectsVersion(Version version)
Description copied from interface: VersionManager
Return all the issues in which the affected version matches the specified version.

Specified by:
getIssuesWithAffectsVersion in interface VersionManager
Parameters:
version - the affected version.
Returns:
all the issues in which the affected version matches the specified version.

isDuplicateName

public boolean isDuplicateName(Version currentVersion,
                               String name)
Description copied from interface: VersionManager
Check that the version name we are changing to is not a duplicate.

Specified by:
isDuplicateName in interface VersionManager
Parameters:
currentVersion - The version to update
name - The new name for the version
Returns:
true if there is already a version with that name for the project

isDuplicateName

public boolean isDuplicateName(Version currentVersion,
                               String name,
                               org.ofbiz.core.entity.GenericValue project)
Checks if a version in the current project already exists with the same name

Specified by:
isDuplicateName in interface VersionManager
Parameters:
currentVersion - The version to update
name - The new name for the version
project - Used to check for duplicate version names in a project.
Returns:
true if there is already a version with that name for the project

storeReorderedVersionList

public void storeReorderedVersionList(List<Version> versions)
Given a re-ordered list of versions, commit the changes to the backend datastore.



Copyright © 2002-2012 Atlassian. All Rights Reserved.