public function build(Planning_Milestone $milestone, array $status_count, array $backlog_trackers, $has_user_priority_change_permission, $representation_type) { $this->id = JsonCast::toInt($milestone->getArtifactId()); $this->uri = self::ROUTE . '/' . $this->id; $this->label = $milestone->getArtifactTitle(); $this->status_value = $milestone->getArtifact()->getStatus(); $this->semantic_status = $milestone->getArtifact()->getSemanticStatusValue(); $this->submitted_by = JsonCast::toInt($milestone->getArtifact()->getFirstChangeset()->getSubmittedBy()); $this->submitted_on = JsonCast::toDate($milestone->getArtifact()->getFirstChangeset()->getSubmittedOn()); $this->capacity = JsonCast::toFloat($milestone->getCapacity()); $this->remaining_effort = JsonCast::toFloat($milestone->getRemainingEffort()); $this->sub_milestone_type = $this->getSubmilestoneType($milestone); $this->planning = new PlanningReference(); $this->planning->build($milestone->getPlanning()); $this->project = new ProjectReference(); $this->project->build($milestone->getProject()); $this->artifact = new ArtifactReference(); $this->artifact->build($milestone->getArtifact()); $this->start_date = null; if ($milestone->getStartDate()) { $this->start_date = JsonCast::toDate($milestone->getStartDate()); if ($representation_type === self::ALL_FIELDS) { $this->number_days_since_start = JsonCast::toInt($milestone->getDaysSinceStart()); } } $this->end_date = null; if ($milestone->getEndDate()) { $this->end_date = JsonCast::toDate($milestone->getEndDate()); if ($representation_type === self::ALL_FIELDS) { $this->number_days_until_end = JsonCast::toInt($milestone->getDaysUntilEnd()); } } if ($representation_type === self::ALL_FIELDS) { $this->parent = null; $parent = $milestone->getParent(); if ($parent) { $this->parent = new MilestoneParentReference(); $this->parent->build($parent); } } $this->has_user_priority_change_permission = $has_user_priority_change_permission; $this->sub_milestones_uri = $this->uri . '/' . self::ROUTE; $this->backlog_uri = $this->uri . '/' . BacklogItemRepresentation::BACKLOG_ROUTE; $this->content_uri = $this->uri . '/' . BacklogItemRepresentation::CONTENT_ROUTE; $this->last_modified_date = JsonCast::toDate($milestone->getLastModifiedDate()); if ($representation_type === self::ALL_FIELDS && $status_count) { $this->status_count = $status_count; } $finder = new \AgileDashboard_Milestone_Pane_Planning_SubmilestoneFinder(\Tracker_HierarchyFactory::instance(), PlanningFactory::build()); $submilestone_tracker = $finder->findFirstSubmilestoneTracker($milestone); $submilestone_trackers = array(); if ($submilestone_tracker) { $submilestone_tracker_ref = new TrackerReference(); $submilestone_tracker_ref->build($finder->findFirstSubmilestoneTracker($milestone)); $submilestone_trackers = array($submilestone_tracker_ref); } $this->resources['milestones'] = array('uri' => $this->uri . '/' . self::ROUTE, 'accept' => array('trackers' => $submilestone_trackers)); $this->resources['backlog'] = array('uri' => $this->uri . '/' . BacklogItemRepresentation::BACKLOG_ROUTE, 'accept' => array('trackers' => $this->getTrackersRepresentation($backlog_trackers))); $this->resources['content'] = array('uri' => $this->uri . '/' . BacklogItemRepresentation::CONTENT_ROUTE, 'accept' => array('trackers' => $this->getContentTrackersRepresentation($milestone))); }
public function build($duration, $capacity, array $points) { $this->duration = JsonCast::toInt($duration); $this->capacity = JsonCast::toFloat($capacity); $this->points = array_map(array('\\Tuleap\\REST\\JsonCast', 'toFloat'), $points); return $this; }
public function build(\AgileDashboard_Milestone_Backlog_IBacklogItem $backlog_item, array $card_fields) { $this->id = JsonCast::toInt($backlog_item->id()); $this->label = $backlog_item->title(); $this->status = $backlog_item->status(); $this->type = $backlog_item->type(); $this->short_type = $backlog_item->short_type(); $this->initial_effort = JsonCast::toFloat($backlog_item->getInitialEffort()); $this->color = $backlog_item->color(); $this->artifact = new ArtifactReference(); $this->artifact->build($backlog_item->getArtifact()); $this->project = new ProjectReference(); $this->project->build($backlog_item->getArtifact()->getTracker()->getProject()); $this->parent = null; if ($backlog_item->getParent()) { $this->parent = new BacklogItemParentReference(); $this->parent->build($backlog_item->getParent()); } $this->has_children = $backlog_item->hasChildren(); $this->addAllowedSubItemTypes($backlog_item); if ($card_fields) { $this->card_fields = $card_fields; } }
public function testCastToFloatReturnsNullIfValueIsNull() { $value = null; $this->assertNull(JsonCast::toFloat($value)); }