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