rdbtoonto.converters
Class RDBToOntoConverter

java.lang.Object
  extended by rdbtoonto.converters.RDBToOntoConverter

public class RDBToOntoConverter
extends java.lang.Object

Base class from which all converters should be derived.
Provides a number of methods to ease the development of new converters.
Among the facilities offered this class, collections are managed to handle tracability between RDB elements and ontology elements.


Field Summary
 java.util.Hashtable<java.lang.String,java.lang.String> _ClassesToDBParts
          _ClassesToDBParts: Inverse of _DBPartsToClasses
static java.lang.String _ClsPropSep
           
 java.util.Hashtable<java.lang.String,java.lang.String> _DataTypePropsDBParts
          _DataTypePropsDBParts: Inverse of __DBPartsToDataTypeProps
 java.util.Hashtable<java.lang.String,com.hp.hpl.jena.ontology.OntClass> _DBPartsToClasses
          _DBPartsToClasses : links DB parts (tables or attributes) to corresponding classes in the ontology.
 java.util.Hashtable<java.lang.String,com.hp.hpl.jena.ontology.DatatypeProperty> _DBPartsToDataTypeProps
          _DBPartsToDataTypeProps : links DB parts (tables or atrtibutes) to corresponding data type properties in the generated ontology.
 java.util.Hashtable<java.lang.String,com.hp.hpl.jena.ontology.ObjectProperty> _DBPartsToObjectProps
          _DBPartsToObjectProps : links DB parts (tables or atrtibutes) to corresponding object properties in the generated ontology.
 java.util.Hashtable<java.lang.String,java.util.Hashtable<com.hp.hpl.jena.ontology.Individual,java.lang.String>> _ForeignKeyValues
          _ForeignKeyValues: This collection can be used during generation to keep track of foreign values when generating instances.
 java.util.Hashtable<java.lang.String,java.lang.Integer> _INameNumPairs
           
static java.util.Hashtable<java.lang.String,LocalConstraintSet> _LocalConstraintSets
           
 java.util.Hashtable<java.lang.String,java.lang.String> _ObjectPropsToDBParts
          __DBPartsToObjectProps: Inverse of _ObjectPropsToDBParts
static java.util.HashSet<java.lang.String> _R2OExcludedTables
           
 int _TotNbDatatypeVals
           
 int _TotNbInstances
           
 int _TotNbRelInstances
           
 java.util.HashSet<java.lang.String> _UsedClassRelNames
           
 java.util.HashSet<java.lang.String> _UsedInstanceNames
           
static java.util.HashSet<java.lang.String> _UserExcludedTables
           
static boolean _WithInverseProps
           
static boolean _WithLocalConstraints
           
static boolean _WithOptimisation
           
 int i_num
           
 
Constructor Summary
RDBToOntoConverter()
          To create a new converter.
 
