use of org.apache.stanbol.rules.base.api.Recipe in project stanbol by apache.
the class ClerezzaRuleStore method listRecipes.
@Override
public RecipeList listRecipes() throws NoSuchRecipeException, RecipeConstructionException {
RecipeList recipeList = new RecipeList();
for (IRI recipeID : recipes) {
Recipe recipe;
try {
recipe = getRecipe(recipeID);
} catch (NoSuchRecipeException e) {
throw e;
} catch (RecipeConstructionException e) {
throw e;
}
recipeList.add(recipe);
}
log.info("The Clerezza rule store contains {} recipes", recipeList.size());
return recipeList;
}
use of org.apache.stanbol.rules.base.api.Recipe in project stanbol by apache.
the class RecipeList method removeAll.
public boolean removeAll(Collection<?> c) {
if (contains(c)) {
for (Object o : c) {
boolean removed = false;
for (int i = 0; i < recipes.length && !removed; i++) {
Recipe recipe = recipes[i];
if (recipe.equals(o)) {
Recipe[] recipesCopy = new Recipe[recipes.length - 1];
System.arraycopy(recipes, 0, recipesCopy, 0, i);
System.arraycopy(recipes, i + 1, recipesCopy, 0, recipesCopy.length - i);
recipes = recipesCopy;
removed = true;
}
}
}
return true;
} else {
return false;
}
}
use of org.apache.stanbol.rules.base.api.Recipe in project stanbol by apache.
the class RuleStoreTest method getRecipeTest.
private void getRecipeTest() throws Exception {
Recipe recipe = store.getRecipe(new IRI("http://incubator.apache.com/stanbol/rules/test/recipeA"));
if (recipe == null) {
Assert.fail();
} else {
System.out.println("Recipe: " + recipe.toString());
}
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 RuleStoreTest method removeRuleInRecipeTest.
private void removeRuleInRecipeTest() throws Exception {
Recipe recipe = store.getRecipe(new IRI("http://incubator.apache.com/stanbol/rules/test/recipeA"));
String tmp = recipe.toString();
Rule rule = recipe.getRule(recipe.listRuleNames().get(0));
store.removeRule(recipe, rule);
Recipe recipe2 = store.getRecipe(new IRI("http://incubator.apache.com/stanbol/rules/test/recipeA"));
String tmp2 = recipe2.toString();
Assert.assertNotSame(tmp, tmp2);
}
use of org.apache.stanbol.rules.base.api.Recipe in project stanbol by apache.
the class RuleStoreTest method createRecipeTest.
private void createRecipeTest() throws Exception {
Recipe recipe = store.createRecipe(new IRI("http://incubator.apache.com/stanbol/rules/test/recipeA"), "The text recipe named A.");
if (recipe == null) {
Assert.fail();
}
log.debug("Created recipe with ID " + recipe.getRecipeID().toString());
}
Aggregations