/*
* We ask to the adapter manager to get the right adapter in order to transform
* recipes into SWRLRule objects.
*/
RuleAdapter adapter;
try {
adapter = adapterManager.getAdapter(recipe, SWRLRule.class);
rules = (List<SWRLRule>) adapter.adaptTo(recipe, SWRLRule.class);
} catch (UnavailableRuleObjectException e) {
log.error(e.getMessage(), e);
} catch (RuleAtomCallExeption e) {
log.error(e.getMessage(), e);
} catch (UnsupportedTypeForExportException e) {
log.error(e.getMessage(), e);
}
/*
RuleList ruleList = recipe.getRuleList();
log.debug("RuleList is: {}",ruleList);
for(org.apache.stanbol.rules.base.api.Rule r : ruleList ){
SWRLRule swrl = r.toSWRL(OWLManager.getOWLDataFactory());
log.debug("Prepared rule: {}",swrl);
rules.add(swrl);
}*/
} catch (NoSuchRecipeException e) {
log.error("Recipe {} does not exists", recipeId);
throw new IOException(e);
}
long end = System.currentTimeMillis();
log.info("[end] Prepared {} rules for OWLApi in {} ms.", rules.size(), (end - start));
}
if(rules == null){
log.error("No rules have been loaded");
throw new IOException("No rules loaded");
}
final Iterator<SWRLRule> iterator = Collections.unmodifiableList(rules).iterator();
return new Iterator<T>(){
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@SuppressWarnings("unchecked")
@Override
public T next() {
return (T) iterator.next();
}
@Override
public void remove() {
log.error("Cannot remove items from this iterator. This may be cused by an error in the program");
throw new UnsupportedOperationException("Cannot remove items from this iterator");
}
};
case Jena:
List<Rule> jenaRules = null;
if (recipeId != null) {
long start = System.currentTimeMillis();
log.info("[start] Prepare rules for Jena ");
try {
Recipe recipe = null;
synchronized (store) {
try {
recipe = store.getRecipe(new UriRef(recipeId));
} catch (RecipeConstructionException e) {
log.error("An error occurred while generating the recipe.", e);
}
}
if(recipe != null){
log.debug("Recipe is: {}", recipe);
/*
* We ask to the adapter manager to get the right adapter in order to transform
* recipes into Jena Rule objects.
*/
RuleAdapter adapter;
try {
adapter = adapterManager.getAdapter(recipe, Rule.class);
jenaRules = (List<Rule>) adapter.adaptTo(recipe, Rule.class);
} catch (UnavailableRuleObjectException e) {
log.error(e.getMessage(), e);
} catch (RuleAtomCallExeption e) {
log.error(e.getMessage(), e);
} catch (UnsupportedTypeForExportException e) {