use of org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException in project stanbol by apache.
the class SubstringAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
org.apache.stanbol.rules.manager.atoms.SubstringAtom tmp = (org.apache.stanbol.rules.manager.atoms.SubstringAtom) ruleAtom;
StringFunctionAtom stringFunctionAtom = tmp.getStringFunctionAtom();
NumericFunctionAtom startAtom = tmp.getStart();
NumericFunctionAtom lengthAtom = tmp.getLength();
try {
SPARQLObject stringSparqlAtom = adapter.adaptTo(stringFunctionAtom, SPARQLObject.class);
SPARQLObject startSparqlAtom = adapter.adaptTo(startAtom, SPARQLObject.class);
SPARQLObject lengthSparqlAtom = adapter.adaptTo(lengthAtom, SPARQLObject.class);
String uriResourceString = stringSparqlAtom.getObject();
String start = startSparqlAtom.getObject();
String length = lengthSparqlAtom.getObject();
String sparql = "<http://www.w3.org/2005/xpath-functions#substring> (" + uriResourceString + ", " + start + ", " + length + ")";
return (T) new SPARQLFunction(sparql);
} catch (UnsupportedTypeForExportException e) {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
} catch (UnavailableRuleObjectException e) {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
}
use of org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException in project stanbol by apache.
the class UpperCaseAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
StringFunctionAtom argument = ((org.apache.stanbol.rules.manager.atoms.UpperCaseAtom) ruleAtom).getStringFunctionAtom();
try {
SPARQLObject sparqlArgument = adapter.adaptTo(argument, SPARQLObject.class);
String sparql = "<http://www.w3.org/2005/xpath-functions#upper-case> (" + sparqlArgument.getObject() + ")";
return (T) new SPARQLFunction(sparql);
} catch (UnsupportedTypeForExportException e) {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
} catch (UnavailableRuleObjectException e) {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
}
use of org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException in project stanbol by apache.
the class JenaAdpterTest method wrongAdaptabeClassTest.
@SuppressWarnings("unchecked")
@Test
public void wrongAdaptabeClassTest() {
try {
List<ConstructQuery> constructQueries = (List<ConstructQuery>) ruleAdapter.adaptTo(recipeGood, ConstructQuery.class);
for (ConstructQuery constructQuery : constructQueries) {
log.debug(constructQuery.toString());
Assert.fail("The adapter for Jena should not accept " + ConstructQuery.class.getCanonicalName() + " objects.");
}
} catch (UnavailableRuleObjectException e) {
Assert.fail(e.getMessage());
} catch (UnsupportedTypeForExportException e) {
log.debug(e.getMessage());
} catch (RuleAtomCallExeption e) {
Assert.fail(e.getMessage());
}
}
use of org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException in project stanbol by apache.
the class JenaAdpterTest method test.
@SuppressWarnings("unchecked")
@Test
public void test() {
try {
List<Rule> rules = (List<Rule>) ruleAdapter.adaptTo(recipeGood, Rule.class);
StringBuilder sb = new StringBuilder();
for (Rule rule : rules) {
sb.append(rule.toString());
}
Assert.assertNotSame(sb.toString(), "");
} catch (UnavailableRuleObjectException e) {
Assert.fail(e.getMessage());
} catch (UnsupportedTypeForExportException e) {
Assert.fail(e.getMessage());
} catch (RuleAtomCallExeption e) {
Assert.fail(e.getMessage());
}
}
use of org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException in project stanbol by apache.
the class ClerezzaAdpterTest method wrongAdaptabeClassTest.
@SuppressWarnings("unchecked")
@Test
public void wrongAdaptabeClassTest() {
try {
List<Rule> rules = (List<Rule>) ruleAdapter.adaptTo(recipeGood, Rule.class);
for (Rule rule : rules) {
log.debug(rule.toString());
Assert.fail("The adapter for Clerezza should not accept " + Rule.class.getCanonicalName() + " objects.");
}
} catch (UnavailableRuleObjectException e) {
Assert.fail(e.getMessage());
} catch (UnsupportedTypeForExportException e) {
log.debug(e.getMessage());
} catch (RuleAtomCallExeption e) {
Assert.fail(e.getMessage());
}
}
Aggregations