1 package org.simantics.graph.refactoring;
3 import gnu.trove.map.hash.THashMap;
6 import java.io.IOException;
7 import java.util.ArrayList;
8 import java.util.Collections;
10 import org.simantics.databoard.Files;
11 import org.simantics.graph.query.TransferableGraphConversion;
12 import org.simantics.graph.representation.old.OldTransferableGraph1;
13 import org.simantics.graph.store.IdentityStore;
14 import org.simantics.graph.store.IdentityStore.ConsistsOf;
16 public class PrintReferencesTool {
18 public static void main(String[] args) throws Exception {
19 print(new File(args[0]));
22 public static void print(File input) throws IOException {
23 OldTransferableGraph1 tg = (OldTransferableGraph1)
24 Files.readFile(input, OldTransferableGraph1.BINDING);
25 GraphRefactoringUtils.fixIncorrectRoot(tg.identities);
26 IdentityStore idStore = TransferableGraphConversion.extractIdentities(tg);
27 printExternals(idStore, idStore.getRoot(""), 0);
30 private static void printExternals(IdentityStore idStore, int cur, int indentation) {
31 THashMap<String, ConsistsOf> map = idStore.getChildMap(cur);
34 ArrayList<String> names = new ArrayList<String>(map.keySet());
35 Collections.sort(names);
36 for(String name : names) {
37 ConsistsOf co = map.get(name);
38 if(!idStore.isNewResource(co.child)) {
39 for(int i=0;i<indentation;++i)
40 System.out.print(" ");
41 System.out.println(name);
42 printExternals(idStore, co.child, indentation+1);