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