r580 - in trunk: . faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate faxtomail-persistence/src/main/xmi faxtomail-service/src/main/java/com/franciaflex/faxtomail/services faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-service/src/main/resources/db/migration/h2 fa
Author: echatellier Date: 2014-08-21 12:11:20 +0200 (Thu, 21 Aug 2014) New Revision: 580 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/580 Log: fixes #5647: Remplacer les relations avec des enums par un stockage en String Added: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/EnumListUserType.java trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/EnumSetUserType.java trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailActionEnumSetUserType.java trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailFieldEnumListUserType.java trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailFieldEnumSetUserType.java trunk/faxtomail-service/src/main/resources/db/migration/h2/V1_0_0_580__transform_enum_set_to_lists.sql trunk/faxtomail-service/src/main/resources/db/migration/postgres/V1_0_0_580__transform_enum_set_to_lists.sql trunk/faxtomail-service/src/main/resources/db/migration/sqlserver/V1_0_0_580__transform_enum_set_to_lists.sql Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationServiceImpl.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailServiceImpl.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ReferentielServiceImpl.java trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestDataImpl.java trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MiscTest.java trunk/faxtomail-service/src/test/resources/log4j2.xml trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.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/pom.xml Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java 2014-08-21 10:11:20 UTC (rev 580) @@ -367,7 +367,7 @@ String hqlForFetchStep1 = "select E." + TopiaEntity.PROPERTY_TOPIA_ID + " FROM " + Email.class.getName() + " E " + query.toString(); String hqlForFetchStep2 = "select distinct E FROM " + Email.class.getName() + " E " + addAllFecthes( Email.PROPERTY_PRIORITY, - Email.PROPERTY_DEMAND_TYPE + "." + DemandType.PROPERTY_FIELDS, + Email.PROPERTY_DEMAND_TYPE, Email.PROPERTY_CLIENT, Email.PROPERTY_RANGE_ROW + "." + RangeRow.PROPERTY_RANGE, Email.PROPERTY_ETAT_ATTENTE, Added: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/EnumListUserType.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/EnumListUserType.java (rev 0) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/EnumListUserType.java 2014-08-21 10:11:20 UTC (rev 580) @@ -0,0 +1,155 @@ +package com.franciaflex.faxtomail.persistence.hibernate; + +/* + * #%L + * FaxToMail :: Persistence + * $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.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.ArrayList; +import java.util.List; + +import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.usertype.UserType; + +/** + * See https://community.jboss.org/wiki/Java5EnumUserType. + * and inspired by http://2lips.pl/blog/usertype-enumset-mysql-set-column. + * + * @author Eric Chatellier + * + * @param <T> + */ +public abstract class EnumListUserType<T extends Enum<T>> implements UserType { + + private Class<T> typeClazz = null; + private Class<? extends List> returnedType = null; + + public EnumListUserType(Class<T> typeClazz) { + this.typeClazz = typeClazz; + returnedType = ArrayList.class; + } + + public Class returnedClass() { + return returnedType; + } + + public int[] sqlTypes() { + return new int[] { Types.LONGVARCHAR }; + } + + public boolean isMutable() { + return false; + } + + /** + * Retrieve an instance of the mapped class from a JDBC resultset. + * Implementors should handle possibility of null values. + * + * @param rs a JDBC result set + * @param names the column names + * @param owner the containing entity + * @return Object + * @throws HibernateException + * @throws SQLException + */ + @Override + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { + String name = rs.getString(names[0]); + List<T> result = null; + if (!rs.wasNull()) { + String[] values = name.split(","); + result = new ArrayList<T>(); + for (String value : values) { + if (!value.isEmpty()) { + result.add(Enum.valueOf(typeClazz, value)); + } + } + } + return result; + } + + /** + * Write an instance of the mapped class to a prepared statement. + * Implementors should handle possibility of null values. A multi-column + * type should be written to parameters starting from <tt>index</tt>. + * + * @param st a JDBC prepared statement + * @param value the object to write + * @param index statement parameter index + * @param session session + * @throws HibernateException + * @throws SQLException + */ + @Override + public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { + if (null == value) { + st.setNull(index, Types.VARCHAR); + } else { + List<T> values = (List<T>)value; + String sqlValue = ""; + if (!values.isEmpty()) { + StringBuilder buf = new StringBuilder(); + for(T val : values) { + buf.append(val.name()).append(","); + } + sqlValue = buf.substring(0, buf.length() - 1); + } + st.setString(index, sqlValue); + } + } + + public Object assemble(Serializable cached, Object owner) throws HibernateException { + return cached; + } + + public Serializable disassemble(Object value) throws HibernateException { + return (Enum<?>) value; + } + + public Object deepCopy(Object value) throws HibernateException { + return value; + } + + public boolean equals(Object x, Object y) throws HibernateException { + if (x == y) { + return true; + } + if (null == x || null == y) { + return false; + } + return x.equals(y); + } + + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + + public Object replace(Object original, Object target, Object owner) throws HibernateException { + return original; + } +} Property changes on: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/EnumListUserType.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/EnumSetUserType.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/EnumSetUserType.java (rev 0) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/EnumSetUserType.java 2014-08-21 10:11:20 UTC (rev 580) @@ -0,0 +1,161 @@ +package com.franciaflex.faxtomail.persistence.hibernate; + +/* + * #%L + * FaxToMail :: Persistence + * $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.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.EnumSet; +import java.util.LinkedHashSet; +import java.util.Set; + +import org.hibernate.HibernateException; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.usertype.UserType; + +/** + * See https://community.jboss.org/wiki/Java5EnumUserType. + * and inspired by http://2lips.pl/blog/usertype-enumset-mysql-set-column. + * + * @author Eric Chatellier + * + * @param <T> + */ +public abstract class EnumSetUserType<T extends Enum<T>> implements UserType { + + private Class<T> typeClazz = null; + private Class<? extends EnumSet> returnedType = null; + + public EnumSetUserType(Class<T> typeClazz) { + this.typeClazz = typeClazz; + returnedType = EnumSet.noneOf(typeClazz).getClass(); + } + + public Class returnedClass() { + return returnedType; + } + + public int[] sqlTypes() { + return new int[] { Types.LONGVARCHAR }; + } + + public boolean isMutable() { + return false; + } + + /** + * Retrieve an instance of the mapped class from a JDBC resultset. + * Implementors should handle possibility of null values. + * + * @param rs a JDBC result set + * @param names the column names + * @param owner the containing entity + * @return Object + * @throws HibernateException + * @throws SQLException + */ + @Override + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { + String name = rs.getString(names[0]); + EnumSet<T> result = null; + if (!rs.wasNull()) { + String[] values = name.split(","); + Set<T> enumList = new LinkedHashSet<T>(); + for (String value : values) { + if (!value.isEmpty()) { + enumList.add(Enum.valueOf(typeClazz, value)); + } + } + if (enumList.isEmpty()) { + result = EnumSet.noneOf(typeClazz); + } else { + result = EnumSet.copyOf(enumList); + } + } + return result; + } + + /** + * Write an instance of the mapped class to a prepared statement. + * Implementors should handle possibility of null values. A multi-column + * type should be written to parameters starting from <tt>index</tt>. + * + * @param st a JDBC prepared statement + * @param value the object to write + * @param index statement parameter index + * @param session session + * @throws HibernateException + * @throws SQLException + */ + @Override + public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { + if (null == value) { + st.setNull(index, Types.VARCHAR); + } else { + Set<T> values = (Set<T>)value; + String sqlValue = ""; + if (!values.isEmpty()) { + StringBuilder buf = new StringBuilder(); + for (T val : values) { + buf.append(val.name()).append(","); + } + sqlValue = buf.substring(0, buf.length() - 1); + } + st.setString(index, sqlValue); + } + } + + public Object assemble(Serializable cached, Object owner) throws HibernateException { + return cached; + } + + public Serializable disassemble(Object value) throws HibernateException { + return (Enum<?>) value; + } + + public Object deepCopy(Object value) throws HibernateException { + return value; + } + + public boolean equals(Object x, Object y) throws HibernateException { + if (x == y) { + return true; + } + if (null == x || null == y) { + return false; + } + return x.equals(y); + } + + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + + public Object replace(Object original, Object target, Object owner) throws HibernateException { + return original; + } +} Property changes on: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/EnumSetUserType.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailActionEnumSetUserType.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailActionEnumSetUserType.java (rev 0) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailActionEnumSetUserType.java 2014-08-21 10:11:20 UTC (rev 580) @@ -0,0 +1,35 @@ +package com.franciaflex.faxtomail.persistence.hibernate; + +/* + * #%L + * FaxToMail :: Persistence + * $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 com.franciaflex.faxtomail.persistence.entities.MailAction; + +public class MailActionEnumSetUserType extends EnumSetUserType<MailAction> { + + public MailActionEnumSetUserType() { + super(MailAction.class); + } + +} Property changes on: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailActionEnumSetUserType.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailFieldEnumListUserType.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailFieldEnumListUserType.java (rev 0) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailFieldEnumListUserType.java 2014-08-21 10:11:20 UTC (rev 580) @@ -0,0 +1,35 @@ +package com.franciaflex.faxtomail.persistence.hibernate; + +/* + * #%L + * FaxToMail :: Persistence + * $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 com.franciaflex.faxtomail.persistence.entities.MailField; + +public class MailFieldEnumListUserType extends EnumListUserType<MailField>{ + + public MailFieldEnumListUserType() { + super(MailField.class); + } + +} Property changes on: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailFieldEnumListUserType.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailFieldEnumSetUserType.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailFieldEnumSetUserType.java (rev 0) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailFieldEnumSetUserType.java 2014-08-21 10:11:20 UTC (rev 580) @@ -0,0 +1,35 @@ +package com.franciaflex.faxtomail.persistence.hibernate; + +/* + * #%L + * FaxToMail :: Persistence + * $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 com.franciaflex.faxtomail.persistence.entities.MailField; + +public class MailFieldEnumSetUserType extends EnumSetUserType<MailField>{ + + public MailFieldEnumSetUserType() { + super(MailField.class); + } + +} Property changes on: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/hibernate/MailFieldEnumSetUserType.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties =================================================================== --- trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-persistence/src/main/xmi/faxtomail.properties 2014-08-21 10:11:20 UTC (rev 580) @@ -28,8 +28,8 @@ # EtatAttente com.franciaflex.faxtomail.persistence.entities.EtatAttente.attribute.label.tagvalue.naturalId=true -com.franciaflex.faxtomail.persistence.entities.EtatAttente.attribute.validFormDisabledActions.stereotype=unique -com.franciaflex.faxtomail.persistence.entities.EtatAttente.attribute.invalidFormDisabledActions.stereotype=unique +com.franciaflex.faxtomail.persistence.entities.EtatAttente.attribute.invalidFormDisabledActions.tagvalue.hibernateAttributeType=com.franciaflex.faxtomail.persistence.hibernate.MailActionEnumSetUserType +com.franciaflex.faxtomail.persistence.entities.EtatAttente.attribute.validFormDisabledActions.tagvalue.hibernateAttributeType=com.franciaflex.faxtomail.persistence.hibernate.MailActionEnumSetUserType # Priority com.franciaflex.faxtomail.persistence.entities.Priority.attribute.label.tagvalue.naturalId=true @@ -39,7 +39,7 @@ # DemandType com.franciaflex.faxtomail.persistence.entities.DemandType.attribute.label.tagvalue.naturalId=true -com.franciaflex.faxtomail.persistence.entities.DemandType.attribute.fields.stereotype=unique +com.franciaflex.faxtomail.persistence.entities.DemandType.attribute.requiredFields.tagvalue.hibernateAttributeType=com.franciaflex.faxtomail.persistence.hibernate.MailFieldEnumSetUserType # Client com.franciaflex.faxtomail.persistence.entities.Client.attribute.brand.tagvalue.naturalId=true @@ -58,6 +58,11 @@ com.franciaflex.faxtomail.persistence.entities.EmailAccount.attribute.host.tagvalue.naturalId=true com.franciaflex.faxtomail.persistence.entities.EmailAccount.attribute.login.tagvalue.naturalId=true + +#�Configuration +com.franciaflex.faxtomail.persistence.entities.Configuration.attribute.searchDisplayColumns.tagvalue.hibernateAttributeType=com.franciaflex.faxtomail.persistence.hibernate.MailFieldEnumListUserType +com.franciaflex.faxtomail.persistence.entities.Configuration.attribute.invalidFormDisabledActions.tagvalue.hibernateAttributeType=com.franciaflex.faxtomail.persistence.hibernate.MailActionEnumSetUserType + # ExtensionCommand com.franciaflex.faxtomail.persistence.entities.ExtensionCommand.attribute.extension.tagvalue.naturalId=true @@ -78,6 +83,7 @@ com.franciaflex.faxtomail.persistence.entities.MailFolder.attribute.parent.tagvalue.naturalId=true com.franciaflex.faxtomail.persistence.entities.MailFolder.attribute.parent.tagvalue.notNull=false com.franciaflex.faxtomail.persistence.entities.MailFolder.attribute.name.tagvalue.naturalId=true +com.franciaflex.faxtomail.persistence.entities.MailFolder.attribute.folderTableColumns.tagvalue.hibernateAttributeType=com.franciaflex.faxtomail.persistence.hibernate.MailFieldEnumListUserType # MailFilter com.franciaflex.faxtomail.persistence.entities.MailFilter.attribute.expression.tagvalue.naturalId=true Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo =================================================================== (Binary files differ) Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java 2014-08-21 10:11:20 UTC (rev 580) @@ -24,14 +24,17 @@ * #L% */ -import com.franciaflex.faxtomail.persistence.entities.MailFolder; -import org.apache.commons.io.Charsets; +import java.nio.charset.Charset; +import java.util.Collection; import javax.mail.MessagingException; import javax.mail.Part; import javax.mail.internet.ContentType; -import java.nio.charset.Charset; +import org.apache.commons.io.Charsets; + +import com.franciaflex.faxtomail.persistence.entities.MailFolder; + /** * @author Kevin Morin (Code Lutin) */ @@ -56,4 +59,19 @@ Charset charset = Charsets.toCharset(charsetName); return charset; } + + /** + * Return true if given collection is not null and contains requested value. + * + * @param coll collection + * @param value value + * @return true if set contains value + */ + public static <T extends Enum<T>> boolean contains(Collection<T> coll, T value) { + boolean result = false; + if (coll != null) { + result = coll.contains(value); + } + return result; + } } Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java 2014-08-21 10:11:20 UTC (rev 580) @@ -24,6 +24,12 @@ * #L% */ +import java.util.Collection; +import java.util.EnumSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import com.franciaflex.faxtomail.persistence.entities.Configuration; import com.franciaflex.faxtomail.persistence.entities.DemandType; import com.franciaflex.faxtomail.persistence.entities.EmailAccount; @@ -35,11 +41,6 @@ import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.services.FaxToMailService; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - /** * @author Kevin Morin (Code Lutin) */ Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationServiceImpl.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationServiceImpl.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationServiceImpl.java 2014-08-21 10:11:20 UTC (rev 580) @@ -38,7 +38,6 @@ import javax.mail.Session; import javax.mail.Store; -import com.franciaflex.faxtomail.persistence.entities.MailField; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -67,6 +66,7 @@ import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserTopiaDao; import com.franciaflex.faxtomail.persistence.entities.GroupChef; import com.franciaflex.faxtomail.persistence.entities.GroupChefTopiaDao; +import com.franciaflex.faxtomail.persistence.entities.MailField; import com.franciaflex.faxtomail.persistence.entities.MailFilter; import com.franciaflex.faxtomail.persistence.entities.MailFilterTopiaDao; import com.franciaflex.faxtomail.persistence.entities.MailFolder; @@ -100,14 +100,10 @@ @Override public Configuration getConfiguration() { ConfigurationTopiaDao dao = getPersistenceContext().getConfigurationDao(); - Configuration config = dao.forAll().addAllFetches( - Configuration.PROPERTY_SEARCH_DISPLAY_COLUMNS, - Configuration.PROPERTY_INVALID_FORM_DISABLED_ACTIONS - ).findUniqueOrNull(); + Configuration config = dao.forAll().findUniqueOrNull(); if (config == null) { config = new ConfigurationImpl(); } - Hibernate.initialize(config.getInvalidFormDisabledActions()); return config; } Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-08-21 10:11:20 UTC (rev 580) @@ -50,6 +50,7 @@ import javax.mail.MessagingException; import com.franciaflex.faxtomail.services.service.exceptions.FolderNotReadableException; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.io.FileUtils; @@ -79,10 +80,12 @@ import com.franciaflex.faxtomail.persistence.entities.*; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; import com.franciaflex.faxtomail.services.service.exceptions.AlreadyLockedMailException; import com.franciaflex.faxtomail.services.service.exceptions.InvalidClientException; import com.franciaflex.faxtomail.services.service.imports.ArchiveImportBean; import com.franciaflex.faxtomail.services.service.imports.ArchiveImportModel; +import com.google.common.base.Enums; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; @@ -118,7 +121,6 @@ Email email = getPersistenceContext().getEmailDao() .forTopiaIdEquals(id) .addAllFetches(Email.PROPERTY_DEMAND_TYPE, - Email.PROPERTY_DEMAND_TYPE + "." + DemandType.PROPERTY_FIELDS, Email.PROPERTY_RANGE_ROW + "." + RangeRow.PROPERTY_RANGE, Email.PROPERTY_HISTORY, Email.PROPERTY_HISTORY + "." + History.PROPERTY_FAX_TO_MAIL_USER, @@ -131,8 +133,6 @@ Email.PROPERTY_EMAIL_GROUP + "." + EmailGroup.PROPERTY_EMAIL, Email.PROPERTY_EMAIL_GROUP + "." + EmailGroup.PROPERTY_EMAIL +"." + Email.PROPERTY_MAIL_FOLDER, Email.PROPERTY_ETAT_ATTENTE, - Email.PROPERTY_ETAT_ATTENTE + "." + EtatAttente.PROPERTY_INVALID_FORM_DISABLED_ACTIONS, - Email.PROPERTY_ETAT_ATTENTE + "." + EtatAttente.PROPERTY_VALID_FORM_DISABLED_ACTIONS, Email.PROPERTY_PRIORITY).findUnique(); return email; @@ -369,7 +369,7 @@ protected void handleEdiTransmission(Email email, HistoryTopiaDao historyDao, Set<String> fieldSet) { History transmissionToEdi; - if (email.getDemandType().containsFields(MailField.RANGE_ROW)) { + if (FaxToMailServiceUtils.contains(email.getDemandType().getRequiredFields(), MailField.RANGE_ROW)) { // si les gammes sont vides, la demande n'est pas valide, on ne fait rien dans ce cas // sinon on transfer à edi @@ -569,7 +569,7 @@ .addNull(Email.PROPERTY_ARCHIVE_DATE) .addNotEquals(Email.PROPERTY_DEMAND_STATUS, DemandStatus.ARCHIVED) .addAllFetches(Email.PROPERTY_PRIORITY, - Email.PROPERTY_DEMAND_TYPE + "." + DemandType.PROPERTY_FIELDS, + Email.PROPERTY_DEMAND_TYPE, Email.PROPERTY_CLIENT, Email.PROPERTY_RANGE_ROW + "." + RangeRow.PROPERTY_RANGE, Email.PROPERTY_ETAT_ATTENTE, Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailServiceImpl.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailServiceImpl.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailServiceImpl.java 2014-08-21 10:11:20 UTC (rev 580) @@ -33,6 +33,7 @@ import java.util.Calendar; import java.util.Collections; import java.util.Date; +import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -70,6 +71,7 @@ import com.franciaflex.faxtomail.persistence.entities.RangeTopiaDao; import com.franciaflex.faxtomail.services.DecoratorService; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; import com.franciaflex.faxtomail.services.service.exceptions.InvalidClientException; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -110,7 +112,8 @@ if (count == 0) { List<DemandType> types = Lists.newArrayList( - demandTypeDao.create(DemandType.PROPERTY_LABEL, "Commande", DemandType.PROPERTY_FIELDS, Sets.newHashSet(MailField.RANGE_ROW)), + demandTypeDao.create(DemandType.PROPERTY_LABEL, "Commande", + DemandType.PROPERTY_REQUIRED_FIELDS, EnumSet.of(MailField.RANGE_ROW)), demandTypeDao.create(DemandType.PROPERTY_LABEL, "Commande Réponse"), demandTypeDao.create(DemandType.PROPERTY_LABEL, "Commande Annulation/Modification"), demandTypeDao.create(DemandType.PROPERTY_LABEL, "Devis Diffus"), @@ -381,7 +384,7 @@ getEmailService().addToHistory(email.getTopiaId(), HistoryType.OPENING, user, now); DemandType demandType = types.get(random.nextInt(types.size())); - if (demandType.containsFields(MailField.RANGE_ROW)) { + if (FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.RANGE_ROW)) { for (int j = 0; j < random.nextInt(4) + 1; j++) { RangeRow rangeRow = rangeRowDao.create(RangeRow.PROPERTY_RANGE, ranges.get(random.nextInt(ranges.size())), RangeRow.PROPERTY_COMMAND_NUMBER, RandomStringUtils.randomNumeric(6), @@ -428,7 +431,7 @@ if (opened) { getEmailService().addToHistory(email.getTopiaId(), HistoryType.OPENING, user, now); DemandType demandType = types.get(random.nextInt(types.size())); - if (demandType.containsFields(MailField.RANGE_ROW)) { + if (FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.RANGE_ROW)) { for (int j = 0; j < random.nextInt(4) + 1; j++) { RangeRow rangeRow = rangeRowDao.create(RangeRow.PROPERTY_RANGE, ranges.get(random.nextInt(ranges.size())), RangeRow.PROPERTY_COMMAND_NUMBER, RandomStringUtils.randomNumeric(6), Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ReferentielServiceImpl.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ReferentielServiceImpl.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ReferentielServiceImpl.java 2014-08-21 10:11:20 UTC (rev 580) @@ -71,7 +71,7 @@ @Override public List<DemandType> getAllDemandType() { DemandTypeTopiaDao dao = getPersistenceContext().getDemandTypeDao(); - return dao.forAll().addAllFetches(DemandType.PROPERTY_FIELDS).findAll(); + return dao.findAll(); } @Override @@ -89,10 +89,7 @@ @Override public List<EtatAttente> getAllEtatAttente() { EtatAttenteTopiaDao dao = getPersistenceContext().getEtatAttenteDao(); - return dao.forAll() - .addAllFetches(EtatAttente.PROPERTY_INVALID_FORM_DISABLED_ACTIONS, - EtatAttente.PROPERTY_VALID_FORM_DISABLED_ACTIONS) - .findAll(); + return dao.findAll(); } @Override Added: trunk/faxtomail-service/src/main/resources/db/migration/h2/V1_0_0_580__transform_enum_set_to_lists.sql =================================================================== --- trunk/faxtomail-service/src/main/resources/db/migration/h2/V1_0_0_580__transform_enum_set_to_lists.sql (rev 0) +++ trunk/faxtomail-service/src/main/resources/db/migration/h2/V1_0_0_580__transform_enum_set_to_lists.sql 2014-08-21 10:11:20 UTC (rev 580) @@ -0,0 +1,25 @@ +-- configuration +alter table configuration_invalidFormDisabledActions drop constraint FK_fj3yycjetl6acpiybfsg4v0yq; +alter table configuration_searchDisplayColumns drop constraint FK_9ffmpp0utfad26oxe70efo1da; +drop table configuration_invalidFormDisabledActions; +drop table configuration_searchDisplayColumns; +alter table configuration add searchDisplayColumns longvarchar; +alter table configuration add invalidFormDisabledActions longvarchar; + +-- demande type +alter table demandType_fields drop constraint FK_c44wglsh0xpua19f1ps9vn24i; +drop table demandType_fields; +alter table demandType add requiredFields longvarchar; + +-- etat attente +alter table etatAttente_invalidFormDisabledActions drop constraint FK_221gjt0dyjtbndk8v7tr85ta6 ; +alter table etatAttente_validFormDisabledActions drop constraint FK_86hqc0dxhqyca7rbx7b3bfydr; +drop table etatAttente_invalidFormDisabledActions; +drop table etatAttente_validFormDisabledActions; +alter table etatAttente add invalidFormDisabledActions longvarchar; +alter table etatAttente add validFormDisabledActions longvarchar; + +-- mail folder +alter table mailFolder_folderTableColumns drop constraint FK_ap7lwii8to9wlxefnu3pn0goe; +drop table mailFolder_folderTableColumns; +alter table mailFolder add folderTableColumns longvarchar; Added: trunk/faxtomail-service/src/main/resources/db/migration/postgres/V1_0_0_580__transform_enum_set_to_lists.sql =================================================================== --- trunk/faxtomail-service/src/main/resources/db/migration/postgres/V1_0_0_580__transform_enum_set_to_lists.sql (rev 0) +++ trunk/faxtomail-service/src/main/resources/db/migration/postgres/V1_0_0_580__transform_enum_set_to_lists.sql 2014-08-21 10:11:20 UTC (rev 580) @@ -0,0 +1,25 @@ +-- configuration +alter table configuration_invalidFormDisabledActions drop constraint FK_fj3yycjetl6acpiybfsg4v0yq; +alter table configuration_searchDisplayColumns drop constraint FK_9ffmpp0utfad26oxe70efo1da; +drop table configuration_invalidFormDisabledActions; +drop table configuration_searchDisplayColumns; +alter table configuration add searchDisplayColumns text; +alter table configuration add invalidFormDisabledActions text; + +-- demande type +alter table demandType_fields drop constraint FK_c44wglsh0xpua19f1ps9vn24i; +drop table demandType_fields; +alter table demandType add requiredFields text; + +-- etat attente +alter table etatAttente_invalidFormDisabledActions drop constraint FK_221gjt0dyjtbndk8v7tr85ta6 ; +alter table etatAttente_validFormDisabledActions drop constraint FK_86hqc0dxhqyca7rbx7b3bfydr; +drop table etatAttente_invalidFormDisabledActions; +drop table etatAttente_validFormDisabledActions; +alter table etatAttente add invalidFormDisabledActions text; +alter table etatAttente add validFormDisabledActions text; + +-- mail folder +alter table mailFolder_folderTableColumns drop constraint FK_ap7lwii8to9wlxefnu3pn0goe; +drop table mailFolder_folderTableColumns; +alter table mailFolder add folderTableColumns text; Added: trunk/faxtomail-service/src/main/resources/db/migration/sqlserver/V1_0_0_580__transform_enum_set_to_lists.sql =================================================================== --- trunk/faxtomail-service/src/main/resources/db/migration/sqlserver/V1_0_0_580__transform_enum_set_to_lists.sql (rev 0) +++ trunk/faxtomail-service/src/main/resources/db/migration/sqlserver/V1_0_0_580__transform_enum_set_to_lists.sql 2014-08-21 10:11:20 UTC (rev 580) @@ -0,0 +1,33 @@ +-- configuration +alter table configuration_invalidFormDisabledActions drop constraint FK_fj3yycjetl6acpiybfsg4v0yq; +alter table configuration_searchDisplayColumns drop constraint FK_9ffmpp0utfad26oxe70efo1da; +GO +drop table configuration_invalidFormDisabledActions; +drop table configuration_searchDisplayColumns; +alter table configuration add searchDisplayColumns varchar(MAX); +alter table configuration add invalidFormDisabledActions varchar(MAX); +GO + +-- demande type +alter table demandType_fields drop constraint FK_c44wglsh0xpua19f1ps9vn24i; +GO +drop table demandType_fields; +alter table demandType add requiredFields varchar(MAX); +GO + +-- etat attente +alter table etatAttente_invalidFormDisabledActions drop constraint FK_221gjt0dyjtbndk8v7tr85ta6 ; +alter table etatAttente_validFormDisabledActions drop constraint FK_86hqc0dxhqyca7rbx7b3bfydr; +GO +drop table etatAttente_invalidFormDisabledActions; +drop table etatAttente_validFormDisabledActions; +alter table etatAttente add invalidFormDisabledActions varchar(MAX); +alter table etatAttente add validFormDisabledActions varchar(MAX); +GO + +-- mail folder +alter table mailFolder_folderTableColumns drop constraint FK_ap7lwii8to9wlxefnu3pn0goe; +GO +drop table mailFolder_folderTableColumns; +alter table mailFolder add folderTableColumns varchar(MAX); +GO \ No newline at end of file Modified: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestDataImpl.java =================================================================== --- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestDataImpl.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/InitTestDataImpl.java 2014-08-21 10:11:20 UTC (rev 580) @@ -64,6 +64,7 @@ import com.franciaflex.faxtomail.persistence.entities.RangeRowTopiaDao; import com.franciaflex.faxtomail.services.DecoratorService; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; import com.franciaflex.faxtomail.services.service.exceptions.InvalidClientException; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -271,7 +272,7 @@ getEmailService().addToHistory(email.getTopiaId(), HistoryType.OPENING, user, now); DemandType demandType = types.get(0); - if (demandType.containsFields(MailField.RANGE_ROW)) { + if (FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.RANGE_ROW)) { 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, @@ -309,7 +310,7 @@ if (opened) { getEmailService().addToHistory(email.getTopiaId(), HistoryType.OPENING, user, now); DemandType demandType = types.get(0); - if (demandType.containsFields(MailField.RANGE_ROW)) { + if (FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.RANGE_ROW)) { 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, Modified: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MiscTest.java =================================================================== --- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MiscTest.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/MiscTest.java 2014-08-21 10:11:20 UTC (rev 580) @@ -36,7 +36,6 @@ * * @author Eric Chatellier */ -@Ignore public class MiscTest extends AbstractFaxToMailServiceTest { @Override Modified: trunk/faxtomail-service/src/test/resources/log4j2.xml =================================================================== --- trunk/faxtomail-service/src/test/resources/log4j2.xml 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-service/src/test/resources/log4j2.xml 2014-08-21 10:11:20 UTC (rev 580) @@ -33,6 +33,7 @@ <Loggers> <Logger name="com.franciaflex.faxtomail.services.service" level="info"/> + <Logger name="org.hibernate.tool.hbm2ddl.SchemaExport" level="fatal"/> <Root level="error"> <AppenderRef ref="Console" /> Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-08-21 10:11:20 UTC (rev 580) @@ -47,7 +47,6 @@ import javax.swing.event.ListSelectionListener; import javax.swing.table.TableCellEditor; -import com.franciaflex.faxtomail.services.FaxToMailServiceContext; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.collections4.CollectionUtils; @@ -65,6 +64,7 @@ import org.nuiton.jaxx.application.swing.table.MoveToNextEditableRowAction; import org.nuiton.jaxx.application.swing.table.MoveToPreviousEditableCellAction; import org.nuiton.jaxx.application.swing.table.MoveToPreviousEditableRowAction; +import org.nuiton.jaxx.application.swing.util.CloseableUI; import org.nuiton.util.beans.BeanMonitor; import com.franciaflex.faxtomail.persistence.entities.Attachment; @@ -77,11 +77,11 @@ import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.persistence.entities.Range; import com.franciaflex.faxtomail.persistence.entities.RangeRow; -import com.franciaflex.faxtomail.services.service.ReferentielService; +import com.franciaflex.faxtomail.services.FaxToMailServiceContext; +import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; import com.franciaflex.faxtomail.ui.swing.actions.SaveDemandeAction; import com.franciaflex.faxtomail.ui.swing.content.attachment.AttachmentEditorUIModel; import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailUIHandler; -import org.nuiton.jaxx.application.swing.util.CloseableUI; import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; /** @@ -117,11 +117,11 @@ DemandType oldType = (DemandType) evt.getOldValue(); if (newType != null && (oldType == null - || !Objects.equals(oldType.containsFields(MailField.RANGE_ROW), - newType.containsFields(MailField.RANGE_ROW)))) { + || !Objects.equals(FaxToMailServiceUtils.contains(oldType.getRequiredFields(), MailField.RANGE_ROW), + FaxToMailServiceUtils.contains(newType.getRequiredFields(), MailField.RANGE_ROW)))) { JSplitPane leftVerticalSplitPanel = getUI().getLeftVerticalSplitPanel(); - if (Boolean.TRUE.equals(newType.containsFields(MailField.RANGE_ROW))) { + if (FaxToMailServiceUtils.contains(newType.getRequiredFields(), MailField.RANGE_ROW)) { if (dividerLocation < 0) { dividerLocation = leftVerticalSplitPanel.getLeftComponent().getPreferredSize().height + 10; } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-08-21 10:11:20 UTC (rev 580) @@ -883,35 +883,35 @@ boolean result = demandType == null; if (!result) { if (PROPERTY_CLIENT_CODE.equals(field)) { - result = !demandType.containsFields(MailField.CLIENT) + result = !FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.CLIENT) || StringUtils.isNotBlank(getClientCode()); } else if (PROPERTY_VALID_RANGE_ROW_MODELS.equals(field)) { - result = !demandType.containsFields(MailField.RANGE_ROW) + result = !FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.RANGE_ROW) || CollectionUtils.isNotEmpty(getValidRangeRowModels()); } else if (Email.PROPERTY_PROJECT_REFERENCE.equals(field)) { - result = !demandType.containsFields(MailField.PROJECT_REFERENCE) + result = !FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.PROJECT_REFERENCE) || StringUtils.isNotBlank(getProjectReference()); } else if (Email.PROPERTY_OBJECT.equals(field)) { - result = !demandType.containsFields(MailField.OBJECT) + result = !FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.OBJECT) || StringUtils.isNotBlank(getObject()); } else if (Email.PROPERTY_COMMENT.equals(field)) { - result = !demandType.containsFields(MailField.COMMENT) + result = !FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.COMMENT) || StringUtils.isNotBlank(getComment()); } else if (Email.PROPERTY_COMPANY_REFERENCE.equals(field)) { - result = !demandType.containsFields(MailField.COMPANY_REFERENCE) + result = !FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.COMPANY_REFERENCE) || StringUtils.isNotBlank(getCompanyReference()); } else if (Email.PROPERTY_PRIORITY.equals(field)) { - result = !demandType.containsFields(MailField.PRIORITY) + result = !FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.PRIORITY) || getPriority() != null; } else if (Email.PROPERTY_ETAT_ATTENTE.equals(field)) { - result = !demandType.containsFields(MailField.ETAT_ATTENTE) + result = !FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.ETAT_ATTENTE) || getEtatAttente() != null; } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchToGroupUIHandler.java 2014-08-21 10:11:20 UTC (rev 580) @@ -24,33 +24,10 @@ * #L% */ -import com.franciaflex.faxtomail.persistence.entities.DemandStatus; -import com.franciaflex.faxtomail.persistence.entities.EmailFilter; -import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; -import com.franciaflex.faxtomail.persistence.entities.MailField; -import com.franciaflex.faxtomail.ui.swing.actions.GroupAction; -import com.franciaflex.faxtomail.ui.swing.actions.SearchToGroupAction; -import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; -import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailDemandListHandler; -import com.franciaflex.faxtomail.ui.swing.util.PaginationComboModel; +import static org.nuiton.i18n.I18n.t; -import org.nuiton.jaxx.application.swing.util.Cancelable; - -import jaxx.runtime.validator.swing.SwingValidator; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.decorator.ColorHighlighter; -import org.jdesktop.swingx.decorator.ComponentAdapter; -import org.jdesktop.swingx.decorator.HighlightPredicate; -import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import java.awt.*; +import java.awt.Color; +import java.awt.Component; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.KeyEvent; @@ -62,10 +39,36 @@ import java.util.Arrays; import java.util.Calendar; import java.util.Date; +import java.util.EnumSet; import java.util.List; -import static org.nuiton.i18n.I18n.t; +import javax.swing.JComponent; +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import jaxx.runtime.validator.swing.SwingValidator; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ColorHighlighter; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel; +import org.nuiton.jaxx.application.swing.util.Cancelable; + +import com.franciaflex.faxtomail.persistence.entities.DemandStatus; +import com.franciaflex.faxtomail.persistence.entities.EmailFilter; +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; +import com.franciaflex.faxtomail.persistence.entities.MailField; +import com.franciaflex.faxtomail.ui.swing.actions.GroupAction; +import com.franciaflex.faxtomail.ui.swing.actions.SearchToGroupAction; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; +import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailDemandListHandler; +import com.franciaflex.faxtomail.ui.swing.util.PaginationComboModel; + /** * @author Kevin Morin (Code Lutin) * Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/search/SearchUIHandler.java 2014-08-21 10:11:20 UTC (rev 580) @@ -31,6 +31,7 @@ import java.util.Arrays; import java.util.Calendar; import java.util.Date; +import java.util.EnumSet; import java.util.List; import javax.swing.JComponent; Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailDemandListHandler.java 2014-08-21 10:11:20 UTC (rev 580) @@ -24,27 +24,26 @@ * #L% */ -import com.ezware.oxbow.swingbits.table.filter.TableRowFilterSupport; -import com.franciaflex.faxtomail.persistence.entities.Attachment; -import com.franciaflex.faxtomail.persistence.entities.DemandStatus; -import com.franciaflex.faxtomail.persistence.entities.Email; -import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; -import com.franciaflex.faxtomail.persistence.entities.HasLabel; -import com.franciaflex.faxtomail.persistence.entities.HistoryType; -import com.franciaflex.faxtomail.persistence.entities.MailField; -import com.franciaflex.faxtomail.persistence.entities.Priority; -import com.franciaflex.faxtomail.persistence.entities.RangeRow; -import com.franciaflex.faxtomail.persistence.entities.Reply; -import com.franciaflex.faxtomail.services.FaxToMailServiceContext; -import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; -import com.franciaflex.faxtomail.ui.swing.actions.ShowDemandeAction; -import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; -import com.franciaflex.faxtomail.ui.swing.content.attachment.AttachmentCellEditor; -import com.franciaflex.faxtomail.ui.swing.content.attachment.AttachmentCellRenderer; -import com.franciaflex.faxtomail.ui.swing.content.demande.replies.RepliesCellEditor; -import com.franciaflex.faxtomail.ui.swing.content.demande.replies.RepliesCellRenderer; -import com.google.common.base.Function; -import com.google.common.collect.Lists; +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.Point; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.EnumSet; +import java.util.List; + +import javax.swing.JPopupMenu; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; @@ -63,18 +62,24 @@ import org.nuiton.validator.NuitonValidatorFactory; import org.nuiton.validator.NuitonValidatorResult; -import javax.swing.*; -import javax.swing.event.ChangeListener; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellRenderer; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; +import com.franciaflex.faxtomail.persistence.entities.Attachment; +import com.franciaflex.faxtomail.persistence.entities.DemandStatus; +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; +import com.franciaflex.faxtomail.persistence.entities.HasLabel; +import com.franciaflex.faxtomail.persistence.entities.MailField; +import com.franciaflex.faxtomail.persistence.entities.Priority; +import com.franciaflex.faxtomail.persistence.entities.RangeRow; +import com.franciaflex.faxtomail.persistence.entities.Reply; +import com.franciaflex.faxtomail.services.FaxToMailServiceContext; +import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; +import com.franciaflex.faxtomail.ui.swing.actions.ShowDemandeAction; +import com.franciaflex.faxtomail.ui.swing.content.attachment.AttachmentCellEditor; +import com.franciaflex.faxtomail.ui.swing.content.attachment.AttachmentCellRenderer; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; +import com.franciaflex.faxtomail.ui.swing.content.demande.replies.RepliesCellEditor; +import com.franciaflex.faxtomail.ui.swing.content.demande.replies.RepliesCellRenderer; +import com.google.common.base.Function; +import com.google.common.collect.Lists; /** * @author Kevin Morin (Code Lutin) Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/AbstractFaxToMailUIHandler.java 2014-08-21 10:11:20 UTC (rev 580) @@ -26,9 +26,7 @@ import java.awt.Component; import java.awt.Container; -import java.awt.Dialog; import java.awt.Dimension; -import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -46,7 +44,6 @@ import javax.swing.ComboBoxModel; import javax.swing.JComboBox; import javax.swing.JComponent; -import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JRootPane; @@ -56,15 +53,10 @@ import javax.swing.event.TableModelListener; import javax.swing.text.JTextComponent; -import com.franciaflex.faxtomail.persistence.entities.Configuration; -import com.franciaflex.faxtomail.persistence.entities.EtatAttente; -import com.franciaflex.faxtomail.persistence.entities.MailAction; -import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import jaxx.runtime.JAXXUtil; import jaxx.runtime.SwingUtil; import jaxx.runtime.swing.editor.bean.BeanUIUtil; import jaxx.runtime.validator.swing.SwingValidator; -import org.nuiton.jaxx.application.swing.util.CloseableUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -74,15 +66,21 @@ import org.nuiton.jaxx.application.swing.ApplicationUI; import org.nuiton.jaxx.application.swing.action.AbstractApplicationAction; import org.nuiton.jaxx.application.swing.util.Cancelable; +import org.nuiton.jaxx.application.swing.util.CloseableUI; import org.nuiton.validator.bean.simple.SimpleBeanValidator; import com.franciaflex.faxtomail.FaxToMailConfiguration; +import com.franciaflex.faxtomail.persistence.entities.Configuration; +import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.HasLabel; +import com.franciaflex.faxtomail.persistence.entities.MailAction; import com.franciaflex.faxtomail.services.DecoratorService; +import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.content.MainUI; import com.franciaflex.faxtomail.ui.swing.content.MainUIHandler; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; import com.google.common.base.Preconditions; import com.google.common.collect.Sets; @@ -447,10 +445,10 @@ boolean valid = model.isValid(); boolean enabled = - etatAttente == null && (valid || !config.containsInvalidFormDisabledActions(action)) + etatAttente == null && (valid || !FaxToMailServiceUtils.contains(config.getInvalidFormDisabledActions(), action)) || etatAttente != null && - (valid && !etatAttente.containsValidFormDisabledActions(action) - || !valid && !etatAttente.containsInvalidFormDisabledActions(action)); + (valid && !FaxToMailServiceUtils.contains(etatAttente.getValidFormDisabledActions(), action) + || !valid && !FaxToMailServiceUtils.contains(etatAttente.getInvalidFormDisabledActions(), action)); return enabled; } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-08-21 10:11:20 UTC (rev 580) @@ -67,8 +67,10 @@ import com.franciaflex.faxtomail.persistence.entities.DemandType; import com.franciaflex.faxtomail.persistence.entities.MailField; import com.franciaflex.faxtomail.services.FaxToMailServiceContext; +import com.franciaflex.faxtomail.services.FaxToMailServiceUtils; import com.google.common.base.Function; import com.google.common.collect.Ordering; + import jaxx.runtime.JAXXObject; import jaxx.runtime.JAXXUtil; @@ -558,7 +560,7 @@ } public static boolean isRangePanelVisible(DemandType demandType) { - return demandType != null && demandType.containsFields(MailField.RANGE_ROW); + return demandType != null && FaxToMailServiceUtils.contains(demandType.getRequiredFields(), MailField.RANGE_ROW); } } 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-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-08-21 10:11:20 UTC (rev 580) @@ -212,7 +212,7 @@ Champs obligatoires pour le type de document : <div class="checkbox" ng-repeat="(mailField,label) in canBeRequiredMailFields"> <label> - <input type="checkbox" ng-checked="selectedDemandType.fields.indexOf(mailField) != -1" + <input type="checkbox" ng-checked="selectedDemandType.requiredFields.indexOf(mailField) != -1" ng-click="changeDemandTypeField(mailField)"> {{label}} </label> </div> Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-08-21 10:11:20 UTC (rev 580) @@ -301,8 +301,8 @@ $scope.selectedDemandType = demandType; // initialize le tableau d'action si vide - if (!$scope.selectedDemandType.fields) { - $scope.selectedDemandType.fields = []; + if (!$scope.selectedDemandType.requiredFields) { + $scope.selectedDemandType.requiredFields = []; } }; @@ -331,17 +331,11 @@ // selection/deselection d'un champ $scope.changeDemandTypeField = function(mailField) { - var index = $scope.selectedDemandType.fields.indexOf(mailField); + var index = $scope.selectedDemandType.requiredFields.indexOf(mailField); if (index != -1) { - $scope.selectedDemandType.fields.splice(index, 1); + $scope.selectedDemandType.requiredFields.splice(index, 1); } else { - - // cas particulier des gammes - if (mailField == 'RANGE_ROW') { - $scope.selectedDemandType.ediTransfer = true; - } - - $scope.selectedDemandType.fields.push(mailField); + $scope.selectedDemandType.requiredFields.push(mailField); } }; }]); Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2014-08-20 14:10:00 UTC (rev 579) +++ trunk/pom.xml 2014-08-21 10:11:20 UTC (rev 580) @@ -106,7 +106,7 @@ <nuitonWebVersion>1.16</nuitonWebVersion> <eugeneVersion>2.13</eugeneVersion> - <topiaVersion>3.0-beta-12</topiaVersion> + <topiaVersion>3.0-SNAPSHOT</topiaVersion> <hibernateVersion>4.3.6.Final</hibernateVersion> <h2Version>1.3.176</h2Version>
participants (1)
-
echatellier@users.forge.codelutin.com