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,14 +126,24 @@ 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[] {
"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); qDoms.setParameter("pac", pacName);
List<?> domsList = qDoms.getResultList(); List<?> domsList = qDoms.getResultList();
for (Object o : domsList) { for (Object o : domsList) {
if (o instanceof Domain) { if (o instanceof AbstractEntity) {
helperModule.delete((AbstractEntity) o); helperModule.delete((AbstractEntity) o);
} }
} }
}
for (UnixUser user : pac.getUnixUser()) { for (UnixUser user : pac.getUnixUser()) {
if (!pacName.equals(user.getName())) { if (!pacName.equals(user.getName())) {