Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentPersonBean.java @ 125:eee2e0ca4032
updated entry beans to use EditIntents.
author | casties |
---|---|
date | Tue, 31 Jan 2017 18:09:54 +0100 |
parents | 28a0c2726466 |
children | 29d40186dfd7 |
rev | line source |
---|---|
1 | 1 package de.mpiwg.itgroup.ismi.entry.beans; |
2 | |
3 import java.io.Serializable; | |
4 import java.util.HashMap; | |
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
|
5 import java.util.List; |
1 | 6 import java.util.Map; |
7 | |
8 import javax.faces.convert.Converter; | |
9 import javax.faces.event.ActionEvent; | |
10 import javax.faces.event.AjaxBehaviorEvent; | |
11 import javax.faces.event.ValueChangeEvent; | |
12 | |
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; | |
124
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
18 import org.mpi.openmind.repository.services.utils.EditIntent; |
1 | 19 import org.mpi.openmind.repository.utils.RomanizationLoC; |
20 import org.mpi.openmind.repository.utils.TransliterationUtil; | |
21 | |
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
|
22 import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; |
1 | 23 /* rich |
24 import com.icesoft.faces.async.render.SessionRenderer; | |
25 import com.icesoft.faces.component.ext.HtmlCommandButton; | |
26 import com.icesoft.faces.component.ext.HtmlInputHidden; | |
27 */ | |
28 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; | |
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
|
29 import de.mpiwg.itgroup.ismi.util.guiComponents.AliasEntityList; |
1 | 30 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; |
31 import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList; | |
32 | |
33 public class CurrentPersonBean extends AbstractISMIBean implements Serializable{ | |
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
|
34 private static final long serialVersionUID = -3366510497089165294L; |
1 | 35 |
36 private static Logger logger = Logger.getLogger(CurrentPersonBean.class); | |
37 | |
38 //private Entity person; | |
39 private String newAlias; | |
40 | |
41 private String romanizedNameTranslit; | |
42 | |
43 public static String birth_date = "birth_date"; | |
44 public static String death_date = "death_date"; | |
45 | |
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
|
46 private AliasListenerObject birthPlaceLo = 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
|
47 private AliasListenerObject deathPlaceLo = new AliasListenerObject(PLACE, name, "is_alias_name_of"); |
1 | 48 |
49 private String valueShortName; | |
50 private Entity shortNameAlias; // is now an alias of type "prime" | |
51 | |
52 private transient Calendar calBirthDate; | |
53 private transient Calendar calDeathDate; | |
54 | |
55 private Map<String, Boolean> deletedAliases = new HashMap<String, Boolean>(); | |
56 | |
57 private EntityList livedInPlaces; | |
58 private EntityList aliasList; | |
59 private EntityList roleList; | |
60 private EntityList studentOfList; | |
61 private EntityList floruitList; | |
124
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
62 |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
63 /** intent to edit all attributes and relations in the form */ |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
64 public static EditIntent editPersonIntent = new EditIntent( |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
65 PERSON, |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
66 // attributes |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
67 new String[]{"name", "name_translit", "birth_date", "birth_date_text", "death_date", "death_date_text", |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
68 "url", "authority_id", "notes", "notes_old"}, |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
69 // source relations |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
70 new String[]{"was_born_in", "was_born_in_as", "died_in", "died_in_as", "lived_in", "lived_in_as", |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
71 "was_student_of", "has_floruit_date", "has_role"}, |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
72 // target relations |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
73 new String[]{"is_prime_alias_name_of", "is_alias_name_of", "is_reference_of"}); |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
74 |
1 | 75 |
76 @Override | |
77 public void reset(){ | |
78 super.reset(); | |
79 this.entity = new Entity(Node.TYPE_ABOX, PERSON, false); | |
80 | |
81 this.newAlias = new String(); | |
82 | |
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
|
83 this.livedInPlaces = new AliasEntityList(PLACE, name, "is_alias_name_of", true); |
1 | 84 this.aliasList = new EntityList(ALIAS, "alias", getWrapper(), getUserName()); |
85 this.roleList = new EntityList(ROLE, "name", getWrapper(), getUserName()); | |
86 this.studentOfList = new EntityList(PERSON, "name_translit", "Student of"); | |
87 this.floruitList = new EntityList(FLORUIT_DATE, "date", getWrapper(), getUserName(), true); | |
88 | |
89 this.valueShortName = ""; | |
90 this.shortNameAlias = null; | |
91 | |
92 this.birthPlaceLo.reset(); | |
93 | |
94 this.deathPlaceLo.reset(); | |
95 | |
96 this.deletedAliases = new HashMap<String, Boolean>(); | |
97 | |
98 this.calBirthDate = new Calendar(); | |
99 this.calDeathDate = new Calendar(); | |
100 | |
101 } | |
102 | |
103 public EntityList getRoleList() { | |
104 return roleList; | |
105 } | |
106 | |
107 public void setRoleList(EntityList roleList) { | |
108 this.roleList = roleList; | |
109 } | |
110 | |
111 public EntityList getAliasList() { | |
112 return aliasList; | |
113 } | |
114 | |
115 public void setAliasList(EntityList aliasList) { | |
116 this.aliasList = aliasList; | |
117 } | |
118 | |
119 public CurrentPersonBean() { | |
120 this.reset(); | |
121 setDefObjectClass(PERSON); | |
122 registerChecker(birthPlaceLo, "Birth place not valid!"); | |
123 registerChecker(deathPlaceLo, "Death place not valid!"); | |
124 } | |
125 | |
126 /** | |
127 * | |
128 * @param event | |
129 */ | |
130 public void shortNameChangeListener(ValueChangeEvent event) { | |
131 try { | |
132 if (event.getNewValue() == null) { | |
133 return; | |
134 } | |
135 if (event.getNewValue().equals(event.getOldValue())) { | |
136 return; | |
137 } | |
138 | |
139 String newShortName = (String) event.getNewValue(); | |
140 | |
141 if (shortNameAlias == null) { | |
142 shortNameAlias = new Entity(org.mpi.openmind.repository.bo.Node.TYPE_ABOX, ALIAS, false); | |
143 | |
144 } | |
145 | |
146 Attribute attr = this.shortNameAlias.getAttributeByName(alias); | |
147 if (attr == null) { | |
148 this.shortNameAlias.addAttribute(new Attribute(alias, TEXT, | |
149 newShortName)); | |
150 } else | |
151 attr.setValue(newShortName); | |
152 | |
153 } catch (Exception e) { | |
154 e.printStackTrace(); | |
155 } | |
156 } | |
157 | |
158 public String translitNameAction() { | |
159 String pn = getAttributes().get(name); | |
160 | |
161 String translit = TransliterationUtil.getTransliteration(pn); | |
162 this.getAttributes().put(name_translit, translit); | |
163 | |
164 return PAGE_EDITOR; | |
165 } | |
166 | |
167 public Calendar getCalBirthDate() { | |
168 return calBirthDate; | |
169 } | |
170 | |
171 public void setCalBirthDate(Calendar calBirthDate) { | |
172 this.calBirthDate = calBirthDate; | |
173 } | |
174 | |
175 public Calendar getCalDeathDate() { | |
176 return calDeathDate; | |
177 } | |
178 | |
179 public void setCalDeathDate(Calendar calDeathDate) { | |
180 this.calDeathDate = calDeathDate; | |
181 } | |
182 | |
183 @Override | |
184 public void setEntity(Entity person) { | |
185 this.reset(); | |
186 | |
187 this.entity = person; | |
188 | |
189 if(this.entity != null && this.entity.isPersistent()){ | |
190 if (this.entity.isLightweight()) { | |
191 this.entity = this.getWrapper().getEntityContent(person); | |
192 } | |
193 | |
194 this.calDeathDate = updateCalendar(this.entity.getAttributeByName(death_date)); | |
195 this.calBirthDate = updateCalendar(this.entity.getAttributeByName(birth_date)); | |
196 | |
197 this.setCurrentId(this.entity.getId().toString()); | |
198 this.loadAttributes(this.entity); | |
199 | |
200 for (Relation rel : this.entity.getSourceRelations()) { | |
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
|
201 String relName = rel.getOwnValue(); |
1 | 202 Entity target = getWrapper().getEntityById(rel.getTargetId()); |
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
|
203 if (relName.equals("was_born_in")) { |
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
|
204 this.birthPlaceLo.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
|
205 } else if (relName.equals("was_born_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
|
206 this.birthPlaceLo.setEntityAndAttribute(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
|
207 } else if (relName.equals("died_in")) { |
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
|
208 this.deathPlaceLo.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
|
209 } else if (relName.equals("died_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
|
210 this.deathPlaceLo.setEntityAndAttribute(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
|
211 } else if (relName.equals(lived_in)) { |
1 | 212 this.livedInPlaces.add(target, rel.getAttributeByName("date")); |
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
|
213 } else if (relName.equals(lived_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
|
214 this.livedInPlaces.add(target, rel.getAttributeByName("date")); |
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
|
215 } else if (relName.equals(was_student_of)) { |
1 | 216 this.studentOfList.add(target); |
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
|
217 } else if (relName.equals(has_role)) { |
1 | 218 this.roleList.add(target); |
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
|
219 } else if (relName.equals("has_floruit_date")) { |
1 | 220 Attribute calAtt = getWrapper().getAttributeByName(target.getId(), "date"); |
221 this.floruitList.add(target, calAtt); | |
222 } | |
223 } | |
224 | |
225 for (Relation rel : this.entity.getTargetRelations()) { | |
226 if (rel.getOwnValue().equals("was_created_by") && rel.getSourceObjectClass().equals(TEXT)) { | |
227 //Entity title = getWrapper().getEntityById(rel.getSourceId()); | |
228 } else if (rel.getOwnValue().equals("is_alias_name_of")) { | |
229 Entity alias = getWrapper().getEntityById(rel.getSourceId()); | |
230 this.aliasList.add(alias); | |
231 } else if (rel.getOwnValue().equals("is_prime_alias_name_of")) { | |
232 Entity alias = getWrapper().getEntityByIdWithContent(rel.getSourceId()); | |
233 this.shortNameAlias = alias; | |
234 this.valueShortName = alias.getAttributeByName("alias").getValue(); | |
235 } | |
236 } | |
237 | |
238 //this.loadReferences(this.entity); | |
239 this.loadEndNoteRefs(); | |
240 this.displayUrl = generateDisplayUrl(person, null, null, getAppBean().getRoot()); | |
241 | |
242 } | |
243 } | |
244 | |
245 /** | |
246 * Saves the current Person. TODO save the target's relations. | |
247 * | |
248 * @return | |
249 */ | |
250 @Override | |
251 public String save() { | |
252 super.save(); | |
253 try { | |
254 | |
255 long start = System.currentTimeMillis(); | |
256 | |
257 CheckResults cr = getCheckResults(); | |
258 if (cr.hasErrors){ | |
259 getSessionBean().setErrorMessages(cr); | |
260 getSessionBean().setDisplayError(true); | |
261 return "SAVE_ERROR"; | |
262 } | |
263 | |
264 getAttributes().put(birth_date, this.calBirthDate.toJSONString()); | |
265 getAttributes().put(death_date, this.calDeathDate.toJSONString()); | |
266 | |
267 this.entity = updateEntityAttributes(this.entity); | |
268 | |
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
|
269 // PERSON -> was_born_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
|
270 replaceAliasSourceRelation(this.entity, birthPlaceLo, PLACE, "was_born_in", "was_born_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
|
271 |
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
|
272 // PERSON -> was_died_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
|
273 replaceAliasSourceRelation(this.entity, deathPlaceLo, PLACE, "died_in", "died_in_as"); |
1 | 274 |
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
|
275 // ALIAS -> is_prime_alias_name_of -> PERSON |
1 | 276 this.entity.removeAllTargetRelationsByName(is_prime_alias_name_of); |
277 if (shortNameAlias != null) { | |
278 shortNameAlias.setObjectClass(ALIAS); | |
124
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
279 shortNameAlias = getWrapper().saveEntity(shortNameAlias, getSessionUser().getEmail(), null); |
107 | 280 new Relation(shortNameAlias, this.entity, is_alias_name_of); |
1 | 281 } |
282 | |
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
|
283 // ALIAS -> is_alias_name_of -> PERSON |
1 | 284 this.entity.removeAllTargetRelationsByName(is_alias_name_of); |
285 for(Entity alias : this.aliasList.getEntities()){ | |
286 Entity alias0 = getWrapper().getEntityByIdWithContent(alias.getId()); | |
107 | 287 new Relation(alias0, this.entity, is_alias_name_of); |
1 | 288 } |
289 | |
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
|
290 // PERSON -> lived_in -> PLACE (manyToMany) |
1 | 291 this.entity.removeAllSourceRelationsByName(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
|
292 this.entity.removeAllSourceRelationsByName(lived_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
|
293 for(Entity place : this.livedInPlaces.getEntities()) { |
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
|
294 Entity placeEnt = getWrapper().getEntityByIdWithContent(place.getId()); |
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 if (placeEnt.getObjectClass().equals(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
|
296 // PERSON -> lived_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
|
297 Relation livedIn = new Relation(this.entity, placeEnt, lived_in); |
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
|
298 Calendar cal = livedInPlaces.getCalendar(place.getId()); |
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
|
299 if(cal != 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
|
300 livedIn.addAttribute(new Attribute("date", "date", cal.toJSONString())); |
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
|
301 } |
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
|
302 } else if (placeEnt.getObjectClass().equals(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
|
303 // PERSON -> lived_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
|
304 Relation livedInAs = new Relation(this.entity, placeEnt, lived_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
|
305 Calendar cal = livedInPlaces.getCalendar(place.getId()); |
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
|
306 if (cal != 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
|
307 livedInAs.addAttribute(new Attribute("date", "date", cal.toJSONString())); |
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
|
308 } |
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
|
309 // 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
|
310 List<Entity> places = getWrapper().getTargetsForSourceRelation(placeEnt, is_alias_name_of, PLACE, 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
|
311 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
|
312 // PERSON -> lived_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
|
313 Entity realPlace = places.get(0); |
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
|
314 Relation livedIn = new Relation(this.entity, realPlace, lived_in); |
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
|
315 if (cal != 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
|
316 livedIn.addAttribute(new Attribute("date", "date", cal.toJSONString())); |
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
|
317 } |
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
|
318 } |
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
|
319 } |
1 | 320 } |
321 | |
322 // Person -> has_floruit_date -> FLORUIT DATE | |
323 this.entity.removeAllSourceRelationsByName(has_floruit_date); | |
324 for(Entity floruitDate : this.floruitList.getEntities()){ | |
325 Entity floruitDate0 = getWrapper().getEntityByIdWithContent(floruitDate.getId()); | |
326 Calendar cal = floruitList.getCalendar(floruitDate.getId()); | |
327 | |
328 if(floruitDate0.getAttributeByName("date") == null){ | |
329 floruitDate0.addAttribute(new Attribute("date", "date", cal.toJSONString())); | |
330 }else{ | |
331 floruitDate0.getAttributeByName("date").setValue(cal.toJSONString()); | |
332 } | |
333 getWrapper().saveAssertion(floruitDate0, getUserName()); | |
107 | 334 new Relation(this.entity, floruitDate0, has_floruit_date); |
1 | 335 } |
336 | |
337 //PERSON -> student of manyToMany -> PERSON | |
338 this.entity.removeAllSourceRelationsByName(was_student_of); | |
339 for(Entity teacher : this.studentOfList.getEntities()){ | |
340 Entity teacher0 = getWrapper().getEntityByIdWithContent(teacher.getId()); | |
107 | 341 new Relation(this.entity, teacher0, was_student_of); |
1 | 342 } |
343 | |
344 //PERSON -> has_role -> ROLE | |
345 this.entity.removeAllSourceRelationsByName(has_role); | |
346 for(Entity role : this.roleList.getEntities()){ | |
347 Entity role0 = getWrapper().getEntityByIdWithContent(role.getId()); | |
107 | 348 new Relation(this.entity, role0, has_role); |
1 | 349 } |
350 | |
351 //REFERENCE -> is_reference_of -> THIS | |
352 this.prepareEndNoteRefs2Save(); | |
353 | |
124
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
354 // save entity |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
355 this.entity = getWrapper().saveEntity(this.entity, getSessionUser().getEmail(), editPersonIntent); |
1 | 356 this.setEntity(this.entity); |
357 this.getCache().setMapDirty(true); | |
358 this.getAppBean().getBiographyBean().makeDirty(); | |
359 | |
360 logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity); | |
361 this.printSuccessSavingEntity(); | |
362 | |
363 } catch (Exception e) { | |
364 logger.error(e.getMessage(), e); | |
365 e.printStackTrace(); | |
366 this.printInternalError(e); | |
367 } | |
368 saveEnd(); | |
369 return PAGE_EDITOR; | |
370 } | |
371 | |
372 public void listenerEditCalendarForLivedInPlaces(ActionEvent event){ | |
373 Entity entity = (Entity)getRequestBean("item"); | |
374 if(entity != null){ | |
375 Calendar cal = this.livedInPlaces.getCalendar(entity.getId()); | |
376 getSessionBean().editCalendar(cal, livedInPlaces, entity.getId()); | |
377 } | |
378 } | |
379 | |
380 public void listenerEditCalendarForFloruitDate(ActionEvent event){ | |
381 Entity entity = (Entity)getRequestBean("item"); | |
382 if(entity != null){ | |
383 Calendar cal = this.floruitList.getCalendar(entity.getId()); | |
384 getSessionBean().editCalendar(cal, floruitList, entity.getId()); | |
385 } | |
386 } | |
387 | |
388 public void listenerRomanizeNameTranslit(AjaxBehaviorEvent event){ | |
389 if(getAttributes().get("name_translit") != null) | |
390 this.romanizedNameTranslit = RomanizationLoC.convert(getAttributes().get("name_translit")); | |
391 } | |
392 | |
393 public Entity getShortName() { | |
394 return shortNameAlias; | |
395 } | |
396 | |
397 public void setShortName(Entity shortName) { | |
398 this.shortNameAlias = shortName; | |
399 } | |
400 | |
401 public String getValueShortName() { | |
402 return valueShortName; | |
403 } | |
404 | |
405 public void setValueShortName(String valueShortName) { | |
406 this.valueShortName = valueShortName; | |
407 } | |
408 | |
409 public void setToDate(Object x) { | |
119 | 410 //System.out.println("hello"); |
1 | 411 } |
412 | |
413 public Converter getToDate() { | |
414 return new myDateTimeConverter(); | |
415 | |
416 } | |
417 | |
418 public Map<String, Boolean> getDeletedAliases() { | |
419 return deletedAliases; | |
420 } | |
421 | |
422 public void setDeletedAliases(Map<String, Boolean> deletedAliases) { | |
423 this.deletedAliases = deletedAliases; | |
424 } | |
425 | |
426 public void setNewAlias(String newAlias) { | |
427 this.newAlias = newAlias; | |
428 } | |
429 | |
430 public String getNewAlias() { | |
431 return newAlias; | |
432 } | |
433 | |
434 public String editMe(){ | |
435 if(this.entity != null){ | |
436 getSessionBean().editEntity(this.entity); | |
437 return "entry_edit_entity"; | |
438 } | |
439 return ""; | |
440 } | |
441 | |
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
|
442 public void setBirthPlaceLo(AliasListenerObject birthPlaceLo) { |
1 | 443 this.birthPlaceLo = birthPlaceLo; |
444 } | |
445 | |
446 public ListenerObject getBirthPlaceLo() { | |
447 return birthPlaceLo; | |
448 } | |
449 | |
450 public ListenerObject getDeathPlaceLo() { | |
451 return deathPlaceLo; | |
452 } | |
453 | |
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
|
454 public void setDeathPlaceLo(AliasListenerObject deathPlaceLo) { |
1 | 455 this.deathPlaceLo = deathPlaceLo; |
456 } | |
457 | |
458 public EntityList getLivedInPlaces() { | |
459 return livedInPlaces; | |
460 } | |
461 | |
462 public void setLivedInPlaces(EntityList livedInPlaces) { | |
463 this.livedInPlaces = livedInPlaces; | |
464 } | |
465 | |
466 public EntityList getStudentOfList() { | |
467 return studentOfList; | |
468 } | |
469 | |
470 | |
471 public void setStudentOfList(EntityList studentOfList) { | |
472 this.studentOfList = studentOfList; | |
473 } | |
474 | |
475 public EntityList getFloruitList() { | |
476 return floruitList; | |
477 } | |
478 | |
479 public void setFloruitList(EntityList floruitList) { | |
480 this.floruitList = floruitList; | |
481 } | |
482 | |
483 public String getRomanizedNameTranslit() { | |
484 return romanizedNameTranslit; | |
485 } | |
486 | |
487 public void setRomanizedNameTranslit(String romanizedNameTranslit) { | |
488 this.romanizedNameTranslit = romanizedNameTranslit; | |
489 } | |
490 } |