com.atlassian.bamboo.plan
Class PlanHibernateDao<T extends Plan>

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate.support.HibernateDaoSupport
          extended by com.atlassian.bamboo.persistence3.BambooHibernateObjectDao<Plan>
              extended by com.atlassian.bamboo.plan.PlanHibernateDao<T>
All Implemented Interfaces:
BambooObjectDao<Plan>, PlanDao, org.springframework.beans.factory.InitializingBean

public class PlanHibernateDao<T extends Plan>
extends BambooHibernateObjectDao<Plan>
implements PlanDao


Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
PlanHibernateDao()
           
 
Method Summary
 java.util.Set<ImmutableChain> filterFavouritedPlans(java.util.Collection<? extends ImmutableChain> plans, com.atlassian.user.User user)
          Return a collection of TopLevelPlans that are a subset of the given Plans collection that are favourited by the User
<T extends Plan>
java.util.List<T>
findAllPlans(java.lang.Class<T> planType)
          Return a Plan collection for specified plan type.
<T extends Plan>
java.util.List<T>
findAllPlansByProject(Project project, java.lang.Class<T> planType)
          Return a Plan collection for specified Project, including plans marked for deletion.
<E extends Plan>
E
findById(long id, java.lang.Class<E> aClass)
          Find an entity by its id
<T extends Plan>
java.util.List<T>
findPlansByProject(Project project, java.lang.Class<T> planType)
          Return a Plan collection for specified Project
<T extends Plan>
java.util.Collection<T>
getAllPlansMarkedForDeletion(java.lang.Class<T> planType)
          Returns a list of Plans that are com.atlassian.bamboo.plan.Plan#markForDeletion() for the given type
 int getBranchCount(Plan plan)
          Returns the number of branches that exist for the given plan
 java.util.List<Pair<java.lang.Long,java.lang.Integer>> getBranchesCount()
          Returns the number of branches that exist for master plans in Bamboo.
 java.util.List<ChainBranch> getBranchesForChain(ImmutableChain chain)
          Returns all branches which have the given chain as their master
 java.util.List<ChainBranchIdentifier> getBranchIdentifiersForChain(PlanIdentifier plan)
          Returns minimal data about all branches which have the given chain as their master
<T extends Plan>
T
getPlanByKey(java.lang.String planKey, java.lang.Class<T> aClass)
          Return a Plan that matches the given key
<T extends Plan>
T
getPlanByName(java.lang.String projectKey, java.lang.String planName, java.lang.Class<T> planType)
          Returns a Plan from a project with the given plan name and Class It is not possible to use this method if the planType parameter is a marker interface type such as Plan, Buildable or TopLevelPlan since it is possible to have a Chain and a Job that share the same name.
<T extends Plan>
T
getPlanByPartialKeyAndName(PlanKey partialPlanKey, java.lang.String planName, java.lang.Class<T> planType)
          Returns a Plan that matches the start of the given PlanKey and name
 java.lang.Class<? extends Plan> getPlanClass(PlanKey planKey)
           
<T extends Plan>
int
getPlanCount(java.lang.Class<T> planType)
          How many plans filtered by Class currently exist
 PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(java.lang.String planKey)
          Return a Plan skeleton providing ONLY id and key, that matches the given key This method should be used only for permission checking using Acegi If Job key is provided as a parameter, parent Chain will be returned anyway, as Acegi assertions are defined only for TopLevelPlans
<T extends Plan>
java.util.List<PlanIdentifier>
getPlanIdentifiersForProject(ProjectIdentifier project, java.lang.Class<T> planType, boolean includeMarkedForDeletion)
          Returns minimal data about all plans in the given project
<T extends Plan>
java.util.List<PlanKey>
getPlanKeys(java.lang.Class<T> planType)
          Returns all plan keys of a particular type
 boolean isChainNameConflicting(java.lang.String projectKey, long idOfChainBeingVerified, java.lang.String planName)
          Verifies whether a Chain name is unique with the given project

 void save(Plan plan)
          Saves the given entity.
 void setPlanDiscriminatorRegistry(PlanDiscriminatorRegistry planDiscriminatorRegistry)
           
 
Methods inherited from class com.atlassian.bamboo.persistence3.BambooHibernateObjectDao
delete, deleteAll, executeReturnLong, findAll, saveAll
 
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
 
