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