Mercurial > hg > ismi-richfaces
diff 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 |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/event/beans/TransferEvent.java Mon Nov 04 15:45:56 2019 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/event/beans/TransferEvent.java Tue Dec 03 19:08:31 2019 +0100 @@ -15,6 +15,7 @@ import de.mpiwg.itgroup.ismi.auxObjects.AliasListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; import de.mpiwg.itgroup.ismi.auxObjects.lo.EventTextLO; +import de.mpiwg.itgroup.ismi.entry.beans.CodexEditorTemplate; import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; public class TransferEvent extends AbstractEvent implements Serializable{ @@ -32,6 +33,8 @@ private AliasListenerObject placeNewLocationLo; private List<SelectItem> suggestedTransferOptions = new ArrayList<SelectItem>(); + + private CodexEditorTemplate codexEditor; public TransferEvent(Entity event) { super(event); @@ -45,6 +48,7 @@ @Override public void setEvent(Entity ev){ + if (codexEditor == null) codexEditor = new CodexEditorTemplate(); reset(); event = ev; if(event != null && event.isPersistent()){ @@ -76,14 +80,17 @@ // EVENT -> has_new_location_as -> ALIAS placeNewLocationLo.setEntityAndAttribute(target); } else if (rel.getOwnValue().equals(is_a_transfer_of)) { - // EVENT study_of WITNESS - // WITNESS is_exemplar_of TEXT - this.witness = target; + // EVENT is_a_transfer_of CODEX + Entity codex = target; + if (codex != null && codex.isPersistent()) { + setCodex(codex); + } + /*this.witness = target; if (witness != null && witness.isPersistent()) { witnessId = witness.getId(); this.textLo.setEntityAndAttribute(getTextOfWitness(witness)); refreshWitnesses(textLo.entity); - } + } */ } else if (rel.getOwnValue().equals(was_transferred_in)) { this.placeLo.setEntityAndAttributeIfEmpty(target); } else if (rel.getOwnValue().equals(was_transferred_in_as)) { @@ -96,6 +103,7 @@ @Override public void reset(){ super.reset(); + if (codexEditor != null) codexEditor.reset(); this.defObjectClass = OC; if (personFromLo != null) { @@ -130,6 +138,18 @@ } + public void setCodex(Entity codex){ + this.codexEditor.getCodexLo().setEntityAndAttributeName(codex, "identifier"); + + if(this.codexEditor.getCodexLo().entity != null && this.codexEditor.getCodexLo().entity.isPersistent()){ + + List<Entity> list = getWrapper().getTargetsForSourceRelation(codex, is_part_of, COLLECTION, 1); + if(list.size() > 0){ + this.codexEditor.setCollection(list.get(0)); + } + } + } + public void listenerRefreshTransferOptions(ActionEvent event){ this.refreshTransferOptions(); } @@ -162,11 +182,12 @@ getAttributes().put("date", this.date.toJSONString()); event = updateEntityAttributes(event); - // EVENT -> was_studied_by -> WITNESS - if (witness.isLightweight()) { - this.witness = getWrapper().getEntityByIdWithContent(witness.getId()); + // EVENT -> is_a_transfer_of -> CODEX + Entity codex = codexEditor.getCodexLo().getEntity(); + if (codex.isLightweight()) { + codex = getWrapper().getEntityByIdWithContent(codex.getId()); } - event.replaceUniqueSourceRelation(witness, WITNESS, is_a_transfer_of); + event.replaceUniqueSourceRelation(codex, CODEX, is_a_transfer_of); // EVENT -> was_transferred_from -> PERSON event.replaceUniqueSourceRelation(personFromLo.entity, PERSON, was_transferred_from); @@ -197,7 +218,7 @@ public boolean checkConsistency(){ //TODO - if(this.witness == null || this.textLo.entity == null ){ + if (codexEditor.getCodexLo().getEntity() == null) { return false; } return true; @@ -246,4 +267,12 @@ this.placeNewLocationLo = placeNewLocationLo; } + public CodexEditorTemplate getCodexEditor() { + return codexEditor; + } + + public void setCodexEditor(CodexEditorTemplate codexEditor) { + this.codexEditor = codexEditor; + } + }