You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@any23.apache.org by jg...@apache.org on 2017/12/07 12:28:14 UTC

[11/17] any23 git commit: Update ElementProcessor

Update ElementProcessor

- instantiate a map's root node
- update unit tests
Signed-off-by:Jacek Grzebyta <gr...@gmail.com>

Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/66ffee03
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/66ffee03
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/66ffee03

Branch: refs/heads/master
Commit: 66ffee03937bc23536628f8b9fa1504bbcd95efe
Parents: 52c199b
Author: Jacek Grzebyta <gr...@gmail.com>
Authored: Fri Nov 3 22:25:29 2017 +0000
Committer: Jacek Grzebyta <gr...@gmail.com>
Committed: Fri Nov 3 22:25:29 2017 +0000

----------------------------------------------------------------------
 .../any23/extractor/yaml/ElementsProcessor.java      | 15 +++++++++++++--
 .../any23/extractor/yaml/ElementsProcessorTest.java  |  2 +-
 .../any23/extractor/yaml/YAMLExtractorTest.java      |  2 +-
 3 files changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/any23/blob/66ffee03/core/src/main/java/org/apache/any23/extractor/yaml/ElementsProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/extractor/yaml/ElementsProcessor.java b/core/src/main/java/org/apache/any23/extractor/yaml/ElementsProcessor.java
index 7d15576..6819b88 100644
--- a/core/src/main/java/org/apache/any23/extractor/yaml/ElementsProcessor.java
+++ b/core/src/main/java/org/apache/any23/extractor/yaml/ElementsProcessor.java
@@ -95,7 +95,17 @@ public class ElementsProcessor {
         }
     }
 
-    protected Map.Entry<Value, Model> processMap(IRI ns, Map<String, Object> object, Value rootNode) {
+    /**
+     * This method creates a map with non bnode root.
+     * 
+     * If a map has instantiated root (not a blank node) it is simpler to create SPARQL query.
+     * 
+     * @param ns
+     * @param object
+     * @param parentNode
+     * @return 
+     */
+    protected Map.Entry<Value, Model> processMap(IRI ns, Map<String, Object> object, Value parentNode) {
         // check if map is empty
         if (object.isEmpty()) {
             return null;
@@ -108,7 +118,8 @@ public class ElementsProcessor {
         assert ns != null : "Namespace value is null";
 
         Model model = modelFactory.createEmptyModel();
-        Value nodeURI = rootNode == null ? RDFUtils.makeIRI() : rootNode;
+        Value nodeURI =RDFUtils.makeIRI("node", ns, true);
+        
         if (!isEmpty) {
             model.add(vf.createStatement((Resource) nodeURI, RDF.TYPE, vocab.mapping));
         }

http://git-wip-us.apache.org/repos/asf/any23/blob/66ffee03/core/src/test/java/org/apache/any23/extractor/yaml/ElementsProcessorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/any23/extractor/yaml/ElementsProcessorTest.java b/core/src/test/java/org/apache/any23/extractor/yaml/ElementsProcessorTest.java
index 6332776..5f9a7d8 100644
--- a/core/src/test/java/org/apache/any23/extractor/yaml/ElementsProcessorTest.java
+++ b/core/src/test/java/org/apache/any23/extractor/yaml/ElementsProcessorTest.java
@@ -54,7 +54,7 @@ public class ElementsProcessorTest {
                 simpleMap,
                 ep.vf.createIRI("http://example.org/node1"));
         
-        Assert.assertEquals(toTest.getKey().stringValue(), "http://example.org/node1");
+        Assert.assertEquals("http://example.org/node_0", toTest.getKey().stringValue());
         Assert.assertTrue(toTest.getValue().size() > 0);
         log.debug("Model: \n{}\n", dumpModel(toTest.getValue(), RDFFormat.TURTLE));
     }

http://git-wip-us.apache.org/repos/asf/any23/blob/66ffee03/core/src/test/java/org/apache/any23/extractor/yaml/YAMLExtractorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/any23/extractor/yaml/YAMLExtractorTest.java b/core/src/test/java/org/apache/any23/extractor/yaml/YAMLExtractorTest.java
index 2dc884c..9dba216 100644
--- a/core/src/test/java/org/apache/any23/extractor/yaml/YAMLExtractorTest.java
+++ b/core/src/test/java/org/apache/any23/extractor/yaml/YAMLExtractorTest.java
@@ -105,7 +105,7 @@ public class YAMLExtractorTest extends AbstractExtractorTestCase {
          */
         assertNotContains(RDF.TYPE, vocab.mapping); 
         int statements = dumpAsListOfStatements().size();
-        Assert.assertTrue("Found " + statements + " statements", statements == 9);
+        Assert.assertTrue("Found " + statements + " statements", statements == 10);
     }
 
     @Test