changeset 194:c7fec83ab69a

fix bugs with make-public buttons in entity details form. Closes #152.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Fri, 07 Dec 2018 15:47:06 +0100
parents 76d2dda8d4de
children 5309d29b3061
files src/main/java/de/mpiwg/itgroup/ismi/browse/EntityDetailsBean.java src/main/java/de/mpiwg/itgroup/ismi/entry/utils/PrivacityUtils.java src/main/webapp/browse/entityDetails.xhtml
diffstat 3 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/browse/EntityDetailsBean.java	Wed Dec 05 18:48:23 2018 +0100
+++ b/src/main/java/de/mpiwg/itgroup/ismi/browse/EntityDetailsBean.java	Fri Dec 07 15:47:06 2018 +0100
@@ -241,11 +241,12 @@
 	 */
 	public String actionChangeEntityPrivacity() {
 		// toggle publication state
-		PrivacityUtils.changeEntityPrivacity(this.entity, null, getWrapper());
+		Entity saveEnt = PrivacityUtils.changeEntityPrivacity(this.entity, null, getWrapper());
 		ArrayList<Entity> saveList = new ArrayList<Entity>();
-		saveList.add(entity);
+		saveList.add(saveEnt);
 		try {
 			getWrapper().saveEntityListAsNodeWithoutContent(saveList, getUserName());
+			this.entity = saveEnt;
 		} catch (Exception e) {
 			printInternalError(e);
 			logger.error(e);
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/utils/PrivacityUtils.java	Wed Dec 05 18:48:23 2018 +0100
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/utils/PrivacityUtils.java	Fri Dec 07 15:47:06 2018 +0100
@@ -81,7 +81,9 @@
 
         // change source relations
         for (Relation rel : entity.getSourceRelations()) {
-            if (!exceptedTypes.contains(rel.getTargetObjectClass())) {
+            if (exceptedTypes != null && exceptedTypes.contains(rel.getTargetObjectClass())) {
+            	continue;
+            } else {
                 Long entId = rel.getTargetId();
                 if (alreadyModified.containsKey(entId)) {
                 	continue;
@@ -93,7 +95,9 @@
         }
         // change target relations
         for (Relation rel : entity.getTargetRelations()) {
-            if (!exceptedTypes.contains(rel.getSourceObjectClass())) {
+            if (exceptedTypes != null && exceptedTypes.contains(rel.getSourceObjectClass())) {
+            	continue;
+            } else {
                 Long entId = rel.getSourceId();
                 if (alreadyModified.containsKey(entId)) {
                 	continue;
--- a/src/main/webapp/browse/entityDetails.xhtml	Wed Dec 05 18:48:23 2018 +0100
+++ b/src/main/webapp/browse/entityDetails.xhtml	Fri Dec 07 15:47:06 2018 +0100
@@ -73,11 +73,13 @@
                             
                             <a4j:commandButton value="Make entity public" title="Change publication state of this entity"
                                 rendered="#{!Session.entDetailsForm.entity.isPublic}"
+                                render="entityDetailsPanel"
                                 style="margin-right:10px;"
                                 onclick="if(!confirm('Do you really want to make this entity public?')){ return; };"
                                 action="#{Session.entDetailsForm.actionChangeEntityPrivacity}"/>
                             <a4j:commandButton value="Make entity private" title="Change publication state of this entity"
                                 rendered="#{Session.entDetailsForm.entity.isPublic}"
+                                render="entityDetailsPanel"
                                 style="margin-right:10px;"
                                 onclick="if(!confirm('Do you really want to make this entity private?')){ return; };"
                                 action="#{Session.entDetailsForm.actionChangeEntityPrivacity}"/>
@@ -85,12 +87,14 @@
                             <a4j:commandButton value="Make all directly related entities public" 
                                 title="Change publication state of directly related entities"
                                 rendered="#{Session.entDetailsForm.entity.isPublic}"
+                                render="entityDetailsPanel"
                                 style="margin-right:10px;"
                                 onclick="if(!confirm('Do you really want to make all related entities public?')){ return; };"
                                 action="#{Session.entDetailsForm.actionChangeRelatedEntitiesPrivacity}"/>
                             <a4j:commandButton value="Make all directly related entities private" 
                                 title="Change publication state of directly related entities"
                                 rendered="#{!Session.entDetailsForm.entity.isPublic}"
+                                render="entityDetailsPanel"
                                 style="margin-right:10px;"
                                 onclick="if(!confirm('Do you really want to make all related entities private?')){ return; };"
                                 action="#{Session.entDetailsForm.actionChangeRelatedEntitiesPrivacity}"/>