Package com.atlassian.bamboo.plan
Interface PlanDao
-
- All Superinterfaces:
BambooObjectDao<Plan>,BambooObjectWithOidDao<Plan>
- All Known Implementing Classes:
PlanHibernateDao
@Internal public interface PlanDao extends BambooObjectWithOidDao<Plan>
DAO Manager forPlan
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclearInvalidFlagForBranchesOfChain(long masterId)List<ImmutableChain>filterFavouritedPlans(@NotNull Collection<? extends ImmutableChain> plans, @NotNull com.atlassian.user.User user)Return a collection ofTopLevelPlans that are a subset of the givenPlans collection that are favourited by theUser<T extends Plan>
@NotNull List<T>findAllPlans(Class<T> planType)Return aPlancollection for specified plan type.<T extends Plan>
@NotNull List<T>findAllPlans(Class<T> planType, int firstResult, int maxResults)Return aPlancollection for specified plan type.<T extends Plan>
List<T>findAllPlansByProject(@NotNull Project project, Class<T> planType)<T extends Plan>
List<T>findPlansByProject(@NotNull Project project, Class<T> planType)<T extends Plan>
@NotNull List<PlanKey>getAllPlanKeys(Class<T> planType)Returns all plan keys of a particular type, including the plans marked for deletion.<T extends Plan>
@NotNull Collection<T>getAllPlansMarkedForDeletion(Class<T> planType)Returns a list ofPlans that areImmutableDeletable.isMarkedForDeletion()for the given typeintgetBranchCount(@NotNull ImmutablePlan plan)Returns the number of branches that exist for the given planList<Pair<Number,Number>>getBranchesCount()Returns the number of branches that exist for master plans in Bamboo.@NotNull List<ChainBranch>getBranchesForChain(ImmutableChain chain)Returns all branches which have the given chain as their masterCollection<Job>getBranchesForJob(Job job)@NotNull List<ChainBranchIdentifier>getBranchIdentifiersForChain(@NotNull PlanIdentifier chain)Returns minimal data about all branches which have the given chain as their master@NotNull List<PlanKey>getBranchKeysForChain(@NotNull PlanKey chainKey)Returns the keys of branches that have as master the chain identified by the given chainKey.@NotNull Set<Long>getFavouritePlansIds(@NotNull com.atlassian.user.User user)Return a collection of Favourite plan ids.@NotNull List<PlanKey>getJobKeys(@NotNull PlanKey chainKey)Return all plan keys of Jobs that belong to a Chain@Nullable BambooEntityOidgetMaxPlanOid(int serverKey, @NotNull BambooEntityType entityType)Returns the maxBambooEntityOidthat's currently in use of the specified entity type, with the given server key.<T extends Plan>
TgetPlanByKey(@NotNull PlanKey planKey, Class<T> aClass)Return aPlanthat matches the given key<T extends Plan>
TgetPlanByKey(@NotNull String planKey, Class<T> aClass)Return aPlanthat matches the given key<T extends Plan>
TgetPlanByPartialKeyAndName(@NotNull PlanKey partialPlanKey, @NotNull String planName, Class<T> planType)@Nullable Class<? extends Plan>getPlanClass(@NotNull PlanKey planKey)intgetPlanCount(@NotNull ProjectIdentifier projectIdentifier)How many plans currently exist in aproject.<T extends Plan>
intgetPlanCount(Class<T> planType)How many plans filtered byClasscurrently exist@Nullable PlanIdentifiergetPlanIdentifierForPermissionCheckingByKey(@NotNull String planKey)Return aPlanskeleton providing ONLY id and key, that matches the given key This method should be used only for permission checking using Acegi IfJobkey is provided as a parameter, parent Chain will be returned anyway, as Acegi assertions are defined only forTopLevelPlans<T extends Plan>
@NotNull List<PlanIdentifier>getPlanIdentifiersForProject(@NotNull ProjectIdentifier projectIdentifier, @NotNull Class<T> planType, boolean includeMarkedForDeletion)Returns minimal data about all plans in the given project<T extends Plan>
@NotNull List<PlanKey>getPlanKeys(Class<T> planType)Returns all plan keys of a particular type, NOT including the plans marked for deletion.<T extends Plan>
Map<PlanKey,Long>getPlanKeysPlanIdsMapping(@NotNull Class<T> aClass)booleanisChainNameConflicting(@NotNull String projectKey, long planIdToIgnore, @NotNull String planName)Verifies whether aChainname is unique with the given projectbooleanisPlanKeyConflicting(@NotNull PlanKey planKey)Verifies whether aPlankey is unique within whole Bamboo installationbooleanisPlanKeyConflicting(@NotNull PlanKey planKey, long idOfChainBeingVerified)Verifies whether aPlankey is unique within whole Bamboo installationvoidmarkPlanForDeletion(PlanKey planKey)Efficiently marks a plan to be deletedvoidsyncDeletionStatusOfChainBranches()Performs a cleanup task to markChainBranchobjects that have a masterPlanthat is marked to be deleted, but is not marked as deleted.voidsyncDeletionStatusOfJobs()Performs a cleanup task to markJobobjects that have aPlanorChainStagethat is marked to be deleted, but it itself was not marked as deleted.voidsyncDeletionStatusOfPlans()-
Methods inherited from interface com.atlassian.bamboo.persistence3.BambooObjectDao
countAll, countWithRestriction, delete, deleteAll, findAll, findById, merge, save, saveAll
-
Methods inherited from interface com.atlassian.bamboo.persistence3.BambooObjectWithOidDao
findByOid
-
-
-
-
Method Detail
-
getPlanByKey
@Nullable <T extends Plan> T getPlanByKey(@NotNull @NotNull PlanKey planKey, Class<T> aClass)
Return aPlanthat matches the given key- Parameters:
planKey-- Returns:
- plan
-
getPlanByKey
@Nullable <T extends Plan> T getPlanByKey(@NotNull @NotNull String planKey, Class<T> aClass)
Return aPlanthat matches the given key- Parameters:
planKey-- Returns:
- plan
-
getPlanIdentifierForPermissionCheckingByKey
@Nullable @Nullable PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(@NotNull @NotNull String planKey)
Return aPlanskeleton providing ONLY id and key, that matches the given key This method should be used only for permission checking using Acegi IfJobkey is provided as a parameter, parent Chain will be returned anyway, as Acegi assertions are defined only forTopLevelPlans- Parameters:
planKey-- Returns:
- plan
-
getPlanClass
@Nullable @Nullable Class<? extends Plan> getPlanClass(@NotNull @NotNull PlanKey planKey)
-
isChainNameConflicting
boolean isChainNameConflicting(@NotNull @NotNull String projectKey, long planIdToIgnore, @NotNull @NotNull String planName)Verifies whether aChainname is unique with the given project- Parameters:
projectKey- of the project to look for the plan inplanIdToIgnore- 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 @NotNull PlanKey planKey)Verifies whether aPlankey 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
-
isPlanKeyConflicting
boolean isPlanKeyConflicting(@NotNull @NotNull PlanKey planKey, long idOfChainBeingVerified)Verifies whether aPlankey is unique within whole Bamboo installation- Parameters:
planKey- key of the plan to be searched for in the databaseidOfChainBeingVerified- id of plan that is verified (i.e. if that plan uses the key, it's not a duplicate key)- Returns:
- true if plan key is conflicting
- Since:
- 5.15
-
getPlanByPartialKeyAndName
@Nullable <T extends Plan> T getPlanByPartialKeyAndName(@NotNull @NotNull PlanKey partialPlanKey, @NotNull @NotNull String planName, Class<T> planType)
- Parameters:
partialPlanKey-planName-planType-- Returns:
- plan
-
getPlanCount
<T extends Plan> int getPlanCount(Class<T> planType)
How many plans filtered byClasscurrently exist- Parameters:
planType-- Returns:
- how many plans exist in the database
-
getPlanCount
int getPlanCount(@NotNull @NotNull ProjectIdentifier projectIdentifier)How many plans currently exist in aproject.- Parameters:
projectIdentifier- identifier of the project- Returns:
- how many plans exist in the database in a project, excluding ones marked for deletion
-
findPlansByProject
<T extends Plan> List<T> findPlansByProject(@NotNull @NotNull Project project, Class<T> planType)
- Parameters:
project-planType-- Returns:
- plans for specifid project
-
findAllPlansByProject
<T extends Plan> List<T> findAllPlansByProject(@NotNull @NotNull Project project, Class<T> planType)
- Parameters:
project-planType-- Returns:
- plans for specifid project
-
findAllPlans
@NotNull <T extends Plan> @NotNull List<T> findAllPlans(Class<T> planType)
Return aPlancollection 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:
Plancollection for specified plan type
-
findAllPlans
@NotNull <T extends Plan> @NotNull List<T> findAllPlans(Class<T> planType, int firstResult, int maxResults)
Return aPlancollection for specified plan type. Does not include plans marked for deletion.- Type Parameters:
T-- Parameters:
planType- type of plan to be selected from DBfirstResult- firstResult for a paginated resultsmaxResults- maximum number of results to return- Returns:
Plancollection for specified plan type
-
filterFavouritedPlans
List<ImmutableChain> filterFavouritedPlans(@NotNull @NotNull Collection<? extends ImmutableChain> plans, @NotNull @NotNull com.atlassian.user.User user)
Return a collection ofTopLevelPlans that are a subset of the givenPlans collection that are favourited by theUser- Parameters:
plans-user-- Returns:
- favoritedBuilds
-
getFavouritePlansIds
@NotNull @NotNull Set<Long> getFavouritePlansIds(@NotNull @NotNull com.atlassian.user.User user)
Return a collection of Favourite plan ids.- Parameters:
user-- Returns:
- favouritePlansIds
-
getAllPlansMarkedForDeletion
@Internal @NotNull <T extends Plan> @NotNull Collection<T> getAllPlansMarkedForDeletion(Class<T> planType)
Returns a list ofPlans that areImmutableDeletable.isMarkedForDeletion()for the given type- Returns:
- plansMarkedForDeletion
-
getPlanKeys
@NotNull <T extends Plan> @NotNull List<PlanKey> getPlanKeys(Class<T> planType)
Returns all plan keys of a particular type, NOT including the plans marked for deletion.
-
getAllPlanKeys
@NotNull <T extends Plan> @NotNull List<PlanKey> getAllPlanKeys(Class<T> planType)
Returns all plan keys of a particular type, including the plans marked for deletion.
-
getJobKeys
@NotNull @NotNull List<PlanKey> getJobKeys(@NotNull @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 @NotNull 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
Collection<Job> getBranchesForJob(Job job)
-
getBranchIdentifiersForChain
@NotNull @NotNull List<ChainBranchIdentifier> getBranchIdentifiersForChain(@NotNull @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> @NotNull List<PlanIdentifier> getPlanIdentifiersForProject(@NotNull @NotNull ProjectIdentifier projectIdentifier, @NotNull @NotNull Class<T> planType, boolean includeMarkedForDeletion)
Returns minimal data about all plans in the given project- Parameters:
projectIdentifier- - to get plans forplanType- to filter plans byincludeMarkedForDeletion- - true if you want to include any results currently marked for deletion- Returns:
- plansIdentifiers matching the above criteria.
-
getBranchCount
int getBranchCount(@NotNull @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
List<Pair<Number,Number>> 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-
-
syncDeletionStatusOfPlans
void syncDeletionStatusOfPlans()
-
syncDeletionStatusOfJobs
void syncDeletionStatusOfJobs()
Performs a cleanup task to markJobobjects that have aPlanorChainStagethat is marked to be deleted, but it itself was not marked as deleted.
-
syncDeletionStatusOfChainBranches
void syncDeletionStatusOfChainBranches()
Performs a cleanup task to markChainBranchobjects that have a masterPlanthat is marked to be deleted, but is not marked as deleted.
-
getMaxPlanOid
@Nullable @Nullable BambooEntityOid getMaxPlanOid(int serverKey, @NotNull @NotNull BambooEntityType entityType)
Returns the maxBambooEntityOidthat's currently in use of the specified entity type, with the given server key. Allowed entity types: -BambooEntityType.CHAIN-BambooEntityType.JOB-BambooEntityType.CHAIN_BRANCH-BambooEntityType.JOB_BRANCHReturns null if no OIDs are in use of the specified type with the given server key.- Throws:
IllegalArgumentException- if the entity type is invalid
-
getPlanKeysPlanIdsMapping
<T extends Plan> Map<PlanKey,Long> getPlanKeysPlanIdsMapping(@NotNull @NotNull Class<T> aClass)
- Returns:
- mapping between plans' keys and their ids for given plan class.
-
clearInvalidFlagForBranchesOfChain
void clearInvalidFlagForBranchesOfChain(long masterId)
-
getBranchKeysForChain
@NotNull @NotNull List<PlanKey> getBranchKeysForChain(@NotNull @NotNull PlanKey chainKey)
Returns the keys of branches that have as master the chain identified by the given chainKey.- Parameters:
chainKey- the key of the chain that is the master of the desired branches.- Returns:
- the keys of branches that have as master the chain identified by the given chainKey.
- Since:
- 9.5
-
-