protected function execute(InputInterface $input, OutputInterface $output)
 {
     $data = $this->transition->export($input->getArgument('project_id'), $input->getArgument('start_date'), $input->getArgument('end_date'));
     if (is_array($data)) {
         Csv::output($data);
     }
 }
Example #2
0
 /**
  * Format row before validation
  *
  * @access public
  * @param  array   $data
  * @return array
  */
 public function prepare(array $row)
 {
     $values = array();
     $values['project_id'] = $this->projectId;
     $values['reference'] = $row['reference'];
     $values['title'] = $row['title'];
     $values['description'] = $row['description'];
     $values['is_active'] = Csv::getBooleanValue($row['is_active']) == 1 ? 0 : 1;
     $values['score'] = (int) $row['score'];
     $values['time_estimated'] = (double) $row['time_estimated'];
     $values['time_spent'] = (double) $row['time_spent'];
     if (!empty($row['assignee'])) {
         $values['owner_id'] = $this->user->getIdByUsername($row['assignee']);
     }
     if (!empty($row['creator'])) {
         $values['creator_id'] = $this->user->getIdByUsername($row['creator']);
     }
     if (!empty($row['color'])) {
         $values['color_id'] = $this->color->find($row['color']);
     }
     if (!empty($row['column'])) {
         $values['column_id'] = $this->board->getColumnIdByTitle($this->projectId, $row['column']);
     }
     if (!empty($row['category'])) {
         $values['category_id'] = $this->category->getIdByName($this->projectId, $row['category']);
     }
     if (!empty($row['swimlane'])) {
         $values['swimlane_id'] = $this->swimlane->getIdByName($this->projectId, $row['swimlane']);
     }
     if (!empty($row['date_due'])) {
         $values['date_due'] = $this->dateParser->getTimestampFromIsoFormat($row['date_due']);
     }
     $this->removeEmptyFields($values, array('owner_id', 'creator_id', 'color_id', 'column_id', 'category_id', 'swimlane_id', 'date_due'));
     return $values;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $data = $this->projectDailyColumnStats->getAggregatedMetrics($input->getArgument('project_id'), $input->getArgument('start_date'), $input->getArgument('end_date'));
     if (is_array($data)) {
         Csv::output($data);
     }
 }
Example #4
0
 /**
  * Process CSV file
  *
  */
 public function step2()
 {
     $values = $this->request->getValues();
     $filename = $this->request->getFilePath('file');
     if (!file_exists($filename)) {
         $this->step1($values, array('file' => array(t('Unable to read your file'))));
     }
     $csv = new Csv($values['delimiter'], $values['enclosure']);
     $csv->setColumnMapping($this->userImport->getColumnMapping());
     $csv->read($filename, array($this->userImport, 'import'));
     if ($this->userImport->counter > 0) {
         $this->session->flash(t('%d user(s) have been imported successfully.', $this->userImport->counter));
     } else {
         $this->session->flashError(t('Nothing have been imported!'));
     }
     $this->response->redirect($this->helper->url->to('userImport', 'step1'));
 }
Example #5
0
 /**
  * Format row before validation
  *
  * @access public
  * @param  array   $data
  * @return array
  */
 public function prepare(array $row)
 {
     $row['username'] = strtolower($row['username']);
     foreach (array('is_admin', 'is_project_admin', 'is_ldap_user') as $field) {
         $row[$field] = Csv::getBooleanValue($row[$field]);
     }
     $this->removeEmptyFields($row, array('password', 'email', 'name'));
     return $row;
 }
Example #6
0
 public function testGetBooleanValue()
 {
     $this->assertEquals(1, Csv::getBooleanValue('1'));
     $this->assertEquals(1, Csv::getBooleanValue('True'));
     $this->assertEquals(1, Csv::getBooleanValue('t'));
     $this->assertEquals(1, Csv::getBooleanValue('TRUE'));
     $this->assertEquals(1, Csv::getBooleanValue('true'));
     $this->assertEquals(1, Csv::getBooleanValue('T'));
     $this->assertEquals(0, Csv::getBooleanValue('0'));
     $this->assertEquals(0, Csv::getBooleanValue('123'));
     $this->assertEquals(0, Csv::getBooleanValue('anything'));
 }