You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by al...@apache.org on 2011/07/27 13:17:33 UTC
svn commit: r1151428 - in /incubator/stanbol/trunk/rules:
manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java
refactor/src/main/java/org/apache/stanbol/rules/refactor/impl/RefactorerImpl.java
Author: alexdma
Date: Wed Jul 27 11:17:32 2011
New Revision: 1151428
URL: http://svn.apache.org/viewvc?rev=1151428&view=rev
Log:
STANBOL-302 : RuleStoreImpl constructor now passes non-null values in recursive constructor calls
Modified:
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java
incubator/stanbol/trunk/rules/refactor/src/main/java/org/apache/stanbol/rules/refactor/impl/RefactorerImpl.java
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=1151428&r1=1151427&r2=1151428&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 Wed Jul 27 11:17:32 2011
@@ -1,19 +1,19 @@
/*
-* 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.
-*/
+ * 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.
+ */
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
@@ -121,10 +121,6 @@ public class RuleStoreImpl implements Ru
return configuration;
}
- private String alias;
-
- private RuleParserImpl kReSRuleParser;
-
private final Logger log = LoggerFactory.getLogger(getClass());
@Reference
@@ -157,7 +153,7 @@ public class RuleStoreImpl implements Ru
*/
public RuleStoreImpl(ONManager onm, Dictionary<String,Object> configuration) {
// This recursive constructor call will also invoke activate()
- this(null, null, (OWLOntology) null);
+ this(onm, configuration, (OWLOntology) null);
}
/**
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=1151428&r1=1151427&r2=1151428&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 Wed Jul 27 11:17:32 2011
@@ -1,19 +1,19 @@
/*
-* 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.
-*/
+ * 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.
+ */
package org.apache.stanbol.rules.refactor.impl;
import java.io.ByteArrayInputStream;
@@ -80,7 +80,26 @@ import com.hp.hpl.jena.reasoner.Reasoner
import com.hp.hpl.jena.sparql.function.FunctionRegistry;
import com.hp.hpl.jena.sparql.pfunction.PropertyFunctionRegistry;
import com.hp.hpl.jena.update.UpdateAction;
-import com.hp.hpl.jena.util.FileManager;
+
+class ForwardChainingRefactoringGraph {
+
+ private MGraph inputGraph;
+ private Graph outputGraph;
+
+ public ForwardChainingRefactoringGraph(MGraph inputGraph, Graph outputGraph) {
+ this.inputGraph = inputGraph;
+ this.outputGraph = outputGraph;
+ }
+
+ public MGraph getInputGraph() {
+ return inputGraph;
+ }
+
+ public Graph getOutputGraph() {
+ return outputGraph;
+ }
+
+}
/**
* The RefactorerImpl is the concrete implementation of the Refactorer interface defined in the KReS APIs. A
@@ -121,21 +140,24 @@ public class RefactorerImpl implements R
private final Logger log = LoggerFactory.getLogger(getClass());
+ @Reference
+ protected ONManager onManager;
+
private IRI refactoringScopeIRI;
private IRI refactoringSpaceIRI;
- private OntologyScope scope;
-
- @Reference
- protected ONManager onManager;
@Reference
protected RuleStore ruleStore;
+ private OntologyScope scope;
+
@Reference
protected Serializer serializer;
+
@Reference
protected TcManager tcManager;
+
@Reference
protected WeightedTcProvider weightedTcProvider;
@@ -249,7 +271,7 @@ public class RefactorerImpl implements R
scope.addSessionSpace(ontologySpaceFactory.createSessionOntologySpace(refactoringSpaceIRI),
kReSSession.getID());
} catch (UnmodifiableOntologySpaceException e) {
-log.error("Failed to create session space",e);
+ log.error("Failed to create session space", e);
}
scopeRegistry.setScopeActive(refactoringScopeIRI, true);
@@ -280,12 +302,44 @@ log.error("Failed to create session spac
this.ruleStore = null;
}
+ private ForwardChainingRefactoringGraph forwardChainingOperation(String query, MGraph mGraph) {
+
+ Graph graph = kReSCoreOperation(query, mGraph);
+
+ mGraph.addAll(graph);
+
+ return new ForwardChainingRefactoringGraph(mGraph, graph);
+ }
+
@Override
public MGraph getRefactoredDataSet(UriRef uriRef) {
return weightedTcProvider.getMGraph(uriRef);
}
+ private Graph kReSCoreOperation(String query, MGraph mGraph) {
+
+ /*
+ *
+ * Graph constructedGraph = null; try { ConstructQuery constructQuery = (ConstructQuery)
+ * QueryParser.getInstance() .parse(query); constructedGraph = tcManager.executeSparqlQuery(
+ * constructQuery, mGraph);
+ *
+ * } catch (ParseException e) { log.error(e.getMessage()); } catch (NoQueryEngineException e) {
+ * log.error(e.getMessage()); }
+ *
+ * return constructedGraph;
+ */
+
+ Model model = JenaToClerezzaConverter.clerezzaMGraphToJenaModel(mGraph);
+
+ Query sparqlQuery = QueryFactory.create(query, Syntax.syntaxARQ);
+ QueryExecution qexec = QueryExecutionFactory.create(sparqlQuery, model);
+
+ return JenaToClerezzaConverter.jenaModelToClerezzaMGraph(qexec.execConstruct()).getGraph();
+
+ }
+
@Override
public void ontologyRefactoring(IRI refactoredOntologyIRI, IRI datasetURI, IRI recipeIRI) throws RefactoringException,
NoSuchRecipeException {
@@ -368,7 +422,6 @@ log.error("Failed to create session spac
// OntModel ontModel =
// jenaToOwlConvert.ModelOwlToJenaConvert(inputOntology, "RDF/XML");
-
Recipe recipe;
try {
recipe = ruleStore.getRecipe(recipeIRI);
@@ -432,7 +485,6 @@ log.error("Failed to create session spac
return refactoredOntology;
}
}
-
@Override
public OWLOntology ontologyRefactoring(OWLOntology inputOntology, Recipe recipe) throws RefactoringException {
@@ -443,14 +495,13 @@ log.error("Failed to create session spac
// OntModel ontModel =
// jenaToOwlConvert.ModelOwlToJenaConvert(inputOntology, "RDF/XML");
-// OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
+ // OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
-
RuleList ruleList = recipe.getkReSRuleList();
log.info("RULE LIST SIZE : " + ruleList.size());
-// OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
-// OWLOntologyManager ontologyManager2 = OWLManager.createOWLOntologyManager();
+ // OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
+ // OWLOntologyManager ontologyManager2 = OWLManager.createOWLOntologyManager();
MGraph unionMGraph = new SimpleMGraph();
@@ -496,47 +547,12 @@ log.error("Failed to create session spac
refactoredOntology = OWLAPIToClerezzaConverter.clerezzaMGraphToOWLOntology(unionMGraph);
-
if (refactoredOntology == null) {
throw new RefactoringException();
} else {
return refactoredOntology;
}
}
-
-
-
- private Graph kReSCoreOperation(String query, MGraph mGraph) {
-
- /*
- *
- * Graph constructedGraph = null; try { ConstructQuery constructQuery = (ConstructQuery)
- * QueryParser.getInstance() .parse(query); constructedGraph = tcManager.executeSparqlQuery(
- * constructQuery, mGraph);
- *
- * } catch (ParseException e) { log.error(e.getMessage()); } catch (NoQueryEngineException e) {
- * log.error(e.getMessage()); }
- *
- * return constructedGraph;
- */
-
- Model model = JenaToClerezzaConverter.clerezzaMGraphToJenaModel(mGraph);
-
- Query sparqlQuery = QueryFactory.create(query, Syntax.syntaxARQ);
- QueryExecution qexec = QueryExecutionFactory.create(sparqlQuery, model);
-
- return JenaToClerezzaConverter.jenaModelToClerezzaMGraph(qexec.execConstruct()).getGraph();
-
- }
-
- private ForwardChainingRefactoringGraph forwardChainingOperation(String query, MGraph mGraph) {
-
- Graph graph = kReSCoreOperation(query, mGraph);
-
- mGraph.addAll(graph);
-
- return new ForwardChainingRefactoringGraph(mGraph, graph);
- }
private Graph sparqlUpdateOperation(String query, MGraph mGraph) {
Model model = JenaToClerezzaConverter.clerezzaMGraphToJenaModel(mGraph);
@@ -545,23 +561,3 @@ log.error("Failed to create session spac
}
}
-
-class ForwardChainingRefactoringGraph {
-
- private MGraph inputGraph;
- private Graph outputGraph;
-
- public ForwardChainingRefactoringGraph(MGraph inputGraph, Graph outputGraph) {
- this.inputGraph = inputGraph;
- this.outputGraph = outputGraph;
- }
-
- public MGraph getInputGraph() {
- return inputGraph;
- }
-
- public Graph getOutputGraph() {
- return outputGraph;
- }
-
-}