1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 /***
19 * <p>Title: WSMO Studio</p>
20 * <p>Description: Semantic Web Service Editor</p>
21 * <p>Copyright: Copyright (c) 2004-2006</p>
22 * <p>Company: OntoText Lab. / SIRMA </p>
23 */
24
25 package org.wsmostudio.runtime;
26
27 import java.util.HashSet;
28 import java.util.Set;
29
30 import org.omwg.ontology.Ontology;
31 import org.wsmo.common.*;
32 import org.wsmo.common.exception.SynchronisationException;
33 import org.wsmo.locator.Locator;
34 import org.wsmo.mediator.*;
35 import org.wsmo.service.Goal;
36 import org.wsmo.service.WebService;
37 import org.wsmostudio.runtime.cache.WSMOTopEntity;
38
39 public class WorkspaceLocator implements Locator {
40
41 public static final byte PROMPT_FOR_LOADING_IMPORTS = 0;
42 public static final byte ALWAYS_LOAD_IMPORTS = 1;
43 public static final byte NEVER_LOAD_IMPORTS = 2;
44
45 @SuppressWarnings("unchecked")
46 public Set<Entity> lookup(Identifier id) throws SynchronisationException {
47 Set<Entity> result = new HashSet<Entity>();
48 Class[] classes = new Class[] {Ontology.class,
49 Goal.class,
50 WebService.class,
51 Mediator.class,
52 WGMediator.class,
53 OOMediator.class,
54 GGMediator.class,
55 WWMediator.class};
56 Entity entity;
57 for(int i = 0; i < classes.length; i++) {
58 entity = lookup(id, classes[i]);
59 if (entity != null) {
60 result.add(entity);
61 }
62 }
63 return result;
64 }
65
66 @SuppressWarnings("unchecked")
67 public Entity lookup(Identifier id, Class clazz) throws SynchronisationException {
68 if (false == id instanceof IRI) {
69 return null;
70 }
71 if (clazz == Ontology.class) {
72 return WSMORuntime.getIOManager().doLoadOntology(id);
73 }
74 if (clazz == Goal.class) {
75 return WSMORuntime.getIOManager().doLoadGoal(id);
76 }
77 if (clazz == WebService.class) {
78 return WSMORuntime.getIOManager().doLoadWebService(id);
79 }
80 if (clazz == OOMediator.class) {
81 return WSMORuntime.getIOManager().doLoadOOMediator(id);
82 }
83 if (clazz == WWMediator.class) {
84 return WSMORuntime.getIOManager().doLoadWWMediator(id);
85 }
86 if (clazz == WGMediator.class) {
87 return WSMORuntime.getIOManager().doLoadWGMediator(id);
88 }
89 if (clazz == GGMediator.class) {
90 return WSMORuntime.getIOManager().doLoadGGMediator(id);
91 }
92 if (clazz == Mediator.class) {
93 int mediType = WSMORuntime.getCache().getTypeByIRI((IRI)id);
94 switch (mediType) {
95 case WSMOTopEntity.OO_MEDIATOR:
96 return WSMORuntime.getIOManager().doLoadOOMediator(id);
97 case WSMOTopEntity.GG_MEDIATOR:
98 return WSMORuntime.getIOManager().doLoadGGMediator(id);
99 case WSMOTopEntity.WG_MEDIATOR:
100 return WSMORuntime.getIOManager().doLoadWGMediator(id);
101 case WSMOTopEntity.WW_MEDIATOR:
102 return WSMORuntime.getIOManager().doLoadWWMediator(id);
103 }
104 }
105 return null;
106 }
107 }
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124