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