com.atlassian.greenhopper.service.backlog
Class BacklogHierarchyServiceImpl

java.lang.Object
  extended by com.atlassian.greenhopper.service.backlog.BacklogHierarchyServiceImpl
All Implemented Interfaces:
BacklogHierarchyService

@Service(value="gh-backlogHierarchyService")
public class BacklogHierarchyServiceImpl
extends java.lang.Object
implements BacklogHierarchyService

This service takes the IDs stored through BacklogHierarchyDao and loads the respective backlog structures. This should always be preferred to speaking to the DAO directly.


Field Summary
 
Fields inherited from interface com.atlassian.greenhopper.service.backlog.BacklogHierarchyService
SERVICE
 
Constructor Summary
BacklogHierarchyServiceImpl()
           
 
Method Summary
 java.util.List<Backlog> getAllAncestors(Backlog backlog)
           
 Tree<Backlog> getBacklogTree(Backlog backlog)
           
 java.util.SortedSet<Backlog> getDirectChildren(Backlog backlog)
           
 java.util.SortedSet<Backlog> getDirectChildren(Backlog backlog, Backlog.Status status)
           
 Backlog getDirectParent(Backlog backlog)
           
 boolean hasChildren(Backlog backlog)
           
 boolean isTopLevel(Backlog backlog)
           
 void removeFromHierarchy(Backlog backlog)
          Removes the Backlog from the hierarchy, associating all of its children with the backlogs parent along the way.
 ErrorCollection saveHierarchy(Backlog backlog, java.lang.Long parentId)
          Persist the hierarchy information for the given backlog and parentId.
 java.util.List<Backlog> sortByHierarchy(java.util.SortedSet<Backlog> backlogsToSort)
          Returns a List of backlogs, where all backlogs of the set have been correctly sorted according to the hierarchy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BacklogHierarchyServiceImpl

public BacklogHierarchyServiceImpl()
Method Detail

hasChildren

public boolean hasChildren(Backlog backlog)
Specified by:
hasChildren in interface BacklogHierarchyService
Returns:
true if the provided backlog has children, false otherwise.

isTopLevel

public boolean isTopLevel(Backlog backlog)
Specified by:
isTopLevel in interface BacklogHierarchyService
Returns:
true if the provided backlog is a top level backlog.

getDirectChildren

public java.util.SortedSet<Backlog> getDirectChildren(Backlog backlog)
Specified by:
getDirectChildren in interface BacklogHierarchyService
Returns:
all backlogs that are direct children of the given backlog (child-level = parent-level + 1), or an empty set if there are none

getDirectChildren

public java.util.SortedSet<Backlog> getDirectChildren(Backlog backlog,
                                                      Backlog.Status status)
Specified by:
getDirectChildren in interface BacklogHierarchyService
Returns:
all backlogs that are direct children of the given backlog (child-level = parent-level + 1), or an empty set if there are none

getBacklogTree

public Tree<Backlog> getBacklogTree(Backlog backlog)
Specified by:
getBacklogTree in interface BacklogHierarchyService
Returns:
a Tree representation of the given backlog and its children. This structure can be used to pass around the data rather than making lots of service calls, where appropriate. The tree is a read-only view, use saveHierarchy() for persistence.

getDirectParent

public Backlog getDirectParent(Backlog backlog)
Specified by:
getDirectParent in interface BacklogHierarchyService
Returns:
the backlog that is the parent of the given backlog (parent-level = child-level - 1), or null if there is none

getAllAncestors

public java.util.List<Backlog> getAllAncestors(Backlog backlog)
Specified by:
getAllAncestors in interface BacklogHierarchyService
Returns:
list of all ancestors of the current backlog

sortByHierarchy

public java.util.List<Backlog> sortByHierarchy(java.util.SortedSet<Backlog> backlogsToSort)
Description copied from interface: BacklogHierarchyService
Returns a List of backlogs, where all backlogs of the set have been correctly sorted according to the hierarchy. Note that the root nodes will be sorted in the way as provided by backlogsToSort

Specified by:
sortByHierarchy in interface BacklogHierarchyService
Returns:
list of backlogs sorted by hierarchy with orphans respecting the order of the backlogs that were passed in

saveHierarchy

public ErrorCollection saveHierarchy(Backlog backlog,
                                     java.lang.Long parentId)
Description copied from interface: BacklogHierarchyService
Persist the hierarchy information for the given backlog and parentId. At storage level, there is a list of child-IDs stored for each backlog. This data is always overwritten or created if necessary. This method also takes care of cleanup operations, like removing the child from a possible previous parent.

Specified by:
saveHierarchy in interface BacklogHierarchyService

removeFromHierarchy

public void removeFromHierarchy(Backlog backlog)
Removes the Backlog from the hierarchy, associating all of its children with the backlogs parent along the way.

Specified by:
removeFromHierarchy in interface BacklogHierarchyService
Parameters:
backlog - the backlog to remove


Copyright © 2007-2011 Atlassian. All Rights Reserved.