Ejemplo n.º 1
0
 /**
  * Same as exportFullHistory() but only the current state of the artifact
  */
 public function exportSnapshotWithoutComments(SimpleXMLElement $artifacts_xml, Tracker_Artifact_Changeset $changeset)
 {
     $artifact_xml = $artifacts_xml->addChild('artifact');
     $artifact_xml->addAttribute('id', $changeset->getArtifact()->getId());
     $artifact_xml->addAttribute('tracker_id', $changeset->getArtifact()->getTrackerId());
     $this->changeset_exporter->exportWithoutComments($artifact_xml, $changeset);
 }
 public function getFullRESTValue(PFUser $user, Tracker_Artifact_Changeset $changeset)
 {
     $classname_with_namespace = 'Tuleap\\Tracker\\REST\\Artifact\\ArtifactFieldValueFullRepresentation';
     $artifact_field_value_full_representation = new $classname_with_namespace();
     $artifact_field_value_full_representation->build($this->getId(), Tracker_FormElementFactory::instance()->getType($this), $this->getLabel(), (int) $changeset->getArtifact()->getPerTrackerArtifactId());
     return $artifact_field_value_full_representation;
 }
 private function getRawMailForChangeset(Tracker_Artifact_Changeset $changeset)
 {
     $raw_mails = $this->getCachedRawMailByChangesetsForArtifact($changeset->getArtifact());
     $changeset_id = $changeset->getId();
     if (isset($raw_mails[$changeset_id])) {
         return $raw_mails[$changeset_id];
     }
     return null;
 }
 public function exportFullHistory(SimpleXMLElement $artifact_xml, Tracker_Artifact_Changeset $changeset)
 {
     $changeset_xml = $artifact_xml->addChild('changeset');
     $this->user_xml_exporter->exportUserByUserId($changeset->getSubmittedBy(), $changeset_xml, 'submitted_by');
     $submitted_on = $changeset_xml->addChild('submitted_on', date('c', $changeset->getSubmittedOn()));
     $submitted_on->addAttribute('format', 'ISO8601');
     $comments_node = $changeset_xml->addChild('comments');
     if ($changeset->getComment()) {
         $changeset->getComment()->exportToXML($comments_node);
     }
     $this->values_exporter->exportChangedFields($artifact_xml, $changeset_xml, $changeset->getArtifact(), $changeset->getValues());
 }
 private function getCrossReferenceListForREST(Tracker_Artifact_Changeset $changeset)
 {
     $crf = new CrossReferenceFactory($changeset->getArtifact()->getId(), Tracker_Artifact::REFERENCE_NATURE, $this->getTracker()->getGroupId());
     $crf->fetchDatas();
     $list = array();
     $refs = $crf->getFormattedCrossReferences();
     if (!empty($refs['target'])) {
         foreach ($refs['target'] as $refTgt) {
             $list[] = array(self::REST_REF_INDEX => $refTgt['ref'], self::REST_REF_URL => $refTgt['url'], self::REST_REF_DIRECTION => self::REST_REF_DIRECTION_OUT);
         }
     }
     if (!empty($refs['source'])) {
         foreach ($refs['source'] as $refSrc) {
             $list[] = array(self::REST_REF_INDEX => $refSrc['ref'], self::REST_REF_URL => $refSrc['url'], self::REST_REF_DIRECTION => self::REST_REF_DIRECTION_IN);
         }
     }
     if (!empty($refs['both'])) {
         foreach ($refs['both'] as $refBoth) {
             $list[] = array(self::REST_REF_INDEX => $refBoth['ref'], self::REST_REF_URL => $refBoth['url'], self::REST_REF_DIRECTION => self::REST_REF_DIRECTION_BOTH);
         }
     }
     return $list;
 }
 /**
  * Get the value of this field
  *
  * @param Tracker_Artifact_Changeset $changeset   The changeset (needed in only few cases like 'lud' field)
  * @param int                        $value_id    The id of the value
  * @param boolean                    $has_changed If the changeset value has changed from the rpevious one
  *
  * @return Tracker_Artifact_ChangesetValue or null if not found
  */
 public function getChangesetValue($changeset, $value_id, $has_changed)
 {
     $rows = $this->getValueDao()->searchById($value_id, $this->id);
     $artifact_links = $this->getArtifactLinkInfos($rows);
     $reverse_artifact_links = array();
     if ($changeset) {
         $reverse_artifact_links = $this->getReverseLinks($changeset->getArtifact()->getId());
     }
     return new Tracker_Artifact_ChangesetValue_ArtifactLink($value_id, $this, $has_changed, $artifact_links, $reverse_artifact_links);
 }
 public function getFullRESTValue(PFUser $user, Tracker_Artifact_Changeset $changeset)
 {
     $value = new Tracker_FormElement_Field_List_Bind_UsersValue($changeset->getArtifact()->getSubmittedBy());
     $submitted_by_value = $value->getFullRESTValue($this);
     $classname_with_namespace = 'Tuleap\\Tracker\\REST\\Artifact\\ArtifactFieldValueFullRepresentation';
     $artifact_field_value_full_representation = new $classname_with_namespace();
     $artifact_field_value_full_representation->build($this->getId(), Tracker_FormElementFactory::instance()->getType($this), $this->getLabel(), $submitted_by_value);
     return $artifact_field_value_full_representation;
 }
 /**
  * Get the value of this field
  *
  * @param Tracker_Artifact_Changeset $changeset   The changeset (needed in only few cases like 'lud' field)
  * @param int                        $value_id    The id of the value
  * @param boolean                    $has_changed If the changeset value has changed from the previous one
  *
  * @return Tracker_Artifact_ChangesetValue or null if not found
  */
 public function getChangesetValue($changeset, $value_id, $has_changed)
 {
     $changeset_value = null;
     $value_ids = $this->getValueDao()->searchById($value_id, $this->id);
     $ugroups = array();
     foreach ($value_ids as $v) {
         $ugroups[] = $v['ugroup_id'];
     }
     $changeset_value = new Tracker_Artifact_ChangesetValue_PermissionsOnArtifact($value_id, $this, $has_changed, $changeset->getArtifact()->useArtifactPermissions(), $ugroups);
     return $changeset_value;
 }
 /**
  * @see Transition_PostAction::after()
  * @param Tracker_Artifact_Changeset $changeset
  */
 public function after(Tracker_Artifact_Changeset $changeset)
 {
     if (!$this->isDefined()) {
         return;
     }
     $build_parameters = array(self::BUILD_PARAMETER_USER => $changeset->getSubmittedBy(), self::BUILD_PARAMETER_PROJECT_ID => $changeset->getArtifact()->getTracker()->getProject()->getID(), self::BUILD_PARAMETER_ARTIFACT_ID => $changeset->getArtifact()->getId(), self::BUILD_PARAMETER_TRACKER_ID => $changeset->getArtifact()->getTracker()->getId(), self::BUILD_PARAMETER_TRIGGER_FIELD_VALUE => $this->getTransition()->getFieldValueTo()->getLabel());
     try {
         $this->ci_client->launchJobBuild($this->job_url, $build_parameters);
         $feedback = $GLOBALS['Language']->getText('workflow_postaction', 'ci_build_succeeded', array($this->job_url));
         $GLOBALS['Response']->addFeedback('info', $feedback);
     } catch (Jenkins_ClientUnableToLaunchBuildException $exception) {
         $GLOBALS['Response']->addFeedback('error', $exception->getMessage());
     }
 }
