Author: alexdma
Date: Thu Mar 10 11:29:06 2011
New Revision: 1080189
URL: http://svn.apache.org/viewvc?rev=1080189&view=rev
Log:
STANBOL-112 :
- Removed deprecated API and calls thereto.
Removed:
incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/semion/util/OntologyInputSourceDBS_L1.java
incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/semion/util/OntologyInputSourceOXML.java
Modified:
incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/KReSSessionResource.java
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/main/java/eu/iksproject/kres/semion/reengineer/db/DBExtractor.java
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/main/java/eu/iksproject/kres/semion/reengineer/xml/XMLExtractor.java
Modified:
incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/KReSSessionResource.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/KReSSessionResource.java?rev=1080189&r1=1080188&r2=1080189&view=diff
==============================================================================
---
incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/KReSSessionResource.java
(original)
+++
incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/KReSSessionResource.java
Thu Mar 10 11:29:06 2011
@@ -25,7 +25,6 @@ import org.semanticweb.owlapi.model.OWLO
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import eu.iksproject.kres.api.manager.KReSONManager;
-import eu.iksproject.kres.api.manager.io.OntologyInputSource;
import eu.iksproject.kres.api.manager.io.RootOntologyIRISource;
import eu.iksproject.kres.api.manager.io.RootOntologySource;
import eu.iksproject.kres.api.manager.ontology.OntologyScope;
@@ -81,9 +80,7 @@ public class KReSSessionResource extends
OntologyScope ontologyScope = scopeRegistry.getScope(scopeIRI);
SessionOntologySpace sos =
ontologyScope.getSessionSpace(sessionIRI);
try {
- sos.addOntology(new RootOntologySource(ontology)/*
- *
createOntologyInputSource( ontology)
- */);
+ sos.addOntology(new RootOntologySource(ontology));
return Response.ok().build();
} catch (UnmodifiableOntologySpaceException e) {
return Response.status(INTERNAL_SERVER_ERROR).build();
@@ -111,9 +108,7 @@ public class KReSSessionResource extends
OntologyScope ontologyScope = scopeRegistry.getScope(scopeIRI);
SessionOntologySpace sos = ontologyScope.getSessionSpace(sessionIRI);
try {
- sos.addOntology(new RootOntologyIRISource(ontologyIRI)/*
- *
createOntologyInputSource( ontologyIRI)
- */);
+ sos.addOntology(new RootOntologyIRISource(ontologyIRI));
return Response.ok().build();
} catch (UnmodifiableOntologySpaceException e) {
return Response.status(INTERNAL_SERVER_ERROR).build();
@@ -123,66 +118,6 @@ public class KReSSessionResource extends
}
- @Deprecated
- private OntologyInputSource createOntologyInputSource(final IRI iri)
throws OWLOntologyCreationException {
-
- final OWLOntology ontology =
onm.getOwlCacheManager().loadOntology(iri);
- OntologyInputSource ontologyInputSource = new OntologyInputSource() {
-
- @Override
- public IRI getPhysicalIRI() {
- return iri;
- }
-
- @Override
- public OWLOntology getRootOntology() {
- return ontology;
- }
-
- @Override
- public boolean hasPhysicalIRI() {
- return iri == null ? false : true;
- }
-
- @Override
- public boolean hasRootOntology() {
- return ontology == null ? false : true;
- }
- };
-
- return ontologyInputSource;
- }
-
- @Deprecated
- private OntologyInputSource createOntologyInputSource(final OWLOntology
ontology) throws OWLOntologyCreationException {
-
- final IRI iri = ontology.getOntologyID().getOntologyIRI();
- OntologyInputSource ontologyInputSource = new OntologyInputSource() {
-
- @Override
- public IRI getPhysicalIRI() {
- return iri;
- }
-
- @Override
- public OWLOntology getRootOntology() {
- return ontology;
- }
-
- @Override
- public boolean hasPhysicalIRI() {
- return iri == null ? false : true;
- }
-
- @Override
- public boolean hasRootOntology() {
- return ontology == null ? false : true;
- }
- };
-
- return ontologyInputSource;
- }
-
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(value = {KReSFormat.RDF_XML, KReSFormat.OWL_XML,
KReSFormat.TURTLE, KReSFormat.FUNCTIONAL_OWL,
@@ -255,13 +190,8 @@ public class KReSSessionResource extends
* treating this as a physical IRI. See if it still works this
way
*/
OWLOntology o = sos.getOntology(ontologyIRI);
- if (o != null) sos.removeOntology(new RootOntologySource(o)/*
- *
createOntologyInputSource(
- *
ontologyIRI)
-
*/);
+ if (o != null) sos.removeOntology(new RootOntologySource(o));
return Response.ok().build();
- // } catch (OWLOntologyCreationException e) {
- // return Response.status(INTERNAL_SERVER_ERROR).build();
} catch (OntologySpaceModificationException e) {
return Response.status(INTERNAL_SERVER_ERROR).build();
}
Modified:
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/main/java/eu/iksproject/kres/semion/reengineer/db/DBExtractor.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/main/java/eu/iksproject/kres/semion/reengineer/db/DBExtractor.java?rev=1080189&r1=1080188&r2=1080189&view=diff
==============================================================================
---
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/main/java/eu/iksproject/kres/semion/reengineer/db/DBExtractor.java
(original)
+++
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/main/java/eu/iksproject/kres/semion/reengineer/db/DBExtractor.java
Thu Mar 10 11:29:06 2011
@@ -36,15 +36,12 @@ import eu.iksproject.kres.api.semion.Ree
import eu.iksproject.kres.api.semion.SemionManager;
import eu.iksproject.kres.api.semion.SemionReengineer;
import eu.iksproject.kres.api.semion.settings.ConnectionSettings;
-import eu.iksproject.kres.api.semion.util.OntologyInputSourceDBS_L1;
import eu.iksproject.kres.api.semion.util.ReengineerType;
import eu.iksproject.kres.api.semion.util.UnsupportedReengineerException;
import eu.iksproject.kres.ontologies.DBS_L1;
-import eu.iksproject.kres.ontologies.XML_OWL;
/**
- * The {@code DBExtractor} is an implementation of the {@link SemionReengineer}
- * for relational databases.
+ * The {@code DBExtractor} is an implementation of the {@link
SemionReengineer} for relational databases.
*
* @author andrea.nuzzolese
*
@@ -54,332 +51,306 @@ import eu.iksproject.kres.ontologies.XML
@Service(SemionReengineer.class)
public class DBExtractor implements SemionReengineer {
- public static final String _DB_DATA_REENGINEERING_SESSION_DEFAULT =
"/db-data-reengineering-session";
- public static final String _DB_DATA_REENGINEERING_SESSION_SPACE_DEFAULT
= "/db-data-reengineering-session-space";
- public static final String _DB_REENGINEERING_SESSION_SPACE_DEFAULT =
"/db-schema-reengineering-session-space";
- public static final String
_DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE_DEFAULT =
"/db-schema-reengineering-ontology-space";
- public static final String _DB_SCHEMA_REENGINEERING_SESSION_DEFAULT =
"/db-schema-reengineering-session";
- public static final String _HOST_NAME_AND_PORT_DEFAULT =
"localhost:8080";
- public static final String _REENGINEERING_SCOPE_DEFAULT =
"db_reengineering";
-
- @Property(value = _DB_DATA_REENGINEERING_SESSION_DEFAULT)
- public static final String DB_DATA_REENGINEERING_SESSION =
"eu.iksproject.kres.semion.reengineer.db.data";
-
- @Property(value = _DB_DATA_REENGINEERING_SESSION_SPACE_DEFAULT)
- public static final String DB_DATA_REENGINEERING_SESSION_SPACE =
"eu.iksproject.kres.semion.reengineer.space.db.data";
-
- @Property(value = _DB_REENGINEERING_SESSION_SPACE_DEFAULT)
- public static final String DB_REENGINEERING_SESSION_SPACE =
"http://kres.iks-project.eu/space/reengineering/db";
-
- @Property(value = _DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE_DEFAULT)
- public static final String DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE =
"eu.iksproject.kres.semion.reengineer.ontology.space.db";
-
- @Property(value = _DB_SCHEMA_REENGINEERING_SESSION_DEFAULT)
- public static final String DB_SCHEMA_REENGINEERING_SESSION =
"eu.iksproject.kres.semion.reengineer.db.schema";
-
- @Property(value = _HOST_NAME_AND_PORT_DEFAULT)
- public static final String HOST_NAME_AND_PORT = "host.name.port";
-
- @Property(value = _REENGINEERING_SCOPE_DEFAULT)
- public static final String REENGINEERING_SCOPE =
"db.reengineering.scope";
-
- ConnectionSettings connectionSettings;
-
- String databaseURI;
-
- private IRI kReSSessionID;
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference
- KReSONManager onManager;
-
- @Reference
- SemionManager reengineeringManager;
-
- private IRI reengineeringScopeIRI;
-
- private IRI reengineeringSpaceIRI;
-
- MGraph schemaGraph;
- protected OntologyScope scope;
-
- @Reference
- TcManager tcManager;
-
- @Reference
- WeightedTcProvider weightedTcProvider;
-
- /**
- * This default constructor is <b>only</b> intended to be used by the
OSGI
- * environment with Service Component Runtime support.
- * <p>
- * DO NOT USE to manually create instances - the DBExtractor instances
do
- * need to be configured! YOU NEED TO USE
- * {@link #DBExtractor(KReSONManager)} or its overloads, to parse the
- * configuration and then initialise the rule store if running outside a
- * OSGI environment.
- */
- public DBExtractor() {
-
- }
-
- /**
- *
- * Create a new {@link DBExtractor} that is formally a
- * {@link SemionReengineer}.
- *
- */
- public DBExtractor(SemionManager reengineeringManager,
- KReSONManager onManager, TcManager tcManager,
- WeightedTcProvider weightedTcProvider,
- Dictionary<String, Object> configuration) {
- this();
- this.reengineeringManager = reengineeringManager;
- this.onManager = onManager;
- this.tcManager = tcManager;
- this.weightedTcProvider = weightedTcProvider;
- activate(configuration);
- }
-
- /**
- * Create a new {@link DBExtractor} that is formally a
- * {@link SemionReengineer}.
- *
- * @param databaseURI
- * {@link String}
- * @param schemaGraph
- * {@link MGraph}
- * @param connectionSettings
- * {@link ConnectionSettings}
- */
- public DBExtractor(SemionManager reengineeringManager,
- KReSONManager onManager, TcManager tcManager,
- WeightedTcProvider weightedTcProvider,
- Dictionary<String, Object> configuration, String
databaseURI,
- MGraph schemaGraph, ConnectionSettings
connectionSettings) {
- // Copy code from overloaded constructor, except that the call
to
- // activate() goes at the end.
- this();
- this.reengineeringManager = reengineeringManager;
- this.onManager = onManager;
- this.tcManager = tcManager;
- this.weightedTcProvider = weightedTcProvider;
- this.databaseURI = databaseURI;
- this.schemaGraph = schemaGraph;
- this.connectionSettings = connectionSettings;
- activate(configuration);
- }
-
- /**
- * Used to configure an instance within an OSGi container.
- *
- * @throws IOException
- */
- @SuppressWarnings("unchecked")
- @Activate
- protected void activate(ComponentContext context) throws IOException {
- log.info("in " + DBExtractor.class + " activate with context "
- + context);
- if (context == null) {
- throw new IllegalStateException("No valid" +
ComponentContext.class
- + " parsed in activate!");
- }
- activate((Dictionary<String, Object>) context.getProperties());
- }
-
- protected void activate(Dictionary<String, Object> configuration) {
-
- String reengineeringScopeID = (String) configuration
- .get(REENGINEERING_SCOPE);
- if (reengineeringScopeID == null)
- reengineeringScopeID = _REENGINEERING_SCOPE_DEFAULT;
- String hostNameAndPort = (String)
configuration.get(HOST_NAME_AND_PORT);
- if (hostNameAndPort == null)
- hostNameAndPort = _HOST_NAME_AND_PORT_DEFAULT;
- // TODO: Manage the other properties
-
- hostNameAndPort = "http://" + hostNameAndPort;
-
- reengineeringScopeIRI = IRI.create(hostNameAndPort +
"/kres/ontology/"
- + reengineeringScopeID);
- reengineeringSpaceIRI =
IRI.create(DB_REENGINEERING_SESSION_SPACE);
-
- reengineeringManager.bindReengineer(this);
-
- KReSSessionManager kReSSessionManager =
onManager.getSessionManager();
- KReSSession kReSSession = kReSSessionManager.createSession();
-
- kReSSessionID = kReSSession.getID();
-
- OntologyScopeFactory ontologyScopeFactory = onManager
- .getOntologyScopeFactory();
-
- ScopeRegistry scopeRegistry = onManager.getScopeRegistry();
-
- OntologySpaceFactory ontologySpaceFactory = onManager
- .getOntologySpaceFactory();
-
- scope = null;
- try {
- log.info("Semion DBExtractor : created scope with IRI "
- + REENGINEERING_SCOPE);
- IRI iri = IRI.create(DBS_L1.URI);
- OWLOntologyManager ontologyManager = OWLManager
- .createOWLOntologyManager();
- OWLOntology owlOntology =
ontologyManager.createOntology(iri);
-
- System.out.println("Created ONTOLOGY OWL");
-
- scope = ontologyScopeFactory.createOntologyScope(
- reengineeringScopeIRI, new
RootOntologyIRISource(IRI
- .create(DBS_L1.URI))/*
-
* new
-
* OntologyInputSourceDBS_L1()
-
*/);
-
- // scope.setUp();
-
- scopeRegistry.registerScope(scope);
-
- } catch (DuplicateIDException e) {
- log.info("Semion DBExtractor : already existing scope
for IRI "
- + REENGINEERING_SCOPE);
- scope = scopeRegistry.getScope(reengineeringScopeIRI);
- } catch (OWLOntologyCreationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (Exception e) {
- log
- .error("Semion DBExtractor : No
OntologyInputSource for ONManager.");
- }
-
- if (scope != null) {
- scope.addSessionSpace(ontologySpaceFactory
-
.createSessionOntologySpace(reengineeringSpaceIRI),
- kReSSession.getID());
-
- scopeRegistry.setScopeActive(reengineeringScopeIRI,
true);
- }
-
- log.info("Activated KReS Semion RDB Reengineer");
- }
-
- @Override
- public boolean canPerformReengineering(DataSource dataSource) {
- if (dataSource.getDataSourceType() == getReengineerType()) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canPerformReengineering(int dataSourceType) {
- if (dataSourceType == getReengineerType()) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canPerformReengineering(OWLOntology schemaOntology) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean canPerformReengineering(String dataSourceType)
- throws UnsupportedReengineerException {
- return
canPerformReengineering(ReengineerType.getType(dataSourceType));
- }
-
- @Override
- public OWLOntology dataReengineering(String graphNS, IRI outputIRI,
- DataSource dataSource, OWLOntology schemaOntology)
- throws ReengineeringException {
-
- SemionDBDataTransformer semionDBDataTransformer = new
SemionDBDataTransformer(
- onManager, schemaOntology);
- return semionDBDataTransformer.transformData(graphNS,
outputIRI);
-
- }
-
- @Deactivate
- protected void deactivate(ComponentContext context) {
- log.info("in " + DBExtractor.class + " deactivate with context "
- + context);
- reengineeringManager.unbindReengineer(this);
- }
-
- @Override
- public int getReengineerType() {
- return ReengineerType.RDB;
- }
-
- private OntologyScope getScope() {
- OntologyScope ontologyScope = null;
-
- ScopeRegistry scopeRegistry = onManager.getScopeRegistry();
-
- if (scopeRegistry.isScopeActive(reengineeringScopeIRI)) {
- ontologyScope =
scopeRegistry.getScope(reengineeringScopeIRI);
- }
-
- return ontologyScope;
- }
-
- @Override
- public OWLOntology reengineering(String graphNS, IRI outputIRI,
- DataSource dataSource) throws ReengineeringException {
- IRI schemaIRI;
- if (outputIRI != null) {
- schemaIRI = IRI.create(outputIRI.toString() +
"/schema");
- } else {
- schemaIRI = IRI.create("/schema");
- }
- OWLOntology schemaOntology = schemaReengineering(graphNS +
"/schema",
- schemaIRI, dataSource);
-
- return dataReengineering(graphNS, outputIRI, dataSource,
schemaOntology);
- }
-
- @Override
- public OWLOntology schemaReengineering(String graphNS, IRI outputIRI,
- DataSource dataSource) {
- OWLOntology schemaOntology = null;
-
- if (outputIRI != null) {
- log
- .info("Semion DBExtractor : starting to
generate RDF graph with URI "
- + outputIRI.toString()
+ " of a db schema ");
- } else {
- log
- .info("Semion DBExtractor : starting to
generate RDF graph of a db schema ");
- }
-
- OntologyScope reengineeringScope = getScope();
- if (reengineeringScope != null) {
- ConnectionSettings connectionSettings =
(ConnectionSettings) dataSource
- .getDataSource();
- SemionDBSchemaGenerator schemaGenerator = new
SemionDBSchemaGenerator(
- outputIRI, connectionSettings);
-
- System.out.println("OWL MANAGER IN SEMION: " +
onManager);
- OWLOntologyManager ontologyManager =
onManager.getOwlCacheManager();
- OWLDataFactory dataFactory = onManager.getOwlFactory();
- schemaOntology =
schemaGenerator.getSchema(ontologyManager,
- dataFactory);
-
- if (outputIRI != null) {
- log.info("Created graph with URI " +
outputIRI.toString()
- + " of DB Schema.");
- } else {
- log.info("Created graph of DB Schema.");
- }
-
- }
- return schemaOntology;
- }
+ public static final String _DB_DATA_REENGINEERING_SESSION_DEFAULT =
"/db-data-reengineering-session";
+ public static final String _DB_DATA_REENGINEERING_SESSION_SPACE_DEFAULT =
"/db-data-reengineering-session-space";
+ public static final String _DB_REENGINEERING_SESSION_SPACE_DEFAULT =
"/db-schema-reengineering-session-space";
+ public static final String _DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE_DEFAULT
= "/db-schema-reengineering-ontology-space";
+ public static final String _DB_SCHEMA_REENGINEERING_SESSION_DEFAULT =
"/db-schema-reengineering-session";
+ public static final String _HOST_NAME_AND_PORT_DEFAULT = "localhost:8080";
+ public static final String _REENGINEERING_SCOPE_DEFAULT =
"db_reengineering";
+
+ @Property(value = _DB_DATA_REENGINEERING_SESSION_DEFAULT)
+ public static final String DB_DATA_REENGINEERING_SESSION =
"eu.iksproject.kres.semion.reengineer.db.data";
+
+ @Property(value = _DB_DATA_REENGINEERING_SESSION_SPACE_DEFAULT)
+ public static final String DB_DATA_REENGINEERING_SESSION_SPACE =
"eu.iksproject.kres.semion.reengineer.space.db.data";
+
+ @Property(value = _DB_REENGINEERING_SESSION_SPACE_DEFAULT)
+ public static final String DB_REENGINEERING_SESSION_SPACE =
"http://kres.iks-project.eu/space/reengineering/db";
+
+ @Property(value = _DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE_DEFAULT)
+ public static final String DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE =
"eu.iksproject.kres.semion.reengineer.ontology.space.db";
+
+ @Property(value = _DB_SCHEMA_REENGINEERING_SESSION_DEFAULT)
+ public static final String DB_SCHEMA_REENGINEERING_SESSION =
"eu.iksproject.kres.semion.reengineer.db.schema";
+
+ @Property(value = _HOST_NAME_AND_PORT_DEFAULT)
+ public static final String HOST_NAME_AND_PORT = "host.name.port";
+
+ @Property(value = _REENGINEERING_SCOPE_DEFAULT)
+ public static final String REENGINEERING_SCOPE = "db.reengineering.scope";
+
+ ConnectionSettings connectionSettings;
+
+ String databaseURI;
+
+ private IRI kReSSessionID;
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Reference
+ KReSONManager onManager;
+
+ @Reference
+ SemionManager reengineeringManager;
+
+ private IRI reengineeringScopeIRI;
+
+ private IRI reengineeringSpaceIRI;
+
+ MGraph schemaGraph;
+ protected OntologyScope scope;
+
+ @Reference
+ TcManager tcManager;
+
+ @Reference
+ WeightedTcProvider weightedTcProvider;
+
+ /**
+ * This default constructor is <b>only</b> intended to be used by the OSGI
environment with Service
+ * Component Runtime support.
+ * <p>
+ * DO NOT USE to manually create instances - the DBExtractor instances do
need to be configured! YOU NEED
+ * TO USE {@link #DBExtractor(KReSONManager)} or its overloads, to parse
the configuration and then
+ * initialise the rule store if running outside a OSGI environment.
+ */
+ public DBExtractor() {
+
+ }
+
+ /**
+ *
+ * Create a new {@link DBExtractor} that is formally a {@link
SemionReengineer}.
+ *
+ */
+ public DBExtractor(SemionManager reengineeringManager,
+ KReSONManager onManager,
+ TcManager tcManager,
+ WeightedTcProvider weightedTcProvider,
+ Dictionary<String,Object> configuration) {
+ this();
+ this.reengineeringManager = reengineeringManager;
+ this.onManager = onManager;
+ this.tcManager = tcManager;
+ this.weightedTcProvider = weightedTcProvider;
+ activate(configuration);
+ }
+
+ /**
+ * Create a new {@link DBExtractor} that is formally a {@link
SemionReengineer}.
+ *
+ * @param databaseURI
+ * {@link String}
+ * @param schemaGraph
+ * {@link MGraph}
+ * @param connectionSettings
+ * {@link ConnectionSettings}
+ */
+ public DBExtractor(SemionManager reengineeringManager,
+ KReSONManager onManager,
+ TcManager tcManager,
+ WeightedTcProvider weightedTcProvider,
+ Dictionary<String,Object> configuration,
+ String databaseURI,
+ MGraph schemaGraph,
+ ConnectionSettings connectionSettings) {
+ // Copy code from overloaded constructor, except that the call to
+ // activate() goes at the end.
+ this();
+ this.reengineeringManager = reengineeringManager;
+ this.onManager = onManager;
+ this.tcManager = tcManager;
+ this.weightedTcProvider = weightedTcProvider;
+ this.databaseURI = databaseURI;
+ this.schemaGraph = schemaGraph;
+ this.connectionSettings = connectionSettings;
+ activate(configuration);
+ }
+
+ /**
+ * Used to configure an instance within an OSGi container.
+ *
+ * @throws IOException
+ */
+ @SuppressWarnings("unchecked")
+ @Activate
+ protected void activate(ComponentContext context) throws IOException {
+ log.info("in " + DBExtractor.class + " activate with context " +
context);
+ if (context == null) {
+ throw new IllegalStateException("No valid" +
ComponentContext.class + " parsed in activate!");
+ }
+ activate((Dictionary<String,Object>) context.getProperties());
+ }
+
+ protected void activate(Dictionary<String,Object> configuration) {
+
+ String reengineeringScopeID = (String)
configuration.get(REENGINEERING_SCOPE);
+ if (reengineeringScopeID == null) reengineeringScopeID =
_REENGINEERING_SCOPE_DEFAULT;
+ String hostNameAndPort = (String)
configuration.get(HOST_NAME_AND_PORT);
+ if (hostNameAndPort == null) hostNameAndPort =
_HOST_NAME_AND_PORT_DEFAULT;
+ // TODO: Manage the other properties
+
+ hostNameAndPort = "http://" + hostNameAndPort;
+
+ reengineeringScopeIRI = IRI.create(hostNameAndPort + "/kres/ontology/"
+ reengineeringScopeID);
+ reengineeringSpaceIRI = IRI.create(DB_REENGINEERING_SESSION_SPACE);
+
+ reengineeringManager.bindReengineer(this);
+
+ KReSSessionManager kReSSessionManager = onManager.getSessionManager();
+ KReSSession kReSSession = kReSSessionManager.createSession();
+
+ kReSSessionID = kReSSession.getID();
+
+ OntologyScopeFactory ontologyScopeFactory =
onManager.getOntologyScopeFactory();
+
+ ScopeRegistry scopeRegistry = onManager.getScopeRegistry();
+
+ OntologySpaceFactory ontologySpaceFactory =
onManager.getOntologySpaceFactory();
+
+ scope = null;
+ try {
+ log.info("Semion DBExtractor : created scope with IRI " +
REENGINEERING_SCOPE);
+ IRI iri = IRI.create(DBS_L1.URI);
+ OWLOntologyManager ontologyManager =
OWLManager.createOWLOntologyManager();
+ OWLOntology owlOntology = ontologyManager.createOntology(iri);
+
+ System.out.println("Created ONTOLOGY OWL");
+
+ scope =
ontologyScopeFactory.createOntologyScope(reengineeringScopeIRI,
+ new RootOntologyIRISource(IRI.create(DBS_L1.URI)));
+
+ // scope.setUp();
+
+ scopeRegistry.registerScope(scope);
+
+ } catch (DuplicateIDException e) {
+ log.info("Semion DBExtractor : already existing scope for IRI " +
REENGINEERING_SCOPE);
+ scope = scopeRegistry.getScope(reengineeringScopeIRI);
+ } catch (OWLOntologyCreationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ log.error("Semion DBExtractor : No OntologyInputSource for
ONManager.");
+ }
+
+ if (scope != null) {
+
scope.addSessionSpace(ontologySpaceFactory.createSessionOntologySpace(reengineeringSpaceIRI),
+ kReSSession.getID());
+
+ scopeRegistry.setScopeActive(reengineeringScopeIRI, true);
+ }
+
+ log.info("Activated KReS Semion RDB Reengineer");
+ }
+
+ @Override
+ public boolean canPerformReengineering(DataSource dataSource) {
+ if (dataSource.getDataSourceType() == getReengineerType()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canPerformReengineering(int dataSourceType) {
+ if (dataSourceType == getReengineerType()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canPerformReengineering(OWLOntology schemaOntology) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean canPerformReengineering(String dataSourceType) throws
UnsupportedReengineerException {
+ return canPerformReengineering(ReengineerType.getType(dataSourceType));
+ }
+
+ @Override
+ public OWLOntology dataReengineering(String graphNS,
+ IRI outputIRI,
+ DataSource dataSource,
+ OWLOntology schemaOntology) throws
ReengineeringException {
+
+ SemionDBDataTransformer semionDBDataTransformer = new
SemionDBDataTransformer(onManager,
+ schemaOntology);
+ return semionDBDataTransformer.transformData(graphNS, outputIRI);
+
+ }
+
+ @Deactivate
+ protected void deactivate(ComponentContext context) {
+ log.info("in " + DBExtractor.class + " deactivate with context " +
context);
+ reengineeringManager.unbindReengineer(this);
+ }
+
+ @Override
+ public int getReengineerType() {
+ return ReengineerType.RDB;
+ }
+
+ private OntologyScope getScope() {
+ OntologyScope ontologyScope = null;
+
+ ScopeRegistry scopeRegistry = onManager.getScopeRegistry();
+
+ if (scopeRegistry.isScopeActive(reengineeringScopeIRI)) {
+ ontologyScope = scopeRegistry.getScope(reengineeringScopeIRI);
+ }
+
+ return ontologyScope;
+ }
+
+ @Override
+ public OWLOntology reengineering(String graphNS, IRI outputIRI, DataSource
dataSource) throws ReengineeringException {
+ IRI schemaIRI;
+ if (outputIRI != null) {
+ schemaIRI = IRI.create(outputIRI.toString() + "/schema");
+ } else {
+ schemaIRI = IRI.create("/schema");
+ }
+ OWLOntology schemaOntology = schemaReengineering(graphNS + "/schema",
schemaIRI, dataSource);
+
+ return dataReengineering(graphNS, outputIRI, dataSource,
schemaOntology);
+ }
+
+ @Override
+ public OWLOntology schemaReengineering(String graphNS, IRI outputIRI,
DataSource dataSource) {
+ OWLOntology schemaOntology = null;
+
+ if (outputIRI != null) {
+ log.info("Semion DBExtractor : starting to generate RDF graph with
URI " + outputIRI.toString()
+ + " of a db schema ");
+ } else {
+ log.info("Semion DBExtractor : starting to generate RDF graph of a
db schema ");
+ }
+
+ OntologyScope reengineeringScope = getScope();
+ if (reengineeringScope != null) {
+ ConnectionSettings connectionSettings = (ConnectionSettings)
dataSource.getDataSource();
+ SemionDBSchemaGenerator schemaGenerator = new
SemionDBSchemaGenerator(outputIRI,
+ connectionSettings);
+
+ System.out.println("OWL MANAGER IN SEMION: " + onManager);
+ OWLOntologyManager ontologyManager =
onManager.getOwlCacheManager();
+ OWLDataFactory dataFactory = onManager.getOwlFactory();
+ schemaOntology = schemaGenerator.getSchema(ontologyManager,
dataFactory);
+
+ if (outputIRI != null) {
+ log.info("Created graph with URI " + outputIRI.toString() + "
of DB Schema.");
+ } else {
+ log.info("Created graph of DB Schema.");
+ }
+
+ }
+ return schemaOntology;
+ }
}
Modified:
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/main/java/eu/iksproject/kres/semion/reengineer/xml/XMLExtractor.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/main/java/eu/iksproject/kres/semion/reengineer/xml/XMLExtractor.java?rev=1080189&r1=1080188&r2=1080189&view=diff
==============================================================================
---
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/main/java/eu/iksproject/kres/semion/reengineer/xml/XMLExtractor.java
(original)
+++
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/main/java/eu/iksproject/kres/semion/reengineer/xml/XMLExtractor.java
Thu Mar 10 11:29:06 2011
@@ -61,7 +61,6 @@ import eu.iksproject.kres.api.semion.Dat
import eu.iksproject.kres.api.semion.ReengineeringException;
import eu.iksproject.kres.api.semion.SemionManager;
import eu.iksproject.kres.api.semion.SemionReengineer;
-import eu.iksproject.kres.api.semion.util.OntologyInputSourceOXML;
import eu.iksproject.kres.api.semion.util.ReengineerType;
import eu.iksproject.kres.api.semion.util.SemionUriRefGenerator;
import eu.iksproject.kres.api.semion.util.UnsupportedReengineerException;