delete pac databases

This commit is contained in:
Peter Hormanns 2011-07-28 13:29:55 +00:00
parent f8de19dd0d
commit 87f15fdba6

View File

@ -126,15 +126,25 @@ public class PacModuleImpl extends AbstractModuleImpl {
} }
GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction()); GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
Query qDoms = em.createQuery("SELECT dom FROM Domains dom WHERE dom.user.pac.name = :pac"); String[] dependQueries = new String[] {
qDoms.setParameter("pac", pacName); "SELECT dom FROM Domains dom WHERE dom.user.pac.name = :pac",
List<?> domsList = qDoms.getResultList(); "SELECT db FROM MySqlDatabases db WHERE db.pac.name = :pac",
for (Object o : domsList) { "SELECT db FROM PgSqlDatabases db WHERE db.pac.name = :pac",
if (o instanceof Domain) { "SELECT dbusr FROM MySqlUsers dbusr WHERE dbusr.pac.name = :pac",
helperModule.delete((AbstractEntity) o); "SELECT dbusr FROM PgSqlUsers dbusr WHERE dbusr.pac.name = :pac",
};
for (String queryString : dependQueries) {
Query qDoms = em.createQuery(queryString);
qDoms.setParameter("pac", pacName);
List<?> domsList = qDoms.getResultList();
for (Object o : domsList) {
if (o instanceof AbstractEntity) {
helperModule.delete((AbstractEntity) o);
}
} }
} }
for (UnixUser user : pac.getUnixUser()) { for (UnixUser user : pac.getUnixUser()) {
if (!pacName.equals(user.getName())) { if (!pacName.equals(user.getName())) {
helperModule.delete(user); helperModule.delete(user);