Ejemplo n.º 10
0
 /** @return Tracker_Artifact_MailGateway_Recipient */
 public function getFromUserAndChangeset(PFUser $user, Tracker_Artifact_Changeset $changeset)
 {
     $artifact = $changeset->getArtifact();
     return new Tracker_Artifact_MailGateway_Recipient($user, $artifact, $this->getEmail($user, $artifact, $changeset));
 }
 /**
  * Get the value of this field
  *
  * @param Tracker_Artifact_Changeset $changeset   The changeset (needed in only few cases like 'lud' field)
  * @param int                        $value_id    The id of the value
  * @param boolean                    $has_changed If the changeset value has changed from the rpevious one
  *
  * @return Tracker_Artifact_ChangesetValue or null if not found
  */
 public function getChangesetValue($changeset, $value_id, $has_changed)
 {
     $changeset_value = new Tracker_Artifact_ChangesetValue_Date($value_id, $this, $has_changed, $changeset->getArtifact()->getSubmittedOn());
     return $changeset_value;
 }
Ejemplo n.º 12
0
 /**
  * Execute actions after transition happens (if there is one)
  *
  * @param PFUser                     $user               The user who changed things
  * @param Array                      $fields_data        Request field data (array[field_id] => data)
  * @param Tracker_Artifact_Changeset $new_changeset      The changeset that has just been created
  * @param Tracker_Artifact_Changeset $previous_changeset The changeset just before (null for a new artifact)
  *
  * @return void
  */
 public function after(array $fields_data, Tracker_Artifact_Changeset $new_changeset, Tracker_Artifact_Changeset $previous_changeset = null)
 {
     $this->logger->defineFingerprint($new_changeset->getArtifact()->getId());
     $this->logger->start(__METHOD__, $new_changeset->getId(), $previous_changeset ? $previous_changeset->getId() : 'null');
     if (isset($fields_data[$this->getFieldId()])) {
         $transition = $this->getCurrentTransition($fields_data, $previous_changeset);
         if ($transition) {
             $transition->after($new_changeset);
         }
     }
     $this->trigger_rules_manager->processTriggers($new_changeset);
     $this->logger->end(__METHOD__, $new_changeset->getId(), $previous_changeset ? $previous_changeset->getId() : 'null');
 }
