Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentWitnessBean.java @ 143:1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Task-Url: https://it-dev.mpiwg-berlin.mpg.de/tracs/ismi/ticket/110
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 23 Jun 2017 20:40:18 +0200 |
parents | 502ae5b1a07d |
children | 8049becb05ca |
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.List; | |
6 | |
7 import javax.faces.component.UIComponent; | |
8 import javax.faces.event.ActionEvent; | |
9 import javax.faces.event.ValueChangeEvent; | |
10 import javax.faces.model.SelectItem; | |
11 | |
12 import org.apache.commons.lang.StringUtils; | |
13 import org.apache.log4j.Logger; | |
14 import org.mpi.openmind.repository.bo.Attribute; | |
15 import org.mpi.openmind.repository.bo.Entity; | |
16 import org.mpi.openmind.repository.bo.Node; | |
17 import org.mpi.openmind.repository.bo.Relation; | |
125 | 18 import org.mpi.openmind.repository.services.utils.EditIntent; |
1 | 19 import org.mpi.openmind.security.bo.User; |
20 | |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
21 import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; |
1 | 22 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; |
23 import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessAuthorLO; | |
24 import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessTextLO; | |
25 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; | |
26 import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList; | |
120 | 27 import de.mpiwg.itgroup.ismi.util.guiComponents.Misidentification; |
28 import de.mpiwg.itgroup.ismi.util.guiComponents.MisidentificationTable; | |
1 | 29 import de.mpiwg.itgroup.ismi.util.guiComponents.StatusImage; |
30 | |
31 public class CurrentWitnessBean extends CodexEditorTemplate implements Serializable{ | |
32 | |
33 private static final long serialVersionUID = -7645136722251494419L; | |
34 | |
35 private static Logger logger = Logger.getLogger(CurrentWitnessBean.class); | |
36 | |
37 private Boolean codicesOverviewRendered = false; | |
38 private List <CodexForList> codicesAll = new ArrayList<CodexForList>(); | |
39 | |
40 private List<SelectItem> titles_list = new ArrayList<SelectItem>(); | |
41 private Long selectedTitleId; | |
42 private Boolean selectTitleRendered = false; | |
43 private String selectPersonType; | |
44 | |
45 private List<SelectItem> persons_list = new ArrayList<SelectItem>(); | |
46 private Long selectedPersonId; | |
47 private Boolean selectPersonRendered = false; | |
48 private Boolean restrictedByRole = true; | |
49 | |
50 //private Entity witness; | |
51 | |
52 private ListenerObject titleLo = new WitnessTextLO(TEXT, full_title_translit, this); | |
53 | |
54 private String valueTitle = ""; | |
55 | |
56 // WITNESS -> has_title_written_as -> ALIAS | |
57 private String valueTextWritten = ""; | |
58 private List<SelectItem> suggestedTitlesWritten = new ArrayList<SelectItem>(); | |
59 private Long valueTitleSelectedId; | |
60 | |
61 // WITNESS -> has_authorWritten_as -> ALIAS | |
62 private String valueAuthorWritten = ""; | |
63 private List<SelectItem> suggestedAuthorsWritten = new ArrayList<SelectItem>(); | |
64 private Long valueAuthorSelectedId; | |
65 | |
66 // WITNESS -> is_exemplar_of -> TEXT -> was_created_by -> PERSON | |
67 private ListenerObject authorLo = new WitnessAuthorLO(PERSON, name_translit, this); | |
68 private String valueAuthor = ""; | |
69 | |
70 private boolean textUnknown = false; | |
71 private static String UNKNOWN = "UNKNOWN"; | |
72 | |
73 | |
74 // WITENSS -> was_copied_by -> PERSON | |
75 private ListenerObject copyistLo = new ListenerObject(PERSON, name_translit); | |
76 | |
77 // WITENSS -> was_copied_at -> PLACE | |
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
|
78 private AliasListenerObject copyPlaceLo = new AliasListenerObject(PLACE, name, "is_alias_name_of"); |
1 | 79 |
80 // WITNESS -> xx -> PERSON | |
81 private ListenerObject patronageLo = new ListenerObject(PERSON, name_translit); | |
82 | |
83 //private List<SelectItem> citiesWithRepositories; | |
84 private boolean foundCodex; | |
85 | |
86 private boolean lockValueAuthor = false; | |
87 private boolean lockValueTitle = false; | |
88 | |
89 private boolean createCodexRendered = false; | |
90 private boolean renderShowAllCodexCandidates = false; | |
91 //private Entity witness_old; | |
92 | |
93 private String newIdentifier; | |
94 | |
95 //private IslamicCalendar islamicCalCopyDate; | |
96 private transient Calendar copyDate; | |
97 | |
98 private EntityList studiedByList; | |
99 private EntityList possibleExamplerOfList; | |
120 | 100 |
101 private MisidentificationTable misidentTable; | |
1 | 102 |
125 | 103 /** intent to edit all attributes and relations in the form */ |
133 | 104 public static EditIntent editWitnessIntent = new EditIntent ( |
125 | 105 AbstractISMIBean.WITNESS, |
106 // attributes | |
133 | 107 new String[] {"ahlwardt_no", "creation_date", "table_of_contents", "incipit", "explicit", "colophon", |
125 | 108 "folios", "is_autograph", "page_dimensions", "written_area_dimensions", "lines_per_page", |
109 "writing_surface", "page_layout", "script", "other_features", "diagrams_and_illustrations", | |
110 "scans", "notes", "notes_old", "notes_on_title_author", "notes_on_collation_and_corrections", | |
111 "notes_on_ownership", "source_of_information"}, | |
112 // source relations | |
133 | 113 new String[] {"is_exemplar_of", "is_part_of", "has_author_misidentification", "was_copied_by", |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
114 "was_copied_in", "was_copied_in_as", "had_patron", "was_studied_by", |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
115 "has_author_written_as", "has_title_written_as"}, |
125 | 116 // target relations |
133 | 117 new String[] {"is_reference_of"}); |
125 | 118 |
1 | 119 public CurrentWitnessBean() { |
120 super(); | |
121 this.entity = new Entity(Node.TYPE_ABOX, WITNESS, false); | |
122 setDefObjectClass(WITNESS); | |
123 | |
124 registerChecker(copyistLo.statusImage, "Copyist not valid"); | |
133 | 125 registerChecker(copyPlaceLo.statusImage, "Copy place not valid"); |
1 | 126 registerChecker(patronageLo.statusImage,"Patron not valid"); |
127 | |
128 } | |
129 | |
130 @Override | |
131 public void reset(){ | |
132 super.reset(); | |
133 this.entity = new Entity(Node.TYPE_ABOX, WITNESS, false); | |
134 this.studiedByList = new EntityList(PERSON, "name_translit", "Studied by"); | |
135 this.possibleExamplerOfList = new EntityList(TEXT, "full_title_translit", "Possible titles"); | |
136 | |
137 this.codicesOverviewRendered = false; | |
138 this.codicesAll = new ArrayList<CodexForList>(); | |
139 | |
140 this.titles_list = new ArrayList<SelectItem>(); | |
141 this.selectedTitleId = null; | |
142 this.selectTitleRendered = false; | |
143 this.selectPersonType = ""; | |
144 | |
145 this.persons_list = new ArrayList<SelectItem>(); | |
146 this.selectedPersonId = null; | |
147 this.selectPersonRendered = false; | |
148 this.restrictedByRole = true; | |
149 | |
150 if(titleLo != null) | |
151 this.titleLo.reset(); | |
152 | |
153 this.valueTitle = ""; | |
154 | |
155 // WITNESS -> has_title_written_as -> ALIAS | |
156 this.valueTextWritten = ""; | |
157 this.suggestedTitlesWritten = new ArrayList<SelectItem>(); | |
158 this.valueTitleSelectedId = null; | |
159 | |
160 // WITNESS -> has_author_written_as -> ALIAS | |
161 this.valueAuthorWritten = ""; | |
162 this.suggestedAuthorsWritten = new ArrayList<SelectItem>(); | |
163 this.valueAuthorSelectedId = null; | |
164 | |
165 // WITNESS -> is_exemplar_of -> TEXT -> was_created_by -> PERSON | |
166 if(this.authorLo != null) | |
167 this.authorLo.reset(); | |
168 this.valueAuthor = ""; | |
169 | |
170 // WITENSS -> was_copied_by -> PERSON | |
171 if(copyistLo != null) | |
172 this.copyistLo.reset(); | |
173 | |
174 // WITENSS -> was_copied_in -> PLACE | |
175 if(this.copyPlaceLo != null) | |
176 this.copyPlaceLo.reset(); | |
177 | |
178 // WITNESS -> xx -> PERSON | |
179 if(patronageLo != null) | |
180 this.patronageLo.reset(); | |
181 | |
182 //this.citiesWithRepositories = null; | |
183 this.foundCodex = false; | |
184 | |
185 this.lockValueAuthor = true; | |
186 this.lockValueTitle = true; | |
187 | |
188 this.createCodexRendered = false; | |
189 this.renderShowAllCodexCandidates = false; | |
190 | |
191 this.newIdentifier = ""; | |
192 | |
193 //this.islamicCalCopyDate = new IslamicCalendar(); | |
194 this.copyDate = new Calendar(); | |
120 | 195 |
196 this.misidentTable = new MisidentificationTable(); | |
1 | 197 } |
198 | |
199 @Override | |
200 public String save() { | |
201 super.save(); | |
202 try { | |
203 | |
204 User user = getSessionUser(); | |
205 | |
206 if(!isCodexIdentifierSet(user.getEmail())){ | |
207 return "SAVE_ERROR"; | |
208 } | |
209 | |
210 if(!isWitnessConsistentBeforeSave()){ | |
211 return "SAVE_ERROR"; | |
212 } | |
213 | |
214 //checking if some LO is not OK. | |
215 CheckResults cr = getCheckResults(); | |
216 if (cr.hasErrors){ | |
217 getSessionBean().setErrorMessages(cr); | |
218 getSessionBean().setDisplayError(true); | |
219 this.setSelectedSaveAsNew(false); | |
220 return "SAVE_ERROR"; | |
221 } | |
222 | |
223 getAttributes().put("creation_date", this.copyDate.toJSONString()); | |
224 | |
225 this.entity = this.updateEntityAttributes(this.entity); | |
226 | |
227 // WITNESS -> is_part_of -> CODEX | |
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
133
diff
changeset
|
228 this.entity.replaceUniqueSourceRelation(getCodexLo().entity, CODEX, is_part_of); |
1 | 229 |
230 // WITNESS -> is_exemplar_of -> TEXT -> was_created_by -> PERSON | |
231 //replaceSourceRelation(this.entity, this.author, PERSON, was_created_by); | |
232 | |
233 // WITENSS -> was_copied_by -> PERSON | |
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
133
diff
changeset
|
234 this.entity.replaceUniqueSourceRelation(this.copyistLo.entity, PERSON, rel_was_copied_by); |
1 | 235 |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
236 // WITNESS -> was_copied_in -> PLACE |
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
133
diff
changeset
|
237 replaceUniqueAliasSourceRelation(this.entity, this.copyPlaceLo, PLACE, rel_was_copied_in, rel_was_copied_in_as); |
1 | 238 |
239 //REFERENCE -> is_reference_of -> WITNESS | |
136 | 240 this.saveReferences(); |
1 | 241 |
242 //WITNESS -> was studied by manyToMany -> PERSON | |
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
133
diff
changeset
|
243 replaceMultipleSourceRelations(entity, studiedByList.getEntities(), PERSON, rel_was_studied_by); |
1 | 244 |
245 // WITNESS -> had_patron -> PERSON | |
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
133
diff
changeset
|
246 this.entity.replaceUniqueSourceRelation(this.patronageLo.entity, PERSON, rel_had_patron); |
1 | 247 |
248 | |
120 | 249 /* |
121 | 250 * save misidentifications |
120 | 251 */ |
252 this.entity = this.misidentTable.saveMisidentifications(this.entity); | |
253 | |
1 | 254 // WITNESS -> is_exemplar_of -> TEXT |
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
133
diff
changeset
|
255 this.entity.replaceUniqueSourceRelation(this.titleLo.entity, TEXT, is_exemplar_of); |
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
133
diff
changeset
|
256 |
122
fb3cb7d70f66
misidentification of witness should really work now.
casties
parents:
121
diff
changeset
|
257 // legacy relations(?) |
1 | 258 this.entity.removeAllSourceRelationsByName(is_possible_exemplar_of); |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
259 |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
260 // update title/author_written_as relations |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
261 this.updateWrittenAliases(); |
1 | 262 |
263 // WITNESS -> is_part_of_codex | |
264 if(this.isSelectedSaveAsNew()){ | |
125 | 265 //this.entity = getWrapper().saveEntityAsNew(this.entity, user.getEmail()); |
1 | 266 }else{ |
136 | 267 /* |
268 * save this entity | |
269 */ | |
125 | 270 this.entity = getWrapper().saveEntity(this.entity, user.getEmail(), editWitnessIntent); |
1 | 271 } |
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
133
diff
changeset
|
272 // re-set form |
1 | 273 this.setEntity(this.entity); |
274 | |
275 logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity); | |
276 this.printSuccessSavingEntity(); | |
277 | |
278 this.setSelectedSaveAsNew(false); | |
279 } catch (Exception e) { | |
280 logger.error(e.getMessage(), e); | |
281 this.printInternalError(e); | |
282 } | |
283 | |
284 saveEnd(); | |
285 return PAGE_EDITOR; | |
286 } | |
287 | |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
288 private void updateWrittenAliases() throws Exception { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
289 |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
290 User user = getSessionUser(); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
291 |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
292 /* |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
293 * WITNESS -> has_title_written_as -> ALIAS |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
294 */ |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
295 if (StringUtils.isNotEmpty(valueTextWritten)) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
296 // check if text is already an alias |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
297 Entity alias = null; |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
298 if (this.suggestedTitlesWritten != null) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
299 for (SelectItem item : this.suggestedTitlesWritten) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
300 Long id = (Long) item.getValue(); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
301 if (id != null) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
302 Entity candidate = getWrapper().getEntityById(id); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
303 if (candidate != null && valueTextWritten.equals(candidate.getOwnValue())) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
304 alias = candidate; |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
305 break; |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
306 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
307 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
308 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
309 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
310 |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
311 if (alias == null) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
312 // create new alias |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
313 alias = new Entity(Node.TYPE_ABOX, ALIAS, false); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
314 alias.addAttribute(new Attribute(ALIAS, "text", valueTextWritten)); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
315 alias = getWrapper().saveEntity(alias, user.getEmail(), null); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
316 new Relation(alias, this.titleLo.getEntity(), "is_alias_title_of"); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
317 alias = getWrapper().saveEntity(alias, user.getEmail(), null); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
318 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
319 if (alias.isLightweight()) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
320 alias = getWrapper().getEntityByIdWithContent(alias.getId()); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
321 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
322 // update relation |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
323 this.entity.replaceUniqueSourceRelation(alias, ALIAS, rel_has_title_written_as); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
324 } else { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
325 // remove relation |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
326 this.entity.removeAllSourceRelations(rel_has_title_written_as, ALIAS); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
327 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
328 |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
329 /* |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
330 * WITNESS -> has_author_written_as -> ALIAS |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
331 */ |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
332 if (StringUtils.isNotEmpty(this.valueAuthorWritten)) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
333 // check if text is already an alias |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
334 Entity alias = null; |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
335 if (suggestedAuthorsWritten != null) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
336 for (SelectItem item : this.suggestedAuthorsWritten) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
337 Long id = (Long) item.getValue(); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
338 if (id != null) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
339 Entity candidate = getWrapper().getEntityById(id); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
340 if (candidate != null && valueAuthorWritten.equals(candidate.getOwnValue())) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
341 alias = candidate; |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
342 break; |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
343 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
344 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
345 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
346 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
347 |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
348 if (alias == null) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
349 // create new alias |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
350 alias = new Entity(Node.TYPE_ABOX, ALIAS, false); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
351 alias.addAttribute(new Attribute(ALIAS, "text", valueAuthorWritten)); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
352 alias = getWrapper().saveEntity(alias, user.getEmail(), null); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
353 new Relation(alias, this.authorLo.getEntity(), "is_alias_name_of"); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
354 alias = getWrapper().saveEntity(alias, user.getEmail(), null); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
355 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
356 if (alias.isLightweight()) { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
357 alias = getWrapper().getEntityByIdWithContent(alias.getId()); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
358 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
359 // update relation |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
360 this.entity.replaceUniqueSourceRelation(alias, ALIAS, rel_has_author_written_as); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
361 } else { |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
362 // remove relation |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
363 this.entity.removeAllSourceRelations(rel_has_author_written_as, ALIAS); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
364 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
365 } |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
366 |
1 | 367 public String saveAsNewEntity() { |
368 this.setSelectedSaveAsNew(true); | |
369 return save(); | |
370 } | |
371 | |
372 public void updateTitle(){ | |
373 | |
374 if(titleLo.entity != null && titleLo.entity.isPersistent()){ | |
375 | |
376 this.textUnknown = UNKNOWN.equals(titleLo.entity.getOwnValue()); | |
377 | |
378 List<Entity> targets = getWrapper().getTargetsForSourceRelation(titleLo.getEntity(), rel_was_created_by, PERSON, 1); | |
379 if(targets.size() > 0){ | |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
380 this.authorLo.setEntityAndAttribute(targets.get(0)); |
1 | 381 |
382 }else{ | |
383 this.authorLo.reset(); | |
384 /* rich | |
385 this.authorLo.setEntityAndAttribute(null, name_translit); | |
386 this.authorLo.statusImage.setStatus(StatusImage.STATUS_UNSET); | |
387 */ | |
388 | |
389 } | |
390 this.suggestedAuthorsWritten = getAuthorAliases(authorLo.entity); | |
391 this.suggestedTitlesWritten = getTitleAliases(titleLo.entity); | |
392 } | |
393 } | |
394 | |
395 public void updateAuthor(){ | |
396 | |
397 if(authorLo.getEntity() != null && authorLo.getEntity().isPersistent()){ | |
398 | |
399 this.titleLo.reset(); | |
400 | |
401 List <Entity> sources = getWrapper().getSourcesForTargetRelation(authorLo.getEntity(), rel_was_created_by, TEXT, -1); | |
402 | |
403 ArrayList<SelectItem> options = new ArrayList<SelectItem>(); | |
404 for (Entity title : sources){ | |
405 options.add(new SelectItem(title.getId(), title.getOwnValue() + " [" + title.getId() + "]")); | |
406 } | |
407 | |
408 titles_list = options; | |
409 this.suggestedAuthorsWritten = getAuthorAliases(authorLo.entity); | |
410 this.suggestedTitlesWritten = getTitleAliases(null); | |
411 } | |
412 } | |
413 | |
414 | |
415 private List<SelectItem> getTitleAliases(Entity title) { | |
416 List<SelectItem> items = new ArrayList<SelectItem>(); | |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
417 // I don't think so: this.valueTextWritten = null; |
1 | 418 if(title != null && title.isPersistent()){ |
419 items.add(new SelectItem(new Long(-1), "-- choose --")); | |
420 List<Entity> aliasTitleList = getWrapper().getSourcesForTargetRelation(title, is_alias_title_of, ALIAS, -1); | |
421 for(Entity alias : aliasTitleList){ | |
422 items.add(new SelectItem(alias.getId(), alias.getOwnValue())); | |
423 } | |
424 | |
425 List<Entity> primeAliasTitleList = getWrapper().getSourcesForTargetRelation(title, is_prime_alias_title_of, ALIAS, -1); | |
426 for(Entity alias : primeAliasTitleList){ | |
427 items.add(new SelectItem(alias.getId(), alias.getOwnValue())); | |
428 } | |
429 } | |
430 | |
431 return items; | |
432 } | |
433 private List<SelectItem> getAuthorAliases(Entity author) { | |
434 List<SelectItem> items = new ArrayList<SelectItem>(); | |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
435 // I don't think so: this.valueAuthorWritten = null; |
1 | 436 if(author != null && author.isPersistent()){ |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
437 items.add(new SelectItem(new Long(-1), "-- choose --")); |
1 | 438 List<Entity> aliasAuthorList = getWrapper().getSourcesForTargetRelation(author, is_alias_name_of, ALIAS, -1); |
439 for(Entity alias : aliasAuthorList){ | |
440 items.add(new SelectItem(alias.getId(), alias.getOwnValue())); | |
441 } | |
442 | |
443 List<Entity> primeAliasAuthorList = getWrapper().getSourcesForTargetRelation(author, is_prime_alias_name_of, ALIAS, -1); | |
444 for(Entity alias : primeAliasAuthorList){ | |
445 items.add(new SelectItem(alias.getId(), alias.getOwnValue())); | |
446 } | |
447 } | |
448 return items; | |
449 | |
450 } | |
451 | |
452 @Override | |
453 public void setEntity(Entity witness) { | |
454 this.reset(); | |
455 this.entity = witness; | |
456 | |
457 if(this.entity.isPersistent()){ | |
458 if (witness.isLightweight()) { | |
459 witness = getWrapper().getEntityContent(witness); | |
460 } | |
461 | |
462 Attribute attCreationDate = this.entity.getAttributeByName("creation_date"); | |
463 if(attCreationDate != null && StringUtils.isNotEmpty(attCreationDate.getOwnValue())){ | |
464 this.copyDate = new Calendar(attCreationDate.getOwnValue()); | |
465 }else{ | |
466 this.copyDate = new Calendar(); | |
467 } | |
468 | |
469 // Loading attributes | |
470 this.loadAttributes(this.entity); | |
471 | |
472 // Loading the relations | |
473 // TODO loading target's relations | |
474 for (Relation rel : witness.getSourceRelations()) { | |
120 | 475 String relName = rel.getOwnValue(); |
476 if (relName.equals(is_exemplar_of)) { | |
1 | 477 // WITNESS -> is_exemplar_of -> TEXT |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
478 Entity 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:
1
diff
changeset
|
479 titleLo.setEntityAndAttribute(target); |
1 | 480 this.updateTitle(); |
120 | 481 } else if (relName.equals(is_possible_exemplar_of)) { |
1 | 482 // WITNESS -> is_possible_exemplar_of -> TEXT |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
483 Entity target = getTargetRelation(rel); |
1 | 484 possibleExamplerOfList.add(target); |
120 | 485 } else if (relName.equals(rel_was_studied_by)) { |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
486 Entity target = getTargetRelation(rel); |
1 | 487 studiedByList.add(target); |
120 | 488 } else if (relName.equals(rel_was_copied_by)) { |
1 | 489 // WITENSS -> was_copied_by -> PERSON |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
490 Entity 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:
1
diff
changeset
|
491 copyistLo.setEntityAndAttribute(target); |
120 | 492 } else if (relName.equals("was_copied_in")) { |
1 | 493 // WITENSS -> was_copied_in -> PLACE |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
494 Entity 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:
1
diff
changeset
|
495 // don't use place if there is an alias |
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
|
496 copyPlaceLo.setEntityAndAttributeIfEmpty(target); |
120 | 497 } else if (relName.equals("was_copied_in_as")) { |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
498 // WITENSS -> was_copied_in_as -> ALIAS |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
499 Entity 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:
1
diff
changeset
|
500 copyPlaceLo.setEntityAndAttribute(target); |
120 | 501 } else if (relName.equals(rel_had_patron)) { |
1 | 502 // WITNESS -> had_patron -> PERSON |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
503 Entity 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:
1
diff
changeset
|
504 patronageLo.setEntityAndAttributeName(target, name_translit); |
120 | 505 } else if (relName.equals(is_part_of)) { |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
506 // WITNESS -> is_part_of -> CODEX |
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
507 if (rel.getTargetObjectClass().equals(CODEX)) { |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
508 Entity target = getTargetRelation(rel); |
1 | 509 this.setCodex(target); |
510 } | |
120 | 511 } else if (relName.equals(Misidentification.HAS_MISIDENT)) { |
512 // WITNESS -> has_misidentification -> MISIDENTIFICATION | |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
513 Entity target = getTargetRelation(rel); |
120 | 514 this.misidentTable.load(target); |
515 | |
516 } else if (relName.equals(rel_has_author_written_as)) { | |
1 | 517 //TODO this relation is no in the definitions |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
518 Entity target = getTargetRelation(rel); |
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
519 Attribute alias = getTargetAttribute(target, "alias"); |
1 | 520 this.valueAuthorWritten = (alias != null) ? alias.getValue() : null; |
521 | |
120 | 522 } else if (relName.equals(rel_has_title_written_as)) { |
1 | 523 //TODO this relation is no in the definitions |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
524 Entity target = getTargetRelation(rel); |
1 | 525 //this.textWritten = target; |
526 Attribute alias = getTargetAttribute(target, "alias"); | |
527 this.valueTextWritten = (alias != null) ? alias.getValue() : null; | |
528 } | |
529 } | |
530 | |
531 //this.loadReferences(this.entity); | |
532 this.loadEndNoteRefs(); | |
533 | |
534 this.setCurrentId(this.entity.getId().toString()); | |
535 this.checkConsistencyFromCountryToCodex(); | |
536 | |
537 this.displayUrl = generateDisplayUrl(authorLo.entity, titleLo.entity, witness, getAppBean().getRoot()); | |
538 } | |
539 } | |
540 | |
541 /** | |
542 * Loads the given codex without reset of the variables, which could cause problem in CurrentWitness Class | |
543 * @param codex | |
544 */ | |
545 public void setCodex(Entity codex){ | |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
546 this.getCodexLo().setEntityAndAttributeName(codex, "identifier"); |
1 | 547 |
548 if(this.getCodexLo().entity != null && this.getCodexLo().entity.isPersistent()){ | |
549 | |
550 List<Entity> list = getWrapper().getTargetsForSourceRelation(codex, is_part_of, COLLECTION, 1); | |
551 if(list.size() > 0){ | |
552 this.setCollection(list.get(0)); | |
553 } | |
554 } | |
555 } | |
556 | |
557 public String getValueAuthor() { | |
558 return valueAuthor; | |
559 } | |
560 | |
561 public void setValueAuthor(String valueAuthor) { | |
562 if(!lockValueAuthor) | |
563 this.valueAuthor = valueAuthor; | |
564 this.lockValueAuthor = false; | |
565 } | |
566 | |
567 public void setValueTitle(String valueTitle) { | |
568 if(!lockValueTitle) | |
569 this.valueTitle = valueTitle; | |
570 this.lockValueTitle = false; | |
571 } | |
572 | |
573 public String getValueTitle() { | |
574 return valueTitle; | |
575 } | |
576 | |
577 public List<SelectItem> getTitles_list() { | |
578 return titles_list; | |
579 } | |
580 | |
581 public void setTitles_list(List<SelectItem> titlesList) { | |
582 titles_list = titlesList; | |
583 } | |
584 | |
585 public void setFoundCodex(boolean foundCodex) { | |
586 this.foundCodex = foundCodex; | |
587 } | |
588 | |
589 public boolean isFoundCodex() { | |
590 return foundCodex; | |
591 } | |
592 | |
593 public void listenerCreateTitleAlias(ValueChangeEvent event) { | |
594 this.valueTextWritten = (String)event.getNewValue(); | |
595 } | |
596 | |
597 public void listenerChooseTitleAlias(ValueChangeEvent event) { | |
598 if (event.getNewValue() != null) { | |
599 Long aliasId = (Long) event.getNewValue(); | |
600 if(aliasId != null){ | |
601 if(aliasId.equals(-1)){ | |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
602 //I don't think so: this.valueTextWritten = null; |
1 | 603 }else{ |
604 Entity alias = getWrapper().getEntityByIdWithContent(aliasId); | |
605 if(alias != null){ | |
606 this.valueTextWritten = alias.getOwnValue(); | |
607 } | |
608 } | |
609 } | |
610 } | |
611 } | |
612 | |
613 public void listenerCreateAuthorAlias(ValueChangeEvent event) { | |
614 this.valueAuthorWritten = (String)event.getNewValue(); | |
615 } | |
616 | |
617 public void listenerChooseAuthorAlias(ValueChangeEvent event) { | |
618 if (event.getNewValue() != null) { | |
619 Long aliasId = (Long) event.getNewValue(); | |
620 if(aliasId != null){ | |
621 if(aliasId.equals(-1)){ | |
143
1c09041f1182
110: The title-as-written-on-manuscript in the witness form does not save
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
136
diff
changeset
|
622 //I don't think so: this.valueAuthorWritten = null; |
1 | 623 }else{ |
624 Entity alias = getWrapper().getEntityByIdWithContent(aliasId); | |
625 if(alias != null){ | |
626 this.valueAuthorWritten = alias.getOwnValue(); | |
627 } | |
628 } | |
629 } | |
630 } | |
631 } | |
632 | |
633 @Override | |
634 public void identifierChangedListener(ValueChangeEvent event) { | |
635 super.identifierChangedListener(event); | |
636 | |
637 if (StringUtils.isEmpty(getCodexLo().attribute.getValue())){ | |
638 renderShowAllCodexCandidates = false; | |
639 this.checkConsistencyFromCountryToCodex(); | |
640 return; | |
641 } | |
642 | |
643 List<Entity> entities = getWrapper().getEntitiesByAtt(CODEX, getCodexLo().getAttName(), getCodexLo().attribute.getValue(), 10000, false); | |
644 | |
645 if (entities.size()>1){ | |
646 if ((getCollectionLo().attribute==null || getCollectionLo().getAttribute().getValue().equals("")) && | |
647 (getRepositoryLo().getAttribute()==null || getRepositoryLo().getAttribute().getValue().equals(""))){ | |
648 showAllCodexCandidates(entities); | |
649 renderShowAllCodexCandidates = true; | |
650 } | |
651 else | |
652 //renderShowAllCodexCandidates = false; | |
653 renderShowAllCodexCandidates = true; // i want to keep the selection field now | |
654 } | |
655 else | |
656 //renderShowAllCodexCandidates = false; | |
657 renderShowAllCodexCandidates = true; //i want to keep the selection field now | |
658 } | |
659 | |
660 public void searchInCurrentRepository(ActionEvent event) { | |
661 | |
662 ValueChangeEvent ne = new ValueChangeEvent((UIComponent) event | |
663 .getComponent(), "", getCollectionLo().getAttribute().getOwnValue()); | |
664 identifierChangedListener(ne); | |
665 | |
666 } | |
667 | |
668 /* rich | |
669 public String insertAuthorAction() { | |
670 return "insert"; | |
671 | |
672 }*/ | |
673 | |
674 public String showOtherTextsByAuthorAction() { | |
675 if (authorLo.entity == null || !authorLo.entity.isPersistent()) | |
676 return ""; | |
677 | |
678 List<SelectItem> options = new ArrayList<SelectItem>(); | |
679 List<Entity> titles = getWrapper().getSourcesForTargetRelation(authorLo.entity, "was_created_by", TEXT, -1); | |
680 for (Entity title: titles){ | |
681 options.add( | |
682 new SelectItem(title.getId(), title.getOwnValue() + " [" + title.getId() + "]")); | |
683 } | |
684 titles_list = options; | |
685 setSelectTitleRendered(true); | |
686 return ""; | |
687 } | |
688 | |
689 /** | |
690 * Gebe moegliche andere Codices aus. Das ist notwendig, weil nach dem jetzigen Stand der Daten ein Codex | |
691 * mehrfach im Datensatz auftachen kann. | |
692 * @return | |
693 */ | |
694 public String showAllCodexCandidates(List<Entity> entities){ | |
695 if (entities != null) { | |
696 for (Entity entity : entities) { | |
697 CodexForList entForList = getCodexData(entity); | |
698 codicesAll.add(entForList); | |
699 } | |
700 } | |
701 setCodicesOverviewRendered(true); | |
702 return ""; | |
703 } | |
704 | |
705 public String showAllTextsAction() { | |
706 titles_list = new ArrayList<SelectItem>(); | |
707 titles_list = getAppBean().getAllTexts(); | |
708 this.selectTitleRendered = true; | |
709 return ""; | |
710 } | |
711 | |
712 public void listenerSelectTitle(ActionEvent event){ | |
713 if(this.selectedTitleId != null){ | |
714 Entity title = getWrapper().getEntityById(this.selectedTitleId); | |
715 if(title != null){ | |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
716 this.titleLo.setEntityAndAttribute(title); |
1 | 717 this.updateTitle(); |
718 setSelectTitleRendered(false); | |
719 } | |
720 } | |
721 } | |
722 | |
723 public void listenerCancelPpSelectTitle(ActionEvent event){ | |
119 | 724 //System.out.println("listenerCancelPpSelectTitle"); |
1 | 725 this.selectTitleRendered = false; |
726 } | |
727 | |
728 public void setSelectTitleRendered(Boolean selectTitleRendered) { | |
729 this.selectTitleRendered = selectTitleRendered; | |
730 } | |
731 | |
732 public Boolean getSelectTitleRendered() { | |
733 return selectTitleRendered; | |
734 } | |
735 | |
736 public List<SelectItem> getPersons_list() { | |
737 return persons_list; | |
738 } | |
739 | |
740 public void setPersons_list(List<SelectItem> personsList) { | |
741 persons_list = personsList; | |
742 } | |
743 | |
744 public Boolean getSelectPersonRendered() { | |
745 return selectPersonRendered; | |
746 } | |
747 | |
748 public void setSelectPersonRendered(Boolean selectPersonRendered) { | |
749 this.selectPersonRendered = selectPersonRendered; | |
750 } | |
751 | |
752 public Boolean getRestrictedByRole() { | |
753 return restrictedByRole; | |
754 } | |
755 | |
756 public void setRestrictedByRole(Boolean restrictedByRole) { | |
757 this.restrictedByRole = restrictedByRole; | |
758 } | |
759 | |
760 private void updatePersonList(){ | |
761 if (!this.restrictedByRole) | |
762 //persons_list = ((AllPersonsBean) this.getBean("AllPersons")) | |
763 // .getPersonsSelectItems(); | |
764 persons_list = getCache().getAllPersons(); | |
765 else { | |
766 //persons_list = ((AllPersonsBean) this.getBean("AllPersons")) | |
767 // .getPersonsSelectItemsByRole(this.selectPersonType); | |
768 persons_list = getCache().getPersonsByRole(selectPersonType); | |
769 } | |
770 } | |
771 | |
772 public String showAllCopyistsAction() { | |
773 this.setSelectPersonType("Copyist"); | |
774 this.updatePersonList(); | |
775 this.selectPersonRendered = true; | |
776 return ""; | |
777 } | |
778 | |
779 public String showAllPatronsAction() { | |
780 this.setSelectPersonType("Patron"); | |
781 this.updatePersonList(); | |
782 this.selectPersonRendered = true; | |
783 return ""; | |
784 } | |
785 | |
786 public String showAllAuthorsAction() { | |
787 this.setSelectPersonType("Author"); | |
788 this.updatePersonList(); | |
789 this.selectPersonRendered = true; | |
790 return ""; | |
791 } | |
792 | |
793 public void listenerCancelPpSelectAuthor(ActionEvent event){ | |
794 this.selectPersonRendered = false; | |
795 } | |
796 | |
797 public void listenerSelectPerson(ActionEvent event){ | |
798 String role = getSelectPersonType(); | |
799 if(this.selectedPersonId != null){ | |
800 Entity selectedPerson = getWrapper().getEntityByIdWithContent(selectedPersonId); | |
801 if(selectedPerson != null){ | |
802 if (role.equals("Copyist")) { | |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
803 copyistLo.setEntityAndAttribute(selectedPerson); |
1 | 804 } else if (role.equals("Patron")) { |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
805 patronageLo.setEntityAndAttribute(selectedPerson); |
1 | 806 } else if (role.equals("Author")) { |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
807 authorLo.setEntityAndAttribute(selectedPerson); |
1 | 808 this.updateAuthor(); |
809 } | |
810 setSelectPersonRendered(false); | |
811 } | |
812 } | |
813 } | |
814 | |
815 public void setSelectPersonType(String selectPersonType) { | |
816 this.selectPersonType = selectPersonType; | |
817 } | |
818 | |
819 public String getSelectPersonType() { | |
820 return selectPersonType; | |
821 } | |
822 | |
823 public void restrictedByRoleChange(ValueChangeEvent event) { | |
824 if (event.getNewValue().equals(event.getOldValue())) | |
825 return; | |
826 try{ | |
827 Boolean val = (Boolean) event.getNewValue(); | |
828 this.setRestrictedByRole(val); | |
829 this.updatePersonList(); | |
830 }catch(Exception ex){ | |
831 ex.printStackTrace(); | |
832 } | |
833 } | |
834 | |
835 public void listenerConvertCreationDate(ActionEvent event) { | |
836 /* | |
837 try{ | |
838 | |
839 String newDate = this.islamicCalCopyDate.islamic2Gregorian(); | |
840 String newJulianDate = this.islamicCalCopyDate.islamic2Julian(); | |
841 | |
842 getAttributes().put("creation_date_ce", newDate); | |
843 getAttributes().put("creation_date_julian", newJulianDate); | |
844 | |
845 }catch(Exception e){ | |
846 e.printStackTrace(); | |
847 addGeneralMsg("Error converting date!"); | |
848 addGeneralMsg("The islamic calendar begins on Friday, July 16th, 622 C.E. in the Julian calendar."); | |
849 addGeneralMsg("The date must be equals or bigger than yawm al-jum'a, 1.Muharram.1 (5.1.1.1)"); | |
850 } | |
851 */ | |
852 } | |
853 | |
854 | |
855 public void selectCodexFromOverviewAction(ActionEvent ae){ | |
856 /* rich | |
857 | |
858 HtmlCommandButton cp = (HtmlCommandButton)ae.getComponent(); | |
859 Long id = (Long) cp.getValue(); | |
860 //juc Entity ent = getOntology().getEntityById(id); | |
861 Entity ent = getWrapper().getEntityById(id); | |
862 this.getCodexLo().setEntityAndAttribute(ent, "identifier"); | |
863 //changeValueAttCodex(this.getCodexLo().getAttribute().getOwnValue()); | |
864 setCodicesOverviewRendered(false); | |
865 | |
866 */ | |
867 | |
868 | |
869 } | |
870 | |
871 public String closeCodicesOverview(){ | |
872 setCodicesOverviewRendered(false); | |
873 return "CLOSE"; | |
874 | |
875 } | |
876 | |
877 | |
878 private boolean isCodexIdentifierSet(String user){ | |
879 try { | |
880 | |
881 if(StatusImage.STATUS_OK.equals(getCodexLo().getStatus())){ | |
882 return true; | |
883 } | |
884 | |
885 String identifier = getNewIdentifier(); | |
886 | |
887 if(!StatusImage.STATUS_OK.equals(getCollectionLo().getStatus()) || | |
888 StringUtils.isEmpty(identifier)){ | |
889 //we can not save the witness | |
890 if(!StatusImage.STATUS_OK.equals(getCollectionLo().getStatus())){ | |
891 addErrorMsg("The Collection is not valid."); | |
892 } | |
893 if(StringUtils.isEmpty(identifier)){ | |
894 addErrorMsg("The Codex does not have an valid identifier."); | |
895 } | |
896 addErrorMsg("The Witness could not be saved."); | |
897 return false; | |
898 }else { | |
899 //two possibilities: | |
900 //1. there exist a codex with the same id | |
901 //2. there is no a codex with this id, it should be saved. | |
902 | |
903 if(StringUtils.isNotEmpty(identifier)){ | |
904 List<Entity> codexListOfCollection = | |
905 getWrapper().getSourcesForTargetRelation(getCollectionLo().getEntity(), | |
906 is_part_of, CODEX, -1); | |
907 for(Entity possibleCodex : codexListOfCollection){ | |
908 //juc Attribute att = getWrapper().getAttributeByName(possibleCodex, "identifier"); | |
909 Attribute att = getWrapper().getAttributeByName(possibleCodex.getId(), "identifier"); | |
910 if(att != null && identifier.equals(att.getValue())){ | |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
911 getCodexLo().setEntityAndAttributeName(possibleCodex, "identifier"); |
1 | 912 return true; |
913 } | |
914 } | |
915 } | |
916 } | |
917 | |
918 //if the Collection Status == OK && the Codex.identifier != null | |
919 Entity newCodex = new Entity(Node.TYPE_ABOX, CODEX, false); | |
920 newCodex.addAttribute(new Attribute("identifier", TEXT, identifier)); | |
124
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
122
diff
changeset
|
921 getWrapper().saveEntity(newCodex, user, null); |
1 | 922 Relation isPartOf = new Relation(newCodex, getCollectionLo().getEntity(), is_part_of); |
923 getWrapper().saveRelationAsNode(isPartOf, user); | |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
1
diff
changeset
|
924 getCodexLo().setEntityAndAttributeName(newCodex, "identifier"); |
1 | 925 |
926 } catch (Exception e) { | |
927 logger.error(e.getMessage(), e); | |
928 return false; | |
929 } | |
930 return true; | |
931 } | |
932 | |
933 public boolean isCreateCodexRendered() { | |
934 return createCodexRendered; | |
935 } | |
936 | |
937 public void setCreateCodexRendered(boolean createCodexRendered) { | |
938 this.createCodexRendered = createCodexRendered; | |
939 } | |
940 | |
941 @Override | |
942 public String loadCloneEntity(){ | |
943 this.setCodex(getCloneEntity()); | |
944 this.setRenderUnityCheckerDialog(false); | |
945 this.checkConsistencyFromCountryToCodex(); | |
946 return PAGE_EDITOR; | |
947 } | |
948 | |
949 public List<CodexForList> getCodicesAll() { | |
950 return codicesAll; | |
951 } | |
952 | |
953 public void setCodicesAll(List<CodexForList> codicesAll) { | |
954 this.codicesAll = codicesAll; | |
955 } | |
956 | |
957 public void setCodicesOverviewRendered(Boolean codicesOverviewRendered) { | |
958 this.codicesOverviewRendered = codicesOverviewRendered; | |
959 } | |
960 | |
961 public Boolean getCodicesOverviewRendered() { | |
962 return codicesOverviewRendered; | |
963 } | |
964 | |
965 /** | |
966 * Teste ob es Codices mit gleichem identifier gibt! | |
967 * @return | |
968 */ | |
969 public Boolean getRenderShowAllCodexCandidates(){ | |
970 return renderShowAllCodexCandidates; | |
971 } | |
972 | |
973 | |
974 | |
975 public List<SelectItem> getSuggestedTitlesWritten() { | |
976 return suggestedTitlesWritten; | |
977 } | |
978 | |
979 public void setSuggestedTitlesWritten(List<SelectItem> suggestedTitlesWritten) { | |
980 this.suggestedTitlesWritten = suggestedTitlesWritten; | |
981 } | |
982 | |
983 public List<SelectItem> getSuggestedAuthorsWritten() { | |
984 return suggestedAuthorsWritten; | |
985 } | |
986 | |
987 public void setSuggestedAuthorsWritten(List<SelectItem> suggestedAuthorsWritten) { | |
988 this.suggestedAuthorsWritten = suggestedAuthorsWritten; | |
989 } | |
990 | |
991 public void codexCodexChangeListener(ValueChangeEvent event) { | |
992 if (event.getNewValue() == null) { | |
993 return; | |
994 } | |
995 if (event.getNewValue().equals(event.getOldValue())) { | |
996 return; | |
997 } | |
998 this.getCodexLo().statusImage.setStatus(StatusImage.STATUS_UNSET); | |
999 this.getCodexLo().attribute.setValue(event.getNewValue().toString()); | |
1000 } | |
1001 public Long getValueTitleSelectedId() { | |
1002 return valueTitleSelectedId; | |
1003 } | |
1004 | |
1005 public void setValueTitleSelectedId(Long valueTitleSelectedId) { | |
1006 this.valueTitleSelectedId = valueTitleSelectedId; | |
1007 } | |
1008 | |
1009 public ListenerObject getCopyistLo() { | |
1010 return copyistLo; | |
1011 } | |
1012 | |
1013 public void setCopyistLo(ListenerObject copyistLo) { | |
1014 this.copyistLo = copyistLo; | |
1015 } | |
1016 | |
1017 public ListenerObject getCopyPlaceLo() { | |
1018 return copyPlaceLo; | |
1019 } | |
1020 | |
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
|
1021 public void setCopyPlaceLo(AliasListenerObject copyPlaceLo) { |
1 | 1022 this.copyPlaceLo = copyPlaceLo; |
1023 } | |
1024 | |
1025 public ListenerObject getPatronageLo() { | |
1026 return patronageLo; | |
1027 } | |
1028 | |
1029 public void setPatronageLo(ListenerObject patronageLo) { | |
1030 this.patronageLo = patronageLo; | |
1031 } | |
1032 | |
1033 public ListenerObject getTitleLo() { | |
1034 return titleLo; | |
1035 } | |
1036 | |
1037 public void setTitleLo(ListenerObject titleLo) { | |
1038 this.titleLo = titleLo; | |
1039 } | |
1040 | |
1041 public ListenerObject getAuthorLo() { | |
1042 return authorLo; | |
1043 } | |
1044 | |
1045 public String getNewIdentifier() { | |
1046 return newIdentifier; | |
1047 } | |
1048 | |
1049 public void setNewIdentifier(String newIdentifier) { | |
1050 this.newIdentifier = newIdentifier; | |
1051 } | |
1052 | |
1053 public EntityList getStudiedByList() { | |
1054 return studiedByList; | |
1055 } | |
1056 | |
1057 public Calendar getCopyDate() { | |
1058 return copyDate; | |
1059 } | |
1060 | |
1061 public void setCopyDate(Calendar copyDate) { | |
1062 this.copyDate = copyDate; | |
1063 } | |
1064 | |
1065 public void setStudiedByList(EntityList studiedByList) { | |
1066 this.studiedByList = studiedByList; | |
1067 } | |
1068 public Long getValueAuthorSelectedId() { | |
1069 return valueAuthorSelectedId; | |
1070 } | |
1071 | |
1072 public void setValueAuthorSelectedId(Long valueAuthorSelectedId) { | |
1073 this.valueAuthorSelectedId = valueAuthorSelectedId; | |
1074 } | |
1075 | |
1076 public String getValueTextWritten() { | |
1077 return valueTextWritten; | |
1078 } | |
1079 | |
1080 public void setValueTextWritten(String valueTextWritten) { | |
1081 //this.valueTextWritten = valueTextWritten; | |
1082 } | |
1083 | |
1084 public String getValueAuthorWritten() { | |
1085 return valueAuthorWritten; | |
1086 } | |
1087 | |
1088 public void setValueAuthorWritten(String valueAuthorWritten) { | |
1089 //this.valueAuthorWritten = valueAuthorWritten; | |
1090 } | |
1091 | |
1092 public void setAuthorLo(ListenerObject authorLo) { | |
1093 this.authorLo = authorLo; | |
1094 } | |
1095 | |
1096 public Long getSelectedTitleId() { | |
1097 return selectedTitleId; | |
1098 } | |
1099 | |
1100 public void setSelectedTitleId(Long selectedTitleId) { | |
1101 this.selectedTitleId = selectedTitleId; | |
1102 } | |
1103 public Long getSelectedPersonId() { | |
1104 return selectedPersonId; | |
1105 } | |
1106 | |
1107 public void setSelectedPersonId(Long selectedPersonId) { | |
1108 this.selectedPersonId = selectedPersonId; | |
1109 } | |
1110 | |
1111 public boolean isTextUnknown() { | |
1112 return textUnknown; | |
1113 } | |
1114 | |
1115 public void setTextUnknown(boolean textUnknown) { | |
1116 this.textUnknown = textUnknown; | |
1117 } | |
1118 | |
1119 public EntityList getPossibleExamplerOfList() { | |
1120 return possibleExamplerOfList; | |
1121 } | |
1122 | |
1123 public void setPossibleExamplerOfList(EntityList possibleExamplerOfList) { | |
1124 this.possibleExamplerOfList = possibleExamplerOfList; | |
1125 } | |
120 | 1126 |
1127 public MisidentificationTable getMisidentTable() { | |
1128 return misidentTable; | |
1129 } | |
1130 | |
1131 public void setMisidentTable(MisidentificationTable misidentTable) { | |
1132 this.misidentTable = misidentTable; | |
1133 } | |
1 | 1134 |
1135 } | |
1136 |