com.atlassian.jira.project
Class CachingProjectManager

java.lang.Object
  extended by com.atlassian.jira.project.AbstractProjectManager
      extended by com.atlassian.jira.project.CachingProjectManager
All Implemented Interfaces:
Startable, ProjectManager

public class CachingProjectManager
extends AbstractProjectManager
implements Startable


Constructor Summary
protected CachingProjectManager(ProjectManager delegateProjectManager, ProjectComponentManager projectComponentManager, boolean updateCache)
          This constructor is to allow test cases to fire up a caching project manager without instantiating the internal project cache.
  CachingProjectManager(ProjectManager delegateProjectManager, ProjectComponentManager projectComponentManager, ProjectFactory projectFactory, com.atlassian.event.api.EventPublisher eventPublisher)
          Normal constructor.
 
Method Summary
 Project createProject(java.lang.String name, java.lang.String key, java.lang.String description, java.lang.String lead, java.lang.String url, java.lang.Long assigneeType, java.lang.Long avatarId)
          Creates the project in the database, and adds default project roles for this project.
 ProjectCache getCache()
           
 org.ofbiz.core.entity.GenericValue getComponent(org.ofbiz.core.entity.GenericValue project, java.lang.String name)
          Deprecated. use ProjectComponentManager and ProjectComponent
 org.ofbiz.core.entity.GenericValue getComponent(java.lang.Long id)
          Deprecated. use ProjectComponentManager and ProjectComponent
 java.util.Collection getComponents(org.ofbiz.core.entity.GenericValue project)
          Deprecated. use ProjectComponentManager and ProjectComponent
 long getNextId(org.ofbiz.core.entity.GenericValue project)
          Get the next issue ID from this project (transactional).
 long getNextId(Project project)
          Get the next issue ID from this project (transactional).
 org.ofbiz.core.entity.GenericValue getProject(java.lang.Long id)
          Retrieve a single project by it's id.
 org.ofbiz.core.entity.GenericValue getProjectByKey(java.lang.String key)
          Retrieve a single project by it's project key.
 org.ofbiz.core.entity.GenericValue getProjectByName(java.lang.String name)
          Retrieve a single project by it's project name.
 java.util.Collection getProjectCategories()
          Get all ProjectCategories.
 org.ofbiz.core.entity.GenericValue getProjectCategory(java.lang.Long id)
          Returns a single project category by id.
 org.ofbiz.core.entity.GenericValue getProjectCategoryFromProject(org.ofbiz.core.entity.GenericValue project)
          Returns a project's category.
 Project getProjectObj(java.lang.Long id)
          Retrieves a single Project by its id.
 Project getProjectObjByKey(java.lang.String projectKey)
          Returns a Project object based on the passed in project key.
 Project getProjectObjByKeyIgnoreCase(java.lang.String projectKey)
          Returns a Project object based ont he passed in project key, not taking into account the case of the project key.
 Project getProjectObjByName(java.lang.String projectName)
          Returns a Project object based on the passed in project name.
 java.util.List<Project> getProjectObjects()
          Return all Projects ordered by name.
 java.util.Collection<Project> getProjectObjectsFromProjectCategory(java.lang.Long projectCategoryId)
          Returns a list of projects in a particular category.
 java.util.Collection<Project> getProjectObjectsWithNoCategory()
          Returns a list of projects without project category, sorted by project name
 java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjects()
          Return all project GenericValues.
 java.util.Collection getProjectsByLead(com.opensymphony.user.User leadUser)
          Returns all the projects that leadUser is the project lead for.
 java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjectsFromProjectCategory(org.ofbiz.core.entity.GenericValue projectCategory)
          Returns a list of projects in a particular category.
 java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjectsWithNoCategory()
          Returns a list of projects without project category, sorted by project name
protected  java.util.Collection noNull(java.util.Collection col)
           
 void onClearCache(ClearCacheEvent event)
           
 void refresh()
          Causes a full refresh of the project cache.
 void refreshProjectDependencies(org.ofbiz.core.entity.GenericValue project)
          This will refresh the dependencies of a project.
 void removeProject(Project project)
          Deletes the provided project from the database.
 void removeProjectIssues(Project project)
          Removes all issues for a particular project.
 void setProjectCategory(org.ofbiz.core.entity.GenericValue project, org.ofbiz.core.entity.GenericValue category)
          Sets a projects category.
 void start()
          This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.
 void updateCache()
           
 void updateProject(org.ofbiz.core.entity.GenericValue updatedProject)
          Persists a project GenericValue to the database.
 Project updateProject(Project updatedProject, java.lang.String name, java.lang.String description, java.lang.String lead, java.lang.String url, java.lang.Long assigneeType, java.lang.Long avatarId)
          Updates the project provided with the new attributes passed in.
 void updateProjectCategory(org.ofbiz.core.entity.GenericValue projectCat)
          Persist an updated project category.
 