Ejemplo n.º 13
0
 public function processTriggers(Tracker_Artifact_Changeset $changeset)
 {
     $this->logger->start(__METHOD__, $changeset->getId());
     $dar_rules = $this->dao->searchForInvolvedRulesIdsByChangesetId($changeset->getId());
     foreach ($dar_rules as $row) {
         $rule = $this->getRuleById($row['rule_id']);
         $this->logger->debug("Found matching rule " . json_encode($rule->fetchFormattedForJson()));
         $this->rules_processor->process($changeset->getArtifact(), $rule);
     }
     $this->logger->end(__METHOD__, $changeset->getId());
 }
 public function getRESTValue(PFUser $user, Tracker_Artifact_Changeset $changeset)
 {
     $classname_with_namespace = 'Tuleap\\Tracker\\REST\\Artifact\\ArtifactFieldValueRepresentation';
     $artifact = $changeset->getArtifact();
     try {
         $start_date = $this->getBurndownStartDate($artifact, $user);
     } catch (Tracker_FormElement_Field_BurndownException $ex) {
         $start_date = null;
     }
     try {
         $duration = $this->getBurndownDuration($artifact, $user);
     } catch (Tracker_FormElement_Field_BurndownException $ex) {
         $duration = null;
     }
     $artifact_field_value_representation = new $classname_with_namespace();
     $artifact_field_value_representation->build($this->getId(), $this->getLabel(), $this->getBurndownData($artifact, $user, $start_date, $duration)->getRESTRepresentation());
     return $artifact_field_value_representation;
 }
Ejemplo n.º 15
0
 private function addSummaryCommentChangeset(Tracker_Artifact $artifact, PFUser $user, Tracker_Artifact_Changeset $from_changeset)
 {
     $original_artifact = $from_changeset->getArtifact();
     $comment = $this->logger->getAllLogs();
     $comment[] = $GLOBALS['Language']->getText('plugin_tracker_artifact', 'copy_artifact_finished', array($original_artifact->getTracker()->getItemName(), $original_artifact->getId()));
     $artifact->createNewChangeset(array(), implode("\n", $comment), $user, true, Tracker_Artifact_Changeset_Comment::TEXT_COMMENT);
 }