com.hp.hpl.jena.sparql.core.Var Java Examples

The following examples show how to use com.hp.hpl.jena.sparql.core.Var. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryTest.java    From ldp4j with Apache License 2.0 6 votes vote down vote up
public void visit(ElementNamedGraph arg0) {
	log(arg0);
	ind.increase();
	arg0.getElement().visit(this);
	com.hp.hpl.jena.graph.Node graphNameNode = arg0.getGraphNameNode();
	if(graphNameNode.isURI() && graphs.contains(graphNameNode.getURI())) {
		if(LOGGER.isDebugEnabled()) {
			LOGGER.debug("Need to relocate graph: "+graphNameNode.getURI());
		}
	} else {
		if(graphNameNode.isVariable() && variables.contains((Var)graphNameNode)) {
			if(LOGGER.isDebugEnabled()) {
				LOGGER.debug("Need to filter result: "+graphNameNode);
			}
		}
	}
	ind.decrease();
}
 
Example #2
Source File: BindingMaker.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
public Binding makeBinding(ResultRow row) {
	if (condition != null) {
		String value = row.get(condition);
		if (value == null || "false".equals(value) || "0".equals(value) || "".equals(value)) {
			return null;
		}
	}
	BindingMap result = new BindingHashMap();
	for (Var variableName: nodeMakers.keySet()) {
		Node node = nodeMakers.get(variableName).makeNode(row);
		if (node == null) {
			return null;
		}
		result.add(Var.alloc(variableName), node);
	}
	return result;
}
 
Example #3
Source File: DownloadRelation.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
public DownloadRelation(
		SQLConnection sqlConnection, 
		DatabaseOp tabular, 
		final NodeMaker nodeMaker, 
		final ValueMaker mediaTypeMaker, 
		final ColumnName contentDownloadColumn) {
	super(sqlConnection, tabular, new HashMap<Var,NodeMaker>() {/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

	{
		put(RESOURCE, nodeMaker);
		put(MEDIA_TYPE, new TypedNodeMaker(TypedNodeMaker.PLAIN_LITERAL, mediaTypeMaker));
		put(CONTENT, new TypedNodeMaker(TypedNodeMaker.PLAIN_LITERAL, new ColumnValueMaker(contentDownloadColumn)));
	}});
	this.contentDownloadColumn = contentDownloadColumn;
}
 
Example #4
Source File: NodeRelationUtil.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
/**
 * Joins this NodeRelation with a Binding. Any row in this
 * NodeRelation that is incompatible with the binding will be
 * dropped, and any compatible row will be extended with
 * FixedNodeMakers whose node is taken from the binding.
 * 
 * FIXME: This doesn't behave correctly when a node maker is available for a given variable but produces unbound results. Everything is compatible with unbound.
 * FIXME: This ignores the condition of the binding maker, if any is present.
 * 
 * @param binding A binding to join with this NodeRelation
 * @return The joined NodeRelation
 */
public static NodeRelation extendWith(NodeRelation table, Binding binding) {
	if (binding.isEmpty()) return table;
	Map<Var,NodeMaker> extraVars = new HashMap<Var,NodeMaker>();
	NodeRelation result = table;
	for (Iterator<Var> it = binding.vars(); it.hasNext();) {
		Var var = it.next();
		Node value = binding.get(var);
		if (table.getBindingMaker().has(var)) {
			result = NodeRelationUtil.select(result, var, value);
		} else {
			extraVars.put(var, new FixedNodeMaker(value));
		}
	}
	if (!extraVars.isEmpty()) {
		extraVars.putAll(result.getBindingMaker().getNodeMakers());
		result = new NodeRelation(result.getSQLConnection(), result.getBaseTabular(), 
				new BindingMaker(extraVars, result.getBindingMaker().getCondition()));
	}
	return result;
}
 
Example #5
Source File: IsLiteralTestEvaluator.java    From anno4j with Apache License 2.0 6 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    TestingSelector testingSelector = (TestingSelector) nodeSelector;
    FunctionTest functionTest = (FunctionTest) testingSelector.getTest();

    if(functionTest.getArgSelectors().get(0) instanceof PropertySelector) {
        PropertySelector arg = (PropertySelector) functionTest.getArgSelectors().get(0);
        PropertySelector delegate = (PropertySelector) testingSelector.getDelegate();

        Var target = Var.alloc(VarIDGenerator.createID());
        elementGroup.addTriplePattern(new Triple(var.asNode(), NodeFactory.createURI(delegate.getProperty().toString()), target));

        Var selector = Var.alloc(VarIDGenerator.createID());
        elementGroup.addTriplePattern(new Triple(target.asNode(), NodeFactory.createURI(arg.getProperty().toString()), selector.asNode()));

        elementGroup.addElementFilter(new ElementFilter(new E_IsLiteral(new ExprVar(selector))));

        return selector;
    } else {
        throw new IllegalStateException("Argument of function isLiteral has to be a PropertySelector");
    }
}
 
