public function getPaginatedTopMilestonesRepresentations(Project $project, PFUser $user, $representation_type, Tuleap\AgileDashboard\Milestone\Criterion\ISearchOnStatus $criterion, $limit, $offset, $order) { $sub_milestones = $this->milestone_factory->getPaginatedTopMilestones($user, $project, $criterion, $limit, $offset, $order); $submilestones_representations = array(); foreach ($sub_milestones->getMilestones() as $submilestone) { $submilestones_representations[] = $this->getMilestoneRepresentation($submilestone, $user, $representation_type); } return new AgileDashboard_Milestone_PaginatedMilestonesRepresentations($submilestones_representations, $sub_milestones->getTotalSize()); }
private function getTopMilestones(PFUser $user, Project $project) { $top_milestones = array(); $milestones = $this->milestone_factory->getSubMilestones($user, $this->milestone_factory->getVirtualTopMilestone($user, $project)); foreach ($milestones as $milestone) { $top_milestones[] = $milestone; } return $top_milestones; }
private function getSubmilestoneCollection(PFUser $user, Planning_ArtifactMilestone $milestone, Tracker $submilestone_tracker, $redirect_to_self) { $submilestones = array_reverse($this->milestone_factory->getSubMilestones($user, $milestone)); $submilestone_collection = new AgileDashboard_Milestone_Pane_Planning_PlanningSubMilestonePresenterCollection($submilestone_tracker); foreach ($submilestones as $submilestone) { $presenter = $this->submilestone_presenter_factory->getPlanningSubMilestonePresenter($user, $submilestone, $redirect_to_self); $submilestone_collection->push($presenter); } return $submilestone_collection; }
private function loadMilestone() { if (!isset($this->additional_criteria[self::FIELD_NAME])) { return; } if ($this->additional_criteria[self::FIELD_NAME]->getValue() == self::TOP_BACKLOG_IDENTIFIER) { $this->milestone = $this->milestone_factory->getVirtualTopMilestone($this->user, $this->project); return; } $this->milestone = $this->milestone_factory->getBareMilestoneByArtifactId($this->user, $this->additional_criteria[self::FIELD_NAME]->getValue()); $this->milestone_has_been_loaded = true; }
private function getAllMilestonesOfCurrentPlanning() { if (!$this->all_milestones) { $this->all_milestones = $this->milestone_factory->getAllMilestones($this->getCurrentUser(), $this->milestone->getPlanning()); } return $this->all_milestones; }
public function linkToMilestoneParent(Planning_Milestone $milestone, PFUser $user, Tracker_Artifact $artifact_added) { $this->milestone_factory->addMilestoneAncestors($user, $milestone); $parent_milestone = $milestone->getParent(); if (!$parent_milestone) { return; } $parent_milestone_artifact = $parent_milestone->getArtifact(); if (!$this->parentMilestoneHasItemTrackerInItsBacklogTracker($parent_milestone, $artifact_added)) { return; } if (!$this->isParentLinkedToParentMilestone($artifact_added, $parent_milestone_artifact, $user)) { $parent_milestone_artifact->linkArtifact($artifact_added->getId(), $user); $this->linkToMilestoneParent($parent_milestone, $user, $artifact_added); } }
/** * We display an effort based progress bar if and only if all backlog elements * have an initial effort. Otherwise, you might ends with a progress bar at * 100% done with cards "not done". * * @return Cardwall_EffortProgressPresenter */ private function getProgressPresenter() { try { return new Cardwall_RemainingEffortProgressPresenter($this->getInitialEffort(), $this->milestone->getCapacity(), $this->milestone->getRemainingEffort()); } catch (InitialEffortNotDefinedException $exception) { $status_count = $this->milestone_factory->getMilestoneStatusCount($this->user, $this->milestone); return new Cardwall_OpenClosedEffortProgressPresenter($status_count[Tracker_Artifact::STATUS_OPEN], $status_count[Tracker_Artifact::STATUS_CLOSED]); } }
private function getPlanningMilestonesByStatus(Planning $planning) { $user = $this->request->getCurrentUser(); switch ($this->request->get('period')) { case self::PAST_PERIOD: return $this->milestone_factory->getAllClosedMilestones($user, $planning); case self::FUTURE_PERIOD: return $this->milestone_factory->getAllOpenMilestones($user, $planning); default: return $this->milestone_factory->getAllOpenMilestones($user, $planning); } }
private function getMilestoneLinkPresenters() { if (!$this->presenters) { $this->presenters = array(); $milestones = $this->milestone_factory->getLastOpenMilestones($this->user, $this->planning, $this->offset, self::NUMBER_TO_DISPLAY + 1); $icon_factory = new AgileDashboard_PaneIconLinkPresenterCollectionFactory($this->pane_info_factory); foreach ($milestones as $milestone) { $this->presenters[] = new Planning_ShortAccessMilestonePresenter($this, $milestone, $icon_factory->getIconLinkPresenterCollection($milestone), $this->milestone_factory, $this->user, $this->theme_path); } if (!empty($this->presenters)) { end($this->presenters)->setIsLatest(); } $this->presenters = array_reverse($this->presenters); } return $this->presenters; }
private function checkSubMilestoneById(Planning_Milestone $milestone, PFUser $user, $sub_milesone_id) { $sub_milestone = $this->milestone_factory->getBareMilestoneByArtifactId($user, $sub_milesone_id); if (!$sub_milestone) { throw new SubMilestoneDoesNotExistException($sub_milesone_id); } if (!$milestone->milestoneCanBeSubmilestone($sub_milestone)) { throw new ElementCannotBeSubmilestoneException($milestone->getArtifactId(), $sub_milestone->getArtifactId()); } if (!$sub_milestone->getArtifact()->userCanView()) { throw new UserCannotReadSubMilestoneException($sub_milesone_id); } if ($sub_milestone->getParent() && $sub_milestone->getParent()->getArtifactId() != $milestone->getArtifactId()) { throw new SubMilestoneAlreadyHasAParentException($sub_milesone_id); } }
/** * @return AgileDashboard_Milestone_Pane_Planning_PlanningSubMilestonePresenter */ public function getPlanningSubMilestonePresenter(PFUser $user, Planning_ArtifactMilestone $milestone, $redirect_to_self) { $this->milestone_factory->updateMilestoneContextualInfo($user, $milestone); return new AgileDashboard_Milestone_Pane_Planning_PlanningSubMilestonePresenter($milestone, $redirect_to_self, $user, $this->icon_factory->getIconLinkPresenterCollection($milestone)); }
private function generateBareMilestone() { $this->milestone = $this->milestone_factory->getBareMilestone($this->getCurrentUser(), $this->project, $this->request->get('planning_id'), $this->request->get('aid')); }
private function generateVirtualTopMilestone() { $this->milestone = $this->milestone_factory->getVirtualTopMilestone($this->getCurrentUser(), $this->project); }
private function getSubmilestoneIds(PFUser $user, Planning_Milestone $milestone) { $sub_milestones = $this->milestone_factory->getSubMilestones($user, $milestone); return array_map(array($this, 'extractArtifactId'), $sub_milestones); }
private function getAllMilestonesOfCurrentPlanning(Planning_Milestone $milestone) { return $this->milestone_factory->getAllBareMilestones($this->request->getCurrentUser(), $milestone->getPlanning()); }
public function __only__itReturnsNullWhenUserCannotSeeArtifacts() { $planning_tracker = aTracker()->withId(12)->withProject(mock('Project'))->build(); stub($this->planning_factory)->getPlanningByPlanningTracker()->returns(aPlanning()->withId(4)->build()); $artifact = aMockArtifact()->build(); stub($artifact)->userCanView($this->user)->returns(false); stub($this->artifact_factory)->getArtifactById($this->artifact_id)->returns($artifact); $this->assertNull($this->milestone_factory->getBareMilestoneByArtifactId($this->user, $this->artifact_id)); }
private function canUserPrioritizeBacklog(Planning_ArtifactMilestone $milestone, PFUser $user) { $artifact_factory = Tracker_ArtifactFactory::instance(); $milestone_factory = new Planning_MilestoneFactory(PlanningFactory::build(), $artifact_factory, Tracker_FormElementFactory::instance(), TrackerFactory::instance(), new AgileDashboard_Milestone_MilestoneStatusCounter($this->dao, new Tracker_ArtifactDao(), $artifact_factory), new PlanningPermissionsManager(), new AgileDashboard_Milestone_MilestoneDao()); return $milestone_factory->userCanChangePrioritiesInMilestone($milestone, $user); }
private function getSubmilestoneIds(PFUser $user, Planning_Milestone $milestone) { return $this->milestone_factory->getSubMilestoneIds($user, $milestone); }