Håvard Ottestad created JENA-1112:
-------------------------------------

             Summary: UpdateTransformOps removes a filter expression
                 Key: JENA-1112
                 URL: https://issues.apache.org/jira/browse/JENA-1112
             Project: Apache Jena
          Issue Type: Bug
          Components: ARQ
    Affects Versions: Jena 3.0.1
            Reporter: Håvard Ottestad
            Priority: Critical


This filter gets removed:
FILTER ( ! EXISTS { ?a foaf:accountName ?username } ) 

The filter is used to stop duplicate usernames.

Example java program below.
----------------------------------------------------------------


import org.apache.jena.graph.Node;
import org.apache.jena.graph.NodeFactory;
import org.apache.jena.sparql.core.Var;
import org.apache.jena.sparql.syntax.syntaxtransform.UpdateTransformOps;
import org.apache.jena.update.UpdateFactory;
import org.apache.jena.update.UpdateRequest;

import java.util.HashMap;

public class Main {
        public static void main(String[] args) {

                String original = "PREFIX foaf: <http://xmlns.com/foaf/0.1/>    
                                                                                
                                                        \n" +
                                "INSERT {                                       
                                                                                
                                                                                
                                        \n" +
                                "               [] foaf:accountName ?username . 
                                                                                
                                                                                
        \n" +
                                "}                                              
                                                                                
                                                                                
                                                \n" +
                                "WHERE{                                         
                                                                                
                                                                                
                                \n" +
                                "       FILTER ( ! EXISTS { ?a foaf:accountName 
?username } ) #### THIS FILTER GETS REMOVED WHEN I TRANSFORM    \n" +
                                "}                                              
                                                                                
                                                                                
                                                        ";
                // The filter is used to stop duplicate usernames.

                UpdateRequest updates = UpdateFactory.create(original);
                System.out.println("--- ORIGINAL 
---\n"+updates.toString()+"\n");

                // set ?username to "test"
                HashMap<Var, Node> varNodeHashMap = new HashMap<Var, Node>();
                varNodeHashMap.put(Var.alloc("username"), 
NodeFactory.createLiteral("test"));

                //Transform
                UpdateRequest transform = UpdateTransformOps.transform(updates, 
varNodeHashMap);
                System.out.println("--- TRANSFORMED 
---\n"+transform.toString());

        }

}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to