From: David M. (JIRA) <dem...@vi...> - 2013-10-25 07:02:00
|
<style> /* Changing the layout to use less space for mobiles */ @media screen and (max-device-width: 480px), screen and (-webkit-min-device-pixel-ratio: 2) { #email-body { min-width: 30em !important; } #email-page { padding: 8px !important; } #email-banner { padding: 8px 8px 0 8px !important; } #email-avatar { margin: 1px 8px 8px 0 !important; padding: 0 !important; } #email-fields { padding: 0 8px 8px 8px !important; } #email-gutter { width: 0 !important; } } </style> <div id="email-body"> <table id="email-wrap" align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#f0f0f0;color:#000000;width:100%;"> <tr valign="top"> <td id="email-page" style="padding:16px !important;"> <table align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#ffffff;border:1px solid #bbbbbb;color:#000000;width:100%;"> <tr valign="top"> <td bgcolor="#FFFFFF" style="background-color:#FFFFFF;color:#395fdb;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;line-height:1;"><img src="https://vufind.org/jira/s/en_US-mz3to8-418945332/850/10/_/jira-logo-scaled.png" alt="" style="vertical-align:top;" /></td> </tr><tr valign="top"> <td id="email-banner" style="padding:32px 32px 0 32px;"> <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;"> <tr valign="top"> <td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;padding:0;"> <img id="email-avatar" src="https://vufind.org/jira/secure/useravatar?avatarId=10072" alt="" height="48" width="48" border="0" align="left" style="padding:0;margin: 0 16px 16px 0;" /> <div id="email-action" style="padding: 0 0 8px 0;font-size:12px;line-height:18px;"> <a class="user-hover" rel="dmaus" id="email_dmaus" href="https://vufind.org/jira/secure/ViewProfile.jspa?name=dmaus" style="color:#326ca6;">David Maus</a> created <img src="https://vufind.org/jira/images/icons/issuetypes/improvement.png" height="16" width="16" border="0" align="absmiddle" alt="Improvement"> <a style='color:#326ca6;text-decoration:none;' href='https://vufind.org/jira/browse/VUFIND-924'>VUFIND-924</a> </div> <div id="email-summary" style="font-size:16px;line-height:20px;padding:2px 0 16px 0;"> <a style='color:#326ca6;text-decoration:none;' href='https://vufind.org/jira/browse/VUFIND-924'><strong>Use Command Pattern in search system</strong></a> </div> </td> </tr> </table> </td> </tr> <tr valign="top"> <td id="email-fields" style="padding:0 32px 32px 32px;"> <table border="0" cellpadding="0" cellspacing="0" style="padding:0;text-align:left;width:100%;" width="100%"> <tr valign="top"> <td id="email-gutter" style="width:64px;white-space:nowrap;"></td> <td> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:#505050;">Issue Type:</strong> </td> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;"> <img src="https://vufind.org/jira/images/icons/issuetypes/improvement.png" height="16" width="16" border="0" align="absmiddle" alt="Improvement"> Improvement </td> </tr> <tr valign="top"> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:#505050;">Assignee:</strong> </td> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;"> <a class="user-hover" rel="dmaus" id="email_dmaus" href="https://vufind.org/jira/secure/ViewProfile.jspa?name=dmaus" style="color:#326ca6;">David Maus</a> </td> </tr> <tr valign="top"> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:#505050;">Components:</strong> </td> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;"> Search </td> </tr> <tr valign="top"> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:#505050;">Created:</strong> </td> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;"> 25/Oct/13 3:00 AM </td> </tr> <tr valign="top"> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:#505050;">Description:</strong> </td> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;"> Limitations of the current implementation <br/> <br/> In order to initiate a backend operation via the search system, the operation in question must be known to the search system service. The service resolves the backend name and delegates the call; thus it must know not only the requested operation but also its formal parameters. <br/> <br/> The Command Pattern [19 provides a solution to this be encapsulating the call to the backend method in a Command that is invoked by the search service. Using the command pattern executing a operation works as follows: <br/> <br/> 1. The caller creates a Command object that provides the name of the target backend <br/> 2. The caller passes the command to the service's invoke() method <br/> 3. The service resolves the backend name to a backend instance <br/> 4. The service triggers the .pre event with command and backend instance <br/> 5. The service executes the command <br/> 6. The service triggers the .post event with command and backend instance <br/> <br/> #+BEGIN_SRC php <br/> namespace VuFindSearch; <br/> <br/> class Service <br/> { <br/> // ... <br/> <br/> /** <br/> * Invoke command. <br/> * <br/> * @param Command\CommandInterface $command <br/> * @return void <br/> */ <br/> public function invoke (Command\CommandInterface $command) <br/> { <br/> $backend = $this->resolve($command->getTargetBackendName()); <br/> $this->triggerPre($command, $backend); <br/> try { <br/> $command->execute($backend); <br/> } catch (BackendException $error) { <br/> $this->triggerError($command, $backend, $error); <br/> throw $error; <br/> } <br/> $this->triggerPost($command, $backend); <br/> } <br/> } <br/> #+END_SRC <br/> <br/> The caller can check if the command was executed by calling the command's isExecuted() method and retrieve the result by calling the command's getResult() method. A command SHOULD throw a LogicException if getResult() is called before the command is executed. <br/> <br/> #+BEGIN_SRC php <br/> namespace VuFindSearch\Command <br/> <br/> interface CommandInterface <br/> { <br/> /** <br/> * Return name of target backend. <br/> * <br/> * @return string <br/> */ <br/> public function getTargetBackendName (); <br/> <br/> /** <br/> * Execute command on backend. <br/> * <br/> * @param BackendInterface $backend <br/> * @return mixed <br/> */ <br/> public function execute (BackendInterface $backend); <br/> <br/> /** <br/> * Was the command executed? <br/> * <br/> * @return boolean <br/> */ <br/> public function isExecuted (); <br/> <br/> /** <br/> * Return result of executed operation. <br/> * <br/> * @throws LogicException Command was not yet executed <br/> * <br/> * @return mixed <br/> */ <br/> public function getResult (); <br/> <br/> /** <br/> * Return search parameters. <br/> * <br/> * @return ParamBag <br/> */ <br/> public function getSearchParameters (); <br/> } <br/> #+END_SRC <br/> <br/> Listeners <br/> <br/> One implication of the command pattern is, that Listeners need to check the command class to decide whether they should activate or not. This is not a problem per-se: The search service provides interfaces for common operations (search, retrieve, retrieveBatch etc.) that listeners can check for. <br/> <br/> [1] <a href="http://en.wikipedia.org/wiki/Command_pattern">http://en.wikipedia.org/wiki/Command_pattern</a> </td> </tr> <tr valign="top"> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:#505050;">Fix Versions:</strong> </td> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;"> 2.2 </td> </tr> <tr valign="top"> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:#505050;">Project:</strong> </td> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;"> <a style="color:#326ca6;" href="https://vufind.org/jira/browse/VUFIND">VuFind</a> </td> </tr> <tr valign="top"> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:#505050;">Priority:</strong> </td> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;"> <img src="https://vufind.org/jira/images/icons/priorities/major.png" height="16" width="16" border="0" align="absmiddle" alt="Major"> Major </td> </tr> <tr valign="top"> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;"> <strong style="font-weight:normal;color:#505050;">Reporter:</strong> </td> <td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;"> <a class="user-hover" rel="dmaus" id="email_dmaus" href="https://vufind.org/jira/secure/ViewProfile.jspa?name=dmaus" style="color:#326ca6;">David Maus</a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td><!-- End #email-page --> </tr> <tr valign="top"> <td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:10px;line-height:14px;padding: 0 16px 16px 16px;text-align:center;"> This message is automatically generated by JIRA.<br /> If you think it was sent incorrectly, please contact your JIRA administrators<br /> For more information on JIRA, see: <a style='color:#326ca6;' href='http://www.atlassian.com/software/jira'>http://www.atlassian.com/software/jira</a> </td> </tr> </table><!-- End #email-wrap --> </div><!-- End #email-body --> |