Method Summary
 void addDBAttributeDatatypePropLink(java.lang.String tableName, java.lang.String attName, com.hp.hpl.jena.ontology.DatatypeProperty prop)
          Keeps a bidirectional link between a DB attribute and derived data type property.
 void addDBPartClassLink(java.lang.String tableName, java.lang.String attName, java.lang.String attVal, com.hp.hpl.jena.ontology.OntClass cls)
          Keeps a bidirectional link between DB elements (tables, attributes, or attribute values) and derived classes.
 void addDBPartObjectPropLink(java.lang.String tableName, java.lang.String attName, com.hp.hpl.jena.ontology.ObjectProperty prop)
          Keeps a bidirectional link between a DB element (table or attribute) and derived objet property.
 void addToSuperClasses(com.hp.hpl.jena.ontology.Individual ind, com.hp.hpl.jena.ontology.OntClass cls)
          Adds an instance in the parent classes.
 void addUsedClassPropName(java.lang.String name)
          Keeps track of the fact that a given string used as a class or property name (This is needed to ensure unicity of names).
 void addUsedInstanceName(java.lang.String name)
          Keeps track of the fact that a given string used as an instance name (This is needed to ensure unicity of names).
 void buildExcludedTables()
          Reads from the current project configuration file the tables to ignore.
 java.lang.String chooseClassName(java.lang.String tableName, java.lang.String prefix)
          Selects a class name from a given table.
 java.lang.String chooseDataRelName(java.lang.String relName, java.lang.String className)
          Selects a name for a data type property.
 java.lang.String chooseObjRelName(java.lang.String relName, java.lang.String className1, java.lang.String className2)
          Selects a name for an object property.
 boolean convert()
          Method that implements the core part of the transitioning process.
 com.hp.hpl.jena.ontology.OntClass createClass(java.lang.String tblName, java.lang.String prefix)
          Creates a class (without properties) from a table definition.
 com.hp.hpl.jena.ontology.OntClass createClass(TableDef tableDef, java.lang.String prefix)
          Creates a class (without properties) from a table definition.
 com.hp.hpl.jena.ontology.OntClass createClassIfNeeded(java.lang.String srcElt, java.lang.String prefix)
          If a class has already been derived from the source element, then the reference to the class is returned, otherwise a new class is created
 com.hp.hpl.jena.ontology.OntClass createClassWithAttributes(TableDef tableDef, java.util.Set<java.lang.String> excludedAtts, java.lang.String prefix)
          Creates a class from a table turning basic attributes into data type properties second parameters specifies a set of attributes to be ignored, along with those already excluded as specified in the constraint set of the table.
 void createIndividualDataProperty(com.hp.hpl.jena.ontology.Individual ind, java.lang.String tableName, java.lang.String att, java.lang.String val)
          Instantiates a data type property from a column value.
 com.hp.hpl.jena.ontology.Individual createIndividualFromRow(TableDef tdef, Row row, com.hp.hpl.jena.ontology.OntClass cls, java.util.Vector namePattern, java.util.HashSet<java.lang.String> foreignCols)
          Creates an instance from a table row.
 com.hp.hpl.jena.ontology.ObjectProperty createObjectProperty(com.hp.hpl.jena.ontology.OntClass cls1, java.lang.String name, com.hp.hpl.jena.ontology.OntClass cls2, boolean withInverse, boolean withInvFunctional)
          Creates an object property from the name of a DB part.
 java.lang.String desambNameWithNumber(java.lang.String name)
          Generic method that desambiguates a resource name by adding a number as suffix.
 com.hp.hpl.jena.ontology.OntClass getClassFromDBPart(java.lang.String tableName, java.lang.String attName, java.lang.String attVal)
          gets the class which has the identified DB element as source.
 com.hp.hpl.jena.ontology.DatatypeProperty getDatatypePropFromDBAtt(java.lang.String tableName, java.lang.String attName)
          gets the data type property which has the identified attribute as source.
 java.lang.String getDBAttFromDatatypeProp(com.hp.hpl.jena.ontology.DatatypeProperty p)
          gets the DB attribute which is the source of the given data type property
 java.lang.String getDBPartFromClass(java.lang.String clsName)
          gets the DB element which is the source of the given class.
 java.lang.String getExternalValueFromPatt(TableDef tdef, Row rowInstance, java.lang.String patt)
           
 com.hp.hpl.jena.ontology.Individual getIndexedInstance(com.hp.hpl.jena.ontology.OntClass cls, java.lang.String idx)
           
 com.hp.hpl.jena.ontology.OntModel getOntology()
           
static java.util.Set<java.lang.String> getTablesWithLCSs()
          Returns the set of tables for which LCSs have been defined.
 java.lang.String giveInstanceName(TableDef tdef, Row rowInstance, com.hp.hpl.jena.ontology.OntClass cls, java.util.Vector namePattern)
          Selects an unambiguous name for a new instance.
 void identifyClassToClassProperties()
          Base method for the identification of object properties.
 void IdentifyFKeyBasedAssociations()
          Derivation of object properties from foreign key relationships.
 void identifyTableBasedAssociations()
          Identification of tables that can be turned into object properties
static boolean initCommonConvProject()
           
