1 package org.simantics.graph.db;
3 import java.util.Collection;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.WriteOnlyGraph;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.graph.representation.Root;
11 public class WrapperAdvisor implements IImportAdvisor2 {
13 private final IImportAdvisor advisor;
15 public WrapperAdvisor(IImportAdvisor advisor) {
16 this.advisor = advisor;
20 public void redirect(Resource temp) {
21 if(advisor instanceof IImportAdvisor2)
22 ((IImportAdvisor2)advisor).redirect(temp);
26 public Resource getTarget() {
27 if(advisor instanceof IImportAdvisor2)
28 return ((IImportAdvisor2)advisor).getTarget();
33 public Collection<Resource> getRoots() {
34 if(advisor instanceof IImportAdvisor2)
35 return ((IImportAdvisor2)advisor).getRoots();
40 public Collection<RootInfo> getRootInfo() {
41 if(advisor instanceof IImportAdvisor2)
42 return ((IImportAdvisor2)advisor).getRootInfo();
47 public Resource analyzeRoot(ReadGraph graph, Root root) throws DatabaseException {
48 return advisor.analyzeRoot(graph, root);
52 public Resource createRoot(WriteOnlyGraph graph, Root root) throws DatabaseException {
53 return advisor.createRoot(graph, root);
57 public Resource createRoot(WriteOnlyGraph graph, Root root, Resource resource) throws DatabaseException {
58 if(advisor instanceof IImportAdvisor2) {
59 return ((IImportAdvisor2)advisor).createRoot(graph, root, resource);
61 throw new UnsupportedOperationException();
66 public void beforeWrite(WriteOnlyGraph graph, TransferableGraphImporter process)
67 throws DatabaseException {
68 if(advisor instanceof IImportAdvisor2)
69 ((IImportAdvisor2)advisor).beforeWrite(graph, process);
73 public void afterWrite(WriteOnlyGraph graph, TransferableGraphImporter process)
74 throws DatabaseException {
75 if(advisor instanceof IImportAdvisor2)
76 ((IImportAdvisor2)advisor).afterWrite(graph, process);
80 public boolean allowImmutableModifications() {
81 if(advisor instanceof IImportAdvisor2)
82 return ((IImportAdvisor2)advisor).allowImmutableModifications();
88 public Resource createChild(WriteOnlyGraph graph, TransferableGraphImporter process, Resource parent,
89 String name) throws DatabaseException {
90 if(advisor instanceof IImportAdvisor2)
91 return ((IImportAdvisor2)advisor).createChild(graph, process, parent, name);
93 return process.createChild(graph, parent, null, name);
97 public Resource createChild(WriteOnlyGraph graph, TransferableGraphImporter process, Resource parent, Resource child,
98 String name) throws DatabaseException {
99 if(advisor instanceof IImportAdvisor2)
100 return ((IImportAdvisor2)advisor).createChild(graph, process, parent, child, name);
102 return process.createChild(graph, parent, child, name);