Author: echatellier Date: 2014-06-09 19:07:41 +0200 (Mon, 09 Jun 2014) New Revision: 161 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/161 Log: Suppression des ?\195?\169tats d'attente Added: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EtatAttenteTopiaDao.java Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ReferentielService.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js Added: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EtatAttenteTopiaDao.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EtatAttenteTopiaDao.java (rev 0) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EtatAttenteTopiaDao.java 2014-06-09 17:07:41 UTC (rev 161) @@ -0,0 +1,46 @@ +package com.franciaflex.faxtomail.persistence.entities; + +/* + * #%L + * FaxToMail :: Persistence + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class EtatAttenteTopiaDao extends AbstractEtatAttenteTopiaDao<EtatAttente> { + + public Map<String, Long> getEtatAttenteCountByFolder() { + String query = "SELECT etatAttente.topiaId, count(*) FROM " + Email.class.getName() + " group by etatAttente.topiaId"; + + Map<String, Long> result = new HashMap<>(); + + List<Object[]> queryResuts = findAll(query); + for (Object[] queryResut : queryResuts) { + String etatAttente = (String)queryResut[0]; + Long count = (Long)queryResut[1]; + result.put(etatAttente, count); + } + return result; + } +} //EtatAttenteTopiaDao Property changes on: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EtatAttenteTopiaDao.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ReferentielService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ReferentielService.java 2014-06-09 16:41:07 UTC (rev 160) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ReferentielService.java 2014-06-09 17:07:41 UTC (rev 161) @@ -49,6 +49,7 @@ import com.franciaflex.faxtomail.persistence.entities.DemandTypeTopiaDao; import com.franciaflex.faxtomail.persistence.entities.EmailAccount; import com.franciaflex.faxtomail.persistence.entities.EmailAccountTopiaDao; +import com.franciaflex.faxtomail.persistence.entities.EmailTopiaDao; import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.EtatAttenteImpl; import com.franciaflex.faxtomail.persistence.entities.EtatAttenteTopiaDao; @@ -97,6 +98,12 @@ return new ArrayList<>(dao.findAll()); } + public Map<String, Long> getEtatAttentesUsage() { + EtatAttenteTopiaDao dao = getPersistenceContext().getEtatAttenteDao(); + Map<String, Long> result = dao.getEtatAttenteCountByFolder(); + return result; + } + public void saveEtatAttente(Collection<EtatAttente> etatAttentes) { Binder<EtatAttente, EtatAttente> binderEtatAttente = BinderFactory.newBinder(EtatAttente.class); @@ -126,6 +133,9 @@ etatAttenteDAO.create(currentEtatAttente); } } + + // delete remaining + etatAttenteDAO.deleteAll(allEtatAttenteIndex.values()); getPersistenceContext().commit(); } Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java 2014-06-09 16:41:07 UTC (rev 160) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java 2014-06-09 17:07:41 UTC (rev 161) @@ -77,6 +77,8 @@ protected List<EtatAttente> etatAttentes; + protected Map<String, Long> etatAttentesUsage; + protected List<DemandType> demandTypes; protected List<MailFolder> mailFolders; @@ -100,6 +102,7 @@ @Action("configuration-input") public String input() throws Exception { etatAttentes = referentielService.getAllEtatAttente(); + etatAttentesUsage = referentielService.getEtatAttentesUsage(); demandTypes = referentielService.getAllDemandType(); mailFolders = mailFolderService.getRootMailFolders(); mailFoldersUsage = mailFolderService.getMailFoldersUsage(); @@ -155,6 +158,10 @@ this.etatAttentes = getGson().fromJson(json, type); } + public Map<String, Long> getEtatAttentesUsage() { + return etatAttentesUsage; + } + public List<DemandType> getDemandTypes() { return demandTypes; } Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-09 16:41:07 UTC (rev 160) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-09 17:07:41 UTC (rev 161) @@ -42,6 +42,7 @@ // datas 'configuration': <s:property value="toJson(configuration)" escapeHtml="false"/>, 'etatAttentes': <s:property value="toJson(etatAttentes)" escapeHtml="false"/>, + 'etatAttentesUsage': <s:property value="toJson(etatAttentesUsage)" escapeHtml="false"/>, 'demandTypes': <s:property value="toJson(demandTypes)" escapeHtml="false"/>, 'mailFolders': <s:property value="toJson(mailFolders)" escapeHtml="false"/>, 'mailFoldersUsage': <s:property value="toJson(mailFoldersUsage)" escapeHtml="false"/>, @@ -140,7 +141,13 @@ <tr ng-repeat="etatAttente in etatAttentes" ng-class="{'info' : etatAttente == selectedEtatAttente}" ng-click="editEtatAttente(etatAttente)"> - <td>{{etatAttente.label}}</td> + <td>{{etatAttente.label}} + + <a class="pull-right btn btn-danger btn-xs" data-nodrag ng-click="deleteEtatAttente($index)" + ng-disabled="etatAttentesUsage[etatAttente.topiaId] > 0" + tooltip="{{etatAttentesUsage[etatAttente.topiaId] > 0 && 'Cet état d\'attente est utilisé et ne peut pas être supprimé'|| 'Supprimer cet état d\'attente'}}"> + <span class="glyphicon glyphicon-remove"></span></a> + </td> </tr> </tbody> </table> Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-09 16:41:07 UTC (rev 160) +++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-09 17:07:41 UTC (rev 161) @@ -124,7 +124,8 @@ */ ConfigurationModule.controller('ConfigurationEtatAttenteController', ['$scope', '$window', 'ConfigurationData', function($scope, $window, ConfigurationData) { - + //{Map} Usage des états d'attente + $scope.etatAttentesUsage = ConfigurationData.etatAttentesUsage; //{Object} etat d'attente selectionné $scope.selectedEtatAttente; @@ -157,6 +158,13 @@ } }; + // suppression d'un etat d'attente non utilisé + $scope.deleteEtatAttente = function(index) { + if ($window.confirm("Êtes-vous sûr de vouloir supprimer cet état d'attente ?")) { + $scope.etatAttentes.splice(index, 1); + } + }; + // selection/deselection d'une action $scope.changeEtatAttenteValidAction = function(action) { var index = $scope.selectedEtatAttente.validFormDisabledActions.indexOf(action);