Mercurial > hg > ismi-richfaces
comparison src/main/java/de/mpiwg/itgroup/ismi/entry/beans/SessionBean.java @ 1:2e911857a759
(none)
author | jurzua |
---|---|
date | Wed, 29 Oct 2014 14:00:28 +0000 |
parents | |
children | 4ec8d4cfad26 |
comparison
equal
deleted
inserted
replaced
0:74df02964906 | 1:2e911857a759 |
---|---|
1 package de.mpiwg.itgroup.ismi.entry.beans; | |
2 | |
3 import java.io.IOException; | |
4 import java.io.Serializable; | |
5 import java.util.ArrayList; | |
6 import java.util.List; | |
7 | |
8 import javax.faces.context.ExternalContext; | |
9 import javax.faces.context.FacesContext; | |
10 import javax.faces.event.ActionEvent; | |
11 import javax.servlet.http.HttpServletRequest; | |
12 | |
13 import org.apache.commons.lang.StringUtils; | |
14 import org.apache.log4j.Logger; | |
15 import org.mpi.openmind.cache.WrapperService; | |
16 import org.mpi.openmind.repository.bo.Attribute; | |
17 import org.mpi.openmind.repository.bo.Entity; | |
18 import org.mpi.openmind.security.SecurityService; | |
19 import org.mpi.openmind.security.bo.User; | |
20 import org.mpiwg.itgroup.escidoc.utils.ESciDocItemDataTable; | |
21 import org.mpiwg.itgroup.escidoc.web.ESciDocItemForm; | |
22 import org.mpiwg.itgroup.geonames.GeonameForm; | |
23 import org.richfaces.event.ItemChangeEvent; | |
24 | |
25 import de.mpiwg.itgroup.ismi.admin.AdminBean; | |
26 import de.mpiwg.itgroup.ismi.browse.EntityDetailsBean; | |
27 import de.mpiwg.itgroup.ismi.defs.DefinitionForm; | |
28 import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean.CheckResults; | |
29 import de.mpiwg.itgroup.ismi.event.beans.CopyEvent; | |
30 import de.mpiwg.itgroup.ismi.event.beans.StudyEvent; | |
31 import de.mpiwg.itgroup.ismi.event.beans.TransferEvent; | |
32 import de.mpiwg.itgroup.ismi.merge.GeneralMerge; | |
33 import de.mpiwg.itgroup.ismi.publicView.DynamicPageEditor; | |
34 import de.mpiwg.itgroup.ismi.publicView.PublicCodexBean; | |
35 import de.mpiwg.itgroup.ismi.publicView.PublicCodexList; | |
36 import de.mpiwg.itgroup.ismi.publicView.PublicCodexView; | |
37 import de.mpiwg.itgroup.ismi.publicView.pages.DynamicPage; | |
38 import de.mpiwg.itgroup.ismi.search.beans.AdvancedSearchBean; | |
39 import de.mpiwg.itgroup.ismi.search.beans.DisplayAuthorBean; | |
40 import de.mpiwg.itgroup.ismi.search.beans.DisplayTitleBean; | |
41 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; | |
42 import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList; | |
43 | |
44 public class SessionBean extends AbstractBean implements Serializable{ | |
45 | |
46 private static Logger logger = Logger.getLogger(SessionBean.class); | |
47 | |
48 private DefinitionForm defForm = new DefinitionForm(); | |
49 private StudyEvent studyEventForm = new StudyEvent(); | |
50 private CopyEvent copyEventForm = new CopyEvent(); | |
51 private TransferEvent transferEventForm = new TransferEvent(); | |
52 private transient AdvancedSearchBean advancedSearch = new AdvancedSearchBean(); | |
53 private GeonameForm geoForm = new GeonameForm(); | |
54 | |
55 private EntityDetailsBean entDetailsForm = new EntityDetailsBean(); | |
56 | |
57 | |
58 private DisplayAuthorBean displayAuthor = new DisplayAuthorBean(); | |
59 private DisplayTitleBean displayTitle = new DisplayTitleBean(); | |
60 | |
61 private ESciDocItemForm eSciDocForm = new ESciDocItemForm(); | |
62 | |
63 private ESciDocItemDataTable refDataTable = new ESciDocItemDataTable(null); | |
64 | |
65 private DynamicPageEditor pageEditor = null; | |
66 | |
67 | |
68 private Calendar currentCalendar = null; | |
69 private EntityList currentEntListForCalendar = null; | |
70 private Long currentEntIdForCalendar; | |
71 | |
72 private boolean displayLoginDialog = false; | |
73 | |
74 private DigiListBean digiList; | |
75 | |
76 //public | |
77 private DynamicPage dynamicPage; | |
78 private PublicCodexView publicCodexView; | |
79 private PublicCodexBean publicCodexBean; | |
80 | |
81 public void editCalendar(Calendar cal, EntityList list, Long entId){ | |
82 this.currentCalendar = cal; | |
83 this.currentEntListForCalendar = list; | |
84 this.currentEntIdForCalendar = entId; | |
85 } | |
86 | |
87 public void listenerSaveEditionCalendar(ActionEvent event){ | |
88 if(this.currentEntListForCalendar != null && this.currentEntIdForCalendar != null){ | |
89 this.currentEntListForCalendar.getCalendarMap().put(currentEntIdForCalendar, currentCalendar); | |
90 this.currentCalendar = null; | |
91 this.currentEntListForCalendar = null; | |
92 this.currentEntIdForCalendar = null; | |
93 } | |
94 } | |
95 | |
96 | |
97 public static String PAGE_ENTITY_REPOSITORY = "entity_repository"; | |
98 public static String PAGE_ENTITY_DETAILS = "entity_details"; | |
99 public static String PAGE_ENTRY = "entry_edit_entity"; | |
100 public static String PAGE_EVENT_FORM = "event_form"; | |
101 public static String PAGE_SIMPLE_SEARCH = "simple_search"; | |
102 public static String PAGE_PUBLIC_CODICES = "public_codices"; | |
103 public static String PAGE_DISPLAY_TITLE = "display_title"; | |
104 public static String PAGE_DISPLAY_AUTHOR = "display_author"; | |
105 public static String PAGE_GENERAL_MERGE = "general_merge"; | |
106 public static String PAGE_GEO_FORM = "geo_form"; | |
107 public static String PAGE_ADMIN = "admin"; | |
108 public static String PAGE_PROFILE = "profile"; | |
109 public static String PAGE_DEF_EDITOR = "defEditor"; | |
110 | |
111 private User user = null; | |
112 private String username = ""; | |
113 private String password = ""; | |
114 | |
115 //private Entity currentEntity; | |
116 | |
117 private GeneralMerge generalMerge; | |
118 | |
119 //private String last_action; | |
120 //private Date time_of_lastAction; | |
121 | |
122 private String remoteAddr; | |
123 | |
124 private static final long serialVersionUID = 1L; | |
125 | |
126 //Entities tabs | |
127 public static String WITNESS_TAB = "Witness"; | |
128 public static String CODEX_TAB = "Codex"; | |
129 public static String COLLECTION_TAB = "Collection"; | |
130 public static String REPOSITORY_TAB = "Repository"; | |
131 public static String CITY_TAB = "Place"; | |
132 public static String TEXT_TAB = "Text"; | |
133 public static String PERSON_TAB = "Person"; | |
134 public static String ALIAS_TAB = "Alias"; | |
135 public static String SUBJECT_TAB = "Subject"; | |
136 public static String ROLE_TAB = "Role"; | |
137 public static String DIGI_TAB = "Digi"; | |
138 | |
139 //Events tabs | |
140 public static String WITNESS_STUDY_EVENT_TAB = "Study"; | |
141 public static String COPY_EVENT_TAB = "Copy"; | |
142 public static String TRANSFER_EVENT_TAB = "Transfer"; | |
143 | |
144 private String selectedTab = WITNESS_TAB; | |
145 private String selectedEventTab = WITNESS_STUDY_EVENT_TAB; | |
146 private String selectedAdvancedSearchTab = "01"; | |
147 | |
148 | |
149 private Long editFormCurrentEntId; | |
150 | |
151 private boolean displayError = false; | |
152 private ArrayList<String> errorMessages; | |
153 | |
154 public String getOCByTabIndex(){ | |
155 if(selectedTab != null){ | |
156 if(selectedTab.equals(WITNESS_TAB)){ | |
157 return AbstractISMIBean.WITNESS; | |
158 }else if(selectedTab.equals(CODEX_TAB)){ | |
159 return AbstractISMIBean.CODEX; | |
160 }else if(selectedTab.equals(COLLECTION_TAB)){ | |
161 return AbstractISMIBean.COLLECTION; | |
162 }else if(selectedTab.equals(REPOSITORY_TAB)){ | |
163 return AbstractISMIBean.REPOSITORY; | |
164 }else if(selectedTab.equals(CITY_TAB)){ | |
165 return AbstractISMIBean.PLACE; | |
166 }else if(selectedTab.equals(TEXT_TAB)){ | |
167 return AbstractISMIBean.TEXT; | |
168 }else if(selectedTab.equals(PERSON_TAB)){ | |
169 return AbstractISMIBean.PERSON; | |
170 }else if(selectedTab.equals(ALIAS_TAB)){ | |
171 return AbstractISMIBean.ALIAS; | |
172 }else if(selectedTab.equals(SUBJECT_TAB)){ | |
173 return AbstractISMIBean.SUBJECT; | |
174 }else if(selectedTab.equals(ROLE_TAB)){ | |
175 return AbstractISMIBean.ROLE; | |
176 }else if(selectedTab.equals(DIGI_TAB)){ | |
177 return AbstractISMIBean.DIGITALIZATION; | |
178 } | |
179 } | |
180 return null; | |
181 } | |
182 | |
183 public void listenerOpenESciDocForm(ActionEvent event){ | |
184 this.refDataTable.open(); | |
185 } | |
186 | |
187 //************************************ | |
188 //************************************ | |
189 //************************************ | |
190 public SessionBean() { | |
191 if(StringUtils.isBlank(this.remoteAddr)){ | |
192 this.getRemoteAddr(); | |
193 } | |
194 logger.info(" [remoteAddr=" + remoteAddr + "]"); | |
195 } | |
196 | |
197 private void autoLogin(){ | |
198 /* | |
199 this.username = "jurzua@mpiwg-berlin.mpg.de"; | |
200 this.password = "221082"; | |
201 this.login(); | |
202 */ | |
203 } | |
204 | |
205 public void getRemoteAddr(){ | |
206 try{ | |
207 HttpServletRequest httpServletRequest = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); | |
208 this.remoteAddr = httpServletRequest.getRemoteAddr(); | |
209 }catch (Exception ex) {} | |
210 } | |
211 | |
212 | |
213 public void listenerLogin(ActionEvent event) { | |
214 this.login(); | |
215 } | |
216 | |
217 public String actionLogin(){ | |
218 this.login(); | |
219 return new String(); | |
220 } | |
221 | |
222 public void listenerDisplayLoginDialog(ActionEvent event) { | |
223 if(user == null){ | |
224 this.displayLoginDialog = true; | |
225 }else{ | |
226 this.displayLoginDialog = false; | |
227 } | |
228 } | |
229 | |
230 public String actionLoginCancel(){ | |
231 this.displayLoginDialog = false; | |
232 return PAGE_SIMPLE_SEARCH; | |
233 } | |
234 | |
235 private void login(){ | |
236 user = null; | |
237 // this.loginMsg = ""; | |
238 | |
239 if (StringUtils.isNotEmpty(username) | |
240 && StringUtils.isNotEmpty(password)) { | |
241 user = getSecurityService().getUserByPassword(username, password); | |
242 } | |
243 | |
244 if (user == null) { | |
245 addErrorMsg("The system does not find the account!"); | |
246 this.displayLoginDialog = false; | |
247 } else { | |
248 if(StringUtils.isBlank(this.remoteAddr)){ | |
249 this.getRemoteAddr(); | |
250 } | |
251 logger.info("login " + username + " [remoteAddr=" + remoteAddr + "]"); | |
252 this.setUser(user); | |
253 this.generalMerge = new GeneralMerge(); | |
254 this.defForm = new DefinitionForm(); | |
255 // refresh the editor of Dirk | |
256 addSessionBean("CurrentWitness", new CurrentWitnessBean()); | |
257 addSessionBean("CurrentCodex", new CurrentCodexBean()); | |
258 addSessionBean("CurrentText", new CurrentTextBean()); | |
259 addSessionBean("CurrentPerson", new CurrentPersonBean()); | |
260 addSessionBean("CurrentAlias", new CurrentAliasBean()); | |
261 addSessionBean("CurrentCollection", new CurrentCollectionBean()); | |
262 addSessionBean("CurrentRepository", new CurrentRepositoryBean()); | |
263 addSessionBean("CurrentCity", new CurrentCityBean()); | |
264 addSessionBean("CurrentDigi", new CurrentDigitalizationBean()); | |
265 editFormCurrentEntId = null; | |
266 this.displayLoginDialog = false; | |
267 } | |
268 } | |
269 | |
270 public String logout() { | |
271 if(StringUtils.isBlank(this.remoteAddr)){ | |
272 this.getRemoteAddr(); | |
273 } | |
274 logger.info("logout " + username + " [remoteAddr=" + remoteAddr + "]"); | |
275 this.username = ""; | |
276 this.password = ""; | |
277 this.user = null; | |
278 this.generalMerge = null; | |
279 this.defForm = null; | |
280 return PAGE_PUBLIC_CODICES; | |
281 } | |
282 | |
283 public boolean isCanDelete() { | |
284 return isAdmin(); | |
285 } | |
286 | |
287 public boolean isCanMerge() { | |
288 if (getUser() != null) { | |
289 String role = getUser().getRole(); | |
290 if (StringUtils.isNotEmpty(role)) { | |
291 if (AdminBean.Administrator.equals(role) | |
292 || AdminBean.Researcher.equals(role)) { | |
293 return true; | |
294 } | |
295 } | |
296 } | |
297 return false; | |
298 } | |
299 | |
300 public boolean isCanCreate() { | |
301 if (getUser() != null) { | |
302 String role = getUser().getRole(); | |
303 if (StringUtils.isNotEmpty(role)) { | |
304 if (AdminBean.Administrator.equals(role) | |
305 || AdminBean.Researcher.equals(role) | |
306 || AdminBean.Student.equals(role)) { | |
307 return true; | |
308 } | |
309 } | |
310 } | |
311 return false; | |
312 } | |
313 | |
314 public boolean isCanEdit() { | |
315 if (getUser() != null) { | |
316 String role = getUser().getRole(); | |
317 if (StringUtils.isNotEmpty(role)) { | |
318 if (AdminBean.Administrator.equals(role) | |
319 || AdminBean.Researcher.equals(role)) { | |
320 return true; | |
321 } | |
322 } | |
323 } | |
324 return false; | |
325 } | |
326 | |
327 public boolean isAdmin() { | |
328 if (getUser() != null) { | |
329 String role = getUser().getRole(); | |
330 if (StringUtils.isNotEmpty(role)) { | |
331 if (AdminBean.Administrator.equals(role)) { | |
332 return true; | |
333 } | |
334 } | |
335 } | |
336 return false; | |
337 } | |
338 | |
339 private List<String> generalMsgList = new ArrayList<String>(); | |
340 private List<String> errorMsgList = new ArrayList<String>(); | |
341 | |
342 public List<String> getErrorMsgList() { | |
343 return errorMsgList; | |
344 } | |
345 | |
346 public void setErrorMsgList(List<String> errorMsgList) { | |
347 this.errorMsgList = errorMsgList; | |
348 } | |
349 | |
350 public List<String> getGeneralMsgList() { | |
351 return generalMsgList; | |
352 } | |
353 | |
354 public void setGeneralMsgList(List<String> generalMsgList) { | |
355 this.generalMsgList = generalMsgList; | |
356 } | |
357 | |
358 public void addErrorMsg(String msg) { | |
359 if (this.errorMsgList == null) | |
360 this.errorMsgList = new ArrayList<String>(); | |
361 if (StringUtils.isNotEmpty(msg)) { | |
362 this.errorMsgList.add(msg); | |
363 } | |
364 } | |
365 | |
366 public void addGeneralMsg(String msg) { | |
367 if (this.generalMsgList == null) | |
368 this.generalMsgList = new ArrayList<String>(); | |
369 if (StringUtils.isNotEmpty(msg)) { | |
370 this.generalMsgList.add(msg); | |
371 } | |
372 } | |
373 | |
374 public void actionCloseErrorMsgDialog(ActionEvent event) { | |
375 this.errorMsgList = new ArrayList<String>(); | |
376 } | |
377 | |
378 public void actionCloseGeneralMsgDialog(ActionEvent event) { | |
379 this.generalMsgList = new ArrayList<String>(); | |
380 } | |
381 | |
382 protected SecurityService getSecurityService() { | |
383 return getAppBean().getSecurityService(); | |
384 } | |
385 | |
386 public void setSelectedTab(String tab) { | |
387 this.selectedTab = tab; | |
388 } | |
389 | |
390 public String closeErrorWindowAction() { | |
391 setDisplayError(false); | |
392 return "close_error"; | |
393 } | |
394 | |
395 public void editEntity(Long id) { | |
396 Entity entity = getWrapper().getEntityById(id); | |
397 this.editEntity(entity); | |
398 } | |
399 | |
400 public void editEntity(String id) { | |
401 try{ | |
402 Long entityId = Long.parseLong(id); | |
403 this.editEntity(entityId); | |
404 }catch (Exception e) { | |
405 e.printStackTrace(); | |
406 } | |
407 } | |
408 | |
409 /* | |
410 public void setPlaceInGeoForm(String id){ | |
411 try { | |
412 Long placeId = new Long(id); | |
413 Entity place = getWrapper().getEntityById(placeId); | |
414 if(place != null){ | |
415 this.geoForm.loadPlace(place); | |
416 } | |
417 } catch (Exception e) { | |
418 e.printStackTrace(); | |
419 } | |
420 }*/ | |
421 | |
422 | |
423 public void editEntity(Entity entity) { | |
424 logger.info("[" + this.getUsername() + "] Edit Entity= " + entity); | |
425 | |
426 entity = getWrapper().getEntityContent(entity); | |
427 | |
428 this.editFormCurrentEntId = entity.getId(); | |
429 if (entity.getObjectClass().equals("WITNESS")) { | |
430 this.editWitness(entity); | |
431 selectedTab = WITNESS_TAB; | |
432 } else if (entity.getObjectClass().equals("TEXT")) { | |
433 this.editText(entity); | |
434 selectedTab = TEXT_TAB; | |
435 } else if (entity.getObjectClass().equals("REPOSITORY")) { | |
436 this.editRepository(entity); | |
437 selectedTab = REPOSITORY_TAB; | |
438 } else if (entity.getObjectClass().equals("PERSON")) { | |
439 this.editPerson(entity); | |
440 selectedTab = PERSON_TAB; | |
441 } else if (entity.getObjectClass().equals("COLLECTION")) { | |
442 this.editCollection(entity); | |
443 selectedTab = COLLECTION_TAB; | |
444 } else if (entity.getObjectClass().equals("CODEX")) { | |
445 this.editCodex(entity); | |
446 selectedTab = CODEX_TAB; | |
447 } else if (entity.getObjectClass().equals("PLACE")) { | |
448 this.editPlace(entity); | |
449 selectedTab = CITY_TAB; | |
450 } else if (entity.getObjectClass().equals("ALIAS")) { | |
451 this.editAlias(entity); | |
452 selectedTab = ALIAS_TAB; | |
453 } else if (entity.getObjectClass().equals("SUBJECT")) { | |
454 this.editSubject(entity); | |
455 selectedTab = SUBJECT_TAB; | |
456 } else if (entity.getObjectClass().equals("ROLE")) { | |
457 this.editRole(entity); | |
458 selectedTab = ROLE_TAB; | |
459 } else if (entity.getObjectClass().equals("DIGITALIZATION")) { | |
460 this.editDigi(entity); | |
461 selectedTab = DIGI_TAB; | |
462 } else if (entity.getObjectClass().equals(StudyEvent.OC)) { | |
463 this.editWitnessStudyEvent(entity); | |
464 selectedEventTab = WITNESS_STUDY_EVENT_TAB; | |
465 } else if (entity.getObjectClass().equals(CopyEvent.OC)) { | |
466 this.editCopyEvent(entity); | |
467 selectedEventTab = COPY_EVENT_TAB; | |
468 } else if (entity.getObjectClass().equals(TransferEvent.OC)) { | |
469 this.editTransferEvent(entity); | |
470 selectedEventTab = TRANSFER_EVENT_TAB; | |
471 } else { | |
472 addErrorMsg("Form not implemented for these entities [" + entity.getObjectClass() + "]"); | |
473 } | |
474 } | |
475 | |
476 //*************************** | |
477 //*************************** | |
478 //*************************** | |
479 //*************************** | |
480 //*************************** | |
481 private void editText(Entity text) { | |
482 CurrentTextBean bean = (CurrentTextBean)getSessionBean(ApplicationBean.CURRENT_TEXT); | |
483 if(bean == null){ | |
484 bean = new CurrentTextBean(); | |
485 addSessionBean(ApplicationBean.CURRENT_TEXT, bean); | |
486 } | |
487 try { | |
488 bean.setEntity(text); | |
489 } catch (Exception e) { | |
490 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
491 } | |
492 } | |
493 | |
494 private void editRepository(Entity repository) { | |
495 CurrentRepositoryBean bean = (CurrentRepositoryBean)getSessionBean(ApplicationBean.CURRENT_REPOSITORY); | |
496 if(bean == null){ | |
497 bean = new CurrentRepositoryBean(); | |
498 addSessionBean(ApplicationBean.CURRENT_REPOSITORY, bean); | |
499 } | |
500 try { | |
501 bean.setEntity(repository); | |
502 } catch (Exception e) { | |
503 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
504 } | |
505 } | |
506 | |
507 private void editPerson(Entity person) { | |
508 CurrentPersonBean bean = (CurrentPersonBean)getSessionBean(ApplicationBean.CURRENT_PERSON); | |
509 if(bean == null){ | |
510 bean = new CurrentPersonBean(); | |
511 addSessionBean(ApplicationBean.CURRENT_PERSON, bean); | |
512 } | |
513 try { | |
514 bean.setEntity(person); | |
515 } catch (Exception e) { | |
516 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
517 } | |
518 } | |
519 | |
520 private void editCollection(Entity collection) { | |
521 CurrentCollectionBean bean = (CurrentCollectionBean) getSessionBean(ApplicationBean.CURRENT_COLLECTION); | |
522 if (bean == null) { | |
523 bean = new CurrentCollectionBean(); | |
524 addSessionBean(ApplicationBean.CURRENT_COLLECTION, bean); | |
525 } | |
526 try { | |
527 bean.setEntity(collection); | |
528 } catch (Exception e) { | |
529 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
530 } | |
531 } | |
532 | |
533 private void editCodex(Entity codex) { | |
534 CurrentCodexBean bean = (CurrentCodexBean) getSessionBean(ApplicationBean.CURRENT_CODEX); | |
535 if (bean == null) { | |
536 bean = new CurrentCodexBean(); | |
537 addSessionBean(ApplicationBean.CURRENT_CODEX, bean); | |
538 } | |
539 try { | |
540 bean.setEntity(codex); | |
541 } catch (Exception e) { | |
542 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
543 } | |
544 } | |
545 | |
546 private void editPlace(Entity place) { | |
547 CurrentCityBean bean = (CurrentCityBean) getSessionBean(ApplicationBean.CURRENT_CITY); | |
548 if (bean == null) { | |
549 bean = new CurrentCityBean(); | |
550 addSessionBean(ApplicationBean.CURRENT_CITY, bean); | |
551 } | |
552 try { | |
553 bean.setEntity(place); | |
554 } catch (Exception e) { | |
555 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
556 } | |
557 } | |
558 | |
559 private void editAlias(Entity alias) { | |
560 CurrentAliasBean bean = (CurrentAliasBean) getSessionBean(ApplicationBean.CURRENT_ALIAS); | |
561 if (bean == null) { | |
562 bean = new CurrentAliasBean(); | |
563 addSessionBean(ApplicationBean.CURRENT_ALIAS, bean); | |
564 } | |
565 try { | |
566 bean.setEntity(alias); | |
567 } catch (Exception e) { | |
568 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
569 } | |
570 } | |
571 | |
572 private void editSubject(Entity subject) { | |
573 CurrentSubjectBean bean = (CurrentSubjectBean) getSessionBean(ApplicationBean.CURRENT_SUBJECT); | |
574 if (bean == null) { | |
575 bean = new CurrentSubjectBean(); | |
576 addSessionBean(ApplicationBean.CURRENT_SUBJECT, bean); | |
577 } | |
578 try { | |
579 bean.setEntity(subject); | |
580 } catch (Exception e) { | |
581 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
582 } | |
583 } | |
584 | |
585 private void editRole(Entity role) { | |
586 CurrentRoleBean bean = (CurrentRoleBean) getSessionBean(ApplicationBean.CURRENT_ROLE); | |
587 if (bean == null) { | |
588 bean = new CurrentRoleBean(); | |
589 addSessionBean(ApplicationBean.CURRENT_ROLE, bean); | |
590 } | |
591 try { | |
592 bean.setEntity(role); | |
593 } catch (Exception e) { | |
594 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
595 } | |
596 } | |
597 | |
598 | |
599 private void editDigi(Entity digi) { | |
600 CurrentDigitalizationBean bean = (CurrentDigitalizationBean) getSessionBean(ApplicationBean.CURRENT_DIGI); | |
601 if (bean == null) { | |
602 bean = new CurrentDigitalizationBean(); | |
603 addSessionBean(ApplicationBean.CURRENT_DIGI, bean); | |
604 } | |
605 try { | |
606 bean.setEntity(digi); | |
607 } catch (Exception e) { | |
608 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
609 } | |
610 } | |
611 | |
612 | |
613 | |
614 private void editWitness(Entity witness) { | |
615 CurrentWitnessBean bean = (CurrentWitnessBean) getSessionBean(ApplicationBean.CURRENT_WITNESS); | |
616 if (bean == null) { | |
617 bean = new CurrentWitnessBean(); | |
618 addSessionBean(ApplicationBean.CURRENT_WITNESS, bean); | |
619 } | |
620 try { | |
621 bean.setEntity(witness); | |
622 } catch (Exception e) { | |
623 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
624 } | |
625 } | |
626 | |
627 private void editWitnessStudyEvent(Entity event){ | |
628 this.studyEventForm = new StudyEvent(event); | |
629 } | |
630 | |
631 public void listenerCreateStudyEvent(ActionEvent event){ | |
632 this.studyEventForm = new StudyEvent(); | |
633 } | |
634 | |
635 private void editCopyEvent(Entity event){ | |
636 this.copyEventForm = new CopyEvent(event); | |
637 } | |
638 | |
639 public void listenerCreateCopyEvent(ActionEvent event){ | |
640 this.copyEventForm = new CopyEvent(); | |
641 } | |
642 | |
643 private void editTransferEvent(Entity event){ | |
644 this.transferEventForm = new TransferEvent(event); | |
645 } | |
646 | |
647 public void listenerCreateTransferEvent(ActionEvent event){ | |
648 this.transferEventForm = new TransferEvent(); | |
649 } | |
650 | |
651 | |
652 public Long getEditFormCurrentEntId() { | |
653 return editFormCurrentEntId; | |
654 } | |
655 | |
656 public void setEditFormCurrentEntId(Long editFormCurrentEntId) { | |
657 this.editFormCurrentEntId = editFormCurrentEntId; | |
658 } | |
659 | |
660 | |
661 public void updateCurrent(ItemChangeEvent event) { | |
662 System.out.println(event.getNewItemName()); | |
663 } | |
664 | |
665 public void listenerEntityTabChange(ItemChangeEvent event) { | |
666 String url = "?formIndex=" + this.selectedTab; | |
667 this.redirect(null, url); | |
668 } | |
669 | |
670 public void listenerEventTabChange(ItemChangeEvent event) { | |
671 String url = "?formIndex=" + this.selectedEventTab; | |
672 this.redirect(null, url); | |
673 } | |
674 | |
675 public void listenerAdvancedSearchTabChange(ItemChangeEvent event) { | |
676 String url = "?searchForm=" + this.selectedAdvancedSearchTab; | |
677 this.redirect(null, url); | |
678 } | |
679 | |
680 protected void redirect(String redirectPath, String parameters){ | |
681 FacesContext fc = FacesContext.getCurrentInstance(); | |
682 ExternalContext ec = fc.getExternalContext(); | |
683 String contextPath = ec.getRequestContextPath(); | |
684 if(StringUtils.isEmpty(redirectPath)){ | |
685 redirectPath = ec.getRequestServletPath(); | |
686 } | |
687 try { | |
688 ec.redirect(ec.encodeActionURL(contextPath + redirectPath + parameters)); | |
689 | |
690 } catch (IOException e) { | |
691 e.printStackTrace(); | |
692 } | |
693 } | |
694 | |
695 public Entity getDefinition(Entity assertion) { | |
696 return getWrapper().getDefinition(assertion.getObjectClass()); | |
697 } | |
698 | |
699 public String toProfile(){ | |
700 return PAGE_PROFILE; | |
701 } | |
702 | |
703 public String toSimpleSearch() { | |
704 return PAGE_SIMPLE_SEARCH; | |
705 } | |
706 | |
707 public String toDefinitionEditor(){ | |
708 if(this.defForm != null){ | |
709 this.defForm.loadDefinitions(); | |
710 return PAGE_DEF_EDITOR; | |
711 } | |
712 return ""; | |
713 } | |
714 | |
715 public String toGeoForm(){ | |
716 this.geoForm.loadPlaces(null); | |
717 return PAGE_GEO_FORM; | |
718 } | |
719 | |
720 public String displayByAttribute() { | |
721 Attribute att = (Attribute) getRequestBean("attribute"); | |
722 logger.info(att); | |
723 if (att != null) { | |
724 Entity ent = getWrapper().getEntityById(att.getSourceId()); | |
725 if (ent.getObjectClass().equals("TEXT")) { | |
726 this.displayTitle.showTitle(ent.getId()); | |
727 return PAGE_DISPLAY_TITLE; | |
728 } else if (ent.getObjectClass().equals("PERSON")) { | |
729 this.displayAuthor.showAuthor(ent.getId()); | |
730 return PAGE_DISPLAY_AUTHOR; | |
731 } | |
732 } | |
733 | |
734 return ""; | |
735 } | |
736 | |
737 public void displayAuthorSetPerson(String personId){ | |
738 try{ | |
739 Long id = new Long(personId); | |
740 Entity person = getWrapper().getEntityById(id); | |
741 if(person != null){ | |
742 person = getWrapper().getEntityContent(person); | |
743 if (person.getObjectClass().equals("PERSON")) { | |
744 this.displayAuthor.showAuthor(person.getId()); | |
745 } | |
746 } | |
747 }catch(Exception e){ | |
748 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
749 } | |
750 } | |
751 | |
752 public void displayAuthorSetTitle(String textId){ | |
753 try{ | |
754 Long id = new Long(textId); | |
755 this.displayAuthor.showTitle(id); | |
756 }catch(Exception e){ | |
757 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
758 } | |
759 } | |
760 | |
761 public void displayAuthorSetWitness(String witnessId){ | |
762 try{ | |
763 Long id = new Long(witnessId); | |
764 this.displayAuthor.showWitness(id); | |
765 }catch(Exception e){ | |
766 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
767 } | |
768 } | |
769 | |
770 public void displayTitleSetTitle(String textId){ | |
771 try{ | |
772 Long id = new Long(textId); | |
773 Entity ent = getWrapper().getEntityById(id); | |
774 if(ent != null){ | |
775 ent = getWrapper().getEntityContent(ent); | |
776 if (ent.getObjectClass().equals("TEXT")) { | |
777 //this.editText(ent); | |
778 this.displayTitle.showTitle(id); | |
779 } | |
780 } | |
781 }catch(Exception e){ | |
782 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
783 } | |
784 } | |
785 | |
786 public void displayTitleSetWitness(String witnessId){ | |
787 try{ | |
788 Long id = new Long(witnessId); | |
789 this.displayTitle.showWitness(id); | |
790 | |
791 }catch(Exception e){ | |
792 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
793 } | |
794 } | |
795 | |
796 public void displayTitleFromWitness(String witnessId){ | |
797 try{ | |
798 Long longWitnessId = new Long(witnessId); | |
799 | |
800 List<Entity> textList = | |
801 getWrapper().getTargetsForSourceRelation(longWitnessId, "is_exemplar_of", "TEXT", 1); | |
802 if(textList.size() > 0){ | |
803 this.displayTitle.showTitle(textList.get(0).getId()); | |
804 this.displayTitle.showWitness(longWitnessId); | |
805 } | |
806 | |
807 }catch(Exception e){ | |
808 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
809 } | |
810 } | |
811 | |
812 public void displayAuthorFromWitness(String witnessId){ | |
813 try{ | |
814 Long longWitnessId = new Long(witnessId); | |
815 | |
816 List<Entity> titleList = | |
817 getWrapper().getTargetsForSourceRelation(longWitnessId, "is_exemplar_of", "TEXT", 1); | |
818 if(titleList.size() > 0){ | |
819 Entity title = titleList.get(0); | |
820 List<Entity> authorList = | |
821 getWrapper().getTargetsForSourceRelation(title.getId(), "was_created_by", "PERSON", 1); | |
822 if(authorList.size() > 0){ | |
823 this.displayAuthor.showAuthor(authorList.get(0).getId()); | |
824 this.displayAuthor.showTitle(title.getId()); | |
825 this.displayAuthor.showWitness(longWitnessId); | |
826 } | |
827 } | |
828 | |
829 }catch(Exception e){ | |
830 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
831 } | |
832 } | |
833 | |
834 public void displayAuthorFromTitles(String titleId){ | |
835 try{ | |
836 Long longTitleId = new Long(titleId); | |
837 | |
838 List<Entity> authorList = | |
839 getWrapper().getTargetsForSourceRelation(longTitleId, "was_created_by", "PERSON", 1); | |
840 if(authorList.size() > 0){ | |
841 this.displayAuthor.showAuthor(authorList.get(0).getId()); | |
842 this.displayAuthor.showTitle(longTitleId); | |
843 } | |
844 | |
845 }catch(Exception e){ | |
846 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
847 } | |
848 } | |
849 | |
850 | |
851 public String editByAttribute() { | |
852 Attribute att = (Attribute) getRequestBean("attribute"); | |
853 logger.info(att); | |
854 if (att != null) { | |
855 Entity ent = getWrapper().getEntityById(att.getSourceId()); | |
856 if (ent != null) { | |
857 this.editEntity(ent); | |
858 return PAGE_ENTRY; | |
859 } | |
860 } | |
861 | |
862 return ""; | |
863 } | |
864 | |
865 public void setIdEntityDetails(String id){ | |
866 try{ | |
867 Long idLong = new Long(id); | |
868 Entity e = getWrapper().getEntityById(idLong); | |
869 this.entDetailsForm.setEntity(e); | |
870 }catch(Exception e){ | |
871 logger.error("[U=" + this.getUsername() + "]" + e.getMessage(), e); | |
872 } | |
873 } | |
874 | |
875 public String editByEntity() { | |
876 Entity ent = (Entity) getRequestBean("entity"); | |
877 if (ent != null) { | |
878 if (ent != null) { | |
879 this.editEntity(ent); | |
880 return PAGE_ENTRY; | |
881 } | |
882 } | |
883 return ""; | |
884 } | |
885 | |
886 public void setErrorMessages(CheckResults cr) { | |
887 | |
888 errorMessages = new ArrayList<String>(); | |
889 for (String err : cr.errors) { | |
890 errorMessages.add(err); | |
891 } | |
892 | |
893 } | |
894 | |
895 public void setDisplayError(boolean b) { | |
896 displayError = b; | |
897 | |
898 } | |
899 | |
900 public boolean getDisplayError() { | |
901 return displayError; | |
902 } | |
903 | |
904 public ArrayList<String> getErrorMessages() { | |
905 return errorMessages; | |
906 } | |
907 | |
908 public User getUser() { | |
909 if(user == null){ | |
910 autoLogin(); | |
911 } | |
912 return user; | |
913 } | |
914 | |
915 public void setUser(User user) { | |
916 this.user = user; | |
917 } | |
918 | |
919 public String getUsername() { | |
920 return username; | |
921 } | |
922 | |
923 public void setUsername(String username) { | |
924 this.username = username; | |
925 } | |
926 | |
927 public String getPassword() { | |
928 return password; | |
929 } | |
930 | |
931 public void setPassword(String password) { | |
932 this.password = password; | |
933 } | |
934 | |
935 public GeneralMerge getGeneralMerge() { | |
936 return generalMerge; | |
937 } | |
938 | |
939 public void setGeneralMerge(GeneralMerge generalMerge) { | |
940 this.generalMerge = generalMerge; | |
941 } | |
942 | |
943 public DefinitionForm getDefForm() { | |
944 return defForm; | |
945 } | |
946 | |
947 public void setDefForm(DefinitionForm defForm) { | |
948 this.defForm = defForm; | |
949 } | |
950 | |
951 public StudyEvent getStudyEventForm() { | |
952 return studyEventForm; | |
953 } | |
954 | |
955 public void setStudyEventForm(StudyEvent studyEventForm) { | |
956 this.studyEventForm = studyEventForm; | |
957 } | |
958 | |
959 public CopyEvent getCopyEventForm() { | |
960 return copyEventForm; | |
961 } | |
962 | |
963 public void setCopyEventForm(CopyEvent copyEventForm) { | |
964 this.copyEventForm = copyEventForm; | |
965 } | |
966 | |
967 public TransferEvent getTransferEventForm() { | |
968 return transferEventForm; | |
969 } | |
970 | |
971 public void setTransferEventForm(TransferEvent transferEventForm) { | |
972 this.transferEventForm = transferEventForm; | |
973 } | |
974 | |
975 public String getSelectedEventTab() { | |
976 return selectedEventTab; | |
977 } | |
978 | |
979 public void setSelectedEventTab(String selectedEventTab) { | |
980 this.selectedEventTab = selectedEventTab; | |
981 } | |
982 | |
983 public AdvancedSearchBean getAdvancedSearch() { | |
984 return advancedSearch; | |
985 } | |
986 | |
987 public void setAdvancedSearch(AdvancedSearchBean advancedSearch) { | |
988 this.advancedSearch = advancedSearch; | |
989 } | |
990 | |
991 public DisplayAuthorBean getDisplayAuthor() { | |
992 return displayAuthor; | |
993 } | |
994 | |
995 public void setDisplayAuthor(DisplayAuthorBean displayAuthor) { | |
996 this.displayAuthor = displayAuthor; | |
997 } | |
998 | |
999 public DisplayTitleBean getDisplayTitle() { | |
1000 return displayTitle; | |
1001 } | |
1002 | |
1003 public void setDisplayTitle(DisplayTitleBean displayTitle) { | |
1004 this.displayTitle = displayTitle; | |
1005 } | |
1006 | |
1007 public Calendar getCurrentCalendar() { | |
1008 return currentCalendar; | |
1009 } | |
1010 | |
1011 public void setCurrentCalendar(Calendar currentCalendar) { | |
1012 this.currentCalendar = currentCalendar; | |
1013 } | |
1014 | |
1015 public EntityList getCurrentEntListForCalendar() { | |
1016 return currentEntListForCalendar; | |
1017 } | |
1018 | |
1019 public void setCurrentEntListForCalendar(EntityList currentEntListForCalendar) { | |
1020 this.currentEntListForCalendar = currentEntListForCalendar; | |
1021 } | |
1022 | |
1023 public Long getCurrentEntIdForCalendar() { | |
1024 return currentEntIdForCalendar; | |
1025 } | |
1026 | |
1027 public void setCurrentEntIdForCalendar(Long currentEntIdForCalendar) { | |
1028 this.currentEntIdForCalendar = currentEntIdForCalendar; | |
1029 } | |
1030 | |
1031 public boolean isDisplayLoginDialog() { | |
1032 return displayLoginDialog; | |
1033 } | |
1034 | |
1035 public boolean isDisplayLoginDialog4PrivatePage(){ | |
1036 return displayLoginDialog || this.user == null; | |
1037 } | |
1038 | |
1039 public boolean isDisplayLoginDialog4PublicPage(){ | |
1040 return displayLoginDialog; | |
1041 } | |
1042 | |
1043 public EntityDetailsBean getEntDetailsForm() { | |
1044 return entDetailsForm; | |
1045 } | |
1046 | |
1047 public void setEntDetailsForm(EntityDetailsBean entDetailsForm) { | |
1048 this.entDetailsForm = entDetailsForm; | |
1049 } | |
1050 | |
1051 public ESciDocItemForm geteSciDocForm() { | |
1052 return eSciDocForm; | |
1053 } | |
1054 | |
1055 public void seteSciDocForm(ESciDocItemForm eSciDocForm) { | |
1056 this.eSciDocForm = eSciDocForm; | |
1057 } | |
1058 | |
1059 public ESciDocItemDataTable getRefDataTable() { | |
1060 return refDataTable; | |
1061 } | |
1062 | |
1063 public void setRefDataTable(ESciDocItemDataTable refDataTable) { | |
1064 this.refDataTable = refDataTable; | |
1065 } | |
1066 | |
1067 public GeonameForm getGeoForm() { | |
1068 return geoForm; | |
1069 } | |
1070 | |
1071 public String getSelectedTab() { | |
1072 return selectedTab; | |
1073 } | |
1074 | |
1075 public String getSelectedAdvancedSearchTab() { | |
1076 return selectedAdvancedSearchTab; | |
1077 } | |
1078 | |
1079 public void setSelectedAdvancedSearchTab(String selectedAdvancedSearchTab) { | |
1080 this.selectedAdvancedSearchTab = selectedAdvancedSearchTab; | |
1081 } | |
1082 | |
1083 | |
1084 public DynamicPageEditor getPageEditor(){ | |
1085 if(this.pageEditor == null){ | |
1086 this.pageEditor = new DynamicPageEditor(); | |
1087 } | |
1088 return this.pageEditor; | |
1089 } | |
1090 | |
1091 public DigiListBean getDigiList() { | |
1092 if(digiList == null){ | |
1093 digiList = new DigiListBean(getWrapper()); | |
1094 } | |
1095 | |
1096 return digiList; | |
1097 } | |
1098 | |
1099 public DynamicPage getDynamicPage() { | |
1100 if(dynamicPage == null){ | |
1101 this.dynamicPage = new DynamicPage(); | |
1102 } | |
1103 return dynamicPage; | |
1104 } | |
1105 | |
1106 public void setDynamicPage(DynamicPage dynamicPage) { | |
1107 this.dynamicPage = dynamicPage; | |
1108 } | |
1109 | |
1110 public PublicCodexView getPublicCodexView(){ | |
1111 if(publicCodexView == null){ | |
1112 this.publicCodexView = new PublicCodexView(); | |
1113 } | |
1114 return this.publicCodexView; | |
1115 } | |
1116 | |
1117 public PublicCodexBean getPublicCodexBean() { | |
1118 if(publicCodexBean == null){ | |
1119 this.publicCodexBean = new PublicCodexBean(); | |
1120 } | |
1121 return publicCodexBean; | |
1122 } | |
1123 | |
1124 public void setPublicCodexBean(PublicCodexBean publicCodexBean) { | |
1125 this.publicCodexBean = publicCodexBean; | |
1126 } | |
1127 | |
1128 | |
1129 | |
1130 } | |
1131 |