1 package org.simantics.graph.tests.conversion;
\r
5 import org.simantics.databoard.Files;
\r
6 import org.simantics.databoard.binding.mutable.Variant;
\r
7 import org.simantics.databoard.container.DataContainer;
\r
8 import org.simantics.databoard.container.DataContainers;
\r
9 import org.simantics.graph.representation.TransferableGraph1;
\r
11 public class TG0_TG1 {
\r
13 public static void main(String[] args) throws Exception {
\r
14 if(args.length != 3) {
\r
15 System.err.println(TG0_TG1.class.getName() + " formatName input.tg output.tg");
\r
18 String formatName = args[0];
\r
19 File input = new File(args[1]);
\r
20 File output = new File(args[2]);
\r
22 if(!input.exists()) {
\r
23 System.err.println(input + " does not exist.");
\r
30 DataContainer header = DataContainers.readHeader(input);
\r
31 if (formatName.equals(header.format)) {
\r
32 System.err.println(input + " already has a data container with the required format, version is " + header.version);
\r
35 System.err.println(input + " already has a data container with another format '" + header.format + ", version is " + header.version);
\r
38 } catch (Throwable e) {
\r
39 // There is no DataContainer in the input file yet.
\r
40 // Continue conversion.
\r
43 TransferableGraph0 tg0 = (TransferableGraph0)Files.readFile(input, TransferableGraph0.BINDING);
\r
44 TransferableGraph1 tg1 = new TransferableGraph1(
\r
51 DataContainers.writeFile(output,
\r
52 new DataContainer(formatName, 1, new Variant(TransferableGraph1.BINDING, tg1)));
\r