clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1054010 - in /incubator/clerezza/trunk/org.apache.clerezza.parent: org.apache.clerezza.platform.config/src/main/java/org/apache/clerezza/platform/config/ org.apache.clerezza.platform.language/org.apache.clerezza.platform.language.core/src/...
Date Thu, 30 Dec 2010 22:14:33 GMT
Author: reto
Date: Thu Dec 30 22:14:32 2010
New Revision: 1054010

URL: http://svn.apache.org/viewvc?rev=1054010&view=rev
Log:
CLEREZZA-366: support for parsing into an existing MGraph

Modified:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.config/src/main/java/org/apache/clerezza/platform/config/SystemConfig.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.language/org.apache.clerezza.platform.language.core/src/main/java/org/apache/clerezza/platform/language/LanguageService.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/ParsingProvider.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/serializedform/ParserTest.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/serializedform/TestServiceManagedProvider.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.jena.parser/src/main/java/org/apache/clerezza/rdf/jena/parser/JenaParserProvider.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.jena.parser/src/test/java/org/apache/clerezza/rdf/jena/parser/JenaParserProviderTest.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfa/src/main/java/org/apache/clerezza/rdf/rdfa/ClerezzaRDFaParser.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParserProviderTest.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializerProviderTest.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupTest.java

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.config/src/main/java/org/apache/clerezza/platform/config/SystemConfig.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.config/src/main/java/org/apache/clerezza/platform/config/SystemConfig.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.config/src/main/java/org/apache/clerezza/platform/config/SystemConfig.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.config/src/main/java/org/apache/clerezza/platform/config/SystemConfig.java
Thu Dec 30 22:14:32 2010
@@ -75,19 +75,19 @@ public class SystemConfig {
 			tcManager.getMGraph(Constants.SYSTEM_GRAPH_URI);
 		} catch (NoSuchEntityException nsee) {
 			MGraph systemGraph = tcManager.createMGraph(Constants.SYSTEM_GRAPH_URI);
-			Graph configGraph = readConfigGraphFile();
 			logger.info("Add initial configuration to system graph");
-			systemGraph.addAll(configGraph);
+			readConfigGraphFile(systemGraph);
+			
 		}
 	}
 
