You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Joshua Taylor (JIRA)" <ji...@apache.org> on 2014/01/30 17:08:09 UTC

[jira] [Created] (JENA-631) property functions are not called from property paths

Joshua Taylor created JENA-631:
----------------------------------

             Summary: property functions are not called from property paths
                 Key: JENA-631
                 URL: https://issues.apache.org/jira/browse/JENA-631
             Project: Apache Jena
          Issue Type: Bug
          Components: ARQ, Jena
    Affects Versions: Jena 2.11.1
            Reporter: Joshua Taylor


Property functions in certain property paths are not invoked.  This was discussed on the users mailing list [1], and sample code to reproduce follows.

[1] http://mail-archives.apache.org/mod_mbox/jena-users/201401.mbox/%3CCA%2BQ4JnnO4oOLzdA0OP1csP8fr_RRdtRW_p_o8D9%2BKpwvisTm8g%40mail.gmail.com%3E

import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.sparql.algebra.Algebra;
import com.hp.hpl.jena.sparql.engine.ExecutionContext;
import com.hp.hpl.jena.sparql.engine.QueryIterator;
import com.hp.hpl.jena.sparql.engine.binding.Binding;
import com.hp.hpl.jena.sparql.pfunction.PropFuncArg;
import com.hp.hpl.jena.sparql.pfunction.library.version;
import com.hp.hpl.jena.vocabulary.RDFS;


public class PropertyFunctionsNotCalledInPath {
	// This class isn't important.  It's just an extension of an existing property 
	// function class so that we can add some output.
	public static class versionEx extends version {
		@Override
		public QueryIterator execEvaluated(Binding binding, PropFuncArg subject, Node predicate, PropFuncArg object, ExecutionContext execCxt) {
			System.out.println( "** Calling versionEx **" );
			return super.execEvaluated(binding, subject, predicate, object, execCxt);
		}
		
	}

	public static void main(String[] args) {
		Model model = ModelFactory.createDefaultModel();
		model.add( RDFS.Class, RDFS.comment, RDFS.Class );

		String[] queries = {
				"ask { ?s <java:PropertyFunctionsNotCalledInPath$versionEx>  \"foo\" }" ,
				"ask { ?s <java:PropertyFunctionsNotCalledInPath$versionEx>? \"foo\" }" };
		
		for ( String queryString : queries ) {
			Query query = QueryFactory.create( queryString );
			System.out.println( "Result:  "+QueryExecutionFactory.create( query, model ).execAsk() );
			System.out.println( "Query:   "+queryString );
			System.out.println( "Algebra: "+Algebra.compile( query ));
		}
		
		/*
		 * Output is as follows.  The versionEx property function gets called in the 
		 * simple case, but not in the case of the more complicated property path.
		 * Neither algebra expression has a propertyfunc operator;  the first just
		 * uses (triple ...).

** Calling versionEx **
Result:  false
Query:   ask { ?s <java:PropertyFunctionsNotCalledInPath$versionEx>  "foo" }
Algebra: (bgp (triple ?s <java:PropertyFunctionsNotCalledInPath$versionEx> "foo"))

Result:  true
Query:   ask { ?s <java:PropertyFunctionsNotCalledInPath$versionEx>? "foo" }
Algebra: (path ?s (path? <java:PropertyFunctionsNotCalledInPath$versionEx>) "foo")

		 */
	}
}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)