onto.jena
Class Memory

java.lang.Object
  extended by onto.jena.Memory

public class Memory
extends java.lang.Object

Jena Memory access Main functionality to access and manipulate Jena ontology models in MySQL database

Version:
0.7
Author:
Michal Laclavik, Emil Gatial (inference, connection testing)

Field Summary
 java.lang.String BASE
          BASE returns ontology uri
 Config config
           
private  com.hp.hpl.jena.db.IDBConnection conn
          Instanceof database connection object
private static java.lang.String DEFAULT_MODEL_NAME
          Default ontology model name
private  boolean loaded
          State variable identifies whether model is loaded
private  org.apache.log4j.Logger log
          Log4j object
private  com.hp.hpl.jena.ontology.OntModel model
          Instance of ontological model used in memory
 java.lang.String OWL_FOOT
          OWL_FOOT is used to add RDF footer to Event messages comming through XML-RPC
 java.lang.String OWL_HEAD
          OWL_HEAD is used to add RDF, OWL and ontology headers to Event messages comming through XML-RPC
 java.lang.String RDQL_USING
          RDQL_USING is used in RDQL queries where we can write <ont:something> or <rdf:something> instead of full ontology uri or RDF uri
 java.lang.String SPARQL_PREFIX
          SPARQL_PREFIX is used in SPARQL queries where we can write <ont:something> or <rdf:something> instead of full agent ontology uri or RDF uri
 
Constructor Summary
Memory(java.lang.String _propertyFile, java.lang.String _name)
          Constructor
 
Method Summary
 void closeModel()
          Close OWL Model and store Model in RDB if using database backend This have to be redesigned and store everything on the crash
 void createModel()
          Creates OWL model out of defined SOURCE_FILE in OWL database and store this model see: SOURCE_FILE, INDIVIDUALS_FILE
 com.hp.hpl.jena.rdf.model.Property createProperty(java.lang.String property)
          Creates ontology property out ofstring represenation
 java.lang.String getBase()
          Reurns the onoloy name space
 com.hp.hpl.jena.db.IDBConnection getConnection()
          This method returns db connection
 com.hp.hpl.jena.ontology.Individual getIndividual(java.lang.String uri)
          Returns individual
 com.hp.hpl.jena.ontology.OntModel getModel()
           
 java.lang.String getNS(java.lang.String key)
          Returns Namespace for given key defined in config file, in property file it search for NS_[KEY]
 com.hp.hpl.jena.ontology.OntClass getOntologyClass(java.lang.String name)
           
 com.hp.hpl.jena.ontology.Individual getOntologyIndividual(java.lang.String name)
          Returns Individual
 java.lang.String getXML(com.hp.hpl.jena.rdf.model.Resource r, java.lang.String space, java.lang.String strRes)
          Recursive method which writes resource with all properties recursively into string and returns it
private  void init(java.lang.String _propertyFile, java.lang.String _name)
           
private  void loadFiles2Model(com.hp.hpl.jena.ontology.OntModel model)
          Returns OWL ontological model for manipulation
 void memory2owl()
          Saves current content of Memory into file defined in Ontology Property file see: OUTPUT_FILE
 void performInference(java.lang.String ruleFile, boolean derivationLogging)
          Infers some new statements about the ontological model accoding to given rules of inference
and adds inferenced model as submodel of memory
 void removeModel()
          Remove model from DB
 void reset()
          Sometimes if operation is idle MySQL connection fails and we need to reset connection and model
 void test()
          Prints objects from OWL model for testing purposes
 void testConnection()
          Tests the status of connection.
 java.lang.String translateNS(java.lang.String shortNS)
          Translate short NS e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

public Config config

RDQL_USING

public java.lang.String RDQL_USING
RDQL_USING is used in RDQL queries where we can write <ont:something> or <rdf:something> instead of full ontology uri or RDF uri


SPARQL_PREFIX

public java.lang.String SPARQL_PREFIX
SPARQL_PREFIX is used in SPARQL queries where we can write <ont:something> or <rdf:something> instead of full agent ontology uri or RDF uri


BASE

