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/08 18:47:39 UTC
[jira] [Resolved] (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 resolved JENA-1112.
---------------------------------
Resolution: Fixed
Fix Version/s: Jena 3.1.0
The transformed WHERE pattern wasn't being put into the new update.
> 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
> Fix For: Jena 3.1.0
>
>
> 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)