Author: mcantelon
Date: Tue Jan 17 12:15:05 2012
New Revision: 10697

Log:
Refactored import CLI tools, putting shared functionality into a base class.

Added:
   trunk/lib/task/import/csvImportBaseTask.class.php   (contents, props changed)
Deleted:
   trunk/lib/task/csvAccessionImportTask.class.php
   trunk/lib/task/csvImportTask.class.php
   trunk/lib/task/csvIsaarImportTask.class.php
Modified:
   trunk/lib/task/import/csvAccessionImportTask.class.php

Modified: trunk/lib/task/import/csvAccessionImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvAccessionImportTask.class.php      Tue Jan 17 
11:32:44 2012        (r10696)
+++ trunk/lib/task/import/csvAccessionImportTask.class.php      Tue Jan 17 
12:15:05 2012        (r10697)
@@ -25,50 +25,14 @@
  * @author     Mike Cantelon <[email protected]>
  * @version    SVN: $Id: csvImportTask.class.php 10666 2012-01-13 01:13:48Z 
mcantelon $
  */
-class csvAccessionImportTask extends sfBaseTask
+class csvAccessionImportTask extends csvImportBaseTask
 {
-  /**
-   * @see sfTask
-   */
-  protected function configure()
-  {
-    $this->addArguments(array(
-      new sfCommandArgument('filename', sfCommandArgument::REQUIRED, 'The 
input file (csv format).')
-    ));
-
-    $this->addOptions(array(
-      new sfCommandOption('rows-until-update', null, 
sfCommandOption::PARAMETER_OPTIONAL, 'Output total rows imported every n 
rows.'),
-      new sfCommandOption('skip-rows', null, 
sfCommandOption::PARAMETER_OPTIONAL, 'Skip n rows before importing.'),
-      new sfCommandOption('error-log', null, 
sfCommandOption::PARAMETER_OPTIONAL, 'File to log errors to.'),
-      new sfCommandOption('source-name', null, 
sfCommandOption::PARAMETER_OPTIONAL, 'Source name to use when inserting keymap 
entries.')
-    ));
-
-    $this->namespace        = 'csv';
-    $this->name             = 'accession-import';
-    $this->briefDescription = 'Import csv acession data';
-
-    $this->detailedDescription = <<<EOF
+  protected $namespace        = 'csv';
+  protected $name             = 'accession-import';
+  protected $briefDescription = 'Import csv acession data';
+  protected $detailedDescription = <<<EOF
 Import CSV data
 EOF;
-  }
-
-  protected function validateOptions($options)
-  {
-    $numericOptions = array('rows-until-update', 'skip-rows');
-
-    foreach($numericOptions as $option)
-    {
-      if ($options[$option] && !is_numeric($options[$option]))
-      {
-        throw new sfException($option .' must be an integer');
-      }
-    }
-
-    if ($options['error-log'] && !is_dir(dirname($options['error-log'])))
-    {
-      throw new sfException('Path to error log is invalid.');
-    }
-  }
 
   /**
    * @see sfTask

Added: trunk/lib/task/import/csvImportBaseTask.class.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/lib/task/import/csvImportBaseTask.class.php   Tue Jan 17 12:15:05 
2012        (r10697)
@@ -0,0 +1,64 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * Import csv data
+ *
+ * @package    symfony
+ * @subpackage task
+ * @author     Mike Cantelon <[email protected]>
+ * @version    SVN: $Id$
+ */
+abstract class csvImportBaseTask extends sfBaseTask
+{
+  /**
+   * @see sfTask
+   */
+  protected function configure()
+  {
+    $this->addArguments(array(
+      new sfCommandArgument('filename', sfCommandArgument::REQUIRED, 'The 
input file (csv format).')
+    ));
+
+    $this->addOptions(array(
+      new sfCommandOption('rows-until-update', null, 
sfCommandOption::PARAMETER_OPTIONAL, 'Output total rows imported every n 
rows.'),
+      new sfCommandOption('skip-rows', null, 
sfCommandOption::PARAMETER_OPTIONAL, 'Skip n rows before importing.'),
+      new sfCommandOption('error-log', null, 
sfCommandOption::PARAMETER_OPTIONAL, 'File to log errors to.'),
+      new sfCommandOption('source-name', null, 
sfCommandOption::PARAMETER_OPTIONAL, 'Source name to use when inserting keymap 
entries.')
+    ));
+  }
+
+  protected function validateOptions($options)
+  {
+    $numericOptions = array('rows-until-update', 'skip-rows');
+
+    foreach($numericOptions as $option)
+    {
+      if ($options[$option] && !is_numeric($options[$option]))
+      {
+        throw new sfException($option .' must be an integer');
+      }
+    }
+
+    if ($options['error-log'] && !is_dir(dirname($options['error-log'])))
+    {
+      throw new sfException('Path to error log is invalid.');
+    }
+  }
+}

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to