Author: mj
Date: Mon Oct 31 15:20:03 2011
New Revision: 10235
Log:
More refactoring & fixes against #140. Implement/fix ISAD fields, much more.
Dates/rights/ISAD creators remain.
Modified:
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
trunk/lib/QubitCsvImport.class.php
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/editAction.class.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
Mon Oct 31 14:40:02 2011 (r10234)
+++ trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
Mon Oct 31 15:20:03 2011 (r10235)
@@ -557,6 +557,8 @@
}
$this->resource->save();
+
+ return; // don't bother adding assets etc. for output
}
}
elseif ($request->isMethod('post'))
Modified: trunk/lib/QubitCsvImport.class.php
==============================================================================
--- trunk/lib/QubitCsvImport.class.php Mon Oct 31 14:40:02 2011 (r10234)
+++ trunk/lib/QubitCsvImport.class.php Mon Oct 31 15:20:03 2011 (r10235)
@@ -120,14 +120,16 @@
$parameters = $this->mapIsdiah($parameters);
break;
case 'rad':
+ $parameters = $this->mapInformationObject($parameters);
$parameters = $this->mapRad($parameters);
break;
case 'isad':
+ $parameters = $this->mapInformationObject($parameters);
$parameters = $this->mapIsad($parameters);
break;
}
- $parameterArray[] = $parameters;
+ $parameterArray[] = $this->mapEdit($parameters);
}
// if we have hierarchy information, re-order data rows
@@ -198,6 +200,7 @@
foreach (explode('|', $parameters['parallelName']) as $new_parallelName)
{
$new_parallelNames['new'.$n] = $new_parallelName;
+ $n++;
}
$parameters['parallelName'] = $new_parallelNames;
@@ -205,6 +208,7 @@
foreach (explode('|', $parameters['otherName']) as $new_otherName)
{
$new_otherNames['new'.$n] = $new_otherName;
+ $n++;
}
$parameters['otherName'] = $new_otherNames;
@@ -239,7 +243,7 @@
if (!isset($this->levelsOfDescription))
{
- foreach
(QubitTaxonomy::getTermsById(QubitTaxonomy::LEVEL_OF_DESCRIPTION_ID) as $term)
+ foreach (QubitTerm::getLevelsOfDescription() as $term)
{
$this->levelsOfDescription[] = $term;
}
@@ -252,7 +256,7 @@
if (!isset($this->descriptionDetailLevels))
{
- foreach
(QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_DETAIL_LEVEL_ID) as
$term)
+ foreach (QubitTerm::getDescriptionDetailLevels() as $term)
{
$this->descriptionDetailLevels[] = $term;
}
@@ -265,7 +269,7 @@
if (!isset($this->descriptionStatuss))
{
- foreach
(QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_STATUS_ID) as $term)
+ foreach (QubitTerm::getDescriptionStatuses() as $term)
{
$this->descriptionStatuss[] = $term;
}
@@ -279,12 +283,138 @@
return $parameters;
}
+ protected function mapInformationObject($parameters)
+ {
+ // NB: any value for publication status means set to published
+ if (!empty($parameters['publicationStatus']))
+ {
+ $parameters['publicationStatus'] =
QubitTerm::PUBLICATION_STATUS_PUBLISHED_ID;
+ }
+
+ if (!empty($parameters['repository']))
+ {
+ $repo =
QubitRepository::getByAuthorizedFormOfName($parameters['repository']);
+
+ // if the repository does not exist, create it
+ if (empty($repo))
+ {
+ $repo = new QubitRepository();
+ $repo->authorizedFormOfName = $parameters['repository'];
+ $repo->save();
+ }
+ $parameters['repository'] = $this->context->routing->generate(null,
array($repo, 'module' => 'repository'));
+ }
+
+ // subject access points
+ if (!isset($this->subjects))
+ {
+ foreach (QubitTerm::getSubjects() as $term)
+ {
+ $this->subjects[$term->__toString()] = $term;
+ }
+ }
+
+ $n = 0;
+ foreach (explode('|', $parameters['subjectAccessPoints']) as
$new_subjectAccessPoint)
+ {
+ // if the subject does not exist, create it
+ if (!in_array($new_subjectAccessPoint, $this->subjects) &&
!empty($new_subjectAccessPoint))
+ {
+ $subject = new QubitTerm();
+ $subject->taxonomyId = QubitTaxonomy::SUBJECT_ID;
+ $subject->name = $new_subjectAccessPoint;
+ $subject->save();
+
+ $this->subjects[$subject->__toString()] = $subject;
+ }
+
+ $new_subjectAccessPoints['new'.$n] =
$this->context->routing->generate(null,
array($this->subjects[$new_subjectAccessPoint], 'module' => 'term'));
+ $n++;
+ }
+ $parameters['subjectAccessPoints'] = $new_subjectAccessPoints;
+
+ // place access points
+ if (!isset($this->places))
+ {
+ foreach (QubitTerm::getPlaces() as $term)
+ {
+ $this->places[$term->__toString()] = $term;
+ }
+ }
+
+ $n = 0;
+ foreach (explode('|', $parameters['placeAccessPoints']) as
$new_placeAccessPoint)
+ {
+ // if the place does not exist, create it
+ if (!in_array($new_placeAccessPoint, $this->places) &&
!empty($new_placeAccessPoint))
+ {
+ $place = new QubitTerm();
+ $place->taxonomyId = QubitTaxonomy::PLACE_ID;
+ $place->name = $new_placeAccessPoint;
+ $place->save();
+
+ $this->places[$place->__toString()] = $place;
+ }
+
+ $new_placeAccessPoints['new'.$n] =
$this->context->routing->generate(null,
array($this->places[$new_placeAccessPoint], 'module' => 'term'));
+ $n++;
+ }
+ $parameters['placeAccessPoints'] = $new_placeAccessPoints;
+
+ // name access points
+ if (!isset($this->names))
+ {
+ foreach (QubitActor::getOnlyActors() as $name)
+ {
+ $this->names[$name->__toString()] = $name;
+ }
+ }
+
+ $n = 0;
+ foreach (explode('|', $parameters['nameAccessPoints']) as
$new_nameAccessPoint)
+ {
+ // if the name does not exist, create it
+ if (!in_array($new_nameAccessPoint, $this->names) &&
!empty($new_nameAccessPoint))
+ {
+ $name = new QubitActor();
+ $name->authorizedFormOfName = $new_nameAccessPoint;
+ $name->save();
+
+ $this->names[$name->__toString()] = $name;
+ }
+
+ $new_nameAccessPoints['new'.$n] =
$this->context->routing->generate(null,
array($this->names[$new_nameAccessPoint], 'module' => 'actor'));
+ $n++;
+ }
+ $parameters['nameAccessPoints'] = $new_nameAccessPoints;
+
+ return $parameters;
+ }
+
protected function mapRad($parameters)
{
+ if (!isset($this->materialTypes))
+ {
+ foreach (QubitTerm::getMaterialTypes() as $term)
+ {
+ $this->materialTypes[$term->__toString()] =
$this->context->routing->generate(null, array($term, 'module' => 'term'));
+ }
+ }
+
+ $n = 0;
+ foreach (explode('|', $parameters['type']) as $new_type)
+ {
+ if (in_array($new_type, array_keys($this->materialTypes)))
+ {
+ $new_types['new'.$n] = $this->materialTypes[$new_type];
+ $n++;
+ }
+ }
+ $parameters['type'] = $new_types;
if (!isset($this->radTitleNotes))
{
- foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::RAD_TITLE_NOTE_ID)
as $term)
+ foreach (QubitTerm::getRADTitleNotes() as $term)
{
$this->radTitleNotes[$term->id] = $term;
}
@@ -302,7 +432,7 @@
if (!isset($this->radNotes))
{
- foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::RAD_NOTE_ID) as
$term)
+ foreach (QubitTerm::getRADNotes() as $term)
{
$this->radNotes[$term->id] = $term;
}
@@ -318,13 +448,37 @@
$parameters['radNoteType'] = array_search($parameters['radNoteType'],
$this->radNotes);
}
- return $this->mapEdit($parameters);
+ return $parameters;
}
protected function mapIsad($parameters)
{
- // TODO: refactor into here
- return $this->mapEdit($parameters);
+ // convert pipe-delimited values into multi-value
+ $n = 0;
+ foreach (explode('|', $parameters['newArchivistNote']) as
$new_archivistNote)
+ {
+ $new_archivistNotes['new'.$n] = $new_archivistNote;
+ $n++;
+ }
+ $parameters['newArchivistNote'] = $new_archivistNotes;
+
+ $n = 0;
+ foreach (explode('|', $parameters['newPublicationNote']) as
$new_publicationNote)
+ {
+ $new_publicationNotes['new'.$n] = $new_publicationNote;
+ $n++;
+ }
+ $parameters['newPublicationNote'] = $new_publicationNotes;
+
+ $n = 0;
+ foreach (explode('|', $parameters['newNote']) as $new_Note)
+ {
+ $new_Notes['new'.$n] = $new_Note;
+ $n++;
+ }
+ $parameters['newNote'] = $new_Notes;
+
+ return $parameters;
}
protected function mapIsdiah($parameters)
@@ -340,31 +494,31 @@
unset($parameters['otherName']);
}
- // NB: this is hacky, but required for an inconsistency in repository
naming
- if (!empty($parameters['descStatus']))
+ // NB: this is hacky, but required for an inconsistency in repository
property names
+ if (!isset($this->descriptionDetailLevels))
{
- $parameters['descriptionStatus'] = $parameters['descStatus'];
- unset($parameters['descStatus']);
+ foreach (QubitTerm::getDescriptionDetailLevels() as $term)
+ {
+ $this->descriptionDetailLevels[] = $term;
+ }
}
- if (!empty($parameters['descDetail']))
+ if (!in_array($parameters['descDetail'], $this->descriptionDetailLevels))
{
- $parameters['descriptionDetail'] = $parameters['descDetail'];
unset($parameters['descDetail']);
}
- $parameters = $this->mapEdit($parameters);
-
- if (!empty($parameters['descriptionStatus']))
+ if (!isset($this->descriptionStatuss))
{
- $parameters['descStatus'] = $parameters['descriptionStatus'];
- unset($parameters['descriptionStatus']);
+ foreach (QubitTerm::getDescriptionStatuses() as $term)
+ {
+ $this->descriptionStatuss[] = $term;
+ }
}
- if (!empty($parameters['descriptionDetail']))
+ if (!in_array($parameters['descStatus'], $this->descriptionStatuss))
{
- $parameters['descDetail'] = $parameters['descriptionDetail'];
- unset($parameters['descriptionDetail']);
+ unset($parameters['descStatus']);
}
return $parameters;
Modified:
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/editAction.class.php
==============================================================================
---
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/editAction.class.php
Mon Oct 31 14:40:02 2011 (r10234)
+++
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/editAction.class.php
Mon Oct 31 15:20:03 2011 (r10235)
@@ -191,6 +191,25 @@
*/
protected function updateNotes()
{
+ if ($this->request->hasParameter('csvimport'))
+ {
+ // remap notes from parameters to request object
+ if ($this->request->getParameterHolder()->has('newArchivistNote'))
+ {
+ $this->request->new_archivist_note =
$this->request->getParameterHolder()->get('newArchivistNote');
+ }
+
+ if ($this->request->getParameterHolder()->has('newPublicationNote'))
+ {
+ $this->request->new_publication_note =
$this->request->getParameterHolder()->get('newPublicationNote');
+ }
+
+ if ($this->request->getParameterHolder()->has('newNote'))
+ {
+ $this->request->new_note =
$this->request->getParameterHolder()->get('newNote');
+ }
+ }
+
// Update archivist's notes (multiple)
foreach ((array) $this->request->new_archivist_note as $content)
{
--
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.