001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.bibliography; 022 023import java.util.Hashtable; 024 025import org.biojava.utils.candy.CandyFinder; 026import org.biojava.utils.candy.CandyVocabulary; 027 028/** 029 * <p> 030 * This interface defines supporting utilities for working with 031 * bibliographic repositories. 032 * </p> 033 * 034 * <p> 035 * The fundamental part of this interface deals with the controlled 036 * vocabularies. However, the <tt>BibRefSupport</tt> interface is here 037 * just a gateway to other Java interfaces defined in a separate 038 * package {@link org.biojava.utils.candy}. 039 * </p> 040 * 041 * <p> 042 * The controlled vocabularies are used in order to find names of 043 * all available attributes of the given bibliographic repository, to 044 * find all possible values of some attributes, and to specify 045 * availability of the ordering and searching criteria. Here belong 046 * methods {@link #getVocabularyFinder getVocabularyFinder}, {@link 047 * #getSupportedValues getSupportedValues}, and {@link 048 * #getSupportedCriteria getSupportedCriteria}. 049 * </p> 050 * 051 * <p> 052 * The other <em>raison d'etre</em> for the BibRefSupport interface is 053 * to have a place where some common constants can be put in. The 054 * constants specify common vocabulary names (examples are {@link 055 * #RESOURCE_TYPES} or {@link #JOURNAL_TITLES}, explicitly defined 056 * bibliographic resource types (for example, {@link #TYPE_BOOK} or 057 * {@link #TYPE_ARTICLE}), and few other things. 058 * </p> 059 * 060 * <p> 061 * And finally, there are some methods allowing to improve an 062 * efficient access to the supporting resources by calling explicitly 063 * {@link #connect connect} and {@link #disconnect disconnect}. 064 * </p> 065 * 066 * <p> 067 * It was an intention to separate completely methods dealing with 068 * bibliographic repositories (as defined in interface {@link 069 * BibRefQuery}) and methods helping with other things (as defined 070 * here). This <em>box of bricks</em> approach helps to use different 071 * communication protocols for bibliographic and supporting 072 * repositories. For example, the performance can be sometimes 073 * improved when the client loads separately all controlled 074 * vocabularies and use them locally while the access to the 075 * bibliographic repository is still remote. 076 * </p> 077 * 078 *<H3>The implementation is advised to used the following constructor</h3> 079 * 080 * <p> 081 *<pre> 082 * public NameOfAnImplementation (String[] args, Hashtable props) {...} 083 *</pre> 084 * where both <tt>args</tt> and <tt>props</tt> contain implementation 085 * specific parameters and properties. However, some properties are 086 * more probable to be used - the suggested names for them are defined 087 * also in this interface (e.g. {@link #INIT_PROP_LOG}). 088 * </p> 089 * 090 * <p> 091 * The use of this constructor makes easier to load dynamically different 092 * supporting implementations. 093 * </p> 094 * 095 * @author <A HREF="mailto:senger@ebi.ac.uk">Martin Senger</A> 096 * @author Matthew Pocock 097 * @version $Id$ 098 * @since 1.3 099 */ 100 101public interface BibRefSupport { 102 103 // 104 // names for global vocabulary names 105 // 106 107 /** 108 * A vocabulary name. The vocabulary contains stringified names of 109 * all citation types stored in the repository. The names of types 110 * that are explicitly defined by this interface should be equal 111 * to the constant strings for types (such as {@link #TYPE_BOOK}). 112 */ 113 static final String RESOURCE_TYPES = "resource_types"; 114 115 /** 116 * A vocabulary name. Some bibliographic repositories consist of 117 * {@link BiblioEntryStatus#repositorySubset several 118 * databases}. Their list can be provided by this vocabulary. 119 */ 120 static final String REPOSITORY_SUBSETS = "repository_subsets"; 121 122 /** 123 * A vocabulary name. The vocabulary contains available 124 * {@link BiblioSubject#subjectHeadings subject headings}. 125 */ 126 static final String SUBJECT_HEADINGS = "subject_headings"; 127 128 /** 129 * A vocabulary name. The vocabulary contains available languages 130 * used in {@link BibRef#language} and {@link BiblioDescription#language}. 131 */ 132 static final String LANGUAGES = "languages"; 133 134 /** 135 * A vocabulary name. The vocabulary contains journal titles as 136 * used in {@link BiblioJournal#name}. 137 */ 138 static final String JOURNAL_TITLES = "journal_titles"; 139 140 /** 141 * A vocabulary name. The vocabulary contains journal 142 * abbreviations as used in {@link BiblioJournal#abbreviation}. 143 */ 144 static final String JOURNAL_ABBREV = "journal_abbreviations"; 145 146 /** 147 * A vocabulary name. The vocabulary contains names of properties 148 * that characterize a citation as a {@link 149 * BiblioEntryStatus#properties repository/database record}. 150 */ 151 static final String ENTRY_PROPERTIES = "entry_properties"; 152 153 // 154 // names for (some) bibliographic resource types 155 // 156 157 /** A name of a bibliographic resource type. */ 158 static final String TYPE_BOOK = "Book"; 159 160 /** A name of a bibliographic resource type. */ 161 static final String TYPE_ARTICLE = "Article"; 162 163 /** A name of a bibliographic resource type. */ 164 static final String TYPE_BOOK_ARTICLE = "BookArticle"; 165 166 /** A name of a bibliographic resource type. */ 167 static final String TYPE_JOURNAL_ARTICLE = "JournalArticle"; 168 169 /** A name of a bibliographic resource type. */ 170 static final String TYPE_PATENT = "Patent"; 171 172 /** A name of a bibliographic resource type. */ 173 static final String TYPE_THESIS = "Thesis"; 174 175 /** A name of a bibliographic resource type. */ 176 static final String TYPE_PROCEEDING = "Proceeding"; 177 178 /** A name of a bibliographic resource type. */ 179 static final String TYPE_TECH_REPORT = "TechReport"; 180 181 /** A name of a bibliographic resource type. */ 182 static final String TYPE_WEB_RESOURCE = "WebResource"; 183 184 // 185 // names for (some) other corners of a bibliographic repository 186 // 187 188 /** A name of a provider type. */ 189 static final String PROVIDER_PERSON = "Person"; 190 191 /** A name of a provider type. */ 192 static final String PROVIDER_ORGANISATION = "Organisation"; 193 194 /** A name of a provider type. */ 195 static final String PROVIDER_SERVICE = "Service"; 196 197 /** A name of a provider type. */ 198 static final String GENERIC_PROVIDER = "Provider"; 199 200 // 201 // names for (some) attribute names 202 // 203 204 /** 205 * <p> 206 * A part of a vocabulary name. It is usually coupled together 207 * with a bibliographic resource type to give a full vocabulary 208 * name. For example: {@link BibRefSupport#TYPE_JOURNAL_ARTICLE 209 * JournalArticle}/ATTR_PROPERTIES. 210 * </p> 211 * 212 * <p> 213 * The vocabulary contains property names for the given resource 214 * type as defined in {@link BibRef#properties}. 215 * </p> 216 */ 217 static final String ATTR_PROPERTIES = "properties"; 218 219 /** 220 * A vocabulary name, or a part of a vocabulary name. 221 * The vocabulary contains all allowed keys in 222 * {@link BiblioScope#properties}. 223 */ 224 static final String ATTR_SCOPE = "scope"; 225 226 /** 227 * A vocabulary name, or a part of a vocabulary name. 228 * The vocabulary contains all allowed keys in 229 * {@link BibRef#format}. 230 */ 231 static final String ATTR_FORMAT = "format"; 232 233 // 234 // names characterizing attributes 235 // 236 237 /** 238 * <p> 239 * A role of an attribute. 240 * </p> 241 * 242 * <p> 243 * The introspection mechanism (provided by using controlled 244 * vocabularies) allows to find what attributes are available in 245 * the repository. The attributes which can be used in query 246 * methods should be identified by putting this constant into 247 * their vocabulary entry (somewhere in the {@link 248 * org.biojava.utils.candy.CandyEntry#description description} field). 249 * </p> 250 */ 251 static final String ROLE_ATTR_QUERYABLE = "queryable"; 252 253 /** 254 * <p> 255 * A role of an attribute. 256 * </p> 257 * 258 * <p> 259 * The introspection mechanism (provided by using controlled 260 * vocabularies) allows to find what attributes are available in 261 * the repository. The attributes which can be used in retrieval 262 * methods should be identified by putting this constant into 263 * their vocabulary entry (somewhere in the {@link 264 * org.biojava.utils.candy.CandyEntry#description description} field). 265 * </p> 266 */ 267 static final String ROLE_ATTR_RETRIEVABLE = "retrievable"; 268 269 /** 270 * <p> 271 * A property name ("<b>log</b>"). 272 * </p> 273 * 274 * <p> 275 * Used for passing an instance dealing with logging. 276 * </p> 277 */ 278 static final String INIT_PROP_LOG = "log"; 279 280 /** 281 * <p> 282 * A property name ("<b>bibrefsupport</b>"). 283 * </p> 284 * 285 * <p> 286 * Used for passing an instance of a class implementing this 287 * interface. It is recommended to pass this property, for 288 * example, in the constructor of an implementation of the {@link 289 * BibRefQuery} interace}. 290 * </p> 291 */ 292 static final String INIT_PROP_SUPPORT = "bibrefsupport"; 293 294 295 /************************************************************************** 296 * <p> 297 * It creates a connection to an object providing the supporting 298 * utilities, or/and it makes all necessary initialization steps 299 * needed for further communication. 300 * </p> 301 * 302 * <p> 303 * However, there should be no need to call this method 304 * explicitly, the other methods should do it automatically before 305 * they need to use any supporting utility. 306 * </p> 307 * 308 * @throws BibRefException if the connection/initialization cannot 309 * be established 310 *************************************************************************/ 311 void connect() 312 throws BibRefException; 313 314 /************************************************************************** 315 * It checks if a utility object is available. The semantic of 316 * <em>available</em>depends on the implementation. 317 * 318 * @return true if it is ready 319 *************************************************************************/ 320 boolean isReady(); 321 322 /************************************************************************** 323 * It closes connection with a utility object. Implementations may 324 * choose to use this method for freeing resources. 325 *************************************************************************/ 326 void disconnect(); 327 328 /************************************************************************** 329 * <p> 330 * It returns an object representing a central place where all 331 * controlled vocabularies can be received from and shared by all 332 * users. 333 * </p> 334 * 335 * <p> 336 * The controlled vocabularies are used for finding names of 337 * all available attributes of the given bibliographic repository, 338 * for finding all possible values of some attributes, and for 339 * specifying availability of the ordering and searching criteria. 340 * </p> 341 * 342 * @return an instance implementing {@link CandyFinder} interface 343 * @throws BibRefException if the vocabulary finder cannot be found 344 *************************************************************************/ 345 CandyFinder getVocabularyFinder() 346 throws BibRefException; 347 348 /************************************************************************** 349 * <p> 350 * It returns a controlled vocabulary containing all possible 351 * values of the attribute given in <tt>attrName</tt> in the 352 * context given in <tt>resourceType</tt>. It is up to the 353 * implementation to define the context. 354 * </p> 355 * 356 * <p> 357 * Specifically, for <tt>attrName</tt> equals to {@link 358 * #ATTR_PROPERTIES} it returns a vocabulary containing attribute 359 * names available for the given citation type. 360 * </p> 361 * 362 * @param resourceType is usually a name of a citation type (e.g. "Book", 363 * "JournalArticle"), see {@link #TYPE_BOOK}, etc., but can define 364 * other contexts as well (e.g. "Person" as defined by constant 365 * {@link #PROVIDER_PERSON}) 366 * @param attrName a name of an attribute whose values should be 367 * available from the returned vocabulary 368 * @return a controlled vocabulary 369 * @throws BibRefException if there is no such vocabulary available, or 370 * something else wrong happened 371 *************************************************************************/ 372 CandyVocabulary getSupportedValues (String resourceType, String attrName) 373 throws BibRefException; 374 375 /************************************************************************** 376 * <p> 377 * It returns all supported searching and sorting criteria for the 378 * whole bibliographic repository. 379 * </p> 380 * 381 * @see #getSupportedCriteria(String) getSupportedCriteria for a repository subset 382 * @return available criteria 383 * @throws BibRefException if something bad happened 384 *************************************************************************/ 385 BiblioCriterion[] getSupportedCriteria() 386 throws BibRefException; 387 388 /************************************************************************** 389 * <p> 390 * It returns all supported searching and sorting criteria in the given 391 * repository subset. 392 * </p> 393 * 394 * @see #getSupportedCriteria getSupportedCriteria regardless of repository subsets 395 * @param repositorySubset a name of a repository subset as used in 396 * {@link BiblioEntryStatus#repositorySubset}, and 397 * as (possibly) defined in the controlled 398 * vocabulary {@link #REPOSITORY_SUBSETS} 399 * @return available criteria 400 * @throws BibRefException if there is no such repository subset, or 401 * something else wrong happened 402 *************************************************************************/ 403 BiblioCriterion[] getSupportedCriteria (String repositorySubset) 404 throws BibRefException; 405 406 /************************************************************************* 407 * <p> 408 * It merges all given collections together. The result should 409 * eliminate redundancy - which usually means removing the same 410 * citations. 411 * </p> 412 * 413 * <p> 414 * The merging process can be influenced by specifying some 415 * <tt>properties</tt> (but they are not defined by this 416 * interface, they depend on the implementation). 417 * </p> 418 * 419 * <p> 420 * <em> 421 * Note that the merging is independent on the repository, or repositories 422 * where the collections come from. The main raison d'etre is actually 423 * to allow to merge collections from different repositories. But it 424 * opens the question what to do with the resulting collection (how to 425 * query it, for example, if it is a "virtual" collection). So it can 426 * be quite difficult to implement this method :-(. 427 * </em> 428 * </p> 429 * 430 * @param collections to be merged together 431 * @param properties define features how to do merging 432 * @return a merged collection 433 * @throws BibRefException if merging failed (which may also happen when 434 * any of the collection is too large) 435 *************************************************************************/ 436 BibRefQuery union (BibRefQuery[] collections, Hashtable properties) 437 throws BibRefException; 438 439}