Mercurial > hg > ismi-richfaces
changeset 170:8604b368ec19 public_by_author
still more work on publicByAuthor feature.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 31 May 2018 21:25:45 +0200 |
parents | 0b5d02012299 |
children | 50b8103ec85c |
files | src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java src/main/webapp/clean/components/publicShowSubjects.xhtml src/main/webapp/clean/publicByAuthor.xhtml |
diffstat | 3 files changed, 74 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java Thu May 31 20:26:10 2018 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java Thu May 31 21:25:45 2018 +0200 @@ -2,10 +2,11 @@ import java.io.Serializable; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.faces.event.ActionEvent; -import javax.faces.event.ValueChangeEvent; import org.apache.log4j.Logger; import org.mpi.openmind.repository.bo.Entity; @@ -26,7 +27,8 @@ protected Entity selectedPerson; protected List<Entity> selectedPersonTexts; - protected List<Entity> selectedPersonSubjects; + protected List<String> selectedPersonSubjects; + protected Map<String,List<Entity>> selectedPersonSubjectMap; private EntityRepositoryBean browseBean; @@ -43,13 +45,14 @@ browseBean.setObjectClass("PERSON"); selectedPersonTexts = new ArrayList<Entity>(); + selectedPersonSubjectMap = new HashMap<String,List<Entity>>(); } public void listenerAuthorIdSearch(ActionEvent event) { setSelectedPersonById(); } - private void setSelectedPersonById() { + protected void setSelectedPersonById() { Entity ent = getWrapper().getEntityById(selectedPersonId); if (ent != null) { ent = getWrapper().getEntityContent(ent); @@ -63,11 +66,45 @@ public void updateSelectedPerson() { // load all texts by this author selectedPersonTexts = new ArrayList<Entity>(); + selectedPersonSubjectMap = new HashMap<String,List<Entity>>(); List<Relation> textRels = selectedPerson.getTargetRelations("was_created_by", "TEXT"); for (Relation rel : textRels) { Long textID = rel.getSourceId(); + // get text Entity text = getWrapper().getEntityByIdWithContent(textID); selectedPersonTexts.add(text); + // get subject + List<Relation> subjectRels = text.getSourceRelations("has_subject", "SUBJECT"); + if (subjectRels.isEmpty()) { + String subject = "NO SUBJECT"; + List<Entity> texts = selectedPersonSubjectMap.get(subject); + if (texts == null) { + texts = new ArrayList<Entity>(); + } + // add text to list + texts.add(text); + // add list to subject map + selectedPersonSubjectMap.put(subject, texts); + + } else { + for (Relation subjectRel : subjectRels) { + Long subjectId = subjectRel.getTargetId(); + Entity subject = getWrapper().getEntityByIdWithContent(subjectId); + List<Entity> texts = selectedPersonSubjectMap.get(subject.getOwnValue()); + if (texts == null) { + texts = new ArrayList<Entity>(); + } + // add text to list + texts.add(text); + // add list to subject map + selectedPersonSubjectMap.put(subject.getOwnValue(), texts); + } + } + } + // update list of subjects + selectedPersonSubjects = new ArrayList<String>(); + for (String sub : selectedPersonSubjectMap.keySet()) { + selectedPersonSubjects.add(sub); } } @@ -145,8 +182,8 @@ /** * @return the selectedPersonSubjects */ - public List<Entity> getSelectedPersonSubjects() { - return selectedPersonSubjects; + public Map<String, List<Entity>> getSelectedPersonSubjectMap() { + return selectedPersonSubjectMap; } /** @@ -156,4 +193,11 @@ this.selectedPersonId = selectedPersonId; } + /** + * @return the selectedPersonSubjects + */ + public List<String> getSelectedPersonSubjects() { + return selectedPersonSubjects; + } + }
--- a/src/main/webapp/clean/components/publicShowSubjects.xhtml Thu May 31 20:26:10 2018 +0200 +++ b/src/main/webapp/clean/components/publicShowSubjects.xhtml Thu May 31 21:25:45 2018 +0200 @@ -9,8 +9,8 @@ <body> <ui:composition> - <!-- <h:outputStylesheet name="/css/ismi-db/repository.css" /> --> - + <!-- <h:outputStylesheet name="/css/ismi-db/repository.css" /> --> + <h:panelGrid columns="3" styleClass="displayPanel" @@ -18,28 +18,34 @@ <h:outputLabel value="Person ID" /> <h:inputText value="#{Session.publicByAuthor.selectedPersonId}" /> - <h:outputText value="#{Session.publicByAuthor.selectedPerson.ownValue}" /> + <h:outputText + value="#{Session.publicByAuthor.selectedPerson.ownValue}" /> - <a4j:commandButton value="search" - actionListener="#{Session.publicByAuthor.listenerAuthorIdSearch}" - render="selectSubjectPanel" /> + <a4j:commandButton value="search" + actionListener="#{Session.publicByAuthor.listenerAuthorIdSearch}" + render="selectSubjectPanel" /> </h:panelGrid> <h:panelGrid id="selectSubjectPanel" columns="1" - style="margin-left: auto; margin-right: auto; text-align: center; width: 100%;" - > - <rich:dataTable - rendered="#{!empty Session.publicByAuthor.selectedPersonTexts}" - value="#{Session.publicByAuthor.selectedPersonTexts}" var="titleItem" - styleClass="select"> - <rich:column> - <div>#{titleItem.ownValue}</div> - </rich:column> - </rich:dataTable> + style="margin-left: auto; margin-right: auto; text-align: center; width: 100%;"> + <rich:dataTable + value="#{Session.publicByAuthor.selectedPersonSubjects}" + var="subject" styleClass="select"> + <rich:column> + <div>#{subject}</div> + <rich:dataTable + value="#{Session.publicByAuthor.selectedPersonSubjectMap.get(subject)}" + var="text" styleClass="select"> + <rich:column> + <div>#{text.ownValue}</div> + </rich:column> + </rich:dataTable> + </rich:column> + </rich:dataTable> - - + + </h:panelGrid>
--- a/src/main/webapp/clean/publicByAuthor.xhtml Thu May 31 20:26:10 2018 +0200 +++ b/src/main/webapp/clean/publicByAuthor.xhtml Thu May 31 21:25:45 2018 +0200 @@ -28,7 +28,7 @@ <ui:include src="components/publicFindAuthor.xhtml" /> </rich:tab> - <rich:tab header="Select Subject" name="02"> + <rich:tab header="Select by Subject" name="02"> <ui:include src="components/publicShowSubjects.xhtml" /> </rich:tab> </rich:tabPanel>