Example #1
0
 /**
  * @return F4h_TicketConverter_Message_Collection
  */
 public static function getMsgContainer()
 {
     if (!self::$msgCollection) {
         self::$msgCollection = new F4h_TicketConverter_Message_Collection();
     }
     return self::$msgCollection;
 }
Example #2
0
 /**
  * @param $filename
  * @return F4h_TicketConverter_QueueBuilder_Cli_Csv_JiraExport
  */
 public static function getQueueBuilder($filename)
 {
     $ext = pathinfo($filename, PATHINFO_EXTENSION);
     switch ($ext) {
         case 'csv':
             return new F4h_TicketConverter_QueueBuilder_Cli_Csv_JiraExport($filename);
             break;
         default:
             F4h_TicketConverter_Runner::getMsgContainer()->push(new F4h_TicketConverter_Model_Message('FAILURE: unsupported filetype', F4h_TicketConverter_Model_Message::ERROR));
             break;
     }
 }
Example #3
0
 /**
  * @return array
  * @throws F4h_TicketConverter_QueueBuilder_Exception
  */
 public function getIds()
 {
     $input = $this->getInputArgs();
     $ids = $input['ids'];
     $project = $input['project'];
     if (is_array($ids)) {
         foreach ($ids as $entry) {
             if (!is_numeric($entry)) {
                 F4h_TicketConverter_Runner::getMsgContainer()->push(new F4h_TicketConverter_Model_Message("FAILURE: '" . $entry . "' expected to be numeric. input ignored."));
                 continue;
             }
             $this->ids[] = array('project' => $project, 'ticket_id' => $entry);
         }
     } else {
         if (!is_numeric($ids)) {
             throw new F4h_TicketConverter_QueueBuilder_Exception("FAILURE: '" . $ids . "' expected to be numeric.");
         }
         $this->ids[] = array('project' => $project, 'ticket_id' => $entry);
     }
     if (empty($this->ids)) {
         throw new F4h_TicketConverter_QueueBuilder_Exception("FAILURE: no valid ids found");
     }
     return $this->ids;
 }
Example #4
0
 /**
  * @param $ticketId
  * @return F4h_TicketConverter_Model_Ticket|null
  * @throws F4h_TicketConverter_Exception_Jira_Xml
  */
 protected function getTicket($ticketId, $gettingEpic = false)
 {
     $ticket = new F4h_TicketConverter_Model_Ticket();
     $xml = $this->getXml($ticketId, $gettingEpic);
     if ($xml) {
         $xmlData = new SimpleXMLElement($xml);
         //fill ticketmodel with data
         try {
             $item = $xmlData->channel->item;
             $this->fillTicketWithDataStoryPoints($item, $ticket);
             $this->fillTicketWithDataDevTeam($item, $ticket);
             $this->fillTicketWithDataEpic($item, $ticket);
             $this->fillTicketWithDataEpicname($item, $ticket);
             $this->fillTicketWithDataSprint($item, $ticket);
             $this->fillTicketWithDataSubtasks($item, $ticket);
             $this->fillTicketWithDataParents($item, $ticket);
             $ticket->setAssignee($item->assignee);
             $ticket->setId($ticketId);
             $ticket->setKey($item->key);
             $ticket->setReporter($item->reporter);
             $ticket->setSummary($item->summary);
             $ticket->setType($item->type);
         } catch (Exception $e) {
             if ($gettingEpic) {
                 return '';
             }
             F4h_TicketConverter_Runner::getMsgContainer()->push(new F4h_TicketConverter_Model_Message('Es ist ein Fehler aufgetreten. Scheinbar hat sich die Jira XML Struktur geändert.', F4h_TicketConverter_Model_Message::ERROR));
             throw new F4h_TicketConverter_Exception_Jira_Xml('FEHLER: Struktur des Jira XML fehlerhaft.');
         }
     }
     if ($ticket->getId()) {
         return $ticket;
     }
     return null;
 }
