You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by en...@apache.org on 2011/04/01 15:01:46 UTC
svn commit: r1087691 [3/13] - in /incubator/stanbol/trunk/reengineer: ./
base/ base/.settings/ base/src/ base/src/main/ base/src/main/java/
base/src/main/java/org/ base/src/main/java/org/apache/
base/src/main/java/org/apache/stanbol/ base/src/main/java...
Added: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DBSchemaGenerator.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DBSchemaGenerator.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DBSchemaGenerator.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DBSchemaGenerator.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,530 @@
+package org.apache.stanbol.reengineer.db;
+
+import java.io.Serializable;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.stanbol.reengineer.base.api.settings.ConnectionSettings;
+import org.apache.stanbol.reengineer.base.api.util.ReengineerUriRefGenerator;
+import org.apache.stanbol.reengineer.db.vocab.DBS_L1_OWL;
+import org.semanticweb.owlapi.model.AddAxiom;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
+
+/**
+ * The {@code DBSchemaGenerator} is responsible of the generation of the RDF of the schema of a relational database.
+ *
+ * @author andrea.nuzzolese
+ *
+ */
+
+public class DBSchemaGenerator extends ReengineerUriRefGenerator implements Serializable {
+
+ private String graphNS;
+ private IRI outputIRI;
+ private ConnectionSettings connectionSettings;
+
+
+ /**
+ * Creates a new standard {@code DBSchemaGenerator}
+ */
+ public DBSchemaGenerator() {
+
+ }
+
+ /**
+ * Creates a new {@code DBSchemaGenerator} that can generate the RDF of the database's schema. The database is available
+ * thanks to the {@code connectionSettings} passed as input. The URI of the RDF will be that one passed as actual parameter to the
+ * formal parameter {@code databaseURI}.
+ *
+ * @param databaseURI {@link String}
+ * @param connectionSettings {@link ConnectionSettings}
+ */
+ public DBSchemaGenerator(IRI outputIRI, ConnectionSettings connectionSettings){
+
+ this.connectionSettings = connectionSettings;
+ this.outputIRI = outputIRI;
+
+ }
+
+
+ /**
+ * Performs the generation of the RDF of the database schema. The RDF graph is added to the {@link MGraph} passed as input.
+ *
+ *
+ * @param mGraph {@link MGraph}
+ * @return the {@link MGraph} containing the database schema into RDF.
+ */
+ public OWLOntology getSchema(OWLOntologyManager manager, OWLDataFactory factory){
+
+ Connection con = openConnection(connectionSettings);
+
+ /*
+ Model schemaModel = ModelFactory.createDefaultModel();
+ schemaModel.setNsPrefixes(DBS_L1.getModel().getNsPrefixMap());
+ schemaModel.setNsPrefix("dbSchema", namespace);
+ schemaModel.setNsPrefix("xsd", "http://www.w3.org/2001/XMLSchema#");
+ schemaModel.setNsPrefix("dbs", DBS_L1.NS);
+ */
+
+
+ OWLOntology schemaOntology = null;
+ if(outputIRI != null){
+ try {
+ schemaOntology = manager.createOntology(outputIRI);
+ } catch (OWLOntologyCreationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ else{
+ try {
+ schemaOntology = manager.createOntology();
+ } catch (OWLOntologyCreationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ if(!graphNS.endsWith("#")){
+ graphNS += "#";
+ }
+
+ IRI databaseConnectionInfoIRI = IRI.create(graphNS + "DBConnectionSettings");
+ OWLClassAssertionAxiom databaseConnectionInfo = createOWLClassAssertionAxiom(factory, DBS_L1_OWL.DatabaseConnection, databaseConnectionInfoIRI);
+ manager.applyChange(new AddAxiom(schemaOntology, databaseConnectionInfo));
+
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.hasName, databaseConnectionInfoIRI, "database_"+outputIRI)));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.hasPhysicalName, databaseConnectionInfoIRI, connectionSettings.getDatabaseName())));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.hasJDBCDriver, databaseConnectionInfoIRI, connectionSettings.getJDBCDriver())));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.hasJDBCDns, databaseConnectionInfoIRI, getConnectionUrl(connectionSettings.getUrl(), connectionSettings.getServerName(), connectionSettings.getPortNumber(), connectionSettings.getDatabaseName()))));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.hasUsername, databaseConnectionInfoIRI, connectionSettings.getUserName())));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.hasPassword, databaseConnectionInfoIRI, connectionSettings.getPassword())));
+
+
+ DatabaseMetaData md;
+ try {
+ md = con.getMetaData();
+
+ ResultSet rs = md.getTables(null, null, "%", null);
+
+ String rdfs = "http://www.w3.org/2000/01/rdf-schema#";
+
+ for(int k=0; rs.next(); k++) {
+ String table = rs.getString(3);
+ System.out.println("TABLE : "+table);
+
+ IRI tableResourceIRI = IRI.create(graphNS + "table_"+table);
+ OWLClassAssertionAxiom tableResource = createOWLClassAssertionAxiom(factory, DBS_L1_OWL.Table, tableResourceIRI);
+ manager.applyChange(new AddAxiom(schemaOntology, tableResource));
+
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.hasName, databaseConnectionInfoIRI, "table_"+table)));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.isTableOf, tableResourceIRI, databaseConnectionInfoIRI)));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.isDumped, databaseConnectionInfoIRI, false)));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.RDFS_LABEL, databaseConnectionInfoIRI, table)));
+
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.hasTable, databaseConnectionInfoIRI, tableResourceIRI)));
+
+ String catalog = con.getCatalog();
+
+ ResultSet fk = md.getImportedKeys(catalog, null, table);
+
+ ResultSet pk = md.getPrimaryKeys(catalog, null, table);
+
+ ResultSet columnsRs = md.getColumns(catalog, null, table, null);
+
+
+
+ while(columnsRs.next()){
+ String columnName = columnsRs.getString("COLUMN_NAME");
+ String columnType = columnsRs.getString("TYPE_NAME");
+ String columnNullable = columnsRs.getString("NULLABLE");
+ System.out.println("COLUMN NAME : "+columnName);
+ System.out.println("COLUMN TYPE : "+columnType);
+ System.out.println("COLUMN NULLABLE : "+columnNullable);
+
+ boolean nullable = true;
+ try{
+ int nullableInt = Integer.valueOf(columnNullable).intValue();
+
+ nullable = nullableInt == 0 ? false : true;
+
+
+ } catch (NumberFormatException e) {
+ nullable = true;
+ }
+
+
+ IRI colummIRI = IRI.create(graphNS + table+"-column_"+columnName);
+ OWLClassAssertionAxiom columm;
+
+ if(nullable){
+ columm = createOWLClassAssertionAxiom(factory, DBS_L1_OWL.NullableColumn, colummIRI);
+ }
+ else{
+ columm = createOWLClassAssertionAxiom(factory, DBS_L1_OWL.NotNullableColumn, colummIRI);
+ }
+ manager.applyChange(new AddAxiom(schemaOntology, columm));
+
+ if(columnType != null){
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.hasSQLType, colummIRI, columnType)));
+ }
+ if(columnName != null){
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.hasName, colummIRI, table+"-column_"+columnName)));
+ }
+
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.isColumnOf, colummIRI, tableResourceIRI)));
+
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory, DBS_L1_OWL.RDFS_LABEL, colummIRI, columnName)));
+
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.isColumnOf, tableResourceIRI, colummIRI)));
+
+
+ }
+
+
+ Hashtable<String, TablePKRelations> relationTable = new Hashtable<String, TablePKRelations>();
+
+ while (fk.next()) {
+ String fkTableName = fk.getString("FKTABLE_NAME");
+ String fkColumnName = fk.getString("FKCOLUMN_NAME");
+ String pkTableName = fk.getString("PKTABLE_NAME");
+ String pkColumnName = fk.getString("PKCOLUMN_NAME");
+
+ IRI foreignKeyResourceIRI = IRI.create(graphNS + table+"_fk_"+fkColumnName);
+ OWLClassAssertionAxiom foreignKeyResource = createOWLClassAssertionAxiom(factory, DBS_L1_OWL.ForeignKey, foreignKeyResourceIRI);
+ manager.applyChange(new AddAxiom(schemaOntology, foreignKeyResource));
+
+ System.out.println("JOIN ON COLUMN "+pkColumnName);
+
+ IRI columnIRI = IRI.create(graphNS + table+"-column_"+fkColumnName);
+
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.hasForeignKeyMember, foreignKeyResourceIRI, columnIRI)));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.isForeignKeyMemberOf, columnIRI, foreignKeyResourceIRI)));
+
+ IRI joinColumnIRI = IRI.create(graphNS + pkTableName+"-column_"+pkColumnName);
+ OWLClassAssertionAxiom joinColumn = createOWLClassAssertionAxiom(factory, DBS_L1_OWL.NotNullableColumn, joinColumnIRI);
+ manager.applyChange(new AddAxiom(schemaOntology, joinColumn));
+
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.joinsOn, columnIRI, joinColumnIRI)));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.hasForeignKey, tableResourceIRI, foreignKeyResourceIRI)));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.isForeignKeyOf, foreignKeyResourceIRI, tableResourceIRI)));
+
+
+ int fkSequence = fk.getInt("KEY_SEQ");
+ if(fkTableName != null){
+ System.out.println("getExportedKeys(): fkTableName="+fkTableName);
+ }
+ if(fkColumnName != null){
+ System.out.println("getExportedKeys(): fkColumnName="+fkColumnName);
+ }
+ if(pkTableName != null){
+ System.out.println("getExportedKeys(): pkTableName="+pkTableName);
+ }
+ if(pkColumnName != null){
+ System.out.println("getExportedKeys(): pkColumnName="+pkColumnName);
+ }
+ System.out.println("getExportedKeys(): fkSequence="+fkSequence);
+
+
+ TablePKRelations tableRelations = relationTable.remove(fkTableName);
+ System.out.println();
+ System.out.println(pkTableName);
+ if(tableRelations == null){
+ tableRelations = new TablePKRelations(fkTableName, new ArrayList<String>(), new ArrayList<String>(), pkTableName);
+ System.out.println("NULL");
+ }
+ else{
+ System.out.println("tableRelations NOT NULL "+tableRelations.getPkTable());
+ }
+ System.out.println();
+ System.out.println();
+
+ ArrayList<String> fkArrayList = tableRelations.getFkColumns();
+ ArrayList<String> pkArrayList = tableRelations.getPkColumns();
+ fkArrayList.add(fkColumnName);
+ pkArrayList.add(pkColumnName);
+
+ tableRelations.setFkColumns(fkArrayList);
+ tableRelations.setPkColumns(pkArrayList);
+
+ relationTable.put(fkTableName, tableRelations);
+
+ }
+
+
+ fk.close();
+
+ for(int i=0; pk.next(); i++){
+ String colPk = pk.getString(4);
+
+ IRI primaryKeyIRI = IRI.create(graphNS + table+"_pk_"+colPk);
+ OWLClassAssertionAxiom primaryKey = createOWLClassAssertionAxiom(factory, DBS_L1_OWL.PrimaryKey, primaryKeyIRI);
+ manager.applyChange(new AddAxiom(schemaOntology, primaryKey));
+
+ IRI columnIRI = IRI.create(graphNS + table+"-column_"+colPk);
+
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.hasPrimaryKeyMember, primaryKeyIRI, columnIRI)));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.isPrimaryKeyMemberOf, columnIRI, primaryKeyIRI)));
+
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.hasPrimaryKey, tableResourceIRI, primaryKeyIRI)));
+ manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory, DBS_L1_OWL.isPrimaryKeyOf, primaryKeyIRI, tableResourceIRI)));
+
+ }
+
+
+
+ pk.close();
+
+
+ }
+
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+
+ return schemaOntology;
+ }
+
+
+ /*
+ public Model getSchemaL1(){
+
+ Connection con = openConnection(connectionSettings);
+
+ Model schemaModel = ModelFactory.createDefaultModel();
+
+ schemaModel.setNsPrefixes(DBS_L1.getModel().getNsPrefixMap());
+ schemaModel.setNsPrefix("dbSchema", namespace);
+ schemaModel.setNsPrefix("xsd", "http://www.w3.org/2001/XMLSchema#");
+ schemaModel.setNsPrefix("dbs", DBS_L1.NS);
+
+ Resource database = schemaModel.createResource(namespace+databaseURI, DBS_L1.DatabaseConnection);
+ database.addLiteral(DBS_L1.hasName, "database_"+databaseURI);
+ database.addProperty(DBS_L1.hasPhysicalName, connectionSettings.getDatabaseName());
+ database.addProperty(DBS_L1.hasJDBCDriver, connectionSettings.getJDBCDriver());
+ database.addProperty(DBS_L1.hasJDBCDns, getConnectionUrl(connectionSettings.getUrl(), connectionSettings.getServerName(), connectionSettings.getPortNumber(), connectionSettings.getDatabaseName()));
+ database.addProperty(DBS_L1.hasUsername, connectionSettings.getUserName());
+ database.addProperty(DBS_L1.hasPassword, connectionSettings.getPassword());
+
+
+
+
+ DatabaseMetaData md;
+ try {
+ md = con.getMetaData();
+
+ ResultSet rs = md.getTables(null, null, "%", null);
+
+ String rdfs = "http://www.w3.org/2000/01/rdf-schema#";
+
+ for(int k=0; rs.next(); k++) {
+ String table = rs.getString(3);
+ System.out.println("TABLE : "+table);
+
+ Resource tableResource = schemaModel.createResource(namespace+"table_"+table, DBS_L1.Table);
+ tableResource.addLiteral(DBS_L1.hasName, "table_"+table);
+ tableResource.addProperty(DBS_L1.isTableOf, database);
+ tableResource.addLiteral(DBS_L1.isDumped, false);
+ tableResource.addLiteral(RDFS.label, table);
+ database.addProperty(DBS_L1.hasTable, tableResource);
+
+ String catalog = con.getCatalog();
+
+ ResultSet fk = md.getImportedKeys(catalog, null, table);
+
+ ResultSet pk = md.getPrimaryKeys(catalog, null, table);
+
+ ResultSet columnsRs = md.getColumns(catalog, null, table, null);
+
+
+
+ while(columnsRs.next()){
+ String columnName = columnsRs.getString("COLUMN_NAME");
+ String columnType = columnsRs.getString("TYPE_NAME");
+ String columnNullable = columnsRs.getString("NULLABLE");
+ System.out.println("COLUMN NAME : "+columnName);
+ System.out.println("COLUMN TYPE : "+columnType);
+ System.out.println("COLUMN NULLABLE : "+columnNullable);
+
+ boolean nullable = true;
+ try{
+ int nullableInt = Integer.valueOf(columnNullable).intValue();
+
+ nullable = nullableInt == 0 ? false : true;
+
+
+ } catch (NumberFormatException e) {
+ nullable = true;
+ }
+
+ Resource columm;
+ if(nullable){
+ columm = schemaModel.createResource(namespace+table+"-column_"+columnName, DBS_L1.NullableColumn);
+ }
+ else{
+ columm = schemaModel.createResource(namespace+table+"-column_"+columnName, DBS_L1.NotNullableColumn);
+ }
+
+ if(columnType != null){
+ columm.addLiteral(DBS_L1.hasSQLType, columnType);
+ }
+ if(columnName != null){
+ columm.addLiteral(DBS_L1.hasName, table+"-column_"+columnName);
+ }
+ columm.addProperty(DBS_L1.isColumnOf, tableResource);
+
+ columm.addLiteral(RDFS.label, columnName);
+
+ //asserisco l'inversa di isFieldOf
+ tableResource.addProperty(DBS_L1.hasColumn, columm);
+
+ }
+
+
+ Hashtable<String, TablePKRelations> relationTable = new Hashtable<String, TablePKRelations>();
+
+ while (fk.next()) {
+ String fkTableName = fk.getString("FKTABLE_NAME");
+ String fkColumnName = fk.getString("FKCOLUMN_NAME");
+ String pkTableName = fk.getString("PKTABLE_NAME");
+ String pkColumnName = fk.getString("PKCOLUMN_NAME");
+
+ Resource foreignKeyResource = schemaModel.createResource(namespace+table+"_fk_"+fkColumnName, DBS_L1.ForeignKey);
+
+
+ System.out.println("JOIN ON COLUMN "+pkColumnName);
+ Resource column = schemaModel.createResource(namespace+table+"-column_"+fkColumnName);
+ foreignKeyResource.addProperty(DBS_L1.hasForeignKeyMember, column);
+ column.addProperty(DBS_L1.isForeignKeyMemberOf, foreignKeyResource);
+
+ column.addProperty(DBS_L1.joinsOn, schemaModel.createResource(namespace+pkTableName+"-column_"+pkColumnName, DBS_L1.NotNullableColumn));
+
+ tableResource.addProperty(DBS_L1.hasForeignKey, foreignKeyResource);
+ foreignKeyResource.addProperty(DBS_L1.isForeignKeyOf, tableResource);
+
+ int fkSequence = fk.getInt("KEY_SEQ");
+ if(fkTableName != null){
+ System.out.println("getExportedKeys(): fkTableName="+fkTableName);
+ }
+ if(fkColumnName != null){
+ System.out.println("getExportedKeys(): fkColumnName="+fkColumnName);
+ }
+ if(pkTableName != null){
+ System.out.println("getExportedKeys(): pkTableName="+pkTableName);
+ }
+ if(pkColumnName != null){
+ System.out.println("getExportedKeys(): pkColumnName="+pkColumnName);
+ }
+ System.out.println("getExportedKeys(): fkSequence="+fkSequence);
+
+
+ TablePKRelations tableRelations = relationTable.remove(fkTableName);
+ System.out.println();
+ System.out.println(pkTableName);
+ if(tableRelations == null){
+ tableRelations = new TablePKRelations(fkTableName, new ArrayList<String>(), new ArrayList<String>(), pkTableName);
+ System.out.println("NULL");
+ }
+ else{
+ System.out.println("tableRelations NOT NULL "+tableRelations.getPkTable());
+ }
+ System.out.println();
+ System.out.println();
+
+ ArrayList<String> fkArrayList = tableRelations.getFkColumns();
+ ArrayList<String> pkArrayList = tableRelations.getPkColumns();
+ fkArrayList.add(fkColumnName);
+ pkArrayList.add(pkColumnName);
+
+ tableRelations.setFkColumns(fkArrayList);
+ tableRelations.setPkColumns(pkArrayList);
+
+ relationTable.put(fkTableName, tableRelations);
+
+ }
+
+
+ fk.close();
+
+ for(int i=0; pk.next(); i++){
+ String colPk = pk.getString(4);
+
+ Resource primaryKey = schemaModel.createResource(namespace+table+"_pk_"+colPk, DBS_L1.PrimaryKey);
+
+ Resource column = schemaModel.createResource(namespace+table+"-column_"+colPk);
+
+ primaryKey.addProperty(DBS_L1.hasPrimaryKeyMember, column);
+ column.addProperty(DBS_L1.isPrimaryKeyMemberOf, primaryKey);
+
+ tableResource.addProperty(DBS_L1.hasPrimaryKey, primaryKey);
+ primaryKey.addProperty(DBS_L1.isPrimaryKeyOf, tableResource);
+ }
+
+
+
+ pk.close();
+
+
+ }
+
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+
+ return schemaModel;
+ }
+
+ */
+
+ private String getConnectionUrl(String url, String serverName, String portNumber, String databaseName){
+ return url+serverName+":"+portNumber+"/"+databaseName;
+ }
+
+
+ private Connection openConnection(ConnectionSettings connectionSettings){
+ Connection con = null;
+ try {
+ Class.forName(connectionSettings.getJDBCDriver());
+ System.out.println(getConnectionUrl(connectionSettings.getUrl(), connectionSettings.getServerName(), connectionSettings.getPortNumber(), connectionSettings.getDatabaseName()));
+ con = DriverManager.getConnection(getConnectionUrl(connectionSettings.getUrl(), connectionSettings.getServerName(), connectionSettings.getPortNumber(), connectionSettings.getDatabaseName()), connectionSettings.getUserName(), connectionSettings.getPassword());
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return con;
+ }
+
+ private void closeConnection(Connection con){
+ try {
+ con.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
Added: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DataExtractionInfo.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DataExtractionInfo.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DataExtractionInfo.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DataExtractionInfo.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,74 @@
+package org.apache.stanbol.reengineer.db;
+
+public class DataExtractionInfo {
+
+ String table;
+ int jobDone;
+ int jobDonePerc;
+ int partialJobDone;
+ int partialJobDonePerc;
+
+ public DataExtractionInfo() {
+ jobDone = 0;
+ jobDonePerc = 0;
+ partialJobDone = 0;
+ partialJobDonePerc = 0;
+ table = "";
+ }
+
+ public synchronized String getTable() {
+ return table;
+ }
+
+ public synchronized void setTable(String table) {
+ this.table = table;
+ }
+
+ public synchronized int getJobDone() {
+ return jobDone;
+ }
+
+ public synchronized void setJobDone(int jobDone) {
+ this.jobDone = jobDone;
+ }
+
+ public synchronized void addJobDone(int jobDone) {
+ this.jobDone += jobDone;
+ }
+
+ public synchronized int getJobDonePerc() {
+ return jobDonePerc;
+ }
+
+ public synchronized void setJobDonePerc(int jobDonePerc) {
+ this.jobDonePerc = jobDonePerc;
+ }
+
+ public synchronized void addJobDonePerc(int jobDonePerc) {
+ this.jobDonePerc += jobDonePerc;
+ }
+
+ public synchronized int getPartialJobDone() {
+ return partialJobDone;
+ }
+
+ public synchronized void setPartialJobDone(int partialJobDone) {
+ this.partialJobDone = partialJobDone;
+ }
+
+ public synchronized void addPartialJobDone(int partialJobDone) {
+ this.partialJobDone += partialJobDone;
+ }
+
+ public synchronized int getPartialJobDonePerc() {
+ return partialJobDonePerc;
+ }
+
+ public synchronized void setPartialJobDonePerc(int partialJobDonePerc) {
+ this.partialJobDonePerc = partialJobDonePerc;
+ }
+
+ public synchronized void addPartialJobDonePerc(int partialJobDonePerc) {
+ this.partialJobDonePerc += partialJobDonePerc;
+ }
+}
Added: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/TablePKRelations.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/TablePKRelations.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/TablePKRelations.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/TablePKRelations.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,60 @@
+package org.apache.stanbol.reengineer.db;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * Utility class for representing and managing in Semion primary and foreign keys of relatinal databases.
+ *
+ * @author andrea.nuzzolese
+ *
+ */
+
+public class TablePKRelations {
+
+ String fkTableName;
+ ArrayList<String> pkColumns;
+ ArrayList<String> fkColumns;
+ String pkTable;
+
+ /**
+ * Create a new {@code TablePKRelations}
+ *
+ * @param fkTableName
+ * @param fkColumns
+ * @param pkColumns
+ * @param pkTable
+ */
+ public TablePKRelations(String fkTableName, ArrayList<String> fkColumns, ArrayList<String> pkColumns, String pkTable) {
+ this.fkTableName = fkTableName;
+ this.fkColumns = fkColumns;
+ this.pkColumns = pkColumns;
+ this.pkTable = pkTable;
+ }
+
+
+ public String getFkTableName() {
+ return fkTableName;
+ }
+
+ public ArrayList<String> getFkColumns() {
+ return fkColumns;
+ }
+
+ public ArrayList<String> getPkColumns() {
+ return pkColumns;
+ }
+
+ public String getPkTable() {
+ return pkTable;
+ }
+
+ public void setPkColumns(ArrayList<String> pkColumns) {
+ this.pkColumns = pkColumns;
+ }
+
+ public void setFkColumns(ArrayList<String> fkColumns) {
+ this.fkColumns = fkColumns;
+ }
+
+}
Propchange: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/connection/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Added: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/connection/DatabaseConnection.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/connection/DatabaseConnection.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/connection/DatabaseConnection.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/connection/DatabaseConnection.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,153 @@
+package org.apache.stanbol.reengineer.db.connection;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.clerezza.rdf.core.Literal;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.access.TcManager;
+
+import org.semanticweb.owlapi.model.OWLOntology;
+
+
+import com.hp.hpl.jena.ontology.OntModel;
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryExecution;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
+import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.vocabulary.RDF;
+
+
+import org.apache.stanbol.reengineer.db.vocab.DBS_L1;
+
+import org.apache.stanbol.owl.trasformation.JenaToOwlConvert;
+
+public class DatabaseConnection {
+
+
+ private OWLOntology schemaOntology;
+ private Connection connection;
+
+ private java.sql.Statement stmt;
+ private PreparedStatement preparedStatement;
+
+ public DatabaseConnection(OWLOntology schemaOntology) {
+
+ this.schemaOntology = schemaOntology;
+ }
+
+
+
+ public void openDBConnection(){
+
+
+
+ String sparql = "SELECT ?dbName ?jdbcDNS ?jdbcDriver ?username ?password " +
+ "WHERE ?db <"+RDF.type.getURI()+"> <"+DBS_L1.DatabaseConnection.toString()+"> . " +
+ "?db <"+DBS_L1.hasPhysicalName.toString()+"> ?dbName . " +
+ "?db <"+DBS_L1.hasJDBCDns.toString()+"> ?jdbcDNS . " +
+ "?db <"+DBS_L1.hasJDBCDriver.toString()+"> ?jdbcDriver . " +
+ "?db <"+DBS_L1.hasUsername.toString()+"> ?username . " +
+ "?db <"+DBS_L1.hasPassword.toString()+"> ?password ";
+
+
+ JenaToOwlConvert jenaToOwlConvert = new JenaToOwlConvert();
+ OntModel ontModel = jenaToOwlConvert.ModelOwlToJenaConvert(schemaOntology, "RDF/XML");
+
+ Query sparqlQuery = QueryFactory.create(sparql);
+ QueryExecution qexec = QueryExecutionFactory.create(sparqlQuery, ontModel) ;
+ com.hp.hpl.jena.query.ResultSet jenaRs = qexec.execSelect();
+ if(jenaRs.hasNext()){
+ QuerySolution qs = jenaRs.next();
+ String jdbcDNS = qs.getLiteral("jdbcDNS").getLexicalForm();
+ String jdbcDriver = qs.getLiteral("jdbcDriver").getLexicalForm();
+ String username = qs.getLiteral("username").getLexicalForm();
+ String password = qs.getLiteral("password").getLexicalForm();
+
+ if(jdbcDNS != null && username != null && password != null && jdbcDriver != null){
+ try {
+ Class.forName(jdbcDriver);
+ connection = java.sql.DriverManager.getConnection(jdbcDNS, username, password);
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+
+
+ }
+
+
+ public ResultSet executeQuery(String query){
+ try {
+
+ openDBConnection();
+
+ System.out.println(query);
+ preparedStatement = connection.prepareStatement(query);
+
+ return preparedStatement.executeQuery();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+
+ public synchronized ResultSet executeQuerySafeMemory(String query){
+ try {
+
+ openDBConnection();
+
+ stmt = connection.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,
+ java.sql.ResultSet.CONCUR_READ_ONLY);
+ System.out.println("Integer.MIN_VALUE: "+Integer.MIN_VALUE);
+ stmt.setFetchSize(Integer.MIN_VALUE);
+
+
+
+ return stmt.executeQuery(query);
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public void closeDBConnection(){
+ try {
+ connection.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void closeStatement(){
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void closePreparedStatement(){
+ try {
+ preparedStatement.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
Propchange: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Added: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/Collectionentity.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/Collectionentity.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/Collectionentity.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/Collectionentity.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,28 @@
+package org.apache.stanbol.reengineer.db.ontology;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+
+public class Collectionentity {
+ /** <p>The RDF model that holds the vocabulary terms</p> */
+ private static Model m_model = ModelFactory.createDefaultModel();
+
+ /** <p>The namespace of the vocabulary as a string</p> */
+ public static final String NS = "http://www.ontologydesignpatterns.org/cp/owl/collectionentity.owl#";
+
+ /** <p>The namespace of the vocabulary as a string</p>
+ * @see #NS */
+ public static String getURI() {return NS;}
+
+ /** <p>The namespace of the vocabulary as a resource</p> */
+ public static final Resource NAMESPACE = m_model.createResource( NS );
+
+ public static final Property hasMember = m_model.createProperty( "http://www.ontologydesignpatterns.org/cp/owl/collectionentity.owl#hasMember" );
+
+ public static final Property isMemberOf = m_model.createProperty( "http://www.ontologydesignpatterns.org/cp/owl/collectionentity.owl#isMemberOf" );
+
+ /** <p>Any physical, social, or mental object, or a substance</p> */
+ public static final Resource Collection = m_model.createResource( "http://www.ontologydesignpatterns.org/cp/owl/collectionentity.owl#Collection" );
+}
Added: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/DBS_L1.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/DBS_L1.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/DBS_L1.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/DBS_L1.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,192 @@
+package org.apache.stanbol.reengineer.db.ontology;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
+import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.util.FileManager;
+
+/**
+ * Vocabulary definitions from http://andriry.altervista.org/tesiSpecialistica/dbs_l1.owl
+ * @author andrea.nuzzolese
+ */
+
+public class DBS_L1 {
+
+
+ private static Model m_model = ModelFactory.createDefaultModel();
+
+ /** <p>The namespace of the vocabulary as a string</p> */
+ public static final String NS = "http://andriry.altervista.org/tesiSpecialistica/dbs_l1.owl#";
+
+ /** <p>The namespace of the vocabulary as a string</p>
+ * @see #NS */
+ public static String getURI() {return NS;}
+
+ /** <p>The namespace of the vocabulary as a resource</p> */
+ public static final Resource NAMESPACE = m_model.createResource( NS );
+
+ public static final Property bindToColumn = m_model.createProperty( NS+"bindToColumn" );
+
+ public static final Property hasColumn = m_model.createProperty( NS+"hasColumn" );
+
+ public static final Property isColumnOf = m_model.createProperty( NS+"isColumnOf" );
+
+ public static final Property hasDatum = m_model.createProperty( NS+"hasDatum" );
+
+ public static final Property isDatumOf = m_model.createProperty( NS+"isDatumOf" );
+
+ public static final Property hasRow = m_model.createProperty( NS+"hasRow" );
+
+ public static final Property isRowOf = m_model.createProperty( NS+"isRowOf" );
+
+ public static final Property isComposedBy = m_model.createProperty( NS+"isComposedBy" );
+
+ public static final Property composes = m_model.createProperty( NS+"composes" );
+
+ public static final Property hasKey = m_model.createProperty( NS+"hasKey" );
+
+ public static final Property isKeyOf = m_model.createProperty( NS+"isKeyOf" );
+
+ public static final Property hasPrimaryKey = m_model.createProperty( NS+"hasPrimaryKey" );
+
+ public static final Property isPrimaryKeyOf = m_model.createProperty( NS+"isPrimaryKeyOf" );
+
+ public static final Property hasForeignKey = m_model.createProperty( NS+"hasForeignKey" );
+
+ public static final Property isForeignKeyOf = m_model.createProperty( NS+"isForeignKeyOf" );
+
+ public static final Property hasSQLType = m_model.createProperty( NS+"hasSQLType" );
+
+ public static final Property hasTable = m_model.createProperty( NS+"hasTable" );
+
+ public static final Property isTableOf = m_model.createProperty( NS+"isTableOf" );
+
+ public static final Property isBoundBy = m_model.createProperty( NS+"isBoundBy" );
+
+ public static final Property isJoinedBy = m_model.createProperty( NS+"isJoinedBy" );
+
+ public static final Property joinsOn = m_model.createProperty( NS+"joinsOn" );
+
+ public static final Property isDumped = m_model.createProperty( NS+"isDumped" );
+
+ public static final Property hasContent = m_model.createProperty( NS+"hasContent" );
+
+ public static final Property hasName = m_model.createProperty( NS+"hasName" );
+
+ public static final Property hasPhysicalName = m_model.createProperty( NS+"hasPhysicalName" );
+
+ public static final Property hasJDBCDriver = m_model.createProperty( NS+"hasJDBCDriver" );
+
+ public static final Property hasJDBCDns = m_model.createProperty( NS+"hasJDBCDns" );
+
+ public static final Property hasUsername = m_model.createProperty( NS+"hasUsername" );
+
+ public static final Property hasPassword = m_model.createProperty( NS+"hasPassword" );
+
+ public static final Property hasPrimaryKeyMember = m_model.createProperty( NS+"hasPrimaryKeyMember" );
+
+ public static final Property isPrimaryKeyMemberOf = m_model.createProperty( NS+"isPrimaryKeyMemberOf" );
+
+ public static final Property hasForeignKeyMember = m_model.createProperty( NS+"hasForeignKeyMember" );
+
+ public static final Property isForeignKeyMemberOf = m_model.createProperty( NS+"isForeignKeyMemberOf" );
+
+ public static final Resource Datum = m_model.createResource( NS+"Datum" );
+
+ public static final Resource DatabaseConnection = m_model.createResource( NS+"DatabaseConnection" );
+
+ public static final Resource DataObject = m_model.createResource( NS+"DataObject" );
+
+ public static final Resource SchemaObject = m_model.createResource( NS+"SchemaObject" );
+
+ public static final Resource Row = m_model.createResource( NS+"Row" );
+
+ public static final Resource Column = m_model.createResource( NS+"Column" );
+
+ public static final Resource Key = m_model.createResource( NS+"Key" );
+
+ public static final Resource PrimaryKey = m_model.createResource( NS+"PrimaryKey" );
+
+ public static final Resource ForeignKey = m_model.createResource( NS+"ForeignKey" );
+
+ public static final Resource Table = m_model.createResource( NS+"Table" );
+
+ public static final Resource NotNullableColumn = m_model.createResource( NS+"NotNullableColumn" );
+
+ public static final Resource NullableColumn = m_model.createResource( NS+"NullableColumn" );
+
+ public static Model getModel(){
+ //return FileManager.get().loadModel("http://andriry.altervista.org/tesiSpecialistica/dbs_l1.owl");
+ return FileManager.get().loadModel("rdf/dbs_l1.owl");
+ }
+
+ public static String getSPARQLPrefix(){
+ Map<String, String> prefixMap = getModel().getNsPrefixMap();
+ Set<String> prefixSet = prefixMap.keySet();
+ Iterator<String> it = prefixSet.iterator();
+
+ String sparqlPrefix = "";
+
+
+ while(it.hasNext()){
+ String prefix = it.next();
+ try {
+ String uri = prefixMap.get(prefix);
+ uri = uri.replace("\\", "/");
+ sparqlPrefix += "PREFIX "+prefix+": <"+(new URI(uri).toString())+">"+System.getProperty("line.separator");
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ return sparqlPrefix;
+ }
+
+ public static String getSPARQLPrefix(Model model){
+ Map<String, String> prefixMap = model.getNsPrefixMap();
+ Set<String> prefixSet = prefixMap.keySet();
+ Iterator<String> it = prefixSet.iterator();
+
+ String sparqlPrefix = "";
+
+
+ while(it.hasNext()){
+ String prefix = it.next();
+ try {
+ String uri = prefixMap.get(prefix);
+ uri = uri.replace("\\", "/");
+ sparqlPrefix += "PREFIX "+prefix+": <"+(new URI(uri).toString())+">"+System.getProperty("line.separator");
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ return sparqlPrefix;
+ }
+
+ public static ResultSet executeQuery(String querySPARQL){
+ Query query = QueryFactory.create(querySPARQL);
+ return QueryExecutionFactory.create(query, getModel()).execSelect();
+ }
+
+ public static ResultSet executeQuery(Model model, String querySPARQL){
+ Query query = QueryFactory.create(querySPARQL);
+ return QueryExecutionFactory.create(query, model).execSelect();
+ }
+
+}
Added: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/ObjectRole.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/ObjectRole.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/ObjectRole.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/ObjectRole.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,35 @@
+package org.apache.stanbol.reengineer.db.ontology;
+
+/* CVS $Id: ObjectRole.java 1082603 2011-03-17 17:41:13Z alexdma $ */
+
+import com.hp.hpl.jena.rdf.model.*;
+
+/**
+ * Vocabulary definitions from http://ontologydesignpatterns.org/cp/owl/objectrole.owl
+ * @author Auto-generated by schemagen on 12 feb 2010 10:07
+ */
+public class ObjectRole {
+ /** <p>The RDF model that holds the vocabulary terms</p> */
+ private static Model m_model = ModelFactory.createDefaultModel();
+
+ /** <p>The namespace of the vocabulary as a string</p> */
+ public static final String NS = "http://www.ontologydesignpatterns.org/cp/owl/objectrole.owl#";
+
+ /** <p>The namespace of the vocabulary as a string</p>
+ * @see #NS */
+ public static String getURI() {return NS;}
+
+ /** <p>The namespace of the vocabulary as a resource</p> */
+ public static final Resource NAMESPACE = m_model.createResource( NS );
+
+ public static final Property hasRole = m_model.createProperty( "http://www.ontologydesignpatterns.org/cp/owl/objectrole.owl#hasRole" );
+
+ public static final Property isRoleOf = m_model.createProperty( "http://www.ontologydesignpatterns.org/cp/owl/objectrole.owl#isRoleOf" );
+
+ /** <p>Any physical, social, or mental object, or a substance</p> */
+ public static final Resource Object = m_model.createResource( "http://www.ontologydesignpatterns.org/cp/owl/objectrole.owl#Object" );
+
+ /** <p>A Concept that classifies an Object</p> */
+ public static final Resource Role = m_model.createResource( "http://www.ontologydesignpatterns.org/cp/owl/objectrole.owl#Role" );
+
+}
Added: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/Schema.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/Schema.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/Schema.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ontology/Schema.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,167 @@
+package org.apache.stanbol.reengineer.db.ontology;
+
+/* CVS $Id: Schema.java 1082603 2011-03-17 17:41:13Z alexdma $ */
+
+import com.hp.hpl.jena.rdf.model.*;
+
+/**
+ * Vocabulary definitions from http://andriry.altervista.org/tesiSpecialistica/schema.owl
+ * @author Auto-generated by schemagen on 07 Jul 2010 17:13
+ */
+public class Schema {
+ /** <p>The RDF model that holds the vocabulary terms</p> */
+ private static Model m_model = ModelFactory.createDefaultModel();
+
+ /** <p>The namespace of the vocabulary as a string</p> */
+ public static final String NS = "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#";
+
+ /** <p>The namespace of the vocabulary as a string</p>
+ * @see #NS */
+ public static String getURI() {return NS;}
+
+ /** <p>The namespace of the vocabulary as a resource</p> */
+ public static final Resource NAMESPACE = m_model.createResource( NS );
+
+ public static final Resource Annotation = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Annotation" );
+
+ public static final Resource Any = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Any" );
+
+ public static final Resource AnyAttribute = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#AnyAttribute" );
+
+ public static final Resource Appinfo = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Appinfo" );
+
+ public static final Resource Attribute = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Attribute" );
+
+ public static final Resource AttributeGroup = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#AttributeGroup" );
+
+ public static final Resource Choice = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Choice" );
+
+ public static final Resource ComplexContent = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#ComplexContent" );
+
+ public static final Resource ComplexType = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#ComplexType" );
+
+ public static final Resource Documentation = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Documentation" );
+
+ public static final Resource Element = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Element" );
+
+ public static final Resource Enumeration = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Enumeration" );
+
+ public static final Resource Extension = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Extension" );
+
+ public static final Resource Field = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Field" );
+
+ public static final Resource FractionDigits = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#FractionDigits" );
+
+ public static final Resource Group = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Group" );
+
+ public static final Resource HasFacet = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#HasFacet" );
+
+ public static final Resource HasFacetAndPropertyhasProperty = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#HasFacetAndPropertyhasProperty" );
+
+ public static final Resource Import = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Import" );
+
+ public static final Resource Key = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Key" );
+
+ public static final Resource List = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#List" );
+
+ public static final Resource MaxEclusive = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#MaxEclusive" );
+
+ public static final Resource MinEclusive = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#MinEclusive" );
+
+ public static final Resource MaxInclusive = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#MaxInclusive" );
+
+ public static final Resource MinInclusive = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#MinInclusive" );
+
+ public static final Resource MinLength = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#MinLength" );
+
+ public static final Resource Notation = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Notation" );
+
+ public static final Resource Pattern = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Pattern" );
+
+ public static final Resource All = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#All" );
+
+ public static final Resource Restriction = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Restriction" );
+
+ public static final Resource Schema = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Schema" );
+
+ public static final Resource Selector = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Selector" );
+
+ public static final Resource Sequence = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Sequence" );
+
+ public static final Resource SimpleType = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#SimpleType" );
+
+ public static final Resource Union = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Union" );
+
+ public static final Resource WhiteSpace = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#WhiteSpace" );
+
+ public static final Resource ScopeAbsent = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Absent" );
+
+ public static final Resource ScopeLocal = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Local" );
+
+ public static final Resource ScopeGlobal = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#Global" );
+
+ public static final Resource VC_NONE = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#VC_NONE" );
+
+ public static final Resource VC_DEFAULT = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#VC_DEFAULT" );
+
+ public static final Resource VC_FIXED = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#VC_FIXED" );
+
+ public static final Resource DERIVATION_EXTENSION = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#DERIVATION_EXTENSION" );
+
+ public static final Resource DERIVATION_RESTRICTION = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#DERIVATION_RESTRICTION" );
+
+ public static final Resource DERIVATION_NONE = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#DERIVATION_NONE" );
+
+ public static final Resource PROHIBITED_EXTENSION = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#PROHIBITED_EXTENSION" );
+
+ public static final Resource PROHIBITED_RESTRICTION = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#PROHIBITED_RESTRICTION" );
+
+ public static final Resource PROHIBITED_NONE = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#PROHIBITED_NONE" );
+
+ public static final Resource COLLAPSE = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#COLLAPSE" );
+
+ public static final Resource PRESERVE = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#PRESERVE" );
+
+ public static final Resource REPLACE = m_model.createResource( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#REPLACE" );
+
+ public static final Property abstractProperty = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#abstract" );
+
+ public static final Property name = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#name" );
+
+ public static final Property type = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#type" );
+
+ public static final Property hasScope = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasScope" );
+
+ public static final Property hasConstraintType = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasConstraintType" );
+
+ public static final Property hasFinal = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasFinal" );
+
+ public static final Property constraint = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#constraint" );
+
+ public static final Property maxOccurs = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#maxOccurs" );
+
+ public static final Property minOccurs = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#minOccurs" );
+
+ public static final Property hasProhibitedSubstitutions = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasProhibitedSubstitutions" );
+
+ public static final Property required = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#required" );
+
+ public static final Property hasParticle = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasParticle" );
+
+ public static final Property hasCompositor = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasCompositor" );
+
+ public static final Property value = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#value" );
+
+ public static final Property hasEnumeration = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasEnumeration" );
+
+ public static final Property hasWhitespace = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasWhitespace" );
+
+ public static final Property base = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#base" );
+
+ public static final Property hasAnnotation = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasAnnotation" );
+
+ public static final Property hasPattern = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasPattern" );
+
+ public static final Property hasAttributeUse = m_model.createProperty( "http://andriry.altervista.org/tesiSpecialistica/schema.xsd#hasAttributeUse" );
+
+}
Propchange: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/vocab/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Added: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/vocab/DBS_L1.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/vocab/DBS_L1.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/vocab/DBS_L1.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/vocab/DBS_L1.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,207 @@
+package org.apache.stanbol.reengineer.db.vocab;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
+import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.util.FileManager;
+
+
+/**
+ * Vocabulary definitions from http://ontologydesignpatterns.org/ont/iks/dbs_l1.owl
+ * @author andrea.nuzzolese
+ */
+
+public class DBS_L1 {
+
+
+ private static Model m_model = ModelFactory.createDefaultModel();
+
+ /** <p>The namespace of the vocabulary as a string</p> */
+ public static final String NS = "http://ontologydesignpatterns.org/ont/iks/dbs_l1.owl#";
+
+ public static final String URI = "http://ontologydesignpatterns.org/ont/iks/dbs_l1.owl";
+
+
+ private static MGraph mGraph = new SimpleMGraph();
+
+
+ /** <p>The namespace of the vocabulary as a string</p>
+ * @see #NS */
+ public static String getURI() {return URI;}
+
+
+ public static final UriRef RDF_TYPE = new UriRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#" + "type");
+
+ public static final UriRef RDFS_LABEL = new UriRef("http://www.w3.org/2000/01/rdf-schema#" + "label");
+
+ public static final UriRef NAMESPACE = new UriRef(NS);
+
+ public static final UriRef bindToColumn = new UriRef( NS+"bindToColumn" );
+
+ public static final UriRef hasColumn = new UriRef( NS+"hasColumn" );
+
+ public static final UriRef isColumnOf = new UriRef( NS+"isColumnOf" );
+
+ public static final UriRef hasDatum = new UriRef( NS+"hasDatum" );
+
+ public static final UriRef isDatumOf = new UriRef( NS+"isDatumOf" );
+
+ public static final UriRef hasRow = new UriRef( NS+"hasRow" );
+
+ public static final UriRef isRowOf = new UriRef( NS+"isRowOf" );
+
+ public static final UriRef isComposedBy = new UriRef( NS+"isComposedBy" );
+
+ public static final UriRef composes = new UriRef( NS+"composes" );
+
+ public static final UriRef hasKey = new UriRef( NS+"hasKey" );
+
+ public static final UriRef isKeyOf = new UriRef( NS+"isKeyOf" );
+
+ public static final UriRef hasPrimaryKey = new UriRef( NS+"hasPrimaryKey" );
+
+ public static final UriRef isPrimaryKeyOf = new UriRef( NS+"isPrimaryKeyOf" );
+
+ public static final UriRef hasForeignKey = new UriRef( NS+"hasForeignKey" );
+
+ public static final UriRef isForeignKeyOf = new UriRef( NS+"isForeignKeyOf" );
+
+ public static final UriRef hasSQLType = new UriRef( NS+"hasSQLType" );
+
+ public static final UriRef hasTable = new UriRef( NS+"hasTable" );
+
+ public static final UriRef isTableOf = new UriRef( NS+"isTableOf" );
+
+ public static final UriRef isBoundBy = new UriRef( NS+"isBoundBy" );
+
+ public static final UriRef isJoinedBy = new UriRef( NS+"isJoinedBy" );
+
+ public static final UriRef joinsOn = new UriRef( NS+"joinsOn" );
+
+ public static final UriRef isDumped = new UriRef( NS+"isDumped" );
+
+ public static final UriRef hasContent = new UriRef( NS+"hasContent" );
+
+ public static final UriRef hasName = new UriRef( NS+"hasName" );
+
+ public static final UriRef hasPhysicalName = new UriRef( NS+"hasPhysicalName" );
+
+ public static final UriRef hasJDBCDriver = new UriRef( NS+"hasJDBCDriver" );
+
+ public static final UriRef hasJDBCDns = new UriRef( NS+"hasJDBCDns" );
+
+ public static final UriRef hasUsername = new UriRef( NS+"hasUsername" );
+
+ public static final UriRef hasPassword = new UriRef( NS+"hasPassword" );
+
+ public static final UriRef hasPrimaryKeyMember = new UriRef( NS+"hasPrimaryKeyMember" );
+
+ public static final UriRef isPrimaryKeyMemberOf = new UriRef( NS+"isPrimaryKeyMemberOf" );
+
+ public static final UriRef hasForeignKeyMember = new UriRef( NS+"hasForeignKeyMember" );
+
+ public static final UriRef isForeignKeyMemberOf = new UriRef( NS+"isForeignKeyMemberOf" );
+
+ public static final UriRef Datum = new UriRef( NS+"Datum" );
+
+ public static final UriRef DatabaseConnection = new UriRef( NS+"DatabaseConnection" );
+
+ public static final UriRef DataObject = new UriRef( NS+"DataObject" );
+
+ public static final UriRef SchemaObject = new UriRef( NS+"SchemaObject" );
+
+ public static final UriRef Record = new UriRef( NS+"Record" );
+
+ public static final UriRef Row = new UriRef( NS+"Row" );
+
+ public static final UriRef Column = new UriRef( NS+"Column" );
+
+ public static final UriRef Key = new UriRef( NS+"Key" );
+
+ public static final UriRef PrimaryKey = new UriRef( NS+"PrimaryKey" );
+
+ public static final UriRef ForeignKey = new UriRef( NS+"ForeignKey" );
+
+ public static final UriRef Table = new UriRef( NS+"Table" );
+
+ public static final UriRef NotNullableColumn = new UriRef( NS+"NotNullableColumn" );
+
+ public static final UriRef NullableColumn = new UriRef( NS+"NullableColumn" );
+
+ public static Model getModel(){
+ //return FileManager.get().loadModel("http://andriry.altervista.org/tesiSpecialistica/dbs_l1.owl");
+ return FileManager.get().loadModel(URI);
+ }
+
+ public static String getSPARQLPrefix(){
+ Map<String, String> prefixMap = getModel().getNsPrefixMap();
+ Set<String> prefixSet = prefixMap.keySet();
+ Iterator<String> it = prefixSet.iterator();
+
+ String sparqlPrefix = "";
+
+
+ while(it.hasNext()){
+ String prefix = it.next();
+ try {
+ String uri = prefixMap.get(prefix);
+ uri = uri.replace("\\", "/");
+ sparqlPrefix += "PREFIX "+prefix+": <"+(new URI(uri).toString())+">"+System.getProperty("line.separator");
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ return sparqlPrefix;
+ }
+
+ public static String getSPARQLPrefix(Model model){
+ Map<String, String> prefixMap = model.getNsPrefixMap();
+ Set<String> prefixSet = prefixMap.keySet();
+ Iterator<String> it = prefixSet.iterator();
+
+ String sparqlPrefix = "";
+
+
+ while(it.hasNext()){
+ String prefix = it.next();
+ try {
+ String uri = prefixMap.get(prefix);
+ uri = uri.replace("\\", "/");
+ sparqlPrefix += "PREFIX "+prefix+": <"+(new URI(uri).toString())+">"+System.getProperty("line.separator");
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ return sparqlPrefix;
+ }
+
+ public static ResultSet executeQuery(String querySPARQL){
+ Query query = QueryFactory.create(querySPARQL);
+ return QueryExecutionFactory.create(query, getModel()).execSelect();
+ }
+
+ public static ResultSet executeQuery(Model model, String querySPARQL){
+ Query query = QueryFactory.create(querySPARQL);
+ return QueryExecutionFactory.create(query, model).execSelect();
+ }
+
+}
Added: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/vocab/DBS_L1_OWL.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/vocab/DBS_L1_OWL.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/vocab/DBS_L1_OWL.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/vocab/DBS_L1_OWL.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,117 @@
+package org.apache.stanbol.reengineer.db.vocab;
+
+import org.semanticweb.owlapi.model.IRI;
+
+
+
+public class DBS_L1_OWL {
+
+ /** <p>The namespace of the vocabulary as a string</p> */
+ public static final String NS = "http://ontologydesignpatterns.org/ont/iks/dbs_l1.owl#";
+
+ public static final String URI = "http://ontologydesignpatterns.org/ont/iks/dbs_l1.owl";
+
+ /** <p>The namespace of the vocabulary as a string</p>
+ * @see #NS */
+ public static String getURI() {return NS;}
+
+
+ public static final IRI RDF_TYPE = IRI.create("http://www.w3.org/1999/02/22-rdf-syntax-ns#" + "type");
+
+ public static final IRI RDFS_LABEL = IRI.create("http://www.w3.org/2000/01/rdf-schema#" + "label");
+
+ public static final IRI NAMESPACE = IRI.create(NS);
+
+ public static final IRI bindToColumn = IRI.create( NS+"bindToColumn" );
+
+ public static final IRI hasColumn = IRI.create( NS+"hasColumn" );
+
+ public static final IRI isColumnOf = IRI.create( NS+"isColumnOf" );
+
+ public static final IRI hasDatum = IRI.create( NS+"hasDatum" );
+
+ public static final IRI isDatumOf = IRI.create( NS+"isDatumOf" );
+
+ public static final IRI hasRow = IRI.create( NS+"hasRow" );
+
+ public static final IRI isRowOf = IRI.create( NS+"isRowOf" );
+
+ public static final IRI isComposedBy = IRI.create( NS+"isComposedBy" );
+
+ public static final IRI composes = IRI.create( NS+"composes" );
+
+ public static final IRI hasKey = IRI.create( NS+"hasKey" );
+
+ public static final IRI isKeyOf = IRI.create( NS+"isKeyOf" );
+
+ public static final IRI hasPrimaryKey = IRI.create( NS+"hasPrimaryKey" );
+
+ public static final IRI isPrimaryKeyOf = IRI.create( NS+"isPrimaryKeyOf" );
+
+ public static final IRI hasForeignKey = IRI.create( NS+"hasForeignKey" );
+
+ public static final IRI isForeignKeyOf = IRI.create( NS+"isForeignKeyOf" );
+
+ public static final IRI hasSQLType = IRI.create( NS+"hasSQLType" );
+
+ public static final IRI hasTable = IRI.create( NS+"hasTable" );
+
+ public static final IRI isTableOf = IRI.create( NS+"isTableOf" );
+
+ public static final IRI isBoundBy = IRI.create( NS+"isBoundBy" );
+
+ public static final IRI isJoinedBy = IRI.create( NS+"isJoinedBy" );
+
+ public static final IRI joinsOn = IRI.create( NS+"joinsOn" );
+
+ public static final IRI isDumped = IRI.create( NS+"isDumped" );
+
+ public static final IRI hasContent = IRI.create( NS+"hasContent" );
+
+ public static final IRI hasName = IRI.create( NS+"hasName" );
+
+ public static final IRI hasPhysicalName = IRI.create( NS+"hasPhysicalName" );
+
+ public static final IRI hasJDBCDriver = IRI.create( NS+"hasJDBCDriver" );
+
+ public static final IRI hasJDBCDns = IRI.create( NS+"hasJDBCDns" );
+
+ public static final IRI hasUsername = IRI.create( NS+"hasUsername" );
+
+ public static final IRI hasPassword = IRI.create( NS+"hasPassword" );
+
+ public static final IRI hasPrimaryKeyMember = IRI.create( NS+"hasPrimaryKeyMember" );
+
+ public static final IRI isPrimaryKeyMemberOf = IRI.create( NS+"isPrimaryKeyMemberOf" );
+
+ public static final IRI hasForeignKeyMember = IRI.create( NS+"hasForeignKeyMember" );
+
+ public static final IRI isForeignKeyMemberOf = IRI.create( NS+"isForeignKeyMemberOf" );
+
+ public static final IRI Datum = IRI.create( NS+"Datum" );
+
+ public static final IRI DatabaseConnection = IRI.create( NS+"DatabaseConnection" );
+
+ public static final IRI DataObject = IRI.create( NS+"DataObject" );
+
+ public static final IRI SchemaObject = IRI.create( NS+"SchemaObject" );
+
+ public static final IRI Record = IRI.create( NS+"Record" );
+
+ public static final IRI Row = IRI.create( NS+"Row" );
+
+ public static final IRI Column = IRI.create( NS+"Column" );
+
+ public static final IRI Key = IRI.create( NS+"Key" );
+
+ public static final IRI PrimaryKey = IRI.create( NS+"PrimaryKey" );
+
+ public static final IRI ForeignKey = IRI.create( NS+"ForeignKey" );
+
+ public static final IRI Table = IRI.create( NS+"Table" );
+
+ public static final IRI NotNullableColumn = IRI.create( NS+"NotNullableColumn" );
+
+ public static final IRI NullableColumn = IRI.create( NS+"NullableColumn" );
+
+}
Propchange: incubator/stanbol/trunk/reengineer/db/src/main/resources/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Added: incubator/stanbol/trunk/reengineer/db/src/main/resources/mysql-connector-java-5.1.10.jar
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/resources/mysql-connector-java-5.1.10.jar?rev=1087691&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/stanbol/trunk/reengineer/db/src/main/resources/mysql-connector-java-5.1.10.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Propchange: incubator/stanbol/trunk/reengineer/db/src/test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/db/src/test/java/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/db/src/test/java/org/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/db/src/test/java/org/apache/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/db/src/test/java/org/apache/stanbol/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/db/src/test/java/org/apache/stanbol/reengineer/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/db/src/test/java/org/apache/stanbol/reengineer/db/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Added: incubator/stanbol/trunk/reengineer/db/src/test/java/org/apache/stanbol/reengineer/db/DBExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/test/java/org/apache/stanbol/reengineer/db/DBExtractorTest.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/test/java/org/apache/stanbol/reengineer/db/DBExtractorTest.java (added)
+++ incubator/stanbol/trunk/reengineer/db/src/test/java/org/apache/stanbol/reengineer/db/DBExtractorTest.java Fri Apr 1 13:01:38 2011
@@ -0,0 +1,91 @@
+package org.apache.stanbol.reengineer.db;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.access.WeightedTcProvider;
+import org.apache.clerezza.rdf.core.sparql.QueryEngine;
+import org.apache.clerezza.rdf.jena.sparql.JenaSparqlEngine;
+import org.apache.clerezza.rdf.simple.storage.SimpleTcProvider;
+import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
+import org.apache.stanbol.reengineer.base.impl.ReengineerManagerImpl;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.semanticweb.owlapi.model.IRI;
+
+public class DBExtractorTest {
+
+ static DBExtractor dbExtractor;
+ static String graphNS;
+ static ONManager onManager;
+ static IRI outputIRI;
+
+ @BeforeClass
+ public static void setupClass() {
+ Dictionary<String, Object> emptyConf = new Hashtable<String, Object>();
+ class SpecialTcManager extends TcManager {
+ public SpecialTcManager(QueryEngine qe, WeightedTcProvider wtcp) {
+ super();
+ bindQueryEngine(qe);
+ bindWeightedTcProvider(wtcp);
+ }
+ }
+
+ QueryEngine qe = new JenaSparqlEngine();
+ WeightedTcProvider wtcp = new SimpleTcProvider();
+ TcManager tcm = new SpecialTcManager(qe, wtcp);
+
+ // Two different ontology storagez, the same sparql engine and tcprovider
+
+
+ onManager = new ONManagerImpl(tcm, wtcp,emptyConf);
+ dbExtractor = new DBExtractor(new ReengineerManagerImpl(tcm, wtcp),
+ onManager, tcm, wtcp, emptyConf);
+ graphNS = "http://kres.iks-project.eu/reengineering/test";
+ outputIRI = IRI.create(graphNS);
+ }
+
+ @Before
+ public void setup() {
+
+ }
+
+ @Before
+ public void tearDown() {
+
+ }
+
+ @Test
+ public void testDataReengineering(){
+// graphNS = "http://kres.iks-project.eu/reengineering/test";
+// outputIRI = IRI.create(graphNS);
+// try {
+// OWLOntology ontology = dbExtractor.dataReengineering(graphNS,
+// outputIRI, null, dbExtractor.schemaReengineering(graphNS,
+// outputIRI, null));
+// } catch (ReengineeringException e) {
+// fail("Some errors occur with dataReengineering of DBExtractor.");
+// }
+ }
+
+ @Test
+ public void testReengineering(){
+// graphNS = "http://kres.iks-project.eu/reengineering/test";
+// outputIRI = IRI.create(graphNS);
+// try {
+// OWLOntology ontology = dbExtractor.reengineering(graphNS,
+// outputIRI, null);
+// } catch (ReengineeringException e) {
+// fail("Some errors occur with reengineering of DBExtractor.");
+// }
+ }
+
+ @Test
+ public void testSchemaReengineering() {
+// OWLOntology ontology = dbExtractor.schemaReengineering(graphNS,
+// outputIRI, null);
+ }
+}
Propchange: incubator/stanbol/trunk/reengineer/mysql/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Added: incubator/stanbol/trunk/reengineer/mysql/.classpath
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/mysql/.classpath?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/mysql/.classpath (added)
+++ incubator/stanbol/trunk/reengineer/mysql/.classpath Fri Apr 1 13:01:38 2011
@@ -0,0 +1,8 @@
+<classpath>
+ <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
+ <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
+ <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="var" path="M2_REPO/mysql/mysql-connector-java/5.1.10/mysql-connector-java-5.1.10.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+</classpath>
\ No newline at end of file
Added: incubator/stanbol/trunk/reengineer/mysql/.project
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/mysql/.project?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/mysql/.project (added)
+++ incubator/stanbol/trunk/reengineer/mysql/.project Fri Apr 1 13:01:38 2011
@@ -0,0 +1,18 @@
+<projectDescription>
+ <name>org.apache.stanbol.reengineer.mysql</name>
+ <comment>Parent POM for the Apache Stanbol project. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Propchange: incubator/stanbol/trunk/reengineer/mysql/.settings/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Added: incubator/stanbol/trunk/reengineer/mysql/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/mysql/.settings/org.eclipse.jdt.core.prefs?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/mysql/.settings/org.eclipse.jdt.core.prefs (added)
+++ incubator/stanbol/trunk/reengineer/mysql/.settings/org.eclipse.jdt.core.prefs Fri Apr 1 13:01:38 2011
@@ -0,0 +1,6 @@
+#Wed Mar 23 17:40:22 GMT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
Added: incubator/stanbol/trunk/reengineer/mysql/.settings/org.eclipse.m2e.core.prefs
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/mysql/.settings/org.eclipse.m2e.core.prefs?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/mysql/.settings/org.eclipse.m2e.core.prefs (added)
+++ incubator/stanbol/trunk/reengineer/mysql/.settings/org.eclipse.m2e.core.prefs Fri Apr 1 13:01:38 2011
@@ -0,0 +1,5 @@
+#Wed Mar 23 17:37:28 GMT 2011
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
Added: incubator/stanbol/trunk/reengineer/mysql/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/mysql/pom.xml?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/mysql/pom.xml (added)
+++ incubator/stanbol/trunk/reengineer/mysql/pom.xml Fri Apr 1 13:01:38 2011
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>stanbol-parent</artifactId>
+ <version>${stanbol-version}</version>
+ <relativePath>../../../parent</relativePath>
+ </parent>
+ <artifactId>org.apache.stanbol.reengineer.mysql</artifactId>
+ <version>${stanbol-version}</version>
+ <packaging>bundle</packaging>
+ <name>Apache Stanbol Reengineer MySQL dependency</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.10</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ com.mysql.*
+ </Export-Package>
+ <Import-Package>
+ !org.*,
+ !com.mysql.*,
+ !com.mchange.*,
+ *
+ </Import-Package>
+ <_nouses>true</_nouses>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <groupId>org.apache.stanbol</groupId>
+</project>
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/assembly/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Added: incubator/stanbol/trunk/reengineer/mysql/src/main/assembly/felix.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/mysql/src/main/assembly/felix.xml?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/mysql/src/main/assembly/felix.xml (added)
+++ incubator/stanbol/trunk/reengineer/mysql/src/main/assembly/felix.xml Fri Apr 1 13:01:38 2011
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+ <id>all</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <dependencySets>
+ <dependencySet>
+ <useProjectArtifact>false</useProjectArtifact>
+ <outputDirectory>modules</outputDirectory>
+ <excludes>
+ <exclude>org.apache.felix:org.apache.felix.main</exclude>
+ </excludes>
+ </dependencySet>
+ <dependencySet>
+ <useProjectArtifact>false</useProjectArtifact>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>org.apache.felix:org.apache.felix.main</include>
+ </includes>
+ </dependencySet>
+ </dependencySets>
+ <files>
+ <file>
+ <source>${project.build.directory}/${project.artifactId}-${project.version}.jar</source>
+ <outputDirectory>modules</outputDirectory>
+ </file>
+ <file>
+ <source>${project.build.directory}/felix.jar</source>
+ <outputDirectory>bin</outputDirectory>
+ </file>
+ <file>
+ <source>${project.build.directory}/config.properties</source>
+ <outputDirectory>conf</outputDirectory>
+ </file>
+ </files>
+</assembly>
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/eu/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/eu/iksproject/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/eu/iksproject/kres/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/eu/iksproject/kres/shared/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/eu/iksproject/kres/shared/dependency/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/eu/iksproject/kres/shared/dependency/mysql/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/org/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/org/apache/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/org/apache/stanbol/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/org/apache/stanbol/reengineer/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target
Propchange: incubator/stanbol/trunk/reengineer/mysql/src/main/java/org/apache/stanbol/reengineer/mysql/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 1 13:01:38 2011
@@ -0,0 +1 @@
+target