Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/event/beans/CopyEvent.java @ 112:59f26a5ef2b3
AliasListenerObject adds aliases to ListenerObject. Change all forms to enable ALIAS for (historical) PLACE fields. Remove REPOSITORY from event forms.
author | casties |
---|---|
date | Tue, 13 Dec 2016 19:04:45 +0100 |
parents | 22a18bfc66b0 |
children | 8e3f1f81acfb |
rev | line source |
---|---|
1 | 1 package de.mpiwg.itgroup.ismi.event.beans; |
2 | |
3 import java.io.Serializable; | |
4 import java.util.ArrayList; | |
5 | |
6 import javax.faces.event.ActionEvent; | |
7 import javax.faces.model.SelectItem; | |
8 | |
9 import org.mpi.openmind.repository.bo.Entity; | |
10 import org.mpi.openmind.repository.bo.Node; | |
11 import org.mpi.openmind.repository.bo.Relation; | |
12 | |
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
|
13 import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; |
1 | 14 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; |
15 import de.mpiwg.itgroup.ismi.auxObjects.lo.EventTextLO; | |
16 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; | |
17 | |
18 public class CopyEvent extends AbstractEvent implements Serializable{ | |
19 | |
20 /** | |
21 * | |
22 */ | |
23 private static final long serialVersionUID = 1545705063133894571L; | |
24 | |
25 public static String OC = "COPY_EVENT"; | |
26 | |
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
|
27 private ListenerObject personCopiedForLo; |
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
|
28 private ListenerObject personCopyingTextLo; |
1 | 29 |
30 private Calendar date; | |
31 | |
32 @Override | |
33 public void setEvent(Entity ev){ | |
34 reset(); | |
35 event = ev; | |
36 if(event != null && event.isPersistent()){ | |
37 if(event.isLightweight()){ | |
38 event = getWrapper().getEntityContent(event); | |
39 } | |
40 | |
41 this.loadAttributes(this.event); | |
42 this.date = updateCalendar(this.event.getAttributeByName("date")); | |
43 | |
44 for (Relation rel : event.getSourceRelations()) { | |
45 Entity target = null; | |
46 if (rel.getOwnValue().equals(was_copied_for)) { | |
95 | 47 //EVENT was_copied_for PERSON |
1 | 48 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:
95
diff
changeset
|
49 personCopiedForLo.setEntityAndAttribute(target); |
1 | 50 }else if (rel.getOwnValue().equals(has_person_copying_text)) { |
95 | 51 //EVENT has_person_copying_text PERSON |
1 | 52 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:
95
diff
changeset
|
53 personCopyingTextLo.setEntityAndAttribute(target); |
1 | 54 } else if (rel.getOwnValue().equals(was_copied_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
|
55 // EVENT was_copied_in PLACE |
1 | 56 target = getTargetRelation(rel); |
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
|
57 placeLo.setEntityAndAttributeIfEmpty(target); |
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
|
58 } else if (rel.getOwnValue().equals(was_copied_in_as)) { |
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
|
59 // EVENT was_copied_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
|
60 target = getTargetRelation(rel); |
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
|
61 placeLo.setEntityAndAttribute(target); |
1 | 62 } else if (rel.getOwnValue().equals(is_a_copy_of)) { |
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
|
63 // EVENT is_a_copy_of WITNESS |
1 | 64 this.witness = getTargetRelation(rel); |
65 if(witness != null && witness.isPersistent()){ | |
66 witnessId = witness.getId(); | |
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
|
67 // WITNESS is_exemplar_of TEXT |
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
|
68 this.textLo.setEntityAndAttribute(getTextOfWitness(witness)); |
1 | 69 refreshWitnesses(textLo.entity); |
70 } | |
71 } | |
72 } | |
73 } | |
74 } | |
75 | |
76 @Override | |
77 public void reset(){ | |
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 super.reset(); |
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
|
79 this.defObjectClass = OC; |
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
|
80 |
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
|
81 if (textLo != null) { |
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
|
82 textLo.reset(); |
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
|
83 } else { |
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
|
84 textLo = new EventTextLO(TEXT, full_title_translit, this); |
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
|
85 } |
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
|
86 |
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
|
87 if (personCopiedForLo != null) { |
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
|
88 personCopiedForLo.reset(); |
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
|
89 } else { |
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
|
90 personCopiedForLo = new ListenerObject(PERSON, name_translit); |
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
|
91 } |
1 | 92 |
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
|
93 if (personCopyingTextLo != null) { |
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
|
94 personCopyingTextLo.reset(); |
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
|
95 } else { |
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
|
96 personCopyingTextLo = new ListenerObject(PERSON, name_translit); |
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
|
97 } |
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
|
98 |
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
|
99 if (placeLo != null) { |
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
|
100 placeLo.reset(); |
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
|
101 } else { |
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
|
102 placeLo = new AliasListenerObject(PLACE, name, is_alias_name_of); |
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
|
103 } |
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
|
104 |
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
|
105 this.date = new Calendar(); |
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
|
106 this.witnessList = new ArrayList<SelectItem>(); |
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
|
107 } |
1 | 108 |
109 /* | |
110 public void listenerChangePersonCopyingText(ValueChangeEvent event) { | |
111 this.personCopyingText = changeListener(event, personCopyingText, PERSON, name_translit); | |
112 } | |
113 | |
114 public void listenerChangePersonCopiedFor(ValueChangeEvent event) { | |
115 this.personCopiedFor = changeListener(event, personCopiedFor, PERSON, name_translit); | |
116 } | |
117 | |
118 public void listenerChangePlace(ValueChangeEvent event) { | |
119 this.place = changeListener(event, place, PLACE, name); | |
120 } | |
121 | |
122 public void listenerChangeRepository(ValueChangeEvent event) { | |
123 this.repository = changeListener(event, repository, REPOSITORY, name); | |
124 }*/ | |
125 | |
126 public void listenerSave(ActionEvent event) { | |
127 this.save(); | |
128 } | |
129 | |
130 @Override | |
131 public String save(){ | |
132 super.save(); | |
133 if(!checkConsistency()){ | |
134 addGeneralMsg("Either the Witness, the Person or the Place is empty."); | |
135 addGeneralMsg("The event could not be saved."); | |
136 return null; | |
137 } | |
138 | |
139 try{ | |
140 getAttributes().put("date", this.date.toJSONString()); | |
141 event = updateEntityAttributes(event); | |
142 | |
143 // EVENT -> was_copied_for -> PERSON | |
144 event.replaceSourceRelation(personCopiedForLo.entity, PERSON, was_copied_for); | |
145 | |
146 // EVENT -> has_person_copying_text -> PERSON | |
147 event.replaceSourceRelation(personCopyingTextLo.entity, PERSON, has_person_copying_text); | |
148 | |
149 // EVENT -> was_copied_in -> 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
|
150 replaceAliasSourceRelation(event, placeLo, PLACE, was_copied_in, was_copied_in_as); |
1 | 151 |
152 // EVENT -> is_a_copy_of -> WITNESS | |
153 if(witness.isLightweight()){ | |
154 this.witness = getWrapper().getEntityByIdWithContent(witness.getId()); | |
155 } | |
156 event.replaceSourceRelation(witness, WITNESS, is_a_copy_of); | |
157 | |
158 getWrapper().saveEntity(event, getSessionUserName()); | |
159 | |
160 printSuccessSavingEntity(); | |
161 | |
162 }catch (Exception e) { | |
163 addGeneralMsg(e.getMessage()); | |
164 logger.error(e.getMessage(), e); | |
165 } | |
166 saveEnd(); | |
167 return null; | |
168 } | |
169 | |
170 public boolean checkConsistency(){ | |
171 if(this.witness == null || | |
172 this.textLo.entity == null || | |
173 this.personCopiedForLo.entity == null || | |
174 this.personCopyingTextLo.entity == null){ | |
175 return false; | |
176 } | |
177 return true; | |
178 } | |
179 | |
180 public CopyEvent(Entity event) { | |
181 super(event); | |
182 } | |
183 | |
184 public CopyEvent(){ | |
185 super(new Entity(Node.TYPE_ABOX, OC, false)); | |
186 } | |
187 | |
188 public ListenerObject getPersonCopiedForLo() { | |
189 return personCopiedForLo; | |
190 } | |
191 | |
192 public void setPersonCopiedForLo(ListenerObject personCopiedForLo) { | |
193 this.personCopiedForLo = personCopiedForLo; | |
194 } | |
195 | |
196 public ListenerObject getPersonCopyingTextLo() { | |
197 return personCopyingTextLo; | |
198 } | |
199 | |
200 public void setPersonCopyingTextLo(ListenerObject personCopyingTextLo) { | |
201 this.personCopyingTextLo = personCopyingTextLo; | |
202 } | |
203 | |
204 public Calendar getDate() { | |
205 return date; | |
206 } | |
207 | |
208 public void setDate(Calendar date) { | |
209 this.date = date; | |
210 } | |
211 } |