Example #5
0
 /**
  * @return bool
  */
 public function buildOutput()
 {
     $responseQueue = $this->getTicketQueue();
     if (count($responseQueue) == 0) {
         F4h_TicketConverter_Runner::getMsgContainer()->clear();
         F4h_TicketConverter_Runner::getMsgContainer()->push(new F4h_TicketConverter_Model_Message('Es wurden keine gültigen Ticketnummern eingegeben.', F4h_TicketConverter_Model_Message::ERROR));
         return false;
     }
     foreach ($responseQueue as $ticket) {
         $ticket->save();
     }
     //get serialized xml buffer
     $serializer = new F4h_TicketConverter_Data_Serializer();
     $xmlString = $serializer->serialize($responseQueue);
     //convert
     $dom = new DOMDocument();
     $dom->loadXML($xmlString);
     $converter = F4h_TicketConverter_Data_Converter_Factory::getConverter();
     $converter->setStylesheet(F4h_TicketConverter_Config::getInstance()->getStylesheetPath());
     $outputPath = $converter->convert($dom);
     return true;
 }
Example #6
0
 /**
  * @covers F4h_TicketConverter_Runner::go
  */
 public function testGo()
 {
     self::assertTrue(F4h_TicketConverter_Runner::go());
 }
Example #7
0
 /**
  * @param bool $isEpic
  * @return bool
  * @throws F4h_TicketConverter_Exception_Jira_Request
  */
 protected function isSuccessful($isEpic = false)
 {
     $requestInfo = curl_getinfo($this->getCurlHandler());
     switch ($requestInfo['http_code']) {
         case '200':
             return true;
             break;
         case '404':
             $ticketUrl = $requestInfo['url'];
             $tmp = substr(strrchr($ticketUrl, '/'), 1);
             $ticketKey = substr($tmp, 0, strrpos($tmp, '.'));
             $message = $ticketKey . ' existiert nicht';
             $errorlevel = F4h_TicketConverter_Model_Message::NOTICE;
             if ($isEpic) {
                 $message = 'Das Epic konnte nicht auf das Ticket gedruckt werden ';
                 $errorlevel = F4h_TicketConverter_Model_Message::INFORMATIONAL;
             }
             F4h_TicketConverter_Runner::getMsgContainer()->push(new F4h_TicketConverter_Model_Message($message, $errorlevel));
             return false;
             break;
         case '401':
             F4h_TicketConverter_Runner::getMsgContainer()->push(new F4h_TicketConverter_Model_Message('Es ist ein Problem aufgetreten. Die Jira Login Daten scheinen fehlerhaft zu sein.', F4h_TicketConverter_Model_Message::ERROR));
             throw new F4h_TicketConverter_Exception_Jira_Request('HTTP 401 -> invalid jira login data');
             break;
         default:
             F4h_TicketConverter_Runner::getMsgContainer()->push(new F4h_TicketConverter_Model_Message('Es scheint zur Zeit ein Problem mit Jira zu geben. Bitte versuchen Sie es später erneut.', F4h_TicketConverter_Model_Message::ERROR));
             throw new F4h_TicketConverter_Exception_Jira_Request('FEHLER: Es scheint zur Zeit ein Problem mit Jira zu geben. Bitte versuchen Sie es später erneut.');
             break;
     }
     exit;
 }
Example #8
0
 /**
  * @param F4h_TicketConverter_Model_Queue $queue
  * @return string
  */
 public function serialize(F4h_TicketConverter_Model_Queue $queue)
 {
     $this->setTicketQueue($queue);
     $buffer = $this->getBuffer();
     $buffer->writeRaw('<?xml version="1.0" encoding="utf-8"?>');
     $buffer->startElement('tickets');
     foreach ($queue as $ticket) {
         $buffer->startElement('ticket');
         $this->createTicketElement($ticket);
         $buffer->endElement();
         F4h_TicketConverter_Runner::getMsgContainer()->push(new F4h_TicketConverter_Model_Message($ticket->getKey(), F4h_TicketConverter_Model_Message::SUCCESS));
     }
     $buffer->endElement();
     return $buffer->outputMemory();
 }
Example #9
0
 /**
  * @return F4h_TicketConverter_Model_Queue|void
  */
 public function build()
 {
     $this->setFileContent();
     if (!$this->inputIsValid()) {
         F4h_TicketConverter_Runner::getMsgContainer()->push(new F4h_TicketConverter_Model_Message("FAILURE: invalid data in file '" . $this->getFilename() . "'", F4h_TicketConverter_Model_Message::ERROR));
         return;
     }
     parent::build();
 }