1 | |
package org.jtheque.films; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.Managers; |
20 | |
import org.jtheque.core.managers.beans.IBeansManager; |
21 | |
import org.jtheque.core.managers.error.IErrorManager; |
22 | |
import org.jtheque.core.managers.error.InternationalizedError; |
23 | |
import org.jtheque.core.managers.feature.Feature; |
24 | |
import org.jtheque.core.managers.feature.Feature.FeatureType; |
25 | |
import org.jtheque.core.managers.feature.IFeatureManager; |
26 | |
import org.jtheque.core.managers.feature.IFeatureManager.CoreFeature; |
27 | |
import org.jtheque.core.managers.file.IFileManager; |
28 | |
import org.jtheque.core.managers.file.able.FileType; |
29 | |
import org.jtheque.core.managers.log.ILoggingManager; |
30 | |
import org.jtheque.core.managers.module.annotations.Module; |
31 | |
import org.jtheque.core.managers.module.annotations.Plug; |
32 | |
import org.jtheque.core.managers.module.annotations.PrePlug; |
33 | |
import org.jtheque.core.managers.module.annotations.UnPlug; |
34 | |
import org.jtheque.core.managers.module.beans.CollectionBasedModule; |
35 | |
import org.jtheque.core.managers.schema.ISchemaManager; |
36 | |
import org.jtheque.core.managers.schema.Schema; |
37 | |
import org.jtheque.core.managers.state.IStateManager; |
38 | |
import org.jtheque.core.managers.state.StateException; |
39 | |
import org.jtheque.core.managers.update.IUpdateManager; |
40 | |
import org.jtheque.core.managers.view.able.IViewManager; |
41 | |
import org.jtheque.core.managers.view.able.components.TabComponent; |
42 | |
import org.jtheque.core.managers.view.impl.components.config.ConfigTabComponent; |
43 | |
import org.jtheque.core.utils.ui.constraints.ConstraintManager; |
44 | |
import org.jtheque.core.utils.ui.constraints.MaxLengthConstraint; |
45 | |
import org.jtheque.core.utils.ui.constraints.NotNullConstraint; |
46 | |
import org.jtheque.films.persistence.FilmsSchema; |
47 | |
import org.jtheque.films.services.able.IActorService; |
48 | |
import org.jtheque.films.services.able.IFilmsService; |
49 | |
import org.jtheque.films.services.able.IRealizersService; |
50 | |
import org.jtheque.films.services.impl.utils.closures.LendingCheckClosure; |
51 | |
import org.jtheque.films.services.impl.utils.config.ConfigManager; |
52 | |
import org.jtheque.films.services.impl.utils.config.Configuration; |
53 | |
import org.jtheque.films.services.impl.utils.file.backup.JTDBackupWriter; |
54 | |
import org.jtheque.films.services.impl.utils.file.backup.XMLBackupWriter; |
55 | |
import org.jtheque.films.services.impl.utils.file.restore.DBV3BackupReader; |
56 | |
import org.jtheque.films.services.impl.utils.file.restore.DBV4BackupReader; |
57 | |
import org.jtheque.films.services.impl.utils.file.restore.JTDBackupReader; |
58 | |
import org.jtheque.films.services.impl.utils.file.restore.XMLBackupReader; |
59 | |
import org.jtheque.films.services.impl.utils.web.GettersUpdatable; |
60 | |
import org.jtheque.films.utils.Constants; |
61 | |
import org.jtheque.films.utils.Constants.Properties.Film; |
62 | |
import org.jtheque.films.utils.Constants.Properties.Kind; |
63 | |
import org.jtheque.films.utils.Constants.Properties.Person; |
64 | |
import org.jtheque.films.utils.Constants.Properties.Publication; |
65 | |
import org.jtheque.films.utils.Constants.Properties.Saga; |
66 | |
import org.jtheque.films.utils.Constants.Properties.Type; |
67 | |
import org.jtheque.primary.PrimaryUtils; |
68 | |
import org.jtheque.primary.services.able.ICollectionsService; |
69 | |
import org.jtheque.primary.services.able.IKindsService; |
70 | |
import org.jtheque.primary.services.able.ILendingsService; |
71 | |
import org.jtheque.primary.services.able.ISagasService; |
72 | |
import org.jtheque.primary.services.able.ITypesService; |
73 | |
import org.jtheque.primary.utils.DataTypeManager; |
74 | |
import org.jtheque.primary.view.impl.choice.ChoiceAction; |
75 | |
import org.jtheque.primary.view.impl.choice.ChoiceActionFactory; |
76 | |
import org.jtheque.primary.view.impl.sort.Sorter; |
77 | |
import org.jtheque.primary.view.impl.sort.SorterFactory; |
78 | |
import org.jtheque.utils.collections.ArrayUtils; |
79 | |
import org.jtheque.utils.collections.CollectionUtils; |
80 | |
|
81 | |
import javax.swing.*; |
82 | |
import java.awt.*; |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
@Module(id = "jtheque-films-module", i18n = "classpath:org/jtheque/films/i18n/films", version = "1.4.2", core = "2.0.2", |
90 | |
jarFile = "jtheque-films-module-1.4.2.jar", updateURL = "http://jtheque.developpez.com/public/versions/FilmsModule.versions") |
91 | |
public final class FilmsModule implements CollectionBasedModule, IFilmsModule { |
92 | |
private ConfigManager config; |
93 | |
|
94 | |
private final ConfigTabComponent[] configTabComponents; |
95 | |
private final TabComponent[] tabComponents; |
96 | |
private final Sorter[] sorters; |
97 | |
private final ChoiceAction[] choiceActions; |
98 | |
|
99 | |
|
100 | |
private Feature sitesFeature; |
101 | |
private Feature refreshFeature; |
102 | |
private Feature printFeature; |
103 | |
private Feature exportFeature; |
104 | |
private Feature importFolderFeature; |
105 | |
private Feature importFeature; |
106 | |
private Feature searchFeature; |
107 | |
private Feature filmsFeature; |
108 | |
private Feature actorsFeature; |
109 | |
private Feature realizersFeature; |
110 | |
private Feature lendingsFeature; |
111 | |
private Feature othersFeature; |
112 | |
private Feature publicationFeature; |
113 | |
private Feature videoFeature; |
114 | |
private Feature coverFeature; |
115 | |
|
116 | |
|
117 | |
private JTDBackupWriter jtdWriter; |
118 | |
private XMLBackupWriter xmlWriter; |
119 | |
private XMLBackupReader xmlReader; |
120 | |
private JTDBackupReader jtdReader; |
121 | |
private DBV3BackupReader dbv3Reader; |
122 | |
private DBV4BackupReader dbv4Reader; |
123 | |
|
124 | |
private Schema schema; |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
public FilmsModule(ChoiceAction[] choiceActions, TabComponent[] tabComponents, Sorter[] sorters, ConfigTabComponent[] configTabComponents) { |
135 | 0 | super(); |
136 | |
|
137 | 0 | this.choiceActions = ArrayUtils.copyOf(choiceActions); |
138 | 0 | this.tabComponents = ArrayUtils.copyOf(tabComponents); |
139 | 0 | this.sorters = ArrayUtils.copyOf(sorters); |
140 | 0 | this.configTabComponents = ArrayUtils.copyOf(configTabComponents); |
141 | 0 | } |
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
@PrePlug |
147 | |
public void prePlug() { |
148 | 0 | Managers.getManager(IUpdateManager.class).registerUpdatable(GettersUpdatable.getInstance()); |
149 | |
|
150 | 0 | PrimaryUtils.setPrimaryImpl("Films"); |
151 | 0 | PrimaryUtils.prePlug(); |
152 | |
|
153 | 0 | schema = new FilmsSchema(); |
154 | |
|
155 | 0 | Managers.getManager(ISchemaManager.class).registerSchema(schema); |
156 | 0 | } |
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
@Plug |
162 | |
public void plug() { |
163 | 0 | loadConfiguration(); |
164 | |
|
165 | 0 | PrimaryUtils.plug(); |
166 | |
|
167 | 0 | DataTypeManager.bindDataTypeToKey(IFilmsService.DATA_TYPE, "film.data.title"); |
168 | 0 | DataTypeManager.bindDataTypeToKey(IActorService.DATA_TYPE, "actor.data.title"); |
169 | 0 | DataTypeManager.bindDataTypeToKey(IRealizersService.DATA_TYPE, "realizer.data.title"); |
170 | 0 | DataTypeManager.bindDataTypeToKey(ITypesService.DATA_TYPE, "type.data.title"); |
171 | 0 | DataTypeManager.bindDataTypeToKey(IKindsService.DATA_TYPE, "kind.data.title"); |
172 | 0 | DataTypeManager.bindDataTypeToKey(ISagasService.DATA_TYPE, "saga.data.title"); |
173 | |
|
174 | 0 | for (Sorter sorter : sorters) { |
175 | 0 | SorterFactory.getInstance().addSorter(sorter); |
176 | |
} |
177 | |
|
178 | 0 | addFeatures(); |
179 | |
|
180 | 0 | for (ConfigTabComponent component : configTabComponents) { |
181 | 0 | Managers.getManager(IViewManager.class).addConfigTabComponent(component); |
182 | |
} |
183 | 0 | } |
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
private void loadConfiguration() { |
189 | 0 | config = Managers.getManager(IStateManager.class).getState(ConfigManager.class); |
190 | |
|
191 | 0 | if (config == null) { |
192 | |
try { |
193 | 0 | config = Managers.getManager(IStateManager.class).createState(ConfigManager.class); |
194 | 0 | } catch (StateException e) { |
195 | 0 | Managers.getManager(ILoggingManager.class).getLogger(getClass()).error(e); |
196 | 0 | config = new ConfigManager(); |
197 | 0 | Managers.getManager(IErrorManager.class).addError(new InternationalizedError("error.loading.configuration")); |
198 | 0 | } |
199 | |
|
200 | 0 | config.setDefaults(); |
201 | |
} |
202 | 0 | } |
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
private void addFeatures() { |
208 | 0 | IFeatureManager manager = Managers.getManager(IFeatureManager.class); |
209 | |
|
210 | 0 | addHelpFeatures(manager); |
211 | 0 | addFileFeatures(manager); |
212 | 0 | addEmptyFeatures(manager); |
213 | 0 | addLendingsFeature(manager); |
214 | 0 | addOthersFeature(manager); |
215 | |
|
216 | 0 | videoFeature = manager.addSubFeature(manager.getFeature(CoreFeature.ADVANCED), "openVideoViewAction", FeatureType.SEPARATED_ACTION, 500); |
217 | 0 | } |
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
private void addHelpFeatures(IFeatureManager manager) { |
225 | 0 | sitesFeature = manager.addSubFeature(manager.getFeature(CoreFeature.HELP), "openSitesViewAction", FeatureType.ACTION, 2); |
226 | 0 | } |
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
private void addLendingsFeature(IFeatureManager manager) { |
234 | 0 | lendingsFeature = manager.createFeature(400, FeatureType.PACK, "menu.jtheque.lendings"); |
235 | |
|
236 | 0 | manager.addSubFeature(lendingsFeature, "openLendingsViewAction", FeatureType.ACTION, 1, Constants.IMAGE_BASE_NAME, "lendings"); |
237 | 0 | manager.addSubFeature(lendingsFeature, "lendFilmAction", FeatureType.ACTION, 2); |
238 | 0 | manager.addSubFeature(lendingsFeature, "returnFilmAction", FeatureType.ACTION, 3); |
239 | |
|
240 | 0 | manager.addFeature(lendingsFeature); |
241 | 0 | } |
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
private void addEmptyFeatures(IFeatureManager manager) { |
249 | 0 | manager.addFeature(realizersFeature = manager.createFeature(300, FeatureType.PACK, "menu.jtheque.realizers")); |
250 | 0 | manager.addFeature(actorsFeature = manager.createFeature(200, FeatureType.PACK, "menu.jtheque.actors")); |
251 | 0 | manager.addFeature(filmsFeature = manager.createFeature(100, FeatureType.PACK, "menu.jtheque.films")); |
252 | 0 | } |
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
private void addFileFeatures(IFeatureManager manager) { |
260 | 0 | refreshFeature = manager.addSubFeature(manager.getFeature(CoreFeature.FILE), "refreshListAction", FeatureType.ACTION, 100); |
261 | |
|
262 | 0 | printFeature = manager.addSubFeature(manager.getFeature(CoreFeature.FILE), "printListAction", FeatureType.ACTION, 101); |
263 | |
|
264 | 0 | publicationFeature = manager.addSubFeature(manager.getFeature(CoreFeature.FILE), "openPublicationViewAction", FeatureType.ACTION, 102); |
265 | |
|
266 | 0 | addExportFeatures(manager); |
267 | 0 | addImportFeatures(manager); |
268 | |
|
269 | 0 | coverFeature = manager.addSubFeature(manager.getFeature(CoreFeature.FILE), "openCoverViewAction", FeatureType.SEPARATED_ACTION, 105); |
270 | |
|
271 | 0 | importFolderFeature = manager.addSubFeature(manager.getFeature(CoreFeature.FILE), "openAutoImportViewAction", FeatureType.ACTION, 106); |
272 | |
|
273 | 0 | searchFeature = manager.createFeature(100, FeatureType.ACTIONS, "menu.jtheque.edit.find"); |
274 | |
|
275 | 0 | addSubFeatures(manager, searchFeature, "searchFilmAction", "searchActorAction", "searchRealizerAction"); |
276 | |
|
277 | 0 | manager.getFeature(CoreFeature.EDIT).addSubFeature(searchFeature); |
278 | 0 | } |
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
|
285 | |
private void addExportFeatures(IFeatureManager manager) { |
286 | 0 | exportFeature = manager.createFeature(103, FeatureType.SEPARATED_ACTIONS, "menu.jtheque.file.export"); |
287 | 0 | exportFeature.setBaseName(Constants.IMAGE_BASE_NAME); |
288 | 0 | exportFeature.setIcon("export"); |
289 | |
|
290 | 0 | addSubFeatures(manager, exportFeature, "exportToExcelAction", "exportToXMLAction", "exportToHTMLAction", |
291 | |
"exportToPDFAction", "exportToTXTAction", "exportToJTFEAction", "exportToCSVAction", "exportToRTFAction"); |
292 | |
|
293 | 0 | manager.getFeature(CoreFeature.FILE).addSubFeature(exportFeature); |
294 | 0 | } |
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
private void addImportFeatures(IFeatureManager manager) { |
302 | 0 | importFeature = manager.createFeature(104, FeatureType.ACTIONS, "menu.jtheque.file.import"); |
303 | 0 | importFeature.setBaseName(Constants.IMAGE_BASE_NAME); |
304 | 0 | importFeature.setIcon("import"); |
305 | |
|
306 | 0 | addSubFeatures(manager, importFeature, "importFromXMLAction", "importFromJTFAction", "importFromJTFEAction"); |
307 | |
|
308 | 0 | manager.getFeature(CoreFeature.FILE).addSubFeature(importFeature); |
309 | 0 | } |
310 | |
|
311 | |
|
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
private void addOthersFeature(IFeatureManager manager) { |
317 | 0 | othersFeature = manager.createFeature(500, FeatureType.PACK, "menu.jtheque.others"); |
318 | |
|
319 | 0 | addNewFeature(manager); |
320 | 0 | addDeleteFeature(manager); |
321 | 0 | addEditFeature(manager); |
322 | |
|
323 | 0 | manager.addFeature(othersFeature); |
324 | 0 | } |
325 | |
|
326 | |
|
327 | |
|
328 | |
|
329 | |
|
330 | |
|
331 | |
private void addNewFeature(IFeatureManager manager) { |
332 | 0 | Feature newFeature = manager.createFeature(1, FeatureType.ACTIONS, "menu.jtheque.others.new"); |
333 | 0 | newFeature.setBaseName(Constants.IMAGE_BASE_NAME); |
334 | 0 | newFeature.setIcon("add_others"); |
335 | |
|
336 | 0 | addSubFeatures(manager, newFeature, "newKindAction", "newTypeAction", "newLanguageMenuAction", |
337 | |
"newBorrowerMenuAction", "newCountryMenuAction", "newSagaAction"); |
338 | |
|
339 | 0 | othersFeature.addSubFeature(newFeature); |
340 | 0 | } |
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
private void addDeleteFeature(IFeatureManager manager) { |
348 | 0 | Feature deleteFeature = manager.createFeature(2, FeatureType.ACTIONS, "menu.jtheque.others.delete"); |
349 | 0 | deleteFeature.setBaseName(Constants.IMAGE_BASE_NAME); |
350 | 0 | deleteFeature.setIcon("delete_others"); |
351 | |
|
352 | 0 | addSubFeatures(manager, deleteFeature, "deleteKindMenuAction", "deleteTypeAction", "deleteLanguageMenuAction", |
353 | |
"deleteCountryMenuAction", "deleteBorrowerMenuAction", "deleteSagaMenuAction"); |
354 | |
|
355 | 0 | othersFeature.addSubFeature(deleteFeature); |
356 | 0 | } |
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
|
363 | |
private void addEditFeature(IFeatureManager manager) { |
364 | 0 | Feature editFeature = manager.createFeature(3, FeatureType.ACTIONS, "menu.jtheque.others.modify"); |
365 | 0 | editFeature.setBaseName(Constants.IMAGE_BASE_NAME); |
366 | 0 | editFeature.setIcon("edit_others"); |
367 | |
|
368 | 0 | addSubFeatures(manager, editFeature, "editKindMenuAction", "editTypeAction", "editLanguageMenuAction", |
369 | |
"editBorrowerMenuAction", "editCountryMenuAction", "editSagaMenuAction"); |
370 | |
|
371 | 0 | othersFeature.addSubFeature(editFeature); |
372 | 0 | } |
373 | |
|
374 | |
private static void addSubFeatures(IFeatureManager manager, Feature parent, String... actions){ |
375 | 0 | for(int i = 0; i < actions.length; i++){ |
376 | 0 | manager.addSubFeature(parent, actions[i], FeatureType.ACTION, i + 1); |
377 | |
} |
378 | 0 | } |
379 | |
|
380 | |
@Override |
381 | |
public boolean chooseCollection(String collection, String password, boolean create) { |
382 | 0 | ICollectionsService collectionsService = Managers.getManager(IBeansManager.class).getBean("collectionsService"); |
383 | |
|
384 | 0 | if (create) { |
385 | 0 | collectionsService.createCollectionAndUse(collection, password); |
386 | 0 | } else if (!collectionsService.login(collection, password)) { |
387 | 0 | return false; |
388 | |
} |
389 | |
|
390 | 0 | return true; |
391 | |
} |
392 | |
|
393 | |
@Override |
394 | |
public void plugCollection() { |
395 | 0 | for (ChoiceAction action : choiceActions) { |
396 | 0 | ChoiceActionFactory.addChoiceAction(action); |
397 | |
} |
398 | |
|
399 | 0 | for (TabComponent component : tabComponents) { |
400 | 0 | Managers.getManager(IViewManager.class).addTabComponent(component); |
401 | |
} |
402 | |
|
403 | 0 | configureBackupAndRestore(); |
404 | |
|
405 | 0 | configureViewConstraints(); |
406 | |
|
407 | 0 | if (getConfiguration().mustControlLendingsOnStartup()) { |
408 | 0 | verifyLendings(); |
409 | |
} |
410 | 0 | } |
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
private static void verifyLendings() { |
416 | 0 | new Thread(new Runnable() { |
417 | |
@Override |
418 | |
public void run() { |
419 | 0 | CollectionUtils.forAllDo( |
420 | |
Managers.getManager(IBeansManager.class).<ILendingsService>getBean("lendingsService").getLendings(), |
421 | |
new LendingCheckClosure()); |
422 | 0 | } |
423 | |
}).start(); |
424 | 0 | } |
425 | |
|
426 | |
|
427 | |
|
428 | |
|
429 | |
private void configureBackupAndRestore() { |
430 | 0 | jtdWriter = new JTDBackupWriter(); |
431 | 0 | xmlWriter = new XMLBackupWriter(); |
432 | |
|
433 | 0 | xmlReader = new XMLBackupReader(); |
434 | 0 | jtdReader = new JTDBackupReader(); |
435 | 0 | dbv3Reader = new DBV3BackupReader(); |
436 | 0 | dbv4Reader = new DBV4BackupReader(); |
437 | |
|
438 | 0 | Managers.getManager(IFileManager.class).registerBackupWriter(FileType.JTD, jtdWriter); |
439 | 0 | Managers.getManager(IFileManager.class).registerBackupWriter(FileType.XML, xmlWriter); |
440 | |
|
441 | 0 | Managers.getManager(IFileManager.class).registerBackupReader(FileType.XML, xmlReader); |
442 | 0 | Managers.getManager(IFileManager.class).registerBackupReader(FileType.JTD, jtdReader); |
443 | 0 | Managers.getManager(IFileManager.class).registerBackupReader(FileType.V3, dbv3Reader); |
444 | 0 | Managers.getManager(IFileManager.class).registerBackupReader(FileType.V4, dbv4Reader); |
445 | 0 | } |
446 | |
|
447 | |
|
448 | |
|
449 | |
|
450 | |
private static void configureViewConstraints() { |
451 | 0 | ConstraintManager.addConstraint(Person.NAME, new MaxLengthConstraint(Person.NAME_MAX_LENGTH, Person.NAME, false, false)); |
452 | 0 | ConstraintManager.addConstraint(Person.FIRST_NAME, new MaxLengthConstraint(Person.FIRST_NAME_MAX_LENGTH, Person.FIRST_NAME, false, false)); |
453 | |
|
454 | 0 | ConstraintManager.addConstraint(Film.TITLE, new MaxLengthConstraint(Film.TITLE_MAX_LENGTH, Film.TITLE, false, false)); |
455 | 0 | ConstraintManager.addConstraint(Film.YEAR, new MaxLengthConstraint(Film.YEAR_MAX_LENGTH, Film.YEAR, false, true)); |
456 | 0 | ConstraintManager.addConstraint(Film.DURATION, new MaxLengthConstraint(Film.DURATION_MAX_LENGTH, Film.DURATION, false, true)); |
457 | 0 | ConstraintManager.addConstraint(Film.RESUME, new MaxLengthConstraint(Film.RESUME_MAX_LENGTH, Film.RESUME, false, false)); |
458 | 0 | ConstraintManager.addConstraint(Film.COMMENT, new MaxLengthConstraint(Film.COMMENT_MAX_LENGTH, Film.COMMENT, false, false)); |
459 | 0 | ConstraintManager.addConstraint(Film.IMAGE, new MaxLengthConstraint(Film.IMAGE_MAX_LENGTH, Film.IMAGE, false, false)); |
460 | 0 | ConstraintManager.addConstraint(Film.FILE_PATH, new MaxLengthConstraint(Film.FILE_PATH_MAX_LENGTH, Film.FILE_PATH, false, false)); |
461 | 0 | ConstraintManager.addConstraint(Film.KIND, new NotNullConstraint(Film.KIND)); |
462 | 0 | ConstraintManager.addConstraint(Film.TYPE, new NotNullConstraint(Film.TYPE)); |
463 | |
|
464 | 0 | ConstraintManager.addConstraint("saga.name", new MaxLengthConstraint(Saga.NAME_MAX_LENGTH, Saga.NAME, false, false)); |
465 | 0 | ConstraintManager.addConstraint("kind.name", new MaxLengthConstraint(Kind.NAME_MAX_LENGTH, Kind.NAME, false, false)); |
466 | 0 | ConstraintManager.addConstraint("type.name", new MaxLengthConstraint(Type.NAME_MAX_LENGTH, Type.NAME, false, false)); |
467 | |
|
468 | 0 | ConstraintManager.addConstraint(Publication.HOST, new MaxLengthConstraint(Publication.HOST_MAX_LENGTH, Publication.HOST, false, false)); |
469 | 0 | ConstraintManager.addConstraint(Publication.USER, new MaxLengthConstraint(Publication.USER_MAX_LENGTH, Publication.USER, true, false)); |
470 | 0 | ConstraintManager.addConstraint(Publication.PASSWORD, new MaxLengthConstraint(Publication.PASSWORD_MAX_LENGTH, Publication.PASSWORD, true, false)); |
471 | 0 | ConstraintManager.addConstraint(Publication.PATH, new MaxLengthConstraint(Publication.PATH_MAX_LENGTH, Publication.PATH, false, false)); |
472 | 0 | ConstraintManager.addConstraint(Publication.PORT, new MaxLengthConstraint(Publication.PORT_MAX_LENGTH, Publication.PORT, false, true)); |
473 | 0 | } |
474 | |
|
475 | |
|
476 | |
|
477 | |
|
478 | |
@UnPlug |
479 | |
public void unplug() { |
480 | 0 | SorterFactory.getInstance().removeSorters(sorters); |
481 | |
|
482 | 0 | PrimaryUtils.unplug(); |
483 | |
|
484 | 0 | for (ConfigTabComponent component : configTabComponents) { |
485 | 0 | Managers.getManager(IViewManager.class).removeConfigTabComponent(component); |
486 | |
} |
487 | |
|
488 | 0 | for (TabComponent component : tabComponents) { |
489 | 0 | Managers.getManager(IViewManager.class).removeTabComponent(component); |
490 | |
} |
491 | |
|
492 | 0 | ChoiceActionFactory.removeChoiceActions(choiceActions); |
493 | |
|
494 | 0 | removeFeatures(); |
495 | |
|
496 | 0 | unregisterBackupObjects(); |
497 | |
|
498 | 0 | DataTypeManager.unbindDataType(IFilmsService.DATA_TYPE); |
499 | 0 | DataTypeManager.unbindDataType(IActorService.DATA_TYPE); |
500 | 0 | DataTypeManager.unbindDataType(IRealizersService.DATA_TYPE); |
501 | 0 | DataTypeManager.unbindDataType(ITypesService.DATA_TYPE); |
502 | 0 | DataTypeManager.unbindDataType(IKindsService.DATA_TYPE); |
503 | 0 | DataTypeManager.unbindDataType(ISagasService.DATA_TYPE); |
504 | |
|
505 | 0 | Managers.getManager(ISchemaManager.class).unregisterSchema(schema); |
506 | 0 | } |
507 | |
|
508 | |
|
509 | |
|
510 | |
|
511 | |
private void unregisterBackupObjects() { |
512 | 0 | Managers.getManager(IFileManager.class).unregisterBackupWriter(FileType.JTD, jtdWriter); |
513 | 0 | Managers.getManager(IFileManager.class).unregisterBackupWriter(FileType.XML, xmlWriter); |
514 | |
|
515 | 0 | Managers.getManager(IFileManager.class).unregisterBackupReader(FileType.XML, xmlReader); |
516 | 0 | Managers.getManager(IFileManager.class).unregisterBackupReader(FileType.JTD, jtdReader); |
517 | 0 | Managers.getManager(IFileManager.class).unregisterBackupReader(FileType.V3, dbv3Reader); |
518 | 0 | Managers.getManager(IFileManager.class).unregisterBackupReader(FileType.V4, dbv4Reader); |
519 | 0 | } |
520 | |
|
521 | |
|
522 | |
|
523 | |
|
524 | |
private void removeFeatures() { |
525 | 0 | Managers.getManager(IFeatureManager.class).getFeature(CoreFeature.HELP).removeSubFeature(sitesFeature); |
526 | 0 | Managers.getManager(IFeatureManager.class).getFeature(CoreFeature.FILE).removeSubFeature(refreshFeature); |
527 | 0 | Managers.getManager(IFeatureManager.class).getFeature(CoreFeature.FILE).removeSubFeature(printFeature); |
528 | 0 | Managers.getManager(IFeatureManager.class).getFeature(CoreFeature.FILE).removeSubFeature(importFeature); |
529 | 0 | Managers.getManager(IFeatureManager.class).getFeature(CoreFeature.FILE).removeSubFeature(exportFeature); |
530 | 0 | Managers.getManager(IFeatureManager.class).getFeature(CoreFeature.FILE).removeSubFeature(importFolderFeature); |
531 | 0 | Managers.getManager(IFeatureManager.class).getFeature(CoreFeature.EDIT).removeSubFeature(searchFeature); |
532 | 0 | Managers.getManager(IFeatureManager.class).getFeature(CoreFeature.EDIT).removeSubFeature(publicationFeature); |
533 | 0 | Managers.getManager(IFeatureManager.class).getFeature(CoreFeature.EDIT).removeSubFeature(coverFeature); |
534 | 0 | Managers.getManager(IFeatureManager.class).getFeature(CoreFeature.ADVANCED).removeSubFeature(videoFeature); |
535 | 0 | Managers.getManager(IFeatureManager.class).removeFeature(realizersFeature); |
536 | 0 | Managers.getManager(IFeatureManager.class).removeFeature(actorsFeature); |
537 | 0 | Managers.getManager(IFeatureManager.class).removeFeature(filmsFeature); |
538 | 0 | Managers.getManager(IFeatureManager.class).removeFeature(othersFeature); |
539 | 0 | Managers.getManager(IFeatureManager.class).removeFeature(lendingsFeature); |
540 | 0 | } |
541 | |
|
542 | |
@Override |
543 | |
public Configuration getConfiguration() { |
544 | 0 | return config; |
545 | |
} |
546 | |
|
547 | |
@Override |
548 | |
public Feature getFilmsFeature() { |
549 | 0 | return filmsFeature; |
550 | |
} |
551 | |
|
552 | |
@Override |
553 | |
public Feature getActorsFeature() { |
554 | 0 | return actorsFeature; |
555 | |
} |
556 | |
|
557 | |
@Override |
558 | |
public Feature getRealizersFeature() { |
559 | 0 | return realizersFeature; |
560 | |
} |
561 | |
} |