Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentPersonBean.java @ 133:5ccd6e709f95
fix attribute name in EditIntent.
author | casties |
---|---|
date | Thu, 23 Feb 2017 19:25:37 +0100 |
parents | efeab3bd856f |
children | 25bfcc9d757c |
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) { | |
126 | 142 shortNameAlias = new Entity(Node.TYPE_ABOX, ALIAS, false); |
1 | 143 } |
144 | |
126 | 145 Attribute attr = shortNameAlias.getAttributeByName(alias); |
1 | 146 if (attr == null) { |
126 | 147 shortNameAlias.addAttribute(new Attribute(alias, TEXT, newShortName)); |
148 } else { | |
1 | 149 attr.setValue(newShortName); |
126 | 150 } |
1 | 151 } catch (Exception e) { |
126 | 152 logger.error(e); |
1 | 153 } |
154 } | |
155 | |
156 public String translitNameAction() { | |
157 String pn = getAttributes().get(name); | |
158 | |
159 String translit = TransliterationUtil.getTransliteration(pn); | |
160 this.getAttributes().put(name_translit, translit); | |
161 | |
162 return PAGE_EDITOR; | |
163 } | |
164 | |
165 public Calendar getCalBirthDate() { | |
166 return calBirthDate; | |
167 } | |
168 | |
169 public void setCalBirthDate(Calendar calBirthDate) { | |
170 this.calBirthDate = calBirthDate; | |
171 } | |
172 | |
173 public Calendar getCalDeathDate() { | |
174 return calDeathDate; | |
175 } | |
176 | |
177 public void setCalDeathDate(Calendar calDeathDate) { | |
178 this.calDeathDate = calDeathDate; | |
179 } | |
180 | |
181 @Override | |
182 public void setEntity(Entity person) { | |
183 this.reset(); | |
184 | |
185 this.entity = person; | |
186 | |
187 if(this.entity != null && this.entity.isPersistent()){ | |
188 if (this.entity.isLightweight()) { | |
189 this.entity = this.getWrapper().getEntityContent(person); | |
190 } | |
191 | |
192 this.calDeathDate = updateCalendar(this.entity.getAttributeByName(death_date)); | |
193 this.calBirthDate = updateCalendar(this.entity.getAttributeByName(birth_date)); | |
194 | |
195 this.setCurrentId(this.entity.getId().toString()); | |
196 this.loadAttributes(this.entity); | |
197 | |
198 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
|
199 String relName = rel.getOwnValue(); |
1 | 200 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
|
201 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
|
202 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
|
203 } 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
|
204 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
|
205 } 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
|
206 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
|
207 } 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
|
208 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
|
209 } else if (relName.equals(lived_in)) { |
1 | 210 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
|
211 } 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
|
212 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
|
213 } else if (relName.equals(was_student_of)) { |
1 | 214 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
|
215 } else if (relName.equals(has_role)) { |
1 | 216 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
|
217 } else if (relName.equals("has_floruit_date")) { |
1 | 218 Attribute calAtt = getWrapper().getAttributeByName(target.getId(), "date"); |
219 this.floruitList.add(target, calAtt); | |
220 } | |
221 } | |
222 | |
223 for (Relation rel : this.entity.getTargetRelations()) { | |
224 if (rel.getOwnValue().equals("was_created_by") && rel.getSourceObjectClass().equals(TEXT)) { | |
225 //Entity title = getWrapper().getEntityById(rel.getSourceId()); | |
226 } else if (rel.getOwnValue().equals("is_alias_name_of")) { | |
227 Entity alias = getWrapper().getEntityById(rel.getSourceId()); | |
228 this.aliasList.add(alias); | |
229 } else if (rel.getOwnValue().equals("is_prime_alias_name_of")) { | |
230 Entity alias = getWrapper().getEntityByIdWithContent(rel.getSourceId()); | |
231 this.shortNameAlias = alias; | |
232 this.valueShortName = alias.getAttributeByName("alias").getValue(); | |
233 } | |
234 } | |
235 | |
236 //this.loadReferences(this.entity); | |
237 this.loadEndNoteRefs(); | |
238 this.displayUrl = generateDisplayUrl(person, null, null, getAppBean().getRoot()); | |
239 | |
240 } | |
241 } | |
242 | |
243 /** | |
244 * Saves the current Person. TODO save the target's relations. | |
245 * | |
246 * @return | |
247 */ | |
248 @Override | |
249 public String save() { | |
250 super.save(); | |
251 try { | |
252 | |
253 long start = System.currentTimeMillis(); | |
254 | |
255 CheckResults cr = getCheckResults(); | |
256 if (cr.hasErrors){ | |
257 getSessionBean().setErrorMessages(cr); | |
258 getSessionBean().setDisplayError(true); | |
259 return "SAVE_ERROR"; | |
260 } | |
261 | |
262 getAttributes().put(birth_date, this.calBirthDate.toJSONString()); | |
263 getAttributes().put(death_date, this.calDeathDate.toJSONString()); | |
264 | |
265 this.entity = updateEntityAttributes(this.entity); | |
266 | |
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
|
267 // 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
|
268 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
|
269 |
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 // 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
|
271 replaceAliasSourceRelation(this.entity, deathPlaceLo, PLACE, "died_in", "died_in_as"); |
1 | 272 |
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
|
273 // ALIAS -> is_alias_name_of -> PERSON |
1 | 274 this.entity.removeAllTargetRelationsByName(is_alias_name_of); |
275 for(Entity alias : this.aliasList.getEntities()){ | |
276 Entity alias0 = getWrapper().getEntityByIdWithContent(alias.getId()); | |
107 | 277 new Relation(alias0, this.entity, is_alias_name_of); |
1 | 278 } |
279 | |
126 | 280 // ALIAS -> is_prime_alias_name_of/is_alias_name_of -> PERSON |
281 this.entity.removeAllTargetRelationsByName(is_prime_alias_name_of); | |
282 if (shortNameAlias != null) { | |
283 if (shortNameAlias.getAttributeByName(alias) == null) { | |
127 | 284 logger.error("ALIAS without Attribute! Trying to fix "+shortNameAlias); |
126 | 285 if (valueShortName != null) { |
286 shortNameAlias.addAttribute(new Attribute(alias, TEXT, valueShortName)); | |
287 } | |
288 } | |
289 shortNameAlias = getWrapper().saveEntity(shortNameAlias, getSessionUser().getEmail(), null); | |
290 // save as is_alias_name_of | |
291 new Relation(shortNameAlias, this.entity, is_alias_name_of); | |
292 } | |
293 | |
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
|
294 // PERSON -> lived_in -> PLACE (manyToMany) |
1 | 295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 // 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 } |
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 } 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
|
307 // 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
|
308 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
|
309 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
|
310 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
|
311 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
|
312 } |
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 // 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
|
314 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
|
315 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
|
316 // 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 } |
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
|
322 } |
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
|
323 } |
1 | 324 } |
325 | |
326 // Person -> has_floruit_date -> FLORUIT DATE | |
327 this.entity.removeAllSourceRelationsByName(has_floruit_date); | |
328 for(Entity floruitDate : this.floruitList.getEntities()){ | |
329 Entity floruitDate0 = getWrapper().getEntityByIdWithContent(floruitDate.getId()); | |
330 Calendar cal = floruitList.getCalendar(floruitDate.getId()); | |
331 | |
332 if(floruitDate0.getAttributeByName("date") == null){ | |
333 floruitDate0.addAttribute(new Attribute("date", "date", cal.toJSONString())); | |
334 }else{ | |
335 floruitDate0.getAttributeByName("date").setValue(cal.toJSONString()); | |
336 } | |
337 getWrapper().saveAssertion(floruitDate0, getUserName()); | |
107 | 338 new Relation(this.entity, floruitDate0, has_floruit_date); |
1 | 339 } |
340 | |
341 //PERSON -> student of manyToMany -> PERSON | |
342 this.entity.removeAllSourceRelationsByName(was_student_of); | |
343 for(Entity teacher : this.studentOfList.getEntities()){ | |
344 Entity teacher0 = getWrapper().getEntityByIdWithContent(teacher.getId()); | |
107 | 345 new Relation(this.entity, teacher0, was_student_of); |
1 | 346 } |
347 | |
348 //PERSON -> has_role -> ROLE | |
349 this.entity.removeAllSourceRelationsByName(has_role); | |
350 for(Entity role : this.roleList.getEntities()){ | |
351 Entity role0 = getWrapper().getEntityByIdWithContent(role.getId()); | |
107 | 352 new Relation(this.entity, role0, has_role); |
1 | 353 } |
354 | |
355 //REFERENCE -> is_reference_of -> THIS | |
356 this.prepareEndNoteRefs2Save(); | |
357 | |
124
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
358 // save entity |
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
119
diff
changeset
|
359 this.entity = getWrapper().saveEntity(this.entity, getSessionUser().getEmail(), editPersonIntent); |
1 | 360 this.setEntity(this.entity); |
361 this.getCache().setMapDirty(true); | |
362 this.getAppBean().getBiographyBean().makeDirty(); | |
363 | |
364 logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity); | |
365 this.printSuccessSavingEntity(); | |
366 | |
367 } catch (Exception e) { | |
368 logger.error(e.getMessage(), e); | |
369 e.printStackTrace(); | |
370 this.printInternalError(e); | |
371 } | |
372 saveEnd(); | |
373 return PAGE_EDITOR; | |
374 } | |
375 | |
376 public void listenerEditCalendarForLivedInPlaces(ActionEvent event){ | |
377 Entity entity = (Entity)getRequestBean("item"); | |
378 if(entity != null){ | |
379 Calendar cal = this.livedInPlaces.getCalendar(entity.getId()); | |
380 getSessionBean().editCalendar(cal, livedInPlaces, entity.getId()); | |
381 } | |
382 } | |
383 | |
384 public void listenerEditCalendarForFloruitDate(ActionEvent event){ | |
385 Entity entity = (Entity)getRequestBean("item"); | |
386 if(entity != null){ | |
387 Calendar cal = this.floruitList.getCalendar(entity.getId()); | |
388 getSessionBean().editCalendar(cal, floruitList, entity.getId()); | |
389 } | |
390 } | |
391 | |
392 public void listenerRomanizeNameTranslit(AjaxBehaviorEvent event){ | |
393 if(getAttributes().get("name_translit") != null) | |
394 this.romanizedNameTranslit = RomanizationLoC.convert(getAttributes().get("name_translit")); | |
395 } | |
396 | |
397 public Entity getShortName() { | |
398 return shortNameAlias; | |
399 } | |
400 | |
401 public void setShortName(Entity shortName) { | |
402 this.shortNameAlias = shortName; | |
403 } | |
404 | |
405 public String getValueShortName() { | |
406 return valueShortName; | |
407 } | |
408 | |
409 public void setValueShortName(String valueShortName) { | |
410 this.valueShortName = valueShortName; | |
411 } | |
412 | |
413 public void setToDate(Object x) { | |
119 | 414 //System.out.println("hello"); |
1 | 415 } |
416 | |
417 public Converter getToDate() { | |
418 return new myDateTimeConverter(); | |
419 | |
420 } | |
421 | |
422 public Map<String, Boolean> getDeletedAliases() { | |
423 return deletedAliases; | |
424 } | |
425 | |
426 public void setDeletedAliases(Map<String, Boolean> deletedAliases) { | |
427 this.deletedAliases = deletedAliases; | |
428 } | |
429 | |
430 public void setNewAlias(String newAlias) { | |
431 this.newAlias = newAlias; | |
432 } | |
433 | |
434 public String getNewAlias() { | |
435 return newAlias; | |
436 } | |
437 | |
438 public String editMe(){ | |
439 if(this.entity != null){ | |
440 getSessionBean().editEntity(this.entity); | |
441 return "entry_edit_entity"; | |
442 } | |
443 return ""; | |
444 } | |
445 | |
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
|
446 public void setBirthPlaceLo(AliasListenerObject birthPlaceLo) { |
1 | 447 this.birthPlaceLo = birthPlaceLo; |
448 } | |
449 | |
450 public ListenerObject getBirthPlaceLo() { | |
451 return birthPlaceLo; | |
452 } | |
453 | |
454 public ListenerObject getDeathPlaceLo() { | |
455 return deathPlaceLo; | |
456 } | |
457 | |
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
|
458 public void setDeathPlaceLo(AliasListenerObject deathPlaceLo) { |
1 | 459 this.deathPlaceLo = deathPlaceLo; |
460 } | |
461 | |
462 public EntityList getLivedInPlaces() { | |
463 return livedInPlaces; | |
464 } | |
465 | |
466 public void setLivedInPlaces(EntityList livedInPlaces) { | |
467 this.livedInPlaces = livedInPlaces; | |
468 } | |
469 | |
470 public EntityList getStudentOfList() { | |
471 return studentOfList; | |
472 } | |
473 | |
474 | |
475 public void setStudentOfList(EntityList studentOfList) { | |
476 this.studentOfList = studentOfList; | |
477 } | |
478 | |
479 public EntityList getFloruitList() { | |
480 return floruitList; | |
481 } | |
482 | |
483 public void setFloruitList(EntityList floruitList) { | |
484 this.floruitList = floruitList; | |
485 } | |
486 | |
487 public String getRomanizedNameTranslit() { | |
488 return romanizedNameTranslit; | |
489 } | |
490 | |
491 public void setRomanizedNameTranslit(String romanizedNameTranslit) { | |
492 this.romanizedNameTranslit = romanizedNameTranslit; | |
493 } | |
494 } |