From dd369c5186feebfba3c9fc2cd44ad90cf7fc4054 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Mon, 7 Jul 2014 15:24:52 +0200 Subject: [PATCH] =?UTF-8?q?V=20agend=C4=9B=20St=C5=99ediska=20se=20zobrazu?= =?UTF-8?q?j=C3=AD=20funkce=20(P=C5=99=C3=ADkazce,=20Spr=C3=A1vce=20rozpo?= =?UTF-8?q?=C4=8Dtu...).=20refs=20#97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukova/isspst/dao/jpa/BaseDaoJPA.java | 7 ++- .../isspst/ui/workgroups/WorkgroupList.java | 22 ++++++-- .../webapp/admin/workgroups/workgroupForm.zul | 2 +- .../webapp/admin/workgroups/workgroups.zul | 50 +++++++++++++------ 4 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/main/java/info/bukova/isspst/dao/jpa/BaseDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/BaseDaoJPA.java index 7f9455d7..7f5f46d8 100644 --- a/src/main/java/info/bukova/isspst/dao/jpa/BaseDaoJPA.java +++ b/src/main/java/info/bukova/isspst/dao/jpa/BaseDaoJPA.java @@ -2,6 +2,7 @@ package info.bukova.isspst.dao.jpa; import java.util.List; +import org.hibernate.NonUniqueObjectException; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; @@ -44,7 +45,11 @@ public abstract class BaseDaoJPA implements BaseDao { @Override public void modify(T entity) { - sessionFactory.getCurrentSession().update(entity); + try { + sessionFactory.getCurrentSession().update(entity); + } catch (NonUniqueObjectException e) { + sessionFactory.getCurrentSession().merge(entity); + } } @Override diff --git a/src/main/java/info/bukova/isspst/ui/workgroups/WorkgroupList.java b/src/main/java/info/bukova/isspst/ui/workgroups/WorkgroupList.java index 69e34748..cd3f2d2f 100644 --- a/src/main/java/info/bukova/isspst/ui/workgroups/WorkgroupList.java +++ b/src/main/java/info/bukova/isspst/ui/workgroups/WorkgroupList.java @@ -1,5 +1,7 @@ package info.bukova.isspst.ui.workgroups; +import java.util.List; + import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.GlobalCommand; import org.zkoss.bind.annotation.Init; @@ -9,8 +11,10 @@ import org.zkoss.zul.TreeModel; import org.zkoss.zul.TreeNode; import info.bukova.isspst.data.Member; +import info.bukova.isspst.data.Role; import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.filters.WorkgroupFilter; +import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.BoolConverter; import info.bukova.isspst.ui.ListViewModel; @@ -19,6 +23,8 @@ public class WorkgroupList extends ListViewModel { @WireVariable private WorkgroupService workgroupService; + @WireVariable + private RoleService roleService; private WorkgroupTreeFactory treeFactory; private BoolConverter boolConverter; @@ -40,21 +46,21 @@ public class WorkgroupList extends ListViewModel { return null; } - @NotifyChange({"dataBean", "workgroupTreeModel", "ableToDelete"}) + @NotifyChange({"dataBean", "workgroupTreeModel", "ableToDelete", "workgroupRoles"}) public void setDataBean(Workgroup data) { super.setDataBean(data); } @Override @GlobalCommand - @NotifyChange({ "dataList", "dataBean", "workgroupTreeModel", "ableToDelete" }) + @NotifyChange({ "dataList", "dataBean", "workgroupTreeModel", "ableToDelete", "workgroupRoles" }) public void refresh() { super.refresh(); } @Override @Command - @NotifyChange({ "filter", "dataList", "dataBean", "workgroupTreeModel" }) + @NotifyChange({ "filter", "dataList", "dataBean", "workgroupTreeModel", "workgroupRoles" }) public void filter() { super.filter(); } @@ -63,4 +69,14 @@ public class WorkgroupList extends ListViewModel { return boolConverter; } + public List getWorkgroupRoles() { + if (getDataBean() != null && getDataBean().isCentre()) { + return roleService.getCentreRoles(); + } else if (getDataBean() != null) { + return roleService.getWorkgroupRoles(); + } + + return null; + } + } diff --git a/src/main/webapp/admin/workgroups/workgroupForm.zul b/src/main/webapp/admin/workgroups/workgroupForm.zul index 8e5e2958..062ea08c 100644 --- a/src/main/webapp/admin/workgroups/workgroupForm.zul +++ b/src/main/webapp/admin/workgroups/workgroupForm.zul @@ -46,7 +46,7 @@ diff --git a/src/main/webapp/admin/workgroups/workgroups.zul b/src/main/webapp/admin/workgroups/workgroups.zul index 54ecb2fd..f8cf63fe 100644 --- a/src/main/webapp/admin/workgroups/workgroups.zul +++ b/src/main/webapp/admin/workgroups/workgroups.zul @@ -57,22 +57,40 @@ - - - - - - - - - - + + + + + + + + + + + + + + + \ No newline at end of file