Class PlanHibernateDao<T extends Plan>

    • Method Detail

      • getPlanByKey

        public <T extends Plan> T getPlanByKey​(@NotNull
                                               @NotNull PlanKey planKey,
                                               Class<T> aClass)
        Description copied from interface: PlanDao
        Return a Plan that matches the given key
        Specified by:
        getPlanByKey in interface PlanDao
        Returns:
        plan
      • getPlanByKey

        public <T extends Plan> T getPlanByKey​(@NotNull
                                               @NotNull String planKey,
                                               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 @Nullable PlanIdentifier getPlanIdentifierForPermissionCheckingByKey​(@NotNull
                                                                                    @NotNull 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
      • isChainNameConflicting

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

        public boolean isPlanKeyConflicting​(@NotNull
                                            @NotNull PlanKey planKey)
        Description copied from interface: PlanDao
        Verifies whether a Plan key is unique within whole Bamboo installation
        Specified by:
        isPlanKeyConflicting in interface PlanDao
        Parameters:
        planKey - key of the plan to be searched for in the database
        Returns:
        true if plan key is conflicting
      • isPlanKeyConflicting

        public boolean isPlanKeyConflicting​(@NotNull
                                            @NotNull PlanKey planKey,
                                            long idOfChainBeingVerified)
        Description copied from interface: PlanDao
        Verifies whether a Plan key is unique within whole Bamboo installation
        Specified by:
        isPlanKeyConflicting in interface PlanDao
        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
      • getPlanByPartialKeyAndName

        @Nullable
        public <T extends Plan> T getPlanByPartialKeyAndName​(@NotNull
                                                             @NotNull PlanKey partialPlanKey,
                                                             @NotNull
                                                             @NotNull String planName,
                                                             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​(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 database
      • getPlanCount

        public int getPlanCount​(@NotNull
                                @NotNull ProjectIdentifier projectIdentifier)
        Description copied from interface: PlanDao
        How many plans currently exist in a project.
        Specified by:
        getPlanCount in interface PlanDao
        Parameters:
        projectIdentifier - identifier of the project
        Returns:
        how many plans exist in the database in a project, excluding ones marked for deletion
      • getPlanKeys

        @NotNull
        public <T extends Plan> @NotNull List<PlanKey> getPlanKeys​(Class<T> planType)
        Description copied from interface: PlanDao
        Returns all plan keys of a particular type, NOT including the plans marked for deletion.
        Specified by:
        getPlanKeys in interface PlanDao
      • getAllPlanKeys

        @NotNull
        public <T extends Plan> @NotNull List<PlanKey> getAllPlanKeys​(Class<T> planType)
        Description copied from interface: PlanDao
        Returns all plan keys of a particular type, including the plans marked for deletion.
        Specified by:
        getAllPlanKeys in interface PlanDao
      • getJobKeys

        @NotNull
        public @NotNull List<PlanKey> getJobKeys​(@NotNull
                                                 @NotNull PlanKey chainKey)
        Description copied from interface: PlanDao
        Return all plan keys of Jobs that belong to a Chain
        Specified by:
        getJobKeys in interface PlanDao
        Parameters:
        chainKey - key of a Chain
        Returns:
        list of Job keys
      • findPlansByProject

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

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

        public void setPlanDiscriminatorRegistry​(PlanDiscriminatorRegistry planDiscriminatorRegistry)
      • save

        public void save​(@NotNull
                         @NotNull Plan plan)
        Description copied from interface: BambooObjectDao
        Saves the given entity. If the entity implementation is an instance of EntityObject this method will: - update EntityObject.getLastModificationDate() - set EntityObject.getCreationDate() if the object has not been saved
        Specified by:
        save in interface BambooObjectDao<T extends Plan>
        Overrides:
        save in class BambooHibernateObjectDao<Plan>
        Parameters:
        plan - entity to be saved
      • getBranchesForChain

        @NotNull
        public @NotNull 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 @NotNull List<ChainBranchIdentifier> getBranchIdentifiersForChain​(@NotNull
                                                                                 @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> @NotNull List<PlanIdentifier> getPlanIdentifiersForProject​(@NotNull
                                                                                           @NotNull ProjectIdentifier project,
                                                                                           @NotNull
                                                                                           @NotNull 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
                                  @NotNull ImmutablePlan 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 List<Pair<Number,​Number>> 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
      • markPlanForDeletion

        public void markPlanForDeletion​(PlanKey planKey)
        Description copied from interface: PlanDao
        Efficiently marks a plan to be deleted
        Specified by:
        markPlanForDeletion in interface PlanDao
      • syncDeletionStatusOfPlans

        public void syncDeletionStatusOfPlans()
        Description copied from interface: PlanDao
        Performs a cleanup task to mark Plan objects that have a Project that is marked to be deleted, but is not marked as deleted.
        Specified by:
        syncDeletionStatusOfPlans in interface PlanDao
      • syncDeletionStatusOfJobs

        public void syncDeletionStatusOfJobs()
        Description copied from interface: PlanDao
        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.
        Specified by:
        syncDeletionStatusOfJobs in interface PlanDao
      • syncDeletionStatusOfChainBranches

        public void syncDeletionStatusOfChainBranches()
        Description copied from interface: PlanDao
        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.
        Specified by:
        syncDeletionStatusOfChainBranches in interface PlanDao
      • getFavouritePlansIds

        @NotNull
        public @NotNull Set<Long> getFavouritePlansIds​(@NotNull
                                                       @NotNull com.atlassian.user.User user)
        Description copied from interface: PlanDao
        Return a collection of Favourite plan ids.
        Specified by:
        getFavouritePlansIds in interface PlanDao
        Returns:
        favouritePlansIds
      • getPlanKeysPlanIdsMapping

        public <T extends PlanMap<PlanKey,​Long> getPlanKeysPlanIdsMapping​(@NotNull
                                                                                  @NotNull Class<T> aClass)
        Specified by:
        getPlanKeysPlanIdsMapping in interface PlanDao
        Returns:
        mapping between plans' keys and their ids for given plan class.
      • getBranchKeysForChain

        @NotNull
        public @NotNull List<PlanKey> getBranchKeysForChain​(@NotNull
                                                            @NotNull PlanKey chainKey)
        Description copied from interface: PlanDao
        Returns the keys of branches that have as master the chain identified by the given chainKey.
        Specified by:
        getBranchKeysForChain in interface PlanDao
        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.