dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21770
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10403: Denying delete of user group if it is used for sharing for now
------------------------------------------------------------
revno: 10403
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-03-22 11:47:34 +0100
message:
Denying delete of user group if it is used for sharing for now
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserGroupDeletionHandler.java
dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserGroupDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserGroupDeletionHandler.java 2012-07-01 11:33:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserGroupDeletionHandler.java 2013-03-22 10:47:34 +0000
@@ -30,6 +30,8 @@
import java.util.Iterator;
import org.hisp.dhis.system.deletion.DeletionHandler;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
/**
* @author Lars Helge Overland
@@ -47,6 +49,9 @@
{
this.userGroupService = userGroupService;
}
+
+ @Autowired
+ private JdbcTemplate jdbcTemplate;
// -------------------------------------------------------------------------
// DeletionHandler implementation
@@ -58,6 +63,7 @@
return UserGroup.class.getSimpleName();
}
+ @Override
public void deleteUser( User user )
{
Iterator<UserGroup> iterator = user.getGroups().iterator();
@@ -69,4 +75,12 @@
userGroupService.updateUserGroup( group );
}
}
+
+ @Override
+ public String allowDeleteUserGroup( UserGroup group )
+ {
+ int count = jdbcTemplate.queryForInt( "select count(*) from usergroupaccess where usergroupid=" + group.getId() );
+
+ return count == 0 ? null : "";
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2013-03-20 09:35:04 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2013-03-22 10:47:34 +0000
@@ -160,6 +160,7 @@
code_from_email=Code from email
password_hint=Minimum 8 characters, 1 upper-case and 1 digit
optional=Optional
+object_not_deleted_associated_by_objects=Object was not deleted because it is used by other objects:
#-- PeriodTypes ----------------------------------------------------------------#