Example #6
Source File: GeneralNodeRelationUtil.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
/**
 * Joins this NodeRelation with a Binding. Any row in this
 * NodeRelation that is incompatible with the binding will be
 * dropped, and any compatible row will be extended with
 * FixedNodeMakers whose node is taken from the binding.
 * 
 * FIXME: This doesn't behave correctly when a node maker is available for a given variable but produces unbound results. Everything is compatible with unbound.
 * FIXME: This ignores the condition of the binding maker, if any is present.
 * 
 * @param binding A binding to join with this NodeRelation
 * @return The joined NodeRelation
 */
public static GeneralNodeRelation extendWith(GeneralNodeRelation table, Binding binding) {
	if (binding.isEmpty()) return table;
	Map<Var,NodeMaker> extraVars = new HashMap<Var,NodeMaker>();
	GeneralNodeRelation result = table;
	for (Iterator<Var> it = binding.vars(); it.hasNext();) {
		Var var = it.next();
		Node value = binding.get(var);
		if (table.getBindingMaker().has(var)) {
			result = GeneralNodeRelationUtil.select(result, var, value);
		} else {
			extraVars.put(var, new FixedNodeMaker(value));
		}
	}
	if (!extraVars.isEmpty()) {
		extraVars.putAll(result.getBindingMaker().getNodeMakers());
		result = new GeneralNodeRelation(result.getConnection(), result.getBaseTabular(), 
				new BindingMaker(extraVars, result.getBindingMaker().getCondition()));
	}
	return result;
}
 
Example #7
Source File: BindingMaker.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
@Override
public String toString() {
	StringBuffer result = new StringBuffer("BindingMaker(\n");
	for (Var variable: nodeMakers.keySet()) {
		result.append("    ");
		result.append(variable);
		result.append(" => ");
		result.append(nodeMakers.get(variable));
		result.append("\n");
	}
	result.append(")");
	if (condition != null) {
		result.append(" WHERE ");
		result.append(condition);
	}
	return result.toString();
}
 
Example #8
Source File: UnionSelectorEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    UnionSelector unionSelector = (UnionSelector) nodeSelector;

    NodeSelector nodeSelectorLeft = unionSelector.getLeft();
    NodeSelector nodeSelectorRight = unionSelector.getRight();

    ElementGroup leftGroup = new ElementGroup();
    ElementGroup rightGroup = new ElementGroup();

    Var leftVar = LDPathEvaluator.evaluate(nodeSelectorLeft, leftGroup, var, evaluatorConfiguration);
    Var rightVar = LDPathEvaluator.evaluate(nodeSelectorRight, rightGroup, var, evaluatorConfiguration);

    Var subVar = Var.alloc(VarIDGenerator.createID());

    Query leftSubQuery = new Query();
    leftGroup.addElement(new ElementBind(subVar, new NodeValueNode(leftVar.asNode())));
    leftSubQuery.setQueryPattern(leftGroup);
    leftSubQuery.addResultVar(var);
    leftSubQuery.addResultVar(subVar);
    leftSubQuery.setQuerySelectType();
    ElementSubQuery leftESubQuery = new ElementSubQuery(leftSubQuery);

    Query rightSubQuery = new Query();
    rightGroup.addElement(new ElementBind(subVar, new NodeValueNode(rightVar.asNode())));
    rightSubQuery.setQueryPattern(rightGroup);
    rightSubQuery.addResultVar(var);
    rightSubQuery.addResultVar(subVar);
    rightSubQuery.setQuerySelectType();
    ElementSubQuery rightESubQuery = new ElementSubQuery(rightSubQuery);


    ElementUnion elementUnion = new ElementUnion();

    elementUnion.addElement(leftESubQuery);
    elementUnion.addElement(rightESubQuery);
    elementGroup.addElement(elementUnion);

    return subVar;
}
 
Example #9
Source File: URIMakerRule.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
private int priority(TripleRelation relation) {
	int result = 0;
	for (Var var: TripleRelation.SPO) {
		URIMakerIdentifier id = uriMakerIdentifier(relation.nodeMaker(var));
		if (id.isURIPattern()) {
			result += 3;
		}
		if (id.isURIColumn()) {
			result -= 1;
		}
	}
	return result;
}
 
