incubator-stanbol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alex...@apache.org
Subject svn commit: r1197271 [3/3] - in /incubator/stanbol/trunk: ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ ontologymanag...
Date Thu, 03 Nov 2011 19:03:13 GMT
Modified: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java?rev=1197271&r1=1197270&r2=1197271&view=diff
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java
(original)
+++ incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java
Thu Nov  3 19:03:11 2011
@@ -243,7 +243,7 @@ public class XMLExtractor extends Reengi
     @Override
     public boolean canPerformReengineering(OWLOntology schemaOntology) {
 
-        OWLDataFactory factory = onManager.getOwlFactory();
+        OWLDataFactory factory = OWLManager.getOWLDataFactory();
 
         OWLClass dataSourceClass = factory.getOWLClass(Reengineer_OWL.DataSource);
         Set<OWLIndividual> individuals = dataSourceClass.getIndividuals(schemaOntology);
@@ -370,7 +370,7 @@ public class XMLExtractor extends Reengi
 
         log.info("Starting XML Reengineering");
         OWLOntologyManager ontologyManager = onManager.getOwlCacheManager();
-        OWLDataFactory factory = onManager.getOwlFactory();
+        OWLDataFactory factory = OWLManager.getOWLDataFactory();
 
         IRI schemaOntologyIRI = schemaOntology.getOntologyID().getOntologyIRI();
 
@@ -463,7 +463,7 @@ public class XMLExtractor extends Reengi
                                           OWLOntology schemaOntology) throws ReengineeringException
{
 
         OWLOntologyManager ontologyManager = onManager.getOwlCacheManager();
-        OWLDataFactory factory = onManager.getOwlFactory();
+        OWLDataFactory factory = OWLManager.getOWLDataFactory();
 
         IRI schemaOntologyIRI = schemaOntology.getOntologyID().getOntologyIRI();
 

Modified: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XSDExtractor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XSDExtractor.java?rev=1197271&r1=1197270&r2=1197271&view=diff
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XSDExtractor.java
(original)
+++ incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XSDExtractor.java
Thu Nov  3 19:03:11 2011
@@ -53,6 +53,7 @@ import org.apache.xerces.xs.XSParticle;
 import org.apache.xerces.xs.XSTerm;
 import org.apache.xerces.xs.XSTypeDefinition;
 import org.apache.xerces.xs.datatypes.ObjectList;
+import org.semanticweb.owlapi.apibinding.OWLManager;
 import org.semanticweb.owlapi.model.AddAxiom;
 import org.semanticweb.owlapi.model.IRI;
 import org.semanticweb.owlapi.model.OWLAxiom;
@@ -553,7 +554,7 @@ public class XSDExtractor extends Reengi
         XSSimpleTypeDecl m;
 
         OWLOntologyManager ontologyManager = onManager.getOwlCacheManager();
-        OWLDataFactory factory = onManager.getOwlFactory();
+        OWLDataFactory factory = OWLManager.getOWLDataFactory();
 
         log.debug("XSD output IRI : " + outputIRI);
 

Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java?rev=1197271&r1=1197270&r2=1197271&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java
(original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java
Thu Nov  3 19:03:11 2011
@@ -515,7 +515,7 @@ public class RuleStoreImpl implements Ru
         Recipe recipe = null;
 
         if (onManager != null && recipeIRI != null) {
-            OWLDataFactory factory = onManager.getOwlFactory();
+            OWLDataFactory factory = OWLManager.getOWLDataFactory();
             OWLIndividual recipeIndividual = factory.getOWLNamedIndividual(recipeIRI);
             if (recipeIndividual != null) {
                 // String ruleNS =
@@ -609,7 +609,7 @@ public class RuleStoreImpl implements Ru
         Set<IRI> recipeIRIs = null;
         String ruleNS = owlmodel.getOntologyID().toString().replace("<", "").replace(">",
"") + "#";
 
-        OWLDataFactory factory = onManager.getOwlFactory();
+        OWLDataFactory factory = OWLManager.getOWLDataFactory();
         OWLClass recipeOWLClass = factory.getOWLClass(IRI.create(ruleNS + "Recipe"));
         Set<OWLIndividual> recipeIndividuals = recipeOWLClass.getIndividuals(owlmodel);
 

Modified: incubator/stanbol/trunk/rules/refactor/src/main/java/org/apache/stanbol/rules/refactor/impl/RefactorerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/refactor/src/main/java/org/apache/stanbol/rules/refactor/impl/RefactorerImpl.java?rev=1197271&r1=1197270&r2=1197271&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/refactor/src/main/java/org/apache/stanbol/rules/refactor/impl/RefactorerImpl.java
(original)
+++ incubator/stanbol/trunk/rules/refactor/src/main/java/org/apache/stanbol/rules/refactor/impl/RefactorerImpl.java
Thu Nov  3 19:03:11 2011
@@ -25,10 +25,14 @@ import org.apache.clerezza.rdf.core.Grap
 import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.EntityAlreadyExistsException;
 import org.apache.clerezza.rdf.core.access.TcManager;
 import org.apache.clerezza.rdf.core.access.WeightedTcProvider;
+import org.apache.clerezza.rdf.core.impl.SimpleGraph;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 import org.apache.clerezza.rdf.core.serializedform.Serializer;
+import org.apache.clerezza.rdf.core.sparql.ParseException;
+import org.apache.clerezza.rdf.core.sparql.QueryParser;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -45,9 +49,10 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.session.DuplicateSessionIDException;
 import org.apache.stanbol.ontologymanager.ontonet.api.session.Session;
 import org.apache.stanbol.ontologymanager.ontonet.api.session.SessionManager;
-import org.apache.stanbol.ontologymanager.ontonet.impl.io.ClerezzaOntologyStorage;
 import org.apache.stanbol.owl.transformation.JenaToClerezzaConverter;
+import org.apache.stanbol.owl.transformation.JenaToOwlConvert;
 import org.apache.stanbol.owl.transformation.OWLAPIToClerezzaConverter;
+import org.apache.stanbol.owl.util.OWLUtils;
 import org.apache.stanbol.rules.base.api.NoSuchRecipeException;
 import org.apache.stanbol.rules.base.api.Recipe;
 import org.apache.stanbol.rules.base.api.Rule;
@@ -339,13 +344,39 @@ public class RefactorerImpl implements R
 
     }
 
+    /**
+     * Method borrowed from the old ontonet ClerezzaStorage
+     * 
+     * @param sparql
+     * @param datasetURI
+     * @return
+     */
+    private OWLOntology sparqlConstruct(String sparql, String datasetURI) {
+
+        org.apache.clerezza.rdf.core.sparql.query.Query query;
+        MGraph mGraph = new SimpleMGraph();
+        try {
+            query = QueryParser.getInstance().parse(sparql);
+            UriRef datasetUriRef = new UriRef(datasetURI);
+            MGraph dataset = weightedTcProvider.getMGraph(datasetUriRef);
+            mGraph.addAll((SimpleGraph) tcManager.executeSparqlQuery(query, dataset));
+        } catch (ParseException e) {
+            log.error("Unable to execute SPARQL. ", e);
+        }
+
+        Model om = JenaToClerezzaConverter.clerezzaMGraphToJenaModel(mGraph);
+        JenaToOwlConvert converter = new JenaToOwlConvert();
+
+        return converter.ModelJenaToOwlConvert(om, "RDF/XML");
+    }
+
     @Override
     public void ontologyRefactoring(IRI refactoredOntologyIRI, IRI datasetURI, IRI recipeIRI)
throws RefactoringException,
                                                                                         
    NoSuchRecipeException {
 
         OWLOntology refactoredOntology = null;
 
-        ClerezzaOntologyStorage ontologyStorage = onManager.getOntologyStore();
+        // ClerezzaOntologyStorage ontologyStorage = onManager.getOntologyStore();
 
         Recipe recipe;
         try {
@@ -358,8 +389,8 @@ public class RefactorerImpl implements R
             String fingerPrint = "";
             for (Rule kReSRule : kReSRuleList) {
                 String sparql = kReSRule.toSPARQL();
-                OWLOntology refactoredDataSet = ontologyStorage
-                        .sparqlConstruct(sparql, datasetURI.toString());
+                OWLOntology refactoredDataSet = /* ontologyStorage */this.sparqlConstruct(sparql,
+                    datasetURI.toString());
 
                 ByteArrayOutputStream out = new ByteArrayOutputStream();
                 try {
@@ -394,7 +425,7 @@ public class RefactorerImpl implements R
 
                 refactoredOntology = merger.createMergedOntology(ontologyManager, refactoredOntologyIRI);
 
-                ontologyStorage.store(refactoredOntology);
+                /* ontologyStorage. */store(refactoredOntology);
 
             } catch (OWLOntologyCreationException e) {
                 // TODO Auto-generated catch block
@@ -411,6 +442,30 @@ public class RefactorerImpl implements R
         }
     }
 
+    /**
+     * Method borrowed from the old ontonet ClerezzaStorage
+     * 
+     * @param o
+     */
+    private void store(OWLOntology o) {
+        // // Why was it using two converters earlier?
+        // JenaToOwlConvert converter = new JenaToOwlConvert();
+        // OntModel om = converter.ModelOwlToJenaConvert(o, "RDF/XML");
+        // MGraph mg = JenaToClerezzaConverter.jenaModelToClerezzaMGraph(om);
+        TripleCollection mg = OWLAPIToClerezzaConverter.owlOntologyToClerezzaMGraph(o);
+        MGraph mg2 = null;
+        IRI iri = OWLUtils.guessOntologyIdentifier(o);
+        UriRef ref = new UriRef(iri.toString());
+        try {
+            mg2 = tcManager.createMGraph(ref);
+        } catch (EntityAlreadyExistsException ex) {
+            log.info("Entity " + ref + " already exists in store. Replacing...");
+            mg2 = tcManager.getMGraph(ref);
+        }
+
+        mg2.addAll(mg);
+    }
+
     @Override
     public OWLOntology ontologyRefactoring(OWLOntology inputOntology, IRI recipeIRI) throws
RefactoringException,
                                                                                     NoSuchRecipeException
{



Mime
View raw message