use of com.hp.hpl.jena.graph.Node in project stanbol by apache.
the class PropertyPrefixFilterTest method testMappings.
@Test
public void testMappings() {
Node subject = Node.createURI("urn:subject");
Node value = Node.createURI("urn:value");
Node rdfType = Node.createURI(NamespaceEnum.rdf + "type");
Assert.assertTrue(importFilter.accept(subject, rdfType, value));
Node rdfsLabel = Node.createURI(NamespaceEnum.rdfs + "label");
Assert.assertTrue(importFilter.accept(subject, rdfsLabel, value));
Node guid = Node.createURI(FB + "type.object.guid");
Assert.assertFalse(importFilter.accept(subject, guid, value));
Node permission = Node.createURI(FB + "type.object.permission");
Assert.assertFalse(importFilter.accept(subject, permission, value));
Node name = Node.createURI(FB + "type.object.name");
Assert.assertTrue(importFilter.accept(subject, name, value));
Node description = Node.createURI(FB + "type.object.description");
Assert.assertTrue(importFilter.accept(subject, description, value));
Node dummy = Node.createURI(FB + "type.dummy");
Assert.assertFalse(importFilter.accept(subject, dummy, value));
Node typePlain = Node.createURI(FB + "type");
Assert.assertFalse(importFilter.accept(subject, typePlain, value));
Node other = Node.createURI(NamespaceEnum.cc + "license");
Assert.assertFalse(importFilter.accept(subject, other, value));
}
use of com.hp.hpl.jena.graph.Node in project stanbol by apache.
the class CreateURI method execEvaluated.
@Override
public QueryIterator execEvaluated(Binding binding, PropFuncArg argumentSubject, Node predicate, PropFuncArg argumentObject, ExecutionContext execCxt) {
Binding b = null;
if (argumentObject.getArg().isLiteral()) {
Node ref = argumentSubject.getArg();
if (ref.isVariable()) {
String argumentString = argumentObject.getArg().toString().replace("\"", "");
//STANBOL-621: Binding1 has no longer a public constructor
//b = new Binding1(binding, Var.alloc(ref), NodeFactory.createURI(argumentString));
b = BindingFactory.binding(binding, Var.alloc(ref), NodeFactory.createURI(argumentString));
}
}
if (b == null) {
b = binding;
}
return IterLib.result(b, execCxt);
}
use of com.hp.hpl.jena.graph.Node in project stanbol by apache.
the class AbstractRuleAtom method getTypedLiteral.
protected Node getTypedLiteral(Object argument) {
Node literal;
if (argument instanceof TypedLiteralAtom) {
TypedLiteralAtom typedLiteralAtom = (TypedLiteralAtom) argument;
URIResource xsdType = typedLiteralAtom.getXsdType();
if (xsdType.getURI().equals(XSD.xboolean)) {
literal = Node_RuleVariable.createLiteral(argument.toString(), null, XSDDatatype.XSDboolean);
} else if (xsdType.getURI().equals(XSD.xdouble)) {
literal = Node_RuleVariable.createLiteral(argument.toString(), null, XSDDatatype.XSDdouble);
} else if (xsdType.getURI().equals(XSD.xfloat)) {
literal = Node_RuleVariable.createLiteral(argument.toString(), null, XSDDatatype.XSDfloat);
} else if (xsdType.getURI().equals(XSD.xint)) {
literal = Node_RuleVariable.createLiteral(argument.toString(), null, XSDDatatype.XSDint);
} else {
literal = Node_RuleVariable.createLiteral(argument.toString());
}
} else if (argument instanceof String) {
literal = Node_RuleVariable.createLiteral((String) argument, null, XSDDatatype.XSDstring);
} else if (argument instanceof Integer) {
literal = Node_RuleVariable.createLiteral(argument.toString(), null, XSDDatatype.XSDinteger);
} else if (argument instanceof Double) {
literal = Node_RuleVariable.createLiteral(argument.toString(), null, XSDDatatype.XSDdouble);
} else if (argument instanceof Float) {
literal = Node_RuleVariable.createLiteral(argument.toString(), null, XSDDatatype.XSDfloat);
} else if (argument instanceof Boolean) {
literal = Node_RuleVariable.createLiteral(argument.toString(), null, XSDDatatype.XSDboolean);
} else {
literal = Node_RuleVariable.createLiteral((String) argument);
}
return literal;
}
use of com.hp.hpl.jena.graph.Node in project stanbol by apache.
the class MultiplicationAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
String div_result = "mul_result" + System.currentTimeMillis();
Node arg1Node = null;
Node arg2Node = null;
Node arg3Node = Node_RuleVariable.createVariable(div_result);
org.apache.stanbol.rules.manager.atoms.MultiplicationAtom tmp = (org.apache.stanbol.rules.manager.atoms.MultiplicationAtom) ruleAtom;
NumericFunctionAtom numericFunctionAtom1 = tmp.getNumericFunctionAtom1();
NumericFunctionAtom numericFunctionAtom2 = tmp.getNumericFunctionAtom2();
ClauseEntry clauseEntry1 = adapter.adaptTo(numericFunctionAtom1, Rule.class);
ClauseEntry clauseEntry2 = adapter.adaptTo(numericFunctionAtom2, Rule.class);
List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
if (clauseEntry1 instanceof HigherOrderClauseEntry) {
arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
} else if (clauseEntry1 instanceof NodeClauseEntry) {
arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
if (clauseEntry2 instanceof HigherOrderClauseEntry) {
arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
} else if (clauseEntry2 instanceof NodeClauseEntry) {
arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
java.util.List<Node> nodes = new ArrayList<Node>();
nodes.add(arg1Node);
nodes.add(arg2Node);
nodes.add(arg3Node);
ClauseEntry clauseEntry = new Functor("product", nodes, BuiltinRegistry.theRegistry);
clauseEntries.add(clauseEntry);
return (T) new HigherOrderClauseEntry(arg3Node, clauseEntries);
}
use of com.hp.hpl.jena.graph.Node in project stanbol by apache.
the class LetAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.LetAtom tmp = (org.apache.stanbol.rules.manager.atoms.LetAtom) ruleAtom;
StringFunctionAtom parameterFunctionAtom = tmp.getParameterFunctionAtom();
IObjectAtom variableIObjectAtom = tmp.getVariable();
ClauseEntry parameterClauseEntry = adapter.adaptTo(parameterFunctionAtom, Rule.class);
ClauseEntry variableClauseEntry = adapter.adaptTo(variableIObjectAtom, Rule.class);
List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
Node parameterNode;
Node variableNode;
if (parameterClauseEntry instanceof HigherOrderClauseEntry) {
parameterNode = ((HigherOrderClauseEntry) parameterClauseEntry).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) parameterClauseEntry).getClauseEntries());
} else if (parameterClauseEntry instanceof NodeClauseEntry) {
parameterNode = ((NodeClauseEntry) parameterClauseEntry).getNode();
} else {
throw new RuleAtomCallExeption(getClass());
}
if (variableClauseEntry instanceof NodeClauseEntry) {
variableNode = ((NodeClauseEntry) variableClauseEntry).getNode();
} else {
throw new RuleAtomCallExeption(getClass());
}
java.util.List<Node> nodes = new ArrayList<Node>();
nodes.add(variableNode);
nodes.add(parameterNode);
ClauseEntry clauseEntry = new Functor("makeSkolem", nodes, BuiltinRegistry.theRegistry);
clauseEntries.add(clauseEntry);
return (T) new HigherOrderClauseEntry(variableNode, clauseEntries);
}
Aggregations