You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/05/08 12:31:35 UTC

[1/2] git commit: LDPath-Parser now accepts @graph statement (begin of MARMOTTA-215)

Updated Branches:
  refs/heads/develop ad9841782 -> 5fe2a271d


LDPath-Parser now accepts @graph statement (begin of MARMOTTA-215)


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/575c30cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/575c30cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/575c30cb

Branch: refs/heads/develop
Commit: 575c30cb0e2a160c09fdcb511b4f3e6a96c1a5ec
Parents: ad98417
Author: Jakob Frank <ja...@apache.org>
Authored: Wed May 8 10:07:38 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Wed May 8 10:07:38 2013 +0200

----------------------------------------------------------------------
 .../marmotta/ldpath/model/programs/Program.java    |   20 +++++++++++++++
 .../javacc/at/newmedialab/ldpath/parser/rdfpath.jj |   18 +++++++++++++
 .../src/test/resources/parse/program.ldpath        |    2 +
 3 files changed, 40 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/575c30cb/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/programs/Program.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/programs/Program.java b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/programs/Program.java
index b09d9e9..43930eb 100644
--- a/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/programs/Program.java
+++ b/libraries/ldpath/ldpath-core/src/main/java/org/apache/marmotta/ldpath/model/programs/Program.java
@@ -58,6 +58,11 @@ public class Program<Node> implements LDPathConstruct<Node> {
      * A map mapping from namespace prefix to namespace URI
      */
     private Map<String, String> namespaces;
+    
+    /**
+     * Restrict evaluation of the program to the graphs/contexts
+     */
+    private Set<Node> graphs;
 
     /**
      * An (optional) filter to use for checking which resources should be
@@ -78,6 +83,7 @@ public class Program<Node> implements LDPathConstruct<Node> {
     public Program() {
         namespaces = new LinkedHashMap<String, String>();
         fields = new LinkedHashSet<FieldMapping<?,Node>>();
+        graphs = new HashSet<Node>();
     }
 
     public void addNamespace(String prefix, String uri) {
@@ -129,6 +135,20 @@ public class Program<Node> implements LDPathConstruct<Node> {
         this.namespaces = new LinkedHashMap<String, String>(namespaces);
     }
     
+    public Set<Node> getGraphs() {
+        return this.graphs;
+    }
+    
+    @SuppressWarnings("unchecked")
+    public Node[] getGraphArr() {
+        return (Node[]) this.graphs.toArray(new Object[this.graphs.size()]);
+    }
+    
+    public void setGraphs(Collection<Node> graphs) {
+        this.graphs.clear();
+        this.graphs.addAll(graphs);
+    }
+    
     /**
      * Executes this Program on the parsed {@link RDFBackend backend}. 
      * @param context The context of the execution

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/575c30cb/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj b/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
index bf2a24b..83dffae 100644
--- a/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
+++ b/libraries/ldpath/ldpath-core/src/main/javacc/at/newmedialab/ldpath/parser/rdfpath.jj
@@ -47,6 +47,7 @@ import org.apache.marmotta.ldpath.model.transformers.*;
 
 
 import java.util.ArrayList;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -456,6 +457,7 @@ Program Program() :
     Map<String, String> nss = null;
     FieldMapping<?,Node> rule;
     NodeSelector<Node> boostSelector;
+    LinkedList<Node> graphs;
 }
 {
   (
@@ -468,6 +470,11 @@ Program Program() :
   )?
 
   (
+    <K_GRAPH> graphs = UriList() <SCOLON> {
+      program.setGraphs(graphs);
+    }
  )?
+
+  (
     <K_FILTER> filter = NodeTest() <SCOLON> {
         program.setFilter(filter);
     }
@@ -493,6 +500,17 @@ Program Program() :
   }
 }
 
+LinkedList<Node> UriList() :
{
+    LinkedList<Node> rest = null;
+    String uri;
}
+{
+    uri = Uri() ( <COMMA> rest = UriList() )?
    {
+      if (rest == null) rest = new LinkedList<Node>();
+      rest.addFirst(resolveResource(uri));
+      return rest;
+    }
+}
+
 FieldMapping Rule() :
 {
     FieldMapping<?,Node> rule;

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/575c30cb/libraries/ldpath/ldpath-core/src/test/resources/parse/program.ldpath
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/test/resources/parse/program.ldpath b/libraries/ldpath/ldpath-core/src/test/resources/parse/program.ldpath
index 5af4a0e..cb75ce6 100644
--- a/libraries/ldpath/ldpath-core/src/test/resources/parse/program.ldpath
+++ b/libraries/ldpath/ldpath-core/src/test/resources/parse/program.ldpath
@@ -16,6 +16,8 @@
 @prefix test: <http://example.com/>;
 @prefix foo: <http://foo.com/some/path#> ;
 
+@graph test:context, foo:ctx, test:bar ;
+
 @filter test:type is foo:bar | test:p1 & is-a test:Case ;
 
 @boost foo:boost / ^test:boost ;


[2/2] git commit: fixed test in ldpath-functions-date

Posted by ja...@apache.org.
fixed test in ldpath-functions-date


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/5fe2a271
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/5fe2a271
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/5fe2a271

Branch: refs/heads/develop
Commit: 5fe2a271db41e80e364507cc22c4c69a6b805946
Parents: 575c30c
Author: Jakob Frank <ja...@apache.org>
Authored: Wed May 8 10:23:25 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Wed May 8 10:23:25 2013 +0200

----------------------------------------------------------------------
 .../model/functions/date/DateFunctionsTest.java    |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5fe2a271/libraries/ldpath/ldpath-functions-date/src/test/java/org/apache/marmotta/ldpath/model/functions/date/DateFunctionsTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-functions-date/src/test/java/org/apache/marmotta/ldpath/model/functions/date/DateFunctionsTest.java b/libraries/ldpath/ldpath-functions-date/src/test/java/org/apache/marmotta/ldpath/model/functions/date/DateFunctionsTest.java
index 8470462..69dc472 100644
--- a/libraries/ldpath/ldpath-functions-date/src/test/java/org/apache/marmotta/ldpath/model/functions/date/DateFunctionsTest.java
+++ b/libraries/ldpath/ldpath-functions-date/src/test/java/org/apache/marmotta/ldpath/model/functions/date/DateFunctionsTest.java
@@ -48,7 +48,7 @@ public class DateFunctionsTest extends AbstractTestBase {
     @Before
     public void loadData() throws RepositoryException, RDFParseException, IOException {
         final int delta = 60 * 60 * 24 * 365;
-        now = new Date();
+        now = new Date(1000*(System.currentTimeMillis() / 1000));
         first = new Date(now.getTime() - 1000l * delta);
 
         uri = repository.getValueFactory().createURI(NSS.get("ex") + now.getTime());