Hello Andrea

Many thanks for this - I'm re-writing this bit of code to use the API as you
have suggested, I'll let you know how it goes.

Out of interest - what is the intended usage of eg AddRule?  Or is that not
part of the API and therefore should be ignored...

Thanks
Steve

> -----Original Message-----
> From: Andrea Giovanni Nuzzolese [mailto:[email protected]] 
> Sent: 09 February 2012 10:01
> To: Stephen Bayliss; [email protected]
> Subject: Re: NPE on refactoring using Java API
> 
> 
> 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.ontologyRefactor
> > ing(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
> 
> 
> 

Reply via email to