Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/entry/beans/ApplicationBean.java @ 145:62d5276ed785
move suggestedTextTypes to CurrentTextBean and read types from definition.
clean city type handling.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 10 Jul 2017 15:54:54 +0200 |
parents | 4aa8c425685d |
children | 2522985f44af |
rev | line source |
---|---|
1 | 1 package de.mpiwg.itgroup.ismi.entry.beans; |
2 | |
3 import java.io.Serializable; | |
4 import java.util.ArrayList; | |
5 import java.util.Arrays; | |
6 import java.util.List; | |
7 | |
8 import javax.faces.context.FacesContext; | |
9 import javax.faces.model.SelectItem; | |
10 import javax.servlet.http.HttpServletRequest; | |
11 | |
12 import org.apache.commons.lang.StringUtils; | |
13 import org.apache.log4j.Logger; | |
14 import org.mpi.openmind.cache.WrapperService; | |
15 import org.mpi.openmind.configuration.ConfigurationService; | |
145
62d5276ed785
move suggestedTextTypes to CurrentTextBean and read types from definition.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
119
diff
changeset
|
16 import org.mpi.openmind.repository.bo.Attribute; |
1 | 17 import org.mpi.openmind.repository.bo.Entity; |
18 import org.mpi.openmind.repository.services.ServiceRegistry; | |
19 import org.mpi.openmind.search.SearchService; | |
20 import org.mpi.openmind.security.SecurityService; | |
21 | |
22 import de.mpiwg.itgroup.ismi.entry.dataBeans.SimpleSearchCache; | |
23 import de.mpiwg.itgroup.ismi.publicView.PublicCodexList; | |
24 | |
25 /** | |
26 * <p> | |
27 * Application scope data bean for your application. Create properties here to | |
28 * represent cached data that should be made available to all users and pages in | |
29 * the application. | |
30 * </p> | |
31 * | |
32 * <p> | |
33 * An instance of this class will be created for you automatically, the first | |
34 * time your application evaluates a value binding expression or method binding | |
35 * expression that references a managed bean using this class. | |
36 * </p> | |
37 * | |
38 * @version ApplicationBean1.java | |
39 * @version Created on 23.06.2009, 10:58:17 | |
40 * @author jurzua | |
41 */ | |
42 | |
43 public class ApplicationBean implements Serializable{ | |
44 | |
45 private static final long serialVersionUID = 804932192506497432L; | |
46 | |
47 private static Logger logger = Logger.getLogger(ApplicationBean.class); | |
48 | |
49 public static String urlISMIExportServiceAuthors = | |
56
ce1cd2450848
change title list export service url. remove biographies menu.
casties
parents:
14
diff
changeset
|
50 "https://ismi-dev.mpiwg-berlin.mpg.de/zope-ismi/database/export/authorsTitlesWitness"; |
1 | 51 |
52 public static String urlISMIExportServiceTitles = | |
56
ce1cd2450848
change title list export service url. remove biographies menu.
casties
parents:
14
diff
changeset
|
53 "https://ismi-dev.mpiwg-berlin.mpg.de/zope-ismi/database/export/titlesWitnesses"; |
1 | 54 |
55 private BiographyBean biographyBean; | |
56 | |
57 private PublicCodexList publicCodexList; | |
58 | |
59 public static String generateExportURL(String urlRoot, List<Long> list, String mode){ | |
60 StringBuilder sb = new StringBuilder(urlRoot); | |
61 | |
62 sb.append("?ids=" + generateIdList(list)); | |
63 | |
64 if(StringUtils.isNotEmpty(mode)){ | |
65 sb.append("&mode=" + mode); | |
66 } | |
67 | |
68 return sb.toString(); | |
69 } | |
70 | |
71 public static String generateIdList(List<Long> list){ | |
72 StringBuilder sb = new StringBuilder(); | |
73 | |
74 int count = 0; | |
75 for(Long id : list){ | |
76 | |
77 if(count>0){ | |
78 sb.append("%7C"); | |
79 } | |
80 sb.append(id); | |
81 count++; | |
82 } | |
83 return sb.toString(); | |
84 } | |
85 | |
86 public static String generateExportURL(String urlRoot, String idList, String mode){ | |
87 StringBuilder sb = new StringBuilder(urlRoot); | |
88 | |
89 sb.append("?ids=" + idList); | |
90 if(StringUtils.isNotEmpty(mode)){ | |
91 sb.append("&mode=" + mode); | |
92 } | |
93 | |
94 return sb.toString(); | |
95 } | |
96 | |
97 | |
98 public static String generateExportURL(String urlRoot, Long id, String mode){ | |
99 StringBuilder sb = new StringBuilder(urlRoot); | |
100 | |
101 sb.append("?ids=" + id); | |
102 if(StringUtils.isNotEmpty(mode)){ | |
103 sb.append("&mode=" + mode); | |
104 } | |
105 | |
106 return sb.toString(); | |
107 } | |
108 | |
109 public static String CURRENT_WITNESS = "CurrentWitness"; | |
110 public static String CURRENT_CODEX = "CurrentCodex"; | |
111 public static String CURRENT_TEXT = "CurrentText"; | |
112 public static String CURRENT_PERSON = "CurrentPerson"; | |
113 public static String CURRENT_ALIAS = "CurrentAlias"; | |
114 public static String CURRENT_COLLECTION = "CurrentCollection"; | |
115 public static String CURRENT_REPOSITORY = "CurrentRepository"; | |
116 public static String CURRENT_CITY = "CurrentCity"; | |
117 public static String CURRENT_SUBJECT = "CurrentSubject"; | |
118 public static String CURRENT_ROLE = "CurrentRole"; | |
119 public static String CURRENT_DIGI = "CurrentDigi"; | |
120 | |
121 private transient SimpleSearchCache simpleSearchCache; | |
122 ServiceRegistry serviceRegistry = null; | |
123 | |
124 | |
125 private List<SelectItem> roleList = new ArrayList<SelectItem>(); | |
126 private List<Entity> entityRoleList = new ArrayList<Entity>(); | |
127 private boolean roleListDirty = true; | |
128 | |
129 private static List<SelectItem> yes_no = new ArrayList<SelectItem>(); | |
130 private static List<SelectItem> roles = new ArrayList<SelectItem>(); | |
131 | |
132 private static List<SelectItem> suggestedStatus = new ArrayList<SelectItem>(); | |
133 private static List<SelectItem> suggestedBindings = new ArrayList<SelectItem>(); | |
134 private static List<SelectItem> writingSurfaces = new ArrayList<SelectItem>(); | |
135 private static List<SelectItem> pageLayout = new ArrayList<SelectItem>(); | |
136 private static List<SelectItem> scripts = new ArrayList<SelectItem>(); | |
137 private static List<SelectItem> sourcesOfInformation = new ArrayList<SelectItem>(); | |
138 private static List<SelectItem> suggestedLanguages = new ArrayList<SelectItem>(); | |
139 private static List<SelectItem> suggestedBoolean = new ArrayList<SelectItem>(); | |
140 | |
141 | |
142 public static String STATUS_NEED_VERIFICATION = "needs verification"; | |
143 public static String STATUS_VERIFIED_BY_CATALOGUE = "verified by catalogue"; | |
144 public static String STATUS_VERIFIED_BY_WITNESS = "verified by witness"; | |
145 public static String STATUS_NOT_CHECKED = "not checked"; | |
146 | |
147 public static String FORMATED_DATE = "formatted date"; | |
148 public static String PLAIN_DATE = "plain date"; | |
149 private static List<SelectItem> dateTypes = new ArrayList<SelectItem>(); | |
150 | |
151 private List<SelectItem> suggestedSubjects = null; | |
152 | |
153 public void resetSuggestedSubjects(){ | |
154 this.suggestedSubjects = new ArrayList<SelectItem>(); | |
155 this.suggestedSubjects.add(new SelectItem(null, "-- choose --")); | |
156 | |
157 List<Entity> cats = getWrapper().getEntitiesByAtt("SUBJECT", "type", "main_subject", -1, false); | |
158 | |
159 for(Entity cat : cats){ | |
160 SelectItem item = new SelectItem(cat.getId(), cat.getOwnValue()); | |
161 | |
162 item.setStyle("font-weight: bold; padding-left: 0px; font-size: 14;"); | |
163 this.suggestedSubjects.add(item); | |
164 List<Entity> subCats = getWrapper().getSourcesForTargetRelation(cat, "is_part_of", "SUBJECT", -1); | |
165 for(Entity subCat : subCats){ | |
166 | |
167 item = new SelectItem(subCat.getId(), subCat.getOwnValue()); | |
168 item.setStyle("padding-left: 10px; font-size: 12;"); | |
169 this.suggestedSubjects.add(item); | |
170 | |
171 List<Entity> subsubCats = getWrapper().getSourcesForTargetRelation(subCat, "is_part_of", "SUBJECT", -1); | |
172 for(Entity subsubCat : subsubCats){ | |
173 if(subsubCat != null){ | |
174 item = new SelectItem(subsubCat.getId(), subsubCat.getOwnValue()); | |
175 | |
176 this.suggestedSubjects.add(item); | |
177 | |
178 }else{ | |
119 | 179 logger.debug("error in resetSuggestedSubjects: main="+cat+" sub="+subCat); |
180 //System.out.println("####################ERROR####################"); | |
181 //System.out.println("resetSuggestedSubjects"); | |
182 //System.out.println(" main: " + cat); | |
183 //System.out.println(" sub: " + subCat); | |
1 | 184 } |
185 } | |
186 } | |
187 } | |
188 } | |
189 | |
190 public List<SelectItem> getSuggestedSubjects() { | |
191 if(suggestedSubjects == null){ | |
192 this.resetSuggestedSubjects(); | |
193 } | |
194 return suggestedSubjects; | |
195 } | |
196 | |
197 public void setSuggestedSubjects(List<SelectItem> suggestedSubjects) { | |
198 this.suggestedSubjects = suggestedSubjects; | |
199 } | |
200 | |
201 static{ | |
202 | |
203 dateTypes.add(new SelectItem(FORMATED_DATE)); | |
204 dateTypes.add(new SelectItem(PLAIN_DATE)); | |
205 | |
206 String[] status = new String[]{"needs verification", "verified by catalogue", "verified by witness"}; | |
207 Arrays.sort(status); | |
208 | |
209 suggestedStatus.add(new SelectItem("", STATUS_NOT_CHECKED)); | |
210 for(int i=0; i< status.length; i++){ | |
211 suggestedStatus.add(new SelectItem(status[i])); | |
212 } | |
213 | |
214 String[] binding = new String[]{"cardboard", "leather with flap", "leather without flap"}; | |
215 Arrays.sort(binding); | |
216 | |
217 suggestedBindings.add(new SelectItem("", "-- choose --")); | |
218 for(int i=0; i< binding.length; i++){ | |
219 suggestedBindings.add(new SelectItem(binding[i])); | |
220 } | |
221 | |
222 | |
223 String[] langs = new String[] { "Arabic", "Persian-Farsi", | |
224 "Greek-classical", "Hebrew", "Latin", "Syriac", "Armenian", | |
225 "Castillian", "Catalan", "Chinese", "French", "German", | |
226 "Greek-Byzantine", "Hindi", "Italian", "Mongolian", | |
227 "Persian-Old", "Persian-Middle", "Russian", "Sanskrit", | |
228 "Turkish (Ottoman pre-1839)", "Turkish (Ottoman 1839-)", | |
229 "Turkish (pre-Ottoman)", "Turkish-Republican", "Urdu", "Uighur" }; | |
230 Arrays.sort(langs); | |
231 | |
232 suggestedLanguages.add(new SelectItem("", "-- choose --")); | |
233 for(int i = 0; i < langs.length; i++){ | |
234 suggestedLanguages.add(new SelectItem(langs[i])); | |
235 } | |
236 | |
237 yes_no.add(new SelectItem("", "-- choose --")); | |
238 yes_no.add(new SelectItem("yes")); | |
239 yes_no.add(new SelectItem("no")); | |
240 | |
241 suggestedBoolean.add(new SelectItem("", "-- choose --")); | |
242 suggestedBoolean.add(new SelectItem("true")); | |
243 suggestedBoolean.add(new SelectItem("false")); | |
244 | |
245 roles.add(new SelectItem("", "-- choose --")); | |
246 roles.add(new SelectItem("annotator")); | |
247 roles.add(new SelectItem("author")); | |
248 roles.add(new SelectItem("copyist")); | |
249 roles.add(new SelectItem("illuminator")); | |
250 roles.add(new SelectItem("illustrator")); | |
251 roles.add(new SelectItem("owner")); | |
252 roles.add(new SelectItem("patron")); | |
253 roles.add(new SelectItem("reader")); | |
254 roles.add(new SelectItem("student")); | |
255 roles.add(new SelectItem("teacher")); | |
256 roles.add(new SelectItem("translator")); | |
257 | |
258 writingSurfaces.add(new SelectItem("", "-- choose --")); | |
259 writingSurfaces.add(new SelectItem("HARD", "HARD")); | |
260 writingSurfaces.add(new SelectItem("marble", " marble")); | |
261 writingSurfaces.add(new SelectItem("metal instrument", " metal instrument")); | |
262 writingSurfaces.add(new SelectItem("stone", " stone")); | |
263 writingSurfaces.add(new SelectItem("SOFT", "SOFT")); | |
264 writingSurfaces.add(new SelectItem("paper", " paper")); | |
265 writingSurfaces.add(new SelectItem("papyrus", " papyrus")); | |
266 writingSurfaces.add(new SelectItem("parchment", " parchment")); | |
267 | |
268 pageLayout.add(new SelectItem("", "-- choose --")); | |
269 pageLayout.add(new SelectItem("Frame-ruled")); | |
270 pageLayout.add(new SelectItem("Paper")); | |
271 | |
272 scripts.add(new SelectItem("", "-- choose --")); | |
273 scripts.add(new SelectItem("Maghribi")); | |
274 scripts.add(new SelectItem("Naskh")); | |
275 scripts.add(new SelectItem("Nasta'liq")); | |
276 scripts.add(new SelectItem("Riqa'")); | |
277 scripts.add(new SelectItem("Ruq'ah")); | |
278 scripts.add(new SelectItem("Shikastah")); | |
279 scripts.add(new SelectItem("Sudani")); | |
280 scripts.add(new SelectItem("Ta'liq")); | |
281 scripts.add(new SelectItem("Tawqi'")); | |
282 scripts.add(new SelectItem("Other-see Notes")); | |
283 | |
284 | |
285 sourcesOfInformation.add(new SelectItem("", "-- choose --")); | |
286 sourcesOfInformation.add(new SelectItem("Actual Witness")); | |
287 sourcesOfInformation.add(new SelectItem("Microfilm")); | |
288 sourcesOfInformation.add(new SelectItem("Digital Form (DVD/CD)")); | |
289 sourcesOfInformation.add(new SelectItem("Catalogue (Give Full Citation In Notes)")); | |
290 } | |
291 | |
292 public SearchService getSS() { | |
293 return serviceRegistry.getSearchService(); | |
294 } | |
295 | |
296 public WrapperService getWrapper() { | |
297 return serviceRegistry.getWrapper(); | |
298 } | |
299 | |
300 public SecurityService getSecurityService() { | |
301 return serviceRegistry.getSecurityService(); | |
302 } | |
303 | |
304 public ConfigurationService getConfService(){ | |
305 return serviceRegistry.getConfigurationService(); | |
306 } | |
307 | |
308 /** | |
309 * <p> | |
310 * Construct a new application data bean instance. | |
311 * </p> | |
312 */ | |
313 public ApplicationBean() { | |
314 logger.info("Initialize ApplicationBean1"); | |
315 this.serviceRegistry = new ServiceRegistry(); | |
316 this.simpleSearchCache = new SimpleSearchCache(serviceRegistry); | |
317 } | |
318 | |
319 public List<SelectItem> getYes_no() { | |
320 return yes_no; | |
321 } | |
322 | |
323 public List<SelectItem> getRoles() { | |
324 return roles; | |
325 } | |
326 | |
327 public List<SelectItem> getWritingSurfaces(){ | |
328 return writingSurfaces; | |
329 } | |
330 | |
331 public List<SelectItem> getPageLayout(){ | |
332 return pageLayout; | |
333 } | |
334 | |
335 public List<SelectItem> getScripts(){ | |
336 return scripts; | |
337 } | |
338 | |
339 public List<SelectItem> getSuggestedStatus(){ | |
340 return suggestedStatus; | |
341 } | |
342 | |
343 public List<SelectItem> getSuggestedBindings(){ | |
344 return suggestedBindings; | |
345 } | |
346 | |
347 public List<SelectItem> getSourcesOfInformation(){ | |
348 return sourcesOfInformation; | |
349 } | |
350 | |
351 public List<SelectItem> getSuggestedLanguages(){ | |
352 return suggestedLanguages; | |
353 } | |
354 | |
355 public List<SelectItem> getSuggestedBoolean(){ | |
356 return suggestedBoolean; | |
357 } | |
358 | |
359 public List<SelectItem> getDateTypes(){ | |
360 return dateTypes; | |
361 } | |
362 | |
363 public SimpleSearchCache getSimpleSearchCache() { | |
364 return simpleSearchCache; | |
365 } | |
366 | |
367 public void setSimpleSearchCache(SimpleSearchCache simpleSearchCache) { | |
368 this.simpleSearchCache = simpleSearchCache; | |
369 } | |
370 | |
371 public void setRoleListAsDirty(){ | |
372 this.roleListDirty = true; | |
373 } | |
374 | |
375 public String getRoot(){ | |
376 return FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); | |
377 } | |
378 | |
379 public List<SelectItem> getRoleList(){ | |
380 if(roleListDirty){ | |
381 this.roleList = new ArrayList<SelectItem>(); | |
382 this.entityRoleList = getWrapper().getEntitiesByDef("ROLE"); | |
383 for(Entity e : this.entityRoleList){ | |
384 this.roleList.add(new SelectItem(e.getId(), e.getOwnValue())); | |
385 } | |
386 this.roleListDirty = false; | |
387 } | |
388 | |
389 return this.roleList; | |
390 } | |
391 | |
392 public String getEditImage(){ | |
393 return "/resources/images/system/edit_20.png"; | |
394 } | |
395 | |
396 public String getImgEdit16(){ | |
397 return "/resources/images/system/edit_16.png"; | |
398 } | |
399 | |
400 public String getImgEdit32(){ | |
401 return "/resources/images/system/edit_32.png"; | |
402 } | |
403 | |
404 public String getImgRemove16(){ | |
405 return "/resources/images/system/remove_16.png"; | |
406 } | |
407 | |
408 public String getImgRemove32(){ | |
409 return "/resources/images/system/remove_32.png"; | |
410 } | |
411 | |
412 public String getImgVersions16(){ | |
413 return "/resources/images/system/versions_16.png"; | |
414 } | |
415 | |
416 public String getImgVersions32(){ | |
417 return "/resources/images/system/versions_32.png"; | |
418 } | |
419 | |
420 public String getImgSave16(){ | |
421 return "/resources/images/system/save_16.png"; | |
422 } | |
423 | |
424 public String getImgSave32(){ | |
425 return "/resources/images/system/save_32.png"; | |
426 } | |
427 | |
428 public String getImgClean16(){ | |
429 return "/resources/images/system/clean_16.png"; | |
430 } | |
431 | |
432 public String getImgClean32(){ | |
433 return "/resources/images/system/clean_32.png"; | |
434 } | |
435 | |
436 public String getImgNew16(){ | |
437 return "/resources/images/system/new_16.png"; | |
438 } | |
439 | |
440 public String getImgNew32(){ | |
441 return "/resources/images/system/new_32.png"; | |
442 } | |
443 | |
444 public String getImgSeach16(){ | |
445 return "/resources/images/system/search_16.png"; | |
446 } | |
447 | |
448 public String getImgSearch32(){ | |
449 return "/resources/images/system/search_32.png"; | |
450 } | |
451 | |
452 public String getDisplayImage(){ | |
453 return "/resources/images/display_32.png"; | |
454 } | |
455 | |
456 public String getWorldImage(){ | |
457 return "/resources/images/icy_earth_32.png"; | |
458 } | |
459 | |
460 public String getBookImage(){ | |
461 return "/resources/images/book_32.png"; | |
462 } | |
463 | |
464 public String getSearchImage(){ | |
465 return "/resources/images/search_32.png"; | |
466 } | |
467 | |
468 public String getImgNetwork32(){ | |
469 return "/resources/images/network_32.png"; | |
470 } | |
471 | |
472 public String getImgPerson32(){ | |
473 return "/resources/images/person_32.png"; | |
474 } | |
475 | |
476 | |
477 public String getImgDown32(){ | |
478 return "/resources/images/down_32.png"; | |
479 } | |
480 | |
481 public String getImgUp32(){ | |
482 return "/resources/images/up_32.png"; | |
483 } | |
484 | |
485 ///**** | |
486 //private List<Entity> texts; | |
487 private List<SelectItem> textsSelectItems; | |
488 private boolean dirty = false; | |
489 | |
490 private void updateListAllTexts(){ | |
491 textsSelectItems = new ArrayList<SelectItem>(); | |
492 for (Entity text : getWrapper().getEntitiesByDef("TEXT")){ | |
493 textsSelectItems.add(new SelectItem(text.getId(), text.getOwnValue() + " [" +text.getId()+ "]")); | |
494 } | |
495 } | |
496 | |
497 public List<SelectItem> getAllTexts() { | |
498 if(this.dirty || textsSelectItems == null){ | |
499 this.updateListAllTexts(); | |
500 this.dirty = false; | |
501 } | |
502 return textsSelectItems; | |
503 } | |
504 | |
505 public void setAllTextsAsDirty(){ | |
506 this.dirty = true; | |
507 } | |
508 | |
509 public String getJSConfirmationSave(){ | |
510 return "if(!confirm('Do you really want to save the changes?')){ return false; };"; | |
511 } | |
512 | |
513 public String getJSConfirmationLogout(){ | |
514 return "if(!confirm('Do you really want to end your session?')){ return false; };"; | |
515 } | |
516 | |
517 public String getJSConfirmationDelete(){ | |
518 return "if(!confirm('Do you really want to delete this?')){ return false; };"; | |
519 } | |
520 | |
521 public String getJSConfirmationSaveAsNew(){ | |
522 return "if(!confirm('Do you really want to save the entity as new?')){ return false;};"; | |
523 } | |
524 | |
525 public String getJSConfirmationMerge(){ | |
526 return "if(!confirm('Do you really want to merge these entities?')){ return false;};"; | |
527 } | |
528 | |
529 public String getJSConfirmationCleanForm(){ | |
530 return "if(!confirm('Do you really want to clear the form?')){ return false;};"; | |
531 } | |
532 | |
533 public String getContextRoot(){ | |
534 | |
535 HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); | |
536 | |
537 | |
538 | |
539 String port = (StringUtils.equals(request.getLocalPort() + "", "80")) ? "" : (":" + request.getLocalPort()); | |
540 String path = request.getScheme() + "://" + request.getLocalName() + port + request.getContextPath(); | |
541 | |
542 return path; | |
543 } | |
544 | |
545 public BiographyBean getBiographyBean(){ | |
546 if(biographyBean == null) | |
547 this.biographyBean = new BiographyBean(); | |
548 return this.biographyBean; | |
549 } | |
550 | |
551 public PublicCodexList getPublicCodexList(){ | |
552 if(publicCodexList == null){ | |
553 publicCodexList = new PublicCodexList(); | |
554 } | |
555 return publicCodexList; | |
556 } | |
94
d2cee1040062
new servlet lifecycle listener to shut down Spring ApplicationBean.
casties
parents:
60
diff
changeset
|
557 |
d2cee1040062
new servlet lifecycle listener to shut down Spring ApplicationBean.
casties
parents:
60
diff
changeset
|
558 public ServiceRegistry getServiceRegistry() { |
d2cee1040062
new servlet lifecycle listener to shut down Spring ApplicationBean.
casties
parents:
60
diff
changeset
|
559 return this.serviceRegistry; |
d2cee1040062
new servlet lifecycle listener to shut down Spring ApplicationBean.
casties
parents:
60
diff
changeset
|
560 } |
1 | 561 } |