use of org.apache.stanbol.rules.base.api.Recipe in project stanbol by apache.
the class RuleStoreTest method getNotExistingRuleByNameInRecipeTest.
private void getNotExistingRuleByNameInRecipeTest() throws Exception {
Recipe recipe = store.getRecipe(new IRI("http://incubator.apache.com/stanbol/rules/test/recipeA"));
try {
recipe.getRule("ruleX");
Assert.fail();
} catch (NoSuchRuleInRecipeException e) {
Assert.assertTrue(true);
}
}
use of org.apache.stanbol.rules.base.api.Recipe in project stanbol by apache.
the class RefactoringTest method refactoringTest.
@Test
public void refactoringTest() throws Exception {
Recipe recipe = store.getRecipe(new IRI("http://incubator.apache.com/stanbol/rules/refactor/test/recipeA"));
Graph tc = refactorer.graphRefactoring(new IRI("http://incubator.apache.com/stanbol/rules/refactor/test/graph"), recipe.getRecipeID());
Assert.assertNotNull(tc);
}
use of org.apache.stanbol.rules.base.api.Recipe in project stanbol by apache.
the class RefactoringTest method setUp.
@Before
public void setUp() {
String separator = System.getProperty("line.separator");
rule = "kres = <http://kres.iks-project.eu/ontology.owl#> . " + separator + "foaf = <http://xmlns.com/foaf/0.1/> . " + separator + "rule1[ is(kres:Person, ?x) . endsWith(str(?x), \"Person\") -> is(foaf:Person, ?x) ]";
InputStream inputStream = RefactoringTest.class.getResourceAsStream("/META-INF/test/testKReSOnt.owl");
Model jenaModel = ModelFactory.createDefaultModel();
jenaModel = jenaModel.read(inputStream, null);
tripleCollection = JenaToClerezzaConverter.jenaModelToClerezzaGraph(jenaModel);
Graph mGraph = tcm.createGraph(new IRI("http://incubator.apache.com/stanbol/rules/refactor/test/graph"));
mGraph.addAll(tripleCollection);
Recipe recipe;
try {
recipe = store.createRecipe(new IRI("http://incubator.apache.com/stanbol/rules/refactor/test/recipeA"), "Recipe for testing the Refactor.");
recipe = store.addRulesToRecipe(recipe, rule, "Test");
} catch (AlreadyExistingRecipeException e) {
Assert.fail(e.getMessage());
}
}
use of org.apache.stanbol.rules.base.api.Recipe in project stanbol by apache.
the class RuleStoreTest method addRuleToRecipeTest.
private void addRuleToRecipeTest() throws Exception {
Recipe recipe = store.getRecipe(new IRI("http://incubator.apache.com/stanbol/rules/test/recipeA"));
String separator = System.getProperty("line.separator");
String rule = "rule1[" + separator + " is(<http://dbpedia.org/ontology/Person>, ?x) . " + separator + " has(<http://dbpedia.org/ontology/playsInTeam>, ?x, ?y) . " + separator + " is (<http://dbpedia.org/ontology/FootballTeam>, ?y) " + separator + " -> " + separator + " is(<http://dbpedia.org/ontology/FootballPlayer>, ?x)" + separator + "] . " + "rule2[" + separator + " is(<http://dbpedia.org/ontology/Organisation>, ?x) . " + separator + " has(<http://dbpedia.org/ontology/hasProduct>, ?x, ?y)" + separator + " -> " + separator + " is(<http://dbpedia.org/ontology/Company>, ?x)" + separator + "]";
store.addRulesToRecipe(recipe, rule, "This is a test rule.");
if (recipe == null) {
Assert.fail();
}
log.debug("Got recipe with ID " + recipe.getRecipeID().toString());
}
use of org.apache.stanbol.rules.base.api.Recipe in project stanbol by apache.
the class RefactorerImpl method graphRefactoring.
@SuppressWarnings("unchecked")
@Override
public void graphRefactoring(IRI refactoredOntologyID, IRI datasetID, IRI recipeID) throws RefactoringException, NoSuchRecipeException {
Recipe recipe;
try {
try {
recipe = ruleStore.getRecipe(recipeID);
RuleAdapter ruleAdapter = ruleAdapterManager.getAdapter(recipe, ConstructQuery.class);
List<ConstructQuery> constructQueries = (List<ConstructQuery>) ruleAdapter.adaptTo(recipe, ConstructQuery.class);
Graph mGraph = tcManager.createGraph(refactoredOntologyID);
for (ConstructQuery constructQuery : constructQueries) {
mGraph.addAll(this.sparqlConstruct(constructQuery, datasetID));
}
} catch (RecipeConstructionException e) {
throw new RefactoringException("The cause of the refactoring excpetion is: " + e.getMessage(), e);
} catch (UnavailableRuleObjectException e) {
throw new RefactoringException("The cause of the refactoring excpetion is: " + e.getMessage(), e);
} catch (UnsupportedTypeForExportException e) {
throw new RefactoringException("The cause of the refactoring excpetion is: " + e.getMessage(), e);
} catch (RuleAtomCallExeption e) {
throw new RefactoringException("The cause of the refactoring excpetion is: " + e.getMessage(), e);
}
} catch (NoSuchRecipeException e1) {
log.error("No Such recipe in the Rule Store", e1);
throw e1;
}
}
Aggregations