Author: jablko
Date: Tue Sep 29 13:29:04 2009
New Revision: 3592
Log:
Use MySQL LIKE vs. Lucene for autocomplete responses, fixes issues 1009 and 1019
Added:
trunk/apps/qubit/modules/actor/actions/autocompleteAction.class.php
- copied, changed from r3582,
trunk/apps/qubit/modules/actor/actions/listAction.class.php
trunk/apps/qubit/modules/repository/actions/autocompleteAction.class.php
- copied, changed from r3582,
trunk/apps/qubit/modules/repository/actions/listAction.class.php
Modified:
trunk/apps/qubit/modules/informationobject/templates/editDcSuccess.php
trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
trunk/apps/qubit/modules/informationobject/templates/editModsSuccess.php
trunk/apps/qubit/modules/informationobject/templates/editRadSuccess.php
trunk/apps/qubit/modules/user/templates/editSuccess.php
Copied and modified:
trunk/apps/qubit/modules/actor/actions/autocompleteAction.class.php (from
r3582, trunk/apps/qubit/modules/actor/actions/listAction.class.php)
==============================================================================
--- trunk/apps/qubit/modules/actor/actions/listAction.class.php Mon Sep 28
17:39:44 2009 (r3582, copy source)
+++ trunk/apps/qubit/modules/actor/actions/autocompleteAction.class.php Tue Sep
29 13:29:04 2009 (r3592)
@@ -17,76 +17,22 @@
* along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
- * Show paginated list of actors.
- *
- * @package qubit
- * @subpackage actor
- * @author Peter Van Garderen <[email protected]>
- * @author David Juhasz <[email protected]>
- * @version svn:$Id$
- */
-class ActorListAction extends sfAction
+class ActorAutocompleteAction extends sfAction
{
public function execute($request)
{
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathiInfoPrefix(),
'/').'/', null, $this->request->getHttpHeader('Referer')));
- if ($request->isXmlHttpRequest() && 'actor' == $params['module'])
- {
- return $this->ajaxResponse($request);
- }
- else
- {
- $this->htmlResponse($request);
- }
- }
-
- protected function ajaxResponse($request)
- {
$criteria = new Criteria;
- $criteria->addJoin(QubitActor::ID, QubitActorI18n::ID,
Criteria::INNER_JOIN);
+ $criteria->add(QubitActor::CLASS_NAME, 'QubitActor');
$criteria->add(QubitActorI18n::AUTHORIZED_FORM_OF_NAME,
$request->query.'%', Criteria::LIKE);
- $criteria->add(QubitActorI18n::CULTURE, $this->getUser()->getCulture(),
Criteria::EQUAL);
-
- // Exclude the calling actor from the list
- if (0 < strlen ($notId = $request->getParameter('not')))
- {
- $criteria->add(QubitActor::ID, $notId, Criteria::NOT_EQUAL);
- }
-
$criteria->addAscendingOrderByColumn(QubitActorI18n::AUTHORIZED_FORM_OF_NAME);
- $criteria->setLimit(10);
-
- $actors = QubitActor::get($criteria);
- foreach ($actors as $actor)
- {
- $results[] = array('id' => $actor->id, 'name' =>
$actor->authorizedFormOfName);
- }
+ $criteria->addJoin(QubitActor::ID, QubitActorI18n::ID);
- return $this->renderText(json_encode(array('Results' => $results)));
- }
-
- protected function htmlResponse($request)
- {
- $search = new QubitSearch;
- $query = new Zend_Search_Lucene_Search_Query_Term(new
Zend_Search_Lucene_Index_Term('QubitActor', 'className'));
-
- if (isset($request->query))
- {
- $query = new Zend_Search_Lucene_Search_Query_Boolean(array($query,
Zend_Search_Lucene_Search_QueryParser::parse($request->query)));
- }
-
- $this->pager = new QubitSearchPager;
- $this->pager->hits = $search->getEngine()->getIndex()->find($query);
+ $this->pager = new QubitPager('QubitActor');
+ $this->pager->setCriteria($criteria);
$this->pager->setPage($request->page);
+ $this->pager->init();
- $ids = array();
- foreach ($this->pager->getResults() as $hit)
- {
- $ids[] = $hit->getDocument()->id;
- }
+ $this->actors = $this->pager->getResults();
- $criteria = new Criteria;
- $criteria->add(QubitActor::ID, $ids, Criteria::IN);
- $this->actors = QubitActor::get($criteria);
+ $this->setTemplate('list');
}
}
Modified: trunk/apps/qubit/modules/informationobject/templates/editDcSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/editDcSuccess.php
Tue Sep 29 12:22:41 2009 (r3591)
+++ trunk/apps/qubit/modules/informationobject/templates/editDcSuccess.php
Tue Sep 29 13:29:04 2009 (r3592)
@@ -134,7 +134,7 @@
<?php echo $form->repository->renderLabel() ?>
<?php echo $form->repository->render(array('class' =>
'form-autocomplete')) ?>
<input class="add" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'create')) ?>
#authorized_form_of_name"/>
- <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'list', 'informationObject'
=> $informationObject->id, 'aclAction' => $aclActionId)) ?>"/>
+ <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'autocomplete',
'informationObject' => $informationObject->id, 'aclAction' => $aclActionId))
?>"/>
</div>
<div class="admin-info">
Modified:
trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
Tue Sep 29 12:22:41 2009 (r3591)
+++ trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
Tue Sep 29 13:29:04 2009 (r3592)
@@ -99,14 +99,14 @@
<?php echo $form->creators->render(array('class' =>
'form-autocomplete')) ?>
<?php echo $form->creators->help(__('Record the name of the
organization(s) or the individual(s) responsible for the creation, accumulation
and maintenance of the records in the unit of description. The name should
given in the standardized form as prescribed by international or national
conventions in accordance with the principles of ISAAR(CPF).'))->renderHelp() ?>
<input class="add" type="hidden" value="<?php echo
url_for(array('module' => 'actor', 'action' => 'create')) ?>
#authorized_form_of_name"/>
- <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'actor', 'action' => 'list')) ?>"/>
+ <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'actor', 'action' => 'autocomplete')) ?>"/>
</div>
<div class="form-item">
<?php echo $form->repository->renderLabel() ?>
<?php echo $form->repository->render(array('class' =>
'form-autocomplete')) ?>
<input class="add" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'create')) ?>
#authorized_form_of_name"/>
- <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'list', 'informationObject'
=> $informationObject->id, 'aclAction' => $aclActionId)) ?>"/>
+ <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'autocomplete',
'informationObject' => $informationObject->id, 'aclAction' => $aclActionId))
?>"/>
</div>
<?php echo render_field($form->archivalHistory->help(__('Record the
successive transfers of ownership, responsibility and/or custody of the unit of
description and indicate those actions, such as history of the arrangement,
production of contemporary finding aids, re-use of the records for other
purposes or software migrations, that have contributed to its present structure
and arrangement. Give the dates of these actions, insofar as they can be
ascertained. If the archival history is unknown, record that information.')),
$informationObject, array('class' => 'resizable')) ?>
Modified:
trunk/apps/qubit/modules/informationobject/templates/editModsSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/editModsSuccess.php
Tue Sep 29 12:22:41 2009 (r3591)
+++ trunk/apps/qubit/modules/informationobject/templates/editModsSuccess.php
Tue Sep 29 13:29:04 2009 (r3592)
@@ -100,7 +100,7 @@
<?php echo $form->repository->renderLabel() ?>
<?php echo $form->repository->render(array('class' =>
'form-autocomplete')) ?>
<input class="add" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'create')) ?>
#authorized_form_of_name"/>
- <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'list', 'informationObject'
=> $informationObject->id, 'aclAction' => $aclActionId)) ?>"/>
+ <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'autocomplete',
'informationObject' => $informationObject->id, 'aclAction' => $aclActionId))
?>"/>
</div>
<div class="admin-info">
Modified:
trunk/apps/qubit/modules/informationobject/templates/editRadSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/editRadSuccess.php
Tue Sep 29 12:22:41 2009 (r3591)
+++ trunk/apps/qubit/modules/informationobject/templates/editRadSuccess.php
Tue Sep 29 13:29:04 2009 (r3592)
@@ -60,7 +60,7 @@
<?php echo $form->repository->renderLabel() ?>
<?php echo $form->repository->render(array('class' =>
'form-autocomplete')) ?>
<input class="add" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'create')) ?>
#authorized_form_of_name"/>
- <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'list')) ?>"/>
+ <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'autocomplete')) ?>"/>
</div>
<?php echo $form->identifier->renderRow() ?>
Copied and modified:
trunk/apps/qubit/modules/repository/actions/autocompleteAction.class.php (from
r3582, trunk/apps/qubit/modules/repository/actions/listAction.class.php)
==============================================================================
--- trunk/apps/qubit/modules/repository/actions/listAction.class.php Mon Sep
28 17:39:44 2009 (r3582, copy source)
+++ trunk/apps/qubit/modules/repository/actions/autocompleteAction.class.php
Tue Sep 29 13:29:04 2009 (r3592)
@@ -17,60 +17,21 @@
* along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
- * @package qubit
- * @subpackage repository
- * @author Peter Van Garderen <[email protected]>
- * @version svn:$Id$
- */
-class RepositoryListAction extends sfAction
+class RepositoryAutocompleteAction extends sfAction
{
public function execute($request)
{
- $search = new QubitSearch;
- $query = new Zend_Search_Lucene_Search_Query_Term(new
Zend_Search_Lucene_Index_Term('QubitRepository', 'className'));
-
- // Filter 'denied' repositories if list for repository auto-complete on
info
- // object form
- if (isset($request->informationObject) && isset($request->aclAction))
- {
- $informationObject =
QubitInformationObject::getById($request->informationObject);
- $deniedRepositories = QubitAcl::deniedRepositories($informationObject,
$request->aclAction);
-
- // If all repositories are denied, no response
- if (array('*') == $deniedRepositories)
- {
-
- return sfView::NONE;
- }
-
- $subquery1 = new Zend_Search_Lucene_Search_Query_MultiTerm();
- foreach ($deniedRepositories as $repositoryId)
- {
- $subquery1->addTerm(new Zend_Search_Lucene_Index_Term($repositoryId,
'id'));
- }
-
- $query = new Zend_Search_Lucene_Search_Query_Boolean(array($query));
- $query->addSubquery($subquery1, false /* prohibited */);
- }
-
- if (isset($request->query))
- {
- $query = new Zend_Search_Lucene_Search_Query_Boolean(array($query,
Zend_Search_Lucene_Search_QueryParser::parse($request->query)));
- }
+ $criteria = new Criteria;
+ $criteria->add(QubitActorI18n::AUTHORIZED_FORM_OF_NAME,
$request->query.'%', Criteria::LIKE);
+ $criteria->addJoin(QubitActor::ID, QubitActorI18n::ID);
- $this->pager = new QubitSearchPager;
- $this->pager->hits = $search->getEngine()->getIndex()->find($query);
+ $this->pager = new QubitPager('QubitRepository');
+ $this->pager->setCriteria($criteria);
$this->pager->setPage($request->page);
+ $this->pager->init();
- $ids = array();
- foreach ($this->pager->getResults() as $hit)
- {
- $ids[] = $hit->getDocument()->id;
- }
+ $this->repositories = $this->pager->getResults();
- $criteria = new Criteria;
- $criteria->add(QubitRepository::ID, $ids, Criteria::IN);
- $this->repositories = QubitRepository::get($criteria);
+ $this->setTemplate('list');
}
}
Modified: trunk/apps/qubit/modules/user/templates/editSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/user/templates/editSuccess.php Tue Sep 29
12:22:41 2009 (r3591)
+++ trunk/apps/qubit/modules/user/templates/editSuccess.php Tue Sep 29
13:29:04 2009 (r3592)
@@ -96,7 +96,7 @@
<option value="<?php echo
$this->context->routing->generate(null, array('module' => 'repository',
'action' => 'show', 'id' => $repository->id)) ?>" selected="selected"><?php
echo $repository->getAuthorizedFormOfName(array('cultureFallback' => true))
?></option>
<?php endif; ?>
</select>
- <input class="list" type="hidden" value="<?php echo
$this->context->routing->generate(null, array('module' => 'repository',
'action' => 'list')) ?>" />
+ <input class="list" type="hidden" value="<?php echo
$this->context->routing->generate(null, array('module' => 'repository',
'action' => 'autocomplete')) ?>" />
</div>
</td>
<td>
@@ -133,7 +133,7 @@
<td>
<div style="width: 100%">
<select name="permission[new][repository]" class="form-autocomplete"
id="newRepository"></select>
- <input class="list" type="hidden" value="<?php echo
$this->context->routing->generate(null, array('module' => 'repository',
'action' => 'list')) ?>" />
+ <input class="list" type="hidden" value="<?php echo
$this->context->routing->generate(null, array('module' => 'repository',
'action' => 'autocomplete')) ?>" />
</div>
</td>
<td> </td>
--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---