Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/event/beans/CopyEvent.java @ 216:93d33f138c9e default tip
update medeniyet image server URL.
| author | casties |
|---|---|
| date | Wed, 26 Jan 2022 16:39:32 +0100 |
| parents | 25bfcc9d757c |
| children |
| 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 public void listenerSave(ActionEvent event) { | |
| 110 this.save(); | |
| 111 } | |
| 112 | |
| 113 @Override | |
| 114 public String save(){ | |
| 115 super.save(); | |
| 116 if(!checkConsistency()){ | |
| 117 addGeneralMsg("Either the Witness, the Person or the Place is empty."); | |
| 118 addGeneralMsg("The event could not be saved."); | |
| 119 return null; | |
| 120 } | |
| 121 | |
| 122 try{ | |
| 123 getAttributes().put("date", this.date.toJSONString()); | |
| 124 event = updateEntityAttributes(event); | |
| 125 | |
| 126 // EVENT -> was_copied_for -> PERSON | |
|
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
124
diff
changeset
|
127 event.replaceUniqueSourceRelation(personCopiedForLo.entity, PERSON, was_copied_for); |
| 1 | 128 |
| 129 // EVENT -> has_person_copying_text -> PERSON | |
|
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
124
diff
changeset
|
130 event.replaceUniqueSourceRelation(personCopyingTextLo.entity, PERSON, has_person_copying_text); |
| 1 | 131 |
| 132 // EVENT -> was_copied_in -> PLACE | |
|
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
124
diff
changeset
|
133 replaceUniqueAliasSourceRelation(event, placeLo, PLACE, was_copied_in, was_copied_in_as); |
| 1 | 134 |
| 135 // EVENT -> is_a_copy_of -> WITNESS | |
| 113 | 136 if (witness.isLightweight()) { |
| 137 this.witness = getWrapper().getEntityByIdWithContent(witness.getId()); | |
| 138 } | |
|
134
25bfcc9d757c
effort to re-use more relations when saving entities.
casties
parents:
124
diff
changeset
|
139 event.replaceUniqueSourceRelation(witness, WITNESS, is_a_copy_of); |
| 1 | 140 |
|
124
28a0c2726466
changed saveEntity() to use new EditIntent. Set up EditIntent for TEXT, PERSON, REFERENCE.
casties
parents:
113
diff
changeset
|
141 getWrapper().saveEntity(event, getSessionUserName(), null); |
| 1 | 142 |
| 143 printSuccessSavingEntity(); | |
| 144 | |
| 145 }catch (Exception e) { | |
| 146 addGeneralMsg(e.getMessage()); | |
| 147 logger.error(e.getMessage(), e); | |
| 148 } | |
| 149 saveEnd(); | |
| 150 return null; | |
| 151 } | |
| 152 | |
| 153 public boolean checkConsistency(){ | |
| 154 if(this.witness == null || | |
| 155 this.textLo.entity == null || | |
| 156 this.personCopiedForLo.entity == null || | |
| 157 this.personCopyingTextLo.entity == null){ | |
| 158 return false; | |
| 159 } | |
| 160 return true; | |
| 161 } | |
| 162 | |
| 163 public CopyEvent(Entity event) { | |
| 164 super(event); | |
| 165 } | |
| 166 | |
| 167 public CopyEvent(){ | |
| 168 super(new Entity(Node.TYPE_ABOX, OC, false)); | |
| 169 } | |
| 170 | |
| 171 public ListenerObject getPersonCopiedForLo() { | |
| 172 return personCopiedForLo; | |
| 173 } | |
| 174 | |
| 175 public void setPersonCopiedForLo(ListenerObject personCopiedForLo) { | |
| 176 this.personCopiedForLo = personCopiedForLo; | |
| 177 } | |
| 178 | |
| 179 public ListenerObject getPersonCopyingTextLo() { | |
| 180 return personCopyingTextLo; | |
| 181 } | |
| 182 | |
| 183 public void setPersonCopyingTextLo(ListenerObject personCopyingTextLo) { | |
| 184 this.personCopyingTextLo = personCopyingTextLo; | |
| 185 } | |
| 186 | |
| 187 public Calendar getDate() { | |
| 188 return date; | |
| 189 } | |
| 190 | |
| 191 public void setDate(Calendar date) { | |
| 192 this.date = date; | |
| 193 } | |
| 194 } |
