ibspan.tss.core.storage
Class ModelLoader

java.lang.Object
  extended by ibspan.tss.core.storage.ModelLoader

public class ModelLoader
extends Object

This class provides transparent access to ontology models by knowing only URIs of their base namespaces. By indirect utilizing of LocationMapper it maps these URIs into local files. The developer in obligated to edit these mappings in default file: "etc/location-mapping.n3".

To access persistent models stored in database it uses single connection described in file pointed by the DB_CONNECTION_FILE constant.

Author:
Maciej Gawinecki

Field Summary
static String DB_CONNECTION_FILE
          URL of property file describing access to database for this machine.
static String DB_PASSWORD_KEY
           
static String DB_TYPE_KEY
           
static String DB_URL_KEY
           
static String DB_USER_KEY
           
 
Constructor Summary
ModelLoader()
           
 
Method Summary
static OntModelSpec getDBOntModelSpec(ConnectionDescription desc)
          Creates specification for OntModel, in which (1) base Model is stored in the database described by the given connection description, and (2) imported ontology are stored in memory-based models.
static OntModel loadDBModel(String uri)
          Loads content of the owl file pointed by given uri into persistent model stored in the database.
static OntModel loadModel(String uri)
          Loads content of the owl file pointed by given uri into memory-based model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DB_CONNECTION_FILE

public static final String DB_CONNECTION_FILE
URL of property file describing access to database for this machine.

See Also:
Constant Field Values

DB_URL_KEY

public static final String DB_URL_KEY
See Also:
Constant Field Values

DB_USER_KEY

public static final String DB_USER_KEY
See Also:
Constant Field Values

DB_PASSWORD_KEY

public static final String DB_PASSWORD_KEY
See Also:
Constant Field Values

DB_TYPE_KEY

public static final String DB_TYPE_KEY
See Also:
Constant Field Values
Constructor Detail

ModelLoader

public ModelLoader()
Method Detail

loadDBModel

public static OntModel loadDBModel(String uri)
                            throws ModelLoaderInitException
Loads content of the owl file pointed by given uri into persistent model stored in the database. The uri plays also two-fold role: (a) it stands for name of the model in database and (b) identify model, so it could be cached by OntDocumentManager; then each application using the same instance of OntDocumentManager accesses the same cached model.

Primary, models are stored in local file and ModelLoaders tries to read them into database. This is done only for the first time of access to the particular model and this operation could time-consuming.

Parameters:
uri - the address of OWL file (usually its base namespace)
Returns:
model representing the OWL file
Throws:
ModelLoaderInitException

loadModel

public static OntModel loadModel(String uri)
Loads content of the owl file pointed by given uri into memory-based model. The uri plays also the role of name of the model, so it is read into memory and cached, and then each application using the same instance of OntDocumentManager accesses the same cached model.

Parameters:
uri - the address of OWL file (usually its base namespace)
Returns:
model representing the OWL file

getDBOntModelSpec

public static OntModelSpec getDBOntModelSpec(ConnectionDescription desc)
                                      throws ModelLoaderInitException
Creates specification for OntModel, in which (1) base Model is stored in the database described by the given connection description, and (2) imported ontology are stored in memory-based models.

Parameters:
desc - description of the database connection
Returns:
null if problem with creating model specification occurs
Throws:
ModelLoaderInitException