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