I Stephen, do not directly use methods of the classes AddRule and AddRecipe. Instead, use methods of the RuleStore. You can create a recipe with the method addRecipe(IRI, String), where the first argument is the recipe ID and the second is a description of the recipe. Then you can add rules to the recipe created with the method addRuleToRecipe(String, String), where the first argument is the ID of the recipe to which you want to add the rule and the second argument is the rule itself.
I hope it helps. Best. Andrea On Feb 8, 2012, at 5:43 PM, Stephen Bayliss wrote: > Hi > > I'm getting an NPE when refactoring using the Java API: > > java.lang.NullPointerException > at > org.apache.stanbol.rules.refactor.impl.RefactorerImpl.ontologyRefactoring(Re > factorerImpl.java:284) > > This is something that used to work with an old svn revision, current rev is > 1236695. > > I'm creating a Recipe with some rules, following the code in the REST API as > an example. > > My Bundle is getting the rule store with > > @Reference > protected RuleStore m_ruleStore; > > I'm adding rules to the store with: > > AddRule adder = new AddRule(m_ruleStore); > adder.addRule(ruleIRI, rule, description); > > (which is returning true) > > I'm adding the recipe by creating a Vector<IRI> ruleIris and populating with > the rule IRIs, then > > AddRecipe recipeAdder = new AddRecipe(m_ruleStore); > recipeAdder.addRecipe(recipeIri, ruleIris, "my rule"); > > (returns true) > > and > m_ruleStore.saveOntology(). > > I can query for the recipe and list the rules fine using a > GetRecipe#getAllRecipes(); > > However, on refactoring with a Refactorer, got in my bundle using: > > @Reference > Refactorer m_refactorer; > > Then > > m_refactorer.ontologyRefactoring(outputIri, inputIri, recipeIri) > > But this is throwing the NPE above. > > (I notice it is using > RuleStore#getRecipe and then Recipe#getkReSRuleList > And if I try to get the recipes using > m_ruleStore.listRecipes(); > this returns Null, which is odd...) > > So how do I get this working? There seem to be "two APIs" in a sense, the > AddRule/GetRule etc stuff and the methods directly on the RuleStore. > > Thanks > Steve