Example #10
Source File: OrTestEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    TestingSelector testingSelector = (TestingSelector) nodeSelector;
    Var delVar = LDPathEvaluator.evaluate(testingSelector.getDelegate(), elementGroup, var, evaluatorConfiguration);
    elementGroup.addElementFilter(new ElementFilter(evaluate(testingSelector.getTest(), elementGroup, delVar, evaluatorConfiguration)));
    return var;
}
 
Example #11
Source File: OrTestEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Expr evaluate(NodeTest nodeTest, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    OrTest orTest = (OrTest) nodeTest;
    Expr expr1 = LDPathEvaluator.evaluate(orTest.getLeft(), elementGroup, var, evaluatorConfiguration);
    Expr expr2 = LDPathEvaluator.evaluate(orTest.getRight(), elementGroup, var, evaluatorConfiguration);
    return new E_LogicalOr(expr1, expr2);
}
 
Example #12
Source File: BindingMaker.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public BindingMaker rename(Renamer renamer) {
	Map<Var,NodeMaker> renamedNodeMakers = new HashMap<Var,NodeMaker>();
	for (Var var: nodeMakers.keySet()) {
		renamedNodeMakers.put(var, renamer.applyTo(nodeMakers.get(var)));
	}
	return new BindingMaker(renamedNodeMakers, 
			condition == null ? null : renamer.applyTo(condition));
}
 
Example #13
Source File: EvalQuery.java    From anno4j with Apache License 2.0 5 votes vote down vote up
public static <T extends ResourceObject> Query evaluate(QueryServiceConfiguration queryServiceDTO, URI rootType) throws ParseException {

        Query query = QueryFactory.make();
        query.setQuerySelectType();

        ElementGroup elementGroup = new ElementGroup();

        Var objectVar = Var.alloc("root");

        // Creating and adding the first triple - could be something like: "?objectVar rdf:type oa:Annotation
        Triple t1 = new Triple(objectVar, RDF.type.asNode(), NodeFactory.createURI(rootType.toString()));
        elementGroup.addTriplePattern(t1);

        // Evaluating the criteria
        for (Criteria c : queryServiceDTO.getCriteria()) {
            SesameValueBackend backend = new SesameValueBackend();

            LdPathParser parser = new LdPathParser(backend, queryServiceDTO.getConfiguration(), new StringReader(c.getLdpath()));
            Var var = LDPathEvaluator.evaluate(parser.parseSelector(queryServiceDTO.getPrefixes()), elementGroup, objectVar, queryServiceDTO.getEvaluatorConfiguration());

            if (c.getConstraint() != null) {
                String resolvedConstraint = resolveConstraintPrefix(c.getConstraint(), queryServiceDTO, parser);
                EvalComparison.evaluate(elementGroup, c, var, resolvedConstraint);
            }
        }

        // Adding all generated patterns to the query object
        query.setQueryPattern(elementGroup);

        // Choose what we want so select - SELECT ?annotation in this case
        query.addResultVar(objectVar);

        // Setting the default prefixes, like rdf: or dc:
        query.getPrefixMapping().setNsPrefixes(queryServiceDTO.getPrefixes());

        return query;
    }
 
Example #14
Source File: LeftBesidesTestFunctionEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    TestingSelector testingSelector = (TestingSelector) nodeSelector;
    FunctionTest functionTest = (FunctionTest) testingSelector.getTest();
    LeftBesidesTest leftBesidesTest = (LeftBesidesTest) functionTest.getTest();

    System.out.println("inside leftBesides.evaluate()");
    return null;
}
 
Example #15
Source File: GeneralTripleRelation.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public GeneralTripleRelation(GeneralConnection connection, DatabaseOp baseRelation, 
		final NodeMaker subjectMaker, final NodeMaker predicateMaker, final NodeMaker objectMaker) {
	super(connection, baseRelation, new HashMap<Var,NodeMaker>() {/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

	{
		put(SUBJECT, subjectMaker);
		put(PREDICATE, predicateMaker);
		put(OBJECT, objectMaker);
	}});
}
 
Example #16
Source File: GeneralURIMakerRule.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
private int priority(GeneralTripleRelation o1) {
	int result = 0;
	for (Var var: TripleRelation.SPO) {
		URIMakerIdentifier id = uriMakerIdentifier(o1.nodeMaker(var));
		if (id.isURIPattern()) {
			result += 3;
		}
		if (id.isURIColumn()) {
			result -= 1;
		}
	}
	return result;
}
 