static boolean initConvConf()
          Initialization of the global options.
 void initConverter()
          initialization of the converter called at the creation of the converter and at the begining of each run.
static boolean initConvProject()
          gets the common project options and local constraints from the project configuration
When adding a new converter, initConvProject might be overridden if new global
options are added.
static boolean initNewProject()
          When creating a new project, call to this method resets project conversion options that refer to values that are specific to the project.
static void initOptimizer()
          Intialization of the database optimizer.
 boolean isAlreadyUsedClassPropName(java.lang.String name)
          Test if a given string is already used to name a class or a property.
 boolean isAlreadyUsedInstanceName(java.lang.String name)
          Test if a given string is already used to name an instance.
 boolean isAlreadyUsedName(java.lang.String name)
          Test if a given string is already used to name a class,a property or an instance
 boolean isAssociation(TableDef table)
          Test if a table is an association between two other tables.
 boolean isExcludedColumn(java.lang.String tableName, java.lang.String colName)
           
static boolean isExcludedTable(java.lang.String tableName)
           
 void keepTrackOfForeignValue(TableDef tdef, java.lang.String fcol, com.hp.hpl.jena.ontology.Individual ind, java.lang.String fkeyVal)
           
 void keepTrackOfIndividual(TableDef tdef, Row row, com.hp.hpl.jena.ontology.OntClass cls, com.hp.hpl.jena.ontology.Individual ind)
           
 java.lang.String makeBaseClassName(java.lang.String tableName, java.lang.String prefix)
          Returns the typical name that could be derived from the table name Local constraints on class names are taken into account in this selection.
 java.lang.String normaliseName(java.lang.String name)
          Normalization of a name to make it compliant with the target ontology framework.
 void populateClasses()
          Populates the classes of the ontology from the table data.
 void populateClassFromTable(TableDef tdef)
          Populates a class from a given table.
 void populateFKeyBasedOProperty(com.hp.hpl.jena.ontology.ObjectProperty prop, java.lang.String dbsrc)
           
 boolean populateObjectProperties()
          Populates the object properties.
 void populateTableBasedOProperty(com.hp.hpl.jena.ontology.ObjectProperty prop, java.lang.String dbsrc)
           
static void readAllLCSs()
          Reads the local contraints sets (LCS).
 LocalConstraintSet readLCS(java.lang.String iter)
          Reads an LCS from the current project configuration file.
 boolean readNeededData()
          Reads the data needed AT THE START OF the learning process.
 void removeDBAttDatatypePropLink(com.hp.hpl.jena.ontology.OntProperty prop)
          Removes a bidirectional link between a DB attribute and a data type property.
 void removeDBAttDatatypePropLink(TableDef tableDef, Attribute att)
          Removes a bidirectional link between a DB attribute and a data type property.
 void removeDBAttObjectPropLink(com.hp.hpl.jena.ontology.OntProperty prop)
          Removes a bidirectional link between a DB elements (table or attribute) and an object property.
 void removeDBAttObjectPropLink(TableDef tableDef, java.lang.String name)
          Removes a bidirectional link between a DB attribute and data type property.
 void removeHierarchy(com.hp.hpl.jena.ontology.OntClass cls)
          Removes a hierarchy in the ontology from a given class.
 void removeTableClassLink(com.hp.hpl.jena.ontology.OntClass cls)
          Removes a bidirectional link between a DB element (table or attribute) and associated class.
 void removeTableClassLink(java.lang.String tableName, java.lang.String attName, java.lang.String attVal)
          Removes a bidirectional link between DB element (table or attribute) and associated class.
static void saveAllLCSs()
          Saves the LCSs of the current project.
static void saveCommonConvPart()
          Saves the common global options of the current project.
static void saveConvPartOfProject()
          Saves all the conversion settings of the current project.
 void saveLCS(LocalConstraintSet cd)
          Saves the LCS given as argument in the current project configuraiton file.
 boolean saveOntology()
          Saves the ontology in file specifiedun the current projecvt definition.
 void setOntology(com.hp.hpl.jena.ontology.OntModel onto)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_WithOptimisation

