public class PlanHibernateDao<T extends Plan> extends BambooHibernateObjectWithOidDao<Plan> implements PlanDao
Constructor and Description |
---|
PlanHibernateDao(TransactionAndHibernateTemplate transactionTemplate) |
Modifier and Type | Method and Description |
---|---|
List<ImmutableChain> |
filterFavouritedPlans(Collection<? extends ImmutableChain> plans,
com.atlassian.user.User user)
Return a collection of
TopLevelPlan s that are a subset of the given Plan s collection that are favourited by the User |
<T extends Plan> |
findAllPlans(Class<T> planType)
Return a
Plan collection for specified plan type. |
<T extends Plan> |
findAllPlans(Class<T> planType,
int firstResult,
int maxResults)
Return a
Plan collection for specified plan type. |
<T extends Plan> |
findAllPlansByProject(Project project,
Class<T> planType)
|
<E extends Plan> |
findById(long id,
Class<E> aClass)
Find an entity by its id
|
<T extends Plan> |
findPlansByProject(Project project,
Class<T> planType)
|
<T extends Plan> |
getAllPlanKeys(Class<T> planType)
Returns all plan keys of a particular type, including the plans marked for deletion.
|
<T extends Plan> |
getAllPlansMarkedForDeletion(Class<T> planType)
Returns a list of
Plan s that are ImmutableDeletable.isMarkedForDeletion() for the given type |
int |
getBranchCount(ImmutablePlan plan)
Returns the number of branches that exist for the given plan
|
List<Pair<Number,Number>> |
getBranchesCount()
Returns the number of branches that exist for master plans in Bamboo.
|
List<ChainBranch> |
getBranchesForChain(ImmutableChain chain)
Returns all branches which have the given chain as their master
|
Collection<Job> |
getBranchesForJob(Job job) |
List<ChainBranchIdentifier> |
getBranchIdentifiersForChain(PlanIdentifier plan)
Returns minimal data about all branches which have the given chain as their master
|
List<PlanKey> |
getJobKeys(PlanKey chainKey)
Return all plan keys of Jobs that belong to a Chain
|
BambooEntityOid |
getMaxPlanOid(int serverKey,
BambooEntityType entityType)
Returns the max
BambooEntityOid that's currently in use of the specified entity type, with the
given server key. |
<T extends Plan> |
getPlanByKey(PlanKey planKey,
Class<T> aClass)
Return a
Plan that matches the given key |
<T extends Plan> |
getPlanByKey(String planKey,
Class<T> aClass)
Return a
Plan that matches the given key |
<T extends Plan> |
getPlanByPartialKeyAndName(PlanKey partialPlanKey,
String planName,
Class<T> planType)
|
Class<? extends Plan> |
getPlanClass(PlanKey planKey) |
<T extends Plan> |
getPlanCount(Class<T> planType)
How many plans filtered by
Class currently exist |
int |
getPlanCount(ProjectIdentifier projectIdentifier)
How many plans currently exist in a
project . |
PlanIdentifier |
getPlanIdentifierForPermissionCheckingByKey(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 TopLevelPlan s |
<T extends Plan> |
getPlanIdentifiersForProject(ProjectIdentifier project,
Class<T> planType,
boolean includeMarkedForDeletion)
Returns minimal data about all plans in the given project
|
<T extends Plan> |
getPlanKeys(Class<T> planType)
Returns all plan keys of a particular type, NOT including the plans marked for deletion.
|
boolean |
isChainNameConflicting(String projectKey,
long idOfChainBeingVerified,
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 |
boolean |
isPlanKeyConflicting(PlanKey planKey,
long idOfChainBeingVerified)
Verifies whether a
Plan key is unique within whole Bamboo installation |
void |
markPlanForDeletion(PlanKey planKey)
Efficiently marks a plan to be deleted
|
void |
save(Plan plan)
Saves the given entity.
|
void |
setPlanDiscriminatorRegistry(PlanDiscriminatorRegistry planDiscriminatorRegistry) |
void |
syncDeletionStatusOfChainBranches()
Performs a cleanup task to mark
ChainBranch objects that have a master Plan that is marked
to be deleted, but is not marked as 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. |
findByOid
countAll, countWithRestriction, delete, deleteAll, executeCountQuery, findAll, merge, saveAll
getCacheAwareHibernateTemplate
checkDaoConfig, createHibernateTemplate, currentSession, getHibernateTemplate, getSessionFactory, setHibernateTemplate, setSessionFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
findByOid
countAll, countWithRestriction, delete, deleteAll, findAll, merge, saveAll
public PlanHibernateDao(TransactionAndHibernateTemplate transactionTemplate)
public <T extends Plan> T getPlanByKey(@NotNull PlanKey planKey, Class<T> aClass)
PlanDao
Plan
that matches the given keygetPlanByKey
in interface PlanDao
public <T extends Plan> T getPlanByKey(@NotNull String planKey, Class<T> aClass)
PlanDao
Plan
that matches the given keygetPlanByKey
in interface PlanDao
@Nullable public PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(@NotNull String planKey)
PlanDao
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 TopLevelPlan
sgetPlanIdentifierForPermissionCheckingByKey
in interface PlanDao
public Class<? extends Plan> getPlanClass(@NotNull PlanKey planKey)
getPlanClass
in interface PlanDao
public <E extends Plan> E findById(long id, @NotNull Class<E> aClass)
BambooObjectDao
findById
in interface BambooObjectDao<Plan>
findById
in class BambooHibernateObjectDao<Plan>
id
- id of entityaClass
- class of entitypublic boolean isChainNameConflicting(@NotNull String projectKey, long idOfChainBeingVerified, @NotNull String planName)
PlanDao
Chain
name is unique with the given project
isChainNameConflicting
in interface PlanDao
projectKey
- of the project to look for the plan inidOfChainBeingVerified
- 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)public boolean isPlanKeyConflicting(@NotNull PlanKey planKey)
PlanDao
Plan
key is unique within whole Bamboo installationisPlanKeyConflicting
in interface PlanDao
planKey
- key of the plan to be searched for in the databasepublic boolean isPlanKeyConflicting(@NotNull PlanKey planKey, long idOfChainBeingVerified)
PlanDao
Plan
key is unique within whole Bamboo installationisPlanKeyConflicting
in interface PlanDao
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)@Nullable public <T extends Plan> T getPlanByPartialKeyAndName(@NotNull PlanKey partialPlanKey, @NotNull String planName, Class<T> planType)
PlanDao
getPlanByPartialKeyAndName
in interface PlanDao
public <T extends Plan> int getPlanCount(Class<T> planType)
PlanDao
Class
currently existgetPlanCount
in interface PlanDao
public int getPlanCount(@NotNull ProjectIdentifier projectIdentifier)
PlanDao
project
.getPlanCount
in interface PlanDao
projectIdentifier
- identifier of the project@NotNull public <T extends Plan> List<PlanKey> getPlanKeys(Class<T> planType)
PlanDao
getPlanKeys
in interface PlanDao
@NotNull public <T extends Plan> List<PlanKey> getAllPlanKeys(Class<T> planType)
PlanDao
getAllPlanKeys
in interface PlanDao
@NotNull public List<PlanKey> getJobKeys(@NotNull PlanKey chainKey)
PlanDao
getJobKeys
in interface PlanDao
chainKey
- key of a Chain@NotNull public <T extends Plan> List<T> findPlansByProject(@NotNull Project project, Class<T> planType)
PlanDao
findPlansByProject
in interface PlanDao
@NotNull public <T extends Plan> List<T> findAllPlansByProject(@NotNull Project project, Class<T> planType)
PlanDao
findAllPlansByProject
in interface PlanDao
@NotNull public <T extends Plan> List<T> findAllPlans(Class<T> planType)
PlanDao
Plan
collection for specified plan type. Does not include plans marked for deletion.findAllPlans
in interface PlanDao
planType
- type of plan to be selected from DBPlan
collection for specified plan type@NotNull public <T extends Plan> List<T> findAllPlans(Class<T> planType, int firstResult, int maxResults)
PlanDao
Plan
collection for specified plan type. Does not include plans marked for deletion.findAllPlans
in interface PlanDao
planType
- type of plan to be selected from DBfirstResult
- firstResult for a paginated resultsmaxResults
- maximum number of results to returnPlan
collection for specified plan typepublic void setPlanDiscriminatorRegistry(PlanDiscriminatorRegistry planDiscriminatorRegistry)
public List<ImmutableChain> filterFavouritedPlans(@NotNull Collection<? extends ImmutableChain> plans, @NotNull com.atlassian.user.User user)
PlanDao
TopLevelPlan
s that are a subset of the given Plan
s collection that are favourited by the User
filterFavouritedPlans
in interface PlanDao
@NotNull public <T extends Plan> Collection<T> getAllPlansMarkedForDeletion(Class<T> planType)
PlanDao
Plan
s that are ImmutableDeletable.isMarkedForDeletion()
for the given typegetAllPlansMarkedForDeletion
in interface PlanDao
public void save(@NotNull Plan plan)
BambooObjectDao
EntityObject
this method will:
- update EntityObject.getLastModificationDate()
- set EntityObject.getCreationDate()
if the object has not been savedsave
in interface BambooObjectDao<Plan>
save
in class BambooHibernateObjectDao<Plan>
plan
- entity to be saved@NotNull public List<ChainBranch> getBranchesForChain(ImmutableChain chain)
PlanDao
getBranchesForChain
in interface PlanDao
chain
- master planpublic Collection<Job> getBranchesForJob(Job job)
getBranchesForJob
in interface PlanDao
@NotNull public List<ChainBranchIdentifier> getBranchIdentifiersForChain(@NotNull PlanIdentifier plan)
PlanDao
getBranchIdentifiersForChain
in interface PlanDao
plan
- master@NotNull public <T extends Plan> List<PlanIdentifier> getPlanIdentifiersForProject(@NotNull ProjectIdentifier project, @NotNull Class<T> planType, boolean includeMarkedForDeletion)
PlanDao
getPlanIdentifiersForProject
in interface PlanDao
project
- - to get plans forplanType
- to filter plans byincludeMarkedForDeletion
- - true if you want to include any results currently marked for deletionpublic int getBranchCount(@NotNull ImmutablePlan plan)
PlanDao
getBranchCount
in interface PlanDao
plan
- to count branches ofpublic List<Pair<Number,Number>> getBranchesCount()
PlanDao
getBranchesCount
in interface PlanDao
public void markPlanForDeletion(PlanKey planKey)
PlanDao
markPlanForDeletion
in interface PlanDao
public void syncDeletionStatusOfJobs()
PlanDao
Job
objects that have a Plan
or ChainStage
that
is marked to be deleted, but it itself was not marked as deleted.syncDeletionStatusOfJobs
in interface PlanDao
public void syncDeletionStatusOfChainBranches()
PlanDao
ChainBranch
objects that have a master Plan
that is marked
to be deleted, but is not marked as deleted.syncDeletionStatusOfChainBranches
in interface PlanDao
@Nullable public BambooEntityOid getMaxPlanOid(int serverKey, @NotNull BambooEntityType entityType)
PlanDao
BambooEntityOid
that'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_BRANCH
Returns null if no OIDs are in use of the specified type with the given server key.getMaxPlanOid
in interface PlanDao
Copyright © 2019 Atlassian Software Systems Pty Ltd. All rights reserved.