Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java @ 119:4aa8c425685d
less System.out.println.
author | casties |
---|---|
date | Fri, 06 Jan 2017 16:59:37 +0100 |
parents | 2b77751e4021 |
children | 32ce1f93ad33 |
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.HashSet; | |
7 import java.util.List; | |
8 import java.util.Map; | |
9 | |
10 import javax.faces.context.FacesContext; | |
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.cache.WrapperService; | |
17 import org.mpi.openmind.repository.bo.Attribute; | |
18 import org.mpi.openmind.repository.bo.Entity; | |
19 import org.mpi.openmind.repository.bo.Node; | |
20 import org.mpi.openmind.repository.bo.Relation; | |
95 | 21 import org.mpi.openmind.repository.services.PersistenceService; |
1 | 22 import org.mpi.openmind.security.SecurityService; |
23 import org.mpi.openmind.security.bo.User; | |
24 | |
112
59f26a5ef2b3
AliasListenerObject adds aliases to ListenerObject. Change all forms to enable ALIAS for (historical) PLACE fields. Remove REPOSITORY from event forms.
casties
parents:
111
diff
changeset
|
25 import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; |
1 | 26 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; |
27 import de.mpiwg.itgroup.ismi.entry.dataBeans.SimpleSearchCache; | |
91 | 28 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; |
1 | 29 import de.mpiwg.itgroup.ismi.util.guiComponents.Reference; |
30 import de.mpiwg.itgroup.ismi.util.guiComponents.ReferenceTable; | |
31 import de.mpiwg.itgroup.ismi.util.guiComponents.StatusChecker; | |
32 import de.mpiwg.itgroup.ismi.util.guiComponents.StatusImage; | |
33 import de.mpiwg.itgroup.ismi.utils.SelectableObject; | |
34 | |
35 /** | |
36 * | |
37 * @author jurzua | |
38 */ | |
39 public class AbstractISMIBean extends AbstractBean implements Serializable{ | |
40 | |
41 private static final long serialVersionUID = 9193140306343947209L; | |
42 | |
43 private static Logger logger = Logger.getLogger(AbstractISMIBean.class); | |
95 | 44 private static Logger txLog = Logger.getLogger(PersistenceService.TRANSACTION_LOGGER); |
1 | 45 |
46 public static String WITNESS = "WITNESS"; | |
47 public static String TEXT = "TEXT"; | |
48 public static String PERSON = "PERSON"; | |
49 public static String COLLECTION = "COLLECTION"; | |
50 public static String CODEX = "CODEX"; | |
51 public static String REPOSITORY = "REPOSITORY"; | |
52 public static String ALIAS = "ALIAS"; | |
53 public static String PLACE = "PLACE"; | |
54 public static String SUBJECT = "SUBJECT"; | |
55 public static String REFERENCE = "REFERENCE"; | |
56 public static String ROLE = "ROLE"; | |
57 public static String DIGITALIZATION = "DIGITALIZATION"; | |
58 public static String FLORUIT_DATE = "FLORUIT_DATE"; | |
59 | |
60 public static String is_digitalization_of = "is_digitalization_of"; | |
61 public static String is_part_of = "is_part_of"; | |
62 public static String is_in = "is_in"; | |
63 public static String has_subject = "has_subject"; | |
64 public static String misattributed_to = "misattributed_to"; | |
65 public static String lived_in = "lived_in"; | |
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
|
66 public static final String lived_in_as = "lived_in_as"; |
1 | 67 public static String owned_by = "owned_by"; |
68 public static String has_role = "has_role"; | |
69 public static String was_student_of = "was_student_of"; | |
70 public static String is_alias_name_of = "is_alias_name_of"; | |
71 public static String is_prime_alias_name_of = "is_prime_alias_name_of"; | |
72 public static String is_alias_title_of = "is_alias_title_of"; | |
73 public static String is_prime_alias_title_of = "is_prime_alias_title_of"; | |
74 public static String alias = "alias"; | |
75 public static String has_floruit_date = "has_floruit_date"; | |
76 | |
77 public static String rel_was_created_by = "was_created_by"; | |
78 public static String rel_was_copied_by = "was_copied_by"; | |
79 public static String is_exemplar_of = "is_exemplar_of"; | |
80 public static String is_possible_exemplar_of = "is_possible_exemplar_of"; | |
81 public static String rel_had_patron = "had_patron"; | |
82 public static String rel_has_title_written_as = "has_title_written_as"; | |
83 public static String rel_has_author_written_as = "has_author_written_as"; | |
84 public static String rel_is_reference_of = "is_reference_of"; | |
85 | |
86 public static String rel_was_studied_by = "was_studied_by"; | |
87 | |
88 public static String PAGE_EDITOR = "entry_edit_entity"; | |
89 public static String PAGE_SIMPLE_SEARCH = "simple_search"; | |
90 public static String PAGE_MERGE = "general_merge"; | |
91 | |
92 //some attributes names | |
93 public static String name = "name"; | |
94 public static String name_translit = "name_translit"; | |
95 public static String full_title_translit = "full_title_translit"; | |
96 | |
97 public static int MAX_SUGGEST = 25; | |
98 | |
99 protected boolean selectedSaveAsNew = false; | |
100 | |
91 | 101 private HashSet<StatusChecker> statusCheckers = new HashSet<StatusChecker>(); |
1 | 102 private boolean warning = false; |
103 private String warningMessage = ""; | |
104 private boolean displayWarning = false; | |
105 | |
106 //private PanelPopup popup = new PanelPopup(); | |
107 //private String popupText = ""; | |
108 | |
109 private String currentId; | |
110 private String currentIdMsg; | |
111 | |
112 // used in the new version | |
113 private Boolean create_error = false; | |
114 private String selectedWitnessID = "0"; | |
115 private boolean showWitness; | |
116 private boolean showTitle = false; | |
117 | |
118 private Map<String, String> attributes = new HashMap<String, String>(); | |
119 protected String defObjectClass = null; | |
120 | |
121 protected String displayUrl; | |
122 | |
123 protected Entity entity; | |
124 | |
125 protected long start; | |
126 | |
91 | 127 /** |
128 * Save current entity. | |
129 * | |
130 * @return | |
131 */ | |
1 | 132 public String save(){ |
133 logger.info("*************** START Saving "+ this.defObjectClass + " [ID=" + entity.getId() +", user"+ getUserName() +"] *********************"); | |
95 | 134 txLog.debug("*** START Saving "+ this.defObjectClass + " id=" + entity.getId() +" user="+getUserName()); |
1 | 135 this.start = System.currentTimeMillis(); |
136 return null; | |
137 } | |
138 | |
91 | 139 /** |
140 * End saving current entity. | |
141 * | |
142 * To be called at the end of save(). | |
143 */ | |
1 | 144 protected void saveEnd(){ |
145 logger.info("*************** END Saving "+ this.defObjectClass + " [ID=" + entity.getId() +", user"+ getUserName() +"] *********************\n"); | |
95 | 146 txLog.debug("*** END Saving "+ this.defObjectClass + " id=" + entity.getId() +" user="+getUserName()); |
1 | 147 } |
148 | |
149 public Entity getEntity() { | |
150 if (this.entity == null) { | |
151 this.entity = new Entity(); | |
152 this.entity.setObjectClass(defObjectClass); | |
153 this.entity.setLightweight(false); | |
154 this.loadAttributes(this.entity); | |
155 } | |
156 return entity; | |
157 } | |
158 | |
91 | 159 /** |
160 * Add save confirmation to message. | |
161 */ | |
162 protected void printSuccessSavingEntity() { | |
1 | 163 this.addGeneralMsg("The entity was successfully saved!"); |
164 this.addGeneralMsg("Its ID is " + this.entity.getId()); | |
165 } | |
166 | |
105 | 167 /** |
168 * Set the current Entity and parse data for the form. | |
169 * | |
170 * @param entity | |
171 */ | |
1 | 172 public void setEntity(Entity entity) { |
173 this.entity = entity; | |
174 } | |
175 | |
176 public String getSaveButtonLabel(){ | |
177 if(entity.isPersistent()) | |
178 return "Save"; | |
179 return "Create"; | |
180 } | |
181 | |
182 public boolean isRenderSaveButton(){ | |
183 //#{(CurrentText.entity.id == null and Session.canCreate) || (CurrentText.entity.id != null and Session.canEdit)} | |
184 if((!entity.isPersistent() && getSessionBean().isCanCreate()) || | |
185 entity.isPersistent() && getSessionBean().isCanEdit()) | |
186 return true; | |
187 return false; | |
188 } | |
189 | |
92 | 190 /** |
191 * Clear the bean by setting a new empty entity. | |
192 * @return | |
193 */ | |
1 | 194 public String clearAction(){ |
119 | 195 //System.out.println("clearAction"); |
1 | 196 this.entity = new Entity(Node.TYPE_ABOX, this.defObjectClass, false); |
197 this.setEntity(this.entity); | |
198 return PAGE_EDITOR; | |
199 } | |
200 | |
92 | 201 /** |
202 * Reload the bean using the entity with currentId. | |
203 * @return | |
204 */ | |
90 | 205 public String actionReloadEntity() { |
1 | 206 Long id = null; |
90 | 207 try { |
1 | 208 id = new Long(this.getCurrentId()); |
90 | 209 } catch (Exception e) {} |
1 | 210 |
90 | 211 if (id != null) { |
212 Entity newEnt = getWrapper().getEntityById(id); | |
213 if (newEnt != null && newEnt.getObjectClass().equals(this.defObjectClass)) { | |
214 this.setEntity(newEnt); | |
215 } else { | |
1 | 216 this.setCurrentIdMsg("Entity no found!"); |
217 } | |
90 | 218 } else { |
1 | 219 this.setCurrentIdMsg("ID is not valid!"); |
220 } | |
221 return PAGE_EDITOR; | |
222 } | |
223 | |
224 public String getDisplayUrl() { | |
225 return displayUrl; | |
226 } | |
227 | |
228 public void setDisplayUrl(String displayUrl) { | |
229 this.displayUrl = displayUrl; | |
230 } | |
231 | |
232 public static String generateDisplayUrl(Entity author, Entity title, Entity witness, String rootUrl){ | |
233 //example: ?personId=414996&textId=36650&witnessId=66802#witnesses | |
234 StringBuilder sb = new StringBuilder(); | |
235 if(author != null && author.isPersistent()){ | |
236 sb.append(rootUrl + "/search/displayAuthor.xhtml?"); | |
237 sb.append("personId=" + author.getId()); | |
238 if(title != null && title.isPersistent()){ | |
239 sb.append("&textId=" + title.getId()); | |
240 if(witness != null && witness.isPersistent()){ | |
241 sb.append("&witness=" + witness.getId()); | |
242 sb.append("#witnesses"); | |
243 }else{ | |
244 sb.append("#titles"); | |
245 } | |
246 } | |
247 }else if(title != null && title.isPersistent()){ | |
248 sb.append(rootUrl + "/search/displayTitle.xhtml?"); | |
249 sb.append("&textId=" + title.getId()); | |
250 if(witness != null && witness.isPersistent()){ | |
251 sb.append("&witness=" + witness.getId()); | |
252 sb.append("#witnesses"); | |
253 }else{ | |
254 sb.append("#titles"); | |
255 } | |
256 | |
257 } | |
258 return sb.toString(); | |
259 } | |
260 | |
261 //******************************** | |
262 //**** PUBLICATIONS END NOTE ***** | |
263 //******************************** | |
264 | |
265 private ReferenceTable endNoteRefTable = new ReferenceTable(); | |
266 | |
267 protected void loadEndNoteRefs(){ | |
268 this.endNoteRefTable.loadRefs(getEntRefs()); | |
269 } | |
270 | |
271 public ReferenceTable getEndNoteRefTable() { | |
272 return endNoteRefTable; | |
273 } | |
274 | |
275 public void setEndNoteRefTable(ReferenceTable endNoteRefTable) { | |
276 this.endNoteRefTable = endNoteRefTable; | |
277 } | |
278 | |
279 private List<Entity> getEntRefs(){ | |
280 List<Entity> rs = new ArrayList<Entity>(); | |
281 for (Relation rel : this.entity.getTargetRelations()) { | |
282 if (rel.getOwnValue().equals(rel_is_reference_of)) { | |
283 rs.add(getWrapper().getEntityByIdWithContent(rel.getSourceId())); | |
284 } | |
285 } | |
286 return rs; | |
287 } | |
288 | |
289 | |
91 | 290 /** |
291 * Save references and set relations. | |
292 * | |
293 * @throws Exception | |
294 */ | |
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
|
295 protected void prepareEndNoteRefs2Save() throws Exception { |
1 | 296 //REFERENCE -> is_reference_of -> WITNESS |
297 this.entity.removeAllTargetRelationsByName(rel_is_reference_of); | |
91 | 298 for (SelectableObject<Reference> so : this.endNoteRefTable.list) { |
1 | 299 Reference ref = so.getObj(); |
300 Entity entRef = ref.getEnt(); | |
91 | 301 getWrapper().saveEntity(entRef, getUserName()); |
1 | 302 //entity can be no persistent, therefore the assignment of the relation should be done after the save |
303 entRef.addSourceRelation(rel_is_reference_of, entity); | |
304 //new Relation(entRef, entity, rel_is_reference_of); | |
305 } | |
306 } | |
307 | |
308 | |
91 | 309 public static Calendar updateCalendar(Attribute att){ |
310 Calendar calendar = null; | |
1 | 311 if(att != null && StringUtils.isNotEmpty(att.getOwnValue())){ |
91 | 312 calendar = new Calendar(att.getOwnValue()); |
1 | 313 }else{ |
91 | 314 calendar = new Calendar(); |
1 | 315 } |
316 return calendar; | |
317 } | |
318 | |
92 | 319 /** |
320 * Load all (defined) attributes of the entity into this.attributes. | |
321 * | |
322 * Creates new empty attributes if entity=null. | |
323 * | |
324 * @param entity | |
325 */ | |
326 protected void loadAttributes(Entity entity) { | |
327 attributes = new HashMap<String, String>(); | |
328 if (entity != null) { | |
329 for (Attribute defAtt : getWrapper().getDefAttributes(this.defObjectClass)) { | |
330 Attribute originalAtt = entity.getAttributeByName(defAtt.getOwnValue()); | |
331 String attValue = (originalAtt != null) ? originalAtt.getOwnValue() : ""; | |
332 attributes.put(defAtt.getOwnValue(), attValue); | |
333 } | |
334 } else { | |
335 for (Attribute defAtt : getWrapper().getDefAttributes(this.defObjectClass)) { | |
336 attributes.put(defAtt.getOwnValue(), ""); | |
337 } | |
338 } | |
339 } | |
1 | 340 |
105 | 341 /** |
342 * Clear some selected options. | |
343 */ | |
1 | 344 public void reset(){ |
345 this.setSelectedSaveAsNew(false); | |
346 this.setCurrentId(""); | |
347 this.setCurrentIdMsg(""); | |
348 this.setAttributes(new HashMap<String, String>()); | |
349 this.displayUrl = null; | |
350 this.endNoteRefTable = new ReferenceTable(); | |
351 } | |
352 | |
353 public boolean isSelectedSaveAsNew() { | |
354 return selectedSaveAsNew; | |
355 } | |
356 | |
357 public void setSelectedSaveAsNew(boolean selectedSaveAsNew) { | |
358 this.selectedSaveAsNew = selectedSaveAsNew; | |
359 } | |
360 | |
361 /** | |
91 | 362 * Update the defined attributes of the given entity with the |
1 | 363 * attributes of the attributes Map<String, String>. |
364 * | |
91 | 365 * @return the entity with updated attributes. |
1 | 366 */ |
91 | 367 public Entity updateEntityAttributes(Entity entity) { |
368 // create entity if it doesn't exist | |
369 if (entity == null) { | |
370 entity = new Entity(Node.TYPE_ABOX, false); | |
371 entity.setObjectClass(this.defObjectClass); | |
372 } | |
373 // update all defined attributes | |
374 for (Attribute defAtt : getWrapper().getDefAttributes(this.defObjectClass)) { | |
375 String attName = defAtt.getOwnValue(); | |
376 Attribute att = entity.getAttributeByName(attName); | |
377 if (StringUtils.isNotEmpty(this.attributes.get(attName))) { | |
378 // there is an attribute to update | |
379 if (att == null) { | |
380 // attribute is new | |
381 att = new Attribute(defAtt); | |
382 entity.addAttribute(att); | |
383 } | |
384 // update value | |
385 att.setOwnValue(this.attributes.get(attName)); | |
386 att.setObjectClass(attName); | |
387 } else if (att != null) { | |
388 // there is no attribute to update - delete attribute | |
389 entity.getAttributes().remove(att); | |
390 } | |
391 } | |
392 return entity; | |
393 } | |
1 | 394 |
395 protected List<SelectItem> updateSuggestedPersonByRole(String searchWord, String objClass, String attName, String role){ | |
396 List<Attribute> attList = getWrapper().getAttributesByDefByAttName(objClass, attName, searchWord.toString(), -1); | |
397 | |
398 List<SelectItem> suggestedItems = new ArrayList<SelectItem>(); | |
399 if (attList == null) | |
400 return suggestedItems; | |
401 | |
402 int count = 0; | |
403 for (Attribute att : attList) { | |
404 if(getCache().roleContainsPersonId(role, att.getSourceId())){ | |
405 SelectItem item = new SelectItem(att, att.getOwnValue() + " [" + att.getSourceId() + "]","description: " + att); | |
406 suggestedItems.add(item); | |
407 count++; | |
408 if(count == MAX_SUGGEST) | |
409 break; | |
410 } | |
411 } | |
412 return suggestedItems; | |
413 } | |
414 | |
415 protected List<SelectItem> updateSuggestedItems(ValueChangeEvent event, | |
416 String objClass, String attName) { | |
417 return updateSuggestedItems((String) event.getNewValue(), objClass, | |
418 attName); | |
419 } | |
420 | |
421 protected List<SelectItem> updateSuggestedItems(String searchWord, | |
422 String objClass, String attName) { | |
423 | |
424 List<Attribute> attList = getWrapper().getAttributesByDefByAttName(objClass, attName, searchWord.toString(), MAX_SUGGEST); | |
425 | |
426 List<SelectItem> suggestedItems = new ArrayList<SelectItem>(); | |
427 if (attList == null) | |
428 return suggestedItems; | |
429 | |
430 for (Attribute att : attList) { | |
431 SelectItem item = new SelectItem(att, att.getOwnValue() + " [" + att.getSourceId() + "]", | |
432 "description: " + att); | |
433 suggestedItems.add(item); | |
434 } | |
435 return suggestedItems; | |
436 } | |
437 | |
438 protected SimpleSearchCache getCache(){ | |
439 return getAppBean().getSimpleSearchCache(); | |
440 } | |
441 | |
442 protected List<SelectItem> updateSuggestedItems(String objClass, | |
443 String firstName, String firstValue, String secondName, | |
444 String secondValue) { | |
445 | |
446 List<Attribute> attList = | |
447 getWrapper(). | |
448 searchAttribute(firstName, firstValue, secondName, secondValue, objClass, MAX_SUGGEST); | |
449 | |
450 List<SelectItem> suggestedItems = new ArrayList<SelectItem>(); | |
451 if (attList == null) | |
452 return suggestedItems; | |
453 | |
454 for (Attribute att : attList) { | |
455 SelectItem item = new SelectItem(att, att.getOwnValue() + " [" + att.getSourceId() + "]"); | |
456 suggestedItems.add(item); | |
457 } | |
458 return suggestedItems; | |
459 } | |
460 | |
461 public Map<String, String> getAttributes() { | |
462 return attributes; | |
463 } | |
464 | |
465 public void setAttributes(Map<String, String> attributes) { | |
466 this.attributes = attributes; | |
467 } | |
468 | |
469 /** | |
470 * <p> | |
471 * This method plays the role of a small cache to get quickly the | |
472 * definitions. | |
473 * </p> | |
474 * TODO this method must be implemented into a bean in session context and | |
475 * research by every beans. | |
476 * | |
477 * @param assertion | |
478 * @return | |
479 */ | |
480 public Entity getLWDefinition(Entity assertion) { | |
481 return getWrapper().getDefinition(assertion.getObjectClass()); | |
482 } | |
483 | |
484 public Entity getLWDefinition(String objClass) { | |
485 return getWrapper().getDefinition(objClass); | |
486 } | |
487 | |
488 /** | |
489 * <p> | |
490 * Returns the target's entity of a relation. The returned target is no | |
491 * light weight. | |
492 * <p> | |
493 * | |
494 * @param rel | |
495 * @param target | |
496 * @return | |
497 */ | |
498 protected Entity getTargetRelation(Relation rel) { | |
499 Entity target = rel.getTarget(); | |
500 if (target == null) { | |
501 target = getWrapper().getEntityById(rel.getTargetId()); | |
502 rel.setTarget(target); | |
503 } else if (target.isLightweight()) { | |
504 target = getWrapper().getEntityContent(target); | |
505 } | |
506 return target; | |
507 } | |
508 | |
509 protected Attribute getTargetAttribute(Entity target, String name) { | |
510 Attribute att = getWrapper().getAttributeByName(target.getId(), name); | |
511 | |
512 if (att == null) { | |
513 att = new Attribute(); | |
514 att.setOwnValue(target.getOwnValue()); | |
515 } | |
516 return att; | |
517 } | |
518 | |
519 protected WrapperService getWrapper() { | |
520 return getAppBean().getWrapper(); | |
521 } | |
522 | |
523 /** | |
524 * <p> | |
525 * Return the <code>FacesContext</code> instance for the current request. | |
526 */ | |
527 protected FacesContext context() { | |
528 return (FacesContext.getCurrentInstance()); | |
529 } | |
530 | |
531 public void setCreate_error(Boolean create_error) { | |
532 this.create_error = create_error; | |
533 } | |
534 | |
535 public Boolean getCreate_error() { | |
536 return create_error; | |
537 } | |
538 | |
539 /** | |
540 * Eine Liste <code>toBeRestricted</code> wird so eingeschraenkt, dass nur | |
541 * noch die jenigen uebrig bleiben, die �ber die Relation | |
542 * <code>relation</code> mit einem der Elemente aus | |
543 * <code>contraintIds</code> verbunden sind. | |
544 * | |
545 * @param toBeRestricted | |
546 * @param constraintIds | |
547 * @param relation | |
548 * @param mode | |
549 * @return | |
550 */ | |
551 protected List<SelectItem> restrictList(List<SelectItem> toBeRestricted, | |
552 List<String> constraintIds, String relation, String mode) { | |
553 | |
554 List<SelectItem> newList = new ArrayList<SelectItem>(); | |
555 | |
556 for (SelectItem s : toBeRestricted) { | |
557 Entity ent = getWrapper().getEntityById( | |
558 Long.valueOf((String) s.getValue())); | |
559 if (s.getValue().equals("0")) { | |
560 newList.add(s); | |
561 continue; | |
562 } | |
563 | |
564 List<Relation> rels; | |
565 if (mode.equals("target")) { | |
566 rels = ent.getTargetRelations(); | |
567 } else if (mode.equals("source")) { | |
568 rels = ent.getSourceRelations(); | |
569 } else { | |
570 System.err.println("restrict List - mode not defined:" + mode); | |
571 return null; | |
572 } | |
573 | |
574 for (Relation r : rels) { | |
575 if (r.getObjectClass().equals(relation)) { | |
576 Long id; | |
577 if (mode.equals("target")) { | |
578 id = r.getSource().getId(); | |
579 } else if (mode.equals("source")) { | |
580 id = r.getTarget().getId(); | |
581 } else { | |
582 System.err.println("restrict List - mode not defined:" | |
583 + mode); | |
584 return null; | |
585 } | |
586 if (constraintIds.contains(String.valueOf(id))) { | |
587 newList.add(s); | |
588 } | |
589 } | |
590 } | |
591 } | |
592 | |
593 return newList; | |
594 } | |
595 | |
596 public String getSelectedWitnessID() { | |
597 return selectedWitnessID; | |
598 } | |
599 | |
600 public void setShowWitness(boolean showWitness) { | |
601 this.showWitness = showWitness; | |
602 } | |
603 | |
604 public boolean isShowWitness() { | |
605 return showWitness; | |
606 } | |
607 | |
608 public void setShowTitle(boolean showTitle) { | |
609 this.showTitle = showTitle; | |
610 } | |
611 | |
612 public boolean isShowTitle() { | |
613 return showTitle; | |
614 } | |
615 /* | |
616 public PanelPopup getPopup() { | |
617 return popup; | |
618 } | |
619 | |
620 public void setPopup(PanelPopup popup) { | |
621 this.popup = popup; | |
622 } | |
623 | |
624 public String getPopupText() { | |
625 return popupText; | |
626 } | |
627 | |
628 public void setPopupText(String popupText) { | |
629 this.popupText = popupText; | |
630 }*/ | |
631 | |
632 | |
633 public String getUserName(){ | |
634 User user = getSessionUser(); | |
635 if(user == null) | |
636 return ""; | |
637 else | |
638 return user.getEmail(); | |
639 } | |
640 | |
641 public User getSessionUser() { | |
642 SessionBean bean = getSessionBean(); | |
643 if(bean != null){ | |
644 return bean.getUser(); | |
645 }else{ | |
646 return null; | |
647 } | |
648 } | |
649 | |
650 public void fillList(List<SelectItem> list, String[] array) { | |
651 list.add(new SelectItem("")); | |
652 for (int i = 0; i < array.length; i++) { | |
653 list.add(new SelectItem(array[i])); | |
654 } | |
655 | |
656 } | |
657 | |
658 public boolean isWarning() { | |
659 return warning; | |
660 } | |
661 | |
662 public void setWarning(boolean warning) { | |
663 this.warning = warning; | |
664 } | |
665 | |
666 public void setWarningMessage(String warningMessage) { | |
667 this.warningMessage = warningMessage; | |
668 } | |
669 | |
670 public String getWarningMessage() { | |
671 return warningMessage; | |
672 } | |
673 | |
674 public void setDisplayWarning(boolean displayWarning) { | |
675 this.displayWarning = displayWarning; | |
676 } | |
677 | |
678 public boolean isDisplayWarning() { | |
679 return displayWarning; | |
680 } | |
681 | |
682 public void registerChecker(StatusChecker sc) { | |
91 | 683 statusCheckers.add(sc); |
1 | 684 } |
685 | |
686 public void registerChecker(ListenerObject lo, String message) { | |
687 registerChecker(lo.statusImage, message); | |
688 | |
689 } | |
690 | |
691 public void registerChecker(StatusChecker sc, String message) { | |
692 sc.setMessage(message); | |
91 | 693 statusCheckers.add(sc); |
1 | 694 } |
695 | |
696 class CheckResults { | |
697 List<String> errors = new ArrayList<String>(); | |
698 List<String> warnings = new ArrayList<String>(); | |
699 public boolean hasErrors = false; | |
700 public boolean hasWarnings = false; | |
701 | |
702 } | |
703 | |
91 | 704 /** |
705 * Get the result from all StatusCheckers. | |
706 * | |
707 * @return | |
708 */ | |
1 | 709 public CheckResults getCheckResults() { |
710 CheckResults cr = new CheckResults(); | |
711 | |
91 | 712 for (StatusChecker sc : statusCheckers) { |
1 | 713 if (sc.getStatus().equals("false")) { |
714 cr.hasErrors = true; | |
715 cr.errors.add(sc.getMessage()); | |
716 } else if (sc.getStatus().equals("unset")) { | |
717 cr.hasWarnings = true; | |
718 cr.warnings.add(sc.getMessage()); | |
719 } | |
720 } | |
721 return cr; | |
722 } | |
723 | |
724 protected ListenerObject changeValue(String ownvalue, ListenerObject lo, String suggestType, String suggestAttributeName, | |
725 List<SelectItem> restrictedItems) { | |
726 if (restrictedItems != null) { | |
727 lo.suggestedItems = restrictedItems;} | |
728 | |
729 if (ownvalue == null || ownvalue.equals("")) | |
730 lo.statusImage.setStatus("unset"); | |
731 else | |
732 lo.statusImage.setStatus("false"); | |
733 lo.entity = null; | |
734 // setze erst mal den Eigenwert auf das eingebene. | |
735 Attribute at = new Attribute(); | |
736 at.setOwnValue(ownvalue); | |
737 lo.attribute = at; | |
738 Entity element = null; | |
739 if (lo.suggestedItems != null) // schaue in der liste der vorgebenen Ereignisse nach. | |
740 for (SelectItem item : lo.suggestedItems) { | |
741 if (item.getLabel().equals(ownvalue)) { | |
742 if (Attribute.class.isInstance(item.getValue())){ // entweder es ist schon ein attribute | |
743 lo.attribute = (Attribute) item.getValue(); | |
744 element = getWrapper().getEntityById( | |
745 lo.attribute.getSourceId()); | |
746 }else{ //oder ein paar wert / id// = (Attribute) item.getValue(); | |
747 element = getWrapper().getEntityById(Long.valueOf((String) item.getValue())); | |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
105
diff
changeset
|
748 lo.setEntityAndAttributeName(element, suggestAttributeName); |
1 | 749 } |
750 if (element != null) { | |
751 if(element.isLightweight()){ | |
752 element = getWrapper().getEntityByIdWithContent(element.getId()); | |
753 } | |
754 lo.entity = element; | |
755 lo.statusImage.setStatus("ok"); | |
756 } | |
757 break; | |
758 } | |
759 | |
760 } else { | |
761 //juc *** List<Entity> ents = getWrapper().getLightweightConceptsByAttribute(null, suggestType, suggestAttributeName, ownvalue, 1, false); | |
762 List<Entity> ents = getWrapper().getEntitiesByAtt(suggestType, suggestAttributeName, ownvalue, 1, false); | |
763 if (ents.size()==1){ | |
111
22a18bfc66b0
new completion that uses ALIASes: AbstractListenerObject. was_copied_in in WITNESS form can use PLACE aliases now. some cleanup.
casties
parents:
105
diff
changeset
|
764 lo.setEntityAndAttributeName(ents.get(0),suggestAttributeName); |
1 | 765 lo.statusImage.setStatus("ok"); |
766 } | |
767 | |
768 } | |
769 return lo; | |
770 | |
771 } | |
772 | |
773 | |
774 | |
775 protected ListenerObject changeValuePersonByRole(ValueChangeEvent event, ListenerObject lo, String role){ | |
776 if (event.getNewValue() == null) { | |
777 return lo; | |
778 }else if(StringUtils.isEmpty(event.getNewValue().toString()) && (event.getOldValue() == null || StringUtils.isEmpty(event.getOldValue().toString()))){ | |
779 //if the old and new value are empty, then return | |
780 return lo; | |
781 } | |
782 if (event.getNewValue().equals(event.getOldValue())) { | |
783 return lo; | |
784 } | |
785 | |
786 String ownValue = (String) event.getNewValue(); | |
787 | |
788 if(StringUtils.isEmpty(ownValue)) | |
789 lo.statusImage.setStatus("unset"); | |
790 else | |
791 lo.statusImage.setStatus("false"); | |
792 | |
793 lo.entity = null; | |
794 // setze erst mal den Eigenwert auf das eingebene. | |
795 Attribute at = new Attribute(); | |
796 at.setOwnValue(ownValue); | |
797 lo.attribute = at; | |
798 for (SelectItem item : lo.suggestedItems) { | |
799 if (StringUtils.isNotEmpty(item.getLabel()) && | |
800 item.getLabel().equals(ownValue)) { | |
801 //System.out.println("item.getValue()= " + item.getValue()); | |
802 lo.attribute = (Attribute) item.getValue(); | |
803 Entity element = getWrapper().getEntityById( | |
804 lo.attribute.getSourceId()); | |
805 | |
806 if (element != null) { | |
807 if(element.isLightweight()){ | |
808 element = getWrapper().getEntityByIdWithContent(element.getId()); | |
809 } | |
810 lo.entity = element; | |
811 lo.statusImage.setStatus(StatusImage.STATUS_OK); | |
812 } | |
813 break; | |
814 } | |
815 | |
816 } | |
817 | |
818 //juc lo.suggestedItems = updateSuggestedPersonByRole(ownValue, PERSON, "name", role); | |
819 lo.suggestedItems = updateSuggestedPersonByRole(ownValue, PERSON, "name_translit", role); | |
820 | |
821 | |
822 return lo; | |
823 } | |
824 | |
825 protected ListenerObject changeValue(String ownvalue, ListenerObject lo, | |
826 String suggestType, String suggestAttributeName) { | |
827 | |
828 return changeValue(ownvalue, lo, suggestType, suggestAttributeName, | |
829 null); | |
830 } | |
831 | |
832 protected ListenerObject changeListener(ValueChangeEvent event, | |
833 ListenerObject lo, String suggestType, String suggestAttributeName, | |
834 String restrictingAttributeName, String restrictingAttributeValue) { | |
835 try { | |
836 if (event.getNewValue() == null) { | |
837 return lo; | |
838 }else if(StringUtils.isEmpty(event.getNewValue().toString()) && (event.getOldValue() == null || StringUtils.isEmpty(event.getOldValue().toString()))){ | |
839 //if the old and new value are empty, then return | |
840 return lo; | |
841 } | |
842 if (event.getNewValue().equals(event.getOldValue())) { | |
843 return lo; | |
844 } | |
845 | |
846 String ownvalue = (String) event.getNewValue(); | |
847 | |
848 if(StringUtils.isEmpty(ownvalue)) | |
849 lo.statusImage.setStatus(StatusImage.STATUS_UNSET); | |
850 else | |
851 lo.statusImage.setStatus(StatusImage.STATUS_FALSE); | |
852 | |
853 lo.entity = null; | |
854 // setze erst mal den Eigenwert auf das eingebene. | |
855 Attribute at = new Attribute(); | |
856 at.setOwnValue(ownvalue); | |
857 lo.attribute = at; | |
858 for (SelectItem item : lo.suggestedItems) { | |
859 if (StringUtils.isNotEmpty(item.getLabel()) && | |
860 item.getLabel().equals(ownvalue)) { | |
861 //System.out.println("item.getValue()= " + item.getValue()); | |
862 lo.attribute = (Attribute) item.getValue(); | |
863 Entity element = getWrapper().getEntityById( | |
864 lo.attribute.getSourceId()); | |
865 | |
866 if (element != null) { | |
867 if(element.isLightweight()){ | |
868 element = getWrapper().getEntityByIdWithContent(element.getId()); | |
869 } | |
870 lo.entity = element; | |
871 lo.statusImage.setStatus(StatusImage.STATUS_OK); | |
872 } | |
873 break; | |
874 } | |
875 | |
876 } | |
877 | |
878 if (restrictingAttributeName == null) { | |
879 lo.suggestedItems = this.updateSuggestedItems(event, | |
880 suggestType, suggestAttributeName); | |
881 } else { | |
882 lo.suggestedItems = this.updateSuggestedItems(suggestType, | |
883 suggestAttributeName, event.getNewValue().toString(), | |
884 restrictingAttributeName, restrictingAttributeValue); | |
885 } | |
886 | |
887 } catch (Exception e) { | |
888 e.printStackTrace(); | |
889 } | |
890 return lo; | |
891 } | |
892 | |
91 | 893 /** |
894 * Update the ownvalues of entities that are related to the given entity. | |
895 * | |
896 * @param entity | |
897 * @param user | |
898 * @throws Exception | |
899 */ | |
900 protected void updateRelatedOW(Entity entity, String user) throws Exception { | |
901 List<Entity> nodeList = new ArrayList<Entity>(); | |
902 | |
903 /* | |
904 * run updates depending on type | |
905 */ | |
906 if (entity.getObjectClass().equals(PLACE)) { | |
907 this.generateOW4City(entity, nodeList, user); | |
908 getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user); | |
909 | |
910 } else if (entity.getObjectClass().equals(REPOSITORY)) { | |
911 this.generateOW4Repository(entity, nodeList, new HashMap<String, String>(), user); | |
912 getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user); | |
913 | |
914 } else if (entity.getObjectClass().equals(COLLECTION)) { | |
915 this.generateOW4Collection(entity, nodeList, new HashMap<String, String>(), user); | |
916 getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user); | |
917 | |
918 } else if (entity.getObjectClass().equals(CODEX)) { | |
919 this.generateOW4Codex(entity, nodeList, new HashMap<String, String>(), user); | |
920 getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user); | |
921 | |
922 } else if (entity.getObjectClass().equals(TEXT)) { | |
923 generateOW4Text(entity, user); | |
924 } | |
925 // TODO PERSON and TEXT | |
926 } | |
1 | 927 |
928 private void generateOW4City(Entity city, List<Entity> nodeList, String user){ | |
929 Map<String, String> map = new HashMap<String, String>(); | |
930 map.put(PLACE, city.getOwnValue()); | |
931 | |
932 List<Entity> repoList = getWrapper().getSourcesForTargetRelation(city, is_in, REPOSITORY, -1); | |
933 for(Entity repo : repoList){ | |
934 this.generateOW4Repository(repo, nodeList, map, user); | |
935 } | |
936 } | |
937 | |
938 private void generateOW4Repository(Entity repository, List<Entity> nodeList, Map<String, String> map, String user){ | |
939 if(map.size() == 0){ | |
940 List<Entity> placeList = getWrapper().getTargetsForSourceRelation(repository, is_in, PLACE, 1); | |
941 map.put(PLACE, ((placeList.size() > 0) ? placeList.get(0).getOwnValue() : "")); | |
942 } | |
943 | |
944 map.put(REPOSITORY, repository.getOwnValue()); | |
945 List<Entity> collectionList = getWrapper().getSourcesForTargetRelation(repository, is_part_of, COLLECTION, -1); | |
946 for(Entity collection : collectionList){ | |
947 this.generateOW4Collection(collection, nodeList, map, user); | |
948 } | |
949 } | |
950 | |
951 private void generateOW4Collection(Entity collection, List<Entity> nodeList, Map<String, String> map, String user){ | |
952 if(map.size() == 0){ | |
953 List<Entity> repoList = getWrapper().getTargetsForSourceRelation(collection, is_part_of, REPOSITORY, 1); | |
954 map.put(REPOSITORY, (repoList.size() > 0) ? repoList.get(0).getOwnValue() : ""); | |
955 if(repoList.size() > 0){ | |
956 Entity repository = repoList.get(0); | |
957 List<Entity> placeList = getWrapper().getTargetsForSourceRelation(repository, is_in, PLACE, 1); | |
958 map.put(PLACE, (placeList.size() > 0) ? placeList.get(0).getOwnValue() : ""); | |
959 }else{ | |
960 map.put(REPOSITORY, ""); | |
961 map.put(PLACE, ""); | |
962 } | |
963 } | |
964 | |
965 map.put(COLLECTION, collection.getOwnValue()); | |
966 List<Entity> list = getWrapper().getSourcesForTargetRelation(collection, is_part_of, CODEX, -1); | |
967 for(Entity codex : list){ | |
968 //update ow codex | |
969 Attribute att = getWrapper().getAttributeByName(codex.getId(), "identifier"); | |
970 if(att != null){ | |
971 codex.setOwnValue(collection.getOwnValue() + "_" + att.getOwnValue()); | |
972 nodeList.add(codex); | |
973 } | |
974 this.generateOW4Codex(codex, nodeList, map, user); | |
975 } | |
976 } | |
977 | |
978 private void generateOW4Codex(Entity codex, List<Entity> nodeList, Map<String, String> map, String user){ | |
979 if(map.size() == 0){ | |
980 List<Entity> collList = getWrapper().getTargetsForSourceRelation(codex, is_part_of, COLLECTION, 1); | |
981 map.put(COLLECTION, (collList.size() > 0 ) ? collList.get(0).getOwnValue() : ""); | |
982 if(collList.size() > 0){ | |
983 Entity collection = collList.get(0); | |
984 List<Entity> repoList = getWrapper().getTargetsForSourceRelation(collection, is_part_of, REPOSITORY, 1); | |
985 map.put(REPOSITORY, (repoList.size() > 0) ? repoList.get(0).getOwnValue() : ""); | |
986 if(repoList.size() > 0){ | |
987 Entity repository = repoList.get(0); | |
988 List<Entity> placeList = getWrapper().getTargetsForSourceRelation(repository, is_in, PLACE, 1); | |
989 map.put(PLACE, (placeList.size() > 0) ? placeList.get(0).getOwnValue() : ""); | |
990 }else{ | |
991 map.put(PLACE, ""); | |
992 } | |
993 }else{ | |
994 map.put(COLLECTION, ""); | |
995 map.put(REPOSITORY, ""); | |
996 map.put(PLACE, ""); | |
997 } | |
998 } | |
999 List<Entity> list = getWrapper().getSourcesForTargetRelation(codex, is_part_of, WITNESS, -1); | |
1000 String placeText = (StringUtils.isNotEmpty(map.get(PLACE))) ? "_" + map.get(PLACE) : ""; | |
1001 String repoText = (StringUtils.isNotEmpty(map.get(REPOSITORY))) ? "_" + map.get(REPOSITORY) : ""; | |
1002 String codexText = (codex != null) ? "_" + codex.getOwnValue() : ""; | |
1003 | |
1004 for(Entity witness : list){ | |
1005 List<Entity> textList = getWrapper().getTargetsForSourceRelation(witness, "is_exemplar_of", TEXT, -1); | |
1006 String textName = (textList.size() > 0) ? textList.get(0).getOwnValue() : ""; | |
1007 witness.setOwnValue(textName + placeText + repoText + codexText); | |
1008 nodeList.add(witness); | |
1009 } | |
1010 } | |
1011 | |
1012 private void generateOW4Text(Entity text, String user) throws Exception{ | |
1013 List<Entity> witnessList = getWrapper().getSourcesForTargetRelation(text, "is_exemplar_of", WITNESS, -1); | |
1014 List<Entity> listToSave = new ArrayList<Entity>(); | |
1015 for(Entity witness : witnessList){ | |
1016 List<Entity> list = getWrapper().getTargetsForSourceRelation(witness, "is_part_of", "CODEX", 1); | |
1017 if(list.size() > 0){ | |
1018 Entity codex = list.get(0); | |
1019 list = getWrapper().getTargetsForSourceRelation(codex, "is_part_of", "COLLECTION", 1); | |
1020 if(list.size() > 0){ | |
1021 Entity collection = list.get(0); | |
1022 list = getWrapper().getTargetsForSourceRelation(collection, "is_part_of", "REPOSITORY", 1); | |
1023 if(list.size() > 0){ | |
1024 Entity repository = list.get(0); | |
1025 list = getWrapper().getTargetsForSourceRelation(repository, "is_in", "PLACE", 1); | |
1026 if(list.size() > 0){ | |
1027 Entity city = list.get(0); | |
1028 witness.setOwnValue(text.getOwnValue() + "_" + city.getOwnValue() + "_" + repository.getOwnValue() + "_" + codex.getOwnValue()); | |
1029 listToSave.add(witness); | |
1030 } | |
1031 } | |
1032 } | |
1033 } | |
1034 getWrapper().saveEntityListAsNodeWithoutContent(listToSave, user); | |
1035 } | |
1036 } | |
1037 | |
1038 protected SecurityService getSecurityService() { | |
1039 return getAppBean().getSecurityService(); | |
1040 } | |
1041 | |
1042 protected ListenerObject changeListener(ValueChangeEvent event, | |
1043 ListenerObject lo, String suggestType, String suggestAttributeName) { | |
1044 | |
1045 return changeListener(event, lo, suggestType, suggestAttributeName, | |
1046 null, null); | |
1047 } | |
1048 | |
1049 public String getCurrentId() { | |
1050 return currentId; | |
1051 } | |
1052 | |
1053 public void setCurrentId(String currentId) { | |
1054 this.currentId = currentId; | |
1055 } | |
1056 | |
1057 public String getCurrentIdMsg() { | |
1058 return currentIdMsg; | |
1059 } | |
1060 | |
1061 public void setCurrentIdMsg(String currentIdMsg) { | |
1062 this.currentIdMsg = currentIdMsg; | |
1063 } | |
1064 | |
1065 public String getDefObjectClass() { | |
1066 return defObjectClass; | |
1067 } | |
1068 | |
1069 public void setDefObjectClass(String defObjectClass) { | |
1070 this.defObjectClass = defObjectClass; | |
1071 } | |
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
|
1072 |
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
|
1073 /** |
113 | 1074 * Replace the given source relations on the given entity by the contents of the AliasListenerObject |
1075 * (type entClass) using the given relName and aliasRelName. | |
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
|
1076 * |
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
|
1077 * ent - relName -> targetClass, |
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
|
1078 * ent - aliasRelName -> ALIAS |
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
|
1079 * |
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
|
1080 * @param ent |
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
|
1081 * @param lo |
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
|
1082 * @param targetClass |
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
|
1083 * @param relName |
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
|
1084 * @param aliasRelName |
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
|
1085 */ |
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
|
1086 protected void replaceAliasSourceRelation(Entity ent, AliasListenerObject lo, String targetClass, String relName, String aliasRelName) { |
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
|
1087 Entity target = lo.entity; |
114 | 1088 if (target == null || target.getObjectClass() == null) { |
1089 return; | |
1090 } | |
1091 if (target.getObjectClass().equals(targetClass)) { | |
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
|
1092 // regular target entity e.g. PLACE |
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
|
1093 ent.replaceSourceRelation(target, targetClass, relName); |
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
|
1094 ent.removeAllSourceRelationsByName(aliasRelName); |
114 | 1095 } else if (target.getObjectClass().equals(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
|
1096 // e.g. WITNESS -> was_created_in_as -> ALIAS |
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
|
1097 ent.replaceSourceRelation(target, ALIAS, aliasRelName); |
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
|
1098 // ALIAS -> is_alias_name_of -> PLACE |
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
|
1099 List<Entity> places = getWrapper().getTargetsForSourceRelation(target, is_alias_name_of, targetClass, 1); |
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
|
1100 if (! places.isEmpty()) { |
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
|
1101 // e.g. WITNESS -> was_created_in -> PLACE |
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
|
1102 ent.replaceSourceRelation(places.get(0), targetClass, relName); |
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
|
1103 } |
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
|
1104 } |
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
|
1105 } |
1 | 1106 } |