public static boolean _WithOptimisation

_WithInverseProps

public static boolean _WithInverseProps

_WithLocalConstraints

public static boolean _WithLocalConstraints

_LocalConstraintSets

public static java.util.Hashtable<java.lang.String,LocalConstraintSet> _LocalConstraintSets

_UserExcludedTables

public static java.util.HashSet<java.lang.String> _UserExcludedTables

_R2OExcludedTables

public static java.util.HashSet<java.lang.String> _R2OExcludedTables

_ClsPropSep

public static java.lang.String _ClsPropSep

i_num

public int i_num

_TotNbInstances

public int _TotNbInstances

_TotNbRelInstances

public int _TotNbRelInstances

_TotNbDatatypeVals

public int _TotNbDatatypeVals

_DBPartsToClasses

public java.util.Hashtable<java.lang.String,com.hp.hpl.jena.ontology.OntClass> _DBPartsToClasses
_DBPartsToClasses : links DB parts (tables or attributes) to corresponding classes in the ontology. A key is either a table name or a table name followed by an attribute name with @ character as separator.


_ClassesToDBParts

public java.util.Hashtable<java.lang.String,java.lang.String> _ClassesToDBParts
_ClassesToDBParts: Inverse of _DBPartsToClasses


_DBPartsToDataTypeProps

public java.util.Hashtable<java.lang.String,com.hp.hpl.jena.ontology.DatatypeProperty> _DBPartsToDataTypeProps
_DBPartsToDataTypeProps : links DB parts (tables or atrtibutes) to corresponding data type properties in the generated ontology. Each key is a table name followed by an attribute name with @ character as separator.


_DataTypePropsDBParts

public java.util.Hashtable<java.lang.String,java.lang.String> _DataTypePropsDBParts
_DataTypePropsDBParts: Inverse of __DBPartsToDataTypeProps


_DBPartsToObjectProps

public java.util.Hashtable<java.lang.String,com.hp.hpl.jena.ontology.ObjectProperty> _DBPartsToObjectProps
_DBPartsToObjectProps : links DB parts (tables or atrtibutes) to corresponding object properties in the generated ontology. A key is either a table name or a table name followed by an attribute name with @ character as separator.


_ObjectPropsToDBParts

public java.util.Hashtable<java.lang.String,java.lang.String> _ObjectPropsToDBParts
__DBPartsToObjectProps: Inverse of _ObjectPropsToDBParts


_ForeignKeyValues

public java.util.Hashtable<java.lang.String,java.util.Hashtable<com.hp.hpl.jena.ontology.Individual,java.lang.String>> _ForeignKeyValues
_ForeignKeyValues: This collection can be used during generation to keep track of foreign values when generating instances. Typically, when class instances are generated first, this collection can help to gather data needed to subsequently generate obeject properties that might be derived from foreign key based attributes. key of the hashtable is a foreign key based attribute. In the second hashtable, key refer to individuals generated from rows, and tha hashtables values are the foreign key values.


_UsedClassRelNames

public java.util.HashSet<java.lang.String> _UsedClassRelNames

_UsedInstanceNames

public java.util.HashSet<java.lang.String> _UsedInstanceNames

_INameNumPairs

public java.util.Hashtable<java.lang.String,java.lang.Integer> _INameNumPairs
Constructor Detail

RDBToOntoConverter

public RDBToOntoConverter()
To create a new converter.

Method Detail

getOntology

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

setOntology

public void setOntology(com.hp.hpl.jena.ontology.OntModel onto)

initConverter

public void initConverter()
initialization of the converter called at the creation of the converter and at the begining of each run. resets all attributes (such as tracability cooletions) used by the converter Can be overrided to handle attributes of a derived converter


initConvConf

public static boolean initConvConf()
Initialization of the global options.
This method be overriden if new global options are added.


initNewProject

public static boolean initNewProject()
When creating a new project, call to this method resets project conversion options that refer to values that are specific to the project.
The following conversion attributes are reinitialized:
When adding a new converter, initNewProject might be overridden.
The derived implementation should include a call to the base initNewProject


