1 package org.simantics.graph.db;
3 import java.util.ArrayList;
4 import java.util.Collection;
6 import org.simantics.db.Resource;
7 import org.simantics.graph.representation.Root;
9 abstract public class AbstractImportAdvisor2 implements IImportAdvisor2 {
11 private Collection<RootInfo> rootInfo = new ArrayList<RootInfo>();
13 public Collection<Resource> getRoots() {
14 ArrayList<Resource> result = new ArrayList<Resource>(rootInfo.size());
15 for(RootInfo info : rootInfo) result.add(info.resource);
20 public void redirect(Resource temp) {
24 public Collection<RootInfo> getRootInfo() {
28 public Resource getRoot() {
29 if(rootInfo.size() == 1) return rootInfo.iterator().next().resource;
30 else throw new IllegalStateException("Expected a single root, got " + rootInfo.size() + " roots.");
33 protected void addRootInfo(Root root, String name, Resource resource) {
34 rootInfo.add(new RootInfo(root, name, resource));
37 public Resource getRoot(String name) {
38 for(RootInfo info : getRootInfo())
39 if(info.name.equals(name)) return info.resource;