Exemple #1
0
 /**
  * Import citations from a raw citation list to the object
  * described by the given association type and id.
  * @param $request Request
  * @param $assocType int
  * @param $assocId int
  * @param $rawCitationList string
  * @return integer the number of spawned citation checking processes
  */
 function importCitations($request, $assocType, $assocId, $rawCitationList)
 {
     assert(is_numeric($assocType) && is_numeric($assocId));
     $assocType = (int) $assocType;
     $assocId = (int) $assocId;
     // Remove existing citations.
     $this->deleteObjectsByAssocId($assocType, $assocId);
     // Tokenize raw citations
     import('lib.pkp.classes.citation.CitationListTokenizerFilter');
     $citationTokenizer = new CitationListTokenizerFilter();
     $citationStrings = $citationTokenizer->execute($rawCitationList);
     // Instantiate and persist citations
     $citations = array();
     if (is_array($citationStrings)) {
         foreach ($citationStrings as $seq => $citationString) {
             $citation = new Citation($citationString);
             // Initialize the citation with the raw
             // citation string.
             $citation->setRawCitation($citationString);
             // Set the object association
             $citation->setAssocType($assocType);
             $citation->setAssocId($assocId);
             // Set the counter
             $citation->setSequence($seq + 1);
             $this->insertObject($citation);
             $citations[$citation->getId()] = $citation;
         }
     }
     // Check new citations in parallel.
     $noOfProcesses = (int) Config::getVar('general', 'citation_checking_max_processes');
     $processDao = DAORegistry::getDAO('ProcessDAO');
     return $processDao->spawnProcesses($request, 'api.citation.CitationApiHandler', 'checkAllCitations', PROCESS_TYPE_CITATION_CHECKING, $noOfProcesses);
 }