changeset 177:af1018d06443

PublicByAuthor feature with new "Select by public and MAMS" works now!
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Fri, 08 Jun 2018 17:03:35 +0200
parents c63d39034b60
children ca83d67a2dc9
files src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java src/main/webapp/clean/components/publicMamsSubjects.xhtml src/main/webapp/clean/makeTextsPublic.xhtml src/main/webapp/resources/css/ismi-db/popupPanel.css src/main/webapp/templates/main_template.xhtml
diffstat 5 files changed, 53 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java	Fri Jun 08 15:32:27 2018 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/merge/PublicByAuthorBean.java	Fri Jun 08 17:03:35 2018 +0200
@@ -5,6 +5,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import javax.faces.event.ActionEvent;
 
@@ -57,6 +58,7 @@
 	    selectedPersonSubjectMap = new HashMap<String,List<Entity>>();
 	    
 	    makeSubjectTree();
+	    updateSubjectTexts();
         logger.info("PublicByAuthorBean.reset() Done.");
 	}
 	
@@ -70,9 +72,6 @@
 	    subjectList = new ArrayList<String>();
 	    subjectEntity = new HashMap<String,Entity>();
 	    subjectParents = new HashMap<String,List<String>>();
-	    subjectTexts = new HashMap<String,List<Entity>>();
-	    subjectPublicTexts = new HashMap<String,List<Entity>>();
-	    subjectPrivateTexts = new HashMap<String,List<Entity>>();
 	    /*
 	     * get all subjects
 	     */
@@ -107,28 +106,41 @@
 	            }
 	        } while (++cnt < 5);
 	        subjectParents.put(subjectName, parents);
-	        /*
-	         * find subject's texts
-	         */
-	        ArrayList<Entity> textList = new ArrayList<Entity>();
-	        ArrayList<Entity> pubTextList = new ArrayList<Entity>();
-	        ArrayList<Entity> privTextList = new ArrayList<Entity>();
-	        for (Relation textRel : subject.getTargetRelations(has_subject, TEXT)) {
-	            Long textId = textRel.getSourceId();
-	            Entity text = getWrapper().getEntityByIdWithContent(textId);
-	            textList.add(text);
-	            if (text.getIsPublic()) {
-	                pubTextList.add(text);
-	            } else {
-	                privTextList.add(text);
-	            }
-	        }
-	        subjectTexts.put(subjectName, textList);
-	        subjectPublicTexts.put(subjectName, pubTextList);
-	        subjectPrivateTexts.put(subjectName, privTextList);
 	    }
 	}
-	
+
+    /**
+     * update subjectTexts, subjectPublicTexts and subjectPrivateTexts.
+     * 
+     */
+    private void updateSubjectTexts() {
+        subjectTexts = new HashMap<String,List<Entity>>();
+        subjectPublicTexts = new HashMap<String,List<Entity>>();
+        subjectPrivateTexts = new HashMap<String,List<Entity>>();
+        for (Entry<String, Entity> subjectItem : subjectEntity.entrySet()) {
+            String subjectName = subjectItem.getKey();
+            Entity subject = subjectItem.getValue();
+            /*
+             * find subject's texts
+             */
+            ArrayList<Entity> textList = new ArrayList<Entity>();
+            ArrayList<Entity> pubTextList = new ArrayList<Entity>();
+            ArrayList<Entity> privTextList = new ArrayList<Entity>();
+            for (Relation textRel : subject.getTargetRelations(has_subject, TEXT)) {
+                Long textId = textRel.getSourceId();
+                Entity text = getWrapper().getEntityByIdWithContent(textId);
+                textList.add(text);
+                if (text.getIsPublic()) {
+                    pubTextList.add(text);
+                } else {
+                    privTextList.add(text);
+                }
+            }
+            subjectTexts.put(subjectName, textList);
+            subjectPublicTexts.put(subjectName, pubTextList);
+            subjectPrivateTexts.put(subjectName, privTextList);
+        }
+    }	
 	
 	public void actionReset() {
 	    reset();
@@ -282,6 +294,7 @@
         /*
          * go through all texts for the subject
          */
+        int pubCnt = 0;
         List<Entity> texts = subjectTexts.get(subject);
         for (Entity text : texts) {
             if (text.isLightweight()) {
@@ -316,6 +329,7 @@
                 List<Entity> entities = PrivacityUtils.setTextAndMorePrivacity(text, true, textMsg, getWrapper());
                 // save only public state
                 getWrapper().saveEntityListAsNodeWithoutContent(entities, null);
+                pubCnt += 1;
             } catch (Exception e) {
                 logger.error(e);
             }
@@ -324,6 +338,12 @@
                 logger.debug(msg);
             }
         }