public java.lang.String BASE
BASE returns ontology uri


OWL_HEAD

public java.lang.String OWL_HEAD
OWL_HEAD is used to add RDF, OWL and ontology headers to Event messages comming through XML-RPC


OWL_FOOT

public java.lang.String OWL_FOOT
OWL_FOOT is used to add RDF footer to Event messages comming through XML-RPC


DEFAULT_MODEL_NAME

private static final java.lang.String DEFAULT_MODEL_NAME
Default ontology model name

See Also:
Constant Field Values

log

private org.apache.log4j.Logger log
Log4j object


conn

private com.hp.hpl.jena.db.IDBConnection conn
Instanceof database connection object


model

private com.hp.hpl.jena.ontology.OntModel model
Instance of ontological model used in memory


loaded

private boolean loaded
State variable identifies whether model is loaded

Constructor Detail

Memory

public Memory(java.lang.String _propertyFile,
              java.lang.String _name)
Constructor

Parameters:
_propertyFile - - property file name where settings for jena memory are stored. Settings are defined according to Config
_name - name of the component
Method Detail

init

private void init(java.lang.String _propertyFile,
                  java.lang.String _name)

getBase

public java.lang.String getBase()
Reurns the onoloy name space

Returns:
name space of memory

getConnection

public com.hp.hpl.jena.db.IDBConnection getConnection()
This method returns db connection

Returns:
instance of db connection object

createModel

public void createModel()
Creates OWL model out of defined SOURCE_FILE in OWL database and store this model see: SOURCE_FILE, INDIVIDUALS_FILE


removeModel

public void removeModel()
Remove model from DB


loadFiles2Model

private void loadFiles2Model(com.hp.hpl.jena.ontology.OntModel model)
Returns OWL ontological model for manipulation


getModel

public com.hp.hpl.jena.ontology.OntModel getModel()

performInference

public void performInference(java.lang.String ruleFile,
                             boolean derivationLogging)
Infers some new statements about the ontological model accoding to given rules of inference
and adds inferenced model as submodel of memory

Parameters:
ruleFile - path to file with line delimited list of rules
derivationLogging - true/false value indicates whether to perform logging of inferenced statements
false value accelerate inferece processing
See Also:
setDerivationLogging

reset

public void reset()
Sometimes if operation is idle MySQL connection fails and we need to reset connection and model


test

public void test()
Prints objects from OWL model for testing purposes


memory2owl

public void memory2owl()
Saves current content of Memory into file defined in Ontology Property file see: OUTPUT_FILE


closeModel

public void closeModel()
Close OWL Model and store Model in RDB if using database backend This have to be redesigned and store everything on the crash


createProperty

public com.hp.hpl.jena.rdf.model.Property createProperty(java.lang.String property)
Creates ontology property out ofstring represenation

Parameters:
property - represents local name of ontology property

getIndividual

public com.hp.hpl.jena.ontology.Individual getIndividual(java.lang.String uri)
Returns individual

Parameters:
uri - URI of individual
Returns:
Individual

getOntologyIndividual

public com.hp.hpl.jena.ontology.Individual getOntologyIndividual(java.lang.String name)
Returns Individual

Parameters:
name - of the individual without namespace prefix
Returns:
Individual

getOntologyClass

public com.hp.hpl.jena.ontology.OntClass getOntologyClass(java.lang.String name)

testConnection

public void testConnection()
Tests the status of connection. If it doesn't exist then make new connection to database and initialize model


getXML

public java.lang.String getXML(com.hp.hpl.jena.rdf.model.Resource r,
                               java.lang.String space,
                               java.lang.String strRes)
Recursive method which writes resource with all properties recursively into string and returns it

Parameters:
space - is just to track levels of XML
r - resource which should be converted to XML text

getNS

public java.lang.String getNS(java.lang.String key)
Returns Namespace for given key defined in config file, in property file it search for NS_[KEY]

Parameters:
key - namespace reference key

translateNS

public java.lang.String translateNS(java.lang.String shortNS)
Translate short NS e.g. region:Region to long NS found in appropriate config file

Parameters:
shortNS -
Returns:
returns full name space