Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ public interface IQuestionDAO
List<Question> selectQuestionsList( Plugin plugin );

/**
* Load the data of all the question objects and returns them as a list
* Load the data of the question objects related to multiview and returns them as a list
*
* @param plugin
* the Plugin
* @return The list which contains the uncomplete data of all the question objects
* @return The list which contains the uncomplete data of the question objects related to multiview
*/
List<Question> selectQuestionsListUncomplete( Plugin plugin );

Expand All @@ -160,13 +160,13 @@ public interface IQuestionDAO
List<Question> selectQuestionsListByFormId( int nIdForm, Plugin plugin );

/**
* Load the data of all the question objects by form id and returns them as a list
* Load the data of the question objects related to multiview by form id and returns them as a list
*
* @param nIdForm
* The id of the form
* @param plugin
* The plugin
* @return The list which contains the data of all the question objects by given form id
* @return The list which contains the data of the question objects related to multiview by given form id
*/
List<Question> selectQuestionsListByFormIdUncomplete( int nIdForm, Plugin plugin );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public final class QuestionDAO implements IQuestionDAO
private static final String SQL_QUERY_SELECT_BY_STEP = SQL_QUERY_SELECT_ALL + " WHERE id_step = ?";
private static final String SQL_QUERY_SELECTALL_BY_FORM = "SELECT fq.id_question, fq.title, fq.code, fq.description, fq.id_entry, fq.id_step, fq.is_visible_multiview_global, fq.is_visible_multiview_form_selected , fq.column_title, fq.is_filterable_multiview_global, fq.is_filterable_multiview_form_selected,fq.multiview_column_order,fq.export_display_order FROM forms_question fq INNER JOIN forms_step fs ON fq.id_step = fs.id_step WHERE fs.id_form = ?";
private static final String SQL_QUERY_SELECT_IN = SQL_QUERY_SELECT_ALL + " WHERE id_question IN ( ";

private static final String SQL_QUERY_SELECT_ALL_UNCOMPLETE = SQL_QUERY_SELECT_ALL + " where (is_visible_multiview_global = '1' or is_filterable_multiview_global = '1')";
private static final String SQL_QUERY_SELECT_BY_STEP_UNCOMPLETE = SQL_QUERY_SELECTALL_BY_FORM + " and (is_visible_multiview_global = '1' or is_visible_multiview_form_selected = '1' or is_filterable_multiview_global = '1' or is_filterable_multiview_form_selected = '1')";

/**
* {@inheritDoc }
*/
Expand Down Expand Up @@ -278,7 +280,7 @@ public List<Integer> selectIdQuestionsList( Plugin plugin )
public List<Question> selectQuestionsListUncomplete( Plugin plugin )
{
List<Question> questionList = new ArrayList<>( );
try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_ALL, plugin ) )
try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_ALL_UNCOMPLETE, plugin ) )
{
daoUtil.executeQuery( );

Expand Down Expand Up @@ -337,7 +339,7 @@ public List<Question> selectQuestionsListByFormId( int nIdForm, Plugin plugin )
public List<Question> selectQuestionsListByFormIdUncomplete( int nIdForm, Plugin plugin )
{
List<Question> questionList = new ArrayList<>( );
try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECTALL_BY_FORM, plugin ) )
try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_BY_STEP_UNCOMPLETE , plugin ) )
{
daoUtil.setInt( 1, nIdForm );
daoUtil.executeQuery( );
Expand Down
37 changes: 28 additions & 9 deletions src/java/fr/paris/lutece/plugins/forms/business/QuestionHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private QuestionHome( )
public static Question create( Question question )
{
_dao.insert( question, _plugin );

_cache.resetCache();
return question;
}

Expand All @@ -86,7 +86,7 @@ public static Question create( Question question )
public static Question update( Question question )
{
_dao.store( question, _plugin );
_cache.removeKey( _cache.getQuestionCacheKey( question.getId( ) ) );
_cache.resetCache();
return question;
}

Expand All @@ -104,7 +104,7 @@ public static void remove( int nKey )
EntryHome.remove( questionToDelete.getIdEntry( ) );
}
_dao.delete( nKey, _plugin );
_cache.removeKey( _cache.getQuestionCacheKey( nKey ) );
_cache.resetCache();
}

