Package com.atlassian.bamboo.labels
Class LabelManagerImpl
java.lang.Object
com.atlassian.bamboo.labels.LabelManagerImpl
- All Implemented Interfaces:
LabelManager
This manager is not transactional but is thread safe
-
Field Summary
Fields inherited from interface com.atlassian.bamboo.labels.LabelManager
BUILDRESULT_LABEL_NAMESPACE, DEFAULT_MAX_RESULTS, FAVOURITE_LABEL_NAME, FAVOURITE_UNMARK_LABEL_NAME, LABEL_ADDED_TO_BUILD_RESULT, LABEL_CREATED, LABEL_DELETED, LABEL_REMOVED_FROM_BUILD_RESULT, NO_CHANGE -
Constructor Summary
ConstructorsConstructorDescriptionLabelManagerImpl(LabelDao labelDao, JiraIssueUtils jiraIssueUtils, PlanManager planManager, ProjectManager projectManager, ResultsSummaryManager resultsSummaryManager, com.atlassian.event.api.EventPublisher eventPublisher) -
Method Summary
Modifier and TypeMethodDescriptionintaddFavourite(Plan plan, com.atlassian.user.User user) Adds a build to a user as favourite.protected intaddLabel(@NotNull String labelName, String namespace, @Nullable Project project, @Nullable Plan plan, @Nullable ResultsSummary resultsSummary, String userName) intaddLabel(@Nullable String labelName, @Nullable PlanKey planKey, @Nullable com.atlassian.user.User user) Creates a normal label for a planintaddLabel(@Nullable String labelName, @Nullable PlanResultKey planResultKey, @Nullable com.atlassian.user.User user) Add a label against a build result.booleanaddLabels(List<String> labelNames, @Nullable PlanKey planKey, @Nullable com.atlassian.user.User user) Creates multiple normal labels for a plan@NotNull List<ResultsSummary>findBuildResultsSummaryByLabel(@NotNull String labelName) Finds allResultsSummarylabelled with given labelname@NotNull List<LabelCount>findLabels(@NotNull String namespace, int maxResults, @Nullable Plan plan, @Nullable Project project) Finds all labels in a given build, with namespace and maxResults.All labels used on a plan levelgetFavouritesForPlan(@NotNull ImmutablePlan plan) Retrieves a list of usernames which have the given plan set as a favourite.getFavouritesForPlan(Plan plan) getLabelsByName(List<String> labelNames) Gets list of labels based on label namesgetPlanLabels(@NotNull ImmutablePlan plan) Get labels defined for a planbooleanhasBuildResultsLabel(@NotNull ResultsSummary buildResultsSummary, @NotNull String label) Checks whether the build results summary has a particular labelbooleanhasPlanLabel(@NotNull Plan plan, @NotNull String label) Checks whether the Plan has a particular labelbooleanisFavourite(@NotNull ImmutablePlan plan, @Nullable com.atlassian.user.User user) Determines if the build is a user's favourite Note that its more efficient to usePlanManager.filterFavouritedPlans(java.util.Collection, com.atlassian.user.User)if you are performing this operation over a collection ofPlansbooleanisManuallyUnmarkedFavourite(@NotNull Plan plan, @Nullable com.atlassian.user.User user) Flag which determines if the user has manually unmarked this build as favourite.intremoveFavourite(@NotNull Plan plan, @Nullable com.atlassian.user.User user) Removes a build from a user's favourite.protected intremoveLabel(@NotNull String labelName, @NotNull String namespace, @NotNull Project project, @Nullable ImmutablePlan plan, @Nullable ResultsSummary resultsSummary) intremoveLabel(@Nullable String labelName, @Nullable PlanKey planKey, @Nullable com.atlassian.user.User user) Remove the standard label for a plan (not all the labels for that plan)intremoveLabel(String labelName, @Nullable PlanResultKey planResultKey, com.atlassian.user.User user) Removes a label against a build result.voidsaveLabelling(Labelling labelling) Saves a specific labelling - does not do any validation or checking.
-
Constructor Details
-
LabelManagerImpl
public LabelManagerImpl(LabelDao labelDao, JiraIssueUtils jiraIssueUtils, PlanManager planManager, ProjectManager projectManager, ResultsSummaryManager resultsSummaryManager, com.atlassian.event.api.EventPublisher eventPublisher)
-
-
Method Details
-
saveLabelling
Description copied from interface:LabelManagerSaves a specific labelling - does not do any validation or checking. If not sure - please use addLabel or addFavourite instead- Specified by:
saveLabellingin interfaceLabelManager- Parameters:
labelling- to save
-
addLabel
public int addLabel(@Nullable @Nullable String labelName, @Nullable @Nullable PlanResultKey planResultKey, @Nullable @Nullable com.atlassian.user.User user) Description copied from interface:LabelManagerAdd a label against a build result.- Specified by:
addLabelin interfaceLabelManager- Returns:
- an
intidentifying result of add process
-
addLabel
public int addLabel(@Nullable @Nullable String labelName, @Nullable @Nullable PlanKey planKey, @Nullable @Nullable com.atlassian.user.User user) Description copied from interface:LabelManagerCreates a normal label for a plan- Specified by:
addLabelin interfaceLabelManager- Returns:
-
addLabels
public boolean addLabels(List<String> labelNames, @Nullable @Nullable PlanKey planKey, @Nullable @Nullable com.atlassian.user.User user) Description copied from interface:LabelManagerCreates multiple normal labels for a plan- Specified by:
addLabelsin interfaceLabelManager- Returns:
-
addFavourite
Description copied from interface:LabelManagerAdds a build to a user as favourite. Adds a label to the build, with namespace = user name, and label name = ":favourite".- Specified by:
addFavouritein interfaceLabelManager- Returns:
- an
intidentifying result of add process
-
removeLabel
public int removeLabel(String labelName, @Nullable @Nullable PlanResultKey planResultKey, com.atlassian.user.User user) Description copied from interface:LabelManagerRemoves a label against a build result. Will delete the Label entity if there are no more build results tied to it.- Specified by:
removeLabelin interfaceLabelManager- Returns:
- an
intidentifying result of delete process
-
removeLabel
public int removeLabel(@Nullable @Nullable String labelName, @Nullable @Nullable PlanKey planKey, @Nullable @Nullable com.atlassian.user.User user) Description copied from interface:LabelManagerRemove the standard label for a plan (not all the labels for that plan)- Specified by:
removeLabelin interfaceLabelManager- Returns:
-
getAllPlanLabels
Description copied from interface:LabelManagerAll labels used on a plan level- Specified by:
getAllPlanLabelsin interfaceLabelManager- Returns:
- Set of
Labelrelated to any plan
-
getPlanLabels
Description copied from interface:LabelManagerGet labels defined for a plan- Specified by:
getPlanLabelsin interfaceLabelManager- Parameters:
plan-Planto filter labels with- Returns:
- Set of
Labelrelated to the plan
-
removeFavourite
public int removeFavourite(@NotNull @NotNull Plan plan, @Nullable @Nullable com.atlassian.user.User user) Description copied from interface:LabelManagerRemoves a build from a user's favourite. Removes labelling object, where namespace = user name, and label name=":favourite".- Specified by:
removeFavouritein interfaceLabelManager- Returns:
- an
intidentifying result of removal process
-
hasBuildResultsLabel
public boolean hasBuildResultsLabel(@NotNull @NotNull ResultsSummary buildResultsSummary, @NotNull @NotNull String label) Description copied from interface:LabelManagerChecks whether the build results summary has a particular label- Specified by:
hasBuildResultsLabelin interfaceLabelManagerlabel- . could be empty- Returns:
- Returns true if there is a label object within the correct namespace and a labelling for the
ResultsSummary
-
hasPlanLabel
Description copied from interface:LabelManagerChecks whether the Plan has a particular label- Specified by:
hasPlanLabelin interfaceLabelManagerlabel- . could be empty- Returns:
- Returns true if there is a label object within the correct namespace and a labelling for the
Plan
-
getLabelsByName
Description copied from interface:LabelManagerGets list of labels based on label names- Specified by:
getLabelsByNamein interfaceLabelManager- Returns:
- list of labels for all existing labels specified in parameter
-
findBuildResultsSummaryByLabel
@NotNull public @NotNull List<ResultsSummary> findBuildResultsSummaryByLabel(@NotNull @NotNull String labelName) Description copied from interface:LabelManagerFinds allResultsSummarylabelled with given labelname- Specified by:
findBuildResultsSummaryByLabelin interfaceLabelManager- Returns:
ListofResultsSummary
-
isFavourite
public boolean isFavourite(@NotNull @NotNull ImmutablePlan plan, @Nullable @Nullable com.atlassian.user.User user) Description copied from interface:LabelManagerDetermines if the build is a user's favourite Note that its more efficient to usePlanManager.filterFavouritedPlans(java.util.Collection, com.atlassian.user.User)if you are performing this operation over a collection ofPlans- Specified by:
isFavouritein interfaceLabelManager- Returns:
booleanyes or no
-
isManuallyUnmarkedFavourite
public boolean isManuallyUnmarkedFavourite(@NotNull @NotNull Plan plan, @Nullable @Nullable com.atlassian.user.User user) Description copied from interface:LabelManagerFlag which determines if the user has manually unmarked this build as favourite.- Specified by:
isManuallyUnmarkedFavouritein interfaceLabelManager- Returns:
booleanflag
-
getFavouritesForPlan
- Specified by:
getFavouritesForPlanin interfaceLabelManager
-
getFavouritesForPlan
Description copied from interface:LabelManagerRetrieves a list of usernames which have the given plan set as a favourite.- Specified by:
getFavouritesForPlanin interfaceLabelManager- Returns:
- list of usernames (as Strings)
-
findLabels
@NotNull public @NotNull List<LabelCount> findLabels(@NotNull @NotNull String namespace, int maxResults, @Nullable @Nullable Plan plan, @Nullable @Nullable Project project) Description copied from interface:LabelManagerFinds all labels in a given build, with namespace and maxResults.- Specified by:
findLabelsin interfaceLabelManager- Returns:
ListofLabelCountobjects, mapping (Labelto count of occurrences.
-
addLabel
-
removeLabel
protected int removeLabel(@NotNull @NotNull String labelName, @NotNull @NotNull String namespace, @NotNull @NotNull Project project, @Nullable @Nullable ImmutablePlan plan, @Nullable @Nullable ResultsSummary resultsSummary)
-