Methods inherited from interface com.atlassian.bamboo.persistence3.BambooObjectDao
delete, deleteAll, executeReturnLong, findAll, saveAll
 

Constructor Detail

PlanHibernateDao

public PlanHibernateDao()
Method Detail

getPlanByKey

public <T extends Plan> T getPlanByKey(@NotNull
                                       java.lang.String planKey,
                                       java.lang.Class<T> aClass)
Description copied from interface: PlanDao
Return a Plan that matches the given key

Specified by:
getPlanByKey in interface PlanDao
Returns:
plan

getPlanIdentifierForPermissionCheckingByKey

@Nullable
public PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(@NotNull
                                                                           java.lang.String planKey)
Description copied from interface: PlanDao
Return a Plan skeleton providing ONLY id and key, that matches the given key This method should be used only for permission checking using Acegi If Job key is provided as a parameter, parent Chain will be returned anyway, as Acegi assertions are defined only for TopLevelPlans

Specified by:
getPlanIdentifierForPermissionCheckingByKey in interface PlanDao
Returns:
plan

getPlanClass

public java.lang.Class<? extends Plan> getPlanClass(@NotNull
                                                    PlanKey planKey)
Specified by:
getPlanClass in interface PlanDao

findById

public <E extends Plan> E findById(long id,
                                   @NotNull
                                   java.lang.Class<E> aClass)
Description copied from interface: BambooObjectDao
Find an entity by its id

Specified by:
findById in interface BambooObjectDao<Plan>
Overrides:
findById in class BambooHibernateObjectDao<Plan>
Parameters:
id - id of entity
aClass - class of entity
Returns:
entity

getPlanByName

public <T extends Plan> T getPlanByName(@NotNull
                                        java.lang.String projectKey,
                                        @NotNull
                                        java.lang.String planName,
                                        java.lang.Class<T> planType)
Description copied from interface: PlanDao
Returns a Plan from a project with the given plan name and Class It is not possible to use this method if the planType parameter is a marker interface type such as Plan, Buildable or TopLevelPlan since it is possible to have a Chain and a Job that share the same name.

Specified by:
getPlanByName in interface PlanDao
Parameters:
projectKey - of the project to look for the plan in
planName - - name of the plan inside the project: this is just the plan component of the name (i.e does not include the project component)
planType - - the type of the plan to retrieve
Returns:
plan with the given name and project key, if found AND is of the correct type.

isChainNameConflicting

public boolean isChainNameConflicting(@NotNull
                                      java.lang.String projectKey,
                                      long idOfChainBeingVerified,
                                      @NotNull
                                      java.lang.String planName)
Description copied from interface: PlanDao
Verifies whether a Chain name is unique with the given project

