package ch.tkuhn.hashuri.rdf;

import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;

import org.openrdf.model.URI;
import org.openrdf.rio.RDFFormat;

import ch.tkuhn.hashuri.HashUriResource;
import ch.tkuhn.nanopub.MalformedNanopubException;
import ch.tkuhn.nanopub.Nanopub;
import ch.tkuhn.nanopub.NanopubImpl;

public class TransformNanopub {

	public static void main(String[] args) throws Exception {
		File inputFile = new File(args[0]);
		HashUriResource r = new HashUriResource(inputFile);
		RdfFileContent content = RdfUtils.load(r);
		Nanopub nanopub = null;
		try {
			nanopub = new NanopubImpl(content.getStatements());
		} catch (MalformedNanopubException ex) {
			System.out.println("ERROR: Malformed nanopub: " + ex.getMessage());
			System.exit(1);
		}
		TransformRdf.transform(content, inputFile.getParent(), nanopub.getUri().toString());
	}

	public static URI transform(InputStream in, RDFFormat format, OutputStream out, String baseName) throws Exception {
		return TransformRdf.transform(in, format, out, baseName);
	}

	public static URI transform(InputStream in, OutputStream out, String baseName) throws Exception {
		return transform(in, RDFFormat.TRIG, out, baseName);
	}

}

@@ -423,16 +423,122 @@
 ption %7B%0A
+%09%09if (args.length == 0) %7B%0A%09%09%09System.out.println(%22ERROR: No file given%22);%0A%09%09%7D%0A%09%09for (String arg : args) %7B%0A%09
 %09%09File i
@@ -564,15 +564,12 @@
 (arg
-s%5B0%5D
 );%0A
+%09
 %09%09Ha
@@ -620,16 +620,17 @@
 ile);%0A%09%09
+%09
 RdfFileC
@@ -664,16 +664,17 @@
 oad(r);%0A
+%09
 %09%09Nanopu
@@ -697,14 +697,16 @@
 ;%0A%09%09
+%09
 try %7B%0A
+%09
 %09%09%09n
@@ -758,16 +758,17 @@
 s());%0A%09%09
+%09
 %7D catch 
@@ -796,24 +796,25 @@
 ption ex) %7B%0A
+%09
 %09%09%09System.ou
@@ -871,24 +871,25 @@
 sage());%0A%09%09%09
+%09
 System.exit(
@@ -894,18 +894,20 @@
 t(1);%0A%09%09
+%09
 %7D%0A
+%09
 %09%09Transf
@@ -985,16 +985,20 @@
 ing());%0A
+%09%09%7D%0A
 %09%7D%0A%0A%09pub

Transform multiple nanopubs at once