5050 * @author kelsey
5151 */
5252@ SuppressWarnings ("unused" )
53- public abstract class AbstractOntologyService {
53+ public abstract class AbstractOntologyService implements OntologyService {
5454
5555 protected static Logger log = LoggerFactory .getLogger ( AbstractOntologyService .class );
5656
@@ -67,9 +67,7 @@ public abstract class AbstractOntologyService {
6767
6868 private boolean isInitialized = false ;
6969
70- /**
71- * Initialize this ontology service.
72- */
70+ @ Override
7371 public void initialize ( boolean forceLoad , boolean forceIndexing ) {
7472 if ( !forceLoad && isInitialized ) {
7573 log .warn ( getOntologyName () + " is already loaded, and force=false, not restarting" );
@@ -155,9 +153,7 @@ public void closeIndex() {
155153 index .close ();
156154 }
157155
158- /**
159- * Looks for any OntologyIndividuals that match the given search string.
160- */
156+ @ Override
161157 public Collection <OntologyIndividual > findIndividuals ( String search ) throws OntologySearchException {
162158 Lock lock = rwLock .readLock ();
163159 try {
@@ -176,12 +172,7 @@ public Collection<OntologyIndividual> findIndividuals( String search ) throws On
176172 }
177173 }
178174
179- /**
180- * Looks for any OntologyIndividuals or ontologyTerms that match the given search string
181- *
182- * @return results, or an empty collection if the results are empty OR the ontology is not available to be
183- * searched.
184- */
175+ @ Override
185176 public Collection <OntologyResource > findResources ( String searchString ) throws OntologySearchException {
186177 Lock lock = rwLock .readLock ();
187178 try {
@@ -200,9 +191,7 @@ public Collection<OntologyResource> findResources( String searchString ) throws
200191 }
201192 }
202193
203- /**
204- * Looks for any ontologyTerms that match the given search string. Obsolete terms are filtered out.
205- */
194+ @ Override
206195 public Collection <OntologyTerm > findTerm ( String search ) throws OntologySearchException {
207196 if ( log .isDebugEnabled () ) log .debug ( "Searching " + getOntologyName () + " for '" + search + "'" );
208197 Lock lock = rwLock .readLock ();
@@ -222,6 +211,7 @@ public Collection<OntologyTerm> findTerm( String search ) throws OntologySearchE
222211 }
223212 }
224213
214+ @ Override
225215 public OntologyTerm findUsingAlternativeId ( String alternativeId ) {
226216 Lock lock = alternativeIDs != null ? rwLock .readLock () : rwLock .writeLock ();
227217 try {
@@ -241,6 +231,7 @@ public OntologyTerm findUsingAlternativeId( String alternativeId ) {
241231 }
242232 }
243233
234+ @ Override
244235 public Set <String > getAllURIs () {
245236 Lock lock = rwLock .readLock ();
246237 try {
@@ -264,10 +255,7 @@ public Set<String> getAllURIs() {
264255 }
265256 }
266257
267- /**
268- * Looks through both Terms and Individuals for a OntologyResource that has a uri matching the uri given. If no
269- * OntologyTerm is found only then will ontologyIndividuals be searched. returns null if nothing is found.
270- */
258+ @ Override
271259 public OntologyResource getResource ( String uri ) {
272260 if ( uri == null ) return null ;
273261 Lock lock = rwLock .readLock ();
@@ -297,9 +285,7 @@ public OntologyResource getResource( String uri ) {
297285 }
298286 }
299287
300- /**
301- * Looks for a OntologyTerm that has the match in URI given
302- */
288+ @ Override
303289 public OntologyTerm getTerm ( String uri ) {
304290 if ( uri == null ) throw new IllegalArgumentException ( "URI cannot be null" );
305291 Lock lock = rwLock .readLock ();
@@ -312,6 +298,7 @@ public OntologyTerm getTerm( String uri ) {
312298 }
313299 }
314300
301+ @ Override
315302 public Collection <OntologyIndividual > getTermIndividuals ( String uri ) {
316303 Lock lock = rwLock .readLock ();
317304 try {
@@ -333,6 +320,7 @@ public Collection<OntologyIndividual> getTermIndividuals( String uri ) {
333320 }
334321 }
335322
323+ @ Override
336324 public boolean isEnabled () {
337325 // quick path: just lookup the configuration
338326 String configParameter = "load." + getOntologyName ();
@@ -349,28 +337,15 @@ public boolean isEnabled() {
349337 }
350338 }
351339
352- /**
353- * Used for determining if the Ontology has finished loading into memory. Although calls like getParents,
354- * getChildren will still work (its much faster once the ontologies have been preloaded into memory.)
355- */
340+ @ Override
356341 public boolean isOntologyLoaded () {
357342 // it's fine not to use the read lock here
358343 return isInitialized ;
359344 }
360345
361346 private Thread initializationThread = null ;
362347
363- /**
364- * Start the initialization thread.
365- * <p>
366- * If the initialization thread is already running, this method does nothing. If the initialization thread
367- * previously completed, the ontology will be reinitialized.
368- *
369- * @param forceLoad Force loading of ontology, even if it is already loaded
370- * @param forceIndexing If forceLoad is also true, indexing will be performed. If you know the index is
371- * up to date, there's no need to do it again. Normally indexing is only done if there is no
372- * index, or if the ontology has changed since last loaded.
373- */
348+ @ Override
374349 public synchronized void startInitializationThread ( boolean forceLoad , boolean forceIndexing ) {
375350 if ( initializationThread != null && initializationThread .isAlive () ) {
376351 log .warn ( String .format ( " Initialization thread for %s is currently running, not restarting." , getOntologyName () ) );
@@ -394,27 +369,28 @@ public synchronized void startInitializationThread( boolean forceLoad, boolean f
394369 initializationThread .start ();
395370 }
396371
372+ @ Override
397373 public boolean isInitializationThreadAlive () {
398374 return initializationThread != null && initializationThread .isAlive ();
399375 }
400376
377+ @ Override
401378 public boolean isInitializationThreadCancelled () {
402379 return initializationThread != null && initializationThread .isInterrupted ();
403380 }
404381
405382 /**
406383 * Cancel the initialization thread.
407384 */
385+ @ Override
408386 public void cancelInitializationThread () {
409387 if ( initializationThread == null ) {
410388 throw new IllegalStateException ( "The initialization thread has not started. Invoke startInitializationThread() first." );
411389 }
412390 initializationThread .interrupt ();
413391 }
414392
415- /**
416- * Wait for the initialization thread to finish.
417- */
393+ @ Override
418394 public void waitForInitializationThread () throws InterruptedException {
419395 if ( initializationThread == null ) {
420396 throw new IllegalStateException ( "The initialization thread has not started. Invoke startInitializationThread() first." );
@@ -439,13 +415,7 @@ public void waitForInitializationThread() throws InterruptedException {
439415 */
440416 protected abstract OntModel loadModel ();
441417
442- /**
443- * Index the ontology for performing full-text searches.
444- *
445- * @see #findIndividuals(String)
446- * @see #findTerm(String)
447- * @see #findResources(String)
448- */
418+ @ Override
449419 public void index ( boolean force ) {
450420 Lock lock = rwLock .writeLock ();
451421 try {
@@ -504,13 +474,7 @@ private OntologyTerm getTermInternal( String uri ) {
504474 } );
505475 }
506476
507- /**
508- * For testing! Overrides normal way of loading the ontology. This does not index the ontology unless 'force' is
509- * true (if there is an existing index, it will be used)
510- *
511- * @param is input stream from which the ontology model is loaded
512- * @param forceIndex initialize the index. Otherwise it will only be initialized if it doesn't exist.
513- */
477+ @ Override
514478 public void loadTermsInNameSpace ( InputStream is , boolean forceIndex ) {
515479 Lock lock = rwLock .writeLock ();
516480 try {
0 commit comments