1 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 public class DEMManagerImpl implements IDEMManager {
26
27
28
29
30
31
32 public IApplication getApplication(String applicationID)
33 {
34 return DEMRegistryImpl.getRegistry().getApplication(applicationID.toLowerCase());
35 }
36
37
38
39
40 public Map<String, IApplication> getApplications(IProvider provider)
41 {
42 Map<String, IApplication> providerApplications = new HashMap<String, IApplication>();
43
44 for (IApplication application: DEMRegistryImpl.getApplications().values())
45 {
46
47 if (application.getProvider() != null && application.getProvider().getID().equals(provider.getID()))
48 providerApplications.put(application.getID(), application);
49 }
50
51 return providerApplications;
52 }
53
54
55
56
57 public IProvider getDefaultProvider()
58 {
59 return DEMRegistryImpl.getDefaultProvider();
60 }
61
62
63
64
65 public IEntity getEntity(Entity type, String entityID)
66 {
67 if (Entity.PROVIDER.equals(type))
68 return getProvider(entityID);
69
70 else if (Entity.APPLICATION.equals(type))
71 return getApplication(entityID);
72
73 else if (Entity.SERVICE.equals(type))
74 return getService(entityID);
75
76 else if (Entity.STAGE.equals(type))
77 return getStage(entityID);
78
79 else
80 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 return DEMRegistryImpl.getRegistry().getProvider(providerID.toLowerCase());
104 }
105
106
107
108
109 public Map<String, IProvider> getProviders()
110 {
111 return DEMRegistryImpl.getProviders();
112 }
113
114
115
116
117 public IService getService(String serviceID)
118 {
119 return DEMRegistryImpl.getRegistry().getService(serviceID.toLowerCase());
120 }
121
122
123
124
125 public Map<String, IService> getServices(IApplication application)
126 {
127 Map<String, IService> applicationServices = new HashMap<String, IService>();
128
129 for (IService service: DEMRegistryImpl.getServices().values())
130 {
131
132 if (service.getApplication() != null && service.getApplication().getID().equals(application.getID()))
133 applicationServices.put(service.getID(), service);
134 }
135
136 return applicationServices;
137 }
138
139
140
141
142 public IStage getStage(String stageID)
143 {
144 return DEMRegistryImpl.getRegistry().getStage(stageID.toLowerCase());
145 }
146
147
148
149
150 public Map<String, IStage> getStages(IService service)
151 {
152 Map<String, IStage> serviceStages = new HashMap<String, IStage>();
153
154 for (IStage stage: DEMRegistryImpl.getStages().values())
155 {
156
157 if (stage.getService() != null && stage.getService().getID().equals(service.getID()))
158 serviceStages.put(stage.getID(), stage);
159 }
160
161 return serviceStages;
162 }
163 }