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