Example #17
Source File: GeneralNodeRelationUtil.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public static GeneralNodeRelation order(GeneralNodeRelation nodeRelation, 
		Var orderByVar, boolean ascending) {
	if (!nodeRelation.getBindingMaker().has(orderByVar)) {
		return nodeRelation;
	}
	List<OrderSpec> orderSpecs = nodeRelation.nodeMaker(orderByVar).orderSpecs(ascending);
	if (orderSpecs.isEmpty()) {
		return nodeRelation;
	}
	return new GeneralNodeRelationOrderer(nodeRelation, orderSpecs).getNodeRelation();
}
 
Example #18
Source File: GeneralNodeRelationUtil.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public static GeneralNodeRelation project(GeneralNodeRelation original, Set<Var> vars) {
	Set<ProjectionSpec> projections = new HashSet<ProjectionSpec>();
	for (Var var: vars) {
		if (!original.getBindingMaker().has(var)) continue;
		projections.addAll(original.nodeMaker(var).projectionSpecs());
	}
	if (new HashSet<ProjectionSpec>(ProjectionSpec.createFromColumns(
			original.getBaseTabular().getColumns())).equals(projections)) {
		// The original already has exactly the columns we need, no need to project
		return original;
	}
	return new GeneralNodeRelationProjecter(original, projections).getNodeRelation();
}
 
Example #19
Source File: NodeRelationUtil.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public static NodeRelation order(NodeRelation nodeRelation, 
		Var orderByVar, boolean ascending) {
	if (!nodeRelation.getBindingMaker().has(orderByVar)) {
		return nodeRelation;
	}
	List<OrderSpec> orderSpecs = nodeRelation.nodeMaker(orderByVar).orderSpecs(ascending);
	if (orderSpecs.isEmpty()) {
		return nodeRelation;
	}
	return new NodeRelationOrderer(nodeRelation, orderSpecs).getNodeRelation();
}
 
Example #20
Source File: NodeRelationUtil.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public static NodeRelation project(NodeRelation original, Set<Var> vars) {
	Set<ProjectionSpec> projections = new HashSet<ProjectionSpec>();
	for (Var var: vars) {
		if (!original.getBindingMaker().has(var)) continue;
		projections.addAll(original.nodeMaker(var).projectionSpecs());
	}
	if (new HashSet<ProjectionSpec>(ProjectionSpec.createFromColumns(
			original.getBaseTabular().getColumns())).equals(projections)) {
		// The original already has exactly the columns we need, no need to project
		return original;
	}
	return new NodeRelationProjecter(original, projections).getNodeRelation();
}
 
Example #21
Source File: TripleRelation.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public TripleRelation(SQLConnection connection, DatabaseOp baseRelation, 
		final NodeMaker subjectMaker, final NodeMaker predicateMaker, final NodeMaker objectMaker) {
	super(connection, baseRelation, new HashMap<Var,NodeMaker>() {/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

	{
		put(SUBJECT, subjectMaker);
		put(PREDICATE, predicateMaker);
		put(OBJECT, objectMaker);
	}});
}
 
Example #22
Source File: IsATestEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    TestingSelector testingSelector = (TestingSelector) nodeSelector;
    NodeTest nodeTest = testingSelector.getTest();
    Var delVar = LDPathEvaluator.evaluate(testingSelector.getDelegate(), elementGroup, var, evaluatorConfiguration);

    IsATest isATest = (IsATest) nodeTest;
    elementGroup.addTriplePattern(new Triple(delVar.asNode(), RDF.type.asNode(), NodeFactory.createURI(isATest.getPathExpression(new SesameValueBackend()).replace("<", "").replace(">", "").replaceFirst("is-a ", ""))));

    return delVar;
}
 
Example #23
Source File: PathEqualityTestEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Expr evaluate(NodeTest nodeTest, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    PathEqualityTest pathEqualityTest = (PathEqualityTest) nodeTest;
    Var tmpVar =  LDPathEvaluator.evaluate(pathEqualityTest.getPath(), elementGroup, var, evaluatorConfiguration);
    if(pathEqualityTest.getNode() instanceof org.openrdf.model.impl.LiteralImpl) {
        return new E_Equals(new ExprVar(tmpVar.asNode()), new NodeValueNode(NodeFactory.createLiteral(((LiteralImpl) pathEqualityTest.getNode()).getLabel().toString())));
    } else {
        return new E_Equals(new ExprVar(tmpVar.asNode()), new NodeValueNode(NodeFactory.createURI(pathEqualityTest.getNode().toString())));
    }
}
 