Methods inherited from class com.atlassian.jira.project.AbstractProjectManager
convertToProjects, createProject, getComponents, getDefaultAssignee, getProject, getProjectCategoryByName, getProjectCategoryByNameIgnoreCase, isDefaultAssignee, isDefaultAssignee, updateProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingProjectManager

public CachingProjectManager(ProjectManager delegateProjectManager,
                             ProjectComponentManager projectComponentManager,
                             ProjectFactory projectFactory,
                             com.atlassian.event.api.EventPublisher eventPublisher)
Normal constructor.

Parameters:
delegateProjectManager - The ProjectManager to delegate to.
eventPublisher -

CachingProjectManager

protected CachingProjectManager(ProjectManager delegateProjectManager,
                                ProjectComponentManager projectComponentManager,
                                boolean updateCache)
This constructor is to allow test cases to fire up a caching project manager without instantiating the internal project cache.

Parameters:
delegateProjectManager - The ProjectManager to delegate to.
updateCache - Whether to instantiate a ProjectCache.
Method Detail

start

public void start()
           throws java.lang.Exception
Description copied from interface: Startable
This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.

Specified by:
start in interface Startable
Throws:
java.lang.Exception - Allows implementations to throw an Exception.

onClearCache

@EventListener
public void onClearCache(ClearCacheEvent event)

updateCache

public void updateCache()

getNextId

public long getNextId(Project project)
Description copied from interface: ProjectManager
Get the next issue ID from this project (transactional). Each project maintains an internal counter for the number of issues. This method may be used to construct a new issue key.

Specified by:
getNextId in interface ProjectManager
Overrides:
getNextId in class AbstractProjectManager
Parameters:
project - The Project
Returns:
A long value representing a new issue id for the project.

getNextId

public long getNextId(org.ofbiz.core.entity.GenericValue project)
Description copied from interface: ProjectManager
Get the next issue ID from this project (transactional). Each project maintains an internal counter for the number of issues. This method may be used to construct a new issue key.

Specified by:
getNextId in interface ProjectManager
Parameters:
project - project GenericValue
Returns:
A long value representing a new issue id for the project.

refreshProjectDependencies

public void refreshProjectDependencies(org.ofbiz.core.entity.GenericValue project)
Description copied from interface: ProjectManager
This will refresh the dependencies of a project. Please do not use this to refresh the passed in project in the project cache. use ProjectManager.refresh()

Specified by:
refreshProjectDependencies in interface ProjectManager
Parameters:
project - project GenericValue

refresh

public void refresh()
Description copied from interface: ProjectManager
Causes a full refresh of the project cache.

Specified by:
refresh in interface ProjectManager

getProject

public org.ofbiz.core.entity.GenericValue getProject(java.lang.Long id)
Description copied from interface: ProjectManager
Retrieve a single project by it's id.

Specified by:
getProject in interface ProjectManager
Parameters:
id - the Project ID.
Returns:
GenericValue representation of a Project.

getProjectObj

public Project getProjectObj(java.lang.Long id)
Description copied from interface: ProjectManager
Retrieves a single Project by its id.

Specified by:
getProjectObj in interface ProjectManager
Parameters:
id - ID of the Project.
Returns:
Project object or null if project with that id doesn't exist.

getProjectByName

public org.ofbiz.core.entity.GenericValue getProjectByName(java.lang.String name)
Description copied from interface: ProjectManager
Retrieve a single project by it's project name.

Specified by:
getProjectByName in interface ProjectManager
Parameters:
name - project name
Returns:
GenericValue representation of a Project.

getProjectByKey

public org.ofbiz.core.entity.GenericValue getProjectByKey(java.lang.String key)
Description copied from interface: ProjectManager
Retrieve a single project by it's project key.

Specified by:
getProjectByKey in interface ProjectManager
Parameters:
key - the project key
Returns:
GenericValue representation of a Project.

getProjectObjByKey

public Project getProjectObjByKey(java.lang.String projectKey)
Description copied from interface: ProjectManager
Returns a Project object based on the passed in project key.

