Mercurial > hg > ismi-richfaces
changeset 120:71638720fe2f
working on MISIDENTIFICATION for witnesses.
author | casties |
---|---|
date | Fri, 06 Jan 2017 20:41:35 +0100 |
parents | 4aa8c425685d |
children | 6f0e9a333c15 |
files | src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentWitnessBean.java src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/Misidentification.java src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/MisidentificationTable.java src/main/webapp/entry/components/misidentification.xhtml src/main/webapp/entry/text.xhtml src/main/webapp/entry/witness.xhtml src/main/webapp/search/displayTitle.xhtml |
diffstat | 7 files changed, 519 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentWitnessBean.java Fri Jan 06 16:59:37 2017 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentWitnessBean.java Fri Jan 06 20:41:35 2017 +0100 @@ -23,6 +23,8 @@ import de.mpiwg.itgroup.ismi.auxObjects.lo.WitnessTextLO; import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; import de.mpiwg.itgroup.ismi.util.guiComponents.EntityList; +import de.mpiwg.itgroup.ismi.util.guiComponents.Misidentification; +import de.mpiwg.itgroup.ismi.util.guiComponents.MisidentificationTable; import de.mpiwg.itgroup.ismi.util.guiComponents.StatusImage; public class CurrentWitnessBean extends CodexEditorTemplate implements Serializable{ @@ -94,6 +96,8 @@ private EntityList studiedByList; private EntityList possibleExamplerOfList; + + private MisidentificationTable misidentTable; public CurrentWitnessBean() { super(); @@ -171,6 +175,8 @@ //this.islamicCalCopyDate = new IslamicCalendar(); this.copyDate = new Calendar(); + + this.misidentTable = new MisidentificationTable(); } @Override @@ -228,6 +234,11 @@ this.entity.replaceSourceRelation(this.patronageLo.entity, PERSON, rel_had_patron); + /* + * save misattributions + */ + this.entity = this.misidentTable.saveMisidentifications(this.entity); + // WITNESS -> is_exemplar_of -> TEXT this.entity.replaceSourceRelation(this.titleLo.entity, TEXT, is_exemplar_of); @@ -258,7 +269,6 @@ this.setSelectedSaveAsNew(false); } catch (Exception e) { logger.error(e.getMessage(), e); - e.printStackTrace(); this.printInternalError(e); } @@ -290,7 +300,7 @@ alias = new Entity(Node.TYPE_ABOX, ALIAS, false); alias.addAttribute(new Attribute(ALIAS, "text", valueTextWritten)); alias = getWrapper().saveEntity(alias, user.getEmail()); - Relation rel = new Relation(alias, this.titleLo.getEntity(), "is_alias_title_of"); + new Relation(alias, this.titleLo.getEntity(), "is_alias_title_of"); alias = getWrapper().saveEntity(alias, user.getEmail()); } if(alias.isLightweight()){ @@ -319,7 +329,7 @@ alias = new Entity(Node.TYPE_ABOX, ALIAS, false); alias.addAttribute(new Attribute(ALIAS, "text", valueAuthorWritten)); alias = getWrapper().saveEntity(alias, user.getEmail()); - Relation rel = new Relation(alias, this.authorLo.getEntity(), "is_alias_name_of"); + new Relation(alias, this.authorLo.getEntity(), "is_alias_name_of"); alias = getWrapper().saveEntity(alias, user.getEmail()); } if(alias.isLightweight()){ @@ -453,48 +463,54 @@ // TODO loading target's relations for (Relation rel : witness.getSourceRelations()) { Entity target = null; - if (rel.getOwnValue().equals(is_exemplar_of)) { + String relName = rel.getOwnValue(); + if (relName.equals(is_exemplar_of)) { // WITNESS -> is_exemplar_of -> TEXT target = getTargetRelation(rel); titleLo.setEntityAndAttribute(target); this.updateTitle(); - } else if (rel.getOwnValue().equals(is_possible_exemplar_of)) { + } else if (relName.equals(is_possible_exemplar_of)) { // WITNESS -> is_possible_exemplar_of -> TEXT target = getTargetRelation(rel); possibleExamplerOfList.add(target); - } else if (rel.getOwnValue().equals(rel_was_studied_by)) { + } else if (relName.equals(rel_was_studied_by)) { target = getTargetRelation(rel); studiedByList.add(target); - } else if (rel.getOwnValue().equals(rel_was_copied_by)) { + } else if (relName.equals(rel_was_copied_by)) { // WITENSS -> was_copied_by -> PERSON target = getTargetRelation(rel); copyistLo.setEntityAndAttribute(target); - } else if (rel.getOwnValue().equals("was_copied_in")) { + } else if (relName.equals("was_copied_in")) { // WITENSS -> was_copied_in -> PLACE target = getTargetRelation(rel); // don't use place if there is an alias copyPlaceLo.setEntityAndAttributeIfEmpty(target); - } else if (rel.getOwnValue().equals("was_copied_in_as")) { + } else if (relName.equals("was_copied_in_as")) { // WITENSS -> was_copied_in_as -> ALIAS target = getTargetRelation(rel); copyPlaceLo.setEntityAndAttribute(target); - } else if (rel.getOwnValue().equals(rel_had_patron)) { + } else if (relName.equals(rel_had_patron)) { // WITNESS -> had_patron -> PERSON target = getTargetRelation(rel); patronageLo.setEntityAndAttributeName(target, name_translit); - } else if (rel.getOwnValue().equals(is_part_of)) { + } else if (relName.equals(is_part_of)) { // WITNESS -> is_part_of -> CODEX if (rel.getTargetObjectClass().equals(CODEX)) { target = getTargetRelation(rel); this.setCodex(target); } - } else if (rel.getOwnValue().equals(rel_has_author_written_as)) { + } else if (relName.equals(Misidentification.HAS_MISIDENT)) { + // WITNESS -> has_misidentification -> MISIDENTIFICATION + target = getTargetRelation(rel); + this.misidentTable.load(target); + + } else if (relName.equals(rel_has_author_written_as)) { //TODO this relation is no in the definitions Entity target2 = getTargetRelation(rel); Attribute alias = getTargetAttribute(target2, "alias"); this.valueAuthorWritten = (alias != null) ? alias.getValue() : null; - } else if (rel.getOwnValue().equals(rel_has_title_written_as)) { + } else if (relName.equals(rel_has_title_written_as)) { //TODO this relation is no in the definitions target = getTargetRelation(rel); //this.textWritten = target; @@ -1098,6 +1114,14 @@ public void setPossibleExamplerOfList(EntityList possibleExamplerOfList) { this.possibleExamplerOfList = possibleExamplerOfList; } + + public MisidentificationTable getMisidentTable() { + return misidentTable; + } + + public void setMisidentTable(MisidentificationTable misidentTable) { + this.misidentTable = misidentTable; + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/Misidentification.java Fri Jan 06 20:41:35 2017 +0100 @@ -0,0 +1,170 @@ +package de.mpiwg.itgroup.ismi.util.guiComponents; + +import java.io.Serializable; +import java.util.List; + +import org.mpi.openmind.cache.WrapperService; +import org.mpi.openmind.repository.bo.Attribute; +import org.mpi.openmind.repository.bo.Entity; +import org.mpi.openmind.repository.bo.Node; +import org.mpi.openmind.repository.bo.Relation; + +public class Misidentification implements Serializable { + private static final long serialVersionUID = -1840193000833171153L; + + public static String TITLE = "title"; + public static String TITLE_TRANSLIT = "title_translit"; + public static String MISIDENT = "MISIDENTIFICATION"; + public static String MISATTRIBUTED_TO = "misattributed_to"; + public static String IS_REFERENCE_OF = "is_reference_of"; + public static String HAS_MISIDENT = "has_misidentification"; + + private Entity misident; + private String title; + private String title_translit; + private Entity person; + private Reference ref; + private WrapperService ot; + private String userName; + + public Misidentification(WrapperService ot, String userName) { + this.ot = ot; + this.userName = userName; + } + + public Entity saveAndGetMisidentification(Entity witness) throws Exception { + + // create misidentification if necessary + if (misident == null) { + misident = new Entity(Node.TYPE_ABOX, MISIDENT, false); + } + + // set title + if (!misident.containsAttribute(TITLE)) { + misident.addAttribute(new Attribute(title, "text", title)); + } else { + misident.getAttributeByName(TITLE).setOwnValue(title); + } + if (!misident.containsAttribute(TITLE_TRANSLIT)) { + misident.addAttribute(new Attribute(title, "text", title_translit)); + } else { + misident.getAttributeByName(TITLE_TRANSLIT).setOwnValue(title_translit); + } + + // save reference + Entity entityRef = this.ref.getEnt(); + ot.saveEntity(entityRef, userName); + + // set person relation to misidentification + this.misident.removeAllSourceRelations(MISATTRIBUTED_TO, "PERSON"); + new Relation(misident, person, MISATTRIBUTED_TO); + + // set reference relation to misidentification + this.misident.removeAllTargetRelations(IS_REFERENCE_OF, "REFERENCE"); + new Relation(entityRef, misident, IS_REFERENCE_OF); + + // set text relation to misidentification + this.misident.removeAllTargetRelations(HAS_MISIDENT, "WITNESS"); + new Relation(witness, misident, HAS_MISIDENT); + + // save misidentification + // FIXME: really save here? + ot.saveEntity(misident, userName); + + return witness; + } + + public static Misidentification create(String title, String title_translit, Entity person, WrapperService ot, + String userName) { + Misidentification obj = new Misidentification(ot, userName); + obj.setTitle(title); + obj.setTitle_translit(title_translit); + obj.setPerson(person); + obj.setRef(new Reference(null)); + + return obj; + } + + public static Misidentification load(Entity misident, WrapperService ot, String userName) throws Exception { + + Misidentification obj = new Misidentification(ot, userName); + + if (misident.isLightweight()) { + obj.setMisident(ot.getEntityByIdWithContent(misident.getId())); + } + + // load title + if (misident.containsAttribute(TITLE)) { + String t = misident.getAttributeByName(TITLE).getOwnValue(); + obj.setTitle(t); + } + if (misident.containsAttribute(TITLE_TRANSLIT)) { + String tt = misident.getAttributeByName(TITLE_TRANSLIT).getOwnValue(); + obj.setTitle_translit(tt); + } + + // loading person. Person can be Light Weight + List<Entity> tmpList = ot.getTargetsForSourceRelation(misident, MISATTRIBUTED_TO, "PERSON", -1); + if (tmpList.size() > 1) { + throw new Exception( + "Misidentification (entity) can not have more than one person associated. " + misident.toString()); + } else if (tmpList.size() == 1) { + obj.setPerson(tmpList.get(0)); + } + + // load references + tmpList = ot.getSourcesForTargetRelation(misident, IS_REFERENCE_OF, "REFERENCE", -1); + if (tmpList.size() > 0) { + Entity ref = tmpList.get(0); + if (ref.isLightweight()) { + ref = ot.getEntityByIdWithContent(ref.getId()); + } + obj.setRef(new Reference(ref)); + } + + // this.person = person; + // this.ref = new Reference(ref); + return obj; + } + + public Entity getPerson() { + return person; + } + + public void setPerson(Entity person) { + this.person = person; + } + + public Reference getRef() { + return ref; + } + + public void setRef(Reference ref) { + this.ref = ref; + } + + public Entity getMisident() { + return misident; + } + + public void setMisident(Entity misident) { + this.misident = misident; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getTitle_translit() { + return title_translit; + } + + public void setTitle_translit(String title_translit) { + this.title_translit = title_translit; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/MisidentificationTable.java Fri Jan 06 20:41:35 2017 +0100 @@ -0,0 +1,158 @@ +package de.mpiwg.itgroup.ismi.util.guiComponents; + +import java.util.ArrayList; +import java.util.List; + +import javax.faces.event.ActionEvent; + +import org.apache.log4j.Logger; +import org.mpi.openmind.repository.bo.Entity; + +import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; +import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; +import de.mpiwg.itgroup.ismi.utils.SelectableObject; + +public class MisidentificationTable extends AbstractISMIBean { + private static final long serialVersionUID = -2756216426560705498L; + private static Logger logger = Logger.getLogger(MisidentificationTable.class); + + private List<SelectableObject<Misidentification>> list = new ArrayList<SelectableObject<Misidentification>>(); + + private Misidentification misident; + + private ListenerObject lo; + //private String attName; + //private String oc; + + public MisidentificationTable(){ + lo = new ListenerObject(PERSON, "name_translit"); + } + + public void listenerRemove(ActionEvent event){ + List<SelectableObject<Misidentification>> toDelete = new ArrayList<SelectableObject<Misidentification>>(); + + for(SelectableObject<Misidentification> so : this.list){ + if(so.isSelected()){ + toDelete.add(so); + } + } + for(SelectableObject<Misidentification> so : toDelete){ + this.list.remove(so); + } + } + + public void listenerEditRef(ActionEvent event){ + SelectableObject<Misidentification> so = + (SelectableObject<Misidentification>)getRequestBean("item"); + if(so != null){ + this.misident = so.getObj(); + } + } + + public void listenerSaveRef(ActionEvent event){ + this.misident = null; + } + + public void listenerCancel(ActionEvent event){ + //@TODO + } + + public void listenerCreate(ActionEvent event){ + if(this.lo.entity != null & this.lo.entity.isPersistent()){ + // FIXME: where to get title? + this.create(null, null, this.lo.entity); + } + } + + public void load(Entity misattEntity){ + if(!containsEntity(misattEntity)){ + //TODO sort + //Collections.sort(this.misattList); + try { + this.list.add(new SelectableObject<Misidentification>(Misidentification.load(misattEntity, getWrapper(), getUserName()))); + } catch (Exception e) { + addErrorMsg(e.getMessage()); + logger.error(e); + } + }else{ + addGeneralMsg("This entity has been already inserted!"); + } + } + + public void create(String title, String title_translit, Entity person){ + try { + this.list.add(new SelectableObject<Misidentification>(Misidentification.create(title, title_translit, person, getWrapper(), getUserName()))); + } catch (Exception e) { + addErrorMsg(e.getMessage()); + logger.error(e); + } + } + + private boolean containsEntity(Entity ent){ + for(SelectableObject<Misidentification> so : this.list){ + if(so.getObj().getPerson() != null && so.getObj().getPerson().getId().equals(ent.getId())){ + return true; + } + } + return false; + } + + /* + public void listenerChanged(ValueChangeEvent event) { + this.lo = changeListener(event, lo, this.oc, this.attName); + if(lo.entity != null && lo.entity.isPersistent()){ + lo.statusImage.setStatus(StatusImage.STATUS_OK); + }else{ + lo.statusImage.setStatus(StatusImage.STATUS_UNSET); + } + } + */ + + + /** + * Save all misidentifications. + * + * @param text + * @return + * @throws Exception + */ + public Entity saveMisidentifications(Entity text) throws Exception{ + for(Misidentification misatt : this.getMisidentList()){ + text = misatt.saveAndGetMisidentification(text); + } + return text; + } + + + private List<Misidentification> getMisidentList() { + List<Misidentification> list = new ArrayList<Misidentification>(); + for(SelectableObject<Misidentification> so : this.list){ + list.add(so.getObj()); + } + return list; + } + + public List<SelectableObject<Misidentification>> getList() { + return list; + } + + public void setList(List<SelectableObject<Misidentification>> list) { + this.list = list; + } + + public Misidentification getMisident() { + return misident; + } + + public void setMisident(Misidentification misident) { + this.misident = misident; + } + + public ListenerObject getLo() { + return lo; + } + + public void setLo(ListenerObject lo) { + this.lo = lo; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/entry/components/misidentification.xhtml Fri Jan 06 20:41:35 2017 +0100 @@ -0,0 +1,143 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.org/rich" + xmlns:ismi="http://java.sun.com/jsf/composite/components/ismi"> +<body> + <ui:composition> + + <h:panelGrid id="misidentArea"> + + <h:panelGroup rendered="#{CurrentWitness.misidentTable.misident != null}"> + <div style="z-index: 100;" class="rf-pp-shade"> + <button class="rf-pp-btn" tabindex="-1" accesskey="" /> + </div> + + <h:panelGrid columns="1" class="rf-pp-cntr" + style="height: 350px; left: 470px; position: fixed; top: 219px; width: 500px; z-index: 100;"> + + <div class="rf-pp-shdw" + style="opacity: 0.1; width: 500px; height: 350px; left: 5px; top: 5px; bottom: -5px;"> + </div> + <div class="rf-pp-hdr " style="cursor: default;"> + <div class="rf-pp-hdr-cnt">EndNote Reference</div> + </div> + + <h:panelGrid columns="1" class="rf-pp-cnt-scrlr" + style="width: 500px; height: 329px;"> + <h:panelGrid columns="1" class="rf-pp-cnt"> + + <h:panelGrid columns="1"> + <h:panelGrid columns="2"> + + <h:outputLabel value="EndNote Id" /> + <h:inputText size="80" + value="#{CurrentWitness.misidentTable.misident.ref.endNoteId}" /> + + <h:outputLabel value="EndNote Content" /> + <h:inputTextarea + value="#{CurrentWitness.misidentTable.misident.ref.endNoteContent}" + rows="10" cols="80" /> + + <h:outputLabel value="Additional Information" /> + <h:inputTextarea + value="#{CurrentWitness.misidentTable.misident.ref.addInformation}" + rows="3" cols="80" /> + + </h:panelGrid> + <a4j:commandButton value="OK" + actionListener="#{CurrentWitness.misidentTable.listenerSaveRef}" + render="misidentArea"/> + </h:panelGrid> + + </h:panelGrid> + </h:panelGrid> + </h:panelGrid> + + </h:panelGroup> + + + + + <h:panelGrid border="0" columns="1"> + <h:panelGrid columns="1" + rendered="#{!empty CurrentWitness.misidentTable.list}"> + + <rich:dataTable value="#{CurrentWitness.misidentTable.list}" var="item"> + + <rich:column> + <f:facet name="header"> + <h:outputText value="Title" /> + </f:facet> + <h:outputText + value="#{item.obj.person.ownValue}" /> + </rich:column> + + <rich:column> + <f:facet name="header"> + <h:outputText value="Title (translit)" /> + </f:facet> + <h:outputText + value="#{item.obj.person.ownValue}" /> + </rich:column> + + <rich:column> + <f:facet name="header"> + <h:outputText value="Author" /> + </f:facet> + <h:outputText + value="[#{item.obj.person.id}] #{item.obj.person.ownValue}" /> + </rich:column> + + <rich:column> + <f:facet name="header"> + <h:outputText value="Reference" /> + </f:facet> + <h:outputText value="#{item.obj.ref.endNoteId}" /> + </rich:column> + + <rich:column> + <f:facet name="header"> + <h:outputText value="Note" /> + </f:facet> + <h:outputText value="#{item.obj.ref.addInformation}" /> + </rich:column> + + <rich:column> + <f:facet name="header"> + <h:outputText value="Edit" /> + </f:facet> + <a4j:commandLink + actionListener="#{CurrentWitness.misidentTable.listenerEditRef}"> + <h:graphicImage url="#{ApplicationBean1.editImage}" /> + <a4j:ajax event="click" render="misidentArea" /> + </a4j:commandLink> + </rich:column> + <rich:column> + <h:selectBooleanCheckbox value="#{item.selected}" /> + </rich:column> + </rich:dataTable> + + + <a4j:commandButton value="Remove" + actionListener="#{CurrentWitness.misidentTable.listenerRemove}" + onclick="#{ApplicationBean1.JSConfirmationDelete}" + render="misidentArea"/> + </h:panelGrid> + + <h:panelGrid columns="2"> + <ismi:autocomplete lo="#{CurrentWitness.misidentTable.lo}" /> + <a4j:commandButton value="Add" + actionListener="#{CurrentWitness.misidentTable.listenerCreate}" + render="misidentArea"/> + </h:panelGrid> + </h:panelGrid> + + </h:panelGrid> + + </ui:composition> +</body> +</html>
--- a/src/main/webapp/entry/text.xhtml Fri Jan 06 16:59:37 2017 +0100 +++ b/src/main/webapp/entry/text.xhtml Fri Jan 06 20:41:35 2017 +0100 @@ -84,7 +84,7 @@ actionListener="#{CurrentText.listenerShowAllAuthors}"> </h:commandButton> - <h:outputText value="Misattributions" /> + <h:outputText value="Misattributed to" /> <ui:include src="components/misattribution.xhtml" /> <h:outputText />
--- a/src/main/webapp/entry/witness.xhtml Fri Jan 06 16:59:37 2017 +0100 +++ b/src/main/webapp/entry/witness.xhtml Fri Jan 06 20:41:35 2017 +0100 @@ -116,6 +116,15 @@ <h:panelGrid columns="2" styleClass="createPanel" columnClasses="createPanelFirstColumn,createPanelColumn02"> + + <h:outputText value="Misidentified as" /> + <ui:include src="components/misidentification.xhtml" /> + + </h:panelGrid> + + + <h:panelGrid columns="2" styleClass="createPanel" + columnClasses="createPanelFirstColumn,createPanelColumn02"> <h:outputText value="Ahlwardt No." /> <h:inputText value="#{CurrentWitness.attributes['ahlwardt_no']}"
--- a/src/main/webapp/search/displayTitle.xhtml Fri Jan 06 16:59:37 2017 +0100 +++ b/src/main/webapp/search/displayTitle.xhtml Fri Jan 06 20:41:35 2017 +0100 @@ -85,7 +85,7 @@ <h:outputText value="#{Session.displayTitle.title.creationDate}" escape="false" /> - <h:outputText value="Create in" /> + <h:outputText value="Created in" /> <h:outputText value="#{Session.displayTitle.title.createIn}" /> <h:outputText value="Language" />