com.atlassian.bamboo.labels
Class LabelManagerImpl

java.lang.Object
  extended by com.atlassian.bamboo.labels.LabelManagerImpl
All Implemented Interfaces:
LabelManager

public class LabelManagerImpl
extends Object
implements 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
LabelManagerImpl(LabelDao labelDao, BuildResultsIndexer buildResultsIndexer, PlanManager planManager, ResultsSummaryManager resultsSummaryManager, com.atlassian.event.api.EventPublisher eventPublisher)
           
 
Method Summary
 int addFavourite(Plan plan, com.atlassian.user.User user)
          Adds a build to a user as favourite.
 int addLabel(String labelName, PlanKey planKey, com.atlassian.user.User user)
          Creates a normal label for a plan
 int addLabel(String labelName, PlanResultKey planResultKey, com.atlassian.user.User user)
          Add a label against a build result.
protected  int addLabel(String labelName, String namespace, Project project, Plan plan, PlanResultKey planResultKey, String userName)
           
 boolean addLabels(List<String> labelNames, PlanKey planKey, com.atlassian.user.User user)
          Creates multiple normal labels for a plan
 List<ResultsSummary> findBuildResultsSummaryByLabel(String labelName)
          Finds all ResultsSummary labelled with given labelname
 List<LabelCount> findLabels(String namespace, int maxResults, Plan plan, Project project)
          Finds all labels in a given build, with namespace and maxResults.
 Set<Label> getAllPlanLabels()
          All labels used on a plan level
 List<String> getFavouritesForPlan(ImmutablePlan plan)
          Retrieves a list of usernames which have the given plan set as a favourite.
 List<String> getFavouritesForPlan(Plan plan)
           
 Collection<Label> getLabelsByName(List<String> labelNames)
          Gets list of labels based on label names
 Set<Label> getPlanLabels(ImmutablePlan plan)
          Get labels defined for a plan
 boolean hasBuildResultsLabel(ResultsSummary buildResultsSummary, String label)
          Checks whether the build results summary has a particular label
 boolean hasPlanLabel(Plan plan, String label)
          Checks whether the Plan has a particular label
 boolean isFavourite(ImmutablePlan plan, com.atlassian.user.User user)
          Determines if the build is a user's favourite Note that its more efficient to use PlanManager.filterFavouritedPlans(java.util.Collection, com.atlassian.user.User) if you are performing this operation over a collection of Plans
 boolean isManuallyUnmarkedFavourite(Plan plan, com.atlassian.user.User user)
          Flag which determines if the user has manually unmarked this build as favourite.
 int removeFavourite(Plan plan, com.atlassian.user.User user)
          Removes a build from a user's favourite.
 int removeLabel(String labelName, PlanKey planKey, com.atlassian.user.User user)
          Remove the standard label for a plan (not all the labels for that plan)
 int removeLabel(String labelName, PlanResultKey planResultKey, com.atlassian.user.User user)
          Removes a label against a build result.
protected  int removeLabel(String labelName, String namespace, Project project, ImmutablePlan plan, PlanResultKey planResultKey, String userName)
           
 void saveLabelling(Labelling labelling)
          Saves a specific labelling - does not do any validation or checking.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelManagerImpl

public LabelManagerImpl(LabelDao labelDao,
                        BuildResultsIndexer buildResultsIndexer,
                        PlanManager planManager,
                        ResultsSummaryManager resultsSummaryManager,
                        com.atlassian.event.api.EventPublisher eventPublisher)
Method Detail

saveLabelling

public void saveLabelling(Labelling labelling)
Description copied from interface: LabelManager
Saves a specific labelling - does not do any validation or checking. If not sure - please use addLabel or addFavourite instead

Specified by:
saveLabelling in interface LabelManager
Parameters:
labelling - to save

addLabel

public int addLabel(@Nullable
                    String labelName,
                    @Nullable
                    PlanResultKey planResultKey,
                    @Nullable
                    com.atlassian.user.User user)
Description copied from interface: LabelManager
Add a label against a build result.

Specified by:
addLabel in interface LabelManager
Returns:
an int identifying result of add process

addLabel

public int addLabel(@Nullable
                    String labelName,
                    @Nullable
                    PlanKey planKey,
                    @Nullable
                    com.atlassian.user.User user)
Description copied from interface: LabelManager
Creates a normal label for a plan

Specified by:
addLabel in interface LabelManager
Returns:

addLabels

public boolean addLabels(List<String> labelNames,
                         @Nullable
                         PlanKey planKey,
                         @Nullable
                         com.atlassian.user.User user)
Description copied from interface: LabelManager
Creates multiple normal labels for a plan

Specified by:
addLabels in interface LabelManager
Returns:

addFavourite

public int addFavourite(Plan plan,
                        com.atlassian.user.User user)
Description copied from interface: LabelManager
Adds a build to a user as favourite. Adds a label to the build, with namespace = user name, and label name = ":favourite".

Specified by:
addFavourite in interface LabelManager
Returns:
an int identifying result of add process

removeLabel

public int removeLabel(String labelName,
                       @Nullable
                       PlanResultKey planResultKey,
                       com.atlassian.user.User user)
Description copied from interface: LabelManager
Removes a label against a build result. Will delete the Label entity if there are no more build results tied to it.

