home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2008 January / Mac_easy_01_08.iso / Software / Office / papers.dmg / Papers.app / Contents / Headers / PapersSearchPluginProtocol.h < prev   
Encoding:
Text File  |  2007-11-01  |  27.1 KB  |  717 lines

  1. //
  2. //  PapersSearchPluginProtocol.h
  3. //
  4. //  Created by Alexander Griekspoor on Fri Jan 23 2007.
  5. //  Copyright (c) 2007 Mekentosj.com. All rights reserved.
  6. // 
  7. //  For use outside of the Papers application structure, please contact
  8. //  feedback@mekentosj.com
  9. //  DO NOT REDISTRIBUTE WITHOUT ALL THE FILES THAT ARE CONTAINED IN THE PACKAGE THAT INCLUDED THIS FILE
  10.  
  11. #import <Cocoa/Cocoa.h>
  12.  
  13. /////////////////////////////////////////////////////////////
  14.  
  15. /*  Searching repositories
  16. Papers allows you through this protocol to write your own search plugins.
  17.  
  18. Note that this file contains three protocols:
  19. @protocol PapersSearchPluginProtocol    - REQUIRED
  20. @protocol PapersMatchPluginProtocol        - OPTIONAL
  21. @protocol PapersAutoMatchPluginProtocol    - OPTIONAL
  22. This allows you to create a plugin that can not only be used as search engine,
  23. but also for matching and auto-matching of papers. The first protocol is required,
  24. the other two are optional. Papers will automatically check which features your
  25. plugin supports.
  26.  
  27. It's important to note that the plugin's method performSearchWithQuery: runs in 
  28. its own thread, although you normally would not have to worry about that, keep 
  29. in mind that if you do fancy stuff you use "performMethodOnMainThread: to prevent
  30. trouble. The plugin signals it's progress to the delegate using a number of delegate 
  31. methods. Make sure you ALWAYS call the delegate methods to signal your progress.
  32. A normal cycle of the plugin would be:
  33.  
  34. Delegate -> Plugin        - (BOOL) readyToPerformSearch;                                // Is the plugin Ready, if not importPreparationError is retrieved.
  35.  
  36. Delegate -> Plugin        - (NSString *)descriptiveStringForQuery: (NSArray *)tokens;     // Delegate uses this to update UI
  37.  
  38. Delegate -> Plugin        - (void) performSearchWithQuery: (NSArray *)query;            // Delegate provides plugin with query, initiates search.
  39.     
  40.         Delegate <- Plugin        - (void)didBeginSearch:(id)sender;                    // Plugin informs delegate that it has started.
  41.  
  42.         Delegate <- Plugin        - (void)didRetrieveObjects:(NSDictionary *)dict;    // Plugin hands over found paper to delegate (optionally repeated).
  43.  
  44.         Delegate <- Plugin        - (void)didEndSearch: (id)sender;                    // Plugin signals it's done.
  45.  
  46. Delegate -> Plugin        - (BOOL) successfulCompletion;                                // Delegate asks plugin if success, if not searchCompletionError is retrieved.
  47.  
  48. Delegate -> Plugin        - (void) performCleanup;                                    // Allows the plugin to cleanup and reset for next import.
  49.  
  50. The structure of the dictionary containing retrieved objects is as follows. Note that you are 
  51. encouraged to fill as many of these fields as you can. You can also provide other fields if 
  52. you wish but these will be ignored within Papers in the current version. Potential 
  53. other programs that also use these plugins might use this info though. 
  54. NOTE: you do not have to list all fields except those marked as obligatory
  55.  
  56. Note that at the root of the dictionary you can provide one or more arrays named:
  57. - papers, an array containing dictionaries representing a paper.
  58. - authors, an array containing dictionaries representing an author.
  59. - journals, an array containing dictionaries representing a journal.
  60. - keywords, an array containing dictionaries representing a keyword.
  61. - publicationTypes, an array containing dictionaries representing a publication type.
  62.  
  63. Each can only occur once (!) and contains an array of the corresponding model dictionaries below.
  64. Usually you will only return Papers, but in case you would like to import a list of journals
  65. or authors irrespective outside the context of a paper this is the way to do it.
  66.  
  67. NOTE: IF YOU ADD AN AUTHOR, JOURNAL, KEYWORD, OR PUBLICATION TYPE TO A PAPER, DON'T ADD IT
  68. SEPARATELY AGAIN IN THE AUTHORS, JOURNALS, KEYWORDS, or PUBLICATION TYPES ARRAYS!! ONLY USE
  69. THE OTHER CATEGORIES IF YOU DON'T IMPORT PAPERS OR IF YOU ADD EXTRA MODEL OBJECTS NOT 
  70. ASSOCIATED TO THE PAPERS YOU IMPORTED.
  71.  
  72. Below follows an example for each category
  73. Unless otherwise noted NSStrings are expected for all field  
  74.  
  75. ////////////////
  76. IMPORTANT NOTE
  77. Papers does not yet support different types than journal articles, 
  78. this will change in version 2.0 and we will adapt some of the fields for this.
  79. ////////////////
  80.  
  81. AUTHORS
  82. - correspondence
  83. - email
  84. - firstName
  85. - homepage
  86. - initials
  87. - lastName - required
  88. - mugshot (NSImage)
  89. - nickName
  90. - notes
  91.  
  92. Example: 
  93.  
  94. <key>authors</key>
  95. <array>
  96.     <dict>
  97.         <key>correspondence</key>
  98.         <string>The European Bioinformatics Institute</string>
  99.         <key>email</key>
  100.         <string>mek@mekentosj.com</string>
  101.         <key>firstName</key>
  102.         <string>Alexander</string>
  103.         <key>homepage</key>
  104.         <string>http://mekentosj.com</string>
  105.         <key>initials</key>
  106.         <string>AC</string>
  107.         <key>lastName</key>
  108.         <string>Griekspoor</string>
  109.         <key>mugshot</key>
  110.         NSImage object
  111.         <key>nickName</key>
  112.         <string>Mek</string>
  113.         <key>notes</key>
  114.         <string>These are example notes</string>
  115.     </dict>
  116.     <dict>
  117.         .. next author ..
  118.     </dict>
  119. </array>
  120.  
  121.  
  122. JOURNALS
  123. - abbreviation
  124. - archives
  125. - authorGuidelines
  126. - cover (NSImage)
  127. - currentissue
  128. - etoc
  129. - homepage
  130. - impactFactor (NSNumber - Float)
  131. - issn
  132. - language
  133. - name - required
  134. - nlmID
  135. - notes
  136. - openAccess (NSNumber - BOOL)
  137. - publisher
  138. - startYear (NSNumber - Int)
  139. - summary
  140.  
  141. Example: 
  142.  
  143. <key>journals</key>
  144. <array>
  145.     <dict>
  146.         <key>abbreviation</key>
  147.         <string>PLoS Biol.</string>
  148.         <key>archives</key>
  149.         <string>http://biology.plosjournals.org/perlserv/?request=get-archive&issn=1545-7885</string>
  150.         <key>authorGuidelines</key>
  151.         <string>http://journals.plos.org/plosbiology/guidelines.php</string>
  152.         <key>cover</key>
  153.         NSImage object
  154.         <key>currentissue</key>
  155.         <string>Vol. 4(12) December 2006</string>
  156.         <key>etoc</key>
  157.         <string>http://biology.plosjournals.org/perlserv/?request=get-toc&issn=1545-7885</string>
  158.         <key>homepage</key>
  159.         <string>http://biology.plosjournals.org/</string>
  160.         <key>impactFactor</key>
  161.         <real>14.2</real>
  162.         <key>issn</key>
  163.         <string>1545-7885</string>
  164.         <key>language</key>
  165.         <string>eng</string>
  166.         <key>name</key>
  167.         <string>PLoS Biology</string>
  168.         <key>nlmID</key>
  169.         <string>101183755</string>
  170.         <key>notes</key>
  171.         <string>More info here...</string>
  172.         <key>openAccess</key>
  173.         <true/>
  174.         <key>publisher</key>
  175.         <string>Public Library of Science</string>
  176.         <key>startYear</key>
  177.         <integer>2003</integer>
  178.         <key>summary</key>
  179.         <string>PLoS Biology is an open-access, peer-reviewed general biology journal published by the Public Library of Science (PLoS), a nonprofit organization of scientists and physicians committed to making the world's scientific and medical literature a public resource. New articles are published online weekly; issues are published monthly.</string>
  180.     </dict>
  181.     <dict>
  182.         .. next journal ..
  183.     </dict>
  184. </array>
  185.  
  186.  
  187. KEYWORDS
  188. - identifier
  189. - name - required
  190. - qualifier
  191. - type
  192. - subtype
  193.  
  194. Example: 
  195.  
  196. <key>keywords</key>
  197. <array>
  198.     <dict>
  199.         <key>identifier</key>
  200.         <string>an identifier</string>
  201.         <key>name</key>
  202.         <string>Breast Cancer</string>
  203.         <key>qualifier</key>
  204.         <string>a qualifier</string>
  205.         <key>subtype</key>
  206.         <string>Major Topic</string>
  207.         <key>type</key>
  208.         <string>MeSH Heading</string>
  209.     </dict>
  210.     <dict>
  211.     .. next keyword ..
  212.     </dict>
  213. </array>
  214.  
  215.  
  216. PUBLICATION TYPES
  217. - name - required
  218.  
  219. Example: 
  220.  
  221. <key>publicationTypes</key>
  222. <array>
  223.     <dict>
  224.         <key>name</key>
  225.         <string>Journal Article</string>
  226.     </dict>
  227.     <dict>
  228.     .. next publication type ..
  229.     </dict>
  230. </array>
  231.  
  232.  
  233. PAPERS
  234. -abstract
  235. -acceptedDate (NSDate)
  236. -affiliation
  237. -authors (NSArray of author dictionaries - see above)
  238. -category
  239. -doi
  240. -image (NSImage)
  241. -issue
  242. -journal (NSArray with a single journal dictionaries - see above)
  243. -keywords (NSArray of keywords dictionaries - see above)
  244. -label
  245. -language
  246. -notes
  247. -openAccess (NSNumber - BOOL)
  248. -pages
  249. -path (NOTE that providing a path to a pdf file will automatically invoke auto-archiving if enabled)
  250. -pii
  251. -identifier (like pmid)
  252. -publicationTypes (NSArray of publication type dictionaries - see above)
  253. -publishedDate (NSDate)
  254. -receivedDate (NSDate)
  255. -revisedDate (NSDate)
  256. -status
  257. -timesCited (NSNumber - Int)
  258. -title
  259. -url
  260. -volume
  261. -year (NSNumber - Int)
  262.  
  263. -tempAuthorString (SEE MATCHING PROTOCOL BELOW)
  264. -tempJournalString (SEE MATCHING PROTOCOL BELOW)
  265.  
  266. Example: 
  267.  
  268. <key>Papers</key>
  269. <array>
  270.     <dict>
  271.         <key>abstract</key>
  272.         <string>MicroRNAs (miRNAs) interact with target...</string>
  273.         <key>acceptedDate</key>
  274.         NSDate object
  275.         <key>affiliation</key>
  276.         <string>Computational Biology Center</string>
  277.         <key>authors</key>
  278.             ... HERE AN ARRAY OF AUTHOR DICTIONARIES LIKE ABOVE ...
  279.         <array/>
  280.         <key>category</key>
  281.         <string>Journal Article</string>
  282.         <key>doi</key>
  283.         <string>10.1371/journal.pbio.0020363</string>
  284.         <key>image</key>
  285.         NSImage object
  286.         <key>issue</key>
  287.         <string>3</string>
  288.         <key>journal</key>
  289.             ... HERE AN ARRAY WITH A SINGLE JOURNAL DICTIONARY LIKE ABOVE ...
  290.         <array/>
  291.         <key>keywords</key>
  292.             ... HERE AN ARRAY OF KEYWORD DICTIONARIES LIKE ABOVE ...
  293.         <array/>
  294.         <key>label</key>
  295.         <string>Cell Biology</string>
  296.         <key>language</key>
  297.         <string>eng</string>
  298.         <key>notes</key>
  299.         <string>Here more info...</string>
  300.         <key>openAccess</key>
  301.         <true/>
  302.         <key>pages</key>
  303.         <string>e363</string>
  304.         <key>path</key>
  305.         <string>/Users/griek/Documents/Papers/1550875.pdf</string>
  306.         <key>pii</key>
  307.         <string>0020363</string>
  308.         <key>identifier</key>
  309.         <string>15502875</string>
  310.         <key>publicationTypes</key>
  311.             ... HERE AN ARRAY OF PUBLICATION TYPE DICTIONARIES LIKE ABOVE ...
  312.         <array/>
  313.         <key>publishedDate</key>
  314.         NSDate object
  315.         <key>receivedDate</key>
  316.         NSDate object
  317.         <key>revisedDate</key>
  318.         NSDate object
  319.         <key>status</key>
  320.         <string>In press</string>
  321.         <key>timesCited</key>
  322.         <integer>12</integer>
  323.         <key>title</key>
  324.         <string>Human MicroRNA targets</string>
  325.         <key>url</key>
  326.         <string>http://biology.plosjournals.org/perlserv/?request=get-document&doi=10.1371/journal.pbio.0020363</string>
  327.         <key>volume</key>
  328.         <string>2</string>
  329.         <key>year</key>
  330.         <integer>2006</integer>
  331.     </dict>
  332. </array>
  333.  
  334. SEE THE COMPLETE EXAMPLE PLIST THAT CAME WITH THIS PACKAGE. 
  335. NOTE THAT WE EXPECT THE ORIGINAL DICTIONARY, NOT A PLIST OR SERIALIZED DICTIONARY
  336.  
  337. */
  338.  
  339. /////////////////////////////////////////////////////////////
  340.  
  341.  
  342. /////////////////////////////////////////////////////////////
  343. /*  USING NSERRORS
  344. NSErrors are returned by two of the methods below in order to allow
  345. the main application to inform the user of problems that occur while 
  346. trying to use the plugin.  
  347. The domain should always be "Papers Importer Error"
  348.  
  349. The user dictionary should have two keys:
  350. "title" and "description".  By default, they will be used to create
  351.  the text of an informative dialog as: "title:  description"
  352.  So design your messages accordingly.  
  353.  
  354.  PLEASE LOCALIZE YOUR MESSAGES WITHIN YOUR PLUGIN
  355.  Make sure the "title" and "description" keys are in an appropriate language by
  356.  the time the application gets the NSError.  This will allow the bundle to be
  357.  entirely self-contained.
  358.  Even if you don't know any other languages, provide the structure within your
  359.  plugin to allow others to do the localization.
  360. */
  361.  
  362. /////////////////////////////////////////////////////////////
  363.  
  364. // THESE ARE METHODS THE PLUGIN DELEGATE IMPLEMENTS AND YOU SHOULD CALL
  365.  
  366. @protocol PapersSearchPluginDelegate <NSObject>
  367.  
  368. // Signal the delegate that you started the search process
  369. // Allows the delegate to prepare the interface before displaying new data
  370. - (void)didBeginSearch:(id)sender;    
  371.  
  372. // Tell the delegate you received the initial number of Papers for the query
  373. // This will trigger the delegate to call your itemsFound method so make sure you
  374. // have can answer that.
  375. - (void)didFindResults:(id)sender;
  376.  
  377. // Provide here an autoreleased dictionary containing the results from your search. The structure of what this
  378. // dictionary should look like is shown above. Papers will convert this dictionary in the corresponding model objects for you.
  379. // If you provide no or an empty dictionary Papers will warn the user no records were found. 
  380. // You can post the results one at the time or in batches or all at once. If you provide them all at once, return nil for
  381. // itemsToImport so that an indeterminate progressbar is shown.
  382. - (void)didRetrieveObjects:(NSDictionary *)dict;        
  383.  
  384. // Signal the delegate that you are done. The delegate will inform how things went so be sure to set any errors and be ready
  385. // to answer didCompleteSuccessfully.
  386. - (void)didEndSearch:(id)sender;                    
  387.  
  388. // Inform the delegate of a status change, use when statusString, foundItems or itemsToRetrieve changes.
  389. // Status updates are automatically issued by calling any of the methods above
  390. - (void)updateStatus:(id)sender;
  391.  
  392. @end
  393.  
  394. @protocol PapersSearchPluginProtocol
  395.  
  396. // gives you a handle to the delegate object to which you deliver results and notify progress (see above)
  397. // do not retain the delegate
  398. - (id)delegate;
  399. - (void)setDelegate: (id)del;
  400.  
  401. // ================================
  402. #pragma mark Repository Information
  403.  
  404. // name returns a string which is shown in the source list and used throughout the UI.
  405. // make sure there are no naming collisions with existing plugins and keep the name rather short.
  406. - (NSString *) name;
  407.  
  408. // allows to return a color for your plugin, like green for google scholar and blue for Pubmed.
  409. // Note: in the plugin test application you can click on the statusbar in the config panel to
  410. // get a color picker that helps you pick a color for the statusbar. The color will be updated and 
  411. // logged into the console so that it can be entered here.
  412. // Important: don't pick a color that is to dark!
  413. - (NSColor *) color;
  414.  
  415. // return the logo as will be displayed in the search box. take a look at the sample plugins for examples.
  416. // suggested size 250w x 50h
  417. - (NSImage *) logo;
  418.  
  419. // return an 37w x 31h icon for use in the statusbar (one with the magnifying class)
  420. - (NSImage *) large_icon;
  421.  
  422. // return an 18w x 16h icon for use in the inspector bar (without a magnifying class)
  423. - (NSImage *) small_icon;
  424.  
  425. // return a 25w x23h icon for use in the source list (normal setting)
  426. - (NSImage *) sourcelist_icon;
  427.  
  428. // return a 20w x 18h icon for use in the source list (small setting)
  429. - (NSImage *) sourcelist_icon_small;
  430.  
  431. // return the weburl to the homepage of the searchengine/repository
  432. - (NSURL *) info_url;
  433.  
  434. // return a unique identifier in the form of a reverse web address of the search engine
  435. - (NSString *) identifier;
  436.  
  437. // return whether the search engine requires a subscription
  438. - (BOOL) requiresSubscription;
  439.  
  440. // return NO if you only wish to use this plugin for matching or automatching
  441. // note that you still need to fullfill the PapersSearchPluginProtocol protocol, 
  442. // you can just leave most of its methods empty in that case.
  443. - (BOOL) actsAsGeneralSearchEngine;
  444.     
  445. // =========================
  446. #pragma mark Preferences
  447.  
  448. // if your plugin needs to be configured you can return here a preference panel. 
  449. // take a look at the example plugin on how to use this.
  450. // Otherwise return nil.
  451. - (NSView *) preferenceView;
  452.  
  453. // ==========================
  454. #pragma mark Query Generation
  455.  
  456. // return a dictionary of predefinedSearchTerms, can be a one or two levels deep.
  457. // the key is the meny item name, if the value is a dictionary it will create a submenu,
  458. // if the value is a string it will be the searchterm that will be filled in upon selection.
  459. //
  460. // Example:
  461. //    <key>Availability</key>
  462. //    <dict>
  463. //        <key>Free Full Text</key>
  464. //        <string>free full text[sb]</string>
  465. //      ...
  466. //    </dict>
  467. //
  468. // Return nil if not applicable      
  469. - (NSDictionary *)predefinedSearchTerms;  //--> show/hide menu!
  470.  
  471. // return a dictionary of searchfield codes that show up as choices in the searchtokens
  472. // the dictionary should contain an array under key "order" and a dictionary under the key "fields" containing 
  473. // key-value pairs where the key is the name of the field and the value a code that 
  474. // your plugin can translate into the right parameters. We advise to adopt the pubmed model of
  475. // field codes. Make sure that it is unlikely that any query a user types in will coincidentally correspond to a field 
  476. // code
  477.  
  478.  
  479. // Example:
  480. //    <key>order</key>
  481. //    <array>
  482. //        <string>First Author</string>
  483. //        ...
  484. //  </array>
  485. //    <key>fields</key>
  486. //    <dict>
  487. //        <key>First Author</key>
  488. //        <string>[1AU]</string>
  489. //      ...
  490. //    </dict>
  491. //
  492. // Return nil if not applicable
  493. - (NSDictionary *)searchFields;  //--> show/hide!
  494.  
  495. // ==========================
  496. #pragma mark Auto-completion
  497.  
  498. // return yes if you wish to autocomplete searchterms
  499. // if you do autocompletion via the internet, be sure to check the server is up!
  500. - (BOOL)autocompletesSearchTerms;
  501. // return an array of strings for the partial string, make sure this stuff works fast!
  502. - (NSArray *)autocompletionsForPartialString: (NSString *)str;
  503.  
  504. // ==========================
  505. #pragma mark Searching
  506.  
  507. // a method to make sure everything's set to go before starting, do some setup or tests here if necessary.
  508. // and a method to find out what the problems are if things aren't set. See above for usage of errorCodes.
  509. // for instance return an error when the service is not up.
  510. - (BOOL) readyToPerformSearch;
  511. - (NSError *) searchPreparationError;
  512.  
  513. // used for the history items and saved folders in the
  514. - (NSString *)descriptiveStringForQuery: (NSArray *)tokens;
  515.  
  516. // return YES if you support cancelling the current search session (strongly advised).
  517. - (BOOL) canCancelSearch;
  518.  
  519. // this method is the main worker method and launches the search process, here you are handed over
  520. // the MTQueryTermTokens that were entered in the searchfield. 
  521. // the tokens have the following key-value compliant fields:
  522. //        NSString *token; - The searchterm like the user entered it
  523. //        NSString *field; - The field that was selected
  524. //      NSString *code; - The code that belongs to the selected field
  525. //        NSString *operatorType; - The operator type (AND, NOT, OR)
  526. //        NSNumber *predefined; - A boolean NSNumber that indicates whether the token was predefined.
  527. //
  528. // also you are handed the offset you have to start from, the first time for a new query this will always be 0
  529. // subsequent pages are fetched by calling this method with an offset which represents the last number of the 
  530. // last number of items you returned. So if you fetched the first time 30 papers, the next time the offset will be 30
  531. // for the next page of results. 
  532. // IMPORTANT: try to always sort results on publication date!
  533. //
  534. // NOTE: that this method runs in a separate thread. Signal your progress to the delegate.
  535. - (void) performSearchWithQuery: (NSArray *)tokens;
  536.  
  537. // informs us that we should stop searching. Since we're running in a thread we should check regularly
  538. // if we have been cancelled
  539. - (void) cancelSearch;
  540.  
  541. // =========================
  542. #pragma mark Saved Searches
  543.  
  544. // NOT YET IMPLEMENTED
  545.  
  546. // when a search is saved it will be regularly updated, only return those results that are new since the given date.
  547. // NOTE that this method runs in a separate thread. Signal your progress to the delegate.
  548. - (void) performSavedSearchWithQuery: (NSArray *)tokens afterDate: (NSDate *)date;
  549.  
  550. // ==========================
  551. #pragma mark Results
  552.  
  553. // number of items that are fetched per batch, default is set by Papers but can be overridden
  554. // internally.
  555. // NOTE: Only applies to the performSearchWithQuery: method
  556. - (NSNumber *)itemsPerPage;
  557. - (void)setItemsPerPage:(NSNumber *)newItemsPerPage;
  558.  
  559. // the offset we have to start fetching from. This is set by Papers before the search is started and
  560. // used when the user wishes to get the next page of results. 
  561. // NOTE: Only applies to the performSearchWithQuery: method
  562. - (NSNumber *)itemOffset;
  563. - (void)setItemOffset:(NSNumber *)newItemOffset;
  564.  
  565. // return the number of items found for this query, this is the total number even if you fetch
  566. // only one page
  567. - (NSNumber *)itemsFound;
  568.  
  569. // return the number of items you are about to retrieve (batch size). 
  570. // return the number of items you have retrieved. 
  571. // As long as this value is nil an indeterminate progress bar is shown, the moment you return a non-nil value for both the 
  572. // progress will be shown to the user. use in combination with the delegate method updateStatus: to push changes to the 
  573. // delegate and force an update.
  574. - (NSNumber *)itemsToRetrieve;
  575. - (NSNumber *)retrievedItems;
  576.  
  577. // return the current status of your plugin to inform the user. make sure these strings are localizable!
  578. // use in combination with the delegate method updateStatus: to push changes to the delegate and force an update.
  579. - (NSString *)statusString;
  580.  
  581. // A method to check whether the search finished properly
  582. // and one to get at any errors that resulted. See above for usage of errorCodes.
  583. - (BOOL) successfulCompletion;
  584. - (NSError *) searchCompletionError;
  585.  
  586. // let the plugin get rid of any data that needs to be reset for a new search.
  587. - (void) performCleanup;
  588.  
  589. // ==========================
  590. #pragma mark Meta-data
  591.  
  592. // return the metadata for the paper with the given identifier
  593. // you will be passed the id as you set it during the search
  594. // return a dictionary with the standard format of a papers entry and the single 
  595. // paper entry or nil if impossible to resolve
  596. // note that this one is asynchronous and you do not signal progress
  597. // to the delegate
  598. // if you want to run asynchronous use the method below with a single 
  599. // identifier in an array
  600. - (NSDictionary *)metadataForID: (NSString *)identifier;
  601.  
  602. // return the metadata for the papers with the given identifiers
  603. // you will be passed the ids as you set it during the search
  604. // return nil if impossible to resolve
  605. // NOTE that this method runs in a separate thread. Signal your progress to the delegate.
  606. - (void)metadataForIDs: (NSArray *)identifiers;
  607.  
  608. // ==========================
  609. #pragma mark Follow-up
  610.  
  611. // return the URL to the paper within the repository
  612. // you will be passed the id as you set it during the search
  613. // return nil if impossible to resolve
  614. - (NSURL *)repositoryURLForID: (NSString *)identifier;
  615.  
  616. // return the URL to the paper at the publisher's website, preferably fulltext
  617. // you will be passed the id as you set it during the search
  618. // return nil if impossible to resolve
  619. - (NSURL *)publisherURLForID: (NSString *)identifier;
  620.  
  621. // return the URL to the PDF ofthe paper
  622. // you will be passed the id as you set it during the search
  623. // return nil if impossible to resolve
  624. // IMPORTANT: if you return nil Papers will do its best to automatically retrieve the PDF on the basis of 
  625. // the publisherURLForID as returned above. ONLY return a link for a PDF here if a) you are sure you
  626. // know the location or b) you think you can do some fancy lookup that outperforms Papers build in attempts.
  627. - (NSURL *)pdfURLForID: (NSString *)identifier;
  628.  
  629. // ==========================
  630. #pragma mark Related Articles
  631.  
  632. // return whether your plugin supports the retrieval of related articles or not.
  633. - (BOOL) supportsRelatedArticles;
  634.  
  635. // return related articles in the same way you return search results.
  636. // you will be passed the id as you set it during the search.
  637. // NOTE: that this method runs in a separate thread. Signal your progress to the delegate.
  638. // IMPORTANT: You can optionally add one extra parameter per paper which is a "score" (NSNumber between 0.0 and 1.0).
  639. - (void) getRelatedArticlesForID: (NSString *)identifier;
  640.  
  641. // ==========================
  642. #pragma mark Recent Articles
  643.  
  644. // These methods are used to find recently published articles for authors, journals or keywords
  645. // Like with matching (see below) you can optimize for speed by returning a limited set of fields:
  646. // - ID, Title, Name, Year, Volume, Issue, Pages, Authors, Journal, Publication Date (these are the minimum)
  647. // In addition you can also return two other variables that replace a number of these
  648. // fields which saves you from parsing complicated strings (this will be done anyway once the match is selected by the user:
  649. // - tempAuthorString -> return a string of authors (see pubmed example) as a whole instead of all authors separately
  650. // - tempJournalString -> return a single string representing the publication (e.g. "Nature 2005, vol. 16(2) pp. 400-123")
  651. // if you return the latter you don't have to return the individual journal, volume, year, issue, pages fields, those will be ignored
  652.  
  653. // return recent articles for the provided author
  654. // you will be passed a dictionary representation of the author during the search
  655. // NOTE that this method runs in a separate thread. Signal your progress to the delegate.
  656. - (void)recentArticlesForAuthor: (NSDictionary *)author;
  657.  
  658. // return recent articles for the provided journal
  659. // you will be passed a dictionary representation of the journal during the search
  660. // NOTE that this method runs in a separate thread. Signal your progress to the delegate.
  661. - (void)recentArticlesForJournal: (NSDictionary *)journal;
  662.  
  663. // return recent articles for the provided keyword
  664. // you will be passed a dictionary representation of the keyword during the search
  665. // NOTE that this method runs in a separate thread. Signal your progress to the delegate.
  666. - (void)recentArticlesForKeyword: (NSDictionary *)keyword;
  667.  
  668. @end
  669.  
  670. // Optional - By implementing this you will be automatically added to the matching list
  671.  
  672. @protocol PapersMatchPluginProtocol
  673.  
  674. // return the logo as will be displayed in the matching search box (this one is smaller than that for the search engine). 
  675. // take a look at the sample plugins for examples.
  676. // suggested size 115w x 40h
  677. - (NSImage *) small_logo;
  678.  
  679. // this method is the main worker method and launches the search process for matches.
  680. // there's no difference with the performSearchWithQuery method above (you could use the same one),
  681. // except that you can optimize for speed by returning a limited set of fields:
  682. // - ID, Title, Name, Year, Volume, Issue, Pages, Authors, Journal, Publication Date (these are the minimum)
  683. //
  684. // In addition there a unique situation here that you can also return two other variable that replace a number of these
  685. // fields which saves you from parsing complicated strings (this will be done anyway once the match is selected by the user:
  686. // - tempAuthorString -> return a string of authors (see pubmed example) as a whole instead of all authors separately
  687. // - tempJournalString -> return a single string representing the publication (e.g. "Nature 2005, vol. 16(2) pp. 400-123")
  688. // if you return the latter you don't have to return the individual journal, volume, year, issue, pages fields, those will be ignored
  689. //
  690. // NOTE that this method runs in a separate thread. Signal your progress to the delegate.
  691. // use the search protocols delegate methods
  692. - (void) performMatchWithQuery: (NSArray *)tokens;
  693.  
  694. // this method is called when the user has selected the right paper, you will be passed the identifier (as you set it
  695. // during the initial search, and you have to return the full metadata for the paper (as rich as possible).
  696. // return the usual dictionary with a papers array containing a SINGLE entry or nil if the identifier cannot be resolved.
  697. // NOTE that this method runs in a separate thread. Signal your progress to the delegate.
  698. // use the above delegate methods
  699. - (void) performMatchForID: (NSString *)identifier;
  700.  
  701. @end
  702.  
  703. // Optional - By implementing this your plugin will be automatically added to the matching list
  704.  
  705. @protocol PapersAutoMatchPluginProtocol
  706.  
  707. // this method is called when the user wishes to auto match a paper. You will be handed all available
  708. // metadata (including the link to the PDF file if present) in the above described dictionary format.
  709. // it's your task to return one or more (preferably fewer than 5) possible hits. Return nothing if you
  710. // can't find anything. 
  711. // NOTE that in the current implementation it's likely we ignore the results if you return more than 1 hit.
  712. // NOTE that this method runs in a separate thread. Signal your progress to the delegate.
  713. // use the above delegate methods
  714. - (void) performAutoMatchForPaper: (NSDictionary *)paper;
  715.  
  716. @end
  717.