Specified by:
getProjectObjByKey in interface ProjectManager
Parameters:
projectKey - the Project key.
Returns:
the Project object specified by the key or null

getProjectObjByKeyIgnoreCase

public Project getProjectObjByKeyIgnoreCase(java.lang.String projectKey)
Description copied from interface: ProjectManager
Returns a Project object based ont he passed in project key, not taking into account the case of the project key.

Specified by:
getProjectObjByKeyIgnoreCase in interface ProjectManager
Parameters:
projectKey - the project key, case does not matter.
Returns:
the project object specified by the key or null if not such project exists.

getProjectObjByName

public Project getProjectObjByName(java.lang.String projectName)
Description copied from interface: ProjectManager
Returns a Project object based on the passed in project name.

Specified by:
getProjectObjByName in interface ProjectManager
Parameters:
projectName - the name of the project
Returns:
the Project object specified by the supplied name or null

getComponent

public org.ofbiz.core.entity.GenericValue getComponent(org.ofbiz.core.entity.GenericValue project,
                                                       java.lang.String name)
Deprecated. use ProjectComponentManager and ProjectComponent

Retrieves the Component with the given name in the given Project or null if none match.

Specified by:
getComponent in interface ProjectManager
Parameters:
project - the Project.
name - the Component name.
Returns:
the Component as a GenericValue or null if there is no match.
See Also:
ProjectComponentManager.findByComponentName(java.lang.Long, java.lang.String)

getComponent

public org.ofbiz.core.entity.GenericValue getComponent(java.lang.Long id)
Deprecated. use ProjectComponentManager and ProjectComponent

Retrieves the Component (as a GenericValue) with the given id or null if none match.

Specified by:
getComponent in interface ProjectManager
Parameters:
id - the id of the component to retrieve
Returns:
the Component as a GenericValue or null if there is no match.
See Also:
ProjectComponentManager.find(Long)

getComponents

public java.util.Collection getComponents(org.ofbiz.core.entity.GenericValue project)
Deprecated. use ProjectComponentManager and ProjectComponent

Retrieve the collection of Components (as GenericValues) associated with the specified project.

Specified by:
getComponents in interface ProjectManager
Parameters:
project - the project (as a GenericValue) used to search on
Returns:
collection of components (as GenericValues) or null if there is no match.
See Also:
ProjectComponentManager.findAllForProject(java.lang.Long)

getProjects

public java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjects()
Description copied from interface: ProjectManager
Return all project GenericValues.

Specified by:
getProjects in interface ProjectManager
Returns:
all projects as Collection

getProjectObjects

public java.util.List<Project> getProjectObjects()
Description copied from interface: ProjectManager
Return all Projects ordered by name.

Specified by:
getProjectObjects in interface ProjectManager
Returns:
all projects ordered by name.

noNull

protected java.util.Collection noNull(java.util.Collection col)

createProject

public Project createProject(java.lang.String name,
                             java.lang.String key,
                             java.lang.String description,
                             java.lang.String lead,
                             java.lang.String url,
                             java.lang.Long assigneeType,
                             java.lang.Long avatarId)
Description copied from interface: ProjectManager
Creates the project in the database, and adds default project roles for this project. If no name, key or lead are provided an exception will be thrown.

Specified by:
createProject in interface ProjectManager
Parameters:
name - The name of the new project
key - The project key of the new project
description - An optional description for the project
lead - The lead developer for the project
url - An optional URL for the new project
assigneeType - The default assignee for issues created in this project. May be either project lead, or unassigned if unassigned issues are enabled.
avatarId - the id of an existing system avatar.
Returns:
The newly created project.

updateProject

public void updateProject(org.ofbiz.core.entity.GenericValue updatedProject)
Description copied from interface: ProjectManager
Persists a project GenericValue to the database.

Specified by:
updateProject in interface ProjectManager
Parameters:
updatedProject - Project details to update.

updateProject

public Project updateProject(Project updatedProject,
                             java.lang.String name,
                             java.lang.String description,
                             java.lang.String lead,
                             java.lang.String url,
                             java.lang.Long assigneeType,
                             java.lang.Long avatarId)
Description copied from interface: ProjectManager
Updates the project provided with the new attributes passed in. This method is responsible for persisting any changes to the database.

Specified by:
updateProject in interface ProjectManager
Parameters:
updatedProject - The project to be updated.
name - The name for the updated project
description - An optional description for the project
lead - The lead developer for the project
url - An optional URL for the updated project
assigneeType - The default assignee for issues created in this project. May be either project lead, or unassigned if unassigned issues are enabled.
avatarId - the id of an existing avatar.
Returns:
The updated project

