public function build(PFUser $user, AgileDashboard_Kanban $kanban, $limit, $offset)
 {
     $dao = new AgileDashboard_KanbanItemDao();
     $factory = Tracker_ArtifactFactory::instance();
     $data = $dao->searchPaginatedBacklogItemsByTrackerId($kanban->getTrackerId(), $limit, $offset);
     $this->total_size = (int) $dao->foundRows();
     $this->collection = array();
     foreach ($data as $row) {
         $artifact = $factory->getInstanceFromRow($row);
         if ($artifact->userCanView($user)) {
             $item_representation = new KanbanItemRepresentation();
             $item_representation->build($artifact, array());
             $this->collection[] = $item_representation;
         }
     }
 }
Esempio n. 2
0
 private function buildItemRepresentation(Tracker_Artifact $artifact)
 {
     $item_representation = new KanbanItemRepresentation();
     $item_in_backlog = $this->kanban_item_manager->isKanbanItemInBacklog($artifact);
     $in_column = $item_in_backlog ? 'backlog' : null;
     if (!$in_column) {
         $item_in_archive = $this->kanban_item_manager->isKanbanItemInArchive($artifact);
         $in_column = $item_in_archive ? 'archive' : null;
     }
     if (!$in_column) {
         $in_column = $this->kanban_item_manager->getColumnIdOfKanbanItem($artifact);
     }
     $item_representation->build($artifact, $this->time_info_factory->getTimeInfo($artifact), $in_column);
     return $item_representation;
 }
Esempio n. 3
0
 /**
  * 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;
 }