65e7f956e48190c86201de421edbd4dff983de00
[simantics/platform.git] / bundles / org.simantics.graph / src / org / simantics / graph / refactoring / FixExportedOntology.java
1 package org.simantics.graph.refactoring;\r
2 \r
3 import java.io.BufferedInputStream;\r
4 import java.io.DataInput;\r
5 import java.io.DataInputStream;\r
6 import java.io.File;\r
7 import java.io.FileInputStream;\r
8 import java.io.InputStream;\r
9 \r
10 import org.simantics.databoard.binding.Binding;\r
11 import org.simantics.databoard.binding.mutable.Variant;\r
12 import org.simantics.databoard.container.DataContainer;\r
13 import org.simantics.databoard.container.DataContainers;\r
14 import org.simantics.graph.representation.TransferableGraph1;\r
15 \r
16 public class FixExportedOntology {\r
17         \r
18         public static void main(String[] args) throws Exception {\r
19                 \r
20 //              File input = new File("E:/work/workspace/apros-head/fi.semantum.simupedia.feature/rootfiles/sharedlibraries/SimupediaStandardLibrary-1.3-trunk.sharedLibrary");\r
21                 File input = new File("E:/work/workspace/apros-head/fi.semantum.simupedia.feature/rootfiles/sharedlibraries/AprosSimupedia-1.3-trunk.sharedLibrary");\r
22                 File output = new File(input.getParentFile(), input.getName() + ".fixed");\r
23                 InputStream is = new FileInputStream(input);\r
24 \r
25                 is = new BufferedInputStream(is, 128*1024);\r
26                 \r
27                 DataInput dis = new DataInputStream(is);\r
28                 org.simantics.databoard.container.DataContainer container = \r
29                                 DataContainers.readFile(dis); \r
30                 Binding binding = TransferableGraph1.BINDING;\r
31                 TransferableGraph1 graph = (TransferableGraph1)container.content.getValue(binding);\r
32                 GraphRefactoringUtils.fixOntologyExport(graph);\r
33 \r
34                 DataContainers.writeFile(output, new DataContainer(\r
35                                 container.format, container.version,\r
36                                 container.metadata, new Variant(TransferableGraph1.BINDING, graph)));\r
37                 \r
38         }\r
39         \r
40 \r
41 }\r