initConvProject

public static boolean initConvProject()
gets the common project options and local constraints from the project configuration
When adding a new converter, initConvProject might be overridden if new global
options are added. The derived implementation should include a call to "RDBToOnto.initCommonConvProject"
A call to "readAllLCSs" should also be included.


initCommonConvProject

public static boolean initCommonConvProject()

initOptimizer

public static void initOptimizer()
Intialization of the database optimizer.
The inclusion dependencies of the current project are read from the project configuration file.


readAllLCSs

public static void readAllLCSs()
Reads the local contraints sets (LCS).


readLCS

public LocalConstraintSet readLCS(java.lang.String iter)
Reads an LCS from the current project configuration file.

Parameters:
iter. - index of the current LCS in the configuration file
Returns:
the created LCS object

getTablesWithLCSs

public static java.util.Set<java.lang.String> getTablesWithLCSs()
Returns the set of tables for which LCSs have been defined.


saveConvPartOfProject

public static void saveConvPartOfProject()
Saves all the conversion settings of the current project.


saveCommonConvPart

public static void saveCommonConvPart()
Saves the common global options of the current project.


saveAllLCSs

public static void saveAllLCSs()
Saves the LCSs of the current project.


saveLCS

public void saveLCS(LocalConstraintSet cd)
Saves the LCS given as argument in the current project configuraiton file.

Parameters:
cd. - The LCS to save

readNeededData

public boolean readNeededData()
Reads the data needed AT THE START OF the learning process.
Might be overridden. The base method just return true.
Note that the schema is often read when opening or creating a new project so that it is not necessary to override the method if only the schema is needed at the start.

Returns:
true if the step has been successfully performed.

convert

public boolean convert()
Method that implements the core part of the transitioning process.
Should be overridden by the selected converter.

Returns:
true if the step has been successfully performed.

buildExcludedTables

public void buildExcludedTables()
Reads from the current project configuration file the tables to ignore.
Also includes all tables with names starting with "R2OTMP".


isExcludedTable

public static boolean isExcludedTable(java.lang.String tableName)

isExcludedColumn

public boolean isExcludedColumn(java.lang.String tableName,
                                java.lang.String colName)

createClass

public com.hp.hpl.jena.ontology.OntClass createClass(java.lang.String tblName,
                                                     java.lang.String prefix)
Creates a class (without properties) from a table definition.
An unambiguous name (uri) is assigned to the class (considering also the potential local constraint on the class name).
No tracability links are added.

Parameters:
tblName - is the name of the source table.
prefix. - The name will start with the speficied prefix (separated with an underscore character).To be set to null if not relevant.
Returns:
The created class.

createClass

public com.hp.hpl.jena.ontology.OntClass createClass(TableDef tableDef,
                                                     java.lang.String prefix)
Creates a class (without properties) from a table definition.
An unambiguous name (uri) is assigned to the class (considering also the potential of a local constraint on the class name).
Tracability links are added.

Parameters:
tableDef - is the source table definition.
prefix. - The name will start with the speficied prefix (separated with an underscore character).To be set to null if not relevant.
Returns:
The created class.

createClassWithAttributes

public com.hp.hpl.jena.ontology.OntClass createClassWithAttributes(TableDef tableDef,
                                                                   java.util.Set<java.lang.String> excludedAtts,
                                                                   java.lang.String prefix)
Creates a class from a table turning basic attributes into data type properties second parameters specifies a set of attributes to be ignored, along with those already excluded as specified in the constraint set of the table. excludedAtts parameter can be set to null.
Tracability links are added for the table and the attributes.


createClassIfNeeded

public com.hp.hpl.jena.ontology.OntClass createClassIfNeeded(java.lang.String srcElt,
                                                             java.lang.String prefix)
If a class has already been derived from the source element, then the reference to the class is returned, otherwise a new class is created

Parameters:
srcElt. - identifier for the source element following the traceability link format (eg. "Films@Category@thriller" to designate thriller value in column Category from table Films) No tracability links are added.