Specified by:
isChainNameConflicting in interface PlanDao
Parameters:
projectKey - of the project to look for the plan in
idOfChainBeingVerified - the id of the plan that has to be ignored during lookup (when you're saving a Plan, you should supply the plan id here)
planName - - name of the plan inside the project: this is just the plan component of the name (i.e does not include the project component)
Returns:
true if the name is in conflict

getPlanByPartialKeyAndName

@Nullable
public <T extends Plan> T getPlanByPartialKeyAndName(@NotNull
                                                              PlanKey partialPlanKey,
                                                              @NotNull
                                                              java.lang.String planName,
                                                              java.lang.Class<T> planType)
Description copied from interface: PlanDao
Returns a Plan that matches the start of the given PlanKey and name

Specified by:
getPlanByPartialKeyAndName in interface PlanDao
Returns:
plan

getPlanCount

public <T extends Plan> int getPlanCount(java.lang.Class<T> planType)
Description copied from interface: PlanDao
How many plans filtered by Class currently exist

Specified by:
getPlanCount in interface PlanDao
Returns:
how many plans exist in the datbase

getPlanKeys

@NotNull
public <T extends Plan> java.util.List<PlanKey> getPlanKeys(java.lang.Class<T> planType)
Description copied from interface: PlanDao
Returns all plan keys of a particular type

Specified by:
getPlanKeys in interface PlanDao
Returns:

findPlansByProject

@NotNull
public <T extends Plan> java.util.List<T> findPlansByProject(@NotNull
                                                                     Project project,
                                                                     java.lang.Class<T> planType)
Description copied from interface: PlanDao
Return a Plan collection for specified Project

Specified by:
findPlansByProject in interface PlanDao
Returns:
plans for specifid project

findAllPlansByProject

@NotNull
public <T extends Plan> java.util.List<T> findAllPlansByProject(@NotNull
                                                                        Project project,
                                                                        java.lang.Class<T> planType)
Description copied from interface: PlanDao
Return a Plan collection for specified Project, including plans marked for deletion.

Specified by:
findAllPlansByProject in interface PlanDao
Returns:
plans for specifid project

findAllPlans

@NotNull
public <T extends Plan> java.util.List<T> findAllPlans(java.lang.Class<T> planType)
Description copied from interface: PlanDao
Return a Plan collection for specified plan type. Does not include plans marked for deletion.

Specified by:
findAllPlans in interface PlanDao
Parameters:
planType - type of plan to be selected from DB
Returns:
Plan collection for specified plan type

setPlanDiscriminatorRegistry

public void setPlanDiscriminatorRegistry(PlanDiscriminatorRegistry planDiscriminatorRegistry)

filterFavouritedPlans

public java.util.Set<ImmutableChain> filterFavouritedPlans(@NotNull
                                                           java.util.Collection<? extends ImmutableChain> plans,
                                                           @NotNull
                                                           com.atlassian.user.User user)
Description copied from interface: PlanDao
Return a collection of TopLevelPlans that are a subset of the given Plans collection that are favourited by the User

Specified by:
filterFavouritedPlans in interface PlanDao
Returns:
favoritedBuilds

getAllPlansMarkedForDeletion

@NotNull
public <T extends Plan> java.util.Collection<T> getAllPlansMarkedForDeletion(java.lang.Class<T> planType)
Description copied from interface: PlanDao
Returns a list of Plans that are com.atlassian.bamboo.plan.Plan#markForDeletion() for the given type

Specified by:
getAllPlansMarkedForDeletion in interface PlanDao
Returns:
plansMarkedForDeletion

save

public void save(@NotNull
                 Plan plan)
Description copied from interface: BambooObjectDao
Saves the given entity. If the entity implementation is an instance of BambooEntityObject this method will: - update EntityObject.getLastModificationDate() - set EntityObject.getCreationDate() if the object has not been saved

Specified by:
save in interface BambooObjectDao<Plan>
Overrides:
save in class BambooHibernateObjectDao<Plan>
Parameters:
plan - entity to be saved

getBranchesForChain

@NotNull
public java.util.List<ChainBranch> getBranchesForChain(ImmutableChain chain)
Description copied from interface: PlanDao
Returns all branches which have the given chain as their master

Specified by:
getBranchesForChain in interface PlanDao
Parameters:
chain - master plan
Returns:
all branches which have the given chain as their master

getBranchIdentifiersForChain

@NotNull
public java.util.List<ChainBranchIdentifier> getBranchIdentifiersForChain(@NotNull
                                                                                  PlanIdentifier plan)
Description copied from interface: PlanDao
Returns minimal data about all branches which have the given chain as their master

Specified by:
getBranchIdentifiersForChain in interface PlanDao
Parameters:
plan - master
Returns:
all branches which have the given chain as their master

getPlanIdentifiersForProject

@NotNull
public <T extends Plan> java.util.List<PlanIdentifier> getPlanIdentifiersForProject(ProjectIdentifier project,
                                                                                            java.lang.Class<T> planType,
                                                                                            boolean includeMarkedForDeletion)
Description copied from interface: PlanDao
Returns minimal data about all plans in the given project

Specified by:
getPlanIdentifiersForProject in interface PlanDao
Parameters:
project - - to get plans for
planType - to filter plans by
includeMarkedForDeletion - - true if you want to include any results currently marked for deletion
Returns:
plansIdentifiers matching the above criteria.

getBranchCount

public int getBranchCount(@NotNull
                          Plan plan)
Description copied from interface: PlanDao
Returns the number of branches that exist for the given plan

Specified by:
getBranchCount in interface PlanDao
Parameters:
plan - to count branches of
Returns:
the number of branches that exist for the given plan

getBranchesCount

public java.util.List<Pair<java.lang.Long,java.lang.Integer>> getBranchesCount()
Description copied from interface: PlanDao
Returns the number of branches that exist for master plans in Bamboo. Only returns masters plans which HAVE branches. Others are omitted.

Specified by:
getBranchesCount in interface PlanDao
Returns:
List of pairs of plan id and their branches count


Copyright © 2012 Atlassian. All Rights Reserved.