comparison src/main/java/de/mpiwg/itgroup/ismi/event/beans/TransferEvent.java @ 213:38c13c8e9b78

change transfer event from witness to codex.
author casties
date Tue, 03 Dec 2019 19:08:31 +0100
parents 25bfcc9d757c
children
comparison
equal deleted inserted replaced
212:310f512f66af 213:38c13c8e9b78
13 import org.mpi.openmind.repository.bo.Relation; 13 import org.mpi.openmind.repository.bo.Relation;
14 14
15 import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; 15 import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject;
16 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; 16 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject;
17 import de.mpiwg.itgroup.ismi.auxObjects.lo.EventTextLO; 17 import de.mpiwg.itgroup.ismi.auxObjects.lo.EventTextLO;
18 import de.mpiwg.itgroup.ismi.entry.beans.CodexEditorTemplate;
18 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; 19 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar;
19 20
20 public class TransferEvent extends AbstractEvent implements Serializable{ 21 public class TransferEvent extends AbstractEvent implements Serializable{
21 22
22 private static final long serialVersionUID = -3606229569295260209L; 23 private static final long serialVersionUID = -3606229569295260209L;
30 private AliasListenerObject placeOriginalLocationLo; 31 private AliasListenerObject placeOriginalLocationLo;
31 32
32 private AliasListenerObject placeNewLocationLo; 33 private AliasListenerObject placeNewLocationLo;
33 34
34 private List<SelectItem> suggestedTransferOptions = new ArrayList<SelectItem>(); 35 private List<SelectItem> suggestedTransferOptions = new ArrayList<SelectItem>();
36
37 private CodexEditorTemplate codexEditor;
35 38
36 public TransferEvent(Entity event) { 39 public TransferEvent(Entity event) {
37 super(event); 40 super(event);
38 this.refreshTransferOptions(); 41 this.refreshTransferOptions();
39 } 42 }
43 this.refreshTransferOptions(); 46 this.refreshTransferOptions();
44 } 47 }
45 48
46 @Override 49 @Override
47 public void setEvent(Entity ev){ 50 public void setEvent(Entity ev){
51 if (codexEditor == null) codexEditor = new CodexEditorTemplate();
48 reset(); 52 reset();
49 event = ev; 53 event = ev;
50 if(event != null && event.isPersistent()){ 54 if(event != null && event.isPersistent()){
51 if(event.isLightweight()){ 55 if(event.isLightweight()){
52 event = getWrapper().getEntityContent(event); 56 event = getWrapper().getEntityContent(event);
74 placeNewLocationLo.setEntityAndAttributeIfEmpty(target); 78 placeNewLocationLo.setEntityAndAttributeIfEmpty(target);
75 } else if (rel.getOwnValue().equals(has_new_location_as)) { 79 } else if (rel.getOwnValue().equals(has_new_location_as)) {
76 // EVENT -> has_new_location_as -> ALIAS 80 // EVENT -> has_new_location_as -> ALIAS
77 placeNewLocationLo.setEntityAndAttribute(target); 81 placeNewLocationLo.setEntityAndAttribute(target);
78 } else if (rel.getOwnValue().equals(is_a_transfer_of)) { 82 } else if (rel.getOwnValue().equals(is_a_transfer_of)) {
79 // EVENT study_of WITNESS 83 // EVENT is_a_transfer_of CODEX
80 // WITNESS is_exemplar_of TEXT 84 Entity codex = target;
81 this.witness = target; 85 if (codex != null && codex.isPersistent()) {
86 setCodex(codex);
87 }
88 /*this.witness = target;
82 if (witness != null && witness.isPersistent()) { 89 if (witness != null && witness.isPersistent()) {
83 witnessId = witness.getId(); 90 witnessId = witness.getId();
84 this.textLo.setEntityAndAttribute(getTextOfWitness(witness)); 91 this.textLo.setEntityAndAttribute(getTextOfWitness(witness));
85 refreshWitnesses(textLo.entity); 92 refreshWitnesses(textLo.entity);
86 } 93 } */
87 } else if (rel.getOwnValue().equals(was_transferred_in)) { 94 } else if (rel.getOwnValue().equals(was_transferred_in)) {
88 this.placeLo.setEntityAndAttributeIfEmpty(target); 95 this.placeLo.setEntityAndAttributeIfEmpty(target);
89 } else if (rel.getOwnValue().equals(was_transferred_in_as)) { 96 } else if (rel.getOwnValue().equals(was_transferred_in_as)) {
90 this.placeLo.setEntityAndAttribute(target); 97 this.placeLo.setEntityAndAttribute(target);
91 } 98 }
94 } 101 }
95 102
96 @Override 103 @Override
97 public void reset(){ 104 public void reset(){
98 super.reset(); 105 super.reset();
106 if (codexEditor != null) codexEditor.reset();
99 107
100 this.defObjectClass = OC; 108 this.defObjectClass = OC;
101 if (personFromLo != null) { 109 if (personFromLo != null) {
102 personFromLo.reset(); 110 personFromLo.reset();
103 } else { 111 } else {
127 135
128 this.placeNewLocationLo = new AliasListenerObject(PLACE, name, is_alias_name_of); 136 this.placeNewLocationLo = new AliasListenerObject(PLACE, name, is_alias_name_of);
129 this.placeOriginalLocationLo = new AliasListenerObject(PLACE, name, is_alias_name_of); 137 this.placeOriginalLocationLo = new AliasListenerObject(PLACE, name, is_alias_name_of);
130 } 138 }
131 139
140
141 public void setCodex(Entity codex){
142 this.codexEditor.getCodexLo().setEntityAndAttributeName(codex, "identifier");
143
144 if(this.codexEditor.getCodexLo().entity != null && this.codexEditor.getCodexLo().entity.isPersistent()){
145
146 List<Entity> list = getWrapper().getTargetsForSourceRelation(codex, is_part_of, COLLECTION, 1);
147 if(list.size() > 0){
148 this.codexEditor.setCollection(list.get(0));
149 }
150 }
151 }
132 152
133 public void listenerRefreshTransferOptions(ActionEvent event){ 153 public void listenerRefreshTransferOptions(ActionEvent event){
134 this.refreshTransferOptions(); 154 this.refreshTransferOptions();
135 } 155 }
136 156
160 180
161 try { 181 try {
162 getAttributes().put("date", this.date.toJSONString()); 182 getAttributes().put("date", this.date.toJSONString());
163 event = updateEntityAttributes(event); 183 event = updateEntityAttributes(event);
164 184
165 // EVENT -> was_studied_by -> WITNESS 185 // EVENT -> is_a_transfer_of -> CODEX
166 if (witness.isLightweight()) { 186 Entity codex = codexEditor.getCodexLo().getEntity();
167 this.witness = getWrapper().getEntityByIdWithContent(witness.getId()); 187 if (codex.isLightweight()) {
168 } 188 codex = getWrapper().getEntityByIdWithContent(codex.getId());
169 event.replaceUniqueSourceRelation(witness, WITNESS, is_a_transfer_of); 189 }
190 event.replaceUniqueSourceRelation(codex, CODEX, is_a_transfer_of);
170 191
171 // EVENT -> was_transferred_from -> PERSON 192 // EVENT -> was_transferred_from -> PERSON
172 event.replaceUniqueSourceRelation(personFromLo.entity, PERSON, was_transferred_from); 193 event.replaceUniqueSourceRelation(personFromLo.entity, PERSON, was_transferred_from);
173 194
174 // EVENT -> was_transferred_to -> PERSON 195 // EVENT -> was_transferred_to -> PERSON
195 return null; 216 return null;
196 } 217 }
197 218
198 public boolean checkConsistency(){ 219 public boolean checkConsistency(){
199 //TODO 220 //TODO
200 if(this.witness == null || this.textLo.entity == null ){ 221 if (codexEditor.getCodexLo().getEntity() == null) {
201 return false; 222 return false;
202 } 223 }
203 return true; 224 return true;
204 } 225 }
205 226
244 265
245 public void setPlaceNewLocationLo(AliasListenerObject placeNewLocationLo) { 266 public void setPlaceNewLocationLo(AliasListenerObject placeNewLocationLo) {
246 this.placeNewLocationLo = placeNewLocationLo; 267 this.placeNewLocationLo = placeNewLocationLo;
247 } 268 }
248 269
270 public CodexEditorTemplate getCodexEditor() {
271 return codexEditor;
272 }
273
274 public void setCodexEditor(CodexEditorTemplate codexEditor) {
275 this.codexEditor = codexEditor;
276 }
277
249 } 278 }