Author: mcantelon
Date: Mon Apr 2 19:16:49 2012
New Revision: 11346
Log:
Added ability to specify repository when importing.
Modified:
trunk/lib/QubitFlatfileImport.class.php
trunk/lib/task/import/csvImportTask.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Mon Apr 2 18:15:23 2012
(r11345)
+++ trunk/lib/QubitFlatfileImport.class.php Mon Apr 2 19:16:49 2012
(r11346)
@@ -1047,6 +1047,30 @@
}
/**
+ * Create a Qubit repository or, if one already exists, fetch it
+ *
+ * @param string $name name of repository
+ *
+ * @return QubitRepository created or fetched repository
+ */
+ public function createOrFetchRepository($name)
+ {
+ $query = "SELECT r.id FROM actor_i18n a \r
+ INNER JOIN repository r ON a.id=r.id \r
+ WHERE a.authorized_form_of_name=?";
+
+ $statement = QubitFlatfileImport::sqlQuery($query, array($name));
+ $result = $statement->fetch(PDO::FETCH_OBJ);
+
+ if ($result)
+ {
+ return QubitRepository::getById($result->id);
+ } else {
+ return $this->createRepository($name);
+ }
+ }
+
+ /**
* Create a Qubit actor or, if one already exists, fetch it
*
* @param string $name name of actor
@@ -1217,6 +1241,21 @@
}
/**
+ * Create a Qubit repository
+ *
+ * @param string $name name of repository
+ *
+ * @return QubitRepository created repository
+ */
+ public function createRepository($name)
+ {
+ $repo = new QubitRepository;
+ $repo->authorizedFormOfName = $name;
+ $repo->save();
+ return $repo;
+ }
+
+ /**
* Create a Qubit actor
*
* @param string $name name of actor
Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php Mon Apr 2 18:15:23
2012 (r11345)
+++ trunk/lib/task/import/csvImportTask.class.php Mon Apr 2 19:16:49
2012 (r11346)
@@ -220,6 +220,7 @@
'descriptionStatus',
'publicationStatus',
'levelOfDetail',
+ 'repository',
'language',
'script',
'copyrightStatus',
@@ -262,6 +263,13 @@
}
*/
+ // set repository
+ if (isset($self->rowStatusVars['repository']))
+ {
+ $repository =
$self->createOrFetchRepository($self->rowStatusVars['repository']);
+ $self->object->repositoryId = $repository->id;
+ }
+
// set level of detail
if (isset($self->rowStatusVars['levelOfDetail']))
{
--
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.