1 /*******************************************************************************
2 * Copyright � Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
3 * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
4 * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
6 * This file is part of the work and learning management system Pentila Nero.
8 * Pentila Nero is free software. You can redistribute it and/or modify since
9 * you respect the terms of either (at least one of the both license) :
10 * - under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 * - the CeCILL-C as published by CeCILL-C; either version 1 of the
14 * License, or any later version
15 * - the GNU Lesser General Public License as published by the
16 * Free Software Foundation, either version 3 of the license,
17 * or (at your option) any later version.
19 * There are special exceptions to the terms and conditions of the
20 * licenses as they are applied to this software. View the full text of
21 * the exception in file LICENSE-PROJECT.txt in the directory of this software
24 * Pentila Nero is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * Licenses for more details.
29 * You should have received a copy of the GNU Affero General Public License
30 * and the CeCILL-C and the GNU Lesser General Public License along with
31 * Pentila Nero. If not, see :
32 * <http://www.gnu.org/licenses/> and
33 * <http://www.cecill.info/licences.fr.html>.
34 ******************************************************************************/
35 package com.pentila.entSavoie.listeners;
37 import java.util.List;
39 import com.liferay.portal.ModelListenerException;
40 import com.liferay.portal.kernel.exception.SystemException;
41 import com.liferay.portal.model.Group;
42 import com.liferay.portal.model.ModelListener;
43 import com.pentila.entSavoie.applicationManager.service.AMSingleUsersLocalServiceUtil;
44 import com.pentila.entSavoie.carnetDAdresses.model.Fiche;
45 import com.pentila.entSavoie.carnetDAdresses.model.Liste;
46 import com.pentila.entSavoie.carnetDAdresses.service.FicheLocalServiceUtil;
47 import com.pentila.entSavoie.carnetDAdresses.service.ListeLocalServiceUtil;
48 import com.pentila.entSavoie.cartable.model.CasierEntry;
49 import com.pentila.entSavoie.cartable.service.CasierEntryLocalServiceUtil;
51 public class ENTGroupListener implements ModelListener<Group> {
53 public void onAfterAddAssociation(Object arg0, String arg1, Object arg2)
54 throws ModelListenerException {
55 // TODO Auto-generated method stub
59 public void onAfterCreate(Group arg0) throws ModelListenerException {
60 // TODO Auto-generated method stub
64 public void onAfterRemove(Group arg0) throws ModelListenerException {
65 // TODO Auto-generated method stub
69 public void onAfterRemoveAssociation(Object arg0, String arg1, Object arg2)
70 throws ModelListenerException {
71 // TODO Auto-generated method stub
75 public void onAfterUpdate(Group arg0) throws ModelListenerException {
76 // TODO Auto-generated method stub
80 public void onBeforeAddAssociation(Object arg0, String arg1, Object arg2)
81 throws ModelListenerException {
82 // TODO Auto-generated method stub
86 public void onBeforeCreate(Group arg0) throws ModelListenerException {
87 // TODO Auto-generated method stub
91 public void onBeforeRemove(Group grp) throws ModelListenerException {
94 long myUserGroupId = grp.getGroupId();
95 long companyId = grp.getCompanyId();
96 long userId = grp.getCreatorUserId();
97 // ** ** Suppression des infos utilisateur relatifs aux service de l'ENT ** **
98 //suite dans le fichier : com.pentila.entSavoie.listeners.UserPassowrdListener
101 //APPLICATION MANAGER
103 AMSingleUsersLocalServiceUtil.deleteByUserId(userId);
104 } catch (SystemException e) {
107 System.out.println("deleting Single users");
110 //on recupere les fiches et on les supprimes
111 List<Fiche> fiches = null;
113 fiches = FicheLocalServiceUtil.findByGroupId(myUserGroupId);
114 } catch (SystemException e) {
117 System.out.println("deleting fiches");
118 for (Fiche f : fiches){
120 FicheLocalServiceUtil.deleteFiche(f);
121 } catch (SystemException e) {
125 //on recupere les listes et on les supprimes
126 List<Liste> lists = null;
128 lists = ListeLocalServiceUtil.findByGroupId(myUserGroupId);
129 } catch (SystemException e) {
132 System.out.println("deleting listes");
133 for (Liste l : lists){
135 ListeLocalServiceUtil.deleteListe(l);
136 } catch (SystemException e) {
142 List<CasierEntry> casierEntries = null;
144 casierEntries = CasierEntryLocalServiceUtil.findByC_G(companyId, myUserGroupId);
145 } catch (SystemException e) {
148 System.out.println("deleting casier entry");
149 for(CasierEntry ce : casierEntries){
151 CasierEntryLocalServiceUtil.deleteCasierEntry(ce);
152 } catch (SystemException e) {
160 public void onBeforeRemoveAssociation(Object arg0, String arg1, Object arg2)
161 throws ModelListenerException {
162 // TODO Auto-generated method stub
166 public void onBeforeUpdate(Group arg0) throws ModelListenerException {
167 // TODO Auto-generated method stub