test_class.file: jena-sparql-api-core/src/test/java/org/aksw/jena_sparql_api/transform/TestElementTransformVirtualPredicates.java
test_class.identifier: TestElementTransformVirtualPredicates
test_case.body: @Test
      public void test() {
      	// Set up some default namespaces
      	Prologue prologue = new Prologue();
          prologue.setPrefixMapping(PrefixMapping.Extended);
          
          // Load a simple RDF model about people and their birth date
          // Note, that there is no explicit 'age' attribute in the data
          Model model = RDFDataMgr.loadModel("virtual-predicates-example.ttl");
          RDFDataMgr.write(System.out, model, RDFFormat.TURTLE_PRETTY);
  
  
          // Set up a map for expanding predicates with binary (sparql) relations
      	Map<Node, BinaryRelation> virtualPredicates = new HashMap<Node, BinaryRelation>();
  
      	// Register a virtual predicate that computes the age from the current
      	// date and birth date of a person
          virtualPredicates.put(NodeFactory.createURI("http://www.example.org/age"),
          		BinaryRelationImpl.create("?s a eg:Person ; eg:birthDate ?start . " + 
          		        "BIND(NOW() AS ?end) " +
          				"BIND(YEAR(?end) - YEAR(?start) - IF(MONTH(?end) < MONTH(?start) || (MONTH(?end) = MONTH(?start) && DAY(?end) < DAY(?start)), 1, 0) as ?age)",
                          "s", "age", prologue));
  
          
          // Set up some queries and run them
          SparqlQueryParser parser = SparqlQueryParserImpl.create(Syntax.syntaxARQ, prologue);
          
          List<Query> queries = Arrays.asList(
              parser.apply("Select (year(NOW()) - year('1984-01-01'^^xsd:date) AS ?d) { }"),
          	parser.apply("Select * { ?s ?p ?o  }"),
          	parser.apply("Select * { ?s eg:age ?o  }"),
          	parser.apply("Select * { ?s a eg:Person ; eg:age ?a }"),
          	parser.apply("Select * { ?s a eg:Person ; ?p ?o . FILTER(?p = eg:age) }")
          );
  
          for(Query query : queries) {
          	if(query.isQueryResultStar()) {
  	        	query.getProjectVars().addAll(query.getResultVars().stream().map(Var::alloc).collect(Collectors.toList()));
  	        	query.setQueryResultStar(false);
  	        	System.out.println(query);
          	}
  
          	Query intermediateQuery = ElementTransformVirtualPredicates.transform(query, virtualPredicates, true);
          	
              Op op = Algebra.compile(intermediateQuery);
  
              Context ctx = ARQ.getContext().copy();
  
              // Disable this transformation, as it does not generate valid SPARQL syntax
              ctx.set(ARQ.optFilterEquality, false);
              //System.out.println("status: " + ctx.get(ARQ.optFilterEquality));
  
  
  //            Context ctx = new Context();
  //            ctx.put(ARQ.optMergeBGPs, true);
  //            ctx.put(ARQ.optMergeExtends, true);
  //            ctx.put(ARQ.optExprConstantFolding, true);
  //            ctx.put(ARQ.optFilterPlacement, true);
  //            ctx.put(ARQ.optFilterConjunction, true);
  //            ctx.put(ARQ.optImplicitLeftJoin, true);
  //            ctx.put(ARQ.optFilterEquality, false);
  //            ctx.put(ARQ.optFilterInequality, false);
  //            ctx.put(ARQ.optDistinctToReduced, false);
  //            ctx.put(ARQ.optFilterExpandOneOf, false);
              ctx.put(ARQ.optFilterPlacement, true);
              ctx.put(ARQ.optFilterPlacementBGP, true);
              
              // TODO Implement rewrite to pull up
              //  extends over joins (join(..., extends(...), ...) -> extends(join(...))
              // Then apply merge BGP
              //ctx.put(ARQ.opt);
              
              
  
              //op = Optimize.optimize(op, ctx);
              System.out.println(op);
              Query finalQuery = OpAsQuery.asQuery(op);
  
              System.out.println("Rewritten query: " + finalQuery);
  
              System.out.println(ResultSetFormatter.asText(
              		FluentQueryExecutionFactory
              			.from(model).create().createQueryExecution(finalQuery).execSelect()));
              
          }
          
          
          //virtualPredicates.put(NodeFactory.createURI("http://ex.org/label"), Relation.create("GRAPH ?g { ?s ?p ?o } . ?g <http://owner> ?o", "s", "o"));
          //virtualPredicates.put(NodeFactory.createURI("http://ex.org/label"), Relation.create("?s <test> ?g . ?g <http://owner> ?o", "s", "o"));
  
  
  
          virtualPredicates.put(NodeFactory.createURI(RDFS.label.getURI()), BinaryRelationImpl.create("?s <skos:label> [ <skos:value> ?l]", "s", "l"));
  
  
          //Query query = QueryFactory.create("Select * { ?s <http://ex.org/label> ?o }");
  //        Query finalQuery = QueryFactory.create("Select * { ?s ?p ?o . Filter(?s = <http://ex.org/foo>) }");
          //op = Transformer.transform(new TransformFilterPlacement(), op);
  
  
  
  
    //      Query intermediateQuery = ElementTransformVirtualPredicates.transform(finalQuery, virtualPredicates, true);
  
          // Optimize the query
  
      }
