gov.nih.nci.caarray.util.owlparser
Class AbstractOntologyOwlParser

java.lang.Object
  extended by gov.nih.nci.caarray.util.owlparser.AbstractOntologyOwlParser
Direct Known Subclasses:
SqlOntologyOwlParser

public abstract class AbstractOntologyOwlParser
extends java.lang.Object

Base class for parsing an ontology description in OWL format. Generates calls to event methods which subclasses should implement to actually do appropriate processing of the parsed data.

Author:
dkokotov

Constructor Summary
AbstractOntologyOwlParser(java.lang.String name, java.lang.String url)
          Create an ontology parser that will parse an ontology OWL file for a term source with given name and url.
 
Method Summary
protected abstract  void finishProcessing()
          Called to indicate the end of processing the OWL doc.
 java.util.Map<java.lang.String,gov.nih.nci.caarray.domain.vocabulary.Category> getCategoryCache()
           
 java.util.Set<gov.nih.nci.caarray.domain.vocabulary.Term> getTermCache()
           
 gov.nih.nci.caarray.domain.vocabulary.TermSource getTermSource()
           
 void parse(org.dom4j.Document owlDoc)
          Parse an OWL document from given Document.
 void parse(java.io.InputStream owlStream)
          Parse an OWL document from given InputStream.
protected abstract  void processCategory(gov.nih.nci.caarray.domain.vocabulary.Category category)
          Process acategory parsed from the OWL.
protected abstract  void processCategorySubclass(gov.nih.nci.caarray.domain.vocabulary.Category category, gov.nih.nci.caarray.domain.vocabulary.Category parentCategory)
          Process a child-parent relationships between the two given categories.
protected abstract  void processTerm(gov.nih.nci.caarray.domain.vocabulary.Term t)
          Process a term parsed from the OWL.
protected abstract  void processTermSource(gov.nih.nci.caarray.domain.vocabulary.TermSource ts)
          Process the term source parsed from the OWL.
protected abstract  void startProcessing()
          Called to indicate the start of processing the OWL doc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractOntologyOwlParser

public AbstractOntologyOwlParser(java.lang.String name,
                                 java.lang.String url)
Create an ontology parser that will parse an ontology OWL file for a term source with given name and url. If name and/or url are null, they will be taken from the OWL file, otheriwse the given values will be used.

Parameters:
name - an explicit name for the term source whose ontology is being parsed
url - an explicit url for the term source whose ontology is being parsed
Method Detail

parse

public void parse(java.io.InputStream owlStream)
           throws ParseException
Parse an OWL document from given InputStream.

Parameters:
owlStream - InputStream containing the bytes of the OWL document
Throws:
ParseException - on error

parse

public void parse(org.dom4j.Document owlDoc)
           throws ParseException
Parse an OWL document from given Document.

Parameters:
owlDoc - The OWL document
Throws:
ParseException - on error

getTermSource

public gov.nih.nci.caarray.domain.vocabulary.TermSource getTermSource()
Returns:
the termSource

getCategoryCache

public java.util.Map<java.lang.String,gov.nih.nci.caarray.domain.vocabulary.Category> getCategoryCache()
Returns:
the categoryCache

getTermCache

public java.util.Set<gov.nih.nci.caarray.domain.vocabulary.Term> getTermCache()
Returns:
the termCache

startProcessing

protected abstract void startProcessing()
                                 throws ParseException
Called to indicate the start of processing the OWL doc.

Throws:
ParseException - on error

finishProcessing

protected abstract void finishProcessing()
                                  throws ParseException
Called to indicate the end of processing the OWL doc. Subclasses should release any resources acquired during processing. This method will be called even if an error had occurred during the parsing process.

Throws:
ParseException - on error

processTermSource

protected abstract void processTermSource(gov.nih.nci.caarray.domain.vocabulary.TermSource ts)
                                   throws ParseException
Process the term source parsed from the OWL. This term source corresponds to the ontology being parsed.

Parameters:
ts - the parsed term source
Throws:
ParseException - on error

processCategory

protected abstract void processCategory(gov.nih.nci.caarray.domain.vocabulary.Category category)
                                 throws ParseException
Process acategory parsed from the OWL. The category child-parent linkages have not. yet been established at this point

Parameters:
category - the parsed category
Throws:
ParseException - on error

processCategorySubclass

protected abstract void processCategorySubclass(gov.nih.nci.caarray.domain.vocabulary.Category category,
                                                gov.nih.nci.caarray.domain.vocabulary.Category parentCategory)
                                         throws ParseException
Process a child-parent relationships between the two given categories.

Parameters:
category - the child category
parentCategory - the parent category
Throws:
ParseException - on error

processTerm

protected abstract void processTerm(gov.nih.nci.caarray.domain.vocabulary.Term t)
                             throws ParseException
Process a term parsed from the OWL. The term includes linkages to all categories it belongs to.

Parameters:
t - the parsed term.
Throws:
ParseException - on error