changeset 171:50b8103ec85c public_by_author

still more work on publicByAuthor feature.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Fri, 01 Jun 2018 16:04:38 +0200
parents 8604b368ec19
children 3475b8bea550
files src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java src/main/webapp/clean/components/publicShowSubjects.xhtml
diffstat 2 files changed, 58 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java	Thu May 31 21:25:45 2018 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java	Fri Jun 01 16:04:38 2018 +0200
@@ -29,7 +29,9 @@
 	protected List<Entity> selectedPersonTexts;
 	protected List<String> selectedPersonSubjects;
     protected Map<String,List<Entity>> selectedPersonSubjectMap;
-	
+
+    protected Map<String,List<String>> subjectParents;
+
 	
 	private EntityRepositoryBean browseBean;
 	
@@ -42,13 +44,49 @@
 	public void reset(){
 		//logger.info("AdvancedSearchBean.reset()");
 	    browseBean = new FullEntityRepositoryBean();
-	    browseBean.setObjectClass("PERSON");
+	    browseBean.setObjectClass(PERSON);
 	    
 	    selectedPersonTexts = new ArrayList<Entity>();
 	    selectedPersonSubjectMap = new HashMap<String,List<Entity>>();
+	    makeSubjectTree();
 	}
 	
-	public void listenerAuthorIdSearch(ActionEvent event) {
+	protected void makeSubjectTree() {
+	    subjectParents = new HashMap<String,List<String>>();
+	    List<Entity> subjects = getWrapper().getEntitiesByDef(SUBJECT);
+	    for (Entity subject : subjects) {
+	        if (subject.isLightweight()) {
+	            subject = getWrapper().getEntityContent(subject);
+	        }
+	        ArrayList<String> parents = new ArrayList<String>();
+	        Entity parent = subject;
+	        int cnt = 0; 
+	        do {
+	            if (parent.isLightweight()) {
+	                parent = getWrapper().getEntityContent(parent);
+	            }
+	            List<Relation> parRels = parent.getSourceRelations(is_part_of, SUBJECT);
+	            if (!parRels.isEmpty()) {
+	                Long parentId = parRels.get(0).getTargetId();
+	                parent = getWrapper().getEntityById(parentId);
+	                parents.add(parent.getOwnValue());
+	            } else {
+	                break;
+	            }
+	        } while (++cnt < 5);
+	        subjectParents.put(subject.getOwnValue(), parents);
+	    }
+	}
+	
+	
+	/**
+     * @return the subjectParents
+     */
+    public Map<String, List<String>> getSubjectParents() {
+        return subjectParents;
+    }
+
+    public void listenerAuthorIdSearch(ActionEvent event) {
         setSelectedPersonById();
 	}
 
--- a/src/main/webapp/clean/components/publicShowSubjects.xhtml	Thu May 31 21:25:45 2018 +0200
+++ b/src/main/webapp/clean/components/publicShowSubjects.xhtml	Fri Jun 01 16:04:38 2018 +0200
@@ -1,5 +1,6 @@
 <!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:c="http://java.sun.com/jsp/jstl/core"
 	xmlns:h="http://java.sun.com/jsf/html"
 	xmlns:f="http://java.sun.com/jsf/core"
 	xmlns:ui="http://java.sun.com/jsf/facelets"
@@ -28,24 +29,36 @@
 		</h:panelGrid>
 
 		<h:panelGrid id="selectSubjectPanel" columns="1"
-			style="margin-left: auto; margin-right: auto; text-align: center; width: 100%;">
+			style="margin-left:auto; margin-right:auto; text-align:left; width:100%;">
 			<rich:dataTable
 				value="#{Session.publicByAuthor.selectedPersonSubjects}"
 				var="subject" styleClass="select">
 				<rich:column>
-					<div>#{subject}</div>
+					<h2 style="margin-top:1em">
+					   #{subject}
+					   <c:forEach items="#{Session.publicByAuthor.subjectParents.get(subject)}"
+					       var="parent"> - #{parent}</c:forEach>
+					</h2>
+					
 					<rich:dataTable
 						value="#{Session.publicByAuthor.selectedPersonSubjectMap.get(subject)}"
 						var="text" styleClass="select">
 						<rich:column>
-							<div>#{text.ownValue}</div>
+							<div>
+							    #{text.ownValue} 
+							    <h:outputLink value="#{ApplicationBean1.root}/browse/entityDetails.xhtml?eid=#{text.id}"
+							         target="_blank">
+							      [#{text.id}]
+						        </h:outputLink> 
+							    
+						    </div>
 						</rich:column>
 					</rich:dataTable>
+					
 				</rich:column>
 			</rich:dataTable>
 
 
-
 		</h:panelGrid>