/**
Expand Down Expand Up @@ -178,13 +178,22 @@ public static List<Question> getQuestionsList( )
}

/**
* Load the data of all the question objects and returns them as a list
* Load the data of the question objects related to multiview and returns them as a list
*
* @return the list which contains the data of all the question objects
* @return the list which contains the data of the question objects related to multiview
*/
public static List<Question> getQuestionsListUncomplete( )
{
return _dao.selectQuestionsListUncomplete( _plugin );
String cacheKey = _cache.getUncompleteQuestionCacheKey( );
@SuppressWarnings( "unchecked" )
List<Question> listQuestion = ( List<Question> ) _cache.getFromCache( cacheKey );
if ( listQuestion == null )
{
listQuestion = _dao.selectQuestionsListUncomplete( _plugin );
_cache.putInCache( cacheKey, listQuestion );
}

return listQuestion;
}

/**
Expand Down Expand Up @@ -212,15 +221,25 @@ public static List<Question> getListQuestionByIdForm( int nIdForm )
}

/**
* Load the data of all the question objects for given form id and returns them as a list
* Load the data of the question objects related to multiview for given form id and returns them as a list
*
* @param nIdForm
* The id of the form
* @return the list of all the question objects for the given form id
* @return the list of the question objects related to multiview for the given form id
*/
public static List<Question> getListQuestionByIdFormUncomplete( int nIdForm )
{
return _dao.selectQuestionsListByFormIdUncomplete( nIdForm, _plugin );

String cacheKey = _cache.getUncompleteQuestionByFormCacheKey( nIdForm );
@SuppressWarnings( "unchecked" )
List<Question> listQuestion = ( List<Question> ) _cache.getFromCache( cacheKey );
if ( listQuestion == null )
{
listQuestion = _dao.selectQuestionsListByFormIdUncomplete( nIdForm, _plugin );
_cache.putInCache( cacheKey, listQuestion );
}

return listQuestion;
}

/**
Expand Down
12 changes: 10 additions & 2 deletions src/java/fr/paris/lutece/plugins/forms/business/StepHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private StepHome( )
public static Step create( Step step )
{
_dao.insert( step, _plugin );
_cache.putInCache( _cache.getStepCacheKey( step.getId( ) ), step );
_cache.resetCache( );
return step;
}

Expand Down Expand Up @@ -192,7 +192,15 @@ public static List<Integer> getIdStepsList( )
*/
public static List<Integer> getIdStepsListByForm( int nIdForm )
{
return _dao.selectIdStepsListByForm( nIdForm, _plugin );
String stepCacheKey = _cache.getIdStepByFormKey( nIdForm );
@SuppressWarnings( "unchecked" )
List<Integer> listIdStep = ( List<Integer> ) _cache.getFromCache( stepCacheKey );
if ( listIdStep == null )
{
listIdStep = _dao.selectIdStepsListByForm( nIdForm, _plugin );
_cache.putInCache( stepCacheKey, listIdStep );
}
return listIdStep;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public String getInitialStepCacheKey( int nIdForm )
return new StringBuilder( "Initial-Step-For-Form-id:" ).append( nIdForm ).toString( );
}

public String getIdStepByFormKey( int nIdQuestion )
{
return new StringBuilder( "Step-For-Form-id:" ).append( nIdQuestion ).toString( );
}

public String getFormCacheKey( int nIdForm )
{
return new StringBuilder( "Form-id:" ).append( nIdForm ).toString( );
Expand Down Expand Up @@ -100,6 +105,16 @@ public String getQuestionCacheKey( int nIdQuestion )
return new StringBuilder( "Question-id:" ).append( nIdQuestion ).toString( );
}

public String getUncompleteQuestionCacheKey( )
{
return new StringBuilder( "Question-Uncomplete" ).toString( );
}

public String getUncompleteQuestionByFormCacheKey( int nIdForm )
{
return new StringBuilder( "Question-Uncomplete-by-Form:" ).append( nIdForm ).toString( );
}

public String getFormDisplayCacheKey( int nIdFormDisplay )
{
return new StringBuilder( "FormDisplay-id:" ).append( nIdFormDisplay ).toString( );
Expand Down