From 87f15fdba6d599fae4abe79272ca5db03e296fec Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 28 Jul 2011 13:29:55 +0000 Subject: [PATCH] delete pac databases --- .../de/hsadmin/mods/pac/PacModuleImpl.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java index adfbc60..8cad528 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java @@ -126,15 +126,25 @@ public class PacModuleImpl extends AbstractModuleImpl { } GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction()); - Query qDoms = em.createQuery("SELECT dom FROM Domains dom WHERE dom.user.pac.name = :pac"); - qDoms.setParameter("pac", pacName); - List domsList = qDoms.getResultList(); - for (Object o : domsList) { - if (o instanceof Domain) { - helperModule.delete((AbstractEntity) o); + String[] dependQueries = new String[] { + "SELECT dom FROM Domains dom WHERE dom.user.pac.name = :pac", + "SELECT db FROM MySqlDatabases db WHERE db.pac.name = :pac", + "SELECT db FROM PgSqlDatabases db WHERE db.pac.name = :pac", + "SELECT dbusr FROM MySqlUsers dbusr WHERE dbusr.pac.name = :pac", + "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()) { if (!pacName.equals(user.getName())) { helperModule.delete(user);