1
|
1 package de.mpiwg.itgroup.ismi.entry.beans;
|
|
2
|
|
3 import java.io.Serializable;
|
|
4 import java.util.ArrayList;
|
|
5 import java.util.HashMap;
|
|
6 import java.util.List;
|
|
7 import java.util.Map;
|
|
8
|
|
9 import javax.faces.event.ActionEvent;
|
|
10 import javax.faces.event.AjaxBehaviorEvent;
|
|
11 import javax.faces.event.ValueChangeEvent;
|
|
12 import javax.faces.model.SelectItem;
|
|
13
|
|
14 import org.apache.commons.lang.StringUtils;
|
|
15 import org.apache.log4j.Logger;
|
|
16 import org.mpi.openmind.repository.bo.Attribute;
|
|
17 import org.mpi.openmind.repository.bo.Entity;
|
|
18 import org.mpi.openmind.repository.bo.Node;
|
|
19 import org.mpi.openmind.repository.bo.Relation;
|
|
20 import org.mpi.openmind.repository.utils.NormalizerUtils;
|
|
21 import org.mpi.openmind.repository.utils.RomanizationLoC;
|
|
22 import org.mpi.openmind.repository.utils.TransliterationUtil;
|
|
23 import org.mpi.openmind.security.bo.User;
|
|
24
|
|
25 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject;
|
|
26 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar;
|
91
|
27 import de.mpiwg.itgroup.ismi.util.guiComponents.Misattribution;
|
|
28 import de.mpiwg.itgroup.ismi.util.guiComponents.MisattributionTable;
|
1
|
29 import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList;
|
|
30
|
90
|
31 public class CurrentTextBean extends AbstractISMIBean implements Serializable{
|
1
|
32 private static final long serialVersionUID = 1017399812886455381L;
|
|
33
|
|
34 private static Logger logger = Logger.getLogger(CurrentTextBean.class);
|
|
35
|
|
36 private String valueShortTitle;
|
|
37 private Entity shortTitleAlias; // is now an alias of type "prime"
|
|
38 private String romanizedTitle;
|
|
39 private String romanizedPrimaAlias;
|
|
40
|
|
41 private String valueTranslitTitle;
|
|
42 private Entity translitTitleAlias; // is now an alias of type "prime"
|
|
43
|
|
44 private ListenerObject authorLo = new ListenerObject(PERSON, "name_translit");
|
|
45 //private String authorInfo;
|
|
46
|
|
47 private ListenerObject placeLo = new ListenerObject(PLACE, "name");
|
|
48
|
|
49 private ListenerObject dedicatedPersonLo = new ListenerObject(PERSON, "name_translit");
|
|
50
|
|
51 private ListenerObject commentaryLo = new ListenerObject(TEXT, "full_title_translit");
|
|
52
|
|
53 private ListenerObject translationLo = new ListenerObject(TEXT, "full_title_translit");
|
|
54
|
|
55 private ListenerObject versionLo = new ListenerObject(TEXT, "full_title_translit");
|
|
56
|
|
57 private static String PERSON_TYPE_CREATED_BY = "created_by";
|
|
58 private static String PERSON_TYPE_DEDICATED_TO = "dedicated_to";
|
|
59 private String personType;
|
|
60
|
|
61 private Attribute attTitleAlias = new Attribute();
|
|
62 private Map<Long, Boolean> deletedTitleAliases = new HashMap<Long, Boolean>();
|
|
63 private String newTitleAlias;
|
|
64
|
|
65 private Attribute attIncipitAlias = new Attribute();
|
|
66 private Map<Long, Boolean> deletedIncipitAliases = new HashMap<Long, Boolean>();
|
|
67 private String newIncipitAlias;
|
|
68
|
|
69 private Attribute attExplicitAlias = new Attribute();
|
|
70 private Map<Long, Boolean> deletedExplicitAliases = new HashMap<Long, Boolean>();
|
|
71 private String newExplicitAlias;
|
|
72
|
|
73 private Long idSubject;
|
|
74 private Entity subject;
|
|
75
|
|
76 public static String main_subject = "main_subject";
|
|
77 public static String sub_subject = "sub_subject";
|
|
78 public static String type = "type";
|
|
79 public static String NO_SUBJECT = "NO_SUBJECT";
|
|
80
|
|
81 private boolean searchTextDialogRendered = false;
|
|
82 private String stringTitle;
|
|
83 private String stringAuthor;
|
|
84 private List<SelectItem> textsFound = new ArrayList<SelectItem>();
|
|
85
|
|
86 private Long idTextSelected;
|
|
87
|
|
88 private String COMMENTARY_CALLER = "Commentary";
|
|
89 private String TRANSLATION_CALLER = "Translation";
|
|
90 private String VERSION_CALLER = "Version";
|
|
91
|
|
92 private String searchCaller;
|
|
93
|
|
94 private transient Calendar creationDate;
|
|
95
|
|
96 private String textAuthorName;
|
|
97 private String textAuthorNameTranslit;
|
|
98
|
|
99 private Boolean selectPersonRendered = false;
|
|
100 private List<SelectItem> personList = new ArrayList<SelectItem>();
|
|
101 private Long selectedPersonId;
|
|
102 private boolean restrictedByRole = false;
|
|
103
|
|
104 private EntityList aliasList;
|
|
105 private EntityList incipitAliasList;
|
|
106 private EntityList explicitAliasList;
|
|
107
|
|
108 //private MisattributionDataTable misattDataTable;
|
91
|
109 private transient MisattributionTable misattTable;
|
1
|
110
|
|
111 public CurrentTextBean() {
|
|
112 this.reset();
|
|
113 }
|
|
114
|
|
115 @Override
|
|
116 public void reset(){
|
|
117 super.reset();
|
|
118 this.entity = new Entity(Node.TYPE_ABOX, TEXT, false);
|
|
119 setDefObjectClass(TEXT);
|
|
120
|
|
121 this.aliasList = new EntityList(ALIAS, "alias", getWrapper(), getUserName());
|
|
122 this.incipitAliasList = new EntityList(ALIAS, "alias", getWrapper(), getUserName());
|
|
123 this.explicitAliasList = new EntityList(ALIAS, "alias", getWrapper(), getUserName());
|
|
124 //this.misattDataTable = new MisattributionDataTable(PERSON, "name_translit");
|
91
|
125 this.misattTable = new MisattributionTable();
|
1
|
126
|
|
127 this.selectPersonRendered = false;
|
|
128 this.selectedPersonId = null;
|
|
129 this.personList = new ArrayList<SelectItem>();
|
|
130 this.restrictedByRole = false;
|
|
131
|
|
132 this.textAuthorName = new String();
|
|
133 this.textAuthorNameTranslit = new String();
|
|
134
|
|
135 this.valueShortTitle = null;
|
|
136 this.shortTitleAlias = null; // is now an alias of type "prime"
|
|
137
|
|
138 this.valueTranslitTitle = null;
|
|
139 this.translitTitleAlias = null; // is now an alias of type "prime"
|
|
140
|
|
141 //this.authorLo = new ListenerObject();
|
|
142 this.authorLo.reset();
|
|
143 //this.authorInfo = null;
|
|
144
|
|
145 //this.placeLo = new ListenerObject();
|
|
146 this.placeLo.reset();
|
|
147
|
|
148 this.dedicatedPersonLo.reset();
|
|
149
|
|
150 this.commentaryLo.reset();
|
|
151
|
|
152 this.translationLo.reset();
|
|
153
|
|
154 this.versionLo.reset();
|
|
155
|
|
156 this.attTitleAlias = new Attribute();
|
|
157 this.deletedTitleAliases = new HashMap<Long, Boolean>();
|
|
158 this.newTitleAlias = null;
|
|
159
|
|
160 this.attIncipitAlias = new Attribute();
|
|
161 this.deletedIncipitAliases = new HashMap<Long, Boolean>();
|
|
162 this.newIncipitAlias = null;
|
|
163
|
|
164 this.attExplicitAlias = new Attribute();
|
|
165 this.deletedExplicitAliases = new HashMap<Long, Boolean>();
|
|
166 this.newExplicitAlias = null;
|
|
167
|
|
168 this.idSubject = null;
|
|
169 this.subject = null;
|
|
170
|
|
171 this.creationDate = new Calendar();
|
|
172
|
|
173
|
|
174 registerChecker(authorLo, "Creator is not valid!");
|
|
175 registerChecker(placeLo, "Place is not valid!");
|
|
176 registerChecker(dedicatedPersonLo, "Place is not valid!");
|
|
177 registerChecker(commentaryLo, "Commentary is not valid!");
|
|
178 registerChecker(translationLo, "Translation is not valid!");
|
|
179 registerChecker(versionLo, "Version is not valid!");
|
|
180
|
|
181 //getPopup().setRendered(false);
|
|
182 }
|
|
183
|
|
184 public List<SelectItem> getPersonList() {
|
|
185 return personList;
|
|
186 }
|
|
187
|
|
188 public void setPersonList(List<SelectItem> personList) {
|
|
189 this.personList = personList;
|
|
190 }
|
|
191
|
|
192 public Boolean getSelectPersonRendered() {
|
|
193 return selectPersonRendered;
|
|
194 }
|
|
195
|
|
196 public void setSelectPersonRendered(Boolean selectPersonRendered) {
|
|
197 this.selectPersonRendered = selectPersonRendered;
|
|
198 }
|
|
199
|
|
200 /**
|
91
|
201 * Set entity and process attributes and relations.
|
1
|
202 *
|
91
|
203 * Source Relations:
|
|
204 * TEXT is_commentary_on TEXT,
|
|
205 * TEXT is_translation_of TEXT,
|
|
206 * TEXT is_version_of TEXT,
|
|
207 * TEXT was_created_by PERSON,
|
|
208 * TEXT was_created_in PLACE,
|
|
209 * TEXT was_dedicated_to PERSON,
|
|
210 * TEXT has_subject SUBJECT
|
|
211 *
|
|
212 * Target Relations:
|
|
213 * ALIAS is_alias_title_of TEXT,
|
|
214 * ALIAS is_alias_incipit_of TEXT
|
1
|
215 *
|
|
216 * @param text
|
|
217 */
|
|
218 @Override
|
|
219 public void setEntity(Entity text) {
|
|
220 this.reset();
|
|
221 this.entity = text;
|
91
|
222 if (this.entity.isPersistent()) {
|
|
223 // set id
|
1
|
224 setCurrentId(this.entity.getId().toString());
|
91
|
225
|
|
226 // load content
|
1
|
227 if (text.isLightweight()) {
|
|
228 this.entity = getWrapper().getEntityContent(this.entity);
|
|
229 this.entity.setLightweight(false);
|
|
230 }
|
|
231
|
91
|
232 // set creation date
|
1
|
233 Attribute attCreationDate = this.entity.getAttributeByName("creation_date");
|
91
|
234 if(attCreationDate != null && StringUtils.isNotEmpty(attCreationDate.getOwnValue())) {
|
1
|
235 this.creationDate = new Calendar(attCreationDate.getOwnValue());
|
91
|
236 } else {
|
1
|
237 this.creationDate = new Calendar();
|
|
238 }
|
|
239
|
91
|
240 /*
|
|
241 * set attributes
|
|
242 */
|
1
|
243 this.loadAttributes(this.entity);//, getDefinition(this.entity));
|
|
244
|
91
|
245 /*
|
|
246 * set source relations
|
|
247 */
|
1
|
248 for (Relation rel : text.getSourceRelations()) {
|
|
249 Entity target = null;
|
91
|
250 String relName = rel.getOwnValue();
|
|
251 if(relName.equals(has_subject)) {
|
1
|
252 this.subject = getTargetRelation(rel);
|
|
253 this.idSubject = subject.getId();
|
91
|
254
|
|
255 } else if (relName.equals("is_commentary_on")) {
|
1
|
256 target = getTargetRelation(rel);
|
|
257 this.commentaryLo.setEntityAndAttribute0(target);
|
91
|
258
|
|
259 } else if (relName.equals("is_translation_of")) {
|
1
|
260 target = getTargetRelation(rel);
|
|
261 this.translationLo.setEntityAndAttribute0(target);
|
91
|
262
|
|
263 } else if (relName.equals("is_version_of")) {
|
1
|
264 target = getTargetRelation(rel);
|
|
265 this.versionLo.setEntityAndAttribute0(target);
|
91
|
266
|
|
267 } else if (relName.equals("was_created_by")) {
|
1
|
268 target = getTargetRelation(rel);
|
|
269 this.authorLo.setEntityAndAttribute0(target);
|
|
270
|
91
|
271 if (this.authorLo.attribute != null) {
|
1
|
272 this.textAuthorNameTranslit = this.authorLo.attribute.getValue();
|
|
273 }
|
|
274
|
91
|
275 } else if (relName.equals("was_dedicated_to")) {
|
1
|
276 target = getTargetRelation(rel);
|
|
277 this.dedicatedPersonLo.setEntityAndAttribute0(target);
|
|
278
|
91
|
279 } else if (relName.equals("was_created_in")) {
|
1
|
280 target = getTargetRelation(rel);
|
|
281 this.placeLo.setEntityAndAttribute0(target);
|
91
|
282
|
|
283 } else if (relName.equals("has_author_misattribution")) {
|
1
|
284 target = getTargetRelation(rel);
|
|
285 this.misattTable.load(target);
|
|
286 }
|
|
287 }
|
91
|
288
|
|
289 /*
|
|
290 * set target relations
|
|
291 */
|
1
|
292 for (Relation rel : text.getTargetRelations()) {
|
91
|
293 String relName = rel.getOwnValue();
|
|
294 if (relName.equals("is_alias_title_of")) {
|
1
|
295 Entity alias = getWrapper().getEntityByIdWithContent(rel.getSourceId());
|
91
|
296 this.aliasList.add(alias);
|
|
297
|
|
298 } else if (relName.equals("is_alias_incipit_of")) {
|
1
|
299 Entity alias = getWrapper().getEntityByIdWithContent(rel.getSourceId());
|
|
300 this.incipitAliasList.add(alias);
|
91
|
301
|
|
302 } else if (relName.equals("is_alias_explicit_of")) {
|
1
|
303 Entity alias = getWrapper().getEntityByIdWithContent(rel.getSourceId());
|
|
304 this.explicitAliasList.add(alias);
|
91
|
305
|
|
306 } else if (relName.equals("is_prime_alias_title_of")) {
|
1
|
307 Entity alias = getWrapper().getEntityByIdWithContent(rel.getSourceId());
|
|
308 this.shortTitleAlias = alias;
|
|
309 this.valueShortTitle = alias.getAttributeByName("alias").getValue();
|
|
310 }
|
9
|
311 }
|
|
312
|
91
|
313 /*
|
|
314 * set references
|
|
315 */
|
1
|
316 this.loadEndNoteRefs();
|
|
317 this.displayUrl = generateDisplayUrl(authorLo.entity, text, null, getAppBean().getRoot());
|
|
318 }
|
|
319 }
|
|
320
|
|
321 public String translitTitleAction() {
|
|
322 String pn = getAttributes().get("full_title");
|
|
323
|
|
324 String translit = TransliterationUtil.getTransliteration(pn);
|
|
325 getAttributes().put("full_title_translit", translit);
|
|
326
|
|
327 return "translit";
|
|
328
|
|
329 }
|
|
330
|
|
331 public void showSearchTextCommentaryDialog(ActionEvent event) {
|
|
332 this.setSearchTextDialogRendered(true);
|
|
333 this.searchCaller = COMMENTARY_CALLER;
|
|
334 }
|
|
335
|
|
336 public void showSearchTextTranslationDialog(ActionEvent event) {
|
|
337 this.setSearchTextDialogRendered(true);
|
|
338 this.searchCaller = TRANSLATION_CALLER;
|
|
339 }
|
|
340
|
|
341 public void showSearchTextVersionDialog(ActionEvent event) {
|
|
342 this.setSearchTextDialogRendered(true);
|
|
343 this.searchCaller = VERSION_CALLER;
|
|
344 }
|
|
345
|
|
346 public void closeSearchTextDialog(ActionEvent event) {
|
|
347 this.setSearchTextDialogRendered(false);
|
|
348 }
|
|
349
|
|
350 public void resetSearchText(ActionEvent event) {
|
|
351 this.textsFound = new ArrayList<SelectItem>();
|
|
352 this.stringAuthor = "";
|
|
353 this.stringTitle = "";
|
|
354 }
|
|
355
|
|
356 public void takeVersion(ActionEvent event) {
|
|
357 if(this.idTextSelected != null){
|
|
358 Entity ent = getWrapper().getEntityById(idTextSelected);
|
|
359 if(ent != null){
|
|
360 if (VERSION_CALLER.equals(this.searchCaller)) {
|
|
361 this.versionLo.setEntityAndAttribute0(ent);
|
|
362
|
|
363 } else if (COMMENTARY_CALLER.equals(this.searchCaller)) {
|
|
364 this.commentaryLo.setEntityAndAttribute0(ent);
|
|
365
|
|
366 } else if (TRANSLATION_CALLER.equals(this.searchCaller)) {
|
|
367 this.translationLo.setEntityAndAttribute0(ent);
|
|
368 }
|
|
369 this.searchTextDialogRendered = false;
|
|
370 }
|
|
371 }
|
|
372 }
|
|
373
|
|
374 public String getStringTitle() {
|
|
375 return stringTitle;
|
|
376 }
|
|
377
|
|
378 public void setStringTitle(String stringTitle) {
|
|
379 this.stringTitle = stringTitle;
|
|
380 }
|
|
381
|
|
382 public String getStringAuthor() {
|
|
383 return stringAuthor;
|
|
384 }
|
|
385
|
|
386 public void setStringAuthor(String stringAuthor) {
|
|
387 this.stringAuthor = stringAuthor;
|
|
388 }
|
|
389
|
|
390 public void searchText(ActionEvent event) {
|
|
391 this.textsFound = new ArrayList<SelectItem>();
|
|
392
|
|
393 if(StringUtils.isNotEmpty(stringTitle)){
|
|
394 if (StringUtils.isNotEmpty(this.stringAuthor)) {
|
|
395 String termAuthor = NormalizerUtils.normalize(stringAuthor);
|
|
396 for(Entity title : getWrapper().getEntitiesByAtt(TEXT, "full_title_translit", stringTitle, -1, true)){
|
|
397 for(Entity author :
|
|
398 getWrapper().getTargetsForSourceRelation(title, "was_created_by", PERSON, -1)){
|
|
399 String authorOW = (StringUtils.isNotEmpty(author.getNormalizedOwnValue())) ? author.getNormalizedOwnValue() : "";
|
|
400 if(authorOW.contains(termAuthor)){
|
|
401 this.textsFound.add(
|
|
402 new SelectItem(title.getId(), "Title [" + title.getId() + "]: " + title.getOwnValue()
|
|
403 + " - Author: " + author.getOwnValue()));
|
|
404 }
|
|
405 }
|
|
406 }
|
|
407 }else{
|
|
408 for(Entity title : getWrapper().getEntitiesByAtt(TEXT, "full_title_translit", stringTitle, -1, true)){
|
|
409 this.textsFound.add(
|
|
410 new SelectItem(title.getId(), "Title: " + title.getOwnValue()));
|
|
411 }
|
|
412 }
|
|
413 }else if (StringUtils.isNotEmpty(this.stringAuthor)) {
|
|
414 String termAuthor = NormalizerUtils.normalize(stringAuthor);
|
|
415 for(Entity author : getCache().getPersonListByRole("Author")){
|
|
416 String authorOW = (StringUtils.isNotEmpty(author.getNormalizedOwnValue())) ? author.getNormalizedOwnValue() : "";
|
|
417 if(authorOW.contains(termAuthor)){
|
|
418 for(Entity title :
|
|
419 getWrapper().getSourcesForTargetRelation(author, "was_created_by", TEXT, -1)){
|
|
420 this.textsFound.add(
|
|
421 new SelectItem(title.getId(), "Author[" + author.getId() + "]: " + author.getOwnValue()
|
|
422 + " - Title: " + title.getOwnValue()));
|
|
423 }
|
|
424 }
|
|
425 }
|
|
426 }
|
|
427 }
|
|
428
|
|
429 public void restrictedByRoleChange(ValueChangeEvent event) {
|
|
430 if (event.getNewValue().equals(event.getOldValue()))
|
|
431 return;
|
|
432 Boolean val = (Boolean) event.getNewValue();
|
|
433 this.setRestrictedByRole(val);
|
|
434 this.updatePersonList();
|
|
435 }
|
|
436
|
|
437 public void listenerRomanizeTitleTranslit(AjaxBehaviorEvent event){
|
|
438 if(getAttributes().get("full_title_translit") != null)
|
|
439 this.romanizedTitle = RomanizationLoC.convert(getAttributes().get("full_title_translit"));
|
|
440 }
|
|
441
|
|
442 public void listenerRomanizePrimaAlias(AjaxBehaviorEvent event){
|
|
443 if(valueShortTitle != null){
|
|
444 this.romanizedPrimaAlias = RomanizationLoC.convert(valueShortTitle);
|
|
445 }
|
|
446 }
|
|
447
|
|
448 public void listenerShowAllAuthors(ActionEvent event) {
|
|
449 this.setPersonType(PERSON_TYPE_CREATED_BY);
|
|
450 this.updatePersonList();
|
|
451 }
|
|
452
|
|
453 public void listenerShowAllDedicatedToPersons(ActionEvent event) {
|
|
454 this.setPersonType(PERSON_TYPE_DEDICATED_TO);
|
|
455 this.updatePersonList();
|
|
456 }
|
|
457
|
|
458 private void updatePersonList(){
|
|
459 if (!restrictedByRole)
|
|
460 this.personList = getCache().getAllPersons();
|
|
461 else {
|
|
462 this.personList = getCache().getPersonsByRole("Author");
|
|
463 }
|
|
464 this.selectPersonRendered = true;
|
|
465 }
|
|
466
|
|
467 public void listenerPersonCancel(ActionEvent event) {
|
|
468 this.selectPersonRendered = false;
|
|
469 }
|
|
470
|
|
471 public void listenerSelectPerson(ActionEvent event){
|
|
472 if(this.selectedPersonId != null){
|
|
473 Entity selectedPerson = getWrapper().getEntityById(selectedPersonId);
|
|
474 if(selectedPerson != null){
|
|
475 if(this.personType.equals(PERSON_TYPE_CREATED_BY)){
|
|
476 this.authorLo.setEntityAndAttribute0(selectedPerson);
|
|
477 this.authorLo.entityInfo = "ID = " + authorLo.getEntity().getId();
|
|
478
|
|
479 Attribute attArabicName = getTargetAttribute(selectedPerson, "name");
|
|
480 if(attArabicName != null){
|
|
481 this.authorLo.entityInfo += ", Arabic Name = " + attArabicName.getOwnValue();
|
|
482 this.textAuthorName = attArabicName.getValue();
|
|
483 }
|
|
484
|
|
485 if(this.authorLo.attribute != null){
|
|
486 this.textAuthorNameTranslit = this.authorLo.attribute.getValue();
|
|
487 }
|
|
488 }else if(this.personType.equals(PERSON_TYPE_DEDICATED_TO)){
|
|
489 this.dedicatedPersonLo.setEntityAndAttribute0(selectedPerson);
|
|
490 }
|
|
491 }
|
|
492 }
|
|
493 this.setSelectPersonRendered(false);
|
|
494 }
|
|
495
|
91
|
496 /**
|
|
497 * Check mandatory parts.
|
|
498 *
|
|
499 * In this case the author has to be set.
|
|
500 *
|
|
501 * @return
|
|
502 */
|
1
|
503 public boolean mandatoryEntriesOK(){
|
|
504 boolean ok = true;
|
|
505 if(this.authorLo.entity == null || !this.authorLo.entity.isPersistent()){
|
|
506 addGeneralMsg("<Created by> is a mandatory entry. If you do not know the author of this text, you should select the person <ANONYMOUS>.");
|
|
507 ok = false;
|
|
508 }
|
|
509 return ok;
|
|
510 }
|
|
511
|
91
|
512 /* (non-Javadoc)
|
|
513 * @see de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean#save()
|
|
514 */
|
1
|
515 @Override
|
|
516 public String save() {
|
|
517 super.save();
|
|
518 try {
|
|
519
|
91
|
520 /*
|
|
521 * check input
|
|
522 */
|
|
523 if (!mandatoryEntriesOK()) {
|
1
|
524 addGeneralMsg("The entity could not be saved.");
|
|
525 return PAGE_EDITOR;
|
91
|
526 }
|
1
|
527 CheckResults cr = getCheckResults();
|
|
528 if (cr.hasErrors) {
|
|
529 getSessionBean().setErrorMessages(cr);
|
|
530 getSessionBean().setDisplayError(true);
|
|
531 return PAGE_EDITOR;
|
|
532 }
|
|
533
|
91
|
534 User user = getSessionUser();
|
1
|
535
|
91
|
536 // add creation date
|
1
|
537 getAttributes().put("creation_date", this.creationDate.toJSONString());
|
|
538
|
91
|
539 // update all attributes
|
1
|
540 this.entity = updateEntityAttributes(this.entity);
|
|
541
|
91
|
542 /*
|
|
543 * set relations
|
|
544 */
|
1
|
545 this.entity.replaceSourceRelation(commentaryLo.entity, TEXT, "is_commentary_on");
|
|
546
|
|
547 this.entity.replaceSourceRelation(translationLo.entity, TEXT, "is_translation_of");
|
|
548
|
|
549 this.entity.replaceSourceRelation(versionLo.entity, TEXT, "is_version_of");
|
|
550
|
|
551 this.entity.replaceSourceRelation(authorLo.entity, PERSON, "was_created_by");
|
|
552
|
|
553 this.entity.replaceSourceRelation(dedicatedPersonLo.entity, PERSON, "was_dedicated_to");
|
|
554
|
|
555 this.entity.replaceSourceRelation(placeLo.entity, PLACE, "was_created_in");
|
|
556
|
|
557 this.entity.removeAllSourceRelations(has_subject, SUBJECT);
|
91
|
558 if (getIdSubject() != null) {
|
1
|
559 this.subject = getWrapper().getEntityByIdWithContent(getIdSubject());
|
|
560 this.entity.replaceSourceRelation(subject, SUBJECT, has_subject);
|
|
561 }
|
|
562
|
91
|
563 /*
|
|
564 * set short title (is_prime_alias_title_of)
|
|
565 */
|
|
566 if (!StringUtils.isEmpty(valueShortTitle)) {
|
1
|
567 this.entity.removeAllTargetRelations("is_prime_alias_title_of", ALIAS);
|
|
568
|
91
|
569 if (this.shortTitleAlias == null) {
|
1
|
570 //1)create alias, 2) update value of alias3) save alias, and 4) add to this text.
|
|
571 shortTitleAlias = new Entity(Node.TYPE_ABOX, ALIAS, false);
|
|
572 shortTitleAlias.addAttribute(new Attribute("alias", "text", this.valueShortTitle));
|
|
573 getWrapper().saveEntity(shortTitleAlias, getUserName());
|
91
|
574 } else {
|
1
|
575 //1) update value, 2) re-save alias
|
|
576 this.shortTitleAlias.getAttributeByName("alias").setOwnValue(this.valueShortTitle);
|
|
577 this.shortTitleAlias.removeAllSourceRelations("is_prime_alias_title_of", TEXT);
|
|
578 getWrapper().saveEntity(shortTitleAlias, getUserName());
|
|
579 }
|
91
|
580 new Relation(shortTitleAlias, this.entity, "is_prime_alias_title_of");
|
1
|
581 }
|
|
582
|
|
583 /*
|
91
|
584 * set alias title (ALIAS -> is_alias_title_of -> TEXT)
|
|
585 */
|
1
|
586 this.entity.removeAllTargetRelationsByName("is_alias_title_of");
|
|
587 for(Entity alias : this.aliasList.getEntities()){
|
|
588 Entity alias0 = getWrapper().getEntityByIdWithContent(alias.getId());
|
91
|
589 new Relation(alias0, this.entity, "is_alias_title_of");
|
1
|
590 }
|
|
591
|
91
|
592 /*
|
|
593 * set alias incipit
|
|
594 */
|
1
|
595 this.entity.removeAllTargetRelationsByName("is_alias_incipit_of");
|
|
596 for(Entity alias : this.incipitAliasList.getEntities()){
|
|
597 Entity alias0 = getWrapper().getEntityByIdWithContent(alias.getId());
|
91
|
598 new Relation(alias0, this.entity, "is_alias_incipit_of");
|
1
|
599 }
|
|
600
|
|
601 /*
|
91
|
602 * save alias explicit
|
|
603 */
|
1
|
604 this.entity.removeAllTargetRelationsByName("is_alias_explicit_of");
|
|
605 for(Entity alias : this.explicitAliasList.getEntities()){
|
|
606 Entity alias0 = getWrapper().getEntityByIdWithContent(alias.getId());
|
91
|
607 new Relation(alias0, this.entity, "is_alias_explicit_of");
|
1
|
608 }
|
|
609
|
91
|
610 // set references
|
1
|
611 this.prepareEndNoteRefs2Save();
|
|
612
|
91
|
613 /*
|
|
614 * set misattribution
|
|
615 */
|
|
616 this.entity.removeAllSourceRelations(Misattribution.HAS_AUTHOR_MISATT, Misattribution.MISATT);
|
1
|
617
|
91
|
618 /*
|
|
619 * save entity
|
|
620 */
|
1
|
621 this.entity = getWrapper().saveEntity(this.entity, user.getEmail());
|
|
622 this.getAppBean().setAllTextsAsDirty();
|
|
623 getAppBean().getSimpleSearchCache().setMapDirty(true);
|
|
624
|
91
|
625 /*
|
|
626 * save misattributions
|
|
627 */
|
1
|
628 this.entity = this.misattTable.saveMisattributions(this.entity);
|
|
629
|
91
|
630 // re-set entity
|
1
|
631 this.setEntity(this.entity);
|
91
|
632
|
|
633 // update related own values
|
|
634 this.updateRelatedOW(this.entity, getSessionUser().getEmail());
|
1
|
635
|
|
636 logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity);
|
91
|
637
|
|
638 // print success
|
1
|
639 this.printSuccessSavingEntity();
|
|
640
|
|
641 } catch (Exception e) {
|
|
642 logger.error(e.getMessage(), e);
|
|
643 this.printInternalError(e);
|
|
644 }
|
91
|
645
|
|
646 // end saving
|
1
|
647 saveEnd();
|
91
|
648 // stay on edit page
|
1
|
649 return PAGE_EDITOR;
|
|
650 }
|
|
651
|
|
652 public EntityList getIncipitAliasList() {
|
|
653 return incipitAliasList;
|
|
654 }
|
|
655
|
|
656 public void setIncipitAliasList(EntityList incipitAliasList) {
|
|
657 this.incipitAliasList = incipitAliasList;
|
|
658 }
|
|
659
|
|
660 public Attribute getAttTitleAlias() {
|
|
661 return attTitleAlias;
|
|
662 }
|
|
663
|
|
664 public void setAttTitleAlias(Attribute attTitleAlias) {
|
|
665 this.attTitleAlias = attTitleAlias;
|
|
666 }
|
|
667
|
|
668 public Attribute getAttIncipitAlias() {
|
|
669 return attIncipitAlias;
|
|
670 }
|
|
671
|
|
672 public void setAttIncipitAlias(Attribute attIncipitAlias) {
|
|
673 this.attIncipitAlias = attIncipitAlias;
|
|
674 }
|
|
675
|
|
676 public Attribute getAttExplicitAlias() {
|
|
677 return attExplicitAlias;
|
|
678 }
|
|
679
|
|
680 public void setAttExplicitAlias(Attribute attExplicitAlias) {
|
|
681 this.attExplicitAlias = attExplicitAlias;
|
|
682 }
|
|
683
|
|
684 public String getValueShortTitle() {
|
|
685 return valueShortTitle;
|
|
686 }
|
|
687
|
|
688 public void setValueShortTitle(String valueShortTitle) {
|
|
689 this.valueShortTitle = valueShortTitle;
|
|
690 }
|
|
691
|
|
692 public Entity getShortTitleAlias() {
|
|
693 return shortTitleAlias;
|
|
694 }
|
|
695
|
|
696 public void setShortTitleAlias(Entity shortTitleAlias) {
|
|
697 this.shortTitleAlias = shortTitleAlias;
|
|
698 }
|
|
699
|
|
700 public String getValueTranslitTitle() {
|
|
701 return valueTranslitTitle;
|
|
702 }
|
|
703
|
|
704 public void setValueTranslitTitle(String valueTranslitTitle) {
|
|
705 this.valueTranslitTitle = valueTranslitTitle;
|
|
706 }
|
|
707
|
|
708 public Entity getTranslitTitleAlias() {
|
|
709 return translitTitleAlias;
|
|
710 }
|
|
711
|
|
712 public void setTranslitTitleAlias(Entity translitTitleAlias) {
|
|
713 this.translitTitleAlias = translitTitleAlias;
|
|
714 }
|
|
715
|
|
716 public void setNewTitleAlias(String newAlias) {
|
|
717 this.newTitleAlias = newAlias;
|
|
718 }
|
|
719
|
|
720 public String getNewTitleAlias() {
|
|
721 return newTitleAlias;
|
|
722 }
|
|
723
|
|
724 public Map<Long, Boolean> getDeletedIncipitAliases() {
|
|
725 return deletedIncipitAliases;
|
|
726 }
|
|
727
|
|
728 public void setDeletedIncipitAliases(
|
|
729 Map<Long, Boolean> deletedIncipitAliases) {
|
|
730 this.deletedIncipitAliases = deletedIncipitAliases;
|
|
731 }
|
|
732
|
|
733 public Map<Long, Boolean> getDeletedExplicitAliases() {
|
|
734 return deletedExplicitAliases;
|
|
735 }
|
|
736
|
|
737 public void setDeletedExplicitAliases(
|
|
738 Map<Long, Boolean> deletedExplicitAliases) {
|
|
739 this.deletedExplicitAliases = deletedExplicitAliases;
|
|
740 }
|
|
741
|
|
742 public String getNewIncipitAlias() {
|
|
743 return newIncipitAlias;
|
|
744 }
|
|
745
|
|
746 public void setNewIncipitAlias(String newIncipitAlias) {
|
|
747 this.newIncipitAlias = newIncipitAlias;
|
|
748 }
|
|
749
|
|
750 public String getNewExplicitAlias() {
|
|
751 return newExplicitAlias;
|
|
752 }
|
|
753
|
|
754 public void setNewExplicitAlias(String newExplicitAlias) {
|
|
755 this.newExplicitAlias = newExplicitAlias;
|
|
756 }
|
|
757
|
|
758 public Map<Long, Boolean> getDeletedTitleAliases() {
|
|
759 return deletedTitleAliases;
|
|
760 }
|
|
761
|
|
762 public void setDeletedTitleAliases(Map<Long, Boolean> deletedTitleAliases) {
|
|
763 this.deletedTitleAliases = deletedTitleAliases;
|
|
764 }
|
|
765
|
|
766 public boolean isSearchTextDialogRendered() {
|
|
767 return searchTextDialogRendered;
|
|
768 }
|
|
769
|
|
770 public void setSearchTextDialogRendered(boolean searchTextDialogRendered) {
|
|
771 this.searchTextDialogRendered = searchTextDialogRendered;
|
|
772 }
|
|
773
|
|
774 public void setTextsFound(List<SelectItem> textsFound) {
|
|
775 this.textsFound = textsFound;
|
|
776 }
|
|
777
|
|
778 public List<SelectItem> getTextsFound() {
|
|
779 return textsFound;
|
|
780 }
|
|
781
|
|
782 public Long getIdTextSelected() {
|
|
783 return idTextSelected;
|
|
784 }
|
|
785
|
|
786 public void setIdTextSelected(Long idTextSelected) {
|
|
787 this.idTextSelected = idTextSelected;
|
|
788 }
|
|
789
|
|
790 public String getSearchCaller() {
|
|
791 return searchCaller;
|
|
792 }
|
|
793
|
|
794 public void setSearchCaller(String searchCaller) {
|
|
795 this.searchCaller = searchCaller;
|
|
796 }
|
|
797 public ListenerObject getAuthorLo() {
|
|
798 return authorLo;
|
|
799 }
|
|
800
|
|
801 public void setAuthorLo(ListenerObject authorLo) {
|
|
802 this.authorLo = authorLo;
|
|
803 }
|
|
804
|
|
805 public ListenerObject getPlaceLo() {
|
|
806 return placeLo;
|
|
807 }
|
|
808
|
|
809 public void setPlaceLo(ListenerObject placeLo) {
|
|
810 this.placeLo = placeLo;
|
|
811 }
|
|
812
|
|
813 public ListenerObject getDedicatedPersonLo() {
|
|
814 return dedicatedPersonLo;
|
|
815 }
|
|
816
|
|
817 public void setDedicatedPersonLo(ListenerObject dedicatedPersonLo) {
|
|
818 this.dedicatedPersonLo = dedicatedPersonLo;
|
|
819 }
|
|
820
|
|
821 public ListenerObject getCommentaryLo() {
|
|
822 return commentaryLo;
|
|
823 }
|
|
824
|
|
825 public void setCommentaryLo(ListenerObject commentaryLo) {
|
|
826 this.commentaryLo = commentaryLo;
|
|
827 }
|
|
828
|
|
829 public ListenerObject getTranslationLo() {
|
|
830 return translationLo;
|
|
831 }
|
|
832
|
|
833 public void setTranslationLo(ListenerObject translationLo) {
|
|
834 this.translationLo = translationLo;
|
|
835 }
|
|
836
|
|
837 public ListenerObject getVersionLo() {
|
|
838 return versionLo;
|
|
839 }
|
|
840
|
|
841 public void setVersionLo(ListenerObject versionLo) {
|
|
842 this.versionLo = versionLo;
|
|
843 }
|
|
844
|
|
845 public Long getIdSubject() {
|
|
846 return idSubject;
|
|
847 }
|
|
848
|
|
849 public void setIdSubject(Long idSubject) {
|
|
850 this.idSubject = idSubject;
|
|
851 }
|
|
852
|
|
853 public Entity getSubject() {
|
|
854 return subject;
|
|
855 }
|
|
856
|
|
857 public void setSubject(Entity subject) {
|
|
858 this.subject = subject;
|
|
859 }
|
|
860
|
|
861 public String getTextAuthorName() {
|
|
862 return textAuthorName;
|
|
863 }
|
|
864
|
|
865 public Calendar getCreationDate() {
|
|
866 return creationDate;
|
|
867 }
|
|
868
|
|
869 public void setCreationDate(Calendar creationDate) {
|
|
870 this.creationDate = creationDate;
|
|
871 }
|
|
872
|
|
873 public void setTextAuthorName(String textAuthorName) {
|
|
874 this.textAuthorName = textAuthorName;
|
|
875 }
|
|
876
|
|
877 public String getTextAuthorNameTranslit() {
|
|
878 return textAuthorNameTranslit;
|
|
879 }
|
|
880
|
|
881 public void setTextAuthorNameTranslit(String textAuthorNameTranslit) {
|
|
882 this.textAuthorNameTranslit = textAuthorNameTranslit;
|
|
883 }
|
|
884
|
|
885 public boolean isRestrictedByRole() {
|
|
886 return restrictedByRole;
|
|
887 }
|
|
888
|
|
889 public void setRestrictedByRole(boolean restrictedByRole) {
|
|
890 this.restrictedByRole = restrictedByRole;
|
|
891 }
|
|
892
|
|
893
|
|
894 public String getPersonType() {
|
|
895 return personType;
|
|
896 }
|
|
897
|
|
898 public void setPersonType(String personType) {
|
|
899 this.personType = personType;
|
|
900 }
|
|
901
|
|
902 public EntityList getAliasList() {
|
|
903 return aliasList;
|
|
904 }
|
|
905
|
|
906 public void setAliasList(EntityList aliasList) {
|
|
907 this.aliasList = aliasList;
|
|
908 }
|
|
909
|
|
910 public EntityList getExplicitAliasList() {
|
|
911 return explicitAliasList;
|
|
912 }
|
|
913
|
|
914 public void setExplicitAliasList(EntityList explicitAliasList) {
|
|
915 this.explicitAliasList = explicitAliasList;
|
|
916 }
|
|
917
|
|
918 public Long getSelectedPersonId() {
|
|
919 return selectedPersonId;
|
|
920 }
|
|
921
|
|
922 public void setSelectedPersonId(Long selectedPersonId) {
|
|
923 this.selectedPersonId = selectedPersonId;
|
|
924 }
|
|
925
|
91
|
926 public MisattributionTable getMisattTable() {
|
1
|
927 return misattTable;
|
|
928 }
|
|
929
|
91
|
930 public void setMisattTable(MisattributionTable misattTable) {
|
1
|
931 this.misattTable = misattTable;
|
|
932 }
|
|
933
|
|
934 public String getRomanizedTitle() {
|
|
935 return romanizedTitle;
|
|
936 }
|
|
937
|
|
938 public void setRomanizedTitle(String romanizedTitle) {
|
|
939 this.romanizedTitle = romanizedTitle;
|
|
940 }
|
|
941
|
|
942 public String getRomanizedPrimaAlias() {
|
|
943 return romanizedPrimaAlias;
|
|
944 }
|
|
945
|
|
946 public void setRomanizedPrimaAlias(String romanizedPrimaAlias) {
|
|
947 this.romanizedPrimaAlias = romanizedPrimaAlias;
|
|
948 }
|
|
949 }
|