Package org.ametys.plugins.survey.data
Class SurveyAnswerDao
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.datasource.AbstractMyBatisDAO
-
- org.ametys.plugins.survey.data.SurveyAnswerDao
-
- All Implemented Interfaces:
LogEnabled
,PluginAware
,Component
,Configurable
,Contextualizable
,Serviceable
public class SurveyAnswerDao extends AbstractMyBatisDAO
Survey answer DAO.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ROLE
The Avalon role name.-
Fields inherited from class org.ametys.core.datasource.AbstractMyBatisDAO
_manager
-
-
Constructor Summary
Constructors Constructor Description SurveyAnswerDao()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSession(SurveySession session)
Insert a session with its answers.void
deleteSession(String sessionId)
Delete a session with its answers.void
deleteSessions(String surveyId)
Delete sessions related to a given survey.List<Map<String,Object>>
getAllSessionCount()
Get the session count list.List<SurveyAnswer>
getAnswers(int sessionId)
Get the answers of a session.SurveySession
getSession(int sessionId)
Get a session from its ID.SurveySession
getSession(String surveyId, UserIdentity user)
Get a user session from the survey ID and the user identity.int
getSessionCount(String surveyId)
Get the count of sessions for a given survey.List<SurveySession>
getSessions()
Get the exhaustive list of sessions.List<SurveySession>
getSessions(String surveyId)
Get all the sessions of a given survey.List<SurveySession>
getSessionsWithAnswers(String surveyId)
Get all the sessions of a given survey, with their answers.SurveySession
getSessionWithAnswers(int sessionId)
Get a session from its ID.protected String
getStatementSuffix(Connection connection)
Get the statement name suffix, depending of the DBMS family.-
Methods inherited from class org.ametys.core.datasource.AbstractMyBatisDAO
_configureDatasource, _getDataSourceId, _getMyBatisConfiguration, configure, contextualize, getSession, getSession, reload, service, setPluginInfo
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Constructor Detail
-
SurveyAnswerDao
public SurveyAnswerDao()
-
-
Method Detail
-
getSession
public SurveySession getSession(int sessionId)
Get a session from its ID.- Parameters:
sessionId
- the session ID.- Returns:
- the session.
-
getSession
public SurveySession getSession(String surveyId, UserIdentity user)
Get a user session from the survey ID and the user identity.- Parameters:
surveyId
- the survey ID.user
- the user.- Returns:
- the session.
-
getSessionWithAnswers
public SurveySession getSessionWithAnswers(int sessionId)
Get a session from its ID.- Parameters:
sessionId
- the session ID.- Returns:
- the session.
-
getSessionCount
public int getSessionCount(String surveyId)
Get the count of sessions for a given survey.- Parameters:
surveyId
- the survey ID.- Returns:
- the session count for this survey.
-
getAllSessionCount
public List<Map<String,Object>> getAllSessionCount()
Get the session count list.- Returns:
- the session count list.
-
getSessions
public List<SurveySession> getSessions()
Get the exhaustive list of sessions.- Returns:
- the sessions.
-
getSessions
public List<SurveySession> getSessions(String surveyId)
Get all the sessions of a given survey.- Parameters:
surveyId
- the survey ID.- Returns:
- the sessions.
-
getSessionsWithAnswers
public List<SurveySession> getSessionsWithAnswers(String surveyId)
Get all the sessions of a given survey, with their answers.- Parameters:
surveyId
- the survey ID.- Returns:
- the sessions with their answers.
-
getAnswers
public List<SurveyAnswer> getAnswers(int sessionId)
Get the answers of a session.- Parameters:
sessionId
- the session ID.- Returns:
- the session answers.
-
addSession
public void addSession(SurveySession session) throws SQLException
Insert a session with its answers.- Parameters:
session
- the session.- Throws:
SQLException
- if a database access error occurs
-
deleteSession
public void deleteSession(String sessionId)
Delete a session with its answers.- Parameters:
sessionId
- the session ID.
-
deleteSessions
public void deleteSessions(String surveyId)
Delete sessions related to a given survey.- Parameters:
surveyId
- the survey ID.
-
getStatementSuffix
protected String getStatementSuffix(Connection connection)
Get the statement name suffix, depending of the DBMS family.- Parameters:
connection
- the connection.- Returns:
- the statement suffix.
-
-