addDBPartClassLink

public void addDBPartClassLink(java.lang.String tableName,
                               java.lang.String attName,
                               java.lang.String attVal,
                               com.hp.hpl.jena.ontology.OntClass cls)
Keeps a bidirectional link between DB elements (tables, attributes, or attribute values) and derived classes.

Parameters:
tableName. - Name of the table.
attName. - Equal to null or "", if not relevant (i.e. the DB source is the table).
attVal. - Equal to null or "", if not relevant (i.e. the DB source is the table or the attribute).
cls -

getClassFromDBPart

public com.hp.hpl.jena.ontology.OntClass getClassFromDBPart(java.lang.String tableName,
                                                            java.lang.String attName,
                                                            java.lang.String attVal)
gets the class which has the identified DB element as source.

Parameters:
tableName. - The name the concerned table
attName. - Attribute name. Equal to null or "", if not relevant (i.e. the DB source is the table).
attVal. - Attribute value. Equal to null or "", if not relevant (i.e. the DB source is the table or the attribute).
Returns:
the class "object" or null.

getDBPartFromClass

public java.lang.String getDBPartFromClass(java.lang.String clsName)
gets the DB element which is the source of the given class.

Parameters:
clsName. - The name of the class.
Returns:
The DB element identifier which is either a table. name or concatenation of a table name and an attribute with @ character as separator.

removeTableClassLink

public void removeTableClassLink(java.lang.String tableName,
                                 java.lang.String attName,
                                 java.lang.String attVal)
Removes a bidirectional link between DB element (table or attribute) and associated class.
No effect if no link is found.

Parameters:
dbPartId. - Identifier of the DB element which is either a table name or concatenation of a table name and an attribute with @ character as separator.

removeTableClassLink

public void removeTableClassLink(com.hp.hpl.jena.ontology.OntClass cls)
Removes a bidirectional link between a DB element (table or attribute) and associated class.
No effect if no link is found.

Parameters:
cls. - The class "object".

addDBAttributeDatatypePropLink

public void addDBAttributeDatatypePropLink(java.lang.String tableName,
                                           java.lang.String attName,
                                           com.hp.hpl.jena.ontology.DatatypeProperty prop)
Keeps a bidirectional link between a DB attribute and derived data type property.

Parameters:
tableDef. - The source table.
attName. - The attribute name.
prop. - The data type property.

getDatatypePropFromDBAtt

public com.hp.hpl.jena.ontology.DatatypeProperty getDatatypePropFromDBAtt(java.lang.String tableName,
                                                                          java.lang.String attName)
gets the data type property which has the identified attribute as source.

Parameters:
tableName. - The name of table to which the attribute belongs.
attName. - The attribute name.
Returns:
The data type property or null.

getDBAttFromDatatypeProp

public java.lang.String getDBAttFromDatatypeProp(com.hp.hpl.jena.ontology.DatatypeProperty p)
gets the DB attribute which is the source of the given data type property

Parameters:
p. -
Returns:
the DB attribute identifier (i.e table name + "@" + attribute name) or null.

addDBPartObjectPropLink

public void addDBPartObjectPropLink(java.lang.String tableName,
                                    java.lang.String attName,
                                    com.hp.hpl.jena.ontology.ObjectProperty prop)
Keeps a bidirectional link between a DB element (table or attribute) and derived objet property.

Parameters:
tableName -
attName -
prop -

removeDBAttDatatypePropLink

public void removeDBAttDatatypePropLink(TableDef tableDef,
                                        Attribute att)
Removes a bidirectional link between a DB attribute and a data type property.
No effect if no link is found.

Parameters:
tableDef. - Name the attribute table
att. - Name of the attribute

removeDBAttDatatypePropLink

public void removeDBAttDatatypePropLink(com.hp.hpl.jena.ontology.OntProperty prop)
Removes a bidirectional link between a DB attribute and a data type property.
No effect if no link is found.

Parameters:
prop. - The data type property.

