r103 - in trunk: faxtomail-persistence/src/main/java/com/franciaflex/faxtomail faxtomail-persistence/src/main/resources/i18n faxtomail-persistence/src/main/xmi faxtomail-service faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service faxtomail-service/src/test/resources faxtomail-service/src/test/resources/csv fax
Author: echatellier Date: 2014-05-27 18:37:04 +0200 (Tue, 27 May 2014) New Revision: 103 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/103 Log: refs #4661: [TECH] R?\195?\169f?\195?\169rentiels Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/DemandTypeImportModel.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EtatAttenteImportModel.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/PriorityImportModel.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/RangeImportModel.java trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestData.java trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/ReferentielServiceTest.java trunk/faxtomail-service/src/test/resources/csv/ trunk/faxtomail-service/src/test/resources/csv/clients.csv trunk/faxtomail-service/src/test/resources/csv/demandtypes.csv trunk/faxtomail-service/src/test/resources/csv/email_accounts.csv trunk/faxtomail-service/src/test/resources/csv/email_filters.csv trunk/faxtomail-service/src/test/resources/csv/etatattentes.csv trunk/faxtomail-service/src/test/resources/csv/priorities.csv trunk/faxtomail-service/src/test/resources/csv/ranges.csv Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo trunk/faxtomail-service/pom.xml trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ReferentielService.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EmailAccountImportModel.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EmailFilterImportModel.java trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/AbstractFaxToMailServiceTest.java trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MailFolderServiceTest.java trunk/faxtomail-ui-web/pom.xml trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/json/HibernateProxyTypeAdapter.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/json/TopiaEntityAdapter.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 trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java 2014-05-27 16:37:04 UTC (rev 103) @@ -216,26 +216,25 @@ return jpaParameters; } - /** - * @return Le nom d'hôte du serveur SMTP. - */ public String getSmtpHost() { return applicationConfig.getOption(FaxToMailConfigurationOption.SMTP_HOST.getKey()); } - /** - * @return Le port du serveur SMTP. - */ public int getSmtpPort() { return applicationConfig.getOptionAsInt(FaxToMailConfigurationOption.SMTP_PORT.getKey()); } - - /** - * @return L'adresse d'expéditeur pour les mails de notifications - */ - public String getSmtpFrom() { - return applicationConfig.getOption(FaxToMailConfigurationOption.SMTP_FROM.getKey()); + + public String getSmtpUser() { + return applicationConfig.getOption(FaxToMailConfigurationOption.SMTP_USER.getKey()); } + + public String getSmtpPassword() { + return applicationConfig.getOption(FaxToMailConfigurationOption.SMTP_PASSWORD.getKey()); + } + + public boolean getSmtpUseSsl() { + return applicationConfig.getOptionAsBoolean(FaxToMailConfigurationOption.SMTP_SSL.getKey()); + } public String getInstanceUrl() { return applicationConfig.getOption(FaxToMailConfigurationOption.INSTANCE_URL.getKey()); @@ -290,6 +289,12 @@ File result = applicationConfig.getOptionAsFile(FaxToMailConfigurationOption.BASEDIR.getKey()); return result; } + + /** @return {@link FaxToMailConfigurationOption#DEMO_DIRECTORY} value */ + public File getDemoDirectory() { + File result = applicationConfig.getOptionAsFile(FaxToMailConfigurationOption.DEMO_DIRECTORY.getKey()); + return result; + } /** @return {@link FaxToMailConfigurationOption#DATA_DIRECTORY} value */ public File getDataDirectory() { Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java 2014-05-27 16:37:04 UTC (rev 103) @@ -48,20 +48,30 @@ null, String.class), SMTP_HOST( - "smtp.host", + "faxtomail.smtp.host", "Nom d'hôte du serveur SMTP", - "", String.class), + null, String.class), SMTP_PORT( - "smtp.port", + "faxtomail.smtp.port", "Le port du serveur SMTP", "25", Integer.class), - SMTP_FROM( - "smtp.from", - "L'adresse d'expéditeur pour les mails de notifications", - "", String.class), + SMTP_USER( + "faxtomail.smtp.user", + "Utilisateur du serveur smtp", + null, String.class), + SMTP_PASSWORD( + "faxtomail.smtp.password", + "Mot de passe de l'utilisateur du smtp", + null, String.class), + + SMTP_SSL( + "faxtomail.smtp.ssl", + "Utilisation on non du mode ssl pour le stmp", + "false", Boolean.class), + DEV_MODE( "faxtomail.devMode", "Mode développement, court-circuite l'envoi de mail", @@ -126,6 +136,13 @@ File.class, true ), + + DEMO_DIRECTORY( + "faxtomail.demo.directory", + n("faxtomail.config.option.demo.directory.description"), + "${faxtomail.basedir}/demo", + File.class, + true), DATA_DIRECTORY( "faxtomail.data.directory", Modified: trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties =================================================================== --- trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-persistence/src/main/resources/i18n/faxtomail-persistence_fr_FR.properties 2014-05-27 16:37:04 UTC (rev 103) @@ -2,6 +2,7 @@ faxtomail.config.option.basedir.description= faxtomail.config.option.csv.separator.description= faxtomail.config.option.data.directory.description= +faxtomail.config.option.demo.directory.description= faxtomail.config.option.edi.directory.description= faxtomail.config.option.i18n.directory.description= faxtomail.config.option.i18n.locale.description= Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties =================================================================== --- trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties 2014-05-27 16:37:04 UTC (rev 103) @@ -52,3 +52,5 @@ # DemandType com.franciaflex.faxtomail.persistence.entities.DemandType.attribute.label.tagvalue.naturalId=true +# Client +#com.franciaflex.faxtomail.persistence.entities.Client.attribute.emailAddress.tagvalue.naturalId=true Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo =================================================================== (Binary files differ) Modified: trunk/faxtomail-service/pom.xml =================================================================== --- trunk/faxtomail-service/pom.xml 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-service/pom.xml 2014-05-27 16:37:04 UTC (rev 103) @@ -124,6 +124,11 @@ <groupId>org.apache.commons</groupId> <artifactId>commons-email</artifactId> </dependency> + + <dependency> + <groupId>javax.activation</groupId> + <artifactId>activation</artifactId> + </dependency> <!-- Logging --> <dependency> Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-05-27 16:37:04 UTC (rev 103) @@ -489,30 +489,17 @@ Email email = getEmailById(originalEmailId); - Properties properties = new Properties(); + final String smtpUser = getApplicationConfig().getSmtpUser(); + final String password = getApplicationConfig().getSmtpPassword(); + final boolean useSsl = getApplicationConfig().getSmtpUseSsl(); - try { - URL smtpPropertiesURL = ClassLoader.getSystemResource("smtp.properties"); - if (smtpPropertiesURL != null) { - properties.load(smtpPropertiesURL.openStream()); - } - } catch(Exception e) { - log.error("error getting the smtp properties", e); - } - - final String smtpUser = properties.getProperty("mail.user"); - final String password = properties.getProperty("mail.password"); - final String useSsl = properties.getProperty("mail.ssl"); - MultiPartEmail message = new MultiPartEmail(); - message.setHostName(properties.getProperty("mail.smtp.host")); - message.setSmtpPort(Integer.parseInt(properties.getProperty("mail.smtp.port"))); + message.setHostName(getApplicationConfig().getSmtpHost()); + message.setSmtpPort(getApplicationConfig().getSmtpPort()); if (StringUtils.isNotBlank(smtpUser) && password != null) { message.setAuthenticator(new DefaultAuthenticator(smtpUser, password)); } - if ("true".equalsIgnoreCase(useSsl)) { - message.setSSLOnConnect(true); - } + message.setSSLOnConnect(useSsl); message.setCharset(EmailConstants.UTF_8); message.setFrom(from); Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java 2014-05-27 16:37:04 UTC (rev 103) @@ -52,13 +52,16 @@ import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; import com.google.common.collect.Lists; import com.google.common.collect.Sets; + import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.SystemUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; import org.nuiton.jaxx.application.ApplicationTechnicalException; import java.io.File; +import java.io.FileInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.Calendar; @@ -282,8 +285,10 @@ folders.put("Jeanne", jeanneFolder); // email accounts + File demoDirectory = getApplicationConfig().getDemoDirectory(); + File emailAcountFile = new File(demoDirectory, "email_accounts.csv"); try { - InputStream emailAccountsPropertiesStream = ClassLoader.getSystemResourceAsStream("email_accounts.csv"); + InputStream emailAccountsPropertiesStream = new FileInputStream(emailAcountFile); if (emailAccountsPropertiesStream != null) { getReferentielService().importEmailAccounts(emailAccountsPropertiesStream); } @@ -293,8 +298,9 @@ } // email filters + File emailFilterFile = new File(demoDirectory, "email_filters.csv"); try { - InputStream emailFiltersPropertiesStream = ClassLoader.getSystemResourceAsStream("email_filters.csv"); + InputStream emailFiltersPropertiesStream = new FileInputStream(emailFilterFile); if (emailFiltersPropertiesStream != null) { getReferentielService().importEmailFilters(emailFiltersPropertiesStream, folders); } @@ -311,8 +317,9 @@ userGroupDao.create(FaxToMailUserGroup.PROPERTY_NAME, "Administrateurs"); // clients and emails + File clientFile = new File(demoDirectory, "fx_clients.csv"); try { - InputStream fxClientsStream = ClassLoader.getSystemResourceAsStream("fx_clients.csv"); + InputStream fxClientsStream = new FileInputStream(clientFile); if (fxClientsStream != null) { List<Client> clients = getReferentielService().importClients(fxClientsStream); Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java 2014-05-27 16:37:04 UTC (rev 103) @@ -58,7 +58,7 @@ public MailFolder getFolderForRecipient(String recipient) { MailFilterTopiaDao filterTopiaDao = getPersistenceContext().getMailFilterDao(); - PaginationParameter tpb = PaginationParameter.of(-1, -1, MailFilter.PROPERTY_POSITION, false); + PaginationParameter tpb = PaginationParameter.of(0, -1, MailFilter.PROPERTY_POSITION, false); String query = "FROM " + MailFilter.class.getCanonicalName() + " WHERE :recipient LIKE " + MailFilter.PROPERTY_EXPRESSION; Map<String, Object> params = new HashMap<>(); 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-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ReferentielService.java 2014-05-27 16:37:04 UTC (rev 103) @@ -60,8 +60,12 @@ import com.franciaflex.faxtomail.persistence.entities.RangeTopiaDao; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; import com.franciaflex.faxtomail.services.service.imports.ClientImportModel; +import com.franciaflex.faxtomail.services.service.imports.DemandTypeImportModel; import com.franciaflex.faxtomail.services.service.imports.EmailAccountImportModel; import com.franciaflex.faxtomail.services.service.imports.EmailFilterImportModel; +import com.franciaflex.faxtomail.services.service.imports.EtatAttenteImportModel; +import com.franciaflex.faxtomail.services.service.imports.PriorityImportModel; +import com.franciaflex.faxtomail.services.service.imports.RangeImportModel; import com.google.common.collect.Maps; /** @@ -164,18 +168,11 @@ EmailAccountTopiaDao dao = getPersistenceContext().getEmailAccountDao(); EmailAccountImportModel emailAccountImportModel = new EmailAccountImportModel(';'); - try { - Import<EmailAccount> importer = Import.newImport(emailAccountImportModel, inputStream); - try { - for (EmailAccount emailAccount : importer) { - result.add(dao.create(emailAccount)); - } - getPersistenceContext().commit(); - - } finally { - IOUtils.closeQuietly(importer); + try (Import<EmailAccount> importer = Import.newImport(emailAccountImportModel, inputStream)) { + for (EmailAccount emailAccount : importer) { + result.add(dao.create(emailAccount)); } - + getPersistenceContext().commit(); } catch (ImportRuntimeException e) { String message; if (e.getCause() != null) { @@ -196,18 +193,80 @@ MailFilterTopiaDao dao = getPersistenceContext().getMailFilterDao(); EmailFilterImportModel emailFilterImportModel = new EmailFilterImportModel(';', foldersByName); - try { - Import<MailFilter> importer = Import.newImport(emailFilterImportModel, inputStream); - try { - for (MailFilter emailFilter : importer) { - result.add(dao.create(emailFilter)); + try (Import<MailFilter> importer = Import.newImport(emailFilterImportModel, inputStream)) { + for (MailFilter emailFilter : importer) { + result.add(dao.create(emailFilter)); + } + getPersistenceContext().commit(); + + } catch (ImportRuntimeException e) { + String message; + if (e.getCause() != null) { + message = e.getCause().getMessage(); + } else { + message = e.getMessage(); + } + throw new ApplicationTechnicalException(message, e); + + } finally { + IOUtils.closeQuietly(inputStream); + } + return result; + } + + public List<EtatAttente> importEtatAttentes(InputStream inputStream) { + + List<EtatAttente> result = new ArrayList<>(); + EtatAttenteTopiaDao etatAttenteTopiaDao = getPersistenceContext().getEtatAttenteDao(); + + EtatAttenteImportModel importModel = new EtatAttenteImportModel(';'); + try (Import<EtatAttente> importer = Import.newImport(importModel, inputStream)) { + for (EtatAttente etatAttente : importer) { + + EtatAttente currentEtatAttente = etatAttenteTopiaDao.forLabelEquals(etatAttente.getLabel()).findAnyOrNull(); + if (currentEtatAttente == null) { + currentEtatAttente = etatAttenteTopiaDao.create(etatAttente); } - getPersistenceContext().commit(); + // else maybe update current ? + + result.add(currentEtatAttente); + } + getPersistenceContext().commit(); - } finally { - IOUtils.closeQuietly(importer); + } catch (ImportRuntimeException e) { + String message; + if (e.getCause() != null) { + message = e.getCause().getMessage(); + } else { + message = e.getMessage(); } + throw new ApplicationTechnicalException(message, e); + } finally { + IOUtils.closeQuietly(inputStream); + } + + return result; + } + + public List<Priority> importPriorities(InputStream inputStream) { + List<Priority> result = new ArrayList<>(); + PriorityTopiaDao priorityTopiaDao = getPersistenceContext().getPriorityDao(); + + PriorityImportModel importModel = new PriorityImportModel(';'); + try (Import<Priority> importer = Import.newImport(importModel, inputStream)) { + for (Priority priority : importer) { + + Priority currentPriority = priorityTopiaDao.forLabelEquals(priority.getLabel()).findAnyOrNull(); + if (currentPriority == null) { + currentPriority = priorityTopiaDao.create(priority); + } + // else maybe update current ? + + result.add(currentPriority); + } + getPersistenceContext().commit(); + } catch (ImportRuntimeException e) { String message; if (e.getCause() != null) { @@ -220,6 +279,73 @@ } finally { IOUtils.closeQuietly(inputStream); } + return result; } + + public List<Range> importRanges(InputStream inputStream) { + List<Range> result = new ArrayList<>(); + RangeTopiaDao rangeTopiaDao = getPersistenceContext().getRangeDao(); + + RangeImportModel importModel = new RangeImportModel(';'); + try (Import<Range> importer = Import.newImport(importModel, inputStream)) { + for (Range range : importer) { + + Range currentRange = rangeTopiaDao.forLabelEquals(range.getLabel()).findAnyOrNull(); + if (currentRange == null) { + currentRange = rangeTopiaDao.create(range); + } + // else maybe update current ? + + result.add(currentRange); + } + getPersistenceContext().commit(); + + } catch (ImportRuntimeException e) { + String message; + if (e.getCause() != null) { + message = e.getCause().getMessage(); + } else { + message = e.getMessage(); + } + throw new ApplicationTechnicalException(message, e); + + } finally { + IOUtils.closeQuietly(inputStream); + } + return result; + } + + public List<DemandType> importDemandTypes(InputStream inputStream) { + List<DemandType> result = new ArrayList<>(); + DemandTypeTopiaDao demandTypeTopiaDao = getPersistenceContext().getDemandTypeDao(); + + DemandTypeImportModel importModel = new DemandTypeImportModel(';'); + try (Import<DemandType> importer = Import.newImport(importModel, inputStream)) { + for (DemandType demandType : importer) { + + DemandType currentDemandType = demandTypeTopiaDao.forLabelEquals(demandType.getLabel()).findAnyOrNull(); + if (currentDemandType == null) { + currentDemandType = demandTypeTopiaDao.create(demandType); + } + // else maybe update current ? + + result.add(currentDemandType); + } + getPersistenceContext().commit(); + + } catch (ImportRuntimeException e) { + String message; + if (e.getCause() != null) { + message = e.getCause().getMessage(); + } else { + message = e.getMessage(); + } + throw new ApplicationTechnicalException(message, e); + + } finally { + IOUtils.closeQuietly(inputStream); + } + return result; + } } Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/DemandTypeImportModel.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/DemandTypeImportModel.java (rev 0) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/DemandTypeImportModel.java 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,47 @@ +package com.franciaflex.faxtomail.services.service.imports; + +/* + * #%L + * FaxToMail :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * 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 org.nuiton.csv.ext.AbstractImportModel; + +import com.franciaflex.faxtomail.persistence.entities.DemandType; +import com.franciaflex.faxtomail.persistence.entities.DemandTypeImpl; + +/** + * Modèle d'import des etat d'attente. + */ +public class DemandTypeImportModel extends AbstractImportModel<DemandType> { + + public DemandTypeImportModel(char separator) { + super(separator); + + newMandatoryColumn("demandetype", DemandType.PROPERTY_LABEL); + } + + @Override + public DemandType newEmptyInstance() { + return new DemandTypeImpl(); + } +} Property changes on: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/DemandTypeImportModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EmailAccountImportModel.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EmailAccountImportModel.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EmailAccountImportModel.java 2014-05-27 16:37:04 UTC (rev 103) @@ -26,11 +26,8 @@ import com.franciaflex.faxtomail.persistence.entities.EmailAccount; import com.franciaflex.faxtomail.persistence.entities.EmailAccountImpl; -import org.nuiton.csv.ValueParser; import org.nuiton.csv.ext.AbstractImportModel; -import java.text.ParseException; - /** * @author Kevin Morin (Code Lutin) * @since x.x Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EmailFilterImportModel.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EmailFilterImportModel.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EmailFilterImportModel.java 2014-05-27 16:37:04 UTC (rev 103) @@ -24,8 +24,6 @@ * #L% */ -import com.franciaflex.faxtomail.persistence.entities.EmailAccount; -import com.franciaflex.faxtomail.persistence.entities.EmailAccountImpl; import com.franciaflex.faxtomail.persistence.entities.MailFilter; import com.franciaflex.faxtomail.persistence.entities.MailFilterImpl; import com.franciaflex.faxtomail.persistence.entities.MailFolder; Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EtatAttenteImportModel.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EtatAttenteImportModel.java (rev 0) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EtatAttenteImportModel.java 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,47 @@ +package com.franciaflex.faxtomail.services.service.imports; + +/* + * #%L + * FaxToMail :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * 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 org.nuiton.csv.ext.AbstractImportModel; + +import com.franciaflex.faxtomail.persistence.entities.EtatAttente; +import com.franciaflex.faxtomail.persistence.entities.EtatAttenteImpl; + +/** + * Modèle d'import des etat d'attente. + */ +public class EtatAttenteImportModel extends AbstractImportModel<EtatAttente> { + + public EtatAttenteImportModel(char separator) { + super(separator); + + newMandatoryColumn("etatattente", EtatAttente.PROPERTY_LABEL); + } + + @Override + public EtatAttente newEmptyInstance() { + return new EtatAttenteImpl(); + } +} Property changes on: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/EtatAttenteImportModel.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/PriorityImportModel.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/PriorityImportModel.java (rev 0) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/PriorityImportModel.java 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,47 @@ +package com.franciaflex.faxtomail.services.service.imports; + +/* + * #%L + * FaxToMail :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * 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 org.nuiton.csv.ext.AbstractImportModel; + +import com.franciaflex.faxtomail.persistence.entities.Priority; +import com.franciaflex.faxtomail.persistence.entities.PriorityImpl; + +/** + * Modèle d'import des etat d'attente. + */ +public class PriorityImportModel extends AbstractImportModel<Priority> { + + public PriorityImportModel(char separator) { + super(separator); + + newMandatoryColumn("priorite", Priority.PROPERTY_LABEL); + } + + @Override + public Priority newEmptyInstance() { + return new PriorityImpl(); + } +} Property changes on: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/PriorityImportModel.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/RangeImportModel.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/RangeImportModel.java (rev 0) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/RangeImportModel.java 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,47 @@ +package com.franciaflex.faxtomail.services.service.imports; + +/* + * #%L + * FaxToMail :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * 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 org.nuiton.csv.ext.AbstractImportModel; + +import com.franciaflex.faxtomail.persistence.entities.Range; +import com.franciaflex.faxtomail.persistence.entities.RangeImpl; + +/** + * Modèle d'import des etat d'attente. + */ +public class RangeImportModel extends AbstractImportModel<Range> { + + public RangeImportModel(char separator) { + super(separator); + + newMandatoryColumn("gamme", Range.PROPERTY_LABEL); + } + + @Override + public Range newEmptyInstance() { + return new RangeImpl(); + } +} Property changes on: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/RangeImportModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/AbstractFaxToMailServiceTest.java =================================================================== --- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/AbstractFaxToMailServiceTest.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/AbstractFaxToMailServiceTest.java 2014-05-27 16:37:04 UTC (rev 103) @@ -29,6 +29,8 @@ import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaPersistenceContext; import com.franciaflex.faxtomail.services.FaxToMailService; import com.franciaflex.faxtomail.services.FaxToMailServiceContext; + +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.SystemUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -58,6 +60,8 @@ protected List<FaxToMailTopiaPersistenceContext> openedTransactions = new LinkedList<>(); + protected File databaseFile; + protected FaxToMailTopiaApplicationContext newApplicationContext(String dataBase) { Map<String, String> hibernateH2Config = new HashMap<String, String>(); @@ -71,7 +75,7 @@ File tempDirFile = SystemUtils.getJavaIoTmpDir(); - File databaseFile = new File(tempDirFile, dataBase); + databaseFile = new File(tempDirFile, dataBase); // Set test data in MSSQLServer mode (like production database) String h2dataPath = databaseFile.getAbsolutePath() + File.separator + "h2data-test;MODE=MSSQLServer"; @@ -102,7 +106,7 @@ return false; } - protected FaxToMailTopiaApplicationContext getApplicationContext () { + protected FaxToMailTopiaApplicationContext getApplicationContext() { String databaseName = UUID.randomUUID().toString(); @@ -214,7 +218,7 @@ } @After - public void tearDown() { + public void tearDown() throws IOException { for (FaxToMailTopiaPersistenceContext openedTransaction : openedTransactions) { @@ -236,6 +240,8 @@ } + // clear full directory + FileUtils.deleteDirectory(databaseFile); } protected static FaxToMailConfiguration getApplicationConfig() { Modified: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java =================================================================== --- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java 2014-05-27 16:37:04 UTC (rev 103) @@ -24,12 +24,10 @@ * #L% */ -import java.util.ArrayList; +import java.io.IOException; import java.util.Collections; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -45,8 +43,6 @@ */ public class EmailServiceTest extends AbstractFaxToMailServiceTest { - private static final Log log = LogFactory.getLog(MailFolderServiceTest.class); - protected EmailService service; protected ReferentielService referentielService; @@ -54,12 +50,11 @@ protected UserService userService; @Before - public void setUp() { + public void setUp() throws IOException { service = newService(EmailService.class); referentielService = newService(ReferentielService.class); userService = newService(UserService.class); - log.info("init sample data"); - newService(InitFaxToMailService.class).initSampleData(); + newService(InitTestData.class).initTestData(); } @Test @@ -68,17 +63,17 @@ // empty filter EmailFilter filter = new EmailFilter(); List<Email> emails = service.search(filter); - Assert.assertEquals(116, emails.size()); + Assert.assertEquals(10, emails.size()); // client code filter - filter.setClientCode("23"); + filter.setClientCode("9915"); emails = service.search(filter); - Assert.assertEquals(18, emails.size()); + Assert.assertEquals(10, emails.size()); // client code filter + subject filter - filter.setDemandObject("ARENO"); + filter.setDemandObject("A+"); emails = service.search(filter); - Assert.assertEquals(2, emails.size()); + Assert.assertEquals(0, emails.size()); // some other fields just to test query syntax filter.setMinReceptionDate(getServiceContext().getNow()); @@ -102,7 +97,6 @@ filter.setDemandStatus(Collections.singletonList(DemandStatus.ARCHIVED)); filter.setGamme(Collections.singletonList(referentielService.getAllRange().get(0))); filter.setPriority(referentielService.getAllPriority()); -// filter.setCommandNumber("test"); filter.setEtatAttente(Collections.singletonList(referentielService.getAllEtatAttente().get(0))); filter.setEdiCodeNumber("test"); filter.setLocalReference("test"); Added: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestData.java =================================================================== --- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestData.java (rev 0) +++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestData.java 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,291 @@ +package com.franciaflex.faxtomail.services.service; + +/* + * #%L + * FaxToMail :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * 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 static org.nuiton.i18n.I18n.t; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.decorator.Decorator; + +import com.franciaflex.faxtomail.persistence.entities.Client; +import com.franciaflex.faxtomail.persistence.entities.DemandStatus; +import com.franciaflex.faxtomail.persistence.entities.DemandType; +import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.EmailTopiaDao; +import com.franciaflex.faxtomail.persistence.entities.EtatAttente; +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserTopiaDao; +import com.franciaflex.faxtomail.persistence.entities.History; +import com.franciaflex.faxtomail.persistence.entities.HistoryTopiaDao; +import com.franciaflex.faxtomail.persistence.entities.HistoryType; +import com.franciaflex.faxtomail.persistence.entities.MailFolder; +import com.franciaflex.faxtomail.persistence.entities.MailFolderTopiaDao; +import com.franciaflex.faxtomail.persistence.entities.Priority; +import com.franciaflex.faxtomail.persistence.entities.Range; +import com.franciaflex.faxtomail.persistence.entities.RangeRow; +import com.franciaflex.faxtomail.persistence.entities.RangeRowTopiaDao; +import com.franciaflex.faxtomail.services.DecoratorService; +import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + +/** + * Test service to manage test data. + * + * @author Eric Chatellier + */ +public class InitTestData extends FaxToMailServiceSupport { + + private static final Log log = LogFactory.getLog(InitTestData.class); + + /** + * Import all test data. + * + * @throws IOException + */ + public void initTestData() throws IOException { + if (log.isDebugEnabled()) { + log.debug("Init test data"); + } + ReferentielService referentielService = newService(ReferentielService.class); + + // import etat attentes + List<EtatAttente> etatAttentes = null; + try (InputStream is = InitTestData.class.getResourceAsStream("/csv/etatattentes.csv")) { + etatAttentes = referentielService.importEtatAttentes(is); + } + + // create folders + MailFolderTopiaDao folderDao = getPersistenceContext().getMailFolderDao(); + Map<String, MailFolder> foldersByName = new HashMap<>(); + MailFolder franciaflex = folderDao.create(MailFolder.PROPERTY_NAME, "Franciaflex"); + + // categories + MailFolder chargesClientelle = folderDao.create(MailFolder.PROPERTY_NAME, "Chargés de clientèle", + MailFolder.PROPERTY_PARENT, franciaflex, + MailFolder.PROPERTY_REPLY_ADDRESSES, Lists.newArrayList("no-reply@franciaflex.com")); + franciaflex.addChildren(chargesClientelle); + foldersByName.put(chargesClientelle.getName(), chargesClientelle); + + MailFolder sav = folderDao.create(MailFolder.PROPERTY_NAME, "SAV", + MailFolder.PROPERTY_PARENT, franciaflex, + MailFolder.PROPERTY_ETAT_ATTENTE, etatAttentes.subList(0, 1)); + franciaflex.addChildren(sav); + foldersByName.put(sav.getName(), sav); + + // user folders + MailFolder cyrilFolder = folderDao.create(MailFolder.PROPERTY_NAME, "Cyril", + MailFolder.PROPERTY_PARENT, chargesClientelle, + MailFolder.PROPERTY_ETAT_ATTENTE, etatAttentes.subList(1, 2)); + chargesClientelle.addChildren(cyrilFolder); + foldersByName.put(cyrilFolder.getName(), cyrilFolder); + + MailFolder claireFolder = folderDao.create(MailFolder.PROPERTY_NAME, "Claire", + MailFolder.PROPERTY_PARENT, chargesClientelle); + chargesClientelle.addChildren(claireFolder); + foldersByName.put(claireFolder.getName(), claireFolder); + + MailFolder agatheFolder = folderDao.create(MailFolder.PROPERTY_NAME, "Agathe", + MailFolder.PROPERTY_PARENT, chargesClientelle, + MailFolder.PROPERTY_ETAT_ATTENTE, etatAttentes.subList(2, 3)); + chargesClientelle.addChildren(agatheFolder); + foldersByName.put(agatheFolder.getName(), agatheFolder); + + MailFolder marcFolder = folderDao.create(MailFolder.PROPERTY_NAME, "Marc", + MailFolder.PROPERTY_PARENT, sav); + sav.addChildren(marcFolder); + foldersByName.put(marcFolder.getName(), marcFolder); + + MailFolder fredericFolder = folderDao.create(MailFolder.PROPERTY_NAME, "Frédéric", + MailFolder.PROPERTY_PARENT, sav); + sav.addChildren(fredericFolder); + foldersByName.put(fredericFolder.getName(), fredericFolder); + + MailFolder jeanneFolder = folderDao.create(MailFolder.PROPERTY_NAME, "Jeanne", + MailFolder.PROPERTY_PARENT, sav); + sav.addChildren(jeanneFolder); + foldersByName.put(jeanneFolder.getName(), jeanneFolder); + + // create test users + FaxToMailUserTopiaDao userDao = getPersistenceContext().getFaxToMailUserDao(); + FaxToMailUser marc = userDao.create(FaxToMailUser.PROPERTY_LAST_NAME, "Lefèbvre", + FaxToMailUser.PROPERTY_FIRST_NAME, "Marc", + FaxToMailUser.PROPERTY_LOGIN, "mlefebvre", + FaxToMailUser.PROPERTY_TRIGRAPH, "MLE"); + FaxToMailUser cyril = userDao.create(FaxToMailUser.PROPERTY_LAST_NAME, "Baillet", + FaxToMailUser.PROPERTY_FIRST_NAME, "Cyril", + FaxToMailUser.PROPERTY_LOGIN, "cbaillet", + FaxToMailUser.PROPERTY_TRIGRAPH, "CBA"); + FaxToMailUser frederic = userDao.create(FaxToMailUser.PROPERTY_LAST_NAME, "Viala", + FaxToMailUser.PROPERTY_FIRST_NAME, "Frédéric", + FaxToMailUser.PROPERTY_LOGIN, "fviala", + FaxToMailUser.PROPERTY_TRIGRAPH, "FVI"); + FaxToMailUser claire = userDao.create(FaxToMailUser.PROPERTY_LAST_NAME, "Marquis", + FaxToMailUser.PROPERTY_FIRST_NAME, "Claire", + FaxToMailUser.PROPERTY_LOGIN, "cmarquis", + FaxToMailUser.PROPERTY_TRIGRAPH, "CMA"); + FaxToMailUser agathe = userDao.create(FaxToMailUser.PROPERTY_LAST_NAME, "Borde", + FaxToMailUser.PROPERTY_FIRST_NAME, "Agathe", + FaxToMailUser.PROPERTY_LOGIN, "aborde", + FaxToMailUser.PROPERTY_TRIGRAPH, "ABO"); + FaxToMailUser jeanne = userDao.create(FaxToMailUser.PROPERTY_LAST_NAME, "Bourgoin", + FaxToMailUser.PROPERTY_FIRST_NAME, "Jeanne", + FaxToMailUser.PROPERTY_LOGIN, "jbourgoin", + FaxToMailUser.PROPERTY_TRIGRAPH, "JBO"); + + // import test csv + List<Range> ranges = null; + try (InputStream is = InitTestData.class.getResourceAsStream("/csv/ranges.csv")) { + ranges = referentielService.importRanges(is); + } + List<Priority> priorities = null; + try (InputStream is = InitTestData.class.getResourceAsStream("/csv/priorities.csv")) { + priorities = referentielService.importPriorities(is); + } + try (InputStream is = InitTestData.class.getResourceAsStream("/csv/email_accounts.csv")) { + referentielService.importEmailAccounts(is); + } + List<Client> clients = null; + try (InputStream is = InitTestData.class.getResourceAsStream("/csv/clients.csv")) { + clients = referentielService.importClients(is); + } + List<DemandType> types = null; + try (InputStream is = InitTestData.class.getResourceAsStream("/csv/demandtypes.csv")) { + types = referentielService.importDemandTypes(is); + } + try (InputStream is = InitTestData.class.getResourceAsStream("/csv/email_filters.csv")) { + referentielService.importEmailFilters(is, foldersByName); + } + + // create test mail + HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao(); + RangeRowTopiaDao rangeRowDao = getPersistenceContext().getRangeRowDao(); + EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); + createEmails(historyDao, rangeRowDao, emailDao, ranges, clients, types, priorities, cyrilFolder, cyril); + } + + protected void createEmails(HistoryTopiaDao historyDao, RangeRowTopiaDao rangeRowDao, EmailTopiaDao emailDao, List<Range> ranges, + List<Client> clients, List<DemandType> types, List<Priority> priorities, MailFolder folder, FaxToMailUser user) + throws InvalidClientException { + for (int i = 0; i < 5; i++) { + createEmail(historyDao, rangeRowDao, emailDao, ranges, clients, types, priorities, folder, user); + } + } + + protected void createEmail(HistoryTopiaDao historyDao, RangeRowTopiaDao rangeRowDao, EmailTopiaDao emailDao, List<Range> ranges, + List<Client> clients, List<DemandType> types, List<Priority> priorities, MailFolder folder, FaxToMailUser user) + throws InvalidClientException { + + List<RangeRow> rangeRows = new ArrayList<>(); + + Client client = clients.get(0); + String sender = client.getEmailAddress(); + boolean fax = false; + if (sender == null && client.getFaxNumber() != null) { + sender = client.getFaxNumber(); + fax = true; + } + + boolean opened = true; //random.nextBoolean(); + + Decorator<Date> dateDecorator = getDecoratorService().getDecoratorByType(Date.class, DecoratorService.DATE); + + Date now = new Date(); + History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.CREATION, History.PROPERTY_FIELDS, Sets.newHashSet( + Email.PROPERTY_SENDER, Email.PROPERTY_CLIENT, Email.PROPERTY_PROJECT_REFERENCE, Email.PROPERTY_OBJECT, Email.PROPERTY_RECEPTION_DATE, + Email.PROPERTY_MAIL_FOLDER, Email.PROPERTY_DEMAND_STATUS), History.PROPERTY_MODIFICATION_DATE, now); + String projectRef = t("faxtomail.email.projectReference.default", dateDecorator.toString(now)); + + Email email = emailDao.create(Email.PROPERTY_SENDER, sender, Email.PROPERTY_FAX, fax, Email.PROPERTY_CLIENT, client, + Email.PROPERTY_PROJECT_REFERENCE, projectRef, Email.PROPERTY_OBJECT, client.getCaracteristic1() + " / " + client.getCode() + " / " + + client.getName() + " / " + client.getFaxNumber() + " / " + dateDecorator.toString(now), Email.PROPERTY_RECEPTION_DATE, now, + Email.PROPERTY_MAIL_FOLDER, folder, Email.PROPERTY_DEMAND_STATUS, opened ? DemandStatus.IN_PROGRESS : DemandStatus.UNTREATED, + Email.PROPERTY_HISTORY, Lists.newArrayList(history)); + + if (opened) { + + getEmailService().addToHistory(email.getTopiaId(), HistoryType.OPENING, user, now); + DemandType demandType = types.get(0); + if (demandType.getRangeNeeded()) { + for (int j = 0; j < 4; j++) { + RangeRow rangeRow = rangeRowDao.create(RangeRow.PROPERTY_RANGE, ranges.get(j), + RangeRow.PROPERTY_COMMAND_NUMBER, RandomStringUtils.randomNumeric(6), RangeRow.PROPERTY_PRODUCT_QUANTITY, + 50, RangeRow.PROPERTY_SAV_QUANTITY, 60); + rangeRows.add(rangeRow); + } + email.setRangeRow(rangeRows); + } + + email.setDemandType(demandType); + email.setPriority(priorities.get(0)); + email.setRangeRow(rangeRows); + getEmailService().saveEmail(email, user, Email.PROPERTY_DEMAND_TYPE, Email.PROPERTY_PRIORITY, Email.PROPERTY_RANGE_ROW); + } + + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.DAY_OF_MONTH, -1); + Date yesterday = cal.getTime(); + history = historyDao.create(History.PROPERTY_TYPE, HistoryType.CREATION, History.PROPERTY_FIELDS, Sets.newHashSet(Email.PROPERTY_SENDER, + Email.PROPERTY_CLIENT, Email.PROPERTY_PROJECT_REFERENCE, Email.PROPERTY_OBJECT, Email.PROPERTY_RECEPTION_DATE, + Email.PROPERTY_MAIL_FOLDER, Email.PROPERTY_DEMAND_STATUS), History.PROPERTY_MODIFICATION_DATE, yesterday); + projectRef = t("faxtomail.email.projectReference.default", dateDecorator.toString(yesterday)); + + email = emailDao.create(Email.PROPERTY_SENDER, sender, Email.PROPERTY_FAX, fax, Email.PROPERTY_CLIENT, client, + Email.PROPERTY_PROJECT_REFERENCE, projectRef, Email.PROPERTY_OBJECT, client.getCaracteristic1() + " / " + client.getCode() + " / " + + client.getName() + " / " + client.getFaxNumber() + " / " + dateDecorator.toString(yesterday), + Email.PROPERTY_RECEPTION_DATE, yesterday, Email.PROPERTY_MAIL_FOLDER, folder, Email.PROPERTY_DEMAND_STATUS, + opened ? DemandStatus.IN_PROGRESS : DemandStatus.UNTREATED, Email.PROPERTY_HISTORY, Lists.newArrayList(history)); + + if (opened) { + getEmailService().addToHistory(email.getTopiaId(), HistoryType.OPENING, user, now); + DemandType demandType = types.get(0); + if (demandType.getRangeNeeded()) { + for (int j = 0; j < 4; j++) { + RangeRow rangeRow = rangeRowDao.create(RangeRow.PROPERTY_RANGE, ranges.get(j), + RangeRow.PROPERTY_COMMAND_NUMBER, RandomStringUtils.randomNumeric(6), RangeRow.PROPERTY_PRODUCT_QUANTITY, + 50, RangeRow.PROPERTY_SAV_QUANTITY, 60); + rangeRows.add(rangeRow); + } + email.setRangeRow(rangeRows); + } + email.setDemandType(demandType); + email.setPriority(priorities.get(0)); + email.setRangeRow(rangeRows); + getEmailService().saveEmail(email, null, email.getClient().getCode(), user, Email.PROPERTY_DEMAND_TYPE, Email.PROPERTY_PRIORITY, + Email.PROPERTY_RANGE_ROW); + } + } +} Property changes on: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestData.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MailFolderServiceTest.java =================================================================== --- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MailFolderServiceTest.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MailFolderServiceTest.java 2014-05-27 16:37:04 UTC (rev 103) @@ -24,7 +24,10 @@ * #L% */ +import java.io.IOException; + import com.franciaflex.faxtomail.persistence.entities.MailFolder; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; @@ -42,10 +45,9 @@ protected MailFolderService service; @Before - public void setUp() { + public void setUp() throws IOException { service = newService(MailFolderService.class); - log.info("init sample data"); - newService(InitFaxToMailService.class).initSampleData(); + newService(InitTestData.class).initTestData(); } @Test Added: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/ReferentielServiceTest.java =================================================================== --- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/ReferentielServiceTest.java (rev 0) +++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/ReferentielServiceTest.java 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,29 @@ +package com.franciaflex.faxtomail.services.service; + +/* + * #%L + * FaxToMail :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * 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% + */ + +public class ReferentielServiceTest extends AbstractFaxToMailServiceTest { + +} Property changes on: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/ReferentielServiceTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/faxtomail-service/src/test/resources/csv/clients.csv =================================================================== --- trunk/faxtomail-service/src/test/resources/csv/clients.csv (rev 0) +++ trunk/faxtomail-service/src/test/resources/csv/clients.csv 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,5 @@ +Id_Correspondance;Societe;Nom;Caracteristique1;Caracteristique2;Caracteristique3;Client_Top;Numero_Fax;Adresse_Mail;Code_Client;Objet_Message;Destination +253042;FX;John Doe;A;71 Allo;NULL;NULL;03 12 34 56 78;john@doe.fr;99153;NULL; +253142;FX;Gerard Menvussa;A+;40 Nabi;NULL;NULL;05 12 23 34 45;gerard.menvussa@code.com;99154;NULL; +253242;FX;Ella Elli;NULL;38 LA;NULL;NULL;04 98 87 76 65;NULL;99184;NULL; + Added: trunk/faxtomail-service/src/test/resources/csv/demandtypes.csv =================================================================== --- trunk/faxtomail-service/src/test/resources/csv/demandtypes.csv (rev 0) +++ trunk/faxtomail-service/src/test/resources/csv/demandtypes.csv 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,4 @@ +demandetype +Devis +Commande +Retour \ No newline at end of file Added: trunk/faxtomail-service/src/test/resources/csv/email_accounts.csv =================================================================== --- trunk/faxtomail-service/src/test/resources/csv/email_accounts.csv (rev 0) +++ trunk/faxtomail-service/src/test/resources/csv/email_accounts.csv 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,2 @@ +protocol;host;user;password +pop3;test.franciaflex.fr;testuser;password Added: trunk/faxtomail-service/src/test/resources/csv/email_filters.csv =================================================================== --- trunk/faxtomail-service/src/test/resources/csv/email_filters.csv (rev 0) +++ trunk/faxtomail-service/src/test/resources/csv/email_filters.csv 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,8 @@ +recipient;folder;position +fx.01test@franciaflex.com;Cyril;0 +fx.02test@franciaflex.com;Agathe;1 +fx.03test@franciaflex.com;Claire;2 +fx.adv%@franciaflex.com;Cyril;3 +fx.savFFEtest@franciaflex.com;Marc;4 +fx.savFMEtest@franciaflex.com;Jeanne;5 +fx.sav%@franciaflex.com;Frédéric;6 \ No newline at end of file Added: trunk/faxtomail-service/src/test/resources/csv/etatattentes.csv =================================================================== --- trunk/faxtomail-service/src/test/resources/csv/etatattentes.csv (rev 0) +++ trunk/faxtomail-service/src/test/resources/csv/etatattentes.csv 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,6 @@ +etatattente +Non traité +Pris +En cours +Transmit +Terminé Added: trunk/faxtomail-service/src/test/resources/csv/priorities.csv =================================================================== --- trunk/faxtomail-service/src/test/resources/csv/priorities.csv (rev 0) +++ trunk/faxtomail-service/src/test/resources/csv/priorities.csv 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,5 @@ +priorite +Bas +Normal +Haut +Urgent Added: trunk/faxtomail-service/src/test/resources/csv/ranges.csv =================================================================== --- trunk/faxtomail-service/src/test/resources/csv/ranges.csv (rev 0) +++ trunk/faxtomail-service/src/test/resources/csv/ranges.csv 2014-05-27 16:37:04 UTC (rev 103) @@ -0,0 +1,6 @@ +gamme +Bas de gamme +Normal de gamme +Haut de gamme +Très haut de gamme +C'est de la gamme Modified: trunk/faxtomail-ui-web/pom.xml =================================================================== --- trunk/faxtomail-ui-web/pom.xml 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-ui-web/pom.xml 2014-05-27 16:37:04 UTC (rev 103) @@ -100,11 +100,6 @@ </dependency> <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - - <dependency> <groupId>org.nuiton.i18n</groupId> <artifactId>nuiton-i18n</artifactId> </dependency> @@ -120,11 +115,6 @@ </dependency> <dependency> - <groupId>org.nuiton.web</groupId> - <artifactId>nuiton-struts2</artifactId> - </dependency> - - <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> </dependency> @@ -197,6 +187,11 @@ <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> + + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + </dependency> <dependency> <groupId>org.quartz-scheduler</groupId> Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/json/HibernateProxyTypeAdapter.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/json/HibernateProxyTypeAdapter.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/json/HibernateProxyTypeAdapter.java 2014-05-27 16:37:04 UTC (rev 103) @@ -1,5 +1,29 @@ package com.franciaflex.faxtomail.web.json; +/* + * #%L + * FaxToMail :: Web + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * 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.io.IOException; import org.hibernate.Hibernate; Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/json/TopiaEntityAdapter.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/json/TopiaEntityAdapter.java 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/json/TopiaEntityAdapter.java 2014-05-27 16:37:04 UTC (rev 103) @@ -1,5 +1,29 @@ package com.franciaflex.faxtomail.web.json; +/* + * #%L + * FaxToMail :: Web + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * 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.lang.reflect.Type; import org.nuiton.topia.persistence.TopiaEntity; 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-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-05-27 16:37:04 UTC (rev 103) @@ -268,7 +268,8 @@ <div id="collapse3" class="panel-collapse collapse"> <div class="panel-body"> <label class="checkbox" ng-repeat="etatAttente in etatAttentes"> - <input type="checkbox"> {{etatAttente.label}} + <input type="checkbox" ng-checked="selectedMailFolder.etatAttente.indexOf(etatAttente) != -1" + ng-click="changeFolderEtatAttente(etatAttente)"> {{etatAttente.label}} </label> </div> </div> Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-05-27 16:37:04 UTC (rev 103) @@ -1,3 +1,26 @@ +/* + * #%L + * FaxToMail :: Web + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * 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% + */ /** * Global configuration controller. @@ -191,7 +214,17 @@ $scope.removeReplyAddress = function(index) { $scope.selectedMailFolder.replyAddresses.splice(index, 1); }; - + + // selection/deselection d'un état d'attente possible pour ce dossier + $scope.changeFolderEtatAttente = function(etatAttente) { + var index = $scope.selectedMailFolder.etatAttente.indexOf(etatAttente); + if (index != -1) { + $scope.selectedMailFolder.etatAttente.splice(index, 1); + } else { + $scope.selectedMailFolder.etatAttente.push(etatAttente); + } + }; + // selection/deselection d'une action possible du menu contextuel pour ce dossier $scope.changeFolderAction = function(etatAttenteAction) { var index = $scope.selectedMailFolder.folderActions.indexOf(etatAttenteAction); @@ -280,4 +313,4 @@ function($scope, $http, ConfigurationData) { // {Array} Liste des groupes ldap $scope.ldapGroups = ["Group1", "Group2", "Group3", "Group4", "Group5"]; -}]); \ No newline at end of file +}]); Modified: trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js 2014-05-27 09:00:44 UTC (rev 102) +++ trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js 2014-05-27 16:37:04 UTC (rev 103) @@ -1,2 +1,25 @@ +/* + * #%L + * FaxToMail :: Web + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * 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% + */ var FaxToMailModule = angular.module('FaxToMail', []);
participants (1)
-
echatellier@users.forge.codelutin.com