public function build(Tracker_Artifact $artifact) { $this->id = JsonCast::toInt($artifact->getId()); $this->uri = ArtifactRepresentation::ROUTE . '/' . $this->id; $this->tracker = new TrackerReference(); $this->tracker->build($artifact->getTracker()); $this->artifact = $artifact; }
private function addAllowedSubItemTypes(\AgileDashboard_Milestone_Backlog_IBacklogItem $backlog_item) { $child_trackers = $backlog_item->getArtifact()->getTracker()->getChildren(); $this->accept = array('trackers' => array()); foreach ($child_trackers as $child_tracker) { $reference = new TrackerReference(); $reference->build($child_tracker); $this->accept['trackers'][] = $reference; } }
public function build(Tracker_Artifact $artifact, $format = '') { $this->id = JsonCast::toInt($artifact->getId()); $this->uri = ArtifactRepresentation::ROUTE . '/' . $this->id; if ($format) { $this->uri = $this->uri . "?values_format={$format}"; } $this->tracker = new TrackerReference(); $this->tracker->build($artifact->getTracker()); $this->artifact = $artifact; }
public function build(array $backlog_items, array $accepted_trackers, $has_user_priority_change_permission) { $this->content = $backlog_items; $this->accept = array('trackers' => array()); foreach ($accepted_trackers as $accepted_tracker) { $reference = new TrackerReference(); $reference->build($accepted_tracker); $this->accept['trackers'][] = $reference; } $this->has_user_priority_change_permission = $has_user_priority_change_permission; return $this; }
public function build(AgileDashboard_Kanban $kanban, AgileDashboard_KanbanColumnFactory $column_factory, AgileDashboard_KanbanUserPreferences $user_preferences, $user_can_add_in_place, PFUser $user) { $this->id = JsonCast::toInt($kanban->getId()); $this->tracker_id = JsonCast::toInt($kanban->getTrackerId()); $this->uri = self::ROUTE . '/' . $this->id; $this->label = $kanban->getName(); $this->columns = array(); $this->backlog = new KanbanBacklogInfoRepresentation(); $this->backlog->build('Backlog', $user_preferences->isBacklogOpen($kanban, $user), $user_can_add_in_place); $this->archive = new KanbanArchiveInfoRepresentation(); $this->archive->build('Archive', $user_preferences->isArchiveOpen($kanban, $user)); $this->tracker = new TrackerReference(); $this->tracker->build($this->getTracker($kanban)); $this->setColumns($kanban, $column_factory, $user_can_add_in_place, $user); $this->resources = array('backlog' => array('uri' => $this->uri . '/' . self::BACKLOG_ROUTE), 'items' => array('uri' => $this->uri . '/' . self::ITEMS_ROUTE)); }
/** * Add new Kanban Item * * Create a kanban item in the given column or backlog * * <pre> * /!\ Kanban REST routes are under construction and subject to changes /!\ * </pre> * <pre> * /!\ Only works for trackers that allow artifact creation with only a "title" /!\ * </pre> * * @access protected * * @url POST * * @param KanbanItemPOSTRepresentation $item The created kanban item {@from body} {@type Tuleap\AgileDashboard\REST\v1\Kanban\KanbanItemPOSTRepresentation} * * @status 201 */ protected function post(KanbanItemPOSTRepresentation $item) { $current_user = $this->getCurrentUser(); $kanban = $this->getKanban($current_user, $item->kanban_id); $tracker = $this->tracker_factory->getTrackerById($kanban->getTrackerId()); $updater = new ArtifactCreator(new ArtifactValidator($this->form_element_factory), $this->artifact_factory, $this->tracker_factory); $tracker_reference = new TrackerReference(); $tracker_reference->build($tracker); $artifact_fields = $this->buildFieldsData($tracker, $item); $art_ref = $updater->create($current_user, $tracker_reference, $artifact_fields); $artifact = $art_ref->getArtifact(); if (!$artifact) { throw new RestException(500, implode('. ', $GLOBALS['Response']->getFeedbackErrors())); } $this->statistics_aggregator->addKanbanAddInPlaceHit($tracker->getGroupId()); $item_representation = $this->buildItemRepresentation($artifact); if (isset($_SERVER[self::HTTP_CLIENT_UUID]) && $_SERVER[self::HTTP_CLIENT_UUID]) { $rights = array('tracker' => $this->permissions_serializer->getLiteralizedUserGroupsThatCanViewTracker($artifact), 'artifact' => $this->permissions_serializer->getLiteralizedUserGroupsThatCanViewArtifact($artifact)); $this->node_js_client->sendMessage($current_user->getId(), $_SERVER[self::HTTP_CLIENT_UUID], $item->kanban_id, $rights, 'kanban_item:create', $item_representation); } return $item_representation; }
/** * Add new Kanban Item * * Create a kanban item in the given column or backlog * * <pre> * /!\ Kanban REST routes are under construction and subject to changes /!\ * </pre> * <pre> * /!\ Only works for trackers that allow artifact creation with only a "title" /!\ * </pre> * * @access protected * * @url POST * * @param KanbanItemPOSTRepresentation $item The created kanban item {@from body} {@type Tuleap\AgileDashboard\REST\v1\Kanban\KanbanItemPOSTRepresentation} * * @status 201 */ protected function post(KanbanItemPOSTRepresentation $item) { $current_user = $this->getCurrentUser(); $kanban = $this->getKanban($current_user, $item->kanban_id); $tracker = $this->tracker_factory->getTrackerById($kanban->getTrackerId()); $updater = new ArtifactCreator(new ArtifactValidator($this->form_element_factory), $this->artifact_factory, $this->tracker_factory); $tracker_reference = new TrackerReference(); $tracker_reference->build($tracker); $artifact_fields = $this->buildFieldsData($tracker, $item); $art_ref = $updater->create($current_user, $tracker_reference, $artifact_fields); $artifact = $art_ref->getArtifact(); if (!$artifact) { throw new RestException(500, implode('. ', $GLOBALS['Response']->getFeedbackErrors())); } $item_representation = new KanbanItemRepresentation(); $item_representation->build($artifact, $this->time_info_factory->getTimeInfo($artifact)); return $item_representation; }
private function getSubmilestoneType(Planning_Milestone $milestone) { $submilestone_type = null; $child_planning = PlanningFactory::build()->getChildrenPlanning($milestone->getPlanning()); if ($child_planning) { $tracker_reference = new TrackerReference(); $tracker_reference->build($child_planning->getPlanningTracker()); $submilestone_type = $tracker_reference; } return $submilestone_type; }