details:   https://code.openbravo.com/erp/devel/pi/rev/f1360ce4b3d1
changeset: 26104:f1360ce4b3d1
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Mon Mar 02 13:45:56 2015 +0100
summary:   Fixes bug 29097: A menu tree node can be moved with a template in 
development

When the Openbravo Trees were reimplemented [1], there was a problem 
reimplementing the logic done when a Menu tree item is moved. Before the 
reimplementation, it was possible to move a menu tree item if the module it 
belonged to was in development or if there was any template module in 
development. The reimplementation did not take into account the templates, so 
from then on it has not been possible to moved menu tree nodes having a 
template in development.

To fix this, templates are taken into accout in the MenuTreeOperationManager 
class.

[1] https://issues.openbravo.com/view.php?id=25906

diffstat:

 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/treeChecks/MenuTreeOperationManager.java
 |  15 ++++++++-
 1 files changed, 13 insertions(+), 2 deletions(-)

diffs (51 lines):

diff -r e6a5485a8001 -r f1360ce4b3d1 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/treeChecks/MenuTreeOperationManager.java
--- 
a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/treeChecks/MenuTreeOperationManager.java
    Tue Feb 24 12:33:15 2015 -0500
+++ 
b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/treeChecks/MenuTreeOperationManager.java
    Mon Mar 02 13:45:56 2015 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -23,7 +23,9 @@
 
 import javax.enterprise.context.ApplicationScoped;
 
+import org.hibernate.criterion.Restrictions;
 import org.openbravo.client.kernel.ComponentProvider.Qualifier;
+import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.utility.OBMessageUtils;
 import org.openbravo.model.ad.module.Module;
@@ -33,6 +35,7 @@
 @ApplicationScoped
 @Qualifier("ADMenu")
 public class MenuTreeOperationManager extends CheckTreeOperationManager {
+  private final String TEMPLATE_TYPE = "T";
 
   /**
    * Only allows to move a node if it belong to a module that is in development
@@ -42,11 +45,19 @@
       String newParentId, String prevNodeId, String nextNodeId) {
     Menu menuEntry = OBDal.getInstance().get(Menu.class, nodeId);
     Module module = menuEntry.getModule();
-    if (module != null && !module.isInDevelopment()) {
+
+    if (module != null && !module.isInDevelopment() && 
!areThereTemplatesInDevelopment()) {
       return new ActionResponse(false, "error",
           OBMessageUtils.messageBD("OBSERDS_ReparentNotInDevTreeNode"));
     } else {
       return new ActionResponse(true);
     }
   }
+
+  private boolean areThereTemplatesInDevelopment() {
+    OBCriteria<Module> templatesInDevelopmentCriteria = 
OBDal.getInstance().createCriteria(Module.class);
+    templatesInDevelopmentCriteria.add(Restrictions.eq(Module.PROPERTY_TYPE, 
TEMPLATE_TYPE));
+    
templatesInDevelopmentCriteria.add(Restrictions.eq(Module.PROPERTY_INDEVELOPMENT,
 true));
+    return (templatesInDevelopmentCriteria.count() > 0);
+  }
 }

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to