private function GivenATrackerHierarchy() { $hierarchy = new Tracker_Hierarchy(); $hierarchy->addRelationship(112, 111); $hierarchy->addRelationship(111, 113); $hierarchy->addRelationship(201, 202); return $hierarchy; }
public function visit(TreeNode $tree_node) { $new_children = array(); foreach ($tree_node->getChildren() as $child_node) { $child_artifact = $child_node->getObject(); if ($this->hierarchy->exists($child_artifact->getTrackerId())) { if ($this->isBacklogPlannableArtifact($child_artifact)) { $new_children[] = $child_node; } else { $new_subchildren = $child_node->accept($this)->getChildren(); $new_children = array_merge($new_children, $new_subchildren); } } } $new_tree_node = new TreeNode(); $new_tree_node->setChildren($new_children); return $new_tree_node; }
public function itReturnsLastlevelTrackerIds() { $hierarchy = new Tracker_Hierarchy(); $grand_pa = 11; $papa = 222; $child = 3333; $grand_uncle = 55; $uncle = 444; $hierarchy->addRelationship($grand_pa, $papa); $hierarchy->addRelationship($grand_pa, $uncle); $hierarchy->addRelationship($papa, $child); $hierarchy->addRelationship(null, $grand_uncle); $expected = array($grand_uncle, $uncle, $child); $result = $hierarchy->getLastLevelTrackerIds(); sort($expected); sort($result); $this->assertEqual($expected, $result); }
public function itReturnsTrackersFromTopToBottomAndTrackerNotInHierarchyAtTheEnd() { $hierarchy = new Tracker_Hierarchy(); $hierarchy->addRelationship(112, 113); $hierarchy->addRelationship(111, 112); $this->assertEqual(array(111, 112, 113, 667, 668, 666), $hierarchy->sortTrackerIds(array(667, 111, 666, 112, 668, 113))); }
private function artifactCanBeAppended($artifact_id, array $artifacts, array $parent_artifact, Tracker_Hierarchy $hierarchy) { return isset($artifacts[$artifact_id]) && $hierarchy->isChild($parent_artifact['tracker_id'], $artifacts[$artifact_id]['tracker_id']); }
/** * If no other trackers were found in hierarchy, returns the tracker alone in hierarchy * * @param array $tracker_ids * @param Tracker_Hierarchy $hierarchy * * @return \Tracker_Hierarchy */ private function fixSingleHierarchy(array $tracker_ids, Tracker_Hierarchy $hierarchy) { if (count($tracker_ids) == 1 && !$hierarchy->flatten()) { $hierarchy->addRelationship($tracker_ids[0], 0); } return $hierarchy; }
public function createKanban() { $kanban_name = $this->request->get('kanban-name'); $tracker_id = $this->request->get('tracker-kanban'); $tracker = $this->tracker_factory->getTrackerById($tracker_id); $user = $this->request->getCurrentUser(); $hierarchy = new Tracker_Hierarchy(); if (!$user->isAdmin($this->group_id)) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('global', 'perm_denied')); return; } if ($this->kanban_manager->doesKanbanExistForTracker($tracker)) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'kanban_tracker_used')); $this->redirectToHome(); return; } try { $hierarchy->getLevel($tracker_id); $is_in_hierarchy = true; } catch (Tracker_Hierarchy_NotInHierarchyException $exeption) { $is_in_hierarchy = false; } if ((count($this->planning_factory->getPlanningsByBacklogTracker($tracker)) > 0 || count($this->planning_factory->getPlanningByPlanningTracker($tracker)) > 0) && !$is_in_hierarchy) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'tracker_used_in_scrum')); $this->redirectToHome(); return; } if ($this->kanban_manager->createKanban($kanban_name, $tracker_id)) { $GLOBALS['Response']->addFeedback(Feedback::INFO, $GLOBALS['Language']->getText('plugin_agiledashboard', 'kanban_created', array($kanban_name))); } else { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_agiledashboard', 'kanban_creation_error', array($kanban_name))); } $this->redirectToHome(); }
private function removeAllConcernedValues(array &$possible_trackers, Tracker_Hierarchy $hierarchy) { foreach ($hierarchy->flatten() as $tracker_id) { unset($possible_trackers[$tracker_id]); } }