Class PlanManagerImpl

    • Constructor Detail

      • PlanManagerImpl

        public PlanManagerImpl​(@NotNull
                               @NotNull PlanDao planDao,
                               @NotNull
                               @NotNull BambooLicenseManager bambooLicenseManager,
                               @NotNull
                               @NotNull com.atlassian.event.api.EventPublisher eventPublisher,
                               @NotNull
                               @NotNull ProjectManager projectManager,
                               @NotNull
                               @NotNull PlanScheduler planScheduler)
    • Method Detail

      • getPlanIdentifierForPermissionCheckingByKey

        public PlanIdentifier getPlanIdentifierForPermissionCheckingByKey​(@NotNull
                                                                          @NotNull String planKey)
        Description copied from interface: PlanManager
        Returns a Plan skeleton 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 PlanManager
        Parameters:
        planKey - of the plan to find
        Returns:
        plan by the id if found, otherwise null
      • getPlanByKeyIfOfType

        public <T extends Plan> T getPlanByKeyIfOfType​(@NotNull
                                                       @NotNull PlanKey planKey,
                                                       @NotNull
                                                       @NotNull Class<T> planType)
        Description copied from interface: PlanManager
        Returns a Plan by its planKey and if it's of the type Class. Does not throw IncorrectPlanTypeException. Should only be used when the type of the plan can not be known.
        Specified by:
        getPlanByKeyIfOfType in interface PlanManager
        Parameters:
        planKey - to search for
        planType - the type of the plan to retrieve
        Returns:
        null if the plan doesn't exist, or it's not of the found type
      • assertPlanPermission

        public boolean assertPlanPermission​(@NotNull
                                            @NotNull PlanIdentifier plan)
        Description copied from interface: PlanManager
        Used to validate user permission for plan.
        Specified by:
        assertPlanPermission in interface PlanManager
        Parameters:
        plan - to check the permissions of
        Returns:
        true if the current user has read(?) permissions on the plan
      • isChainNameConflicting

        public boolean isChainNameConflicting​(@NotNull
                                              @NotNull String projectKey,
                                              long planIdToIgnore,
                                              @NotNull
                                              @NotNull String planName)
        Description copied from interface: PlanManager
        Verifies whether a Chain name is unique with the given project

        Specified by:
        isChainNameConflicting in interface PlanManager
        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
      • isPlanKeyConflicting

        public boolean isPlanKeyConflicting​(@NotNull
                                            @NotNull PlanKey planKey)
        Description copied from interface: PlanManager
        Verifies whether a Plan key is unique within whole Bamboo installation
        Specified by:
        isPlanKeyConflicting in interface PlanManager
        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 planIdToIgnore)
        Description copied from interface: PlanManager
        Verifies whether a Plan key is unique within whole Bamboo installation
        Specified by:
        isPlanKeyConflicting in interface PlanManager
        planIdToIgnore - id of plan which we want to set key for, if the key is used by that plan, it's not really conflicting
        Returns:
        true if plan key is conflicting
      • getAllPlanKeys

        @NotNull
        public <T extends Plan> @NotNull List<PlanKey> getAllPlanKeys​(Class<T> planType)
        Description copied from interface: PlanManager
        Returns keys of all Plan's filtered by Class. Does not include plans marked for deletion.
        Specified by:
        getAllPlanKeys in interface PlanManager
        Parameters:
        planType - - the type of the plan to retrieve
        Returns:
        plan keys
      • getAllPlans

        @NotNull
        public <T extends Plan> @NotNull List<T> getAllPlans​(Class<T> planType,
                                                             int firstResult,
                                                             int maxResults)
        Description copied from interface: PlanManager
        Returns all Plan's filtered by Class. Does not include plans marked for deletion.
        Specified by:
        getAllPlans in interface PlanManager
        Parameters:
        planType - - the type of the plan to retrieve
        firstResult - firstResult for a paginated results
        maxResults - maximum number of results to return
        Returns:
        plans sorted by DescriptionProvider.getName()
      • getAllChainsAndJobsUnrestricted

        @NotNull
        public @NotNull List<Chain> getAllChainsAndJobsUnrestricted()
        Description copied from interface: PlanManager
        WARNING this is probably a bad idea from a performance perspective, only do this if you're going to traverse through all the ChainStage and Job of all Chains returned.
        Specified by:
        getAllChainsAndJobsUnrestricted in interface PlanManager
        Returns:
      • getPlansByProject

        @NotNull
        public <T extends Plan> @NotNull List<T> getPlansByProject​(Project project,
                                                                   Class<T> planType)
        Description copied from interface: PlanManager
        Returns all Plan's filtered by Project and Class
        Specified by:
        getPlansByProject in interface PlanManager
        Parameters:
        project - - that the plans will belong to
        planType - - the type of the plan to retrieve
        Returns:
        plans contained within the given project and of the given type
      • getAllPlansByProject

        @NotNull
        public <T extends Plan> @NotNull List<T> getAllPlansByProject​(Project project,
                                                                      Class<T> planType)
        Description copied from interface: PlanManager
        Returns all Plan's filtered by Project and Class, including the plans marked for deletion.
        Specified by:
        getAllPlansByProject in interface PlanManager
        Parameters:
        project - - that the plans will belong to
        planType - - the type of the plan to retrieve
        Returns:
        plans contained within the given project and of the given type
      • 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: PlanManager
        Retrieve a list of plans for a given project. Only minimal data about the plans is returned.
        Specified by:
        getPlanIdentifiersForProject in interface PlanManager
        Parameters:
        project - to get plans for
        planType - to filter plans by
        includeMarkedForDeletion - set to true if you want to return plans marked for deletion
        Returns:
        PlanIdentifiers meeting the above criteria.
      • getProjectPlanMap

        @NotNull
        public <T extends Plan> @NotNull Map<Project,​Collection<T>> getProjectPlanMap​(Class<T> planType,
                                                                                            boolean includeEmptyProjects)
        Description copied from interface: PlanManager
        Return mapping of Project to Plan of given type
        Specified by:
        getProjectPlanMap in interface PlanManager
        Parameters:
        planType - type of plan to be selected from DB
        includeEmptyProjects - should empty projects be included in result
        Returns:
        mapping of Project to Plan of given type
      • getPlanCount

        public <T extends Plan> int getPlanCount​(Class<T> planType)
        Description copied from interface: PlanManager
        How many plans filtered by Class currently exist
        Specified by:
        getPlanCount in interface PlanManager
        Parameters:
        planType - - the type of the plan to retrieve
        Returns:
        how many plans exist in the datbase
      • getPlanCount

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

        public void savePlan​(@NotNull
                             @NotNull Plan plan)
        Description copied from interface: PlanManager
        Saves the Plan
        Specified by:
        savePlan in interface PlanManager
        Parameters:
        plan - to be saved
      • createPlan

        public void createPlan​(@NotNull
                               @NotNull Plan plan)
        Description copied from interface: PlanManager
        Same as savePlan, but create permissions used instead of edit permissions.
        Specified by:
        createPlan in interface PlanManager
      • isPlanCreationAllowed

        public boolean isPlanCreationAllowed()
        Check whether or not a plan can be created or not (based on licensing etc) USE SPARINGLY!!!
        Specified by:
        isPlanCreationAllowed in interface PlanManager
        Returns:
        true if a plan can be created otherwise false;
      • triggerConfigUpdatedEventsForPlansInProject

        public void triggerConfigUpdatedEventsForPlansInProject​(@NotNull
                                                                @NotNull Project project)
        Description copied from interface: PlanManager
        Triggers updated events for every plan in a project regardless of permissions.
        Specified by:
        triggerConfigUpdatedEventsForPlansInProject in interface PlanManager
        Parameters:
        project - to trigger event for.
      • deletePlan

        public void deletePlan​(@NotNull
                               @NotNull Plan plan)
        Description copied from interface: PlanManager
        Removes the plan object from the database. Does not do any other clean up work at all Please use the DeletionService rather than using this method directly
        Specified by:
        deletePlan in interface PlanManager
        Parameters:
        plan - to delete.
      • syncDeletionStatusOfJobs

        public void syncDeletionStatusOfJobs()
        Description copied from interface: PlanManager
        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 PlanManager
      • syncDeletionStatusOfPlans

        public void syncDeletionStatusOfPlans()
        Description copied from interface: PlanManager
        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 PlanManager
      • filterFavouritedPlans

        @NotNull
        public @NotNull Set<ImmutableChain> filterFavouritedPlans​(@NotNull
                                                                  @NotNull Collection<? extends ImmutableChain> plans,
                                                                  @NotNull
                                                                  @NotNull com.atlassian.user.User user)
        Description copied from interface: PlanManager
        Return a set of Plans that are a subset of the given TopLevelPlans collection that are favourited by the User. Plans are not filtered by read permission.
        Specified by:
        filterFavouritedPlans in interface PlanManager
        Parameters:
        plans - to filter
        user - to return the favourites of
        Returns:
        a set of Chains that are a subset of the given TopLevelPlans collection that are favourited by the User
      • getFavouritePlansIds

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