|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrdbtoonto.converters.RDBToOntoConverter
public class RDBToOntoConverter
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 |
---|
public static boolean _WithOptimisation
public static boolean _WithInverseProps
public static boolean _WithLocalConstraints
public static java.util.Hashtable<java.lang.String,LocalConstraintSet> _LocalConstraintSets
public static java.util.HashSet<java.lang.String> _UserExcludedTables
public static java.util.HashSet<java.lang.String> _R2OExcludedTables
public static java.lang.String _ClsPropSep
public int i_num
public int _TotNbInstances
public int _TotNbRelInstances
public int _TotNbDatatypeVals
public java.util.Hashtable<java.lang.String,com.hp.hpl.jena.ontology.OntClass> _DBPartsToClasses
public java.util.Hashtable<java.lang.String,java.lang.String> _ClassesToDBParts
public java.util.Hashtable<java.lang.String,com.hp.hpl.jena.ontology.DatatypeProperty> _DBPartsToDataTypeProps
public java.util.Hashtable<java.lang.String,java.lang.String> _DataTypePropsDBParts
public java.util.Hashtable<java.lang.String,com.hp.hpl.jena.ontology.ObjectProperty> _DBPartsToObjectProps
public java.util.Hashtable<java.lang.String,java.lang.String> _ObjectPropsToDBParts
public java.util.Hashtable<java.lang.String,java.util.Hashtable<com.hp.hpl.jena.ontology.Individual,java.lang.String>> _ForeignKeyValues
public java.util.HashSet<java.lang.String> _UsedClassRelNames
public java.util.HashSet<java.lang.String> _UsedInstanceNames
public java.util.Hashtable<java.lang.String,java.lang.Integer> _INameNumPairs
Constructor Detail |
---|
public RDBToOntoConverter()
Method Detail |
---|
public com.hp.hpl.jena.ontology.OntModel getOntology()
public void setOntology(com.hp.hpl.jena.ontology.OntModel onto)
public void initConverter()
public static boolean initConvConf()
public static boolean initNewProject()
public static boolean initConvProject()
public static boolean initCommonConvProject()
public static void initOptimizer()
public static void readAllLCSs()
public LocalConstraintSet readLCS(java.lang.String iter)
iter.
- index of the current LCS in the configuration file
public static java.util.Set<java.lang.String> getTablesWithLCSs()
public static void saveConvPartOfProject()
public static void saveCommonConvPart()
public static void saveAllLCSs()
public void saveLCS(LocalConstraintSet cd)
cd.
- The LCS to savepublic boolean readNeededData()
public boolean convert()
public void buildExcludedTables()
public static boolean isExcludedTable(java.lang.String tableName)
public boolean isExcludedColumn(java.lang.String tableName, java.lang.String colName)
public com.hp.hpl.jena.ontology.OntClass createClass(java.lang.String tblName, java.lang.String prefix)
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.
public com.hp.hpl.jena.ontology.OntClass createClass(TableDef tableDef, java.lang.String prefix)
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.
public com.hp.hpl.jena.ontology.OntClass createClassWithAttributes(TableDef tableDef, java.util.Set<java.lang.String> excludedAtts, java.lang.String prefix)
public com.hp.hpl.jena.ontology.OntClass createClassIfNeeded(java.lang.String srcElt, java.lang.String prefix)
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.public void addDBPartClassLink(java.lang.String tableName, java.lang.String attName, java.lang.String attVal, com.hp.hpl.jena.ontology.OntClass cls)
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
- public com.hp.hpl.jena.ontology.OntClass getClassFromDBPart(java.lang.String tableName, java.lang.String attName, java.lang.String attVal)
tableName.
- The name the concerned tableattName.
- 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).
public java.lang.String getDBPartFromClass(java.lang.String clsName)
clsName.
- The name of the class.
public void removeTableClassLink(java.lang.String tableName, java.lang.String attName, java.lang.String attVal)
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.public void removeTableClassLink(com.hp.hpl.jena.ontology.OntClass cls)
cls.
- The class "object".public void addDBAttributeDatatypePropLink(java.lang.String tableName, java.lang.String attName, com.hp.hpl.jena.ontology.DatatypeProperty prop)
tableDef.
- The source table.attName.
- The attribute name.prop.
- The data type property.public com.hp.hpl.jena.ontology.DatatypeProperty getDatatypePropFromDBAtt(java.lang.String tableName, java.lang.String attName)
tableName.
- The name of table to which the attribute belongs.attName.
- The attribute name.
public java.lang.String getDBAttFromDatatypeProp(com.hp.hpl.jena.ontology.DatatypeProperty p)
p.
-
public void addDBPartObjectPropLink(java.lang.String tableName, java.lang.String attName, com.hp.hpl.jena.ontology.ObjectProperty prop)
tableName
- attName
- prop
- public void removeDBAttDatatypePropLink(TableDef tableDef, Attribute att)
tableDef.
- Name the attribute tableatt.
- Name of the attributepublic void removeDBAttDatatypePropLink(com.hp.hpl.jena.ontology.OntProperty prop)
prop.
- The data type property.public void removeDBAttObjectPropLink(TableDef tableDef, java.lang.String name)
tableDef.
- Name the attribute tableatt.
- Name of the attributepublic void removeDBAttObjectPropLink(com.hp.hpl.jena.ontology.OntProperty prop)
prop.
- The object property.public boolean isAlreadyUsedName(java.lang.String name)
public boolean isAlreadyUsedClassPropName(java.lang.String name)
public boolean isAlreadyUsedInstanceName(java.lang.String name)
public void addUsedClassPropName(java.lang.String name)
public void addUsedInstanceName(java.lang.String name)
public java.lang.String normaliseName(java.lang.String name)
name.
- The input string to be turn into an acceptable name
public java.lang.String chooseClassName(java.lang.String tableName, java.lang.String prefix)
tableName.
- Name ot the tableprefix.
- The name will start with the speficied prefix (separated with an underscore character).To be set to null if not relevant.
public java.lang.String makeBaseClassName(java.lang.String tableName, java.lang.String prefix)
tableName.
- Name ot the tableprefix.
- The name will start with the speficied prefix (separated with an underscore character).To be set to null if not relevant.
public java.lang.String chooseDataRelName(java.lang.String relName, java.lang.String className)
public java.lang.String chooseObjRelName(java.lang.String relName, java.lang.String className1, java.lang.String className2)
relName.
- The base source nameclassName1.
- The domain classclassName2.
- The ranege class
public java.lang.String desambNameWithNumber(java.lang.String name)
public void identifyClassToClassProperties()
public void identifyTableBasedAssociations()
public boolean isAssociation(TableDef table)
public void IdentifyFKeyBasedAssociations()
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)
cls1.
- The domain classname.
- Name of the source elementcls2.
- The range classwithInverse.
- Argument set to true if inverse property should be included.withInvFunctional.
- Argument set to true if inverse functional property should be included.
public boolean saveOntology()
public void removeHierarchy(com.hp.hpl.jena.ontology.OntClass cls)
cls.
- The root of the hierarchy to be removedpublic void populateClasses()
public void populateClassFromTable(TableDef tdef)
tdef.
- The source table definition.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)
tdef.
- The source table definitionrow.
- The rowcls.
- The class in which the instance will creatednamePattern.
- Naming pattern that might have been specified through a local constraint (can be set to null)foreignCols.
- Names of the foreign key attributes.
public void addToSuperClasses(com.hp.hpl.jena.ontology.Individual ind, com.hp.hpl.jena.ontology.OntClass cls)
ind.
- The instancecls.
- The base class of the instancepublic void createIndividualDataProperty(com.hp.hpl.jena.ontology.Individual ind, java.lang.String tableName, java.lang.String att, java.lang.String val)
ind.
- The instance on which the property is added.tableName.
- the source table name.att.
- The source attribute name.val.
- The source attribute value.public void keepTrackOfForeignValue(TableDef tdef, java.lang.String fcol, com.hp.hpl.jena.ontology.Individual ind, java.lang.String fkeyVal)
public void keepTrackOfIndividual(TableDef tdef, Row row, com.hp.hpl.jena.ontology.OntClass cls, com.hp.hpl.jena.ontology.Individual ind)
public com.hp.hpl.jena.ontology.Individual getIndexedInstance(com.hp.hpl.jena.ontology.OntClass cls, java.lang.String idx)
public java.lang.String giveInstanceName(TableDef tdef, Row rowInstance, com.hp.hpl.jena.ontology.OntClass cls, java.util.Vector namePattern)
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.
public java.lang.String getExternalValueFromPatt(TableDef tdef, Row rowInstance, java.lang.String patt)
public boolean populateObjectProperties()
public void populateFKeyBasedOProperty(com.hp.hpl.jena.ontology.ObjectProperty prop, java.lang.String dbsrc)
public void populateTableBasedOProperty(com.hp.hpl.jena.ontology.ObjectProperty prop, java.lang.String dbsrc)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |