use of org.apache.stanbol.rules.base.api.Rule in project stanbol by apache.
the class RuleParserTest method testParser.
@Test
public void testParser() {
try {
KB kReSKB = RuleParserImpl.parse("http://incubator.apache.org/stanbol/rules/test/", kReSRule);
if (kReSKB != null) {
RuleList kReSRuleList = kReSKB.getRuleList();
if (kReSRuleList != null) {
for (Rule kReSRule : kReSRuleList) {
log.debug("RULE : " + kReSRule.toString());
}
}
log.debug("RULE LIST IS NULL");
} else {
log.debug("KB IS NULL");
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.apache.stanbol.rules.base.api.Rule in project stanbol by apache.
the class RuleParserImpl method prefix.
public final void prefix() throws ParseException {
String nsPrefix;
Object obj;
Rule rule;
nsPrefix = getVariable();
switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case EQUAL:
obj = equality();
String prefixURI = (String) obj;
prefixURI = prefixURI.substring(1, prefixURI.length() - 1);
kb.addPrefix(nsPrefix, prefixURI);
break;
case LQUAD:
obj = rule();
AtomList[] atoms = (AtomList[]) obj;
String ruleStorePrefix = kb.getPrefixURI("rmi2");
ruleStorePrefix = ruleStorePrefix.substring(0, ruleStorePrefix.length());
if (atoms.length == 1) {
AtomList body = atoms[0];
if (body.size() == 1) {
// FIXME it previously managed SPARQL code injection.
}
} else {
rule = new RuleImpl(new IRI(ruleStorePrefix + nsPrefix), nsPrefix, atoms[0], atoms[1]);
kb.addRule(rule);
}
break;
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
use of org.apache.stanbol.rules.base.api.Rule in project stanbol by apache.
the class RuleStoreTest method getExistingRuleByIdInRecipeTest.
private void getExistingRuleByIdInRecipeTest() throws Exception {
Recipe recipe = store.getRecipe(new IRI("http://incubator.apache.com/stanbol/rules/test/recipeA"));
try {
Rule rule = recipe.getRule(recipe.listRuleIDs().get(0));
Assert.assertNotNull(rule);
} catch (NoSuchRuleInRecipeException e) {
Assert.fail();
}
}
use of org.apache.stanbol.rules.base.api.Rule in project stanbol by apache.
the class RuleStoreTest method getExistingRuleByNameInRecipeTest.
private void getExistingRuleByNameInRecipeTest() throws Exception {
Recipe recipe = store.getRecipe(new IRI("http://incubator.apache.com/stanbol/rules/test/recipeA"));
try {
Rule rule = recipe.getRule(recipe.listRuleNames().get(0));
Assert.assertNotNull(rule);
} catch (NoSuchRuleInRecipeException e) {
Assert.fail();
}
}
use of org.apache.stanbol.rules.base.api.Rule in project stanbol by apache.
the class RuleList method remove.
public boolean remove(Object o) {
boolean removed = false;
for (int i = 0; i < rules.length && !removed; i++) {
Rule semionRule = rules[i];
if (semionRule.equals(o)) {
Rule[] semionRulesCopy = new Rule[rules.length - 1];
System.arraycopy(rules, 0, semionRulesCopy, 0, i);
System.arraycopy(rules, i + 1, semionRulesCopy, 0, semionRulesCopy.length - i);
rules = semionRulesCopy;
removed = true;
}
}
return removed;
}
Aggregations