1 | 0 | |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
package pt.digitalis.dif.codegen.templates; |
7 | |
|
8 | |
import java.util.Map; |
9 | |
|
10 | |
import pt.digitalis.dif.codegen.CGAncillaries; |
11 | |
import pt.digitalis.dif.dem.interfaces.IApplication; |
12 | |
import pt.digitalis.dif.dem.interfaces.IApplicationPrivate; |
13 | |
import pt.digitalis.dif.dem.interfaces.IProvider; |
14 | |
import pt.digitalis.dif.dem.interfaces.IService; |
15 | |
import pt.digitalis.dif.dem.objects.LicenseEditionType; |
16 | |
import pt.digitalis.dif.exception.manager.RegistrationManagerException; |
17 | |
import pt.digitalis.dif.startup.DIFGeneralConfigurationParameters; |
18 | |
import pt.digitalis.dif.utils.logging.DIFLogger; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | 0 | public class ApplicationCGTemplate implements IApplication, IApplicationPrivate { |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public void __CG__initialize() |
33 | |
{ |
34 | |
|
35 | 0 | } |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
public LicenseEditionType getLicenseEdition() |
41 | |
{ |
42 | |
|
43 | 0 | return TemplateResources.getRegistrationManager().getApplicationEdition(this.getID()); |
44 | |
} |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
public String getID() |
50 | |
{ |
51 | 0 | return CGAncillaries.CG_TO_BE_IMPLEMENTED_MESSAGE; |
52 | |
} |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
public String getMessage(String messageID) |
58 | |
{ |
59 | 0 | return getMessages().get(messageID); |
60 | |
} |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
public Map<String, String> getMessages() |
66 | |
{ |
67 | 0 | return TemplateResources.getMessageManager().getMessages(this, |
68 | 0 | DIFGeneralConfigurationParameters.getInstance().getDefaultLanguage()); |
69 | |
} |
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
public String getName() |
75 | |
{ |
76 | 0 | return CGAncillaries.CG_TO_BE_IMPLEMENTED_MESSAGE; |
77 | |
} |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
public String getOriginalClassName() |
83 | |
{ |
84 | 0 | return CGAncillaries.CG_TO_BE_IMPLEMENTED_MESSAGE; |
85 | |
} |
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
public IProvider getProvider() |
91 | |
{ |
92 | 0 | return TemplateResources.getDEMManager().getProvider(CGAncillaries.CG_TO_BE_IMPLEMENTED_MESSAGE); |
93 | |
} |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
public Map<String, IService> getServices() |
99 | |
{ |
100 | 0 | return TemplateResources.getDEMManager().getServices(this); |
101 | |
} |
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
protected TemplateResources getTemplateResources() |
107 | |
{ |
108 | 0 | return TemplateResources.getInstance(); |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
public String getUID() |
115 | |
{ |
116 | 0 | return "APPLICATION:" + this.getID(); |
117 | |
} |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public boolean isRegistered() |
123 | |
{ |
124 | |
|
125 | 0 | boolean result = this.getProvider().isRegistered(); |
126 | |
|
127 | 0 | if (this.isRegistrable()) |
128 | 0 | result = TemplateResources.getRegistrationManager().isApplicationRegistered(this.getID()); |
129 | |
|
130 | 0 | return result; |
131 | |
} |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
public boolean isRegistrable() |
137 | |
{ |
138 | 0 | return TemplateResources.getRegistrationManager().isApplicationRegistrable(this.getID()); |
139 | |
} |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
public boolean register(String name, String key) |
145 | |
{ |
146 | |
try |
147 | |
{ |
148 | 0 | return TemplateResources.getRegistrationManager().registerApplication(getID(), name, key); |
149 | |
} |
150 | 0 | catch (RegistrationManagerException e) |
151 | |
{ |
152 | 0 | DIFLogger.getLogger().debug(e); |
153 | 0 | return false; |
154 | |
} |
155 | |
} |
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
public void unregister() |
161 | |
{ |
162 | 0 | TemplateResources.getRegistrationManager().unregisterApplication(getID()); |
163 | 0 | } |
164 | |
} |