Interface PlanDao

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

@Internal public interface PlanDao extends BambooObjectWithOidDao<Plan>
DAO Manager for Plan
  • Method Details

    • getPlanByKey

      @Nullable <T extends Plan> T getPlanByKey(@NotNull @NotNull PlanKey planKey, Class<T> aClass)
      Return a Plan that matches the given key
      Parameters:
      planKey -
      Returns:
      plan
    • getPlanByKey

      @Nullable <T extends Plan> T getPlanByKey(@NotNull @NotNull String planKey, Class<T> aClass)
      Return a Plan that matches the given key
      Parameters:
      planKey -
      Returns:
      plan
    • getPlanIdentifierForPermissionCheckingByKey

      @Nullable @Nullable PlanIdentifier getPlanIdentifierForPermissionCheckingByKey(@NotNull @NotNull 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 @Nullable Class<? extends Plan> getPlanClass(@NotNull @NotNull PlanKey planKey)
    • isChainNameConflicting

      boolean isChainNameConflicting(@NotNull @NotNull String projectKey, long planIdToIgnore, @NotNull @NotNull 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 @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
    • isPlanKeyConflicting

      boolean isPlanKeyConflicting(@NotNull @NotNull PlanKey planKey, long idOfChainBeingVerified)
      Verifies whether a Plan key is unique within whole Bamboo installation
      Parameters:
      planKey - key of the plan to be searched for in the database
      idOfChainBeingVerified - 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)
      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(Class<T> planType)
      How many plans filtered by Class currently exist
      Parameters:
      planType -
      Returns:
      how many plans exist in the database
    • getPlanCount

      int getPlanCount(@NotNull @NotNull ProjectIdentifier projectIdentifier)
      How many plans currently exist in a project.
      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)
      Return a Plan collection for specified Project
      Parameters:
      project -
      planType -
      Returns:
      plans for specifid project
    • findAllPlansByProject

      <T extends Plan> List<T> findAllPlansByProject(@NotNull @NotNull Project project, 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> @NotNull List<T> findAllPlans(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
    • findAllPlans

      @NotNull <T extends Plan> @NotNull List<T> findAllPlans(Class<T> planType, int firstResult, int maxResults)
      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
      firstResult - firstResult for a paginated results
      maxResults - maximum number of results to return
      Returns:
      Plan collection for specified plan type
    • filterFavouritedPlans

      List<ImmutableChain> filterFavouritedPlans(@NotNull @NotNull Collection<? extends ImmutableChain> plans, @NotNull @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
    • 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 of Plans that are ImmutableDeletable.isMarkedForDeletion() for the given type
      Returns:
      plansMarkedForDeletion
    • getAllPlansMarkedForDeletionCount

      <T extends Plan> long getAllPlansMarkedForDeletionCount(Class<T> planType)
      Returns a count of Plans that are ImmutableDeletable.isMarkedForDeletion() for the given type
      Returns:
      number of plans of a requested type scheduled for deletion
      Since:
      10.0
    • 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 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 @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()
      Performs a cleanup task to mark Plan objects that have a Project that is marked to be deleted, but is not marked as deleted.
    • 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.
    • syncDeletionStatusOfChainBranches

      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.
    • getMaxPlanOid

      @Nullable @Nullable BambooEntityOid getMaxPlanOid(int serverKey, @NotNull @NotNull BambooEntityType entityType)
      Returns the max 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.
      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