com.atlassian.bamboo.labels
Class LabelManagerImpl

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

public class LabelManagerImpl
extends java.lang.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()
           
 
Method Summary
 int addFavourite(Plan plan, com.atlassian.user.User user)
          Adds a build to a user as favourite.
 int addLabel(java.lang.String labelName, BuildResults buildResults, com.atlassian.user.User user)
          Add a label against a build result.
protected  int addLabel(java.lang.String labelName, java.lang.String namespace, Project project, Plan plan, BuildResults buildResults, java.lang.String userName)
           
 java.util.List<BuildResultsSummary> findBuildResultsSummaryByLabel(java.lang.String labelName)
          Finds all BuildResultsSummary labelled with given labelname
 java.util.List<LabelCount> findLabels(java.lang.String namespace, int maxResults, Build build, Project project)
          Finds all labels in a given build, with namespace and maxResults.
 java.util.List<Label> findLabelsByMatchingString(java.lang.String match, java.lang.String escapeChar)
          Find all labels that match the specified string.
 java.util.List<java.lang.String> getFavouritesForPlan(Plan plan)
          Retrieves a list of usernames which have the given plan set as a favourite.
 java.util.Collection<Label> getLabelsByName(java.util.List<java.lang.String> labelNames)
          Gets list of labels based on label names
 boolean hasBuildResultsLabel(BuildResultsSummary buildResultsSummary, java.lang.String label)
          Checks whether the build results summary has a particular label
 boolean isFavourite(Plan plan, com.atlassian.user.User user)
          Determines if the build is a user's favourite Note that its more efficient to use BuildManager.filterFavouritedBuilds(java.util.Collection, com.atlassian.user.User) if you are performing this operation over a collection of Builds
 boolean isManuallyUnmarkedFavourite(Build build, 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(java.lang.String labelName, BuildResults buildResults, com.atlassian.user.User user)
          Removes a label against a build result.
protected  int removeLabel(java.lang.String labelName, java.lang.String namespace, Project project, Plan plan, BuildResults buildResults, java.lang.String userName)
           
 void setBuildResultsIndexer(BuildResultsIndexer buildResultsIndexer)
           
 void setLabelDao(LabelDao labelDao)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelManagerImpl

public LabelManagerImpl()
Method Detail

addLabel

public int addLabel(@Nullable
                    java.lang.String labelName,
                    @Nullable
                    BuildResults buildResults,
                    @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

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(java.lang.String labelName,
                       BuildResults buildResults,
                       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

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
                                    BuildResultsSummary buildResultsSummary,
                                    @NotNull
                                    java.lang.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 BuildResultsSummary

getLabelsByName

public java.util.Collection<Label> getLabelsByName(java.util.List<java.lang.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

public java.util.List<BuildResultsSummary> findBuildResultsSummaryByLabel(@NotNull
                                                                          java.lang.String labelName)
Description copied from interface: LabelManager
Finds all BuildResultsSummary labelled with given labelname

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

isFavourite

public boolean isFavourite(@NotNull
                           Plan 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 BuildManager.filterFavouritedBuilds(java.util.Collection, com.atlassian.user.User) if you are performing this operation over a collection of Builds

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

isManuallyUnmarkedFavourite

public boolean isManuallyUnmarkedFavourite(@NotNull
                                           Build build,
                                           @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

@NotNull
public java.util.List<java.lang.String> getFavouritesForPlan(@NotNull
                                                                     Plan 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 java.util.List<LabelCount> findLabels(@NotNull
                                                     java.lang.String namespace,
                                                     int maxResults,
                                                     @Nullable
                                                     Build build,
                                                     @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
Returns:
List of LabelCount objects, mapping (Label to count of occurances.

findLabelsByMatchingString

public java.util.List<Label> findLabelsByMatchingString(java.lang.String match,
                                                        java.lang.String escapeChar)
Description copied from interface: LabelManager
Find all labels that match the specified string. Uses wildcard matching, eg LIKE %name%

Specified by:
findLabelsByMatchingString in interface LabelManager
Returns:
list of labels

addLabel

protected int addLabel(@NotNull
                       java.lang.String labelName,
                       java.lang.String namespace,
                       Project project,
                       Plan plan,
                       @Nullable
                       BuildResults buildResults,
                       java.lang.String userName)

removeLabel

protected int removeLabel(@NotNull
                          java.lang.String labelName,
                          @NotNull
                          java.lang.String namespace,
                          @NotNull
                          Project project,
                          @NotNull
                          Plan plan,
                          @Nullable
                          BuildResults buildResults,
                          @Nullable
                          java.lang.String userName)

setLabelDao

public void setLabelDao(LabelDao labelDao)

setBuildResultsIndexer

public void setBuildResultsIndexer(BuildResultsIndexer buildResultsIndexer)


Copyright © 2010 Atlassian. All Rights Reserved.