removeDBAttObjectPropLink

public void removeDBAttObjectPropLink(TableDef tableDef,
                                      java.lang.String name)
Removes a bidirectional link between a DB attribute and data type property.
No effect if no link is found.

Parameters:
tableDef. - Name the attribute table
att. - Name of the attribute

removeDBAttObjectPropLink

public void removeDBAttObjectPropLink(com.hp.hpl.jena.ontology.OntProperty prop)
Removes a bidirectional link between a DB elements (table or attribute) and an object property.
No effect if no link is found.

Parameters:
prop. - The object property.

isAlreadyUsedName

public boolean isAlreadyUsedName(java.lang.String name)
Test if a given string is already used to name a class,a property or an instance


isAlreadyUsedClassPropName

public boolean isAlreadyUsedClassPropName(java.lang.String name)
Test if a given string is already used to name a class or a property.


isAlreadyUsedInstanceName

public boolean isAlreadyUsedInstanceName(java.lang.String name)
Test if a given string is already used to name an instance.


addUsedClassPropName

public void addUsedClassPropName(java.lang.String name)
Keeps track of the fact that a given string used as a class or property name (This is needed to ensure unicity of names).


addUsedInstanceName

public void addUsedInstanceName(java.lang.String name)
Keeps track of the fact that a given string used as an instance name (This is needed to ensure unicity of names).


normaliseName

public java.lang.String normaliseName(java.lang.String name)
Normalization of a name to make it compliant with the target ontology framework.
Typically, characters that are not allowed like quotes are replaced by underscore characters.

Parameters:
name. - The input string to be turn into an acceptable name
Returns:
The transformed name

chooseClassName

public java.lang.String chooseClassName(java.lang.String tableName,
                                        java.lang.String prefix)
Selects a class name from a given table. Local constraints on class names are taken into account in this selection. If an active local constraint is defined, then the user defined name given through this constraint is used as a base name. Otherwise, the base name is the table name. Then, a unique name is generated from the base name.

Parameters:
tableName. - Name ot the table
prefix. - The name will start with the speficied prefix (separated with an underscore character).To be set to null if not relevant.
Returns:
Selected class name.

makeBaseClassName

public java.lang.String makeBaseClassName(java.lang.String tableName,
                                          java.lang.String prefix)
Returns the typical name that could be derived from the table name Local constraints on class names are taken into account in this selection. If an active local constraint is defined, then the user defined name given through this constraint is used as a base name. Otherwise, the base name is the table name. Then, a unique name is generated from the base name.

Parameters:
tableName. - Name ot the table
prefix. - The name will start with the speficied prefix (separated with an underscore character).To be set to null if not relevant.
Returns:
typical class name.

chooseDataRelName

public java.lang.String chooseDataRelName(java.lang.String relName,
                                          java.lang.String className)
Selects a name for a data type property.


chooseObjRelName

public java.lang.String chooseObjRelName(java.lang.String relName,
                                         java.lang.String className1,
                                         java.lang.String className2)
Selects a name for an object property.

Parameters:
relName. - The base source name
className1. - The domain class
className2. - The ranege class
Returns:

desambNameWithNumber

public java.lang.String desambNameWithNumber(java.lang.String name)
Generic method that desambiguates a resource name by adding a number as suffix.


identifyClassToClassProperties

public void identifyClassToClassProperties()
Base method for the identification of object properties. Basically, a call to identifyTableBasedAssociations and identifyTableBasedAssociations


identifyTableBasedAssociations

public void identifyTableBasedAssociations()
Identification of tables that can be turned into object properties


isAssociation

public boolean isAssociation(TableDef table)
Test if a table is an association between two other tables.


IdentifyFKeyBasedAssociations

public void IdentifyFKeyBasedAssociations()
Derivation of object properties from foreign key relationships.


createObjectProperty

public com.hp.hpl.jena.ontology.ObjectProperty createObjectProperty(com.hp.hpl.jena.ontology.OntClass cls1,
                                                                    java.lang.String name,
                                                                    com.hp.hpl.jena.ontology.OntClass cls2,
                                                                    boolean withInverse,
                                                                    boolean withInvFunctional)
