You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2016/01/07 18:10:39 UTC

[jira] [Assigned] (JENA-1112) UpdateTransformOps removes a filter expression

     [ https://issues.apache.org/jira/browse/JENA-1112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andy Seaborne reassigned JENA-1112:
-----------------------------------

    Assignee: Andy Seaborne

> 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
>            Assignee: Andy Seaborne
>
> This filter gets removed:
> {code}
> FILTER ( ! EXISTS { ?a foaf:accountName ?username } ) 
> {code}
> The filter is used to stop duplicate usernames.
> Example java program below.
> ----------------------------------------------------------------
> {code}
> 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" +
> 				"	#### THIS FILTER GETS REMOVED WHEN I TRANSFORM \n" +
> 				"	FILTER ( ! EXISTS { ?a foaf:accountName ?username } )  \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());
> 	}
> }
> {code}
> FYI. Maven setup:
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
>     <modelVersion>4.0.0</modelVersion>
>     <groupId>fjkldsjlk</groupId>
>     <artifactId>fksfjklwe</artifactId>
>     <version>1.0-SNAPSHOT</version>
>     <dependencies>
>         <dependency>
>             <groupId>org.apache.jena</groupId>
>             <artifactId>apache-jena-libs</artifactId>
>             <version>3.0.1</version>
>         </dependency>
>     </dependencies>
> </project>
> {code}



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