[roleInheritance] Replace usage of getId() with DalUtil.getId()
authorCarlos Aristu <carlos.aristu@openbravo.com>
Thu, 01 Oct 2015 17:12:35 +0200
changeset 27789 8780c766a8c7
parent 27788 026fba00f6f7
child 27790 74ee8fbfd426
[roleInheritance] Replace usage of getId() with DalUtil.getId()
src/org/openbravo/roleInheritance/RoleInheritanceEventHandler.java
src/org/openbravo/roleInheritance/RoleInheritanceManager.java
--- a/src/org/openbravo/roleInheritance/RoleInheritanceEventHandler.java	Thu Oct 01 16:02:38 2015 +0200
+++ b/src/org/openbravo/roleInheritance/RoleInheritanceEventHandler.java	Thu Oct 01 17:12:35 2015 +0200
@@ -95,7 +95,7 @@
   private boolean existCycles(Role role, String roleIdToFind) {
     boolean result = false;
     for (RoleInheritance ri : role.getADRoleInheritanceInheritFromList()) {
-      if (roleIdToFind.equals(ri.getRole().getId())) {
+      if (roleIdToFind.equals((String) DalUtil.getId(ri.getRole()))) {
         return true;
       }
       result = existCycles(ri.getRole(), roleIdToFind);
--- a/src/org/openbravo/roleInheritance/RoleInheritanceManager.java	Thu Oct 01 16:02:38 2015 +0200
+++ b/src/org/openbravo/roleInheritance/RoleInheritanceManager.java	Thu Oct 01 17:12:35 2015 +0200
@@ -290,7 +290,7 @@
       whereClause.append(" where p.").append(roleProperty).append(" = :roleId");
       addEntityWhereClause(whereClause, className);
       final OBQuery<T> query = OBDal.getInstance().createQuery(clazz, whereClause.toString());
-      query.setNamedParameter("roleId", role.getId());
+      query.setNamedParameter("roleId", (String) DalUtil.getId(role));
       doEntityParameterReplacement(query, className);
       query.setFilterOnActive(false);
       return (List<? extends InheritedAccessEnabled>) query.list();
@@ -907,11 +907,14 @@
     final OBCriteria<RoleInheritance> obCriteria = OBDal.getInstance().createCriteria(
         RoleInheritance.class);
     obCriteria.add(Restrictions.eq(RoleInheritance.PROPERTY_ROLE, inheritance.getRole()));
-    obCriteria.add(Restrictions.ne(RoleInheritance.PROPERTY_ID, inheritance.getId()));
+    obCriteria
+        .add(Restrictions.ne(RoleInheritance.PROPERTY_ID, (String) DalUtil.getId(inheritance)));
     obCriteria.addOrderBy(RoleInheritance.PROPERTY_SEQUENCENUMBER, true);
     boolean added = false;
     for (RoleInheritance rh : obCriteria.list()) {
-      if (rh.getInheritFrom().getId().equals(inheritance.getInheritFrom().getId())) {
+      String inheritFromId = (String) DalUtil.getId(rh.getInheritFrom());
+      String inheritanceInheritFromId = (String) DalUtil.getId(inheritance.getInheritFrom());
+      if (inheritFromId.equals(inheritanceInheritFromId)) {
         Utility.throwErrorMessage("RoleInheritanceInheritFromDuplicated");
       } else if (rh.getSequenceNumber().equals(inheritance.getSequenceNumber())) {
         Utility.throwErrorMessage("RoleInheritanceSequenceNumberDuplicated");