-	private Graph readConfigGraphFile() {
+	private void readConfigGraphFile(MGraph mGraph) {
 		URL config = getClass().getResource(CONFIG_FILE);
 		if (config == null) {
 			throw new RuntimeException("no config file found");
 		}
 		try {
-			return parser.parse(config.openStream(),
+			parser.parse(mGraph, config.openStream(),
 					SupportedFormat.RDF_XML, null);
 		} catch (IOException ex) {
 			logger.warn("Cannot parse coniguration at URL: {}", config);

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.language/org.apache.clerezza.platform.language.core/src/main/java/org/apache/clerezza/platform/language/LanguageService.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.language/org.apache.clerezza.platform.language.core/src/main/java/org/apache/clerezza/platform/language/LanguageService.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.language/org.apache.clerezza.platform.language.core/src/main/java/org/apache/clerezza/platform/language/LanguageService.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.language/org.apache.clerezza.platform.language.core/src/main/java/org/apache/clerezza/platform/language/LanguageService.java
Thu Dec 30 22:14:32 2010
@@ -46,6 +46,7 @@ import org.apache.clerezza.rdf.core.UriR
 import org.apache.clerezza.rdf.core.access.LockableMGraph;
 import org.apache.clerezza.rdf.core.access.SecuredMGraph;
 import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 import org.apache.clerezza.rdf.core.impl.TripleImpl;
 import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
 import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
@@ -241,8 +242,10 @@ public class LanguageService {	
 			throw new RuntimeException("no file found");
 		}
 		try {
-			lingvojGraph = parser.parse(config.openStream(),
+			MGraph lingvojMGraph = new SimpleMGraph();
+			parser.parse(lingvojMGraph, config.openStream(),
 					SupportedFormat.RDF_XML, null);
+			lingvojGraph = lingvojMGraph.getGraph();
 			softLingvojGraph = new SoftReference<Graph>(lingvojGraph);
 			return lingvojGraph;
 		} catch (IOException ex) {

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java
Thu Dec 30 22:14:32 2010
@@ -30,7 +30,9 @@ import java.util.ServiceLoader;
 import java.util.Set;
 
 import org.apache.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 
 /**
  * This singleton class provides a method <code>parse</code> to transform 
@@ -125,8 +127,56 @@ public class Parser {
 			String formatIdentifier) throws UnsupportedFormatException {
 		return parse(serializedGraph, formatIdentifier, null);
 	}
+
+	/**
+	 * Parses a serialized Graph from an InputStream. This delegates the
+	 * processing to the provider registered for the specified format, if
+	 * the formatIdentifier contains a ';'-character only the section before
+	 * that character is used for choosing the provider.
+	 *
+	 * @param target the MGraph to which the parsed triples are added
+	 * @param serializedGraph an inputstream with the serialization
+	 * @param formatIdentifier a string identifying the format (usually the MIME-type)
+	 * @throws UnsupportedFormatException
+	 */
+	public void parse(MGraph target, InputStream serializedGraph,
+			String formatIdentifier) throws UnsupportedFormatException {
+		parse(target, serializedGraph, formatIdentifier, null);
+	}
+
+	/**
+	 * Parses a serialized Graph from an InputStream. This delegates the
+	 * processing to the provider registered for the specified format, if
+	 * the formatIdentifier contains a ';'-character only the section before
+	 * that character is used for choosing the provider.
+	 *
+	 * @param serializedGraph an inputstream with the serialization
+	 * @param formatIdentifier a string identifying the format (usually the MIME-type)
+	 * @param baseUri the uri against which relative uri-refs are evaluated
+	 * @return the graph read from the stream
+	 * @throws UnsupportedFormatException
+	 */
 	public Graph parse(InputStream serializedGraph,
 			String formatIdentifier, UriRef baseUri) throws UnsupportedFormatException {
+		MGraph mGraph = new SimpleMGraph();
+		parse(mGraph, serializedGraph, formatIdentifier, baseUri);
+		return mGraph.getGraph();
+	}
+
+	/**
+	 * Parses a serialized Graph from an InputStream. This delegates the
+	 * processing to the provider registered for the specified format, if
+	 * the formatIdentifier contains a ';'-character only the section before
+	 * that character is used for choosing the provider.
+	 *
+	 * @param target the MGraph to which the parsed triples are added
+	 * @param serializedGraph an inputstream with the serialization
+	 * @param formatIdentifier a string identifying the format (usually the MIME-type)
+	 * @param baseUri the uri against which relative uri-refs are evaluated
+	 * @throws UnsupportedFormatException
+	 */
+	public void parse(MGraph target, InputStream serializedGraph,
+			String formatIdentifier, UriRef baseUri) throws UnsupportedFormatException {
 		String deParameterizedIdentifier;
 		int semicolonPos = formatIdentifier.indexOf(';');
 		if (semicolonPos > -1) {
@@ -138,7 +188,7 @@ public class Parser {
 		if (provider == null) {
 			throw new UnsupportedParsingFormatException(formatIdentifier);
 		}
-		return provider.parse(serializedGraph, formatIdentifier, baseUri);
+		provider.parse(target, serializedGraph, formatIdentifier, baseUri);
 	}
 	
 	/**

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/ParsingProvider.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/ParsingProvider.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/ParsingProvider.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/ParsingProvider.java
Thu Dec 30 22:14:32 2010
@@ -20,7 +20,7 @@ package org.apache.clerezza.rdf.core.ser
 
 import java.io.InputStream;
 
-import org.apache.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.UriRef;
 
 /**
@@ -38,11 +38,12 @@ public interface ParsingProvider {
 	 * before a ';'-character in the <code>formatIdentifier</code> matches
 	 * a <code>SupportedFormat</code> annotation of the implementing class.
 	 *
+	 * @param target the mutable graph to which the read triples shall be added
 	 * @param serializedGraph the stream from which the serialized graph is read
 	 * @param formatIdentifier a String identifying the format
 	 * @param baseUri the baseUri for interpreting relative uris, may be null
-	 * @return the graph read from <code>serializedGraph</code>
 	 */
-	Graph parse(InputStream serializedGraph, String formatIdentifier, UriRef baseUri);
+	void parse(MGraph target, InputStream serializedGraph,
+			String formatIdentifier, UriRef baseUri);
 
 }

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/serializedform/ParserTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/serializedform/ParserTest.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/serializedform/ParserTest.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/serializedform/ParserTest.java
Thu Dec 30 22:14:32 2010
@@ -72,18 +72,16 @@ public class ParserTest {
 	static class ParsingProviderA implements ParsingProvider {
 
 		@Override
-		public Graph parse(InputStream serializedGraph, String formatIdentifier, UriRef baseUri)
{
+		public void parse(MGraph target, InputStream serializedGraph, String formatIdentifier,
UriRef baseUri) {
 			providerAInvoked = true;
-			return null;
 		}
 	};
 	@SupportedFormat("application/x-fantasy2+rdf")
 	static class ParsingProviderB implements ParsingProvider {
 
 		@Override
-		public Graph parse(InputStream serializedGraph, String formatIdentifier, UriRef baseUri)
{
+		public void parse(MGraph target, InputStream serializedGraph, String formatIdentifier,
UriRef baseUri) {
 			providerBInvoked = true;
-			return null;
 		}
 	};
 }

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/serializedform/TestServiceManagedProvider.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/serializedform/TestServiceManagedProvider.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/serializedform/TestServiceManagedProvider.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/test/java/org/apache/clerezza/rdf/core/serializedform/TestServiceManagedProvider.java
Thu Dec 30 22:14:32 2010
@@ -19,9 +19,9 @@
 package org.apache.clerezza.rdf.core.serializedform;
 
 import java.io.InputStream;
+import org.apache.clerezza.rdf.core.MGraph;
 import org.junit.Assert;
 import org.junit.Test;
-import org.apache.clerezza.rdf.core.Graph;
 import org.apache.clerezza.rdf.core.UriRef;
 
 /**
@@ -36,11 +36,10 @@ public class TestServiceManagedProvider 
 	private static boolean parseInvoked;
 
 	@Override
-	public Graph parse(InputStream serializedGraph, String formatIdentifier, UriRef baseUri)
{
+	public void parse(MGraph target, InputStream serializedGraph, String formatIdentifier, UriRef
baseUri) {
 		parseInvoked = true;
-		return null;
 	}
-
+	
 	@Test
 	public void registerOneProvider() {
 		Parser parser = Parser.getInstance();

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.jena.parser/src/main/java/org/apache/clerezza/rdf/jena/parser/JenaParserProvider.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.jena.parser/src/main/java/org/apache/clerezza/rdf/jena/parser/JenaParserProvider.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.jena.parser/src/main/java/org/apache/clerezza/rdf/jena/parser/JenaParserProvider.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.jena.parser/src/main/java/org/apache/clerezza/rdf/jena/parser/JenaParserProvider.java
Thu Dec 30 22:14:32 2010
@@ -55,10 +55,9 @@ import org.apache.clerezza.rdf.core.seri
 public class JenaParserProvider implements ParsingProvider {
 
 	@Override
-	public Graph parse(InputStream serializedGraph, String formatIdentifier, UriRef baseUri)
{
+	public void parse(MGraph target, InputStream serializedGraph, String formatIdentifier, UriRef
baseUri) {
 		String jenaFormat = getJenaFormat(formatIdentifier);
-		MGraph mResult = new SimpleMGraph();
-		com.hp.hpl.jena.graph.Graph graph = new JenaGraph(mResult);
+		com.hp.hpl.jena.graph.Graph graph = new JenaGraph(target);
 		Model model = ModelFactory.createModelForGraph(graph);
 		String base;
 		if (baseUri == null) {
@@ -67,7 +66,6 @@ public class JenaParserProvider implemen
 			base = baseUri.getUnicodeString();
 		}
 		model.read(serializedGraph, base, jenaFormat);
-		return mResult.getGraph();
 	}
 
 	private String getJenaFormat(String formatIdentifier) {

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.jena.parser/src/test/java/org/apache/clerezza/rdf/jena/parser/JenaParserProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.jena.parser/src/test/java/org/apache/clerezza/rdf/jena/parser/JenaParserProviderTest.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.jena.parser/src/test/java/org/apache/clerezza/rdf/jena/parser/JenaParserProviderTest.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.jena.parser/src/test/java/org/apache/clerezza/rdf/jena/parser/JenaParserProviderTest.java
Thu Dec 30 22:14:32 2010
@@ -23,8 +23,10 @@ import java.io.InputStream;
 import org.junit.Assert;
 import org.junit.Test;
 import org.apache.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
-import org.apache.clerezza.rdf.jena.facade.JenaGraph;
 
 
 
@@ -42,16 +44,9 @@ public class JenaParserProviderTest {
 		ParsingProvider provider = new JenaParserProvider();
 		InputStream nTriplesIn = getClass().getResourceAsStream("test-04.nt");
 		InputStream turtleIn = getClass().getResourceAsStream("test-04.ttl");
-		Graph graphFromNTriples = provider.parse(nTriplesIn, "text/rdf+nt", null);
-		Graph graphFromTurtle = provider.parse(turtleIn, "text/turtle", null);
-		//due to http://issues.trialox.org/jira/browse/RDF-6 we cannot just check
-		//that the two graphs are equals
-		Assert.assertEquals(graphFromNTriples.size(), graphFromTurtle.size());
-		Assert.assertEquals(graphFromNTriples.hashCode(), graphFromTurtle.hashCode());
-		//isomorphism delegated to jena
-		JenaGraph jenaGraphFromNTriples = new JenaGraph(graphFromNTriples);
-		JenaGraph jenaGraphFromTurtle = new JenaGraph(graphFromTurtle);
-		Assert.assertTrue(jenaGraphFromNTriples.isIsomorphicWith(jenaGraphFromTurtle));
+		Graph graphFromNTriples = parse(provider, nTriplesIn, "text/rdf+nt", null);
+		Graph graphFromTurtle = parse(provider, turtleIn, "text/turtle", null);
+		Assert.assertEquals(graphFromNTriples, graphFromTurtle);
 	}
 
 	/*
@@ -62,16 +57,9 @@ public class JenaParserProviderTest {
 		ParsingProvider provider = new JenaParserProvider();
 		InputStream nTriplesIn = getClass().getResourceAsStream("test-04.nt");
 		InputStream rdfIn = getClass().getResourceAsStream("test-04.rdf");
-		Graph graphFromNTriples = provider.parse(nTriplesIn, "text/rdf+nt", null);
-		Graph graphFromTurtle = provider.parse(rdfIn, "application/rdf+xml", null);
-		//due to http://issues.trialox.org/jira/browse/RDF-6 we cannot just check
-		//that the two graphs are equals
-		Assert.assertEquals(graphFromNTriples.size(), graphFromTurtle.size());
-		Assert.assertEquals(graphFromNTriples.hashCode(), graphFromTurtle.hashCode());
-		//isomorphism delegated to jena
-		JenaGraph jenaGraphFromNTriples = new JenaGraph(graphFromNTriples);
-		JenaGraph jenaGraphFromTurtle = new JenaGraph(graphFromTurtle);
-		Assert.assertTrue(jenaGraphFromNTriples.isIsomorphicWith(jenaGraphFromTurtle));
+		Graph graphFromNTriples = parse(provider, nTriplesIn, "text/rdf+nt", null);
+		Graph graphFromTurtle = parse(provider, rdfIn, "application/rdf+xml", null);
+		Assert.assertEquals(graphFromNTriples, graphFromTurtle);
 	}
 	
 	@Test
@@ -79,16 +67,15 @@ public class JenaParserProviderTest {
 		ParsingProvider provider = new JenaParserProvider();
 		InputStream nTriplesIn = getClass().getResourceAsStream("test-04.nt");
 		InputStream turtleIn = getClass().getResourceAsStream("test-04.ttl");
-		Graph graphFromNTriples = provider.parse(nTriplesIn, "text/rdf+nt", null);
-		Graph graphFromTurtle = provider.parse(turtleIn, "text/turtle;charset=UTF-", null);
-		//due to http://issues.trialox.org/jira/browse/RDF-6 we cannot just check
-		//that the two graphs are equals
-		Assert.assertEquals(graphFromNTriples.size(), graphFromTurtle.size());
-		Assert.assertEquals(graphFromNTriples.hashCode(), graphFromTurtle.hashCode());
-		//isomorphism delegated to jena
-		JenaGraph jenaGraphFromNTriples = new JenaGraph(graphFromNTriples);
-		JenaGraph jenaGraphFromTurtle = new JenaGraph(graphFromTurtle);
-		Assert.assertTrue(jenaGraphFromNTriples.isIsomorphicWith(jenaGraphFromTurtle));
+		Graph graphFromNTriples = parse(provider, nTriplesIn, "text/rdf+nt", null);
+		Graph graphFromTurtle = parse(provider, turtleIn, "text/turtle;charset=UTF-", null);
+		Assert.assertEquals(graphFromNTriples, graphFromTurtle);
+	}
+
+	private Graph parse(ParsingProvider parsingProvider, InputStream in, String type, UriRef
base) {
+		MGraph simpleMGraph = new SimpleMGraph();
+		parsingProvider.parse(simpleMGraph, in, type, base);
+		return simpleMGraph.getGraph();
 	}
 
 }

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfa/src/main/java/org/apache/clerezza/rdf/rdfa/ClerezzaRDFaParser.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfa/src/main/java/org/apache/clerezza/rdf/rdfa/ClerezzaRDFaParser.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfa/src/main/java/org/apache/clerezza/rdf/rdfa/ClerezzaRDFaParser.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfa/src/main/java/org/apache/clerezza/rdf/rdfa/ClerezzaRDFaParser.java
Thu Dec 30 22:14:32 2010
@@ -40,20 +40,19 @@ import org.xml.sax.XMLReader;
 public abstract class ClerezzaRDFaParser implements ParsingProvider {
 
 	private static Logger log = LoggerFactory.getLogger(ClerezzaRDFaParser.class);
-	private MGraph mGraph = new SimpleMGraph();
+
 
 	@Override
-	public Graph parse(InputStream in, String formatIdentifier, UriRef baseUri) {
+	public void parse(MGraph target, InputStream in, String formatIdentifier, UriRef baseUri)
{
 		try {
-			parse(new InputSource(in), baseUri);
+			parse(target, new InputSource(in), baseUri);
 		} catch (IOException e) {
 			throw new RuntimeException(e);
 		}
-		return mGraph.getGraph();
 	}
 
-	private void parse(InputSource in, UriRef baseURI) throws IOException {
-		Parser parser = new Parser(new ClerezzaStatementSink(mGraph));
+	private void parse(MGraph target, InputSource in, UriRef baseURI) throws IOException {
+		Parser parser = new Parser(new ClerezzaStatementSink(target));
 		if (baseURI != null) {
 			parser.setBase(baseURI.getUnicodeString());
 		} else {

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/main/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParsingProvider.java
Thu Dec 30 22:14:32 2010
@@ -57,9 +57,8 @@ public class RdfJsonParsingProvider impl
 	private final Logger logger = LoggerFactory.getLogger(getClass());
 
 	@Override
-	public Graph parse(InputStream serializedGraph, String formatIdentifier, UriRef baseUri)
{
+	public void parse(MGraph target, InputStream serializedGraph, String formatIdentifier, UriRef
baseUri) {
 
-		MGraph mGraph = new SimpleMGraph();
 		JSONParser parser = new JSONParser();
 		InputStreamReader reader = new InputStreamReader(serializedGraph);
 		try {
@@ -68,7 +67,7 @@ public class RdfJsonParsingProvider impl
 			for (String keyString : subjects.keySet()) {
 				NonLiteral key = subjects.get(keyString);
 				JSONObject predicates = (JSONObject) root.get(keyString);
-				addValuesToGraph(key, subjects, predicates, mGraph);
+				addValuesToGraph(key, subjects, predicates, target);
 			}
 		} catch (IOException ioe) {
 			logger.error(ioe.getMessage());
@@ -77,7 +76,6 @@ public class RdfJsonParsingProvider impl
 			logger.error(pe.getMessage());
 			throw new RuntimeException(pe.getMessage());
 		}
-		return mGraph.getGraph();
 	}
 
 	private Map<String, NonLiteral> createSubjectsFromJSONObjects(

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParserProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParserProviderTest.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParserProviderTest.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/parser/RdfJsonParserProviderTest.java
Thu Dec 30 22:14:32 2010
@@ -24,8 +24,10 @@ import java.util.Iterator;
 import org.junit.Assert;
 import org.junit.Test;
 import org.apache.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.Triple;
 import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
 
 
@@ -41,9 +43,10 @@ public class RdfJsonParserProviderTest {
 	public void testParser() {
 		ParsingProvider provider = new RdfJsonParsingProvider();
 		InputStream jsonIn = getClass().getResourceAsStream("test.json");
-		Graph graphFromJsonRdf = provider.parse(jsonIn, "application/rdf+json", null);
-		Assert.assertEquals(graphFromJsonRdf.size(), 6);
-		Iterator<Triple> triples = graphFromJsonRdf.filter(new UriRef("http://base/child1"),
null, null);
+		MGraph deserializedMGraph = new SimpleMGraph();
+		provider.parse(deserializedMGraph, jsonIn, "application/rdf+json", null);
+		Assert.assertEquals(deserializedMGraph.size(), 6);
+		Iterator<Triple> triples = deserializedMGraph.filter(new UriRef("http://base/child1"),
null, null);
 		while(triples.hasNext()) {
 			UriRef uri = triples.next().getPredicate();
 			Assert.assertEquals(uri.getUnicodeString(), "http://base/propertyB");

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializerProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializerProviderTest.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializerProviderTest.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.rdfjson/src/test/java/org/apache/clerezza/rdf/rdfjson/serializer/RdfJsonSerializerProviderTest.java
Thu Dec 30 22:14:32 2010
@@ -79,9 +79,10 @@ public class RdfJsonSerializerProviderTe
 		ParsingProvider parsingProvider = new RdfJsonParsingProvider();
 		ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph
 				.toByteArray());
-		Graph graphFromJsonRdf = parsingProvider.parse(jsonIn,
-				"application/rdf+json", null);
-		Assert.assertEquals(graphFromJsonRdf.size(), 6);
+		MGraph deserializedMGraph = new SimpleMGraph();
+		parsingProvider.parse(deserializedMGraph, jsonIn, "application/rdf+json", null);
+		Assert.assertEquals(6, deserializedMGraph.size());
+		Assert.assertEquals(mGraph.getGraph(), deserializedMGraph.getGraph());
 
 	}
 }

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupTest.java?rev=1054010&r1=1054009&r2=1054010&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupTest.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupTest.java
Thu Dec 30 22:14:32 2010
@@ -21,6 +21,7 @@ package org.apache.clerezza.rdf.web.core
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
@@ -36,6 +37,8 @@ import org.apache.clerezza.rdf.core.acce
 import org.apache.clerezza.rdf.core.access.TcManager;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
 import org.apache.clerezza.rdf.core.serializedform.Serializer;
 import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
 import org.apache.clerezza.rdf.jena.parser.JenaParserProvider;
@@ -69,7 +72,7 @@ public class BackupTest {
 
 	private static String backupContentFileName = "triplecollections.nt";
 	private static BackupMessageBodyWriter backup;
-	private static JenaParserProvider parser = new JenaParserProvider();
+	private static Parser parser = Parser.getInstance();
 
 	@Before
 	public void setUp() {



Mime
View raw message