Class QuestionRepositoryImpl
java.lang.Object
it.unimib.unimibmodules.repository.QuestionRepositoryImpl
- All Implemented Interfaces:
QuestionRepository
,QuestionRepositoryReadOnly
@Component("questionRepository")
public class QuestionRepositoryImpl
extends Object
implements QuestionRepository, QuestionRepositoryReadOnly
Repository for the Question class.
- Version:
- 0.4.1
- Author:
- Khalil
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final QuestionDAO
The instance of questionDAO that will be used to perform actions to the DB -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Inserts an instance of Question in the databasevoid
Inserts a list of questions in the databaseget
(int id) Finds the question identified by id in the databasegetAll()
Returns all questions in the database.getAllLazy
(int offset, int limit) Finds all the questions in the database with Lazy Loading parametersgetByCategory
(int categoryId) Finds the question associated with the category identified bysurveyId
getByCategoryLazy
(int categoryId, int offset, int limit) Finds the question associated with the category identified bysurveyId
with Lazy LoadinggetBySurveyId
(int surveyId) Finds the question associated with the survey identified bysurveyId
Finds the question in the database where text is contained in the text of the questiongetByTextLazy
(String text, int offset, int limit) Finds the question in the database where text is contained in the text of the question for lazy loadinggetByUser
(int userId) Finds the question in the database created by a specified usergetByUserLazy
(int userId, int offset, int limit) Finds the question in the database created by a specified user with Lazy Loadingvoid
Updates a question in the database using a new instance of Question.void
remove
(int id) Deletes from the database the question identified by id.void
Deletes all questions in the database.
-
Field Details
-
questionDAO
The instance of questionDAO that will be used to perform actions to the DB
-
-
Constructor Details
-
QuestionRepositoryImpl
-
-
Method Details
-
add
Inserts an instance of Question in the database- Specified by:
add
in interfaceQuestionRepository
- Parameters:
entity
- an instance of Question- See Also:
-
addAll
Inserts a list of questions in the database- Parameters:
entities
- a list of Questions
-
getAllLazy
Finds all the questions in the database with Lazy Loading parameters- Specified by:
getAllLazy
in interfaceQuestionRepository
- Parameters:
offset
- initial position for the querylimit
- limiting query results- Returns:
- a list of Questions
- See Also:
-
get
Finds the question identified by id in the database- Specified by:
get
in interfaceQuestionRepository
- Specified by:
get
in interfaceQuestionRepositoryReadOnly
- Parameters:
id
- the id of the question to be found- Returns:
- an instance of Question if there is a question identified by id, null otherwise
- Throws:
NotFoundException
- if no question identified byid
has been found- See Also:
-
getBySurveyId
Finds the question associated with the survey identified bysurveyId
- Specified by:
getBySurveyId
in interfaceQuestionRepository
- Parameters:
surveyId
- the id of the survey- Returns:
- a list of Questions
- See Also:
-
getByText
Finds the question in the database where text is contained in the text of the question- Specified by:
getByText
in interfaceQuestionRepository
- Parameters:
text
- the text to search in the question- Returns:
- a list of Questions where the text is contained in the text of the question
-
getByTextLazy
Finds the question in the database where text is contained in the text of the question for lazy loading- Specified by:
getByTextLazy
in interfaceQuestionRepository
- Parameters:
text
- the id of the surveyoffset
- initial position for the querylimit
- limiting query results- Returns:
- a list of Questions where the text is contained in the text of the question
-
getByUser
Finds the question in the database created by a specified user- Specified by:
getByUser
in interfaceQuestionRepository
- Parameters:
userId
- id of the user- Returns:
- an instance of Question if there is a question identified by id, null otherwise
-
getByUserLazy
Finds the question in the database created by a specified user with Lazy Loading- Specified by:
getByUserLazy
in interfaceQuestionRepository
- Parameters:
userId
- id of the useroffset
- initial position for the querylimit
- limiting query results- Returns:
- an instance of Question if there is a question identified by id, null otherwise
-
getByCategory
Finds the question associated with the category identified bysurveyId
- Specified by:
getByCategory
in interfaceQuestionRepository
- Parameters:
categoryId
- the id of the category- Returns:
- a list of Questions
- See Also:
-
getByCategoryLazy
Finds the question associated with the category identified bysurveyId
with Lazy Loading- Specified by:
getByCategoryLazy
in interfaceQuestionRepository
- Parameters:
categoryId
- the id of the categoryoffset
- initial position for the querylimit
- limiting query results- Returns:
- a list of Questions
-
getAll
Returns all questions in the database.- Specified by:
getAll
in interfaceQuestionRepository
- Returns:
- a list of Questions
- Throws:
NotFoundException
-
remove
Deletes from the database the question identified by id.- Specified by:
remove
in interfaceQuestionRepository
- Parameters:
id
- the id of the question to be deleted- Throws:
NotFoundException
- if no question identified byid
has been found- See Also:
-
removeAll
public void removeAll()Deletes all questions in the database. -
modify
Updates a question in the database using a new instance of Question.- Specified by:
modify
in interfaceQuestionRepository
- Parameters:
entity
- the new instance of Question- See Also:
-