1 | 0 | package pt.digitalis.dif.dem.managers.impl; |
2 | |
|
3 | |
import java.util.HashMap; |
4 | |
import java.util.Map; |
5 | |
|
6 | |
import pt.digitalis.dif.dem.DEMRegistryImpl; |
7 | |
import pt.digitalis.dif.dem.Entity; |
8 | |
import pt.digitalis.dif.dem.interfaces.IApplication; |
9 | |
import pt.digitalis.dif.dem.interfaces.IEntity; |
10 | |
import pt.digitalis.dif.dem.interfaces.IProvider; |
11 | |
import pt.digitalis.dif.dem.interfaces.IService; |
12 | |
import pt.digitalis.dif.dem.interfaces.IStage; |
13 | |
import pt.digitalis.dif.dem.managers.IDEMManager; |
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | 0 | public class DEMManagerImpl implements IDEMManager { |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public IApplication getApplication(String applicationID) |
33 | |
{ |
34 | 0 | return DEMRegistryImpl.getRegistry().getApplication(applicationID.toLowerCase()); |
35 | |
} |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
public Map<String, IApplication> getApplications(IProvider provider) |
41 | |
{ |
42 | 0 | Map<String, IApplication> providerApplications = new HashMap<String, IApplication>(); |
43 | |
|
44 | 0 | for (IApplication application: DEMRegistryImpl.getApplications().values()) |
45 | |
{ |
46 | |
|
47 | 0 | if (application.getProvider() != null && application.getProvider().getID().equals(provider.getID())) |
48 | 0 | providerApplications.put(application.getID(), application); |
49 | |
} |
50 | |
|
51 | 0 | return providerApplications; |
52 | |
} |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
public IProvider getDefaultProvider() |
58 | |
{ |
59 | 0 | return DEMRegistryImpl.getDefaultProvider(); |
60 | |
} |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
public IEntity getEntity(Entity type, String entityID) |
66 | |
{ |
67 | 0 | if (Entity.PROVIDER.equals(type)) |
68 | 0 | return getProvider(entityID); |
69 | |
|
70 | 0 | else if (Entity.APPLICATION.equals(type)) |
71 | 0 | return getApplication(entityID); |
72 | |
|
73 | 0 | else if (Entity.SERVICE.equals(type)) |
74 | 0 | return getService(entityID); |
75 | |
|
76 | 0 | else if (Entity.STAGE.equals(type)) |
77 | 0 | return getStage(entityID); |
78 | |
|
79 | |
else |
80 | 0 | return null; |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
} |
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
public IProvider getProvider(String providerID) |
102 | |
{ |
103 | 0 | return DEMRegistryImpl.getRegistry().getProvider(providerID.toLowerCase()); |
104 | |
} |
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
public Map<String, IProvider> getProviders() |
110 | |
{ |
111 | 0 | return DEMRegistryImpl.getProviders(); |
112 | |
} |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
public IService getService(String serviceID) |
118 | |
{ |
119 | 0 | return DEMRegistryImpl.getRegistry().getService(serviceID.toLowerCase()); |
120 | |
} |
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
public Map<String, IService> getServices(IApplication application) |
126 | |
{ |
127 | 0 | Map<String, IService> applicationServices = new HashMap<String, IService>(); |
128 | |
|
129 | 0 | for (IService service: DEMRegistryImpl.getServices().values()) |
130 | |
{ |
131 | |
|
132 | 0 | if (service.getApplication() != null && service.getApplication().getID().equals(application.getID())) |
133 | 0 | applicationServices.put(service.getID(), service); |
134 | |
} |
135 | |
|
136 | 0 | return applicationServices; |
137 | |
} |
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
public IStage getStage(String stageID) |
143 | |
{ |
144 | 0 | return DEMRegistryImpl.getRegistry().getStage(stageID.toLowerCase()); |
145 | |
} |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
public Map<String, IStage> getStages(IService service) |
151 | |
{ |
152 | 0 | Map<String, IStage> serviceStages = new HashMap<String, IStage>(); |
153 | |
|
154 | 0 | for (IStage stage: DEMRegistryImpl.getStages().values()) |
155 | |
{ |
156 | |
|
157 | 0 | if (stage.getService() != null && stage.getService().getID().equals(service.getID())) |
158 | 0 | serviceStages.put(stage.getID(), stage); |
159 | |
} |
160 | |
|
161 | 0 | return serviceStages; |
162 | |
} |
163 | |
} |