test_case.class_method_signature: TestElementTransformVirtualPredicates.test()
test_case.full_signature: @Test public void test()
test_case.identifier: test
test_case.invocations: setPrefixMapping loadModel write put createURI create create asList apply apply apply apply apply isQueryResultStar addAll getProjectVars collect map stream getResultVars toList setQueryResultStar println transform compile copy getContext set put put println asQuery println println asText execSelect createQueryExecution create from put createURI getURI create
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test()
focal_class.declarator: logger = LoggerFactory.getLogger(ElementTransformVirtualPredicates.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(ElementTransformVirtualPredicates.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: virtualPredicates
focal_class.modifier: protected
focal_class.original_string: protected Map<Node, BinaryRelation> virtualPredicates;
focal_class.type: Map<Node, BinaryRelation>
focal_class.var_name: virtualPredicates
focal_class.declarator: varGen
focal_class.modifier: protected
focal_class.original_string: protected Generator<Var> varGen;
focal_class.type: Generator<Var>
focal_class.var_name: varGen
focal_class.file: jena-sparql-api-core/src/main/java/org/aksw/jena_sparql_api/transform/ElementTransformVirtualPredicates.java
focal_class.identifier: ElementTransformVirtualPredicates
focal_class.class_method_signature: ElementTransformVirtualPredicates.ElementTransformVirtualPredicates()
focal_class.full_signature: public  ElementTransformVirtualPredicates()
focal_class.identifier: ElementTransformVirtualPredicates
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  ElementTransformVirtualPredicates()
focal_class.class_method_signature: ElementTransformVirtualPredicates.ElementTransformVirtualPredicates(Map<Node, BinaryRelation> virtualPredicates)
focal_class.full_signature: public  ElementTransformVirtualPredicates(Map<Node, BinaryRelation> virtualPredicates)
focal_class.identifier: ElementTransformVirtualPredicates
focal_class.modifiers: public
focal_class.parameters: (Map<Node, BinaryRelation> virtualPredicates)
focal_class.signature:  ElementTransformVirtualPredicates(Map<Node, BinaryRelation> virtualPredicates)
focal_class.class_method_signature: ElementTransformVirtualPredicates.ElementTransformVirtualPredicates(Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.full_signature: public  ElementTransformVirtualPredicates(Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.identifier: ElementTransformVirtualPredicates
focal_class.modifiers: public
focal_class.parameters: (Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.signature:  ElementTransformVirtualPredicates(Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.class_method_signature: ElementTransformVirtualPredicates.transform(ElementTriplesBlock el)
focal_class.full_signature: @Override public Element transform(ElementTriplesBlock el)
focal_class.identifier: transform
focal_class.modifiers: @Override public
focal_class.parameters: (ElementTriplesBlock el)
focal_class.return: Element
focal_class.signature: Element transform(ElementTriplesBlock el)
focal_class.class_method_signature: ElementTransformVirtualPredicates.transform(ElementPathBlock el)
focal_class.full_signature: @Override public Element transform(ElementPathBlock el)
focal_class.identifier: transform
focal_class.modifiers: @Override public
focal_class.parameters: (ElementPathBlock el)
focal_class.return: Element
focal_class.signature: Element transform(ElementPathBlock el)
focal_class.class_method_signature: ElementTransformVirtualPredicates.applyTransform(ElementTriplesBlock el, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> rootVarGen)
focal_class.full_signature: public static Element applyTransform(ElementTriplesBlock el, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> rootVarGen)
focal_class.identifier: applyTransform
focal_class.modifiers: public static
focal_class.parameters: (ElementTriplesBlock el, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> rootVarGen)
focal_class.return: Element
focal_class.signature: Element applyTransform(ElementTriplesBlock el, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> rootVarGen)
focal_class.class_method_signature: ElementTransformVirtualPredicates.applyTransform(ElementPathBlock el, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> rootVarGen)
focal_class.full_signature: public static Element applyTransform(ElementPathBlock el, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> rootVarGen)
focal_class.identifier: applyTransform
focal_class.modifiers: public static
focal_class.parameters: (ElementPathBlock el, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> rootVarGen)
focal_class.return: Element
focal_class.signature: Element applyTransform(ElementPathBlock el, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> rootVarGen)
focal_class.class_method_signature: ElementTransformVirtualPredicates.applyTransform(Triple triple, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.full_signature: public static Element applyTransform(Triple triple, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.identifier: applyTransform
focal_class.modifiers: public static
focal_class.parameters: (Triple triple, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.return: Element
focal_class.signature: Element applyTransform(Triple triple, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.class_method_signature: ElementTransformVirtualPredicates.createElementForVariablePredicate(Var pVar, Node s, Node o, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.full_signature: public static Element createElementForVariablePredicate(Var pVar, Node s, Node o, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.identifier: createElementForVariablePredicate
focal_class.modifiers: public static
focal_class.parameters: (Var pVar, Node s, Node o, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.return: Element
focal_class.signature: Element createElementForVariablePredicate(Var pVar, Node s, Node o, Map<Node, BinaryRelation> virtualPredicates, Generator<Var> varGen)
focal_class.class_method_signature: ElementTransformVirtualPredicates.createElementForConcretePredicate(Var pVar, Node pRef, Node s, Node o, BinaryRelation relation, Generator<Var> varGen)
focal_class.full_signature: public static Element createElementForConcretePredicate(Var pVar, Node pRef, Node s, Node o, BinaryRelation relation, Generator<Var> varGen)
focal_class.identifier: createElementForConcretePredicate
focal_class.modifiers: public static
focal_class.parameters: (Var pVar, Node pRef, Node s, Node o, BinaryRelation relation, Generator<Var> varGen)
focal_class.return: Element
focal_class.signature: Element createElementForConcretePredicate(Var pVar, Node pRef, Node s, Node o, BinaryRelation relation, Generator<Var> varGen)
focal_class.class_method_signature: ElementTransformVirtualPredicates.transform(Query query, Map<Node, BinaryRelation> virtualPredicates, boolean cloneOnChange)
focal_class.full_signature: public static Query transform(Query query, Map<Node, BinaryRelation> virtualPredicates, boolean cloneOnChange)
focal_class.identifier: transform
focal_class.modifiers: public static
focal_class.parameters: (Query query, Map<Node, BinaryRelation> virtualPredicates, boolean cloneOnChange)
focal_class.return: Query
focal_class.signature: Query transform(Query query, Map<Node, BinaryRelation> virtualPredicates, boolean cloneOnChange)
focal_class.class_method_signature: ElementTransformVirtualPredicates.transform(Element element, Map<Node, BinaryRelation> virtualPredicates)
focal_class.full_signature: public static Element transform(Element element, Map<Node, BinaryRelation> virtualPredicates)
focal_class.identifier: transform
focal_class.modifiers: public static
focal_class.parameters: (Element element, Map<Node, BinaryRelation> virtualPredicates)
focal_class.return: Element
focal_class.signature: Element transform(Element element, Map<Node, BinaryRelation> virtualPredicates)
focal_class.superclass: extends ElementTransformCopyBase
focal_method.body: @Override
      public Element transform(ElementTriplesBlock el) {
          Element result = applyTransform(el, virtualPredicates, varGen);
          return result;
      }
focal_method.class_method_signature: ElementTransformVirtualPredicates.transform(ElementTriplesBlock el)
focal_method.full_signature: @Override public Element transform(ElementTriplesBlock el)
focal_method.identifier: transform
focal_method.invocations: applyTransform
focal_method.modifiers: @Override public
focal_method.parameters: (ElementTriplesBlock el)
focal_method.return: Element
focal_method.signature: Element transform(ElementTriplesBlock el)