...
 
Commits (51)
......@@ -9,7 +9,7 @@
<groupId>fr.paris.lutece.plugins</groupId>
<artifactId>plugin-form</artifactId>
<packaging>lutece-plugin</packaging>
<version>4.2.0-SNAPSHOT</version>
<version>4.2.0</version>
<name>Lutece form plugin</name>
<repositories>
<repository>
......@@ -64,5 +64,6 @@
<connection>scm:git:https://github.com/lutece-platform/lutece-form-plugin-form.git</connection>
<developerConnection>scm:git:https://github.com/lutece-platform/lutece-form-plugin-form.git</developerConnection>
<url>https://github.com/lutece-platform/lutece-form-plugin-form.git</url>
</scm>
<tag>plugin-form-4.2.0</tag>
</scm>
</project>
/*
* Copyright (c) 2002-2017, Mairie de Paris
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright notice
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice
* and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* License 1.0
*/
package fr.paris.lutece.plugins.form.business;
/**
*
* class ConditionalEntryFieldMapper
*
*/
public class ConditionalEntriesFieldMapper
{
private int _nIdField;
private String _strConditionalEntries;
public ConditionalEntriesFieldMapper( int nIdField, String strGroupStringBuffer )
{
this._nIdField = nIdField;
this._strConditionalEntries = strGroupStringBuffer;
}
public int getIdField( )
{
return _nIdField;
}
public void setIdField( int _nIdField )
{
this._nIdField = _nIdField;
}
public String getConditionalEntries( )
{
return _strConditionalEntries;
}
public void setConditionalEntries( String _strConditionalEntries )
{
this._strConditionalEntries = _strConditionalEntries;
}
}
......@@ -72,6 +72,8 @@ public class Form implements AdminWorkgroupResource, RBACResource
private String _strTitle;
private String _strFrontOfficeTitle;
private boolean _bIsShownFrontOfficeTitle;
private boolean _bIsShownFrontOfficePicture;
private int _nIdPictureFile;
private String _strDescription;
private String _strWelcomeMessage;
private String _strUnavailabilityMessage;
......@@ -347,6 +349,48 @@ public class Form implements AdminWorkgroupResource, RBACResource
this._bIsShownFrontOfficeTitle = bIsShownFrontOfficeTitle;
}
/**
* get the value of the boolean isShownFrontOfficePicture
*
* @return bIsShownFrontOfficePicture
*/
public boolean isShownFrontOfficePicture( )
{
return _bIsShownFrontOfficePicture;
}
/**
* set the value of the boolean isShownFrontOfficePicture
*
* @param bIsShownFrontOfficePicture
* The value of the boolean isShownFrontOfficePicture
*/
public void setIsShownFrontOfficePicture( boolean bIsShownFrontOfficePicture )
{
this._bIsShownFrontOfficePicture = bIsShownFrontOfficePicture;
}
/**
* get the value of the integer nIdPictureFile
*
* @return the nIdPictureFile
*/
public int getIdPictureFile( )
{
return _nIdPictureFile;
}
/**
* Set the value of the integer nIdPictureFile
*
* @param nIdPictureFile
* the nIdPictureFile to set
*/
public void setIdPictureFile( int nIdPictureFile )
{
this._nIdPictureFile = nIdPictureFile;
}
/**
* Get the description of the form
*
......
......@@ -62,28 +62,29 @@ public final class FormDAO implements IFormDAO
+ "libelle_validate_button,libelle_reset_button,date_begin_disponibility,date_end_disponibility,"
+ " active,auto_publication,date_creation,limit_number_response,id_recap,active_requirement,information_1,"
+ " information_2,information_3,information_4,information_5, supports_https, code_theme, active_mylutece_authentification,"
+ " id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning, max_number_response" + " FROM form_form WHERE id_form = ?";
+ " id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning, max_number_response, is_shown_front_office_picture, id_file_front_office_picture"
+ " FROM form_form WHERE id_form = ?";
private static final String SQL_QUERY_INSERT = "INSERT INTO form_form ( id_form,title,front_office_title,is_shown_front_office_title,description, welcome_message,"
+ "unavailability_message,requirement_message,workgroup,"
+ "id_mailing_list,active_captcha,active_store_adresse,"
+ "libelle_validate_button,libelle_reset_button,date_begin_disponibility,"
+ " date_end_disponibility,active,auto_publication,date_creation,limit_number_response,"
+ " id_recap,active_requirement,information_1,information_2,information_3,information_4,information_5, "
+ " supports_https, code_theme, active_mylutece_authentification, id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning, max_number_response ) "
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ " supports_https, code_theme, active_mylutece_authentification, id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning, max_number_response, is_shown_front_office_picture, id_file_front_office_picture ) "
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
private static final String SQL_QUERY_DELETE = "DELETE FROM form_form WHERE id_form = ? ";
private static final String SQL_QUERY_UPDATE = "UPDATE form_form SET id_form=?,title=?,front_office_title=?,is_shown_front_office_title=?,description=?, welcome_message=?,"
+ "unavailability_message=?, requirement_message=?,workgroup=?,"
+ "id_mailing_list=?,active_captcha=?,active_store_adresse=?,"
+ "libelle_validate_button=?,libelle_reset_button=?,date_begin_disponibility=?,date_end_disponibility=?,active=?,auto_publication=?,limit_number_response=? ,active_requirement=?,"
+ "information_1=? ,information_2=? ,information_3=? ,information_4=? ,information_5=?, supports_https = ?, code_theme = ?, "
+ "active_mylutece_authentification=? ,id_category=?, automatic_cleaning = ?, cleaning_by_removal = ?, nb_days_before_cleaning = ?,max_number_response=? WHERE id_form=?";
+ "active_mylutece_authentification=? ,id_category=?, automatic_cleaning = ?, cleaning_by_removal = ?, nb_days_before_cleaning = ?,max_number_response=?, is_shown_front_office_picture=?, id_file_front_office_picture=? WHERE id_form=?";
private static final String SQL_QUERY_SELECT_FORM_BY_FILTER = "SELECT id_form,title,front_office_title,is_shown_front_office_title,description, welcome_message,"
+ "unavailability_message, requirement_message,workgroup,"
+ "id_mailing_list,active_captcha,active_store_adresse,"
+ "libelle_validate_button,libelle_reset_button,date_begin_disponibility,date_end_disponibility,active,"
+ " auto_publication,date_creation,limit_number_response,id_recap,active_requirement,information_1,"
+ " information_2,information_3,information_4,information_5,supports_https, code_theme, active_mylutece_authentification, id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning, max_number_response "
+ " information_2,information_3,information_4,information_5,supports_https, code_theme, active_mylutece_authentification, id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning, max_number_response, is_shown_front_office_picture, id_file_front_office_picture "
+ " FROM form_form ";
private static final String SQL_QUERY_SELECT_ALL_THEMES = "SELECT id_form, code_theme FROM form_form";
private static final String SQL_QUERY_FIND_ANONYMIZE_ENTRIES = " SELECT id_entry FROM form_anonymize_fields WHERE id_form = ? ";
......@@ -187,6 +188,8 @@ public final class FormDAO implements IFormDAO
daoUtil.setBoolean( nIndex++, form.getCleaningByRemoval( ) );
daoUtil.setInt( nIndex++, form.getNbDaysBeforeCleaning( ) );
daoUtil.setInt( nIndex++, form.getMaxNumberResponse( ) );
daoUtil.setBoolean( nIndex++, form.isShownFrontOfficePicture( ) );
daoUtil.setInt( nIndex++, form.getIdPictureFile( ) );
daoUtil.executeUpdate( );
daoUtil.free( );
......@@ -255,6 +258,8 @@ public final class FormDAO implements IFormDAO
form.setCleaningByRemoval( daoUtil.getBoolean( nIndex++ ) );
form.setNbDaysBeforeCleaning( daoUtil.getInt( nIndex++ ) );
form.setMaxNumberResponse( daoUtil.getInt( nIndex++ ) );
form.setIsShownFrontOfficePicture( daoUtil.getBoolean( nIndex++ ) );
form.setIdPictureFile( daoUtil.getInt( nIndex++ ) );
}
daoUtil.free( );
......@@ -324,6 +329,8 @@ public final class FormDAO implements IFormDAO
daoUtil.setBoolean( nIndex++, form.getCleaningByRemoval( ) );
daoUtil.setInt( nIndex++, form.getNbDaysBeforeCleaning( ) );
daoUtil.setInt( nIndex++, form.getMaxNumberResponse( ) );
daoUtil.setBoolean( nIndex++, form.isShownFrontOfficePicture( ) );
daoUtil.setInt( nIndex++, form.getIdPictureFile( ) );
daoUtil.setInt( nIndex++, form.getIdForm( ) );
......@@ -491,6 +498,8 @@ public final class FormDAO implements IFormDAO
form.setCleaningByRemoval( daoUtil.getBoolean( nIndex++ ) );
form.setNbDaysBeforeCleaning( daoUtil.getInt( nIndex++ ) );
form.setMaxNumberResponse( daoUtil.getInt( nIndex++ ) );
form.setIsShownFrontOfficePicture( daoUtil.getBoolean( nIndex++ ) );
form.setIdPictureFile( daoUtil.getInt( nIndex++ ) );
formList.add( form );
}
......
/*
* Copyright (c) 2002-2017, Mairie de Paris
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright notice
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice
* and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* License 1.0
*/
package fr.paris.lutece.plugins.form.business;
import org.apache.commons.lang.StringUtils;
import fr.paris.lutece.plugins.form.utils.EntryTypeGroupUtils;
import fr.paris.lutece.plugins.form.utils.FormConstants;
import fr.paris.lutece.plugins.genericattributes.business.Entry;
import fr.paris.lutece.plugins.genericattributes.business.EntryHome;
import fr.paris.lutece.plugins.genericattributes.business.Response;
/**
*
* Response object with the identifier of the group which is belong to
*
*/
public class RecapResponse
{
private final Response _response;
private final int _nIdGroup;
private final String _strGroupTitle;
// Constructor
public RecapResponse( Response response )
{
_response = response;
// Retrieve the identifier of the group where the entry of the response belong to
int nIdGroupEntryResponse = EntryTypeGroupUtils.findIdGroupEntryResponse( response );
_nIdGroup = nIdGroupEntryResponse;
// Retrieve the title of the group if it exists
String strEntryGrouptitle = StringUtils.EMPTY;
if ( nIdGroupEntryResponse != FormConstants.DEFAULT_GROUP_NUMBER )
{
Entry entryGroup = EntryHome.findByPrimaryKey( nIdGroupEntryResponse );
if ( entryGroup != null )
{
strEntryGrouptitle = entryGroup.getTitle( );
}
}
_strGroupTitle = strEntryGrouptitle;
}
/**
* Return the response
*
* @return the response
*/
public Response getResponse( )
{
return _response;
}
/**
* Return the identifier of the group of the entry of the response
*
* @return the nIdGroup
*/
public int getIdGroup( )
{
return _nIdGroup;
}
/**
* Return the title of the group where the Response belong to
*
* @return the strGroupTitle
*/
public String getGroupTitle( )
{
return _strGroupTitle;
}
}
......@@ -39,10 +39,16 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import fr.paris.lutece.plugins.form.utils.EntryTypeGroupUtils;
import fr.paris.lutece.plugins.form.service.entrytype.EntryTypeGroup;
import fr.paris.lutece.plugins.form.utils.FormConstants;
import fr.paris.lutece.plugins.genericattributes.business.Entry;
import fr.paris.lutece.plugins.genericattributes.business.EntryHome;
import fr.paris.lutece.plugins.genericattributes.business.Field;
import fr.paris.lutece.plugins.genericattributes.business.Response;
import fr.paris.lutece.plugins.genericattributes.util.GenericAttributesUtils;
import fr.paris.lutece.portal.util.mvc.utils.MVCMessage;
/**
......@@ -51,14 +57,32 @@ import fr.paris.lutece.portal.util.mvc.utils.MVCMessage;
public class IterationGroup
{
private final int _nNbMaxIteration;
private final int _nNbMinIteration;
private Map<Integer, List<IterationResponse>> _mapIterationResponses = new LinkedHashMap<>( );
private List<MVCMessage> _listErrorMessages = new ArrayList<>( );
// Constructor
public IterationGroup( int nIdEntry )
public IterationGroup( Entry entry )
{
_nNbMaxIteration = EntryTypeGroupUtils.getEntryMaxIterationAllowed( nIdEntry );
_mapIterationResponses.put( NumberUtils.INTEGER_ONE, new ArrayList<IterationResponse>( ) );
int nNbMaxIteration = FormConstants.DEFAULT_MINIMUM_ITERATION_NUMBER;
int nNbMinIteration = FormConstants.DEFAULT_MINIMUM_ITERATION_NUMBER;
if ( entry != null )
{
int nIdEntry = entry.getIdEntry( );
nNbMaxIteration = getEntryMaxIterationAllowed( nIdEntry );
int nMinNumberOfIteration = getEntryMinIterationAllowed( nIdEntry );
nNbMinIteration = nMinNumberOfIteration;
for ( int nIterationNumber = NumberUtils.INTEGER_ONE; nIterationNumber <= nMinNumberOfIteration; nIterationNumber++ )
{
_mapIterationResponses.put( nIterationNumber, new ArrayList<IterationResponse>( ) );
}
}
_nNbMaxIteration = nNbMaxIteration;
_nNbMinIteration = nNbMinIteration;
}
/**
......@@ -71,6 +95,16 @@ public class IterationGroup
return _nNbMaxIteration;
}
/**
* Return the minimum number of iteration necessary for the group
*
* @return the minimum number of iteration necessary for the group
*/
public int getNbMinIteration( )
{
return _nNbMinIteration;
}
/**
* Return the list of error messages
*
......@@ -126,6 +160,14 @@ public class IterationGroup
_mapIterationResponses.remove( nIterationNumber );
}
/**
* Add an iteration to the group
*/
public void addIteration( )
{
_mapIterationResponses.put( getLastIterationNumber( ) + NumberUtils.INTEGER_ONE, new ArrayList<IterationResponse>( ) );
}
/**
* Add Responses for the specified entry for the specified iteration
*
......@@ -234,4 +276,58 @@ public class IterationGroup
{
return getIterationNumber( ) >= _nNbMaxIteration;
}
/**
* Return the minimum number of iterations necessary for the entry. Return 0 if a problem occurred.
*
* @param idEntry
* The id of the entry to find the minimum number of iterations necessary
* @return the minimum number of iterations necessary for the entry return 0 if a problem occurred
*/
public static int getEntryMinIterationAllowed( int idEntry )
{
return findFieldValue( idEntry, EntryTypeGroup.CONSTANT_NB_MINIMUM_ITERATION, FormConstants.DEFAULT_MINIMUM_ITERATION_NUMBER );
}
/**
* Return the maximum number of iterations allowed for the entry. Return -1 if none iterations are allowed.
*
* @param idEntry
* The id of the entry to find the maximum number of iterations
* @return the maximum number of iterations allowed for the entry return -1 if none iterations are allowed
*/
public static int getEntryMaxIterationAllowed( int idEntry )
{
return findFieldValue( idEntry, EntryTypeGroup.CONSTANT_NB_ITERATION, FormConstants.DEFAULT_ITERATION_NUMBER );
}
/**
* Retrieve the value of field of an entry. Return the value if found the default value is returned otherwise
*
* @param nIdEntry
* The entry to retrieve the field from
* @param strFieldName
* The name of the field to retrieve
* @param nDefaultValue
* The default value to returned if the field has not found
* @return the value of the field from its name or the default value if not found
*/
public static int findFieldValue( int nIdEntry, String strFieldName, int nDefaultValue )
{
Entry entry = EntryHome.findByPrimaryKey( nIdEntry );
if ( entry != null && StringUtils.isNotBlank( strFieldName ) )
{
Field fieldNbIteration = GenericAttributesUtils.findFieldByTitleInTheList( strFieldName, entry.getFields( ) );
if ( fieldNbIteration != null )
{
return NumberUtils.toInt( fieldNbIteration.getValue( ), nDefaultValue );
}
// If the field doesn't exist we will return the default value
return nDefaultValue;
}
return nDefaultValue;
}
}
......@@ -116,7 +116,7 @@ public class FormPortlet extends Portlet
strUrlAction = AppHTTPSService.getHTTPSUrl( request ) + strUrlAction;
}
XmlUtil.addElementHtml( strXml, TAG_FORM_PORTLET_CONTENT, FormUtils.getHtmlForm( form, strUrlAction, locale, true ) );
XmlUtil.addElementHtml( strXml, TAG_FORM_PORTLET_CONTENT, FormUtils.getHtmlForm( form, strUrlAction, locale, true, request ) );
}
else
{
......
/*
* Copyright (c) 2002-2017, Mairie de Paris
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright notice
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice
* and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* License 1.0
*/
package fr.paris.lutece.plugins.form.business.portlet;
import fr.paris.lutece.portal.business.portlet.IPortletInterfaceDAO;
/**
* IFormPortletDAO
*/
public interface IListFormPortletDAO extends IPortletInterfaceDAO
{
}
/*
* Copyright (c) 2002-2014, Mairie de Paris
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright notice
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice
* and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* License 1.0
*/
package fr.paris.lutece.plugins.form.business.portlet;
import fr.paris.lutece.plugins.form.business.Category;
import fr.paris.lutece.plugins.form.business.CategoryHome;
import fr.paris.lutece.plugins.form.business.Form;
import fr.paris.lutece.plugins.form.business.FormFilter;
import fr.paris.lutece.plugins.form.business.FormHome;
import fr.paris.lutece.portal.business.portlet.Portlet;
import fr.paris.lutece.portal.service.message.SiteMessageException;
import fr.paris.lutece.portal.service.plugin.Plugin;
import fr.paris.lutece.portal.service.plugin.PluginService;
import fr.paris.lutece.util.xml.XmlUtil;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
/**
*
* @author alexandre
*/
public class ListFormPortlet extends Portlet
{
// ///////////////////////////////////////////////////////////////////////////////
// Xml Tags
private static final String TAG_FORM_PORTLET = "form-portlet";
private static final String TAG_FORM_PORTLET_CONTENT = "form-portlet-content";
private static final String TAG_FORM = "form";
private static final String TAG_FORM_ID = "form-id";
private static final String TAG_FORM_TITLE = "form-title";
private static final String TAG_CATEGORY = "category-form";
private static final String TAG_CATEGORY_ID = "category-id";
private static final String TAG_CATEGORY_COLOR = "category-color";
private static final String TAG_CATEGORY_TITLE = "category-title";
private int _nIdCategory;
/**
* Get the id category of the listFormPortlet
*
* @return the id category of the listFormPortlet
*/
public int getIdCategory( )
{
return _nIdCategory;
}
/**
* Set the id category of the listFormPortlet
*
* @param nIdCategory
*/
public void setIdCategory( int nIdCategory )
{
_nIdCategory = nIdCategory;
}
/**
* {@inheritDoc}
*/
@Override
public void remove( )
{
ListFormPortletHome.getInstance( ).remove( this );
}
/**
* Updates the current instance of the form portlet object
*/
public void update( )
{
ListFormPortletHome.getInstance( ).update( this );
}
/**
* {@inheritDoc}
*/
@Override
public String getXml( HttpServletRequest request ) throws SiteMessageException
{
Plugin plugin = PluginService.getPlugin( this.getPluginName( ) );
Locale locale;
if ( request != null )
{
locale = request.getLocale( );
}
else
{
locale = Locale.getDefault( );
}
StringBuffer strXml = new StringBuffer( );
XmlUtil.beginElement( strXml, TAG_FORM_PORTLET );
// Get the portlet
ListFormPortlet portlet = (ListFormPortlet) ListFormPortletHome.findByPrimaryKey( getId( ) );
// Get the list of forms for the configured category
Category category = CategoryHome.findByPrimaryKey( portlet.getIdCategory( ), plugin );
FormFilter filter = new FormFilter( );
filter.setIdCategory( category.getIdCategory( ) );
List<Form> listForm = FormHome.getFormList( filter, plugin );
XmlUtil.beginElement( strXml, TAG_FORM_PORTLET_CONTENT );
if ( category != null )
{
XmlUtil.beginElement( strXml, TAG_CATEGORY );
XmlUtil.addElement( strXml, TAG_CATEGORY_ID, category.getIdCategory( ) );
XmlUtil.addElement( strXml, TAG_CATEGORY_COLOR, category.getColor( ) );
XmlUtil.addElement( strXml, TAG_CATEGORY_TITLE, category.getTitle( ) );
XmlUtil.endElement( strXml, TAG_CATEGORY );
}
if ( !listForm.isEmpty( ) )
{
for ( Form form : listForm )
{
if ( form.isActive( ) )
{
XmlUtil.beginElement( strXml, TAG_FORM );
XmlUtil.addElement( strXml, TAG_FORM_ID, form.getIdForm( ) );
XmlUtil.addElement( strXml, TAG_FORM_TITLE, form.getTitle( ) );
XmlUtil.endElement( strXml, TAG_FORM );
}
}
}
XmlUtil.endElement( strXml, TAG_FORM_PORTLET_CONTENT );
XmlUtil.endElement( strXml, TAG_FORM_PORTLET );
String strXmlDoc = addPortletTags( strXml );
return strXmlDoc;
}
/**
* {@inheritDoc}
*/
@Override
public String getXmlDocument( HttpServletRequest request ) throws SiteMessageException
{
return XmlUtil.getXmlHeader( ) + getXml( request );
}
}
/*
* Copyright (c) 2002-2017, Mairie de Paris
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright notice
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice
* and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* License 1.0
*/
package fr.paris.lutece.plugins.form.business.portlet;
import fr.paris.lutece.portal.business.portlet.Portlet;
import fr.paris.lutece.util.sql.DAOUtil;
/**
* This class provides Data Access methods for ArticlesListPortlet objects
*/
public final class ListFormPortletDAO implements IListFormPortletDAO
{
private static final String SQL_QUERY_INSERT = "INSERT INTO list_form_portlet ( id_portlet , id_category_form ) VALUES ( ? , ? )";
private static final String SQL_QUERY_SELECT = "SELECT id_portlet , id_category_form FROM list_form_portlet WHERE id_portlet = ? ";
private static final String SQL_QUERY_UPDATE = "UPDATE list_form_portlet SET id_portlet = ?, id_category_form = ? WHERE id_portlet = ? ";
private static final String SQL_QUERY_DELETE = "DELETE FROM list_form_portlet WHERE id_portlet= ? ";
// /////////////////////////////////////////////////////////////////////////////////////
// Access methods to data
/**
* Insert a new record in the table form_portlet
*
*
* @param portlet
* the instance of the Portlet object to insert
*/
@Override
public void insert( Portlet portlet )
{
ListFormPortlet p = (ListFormPortlet) portlet;
DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT );
daoUtil.setInt( 1, p.getId( ) );
daoUtil.setInt( 2, p.getIdCategory( ) );
daoUtil.executeUpdate( );
daoUtil.free( );
}
/**
* Deletes records for a portlet identifier in the table form_portlet
*
*
* @param nPortletId
* the portlet identifier
*/
@Override
public void delete( int nPortletId )
{
DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE );
daoUtil.setInt( 1, nPortletId );
daoUtil.executeUpdate( );
daoUtil.free( );
}
/**
* Loads the data of Form Portlet whose identifier is specified in parameter
*
*
* @param nPortletId
* The Portlet identifier
* @return theDocumentListPortlet object
*/
@Override
public Portlet load( int nPortletId )
{
DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT );
daoUtil.setInt( 1, nPortletId );
daoUtil.executeQuery( );
ListFormPortlet portlet = new ListFormPortlet( );
if ( daoUtil.next( ) )
{
portlet.setId( daoUtil.getInt( 1 ) );
portlet.setIdCategory( daoUtil.getInt( 2 ) );
}
daoUtil.free( );
return portlet;
}
/**
* Update the record in the table
*
*
* @param portlet
* A portlet
*/
@Override
public void store( Portlet portlet )
{
ListFormPortlet p = (ListFormPortlet) portlet;
DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE );
daoUtil.setInt( 1, p.getId( ) );
daoUtil.setInt( 2, p.getIdCategory( ) );
daoUtil.setInt( 3, p.getId( ) );
daoUtil.executeUpdate( );
daoUtil.free( );
}
}
/*
* Copyright (c) 2002-2017, Mairie de Paris
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright notice
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice
* and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* License 1.0
*/
package fr.paris.lutece.plugins.form.business.portlet;
import fr.paris.lutece.portal.business.portlet.IPortletInterfaceDAO;
import fr.paris.lutece.portal.business.portlet.PortletHome;
import fr.paris.lutece.portal.business.portlet.PortletTypeHome;
import fr.paris.lutece.portal.service.spring.SpringContextService;
/**
* This class provides instances management methods for ArticlesListPortlet objects
*/
public class ListFormPortletHome extends PortletHome
{
// ///////////////////////////////////////////////////////////////////////////////
// Constants
// Static variable pointed at the DAO instance
private static IListFormPortletDAO _dao = SpringContextService.getBean( "form.listFormPortletDAO" );
/* This class implements the Singleton design pattern. */
private static ListFormPortletHome _singleton;
/**
* Constructor
*/
public ListFormPortletHome( )
{
if ( _singleton == null )
{
_singleton = this;
}
}
/**
* Returns the instance of FormPortletHome
*
* @return the FormPortletHome instance
*/
public static ListFormPortletHome getInstance( )
{
if ( _singleton == null )
{
_singleton = new ListFormPortletHome( );
}
return _singleton;
}
/**
* Returns the identifier of the portlet type
*
* @return the portlet type identifier
*/
@Override
public String getPortletTypeId( )
{
String strCurrentClassName = this.getClass( ).getName( );
String strPortletTypeId = PortletTypeHome.getPortletTypeId( strCurrentClassName );
return strPortletTypeId;
}
/**
* Returns the instance of the portlet DAO singleton
*
* @return the instance of the DAO singleton
*/
@Override
public IPortletInterfaceDAO getDAO( )
{
return _dao;
}
}
......@@ -6,6 +6,7 @@
plugin.description=Form
plugin.provider=Mairie de Paris
portlet.name=Form
portlet.listForm.name=List of forms
################################################################################
# Daemon publication
......@@ -167,12 +168,16 @@ createForm.frontOfficeTitle=Front office: Title
createForm.frontOfficeTitleComment=Choose another title for this form in the front office.
createForm.frontOfficeTitleIsShown=Front office: displayed ?
createForm.frontOfficeTitleIsShownComment=Display or not the front office title.
createForm.frontOfficePictureIsShown=Front office: Display a picture ?
createForm.frontOfficePictureIsShownComment=Allow to display a picture at the top of the form.
createForm.frontOfficePicture=Picture to display at the top of the form
createForm.labelAnonymizeEntries=Answers to anonymize
createForm.labelNbDaysBeforeCleaning=Number of days before answers cleaning
createEntry.labelWidthImage=Width Of the camera
createEntry.labelHeightImage=Height Of the camera
createEntry.labelImageSize=Maximal size of the capture
createEntry.labelImageType=Image type
createForm.labelFormPictureMaxSize=Maximum size of the picture of the form in front-office (in byte)
createForm.titleOpen=Open
createForm.titleClose=Close
......@@ -189,7 +194,6 @@ modifyForm.moveAll=Move all selected questions
modifyForm.manageEnter.title=List of questions
modifyForm.manageEnter.labelQuestionNumber=Number of questions
modifyForm.manageEnter.labelInsertGroup=Insert Group of question
modifyForm.manageEnter.buttonInsertIteration=Insert an iteration
modifyForm.manageEnter.buttonRemoveIteration=Remove an iteration
modifyForm.manageEnter.labelInsertEntry=Insert field
modifyForm.manageEnter.buttonInsertEntry=Insert
......@@ -231,7 +235,11 @@ createEntry.titleQuestion=Create new question
modifyEntry.titleComment=Modify comment
modifyEntry.titleQuestion=Modify question
modifyEntry.titleGroup=Modify group of questions
modifyEntry.typeGroup.message.fieldNbIterations=Number of iterations
modifyEntry.typeGroup.message.error.fieldNbIterations.mandatory=The maximum number of iteration must be specified if the group allow iterations.
modifyEntry.typeGroup.message.error.fieldNbIterations=The maximum number of iteration must be superior than zero.
modifyEntry.typeGroup.message.error.fieldNbMinimumIterations.mandatory=The minimum number of iteration must be specified if the group allow iterations.
modifyEntry.typeGroup.message.error.fieldNbMinimumIterations=The minimum number of iteration must be at least equal to zero.
modifyEntry.typeGroup.message.error.fieldNbIterations.badValue=The maximum number of iteration must be superior or equal to the minimum number of iteration.
createEntry.labelTitle=Title
createEntry.labelTitleComment=Title of the question.
......@@ -272,8 +280,13 @@ createEntry.labelCSSClass=CSS classes
createEntry.labelCSSClassComment=The CSS classes must be separated by a space
createEntry.labelMandatoryErrorMessage=Error message to display if there is no value
createEntry.labelMandatoryErrorMessageHelp=Leave empty to display the default mandatory error message
createEntry.labelIteration=Group which allow iterations
createEntry.labelNbIteration=Number of possible iterations
createEntry.labelHelpNbIteration=Represent how many times you can duplicate this group
createEntry.labelHelpNbIteration=Represent how many times you can duplicate this group. This number must be superior than zero.
createEntry.labelNbMinimumIteration=Minimum number of iterations allowed
createEntry.labelHelpNbMinimumIteration=Represent the minimum number of times you can duplicate this group.
createEntry.labelIterationAddingLabel=Label of the button for adding an iteration
createEntry.labelHelpIterationAddingLabel=Message will be shown for the iteration adding button
createEntry.labelEntryType=Type
createEntry.labelPrefix=Prefix
......@@ -438,9 +451,10 @@ result.graph.labelAxisX=Date
result.graph.labelAxisY=Nbr of validation
listForm.labelForm=Form
listForm.labelFormCategory=Form category
recapFormSubmit.labelLegendRecap=Recap
recapFormSubmit.labelLegendStatistic=Votes Statistic
recapFormSubmit.labelLegendStatistic=Votes Statistic
recapFormSubmit.buttonValidate=Validate recap
recapFormSubmit.buttonBack=Back
recapFormSubmit.buttonCancel=Back to the form
......@@ -491,11 +505,11 @@ message.mandatory.Entry=This field is mandatory.
message.warning.advanced_parameters_save=Modifications will be saved once the form is saved.
message.error.removingFile=The file can't deleted.
message.confirmRemoveEntry=Are you sure to want to delete this field?
message.confirmRemoveEntry=Are you sure to want to delete this field and all his answers?
message.confirmRemoveField=Are you sure to want to delete this question?
message.confirmRemoveGroupNoQuestion=Are you sure to want to delete this field?
message.confirmRemoveGroupWithAnyEntry=Are you sure to want to delete this group of questions?
message.confirmRemoveGroupWhithEntry=The group you want to delete are associated to questions.Are you sure to want to delete this group and the questions associated?
message.confirmRemoveGroupWhithEntry=The group you want to delete are associated to questions.Are you sure to want to delete this group and the questions associated with their answers?
message.confirmRemoveExportFormat=Are you sure to want to delete this export format?
message.regularExpressionCanNotBeRemoved=The regular expression is associated to a form ,You cant't delete this regular expression!
message.stylesheetNotValid=The file is not valide.
......@@ -512,8 +526,9 @@ message.mandatory.form=You must choose a form
message.session.lost=Session lost
message.field_value_field=The value of field do not content special characters or space
message.error.export.encoding.not_supported=The encoding "{0}" is not supported.
message.cantAddIteration=You can't duplicate these fields before filling at least one existing field.
message.limitIterationReached=You can't duplicate these fields because you have reach the limit of the duplication allowed.
message.frontOfficePicture.error.notImage=The uploaded file must be a picture.
message.frontOfficePicture.error.imageSize=The uploaded file has reached the limit size (the maximum size of the uploaded file must be lower than {0} bytes).
###################################################################################
#permission
......
......@@ -6,6 +6,7 @@
plugin.description=Form
plugin.provider=Mairie de Paris
portlet.name=Formulaire
portlet.listForm.name=Liste de formulaires
################################################################################
# Daemon publication
......@@ -165,12 +166,16 @@ createForm.frontOfficeTitle=Front office: Titre
createForm.frontOfficeTitleComment=Permet de choisir le titre affich\u00e9 pour ce formulaire dans le front-office.
createForm.frontOfficeTitleIsShown=Front office: Afficher le titre ?
createForm.frontOfficeTitleIsShownComment=Permet d'afficher ou non le titre ci-dessus en front-office.
createForm.frontOfficePictureIsShown=Front office: Afficher une image ?
createForm.frontOfficePictureIsShownComment=Permet d'afficher une image en haut du formulaire en front-office.
createForm.frontOfficePicture=Image \u00e0 afficher pour le formulaire en front-office
createForm.labelAutomaticCleaning=Nettoyer automatiquement les r\u00e9ponses
createForm.labelCleaningMethod=M\u00e9thode de nettoyage
createForm.labelRemove=Suppression
createForm.labelAnonymize=Anonymisation
createForm.labelAnonymizeEntries=r\u00e9ponses &#224; anonymiser
createForm.labelNbDaysBeforeCleaning=Nombre de jours de conservation des r\u00e9ponses
createForm.labelFormPictureMaxSize=Taille maximale de l'image pour le formulaire en front-office (en octets)
createForm.titleOpen=Ouvrir
createForm.titleClose=Fermer
......@@ -187,7 +192,6 @@ modifyForm.moveAll=D\u00e9placer les questions s\u00e9lectionn\u00e9es dans le r
modifyForm.manageEnter.title=Liste de questions
modifyForm.manageEnter.labelQuestionNumber=Nombre de questions
modifyForm.manageEnter.labelInsertGroup=Ins\u00e9rer un regroupement
modifyForm.manageEnter.buttonInsertIteration=Ajouter une it\u00e9ration
modifyForm.manageEnter.buttonRemoveIteration=Supprimer une it\u00e9ration
modifyForm.manageEnter.labelInsertEntry=Ins\u00e9rer un champ
modifyForm.manageEnter.buttonInsertEntry=Ajouter
......@@ -228,7 +232,11 @@ createEntry.titleQuestion=Cr\u00e9ation d'une question du formulaire
modifyEntry.titleComment=Modification d'un commentaire du formulaire
modifyEntry.titleQuestion=Modification d'une question du formulaire
modifyEntry.titleGroup=Modification d'un regroupement du formulaire
modifyEntry.typeGroup.message.fieldNbIterations=Nombre d'it\u00e9rations
modifyEntry.typeGroup.message.error.fieldNbIterations.mandatory=Le nombre d'it\u00e9rations maximum doit \u00eatre renseign\u00e9 si le regroupement accepte des it\u00e9rations.
modifyEntry.typeGroup.message.error.fieldNbIterations=Le nombre maximum d'it\u00e9rations doit \u00eatre sup\u00e9rieur \u00e0 z\u00e9ro.
modifyEntry.typeGroup.message.error.fieldNbMinimumIterations.mandatory=Le nombre d'it\u00e9rations minimum doit \u00eatre renseign\u00e9 si le regroupement accepte des it\u00e9rations.
modifyEntry.typeGroup.message.error.fieldNbMinimumIterations=Le nombre d'it\u00e9rations minimum doit \u00eatre au minimum \u00e9gal \u00e0 z\u00e9ro.
modifyEntry.typeGroup.message.error.fieldNbIterations.badValue=Le nombre d'it\u00e9rations maximum doit \u00eatre sup\u00e9rieur ou \u00e9gal au nombre d'it\u00e9rations minimum.
createEntry.labelTitle=Titre
createEntry.labelTitleComment=Enonc\u00e9 de la question pos\u00e9e.
......@@ -244,8 +252,13 @@ createEntry.labelAttributeNameComment=Nom de l'attibut de session &#224; r\u00e9
createEntry.labelFileMaxSize=Taille maximale du fichier (en octets)
createEntry.labelMaxFiles=Nombre de fichiers max
createEntry.labelImageType=Type image
createEntry.labelIteration=Regroupement autorisant des it\u00e9rations
createEntry.labelNbIteration=Nombre d'it\u00e9rations possible
createEntry.labelHelpNbIteration=Repr\u00e9sente le nombre de fois o\u00f9 le regroupement peut \u00eatre dupliqu\u00e9
createEntry.labelHelpNbIteration=Repr\u00e9sente le nombre de fois o\u00f9 le regroupement peut \u00eatre dupliqu\u00e9. Ce nombre doit \u00eatre sup\u00e9rieur \u00e0 z\u00e9ro.
createEntry.labelNbMinimumIteration=Nombre d'it\u00e9rations minimum autoris\u00e9
createEntry.labelHelpNbMinimumIteration=Repr\u00e9sente le nombre minimum de fois o\u00f9 le regroupement peut \u00eatre dupliqu\u00e9
createEntry.labelIterationAddingLabel=Label du bouton d'ajout d'une it\u00e9ration
createEntry.labelHelpIterationAddingLabel=Message affich\u00e9 pour le bouton d'ajout d'une it\u00e9ration
createEntry.labelType=Type de question
createEntry.labelPresentation=Mod&#232;le de pr\u00e9sentation
......@@ -439,9 +452,10 @@ result.graph.labelAxisX=Date
result.graph.labelAxisY=Nbr soumissions
listForm.labelForm=Formulaire
listForm.labelFormCategory=Cat\u00e9gorie de formulaire
recapFormSubmit.labelLegendRecap=R\u00e9capitulatif
recapFormSubmit.labelLegendStatistic=Statistic des votes
recapFormSubmit.labelLegendStatistic=Statistiques des votes
recapFormSubmit.buttonValidate=Valider le r\u00e9capitulatif
recapFormSubmit.buttonBack=Retour
recapFormSubmit.buttonCancel=Revenir au formulaire
......@@ -492,11 +506,11 @@ message.mandatory.entry=Ce champ est obligatoire.
message.warning.advanced_parameters_save=Les modifications ne seront prises en compte qu'&#224; l'enregistrement du formulaire.
message.error.removingFile=Une erreur est survenue lors de la suppression du fichier.
message.confirmRemoveEntry=Etes-vous s&#251;r de vouloir supprimer ce champ ?
message.confirmRemoveEntry=Etes-vous s&#251;r de vouloir supprimer ce champ ainsi que toutes les r\u00e9ponses associ\u00e9es ?
message.confirmRemoveField=Etes-vous s&#251;r de vouloir supprimer cette question ?
message.confirmRemoveGroupNoQuestion=Etes-vous s&#251;r de vouloir supprimer ce champ ?
message.confirmRemoveGroupWithAnyEntry=Etes-vous s&#251;r de vouloir supprimer ce regroupement ?
message.confirmRemoveGroupWhithEntry=Le regroupement que vous souhaitez supprimer contient des champs. Etes-vous s&#251;r de vouloir supprimer ce regroupement et les champs associ\u00e9s ?
message.confirmRemoveGroupWhithEntry=Le regroupement que vous souhaitez supprimer contient des champs. Etes-vous s&#251;r de vouloir supprimer ce regroupement et les champs associ\u00e9s ainsi que leurs r\u00e9ponses ?
message.confirmRemoveExportFormat=Etes-vous s&#251;r de vouloir supprimer ce format d'export ?
message.regularExpressionCanNotBeRemoved=Un ou plusieurs formulaires utilisent cette expression r\u00e9guli&#232;re.
message.stylesheetNotValid=Le fichier n'est pas valide.
......@@ -513,8 +527,9 @@ message.mandatory.form=Vous devez s\u00e9lectionner un formulaire
message.session.lost=La session a expir\u00e9
message.field_value_field=Le champ valeur ne doit pas contenir de caract&#232;res sp\u00e9ciaux ou d'espaces
message.error.export.encoding.not_supported=L''encoding "{0}" n''est pas correct.
message.cantAddIteration=Vous ne pouvez pas dupliquer ces champs avant d'avoir remplis au moins un de ceux existants.
message.limitIterationReached=Vous ne pouvez plus dupliquer ces champs car vous avez atteint le nombre de duplication maximum.
message.frontOfficePicture.error.notImage=Le fichier charg\u00e9 doit \u00eatre une image.
message.frontOfficePicture.error.imageSize=Le fichier charg\u00e9 est trop volumineux (taille maximale du fichier autoris\u00e9: {0} octets).
###################################################################################
#permission
......
......@@ -200,7 +200,7 @@ public class EntryTypeMyLuteceUserAttribute extends AbstractEntryTypeMyLuteceUse
// Then construct the item
StringBuilder myLuteceAttribute18nKey = new StringBuilder( );
myLuteceAttribute18nKey.append( FormUtils.CONSTANT_MYLUTECE_ATTRIBUTE_I18N_SUFFIX );
myLuteceAttribute18nKey.append( FormUtils.CONSTANT_MYLUTECE_ATTRIBUTE_I18N_PREFIX );
myLuteceAttribute18nKey.append( strAttribute );
item.setName( I18nService.getLocalizedString( myLuteceAttribute18nKey.toString( ), Locale.forLanguageTag( strLangage ) ) );
......
......@@ -64,6 +64,7 @@ public class FormConstants
public static final String MARK_FORM_SUBMIT = "formSubmit";
public static final String MARK_URL_ACTION = "url_action";
public static final String MARK_STR_LIST_CHILDREN = "str_list_entry_children";
public static final String MARK_LIST_MAP_CHILDREN = "list_entry_children";
// Prefixes
public static final String PREFIX_ITERATION = "nIt";
......@@ -76,5 +77,7 @@ public class FormConstants
// Other constants
public static final String CONSTANT_WHERE = " WHERE ";
public static final String CONSTANT_AND = " AND ";
public static final int DEFAULT_GROUP_NUMBER = NumberUtils.INTEGER_MINUS_ONE;
public static final int DEFAULT_ITERATION_NUMBER = NumberUtils.INTEGER_MINUS_ONE;
public static final int DEFAULT_MINIMUM_ITERATION_NUMBER = NumberUtils.INTEGER_ZERO;
}
......@@ -56,8 +56,8 @@ import fr.paris.lutece.plugins.form.business.FormSubmit;
import fr.paris.lutece.plugins.form.business.FormSubmitHome;
import fr.paris.lutece.plugins.form.business.Recap;
import fr.paris.lutece.plugins.form.business.RecapHome;
import fr.paris.lutece.plugins.form.business.RecapResponse;
import fr.paris.lutece.plugins.form.business.RequirementFormError;
import fr.paris.lutece.plugins.form.business.iteration.IterationGroup;
import fr.paris.lutece.plugins.form.business.outputprocessor.IOutputProcessor;
import fr.paris.lutece.plugins.form.service.EntryTypeService;
import fr.paris.lutece.plugins.form.service.FormPlugin;
......@@ -132,9 +132,9 @@ public class FormApp extends MVCApplication
private static final String MARK_ENTRY_TYPE_SESSION = "entry_type_session";
private static final String MARK_ENTRY_TYPE_NUMBERING = "entry_type_numbering";
private static final String MARK_IS_DRAFT_SAVED = "is_draft_saved";
private static final String MARK_FORM_ERRORS = "form_errors";
private static final String MARK_ORDER = "order";
private static final String MARK_ASC = "asc";
private static final String MARK_LIST_RECAP_RESPONSE = "list_recap_response";
// templates
private static final String TEMPLATE_XPAGE_RECAP_FORM_SUBMIT = "skin/plugins/form/recap_form_submit.html";
......@@ -286,14 +286,11 @@ public class FormApp extends MVCApplication
return getFormView( request );
}
if ( request.getParameter( FormConstants.PARAMETER_ACTION_ADD_ITERATION ) != null )
{
cleanSession( request.getSession( ) );
cleanSession( request.getSession( ) );
return getForm( request );
}
EntryTypeGroupUtils.manageAddingIteration( request );
return getFormView( request );
return getForm( request );
}
/**
......@@ -313,17 +310,11 @@ public class FormApp extends MVCApplication
return getFormView( request );
}
String strRemoveIteration = request.getParameter( FormConstants.PARAMETER_ACTION_REMOVE_ITERATION );
if ( StringUtils.isNotBlank( strRemoveIteration ) )
{
cleanSession( request.getSession( ) );
EntryTypeGroupUtils.manageRemoveIterationGroup( request );
cleanSession( request.getSession( ) );
return getForm( request );
}
EntryTypeGroupUtils.manageRemoveIterationGroup( request );
return getFormView( request );
return getForm( request );
}
/**
......@@ -483,7 +474,7 @@ public class FormApp extends MVCApplication
FormAsynchronousUploadHandler.getHandler( ).removeSessionFiles( strSessionId );
// Add the iterationMap to the session
populateIterationGroupMap( session, nIdForm );
EntryTypeGroupUtils.populateIterationGroupMap( session, nIdForm );
}
/**
......@@ -847,9 +838,6 @@ public class FormApp extends MVCApplication
page.setPathLabel( form.getTitle( ) );
}
// Retrieve the session from the request
HttpSession session = request.getSession( );
if ( !form.isActive( ) )
{
model.put( MARK_MESSAGE_FORM_INACTIVE, form.getUnavailabilityMessage( ) );
......@@ -860,7 +848,7 @@ public class FormApp extends MVCApplication
if ( AppHTTPSService.isHTTPSSupportEnabled( ) )
{
session.setAttribute( AppPathService.SESSION_BASE_URL, AppPathService.getBaseUrl( request ) );
request.getSession( ).setAttribute( AppPathService.SESSION_BASE_URL, AppPathService.getBaseUrl( request ) );
strUrlAction = AppHTTPSService.getHTTPSUrl( request ) + strUrlAction;
}
......@@ -879,9 +867,6 @@ public class FormApp extends MVCApplication
model.put( MARK_IS_DRAFT_SAVED, bIsDraftSaved );
// Check if there are responses in the session. If so, then there are errors
model.put( MARK_FORM_ERRORS, FormUtils.getFormErrors( session ) );
HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_XPAGE_FORM, request.getLocale( ), model );
page.setContent( template.getHtml( ) );
......@@ -998,6 +983,9 @@ public class FormApp extends MVCApplication
FormUtils.removeFormErrors( session );
session.removeAttribute( SESSION_VALIDATE_REQUIREMENT );
// Create the list of RecapResponse objects
List<RecapResponse> listRecapResponse = new ArrayList<>( );
// convert the value of the object response to string
for ( Response response : formSubmit.getListResponse( ) )
{
......@@ -1010,8 +998,14 @@ public class FormApp extends MVCApplication
{
response.setToStringValueResponse( StringUtils.EMPTY );
}
// Create a RecapResponse object for the current Response and add it to the list
listRecapResponse.add( new RecapResponse( response ) );
}
// Add the list of RecapResponse object to the model
model.put( MARK_LIST_RECAP_RESPONSE, listRecapResponse );
if ( form.isSupportHTTPS( ) && AppHTTPSService.isHTTPSSupportEnabled( ) )
{
recap.setBackUrl( AppHTTPSService.getHTTPSUrl( request ) + recap.getBackUrl( ) );
......@@ -1322,32 +1316,6 @@ public class FormApp extends MVCApplication
}
}
/**
* Populate the iteration map of a form and set it to the session
*
* @param session
* The session to set the map inside
* @param nIdForm
* The id of the form to create the iteration group from
*/
private void populateIterationGroupMap( HttpSession session, int nIdForm )
{
if ( session != null )
{
Map<Integer, IterationGroup> mapIterationGroup = new LinkedHashMap<Integer, IterationGroup>( );
List<Integer> listIdEntryGroupIterable = EntryTypeGroupUtils.findIdEntryGroupIterable( nIdForm );
if ( listIdEntryGroupIterable != null )
{
for ( Integer identryIterableGroup : listIdEntryGroupIterable )
{
mapIterationGroup.put( identryIterableGroup, new IterationGroup( identryIterableGroup ) );
}
}
session.setAttribute( FormConstants.SESSION_ITERATION_MAP, mapIterationGroup );
}
}
/**
* Detect if the iteration map of the form is lost or not.
*
......
This diff is collapsed.
/*
* Copyright (c) 2002-2017, Mairie de Paris
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright notice
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice
* and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* License 1.0
*/
package fr.paris.lutece.plugins.form.web.portlet;
import fr.paris.lutece.plugins.form.business.Category;
import fr.paris.lutece.plugins.form.business.CategoryHome;
import fr.paris.lutece.plugins.form.business.portlet.ListFormPortlet;
import fr.paris.lutece.plugins.form.business.portlet.ListFormPortletHome;
import fr.paris.lutece.plugins.form.utils.FormUtils;
import fr.paris.lutece.plugins.form.web.FormJspBean;
import fr.paris.lutece.portal.business.portlet.PortletHome;
import fr.paris.lutece.portal.business.portlet.PortletType;
import fr.paris.lutece.portal.business.portlet.PortletTypeHome;
import fr.paris.lutece.portal.service.message.AdminMessage;
import fr.paris.lutece.portal.service.message.AdminMessageService;
import fr.paris.lutece.portal.service.plugin.Plugin;
import fr.paris.lutece.portal.service.plugin.PluginService;
import fr.paris.lutece.portal.service.util.AppLogService;
import fr.paris.lutece.portal.web.portlet.PortletJspBean;
import fr.paris.lutece.util.ReferenceList;
import fr.paris.lutece.util.html.HtmlTemplate;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;