Creates an object property from the name of a DB part.
No tracability information added

Parameters:
cls1. - The domain class
name. - Name of the source element
cls2. - The range class
withInverse. - Argument set to true if inverse property should be included.
withInvFunctional. - Argument set to true if inverse functional property should be included.
Returns:
the created object property

saveOntology

public boolean saveOntology()
Saves the ontology in file specifiedun the current projecvt definition.

Returns:
true if saving has been successful.

removeHierarchy

public void removeHierarchy(com.hp.hpl.jena.ontology.OntClass cls)
Removes a hierarchy in the ontology from a given class.

Parameters:
cls. - The root of the hierarchy to be removed

populateClasses

public void populateClasses()
Populates the classes of the ontology from the table data.


populateClassFromTable

public void populateClassFromTable(TableDef tdef)
Populates a class from a given table.

Parameters:
tdef. - The source table definition.

createIndividualFromRow

public com.hp.hpl.jena.ontology.Individual createIndividualFromRow(TableDef tdef,
                                                                   Row row,
                                                                   com.hp.hpl.jena.ontology.OntClass cls,
                                                                   java.util.Vector namePattern,
                                                                   java.util.HashSet<java.lang.String> foreignCols)
Creates an instance from a table row.

Parameters:
tdef. - The source table definition
row. - The row
cls. - The class in which the instance will created
namePattern. - Naming pattern that might have been specified through a local constraint (can be set to null)
foreignCols. - Names of the foreign key attributes.
Returns:
The created instance.

addToSuperClasses

public void addToSuperClasses(com.hp.hpl.jena.ontology.Individual ind,
                              com.hp.hpl.jena.ontology.OntClass cls)
Adds an instance in the parent classes.

Parameters:
ind. - The instance
cls. - The base class of the instance

createIndividualDataProperty

public void createIndividualDataProperty(com.hp.hpl.jena.ontology.Individual ind,
                                         java.lang.String tableName,
                                         java.lang.String att,
                                         java.lang.String val)
Instantiates a data type property from a column value.
Tracability link is added.

Parameters:
ind. - The instance on which the property is added.
tableName. - the source table name.
att. - The source attribute name.
val. - The source attribute value.

keepTrackOfForeignValue

public void keepTrackOfForeignValue(TableDef tdef,
                                    java.lang.String fcol,
                                    com.hp.hpl.jena.ontology.Individual ind,
                                    java.lang.String fkeyVal)

keepTrackOfIndividual

public void keepTrackOfIndividual(TableDef tdef,
                                  Row row,
                                  com.hp.hpl.jena.ontology.OntClass cls,
                                  com.hp.hpl.jena.ontology.Individual ind)

getIndexedInstance

public com.hp.hpl.jena.ontology.Individual getIndexedInstance(com.hp.hpl.jena.ontology.OntClass cls,
                                                              java.lang.String idx)

giveInstanceName

public java.lang.String giveInstanceName(TableDef tdef,
                                         Row rowInstance,
                                         com.hp.hpl.jena.ontology.OntClass cls,
                                         java.util.Vector namePattern)
Selects an unambiguous name for a new instance.

Parameters:
rowInstance. - The row from which the instance will be created.
cls. - The class.
namePattern. - Naming pattern that might have been defined through a local constraint.
Returns:
The selected name.

getExternalValueFromPatt

public java.lang.String getExternalValueFromPatt(TableDef tdef,
                                                 Row rowInstance,
                                                 java.lang.String patt)

populateObjectProperties

public boolean populateObjectProperties()
Populates the object properties.


populateFKeyBasedOProperty

public void populateFKeyBasedOProperty(com.hp.hpl.jena.ontology.ObjectProperty prop,
                                       java.lang.String dbsrc)

populateTableBasedOProperty

public void populateTableBasedOProperty(com.hp.hpl.jena.ontology.ObjectProperty prop,
                                        java.lang.String dbsrc)