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