removeProjectIssues

public void removeProjectIssues(Project project)
                         throws RemoveException
Description copied from interface: ProjectManager
Removes all issues for a particular project. A RemoveException will be thrown on any errors removing issues.

Specified by:
removeProjectIssues in interface ProjectManager
Parameters:
project - The project for which issues will be deleted.
Throws:
RemoveException - if there's any errors removing issues

removeProject

public void removeProject(Project project)
Description copied from interface: ProjectManager
Deletes the provided project from the database. Please note that this method only deletes the project itself and not any related entities. Use ProjectService.deleteProject(com.opensymphony.user.User, com.atlassian.jira.bc.project.ProjectService.DeleteProjectValidationResult) to properly delete a project.

Specified by:
removeProject in interface ProjectManager
Parameters:
project - The project to be deleted.

getProjectCategories

public java.util.Collection getProjectCategories()
Description copied from interface: ProjectManager
Get all ProjectCategories.

Specified by:
getProjectCategories in interface ProjectManager
Returns:
A collection of category GenericValues

getProjectCategory

public org.ofbiz.core.entity.GenericValue getProjectCategory(java.lang.Long id)
Description copied from interface: ProjectManager
Returns a single project category by id.

Specified by:
getProjectCategory in interface ProjectManager
Parameters:
id - Project Category ID.
Returns:
A category GenericValue

updateProjectCategory

public void updateProjectCategory(org.ofbiz.core.entity.GenericValue projectCat)
Description copied from interface: ProjectManager
Persist an updated project category.

Specified by:
updateProjectCategory in interface ProjectManager
Parameters:
projectCat - project category.

getProjectsFromProjectCategory

public java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjectsFromProjectCategory(org.ofbiz.core.entity.GenericValue projectCategory)
Description copied from interface: ProjectManager
Returns a list of projects in a particular category.

Specified by:
getProjectsFromProjectCategory in interface ProjectManager
Parameters:
projectCategory - project category.
Returns:
A collection of project GenericValues sorted by name.

getProjectObjectsFromProjectCategory

public java.util.Collection<Project> getProjectObjectsFromProjectCategory(java.lang.Long projectCategoryId)
Description copied from interface: ProjectManager
Returns a list of projects in a particular category.

Specified by:
getProjectObjectsFromProjectCategory in interface ProjectManager
Parameters:
projectCategoryId - project category id.
Returns:
A collection of project Projects sorted by name.

getProjectCategoryFromProject

public org.ofbiz.core.entity.GenericValue getProjectCategoryFromProject(org.ofbiz.core.entity.GenericValue project)
Description copied from interface: ProjectManager
Returns a project's category.

Specified by:
getProjectCategoryFromProject in interface ProjectManager
Parameters:
project - project
Returns:
A category GenericValue or null if no category exists.

getProjectsWithNoCategory

public java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjectsWithNoCategory()
Description copied from interface: ProjectManager
Returns a list of projects without project category, sorted by project name

Specified by:
getProjectsWithNoCategory in interface ProjectManager
Returns:
A collection of project GenericValues sorted by name

getProjectObjectsWithNoCategory

public java.util.Collection<Project> getProjectObjectsWithNoCategory()
                                                              throws DataAccessException
Description copied from interface: ProjectManager
Returns a list of projects without project category, sorted by project name

Specified by:
getProjectObjectsWithNoCategory in interface ProjectManager
Returns:
A collection of Projects sorted by name
Throws:
DataAccessException - If any errors occur accessing the DB.

setProjectCategory

public void setProjectCategory(org.ofbiz.core.entity.GenericValue project,
                               org.ofbiz.core.entity.GenericValue category)
Description copied from interface: ProjectManager
Sets a projects category.

Specified by:
setProjectCategory in interface ProjectManager
Parameters:
project - project
category - category

getProjectsByLead

public java.util.Collection getProjectsByLead(com.opensymphony.user.User leadUser)
Description copied from interface: ProjectManager
Returns all the projects that leadUser is the project lead for.

Specified by:
getProjectsByLead in interface ProjectManager
Parameters:
leadUser - Project Lead
Returns:
A collection of project GenericValues TODO: deprecate this method.

getCache

public ProjectCache getCache()


Copyright © 2002-2011 Atlassian. All Rights Reserved.