com.atlassian.bamboo.plan
Interface PlanDao

All Superinterfaces:
BambooObjectDao<Plan>
All Known Implementing Classes:
PlanHibernateDao

public interface PlanDao
extends BambooObjectDao<Plan>

DAO Manager for Plan


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.
<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(ImmutablePlan 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.Collection<Job> getBranchesForJob(Job job)
           
 java.util.List<ChainBranchIdentifier> getBranchIdentifiersForChain(PlanIdentifier chain)
          Returns minimal data about all branches which have the given chain as their master
 java.util.List<PlanKey> getJobKeys(PlanKey chainKey)
          Return all plan keys of Jobs that belong to a Chain
<T extends Plan>
T
getPlanByKey(PlanKey planKey, java.lang.Class<T> aClass)
          Return a Plan that matches the given key
<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)
          Deprecated. since 4.0 implementation no longer guarantees exception on using the method with incorrect planType parameter but only when the result is not unique. Use: PlanDao#isPlanNameConflicting(String, String)
<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 projectIdentifier, 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 planIdToIgnore, java.lang.String planName)
          Verifies whether a Chain name is unique with the given project

 boolean isPlanKeyConflicting(PlanKey planKey)
          Verifies whether a Plan key is unique within whole Bamboo installation
 void markPlanForDeletion(PlanKey planKey)
          Efficiently marks a plan to be deleted
 void syncDeletionStatusOfJobs()
          Performs a cleanup task to mark Job objects that have a Plan or ChainStage that is marked to be deleted, but it itself was not marked as deleted.
 
Methods inherited from interface com.atlassian.bamboo.persistence3.BambooObjectDao
delete, deleteAll, executeReturnLong, findAll, findById, save, saveAll
 

Method Detail

getPlanByKey

@Nullable
<T extends Plan> T getPlanByKey(@NotNull
                                         PlanKey planKey,
                                         java.lang.Class<T> aClass)
Return a Plan that matches the given key

Parameters:
planKey -
Returns:
plan

getPlanByKey

@Nullable
<T extends Plan> T getPlanByKey(@NotNull
                                         java.lang.String planKey,
                                         java.lang.Class<T> aClass)
Return a Plan that matches the given key

Parameters:
planKey -
Returns:
plan

getPlanIdentifierForPermissionCheckingByKey

@Nullable
PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(@NotNull
                                                                    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

Parameters:
planKey -
Returns:
plan

getPlanClass

@Nullable
java.lang.Class<? extends Plan> getPlanClass(@NotNull
                                                      PlanKey planKey)

getPlanByName

@Nullable
@Deprecated
<T extends Plan> T getPlanByName(@NotNull
                                                     java.lang.String projectKey,
                                                     @NotNull
                                                     java.lang.String planName,
                                                     java.lang.Class<T> planType)
Deprecated. since 4.0 implementation no longer guarantees exception on using the method with incorrect planType parameter but only when the result is not unique. Use: PlanDao#isPlanNameConflicting(String, String)

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.

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.
Throws:
IncorrectPlanTypeException - if the result is not unique

isChainNameConflicting

boolean isChainNameConflicting(@NotNull
                               java.lang.String projectKey,
                               long planIdToIgnore,
                               @NotNull
                               java.lang.String planName)
Verifies whether a Chain name is unique with the given project

Parameters:
projectKey - of the project to look for the plan in
planIdToIgnore - 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
Since:
4.0

isPlanKeyConflicting

boolean isPlanKeyConflicting(@NotNull
                             PlanKey planKey)
Verifies whether a Plan key is unique within whole Bamboo installation

Parameters:
planKey - key of the plan to be searched for in the database
Returns:
true if plan key is conflicting
Since:
4.3

getPlanByPartialKeyAndName

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

Parameters:
partialPlanKey -
planName -
planType -
Returns:
plan

getPlanCount

<T extends Plan> int getPlanCount(java.lang.Class<T> planType)
How many plans filtered by Class currently exist

Parameters:
planType -
Returns:
how many plans exist in the database

findPlansByProject

<T extends Plan> java.util.List<T> findPlansByProject(@NotNull
                                                      Project project,
                                                      java.lang.Class<T> planType)
Return a Plan collection for specified Project

Parameters:
project -
planType -
Returns:
plans for specifid project

findAllPlansByProject

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

Parameters:
project -
planType -
Returns:
plans for specifid project

findAllPlans

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

Type Parameters:
T -
Parameters:
planType - type of plan to be selected from DB
Returns:
Plan collection for specified plan type

filterFavouritedPlans

java.util.Set<ImmutableChain> filterFavouritedPlans(@NotNull
                                                    java.util.Collection<? extends ImmutableChain> plans,
                                                    @NotNull
                                                    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

Parameters:
plans -
user -
Returns:
favoritedBuilds

getAllPlansMarkedForDeletion

@NotNull
<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

Returns:
plansMarkedForDeletion

getPlanKeys

@NotNull
<T extends Plan> java.util.List<PlanKey> getPlanKeys(java.lang.Class<T> planType)
Returns all plan keys of a particular type

Type Parameters:
T -
Parameters:
planType -
Returns:

getJobKeys

@NotNull
java.util.List<PlanKey> getJobKeys(@NotNull
                                           PlanKey chainKey)
Return all plan keys of Jobs that belong to a Chain

Parameters:
chainKey - key of a Chain
Returns:
list of Job keys

getBranchesForChain

@NotNull
java.util.List<ChainBranch> getBranchesForChain(ImmutableChain chain)
Returns all branches which have the given chain as their master

Parameters:
chain - master plan
Returns:
all branches which have the given chain as their master

getBranchesForJob

java.util.Collection<Job> getBranchesForJob(Job job)

getBranchIdentifiersForChain

@NotNull
java.util.List<ChainBranchIdentifier> getBranchIdentifiersForChain(@NotNull
                                                                           PlanIdentifier chain)
Returns minimal data about all branches which have the given chain as their master

Parameters:
chain - master
Returns:
all branches which have the given chain as their master

getPlanIdentifiersForProject

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

Parameters:
projectIdentifier - - 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

int getBranchCount(@NotNull
                   ImmutablePlan plan)
Returns the number of branches that exist for the given plan

Parameters:
plan - to count branches of
Returns:
the number of branches that exist for the given plan

getBranchesCount

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

Returns:
List of pairs of plan id and their branches count

markPlanForDeletion

void markPlanForDeletion(PlanKey planKey)
Efficiently marks a plan to be deleted

Parameters:
planKey -

syncDeletionStatusOfJobs

void syncDeletionStatusOfJobs()
Performs a cleanup task to mark Job objects that have a Plan or ChainStage that is marked to be deleted, but it itself was not marked as deleted.



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