Specified by:
removeLabel in interface LabelManager
Returns:
an int identifying result of delete process

removeLabel

public int removeLabel(@Nullable
                       String labelName,
                       @Nullable
                       PlanKey planKey,
                       @Nullable
                       com.atlassian.user.User user)
Description copied from interface: LabelManager
Remove the standard label for a plan (not all the labels for that plan)

Specified by:
removeLabel in interface LabelManager
Returns:

getAllPlanLabels

@NotNull
public Set<Label> getAllPlanLabels()
Description copied from interface: LabelManager
All labels used on a plan level

Specified by:
getAllPlanLabels in interface LabelManager
Returns:
Set of Label related to any plan

getPlanLabels

@NotNull
public Set<Label> getPlanLabels(@NotNull
                                        ImmutablePlan plan)
Description copied from interface: LabelManager
Get labels defined for a plan

Specified by:
getPlanLabels in interface LabelManager
Parameters:
plan - Plan to filter labels with
Returns:
Set of Label related to the plan

removeFavourite

public int removeFavourite(@NotNull
                           Plan plan,
                           @Nullable
                           com.atlassian.user.User user)
Description copied from interface: LabelManager
Removes a build from a user's favourite. Removes labelling object, where namespace = user name, and label name=":favourite".

Specified by:
removeFavourite in interface LabelManager
Returns:
an int identifying result of removal process

hasBuildResultsLabel

public boolean hasBuildResultsLabel(@NotNull
                                    ResultsSummary buildResultsSummary,
                                    @NotNull
                                    String label)
Description copied from interface: LabelManager
Checks whether the build results summary has a particular label

Specified by:
hasBuildResultsLabel in interface LabelManager
Parameters:
buildResultsSummary - @NotNull
label - @NotNull . could be empty
Returns:
Returns true if there is a label object within the correct namespace and a labelling for the ResultsSummary

hasPlanLabel

public boolean hasPlanLabel(@NotNull
                            Plan plan,
                            @NotNull
                            String label)
Description copied from interface: LabelManager
Checks whether the Plan has a particular label

Specified by:
hasPlanLabel in interface LabelManager
Parameters:
plan - @NotNull
label - @NotNull . could be empty
Returns:
Returns true if there is a label object within the correct namespace and a labelling for the Plan

getLabelsByName

public Collection<Label> getLabelsByName(List<String> labelNames)
Description copied from interface: LabelManager
Gets list of labels based on label names

Specified by:
getLabelsByName in interface LabelManager
Returns:
list of labels for all existing labels specified in parameter

findBuildResultsSummaryByLabel

@NotNull
public List<ResultsSummary> findBuildResultsSummaryByLabel(@NotNull
                                                                   String labelName)
Description copied from interface: LabelManager
Finds all ResultsSummary labelled with given labelname

Specified by:
findBuildResultsSummaryByLabel in interface LabelManager
Returns:
List of ResultsSummary

isFavourite

public boolean isFavourite(@NotNull
                           ImmutablePlan plan,
                           @Nullable
                           com.atlassian.user.User user)
Description copied from interface: LabelManager
Determines if the build is a user's favourite Note that its more efficient to use PlanManager.filterFavouritedPlans(java.util.Collection, com.atlassian.user.User) if you are performing this operation over a collection of Plans

Specified by:
isFavourite in interface LabelManager
Returns:
boolean yes or no

isManuallyUnmarkedFavourite

public boolean isManuallyUnmarkedFavourite(@NotNull
                                           Plan plan,
                                           @Nullable
                                           com.atlassian.user.User user)
Description copied from interface: LabelManager
Flag which determines if the user has manually unmarked this build as favourite.

Specified by:
isManuallyUnmarkedFavourite in interface LabelManager
Returns:
boolean flag

getFavouritesForPlan

public List<String> getFavouritesForPlan(Plan plan)
Specified by:
getFavouritesForPlan in interface LabelManager

getFavouritesForPlan

@NotNull
public List<String> getFavouritesForPlan(@NotNull
                                                 ImmutablePlan plan)
Description copied from interface: LabelManager
Retrieves a list of usernames which have the given plan set as a favourite.

Specified by:
getFavouritesForPlan in interface LabelManager
Returns:
list of usernames (as Strings)

findLabels

@NotNull
public List<LabelCount> findLabels(@NotNull
                                           String namespace,
                                           int maxResults,
                                           @Nullable
                                           Plan plan,
                                           @Nullable
                                           Project project)
Description copied from interface: LabelManager
Finds all labels in a given build, with namespace and maxResults.

Specified by:
findLabels in interface LabelManager
project - @return List of LabelCount objects, mapping (Label to count of occurrences.

addLabel

protected int addLabel(@NotNull
                       String labelName,
                       String namespace,
                       Project project,
                       Plan plan,
                       @Nullable
                       PlanResultKey planResultKey,
                       String userName)

removeLabel

protected int removeLabel(@NotNull
                          String labelName,
                          @NotNull
                          String namespace,
                          @NotNull
                          Project project,
                          @NotNull
                          ImmutablePlan plan,
                          @Nullable
                          PlanResultKey planResultKey,
                          @Nullable
                          String userName)


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.