+        if (pubCnt == 0) {
+            addGeneralMsg("No text matched your criteria.");
+        } else {
+            addGeneralMsg(pubCnt+" texts with MAMS number < "+maxMamsNr+" were made public!");            
+        }
+        updateSubjectTexts();
         return null;
     }
     
--- a/src/main/webapp/clean/components/publicMamsSubjects.xhtml	Fri Jun 08 15:32:27 2018 +0200
+++ b/src/main/webapp/clean/components/publicMamsSubjects.xhtml	Fri Jun 08 17:03:35 2018 +0200
@@ -34,8 +34,8 @@
 					</h2>
 
 					<a4j:commandButton value="make all texts up to given MAMS number and their witnesses public"
-						actionListener="#{Session.publicByAuthor.NoactionMakeMamsSubjectAndRelatedPublic}"
-						render="selectSubjectPanel" style="margin-bottom:0.5em"/>
+						actionListener="#{Session.publicByAuthor.actionMakeMamsSubjectAndRelatedPublic}"
+						render="selectSubjectPanel2" style="margin-bottom:0.5em"/>
 
                     <div>
 						#{Session.publicByAuthor.subjectPublicTexts.get(subject).size()}
--- a/src/main/webapp/clean/makeTextsPublic.xhtml	Fri Jun 08 15:32:27 2018 +0200
+++ b/src/main/webapp/clean/makeTextsPublic.xhtml	Fri Jun 08 17:03:35 2018 +0200
@@ -38,7 +38,7 @@
 
         <a4j:commandButton value="reload all texts"
             actionListener="#{Session.publicByAuthor.actionReset}"
-            render="mainPanel" />
+            render="mainPanel,selectSubjectPanel,selectSubjectPanel2" />
 
 
 			</h:panelGrid>
--- a/src/main/webapp/resources/css/ismi-db/popupPanel.css	Fri Jun 08 15:32:27 2018 +0200
+++ b/src/main/webapp/resources/css/ismi-db/popupPanel.css	Fri Jun 08 17:03:35 2018 +0200
@@ -1,9 +1,9 @@
 
 .ismi-pp-cntr {
     
-    position: fixed;
-  	top: 50%;
-  	left: 50%;
+    position: absolute;
+  	top: 20%;
+  	left: 20%;
   	
     z-index: 100;
     
@@ -12,11 +12,8 @@
     border-radius: 0;
     cursor: default;
 	
-	/* default values*/
-	width: 300px; height: 100px; margin-top: -80px; margin-left: -150px;
-	
+	width: 300px; height: 100px;
 	/*
-	width: 300px; height: 100px;
     margin-top: -50px;
   	margin-left: -150px;
   	*/
--- a/src/main/webapp/templates/main_template.xhtml	Fri Jun 08 15:32:27 2018 +0200
+++ b/src/main/webapp/templates/main_template.xhtml	Fri Jun 08 17:03:35 2018 +0200
@@ -40,11 +40,9 @@
 								<h:graphicImage url="/resources/images/info_32.png" />
 								<h:panelGrid style="text-align:left; min-width:60em">
 									<h:dataTable value="#{Session.generalMsgList}" var="msg"
-										rows="10">
+										rows="0">
 										<h:column>
-										  <div style="overflow:scroll;max-height:300px">
 											<h:outputText value="#{msg}" />
-										  </div>
 										</h:column>
 									</h:dataTable>
 								</h:panelGrid>
@@ -64,7 +62,7 @@
 		<h:panelGrid id="errorMsgPp">
 			<a4j:outputPanel ajaxRendered="true">
 				<h:panelGroup rendered="#{!empty Session.errorMsgList}">
-					<div style="z-index: 100;" class="rf-pp-shade">
+					<div style="z-index:100;" class="rf-pp-shade">
 						<button class="rf-pp-btn" tabindex="-1" accesskey="" />
 					</div>
 
@@ -79,7 +77,7 @@
 								<h:graphicImage url="/resources/images/error_32.png" />
 								<h:panelGrid style="text-align:left">
 									<h:dataTable value="#{Session.errorMsgList}" var="msg"
-										rows="10">
+										rows="0">
 										<h:column>
 											<h:outputText value="#{msg}" />
 										</h:column>