public function __construct(\Planning_Milestone $milestone)
 {
     $this->id = JsonCast::toInt($milestone->getArtifactId());
     $this->label = $milestone->getArtifactTitle();
     $this->last_modified = JsonCast::toDate($milestone->getLastModifiedDate());
     $this->uri = self::ROUTE . '/' . $this->id;
 }
 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(Tracker_Artifact_Changeset $changeset, Tracker_Artifact_Changeset_Comment $last_comment, array $values)
 {
     $this->id = JsonCast::toInt($changeset->getId());
     $this->submitted_by = JsonCast::toInt($changeset->getSubmittedBy());
     $this->submitted_on = JsonCast::toDate($changeset->getSubmittedOn());
     $this->email = $changeset->getEmail();
     $this->last_comment = new ChangesetCommentRepresentation();
     $this->last_comment->build($last_comment);
     $this->values = $values;
     $this->last_modified_date = JsonCast::toDate($last_comment->getSubmittedOn());
 }
Ejemplo n.º 4
0
 /** @return array */
 public function getTimeInfo(Tracker_Artifact $artifact)
 {
     $timeinfo = array();
     foreach ($this->dao->searchTimeInfoForItem($artifact->getTrackerId(), $artifact->getId()) as $row) {
         $timeinfo[$row['column_id']] = JsonCast::toDate($row['submitted_on']);
     }
     if (empty($timeinfo)) {
         $timeinfo['kanban'] = null;
     } else {
         $timeinfo['kanban'] = min($timeinfo);
     }
     $timeinfo['archive'] = JsonCast::toDate($this->dao->getTimeInfoForArchivedItem($artifact->getId()));
     return $timeinfo;
 }
 public function build(Tracker_Artifact_Changeset $changeset, PFUser $user, Tracker_Artifact_Changeset_Comment $last_comment, array $values)
 {
     $this->id = JsonCast::toInt($changeset->getId());
     $this->submitted_by = JsonCast::toInt($changeset->getSubmittedBy());
     $this->submitted_by_details = new MinimalUserRepresentation();
     $this->submitted_by_details->build($user);
     $this->submitted_on = JsonCast::toDate($changeset->getSubmittedOn());
     $this->email = $changeset->getEmail();
     $this->last_comment = new ChangesetCommentRepresentation();
     $this->last_comment->build($last_comment);
     $this->values = $values;
     $this->last_modified_by = new MinimalUserRepresentation();
     $this->last_modified_by->build(UserManager::instance()->getUserById($last_comment->getSubmittedBy()));
     $this->last_modified_date = JsonCast::toDate($last_comment->getSubmittedOn());
 }
 public function build(Tracker_Artifact $artifact, array $values)
 {
     $this->id = JsonCast::toInt($artifact->getId());
     $this->uri = self::ROUTE . '/' . $artifact->getId();
     $this->tracker = new ResourceReference();
     $this->tracker->build($artifact->getTrackerId(), TrackerRepresentation::ROUTE);
     $this->project = new ProjectReference();
     $this->project->build($artifact->getTracker()->getProject());
     $this->submitted_by = JsonCast::toInt($artifact->getSubmittedBy());
     $this->submitted_on = JsonCast::toDate($artifact->getSubmittedOn());
     $this->html_url = $artifact->getUri();
     $this->changesets_uri = self::ROUTE . '/' . $this->id . '/' . ChangesetRepresentation::ROUTE;
     $this->values = $values;
     $this->last_modified_date = JsonCast::toDate($artifact->getLastUpdateDate());
 }
Ejemplo n.º 7
0
 public function testCastToDateReturnsNullIfValueIsNull()
 {
     $value = null;
     $this->assertNull(JsonCast::toDate($value));
 }