Example #24
Source File: LiteralTypeTestEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    TestingSelector testingSelector = (TestingSelector) nodeSelector;
    NodeTest nodeTest = testingSelector.getTest();
    Var delVar = LDPathEvaluator.evaluate(testingSelector.getDelegate(), elementGroup, var, evaluatorConfiguration);

    elementGroup.addElementFilter(new ElementFilter(evaluate(nodeTest, elementGroup, delVar, evaluatorConfiguration)));
    return delVar;
}
 
Example #25
Source File: PropertySelectorEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    PropertySelector propertySelector = (PropertySelector) nodeSelector;
    if (propertySelector instanceof WildcardSelector) {
        throw new IllegalStateException(propertySelector.getClass() + " is not supported.");
    }

    Var id = Var.alloc(VarIDGenerator.createID());
    elementGroup.addTriplePattern(new Triple(var.asNode(), NodeFactory.createURI(propertySelector.getProperty().toString()), id.asNode()));

    return id;
}
 
Example #26
Source File: PathEqualityTestEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    TestingSelector testingSelector = (TestingSelector) nodeSelector;
    NodeTest nodeTest = testingSelector.getTest();
    Var delVar = LDPathEvaluator.evaluate(testingSelector.getDelegate(), elementGroup, var, evaluatorConfiguration);

    elementGroup.addElementFilter(new ElementFilter(evaluate(nodeTest, elementGroup, delVar, evaluatorConfiguration)));
    return var;
}
 
Example #27
Source File: RecursivePathSelectorEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    RecursivePathSelector recursivePathSelector = (RecursivePathSelector) nodeSelector;

    Var id = Var.alloc(VarIDGenerator.createID());
    ElementPathBlock epb = new ElementPathBlock();
    String pathExpression = recursivePathSelector.getPathExpression(new SesameValueBackend());
    /**
     * initial pathExpression contains:
     *      (<http://www.w3.org/ns/oa#hasBody> / <http://www.example.com/schema#recursiveBodyValue>)*
     *
     * Because P_ZeroOrMore and so one, creates the same expression we have to strip the redundant chars.
     */
    String strippedPathExpression = pathExpression.substring(2, pathExpression.length() -3 );

    TriplePath triplePath = null;
    if (pathExpression.contains("*")) {
        triplePath = new TriplePath(var.asNode(), new P_ZeroOrMore1(new P_Link(NodeFactory.createURI(strippedPathExpression))), id.asNode());
    } else if (pathExpression.contains("+")) {
        triplePath = new TriplePath(var.asNode(), new P_OneOrMore1(new P_Link(NodeFactory.createURI(strippedPathExpression))), id.asNode());
    } else {
        throw new IllegalStateException("Only ZeroOrMorePath(*), OneOrMorePath(+) path selectors are currently supported.");
    }

    epb.addTriple(triplePath);
    ElementGroup group = new ElementGroup();
    group.addElement(epb);
    elementGroup.addElement(group);
    return id;
}
 
Example #28
Source File: NotTestEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    TestingSelector testingSelector = (TestingSelector) nodeSelector;
    Var delVar = LDPathEvaluator.evaluate(testingSelector.getDelegate(), elementGroup, var, evaluatorConfiguration);
    elementGroup.addElementFilter(new ElementFilter(evaluate(testingSelector.getTest(), elementGroup, delVar, evaluatorConfiguration)));
    return delVar;
}
 
Example #29
Source File: IsATestEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Expr evaluate(NodeTest nodeTest, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    IsATest isATest = (IsATest) nodeTest;
    Var tmpVar = Var.alloc(Var.alloc(VarIDGenerator.createID()));
    elementGroup.addTriplePattern(new Triple(var.asNode(), RDF.type.asNode(), tmpVar.asNode()));
    return new E_Equals(new ExprVar(tmpVar.asNode()), new NodeValueNode(NodeFactory.createURI(isATest.getPathExpression(new SesameValueBackend()).replace("<", "").replace(">", "").replaceFirst("is-a ", ""))));
}
 
Example #30
Source File: GroupedSelectorEvaluator.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
    GroupedSelector groupedSelector = (GroupedSelector) nodeSelector;
    ElementGroup newGroup = new ElementGroup();
    elementGroup.addElement(newGroup);
    return LDPathEvaluator.evaluate(groupedSelector.getContent(), newGroup, var, evaluatorConfiguration);
}