You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/07/15 14:20:51 UTC
[2/4] incubator-taverna-language git commit: ro bundles now recognize
their history
ro bundles now recognize their history
the `RDFToManifest.readTo` method just didn't look for a potential history.
implemented the missing part and extended the test
fixes https://issues.apache.org/jira/browse/TAVERNA-842
Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/bcc31f8c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/bcc31f8c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/bcc31f8c
Branch: refs/heads/master
Commit: bcc31f8cecf4699a71943e3887893f49b41675d2
Parents: 74d9f2f
Author: Martin Scharm <ma...@binfalse.de>
Authored: Tue Jul 14 14:25:07 2015 +0100
Committer: Martin Scharm <ma...@binfalse.de>
Committed: Tue Jul 14 14:25:07 2015 +0100
----------------------------------------------------------------------
.../robundle/manifest/RDFToManifest.java | 8 ++++++
.../robundle/manifest/TestManifestJSON.java | 27 ++++++++++++++------
2 files changed, 27 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/bcc31f8c/taverna-robundle/src/main/java/org/apache/taverna/robundle/manifest/RDFToManifest.java
----------------------------------------------------------------------
diff --git a/taverna-robundle/src/main/java/org/apache/taverna/robundle/manifest/RDFToManifest.java b/taverna-robundle/src/main/java/org/apache/taverna/robundle/manifest/RDFToManifest.java
index 6328bb8..4413de9 100644
--- a/taverna-robundle/src/main/java/org/apache/taverna/robundle/manifest/RDFToManifest.java
+++ b/taverna-robundle/src/main/java/org/apache/taverna/robundle/manifest/RDFToManifest.java
@@ -40,6 +40,7 @@ import java.util.logging.Logger;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.RiotException;
+import org.apache.taverna.robundle.Bundles;
import com.hp.hpl.jena.ontology.DatatypeProperty;
import com.hp.hpl.jena.ontology.Individual;
@@ -424,6 +425,13 @@ public class RDFToManifest {
RDFNode created = ro.getPropertyValue(createdOn);
manifest.setCreatedOn(literalAsFileTime(created));
+
+
+ List<Path> history = new ArrayList<Path> ();
+ for (Individual histItem : listObjectProperties (ro, hasProvenance))
+ history.add (Bundles.uriToBundlePath (manifest.getBundle (), relativizeFromBase(histItem.getURI (), root)));
+ manifest.setHistory (history);
+
List<Agent> authors = getAgents(root, ro, authoredBy);
if (!authors.isEmpty())
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/bcc31f8c/taverna-robundle/src/test/java/org/apache/taverna/robundle/manifest/TestManifestJSON.java
----------------------------------------------------------------------
diff --git a/taverna-robundle/src/test/java/org/apache/taverna/robundle/manifest/TestManifestJSON.java b/taverna-robundle/src/test/java/org/apache/taverna/robundle/manifest/TestManifestJSON.java
index ace81e0..f80baea 100644
--- a/taverna-robundle/src/test/java/org/apache/taverna/robundle/manifest/TestManifestJSON.java
+++ b/taverna-robundle/src/test/java/org/apache/taverna/robundle/manifest/TestManifestJSON.java
@@ -21,6 +21,7 @@ package org.apache.taverna.robundle.manifest;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -37,10 +38,6 @@ import java.util.TimeZone;
import org.apache.taverna.robundle.Bundle;
import org.apache.taverna.robundle.Bundles;
-import org.apache.taverna.robundle.manifest.Agent;
-import org.apache.taverna.robundle.manifest.Manifest;
-import org.apache.taverna.robundle.manifest.PathAnnotation;
-import org.apache.taverna.robundle.manifest.PathMetadata;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
@@ -56,8 +53,21 @@ public class TestManifestJSON {
// create history
try (Bundle bundle = Bundles.createBundle())
{
+ Bundles.closeAndSaveBundle (bundle, tmpBundle);
+ }
+ catch (IOException e)
+ {
+ fail ("failed to create bundle for history test: " + e.getMessage ());
+ }
+
+ // make sure it doesn't fail if there is no history
+ try (Bundle bundle = Bundles.openBundle (tmpBundle))
+ {
Manifest manifest = bundle.getManifest();
Path evolutionPath = bundle.getPath(".ro/evolution.ttl");
+ assertFalse ("did not expect a history file", Files.exists (evolutionPath));
+ assertEquals ("did not expect a history", 0, manifest.getHistory ().size ());
+
Files.createDirectories(evolutionPath.getParent());
Bundles.setStringValue(
evolutionPath,
@@ -66,20 +76,21 @@ public class TestManifestJSON {
manifest.getHistory().add(evolutionPath);
assertTrue ("expected a history file", Files.exists (evolutionPath));
assertTrue ("expected a history", manifest.getHistory ().size () > 0);
- Bundles.closeAndSaveBundle (bundle, tmpBundle);
+
+ Bundles.closeBundle (bundle);
}
catch (IOException e)
{
- fail ("failed to create bundle for history test: " + e.getMessage ());
+ fail ("failed to read bundle for history test: " + e.getMessage ());
}
// check if history is still there
- try (Bundle bundle = Bundles.openBundle (tmpBundle))
+ try (Bundle bundle = Bundles.openBundleReadOnly (tmpBundle))
{
Manifest manifest = bundle.getManifest();
Path evolutionPath = bundle.getPath(".ro/evolution.ttl");
assertTrue ("expected a history file", Files.exists (evolutionPath));
- assertTrue ("expected a history", manifest.getHistory ().size () > 0);
+ assertEquals ("expected exactly one history", 1, manifest.getHistory ().size ());
Bundles.closeBundle (bundle);
}
catch (IOException e)