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 QuestionDAOThe instance of questionDAO that will be used to perform actions to the DB -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInserts an instance of Question in the databasevoidInserts 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 bysurveyIdgetByCategoryLazy(int categoryId, int offset, int limit) Finds the question associated with the category identified bysurveyIdwith Lazy LoadinggetBySurveyId(int surveyId) Finds the question associated with the survey identified bysurveyIdFinds 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 LoadingvoidUpdates a question in the database using a new instance of Question.voidremove(int id) Deletes from the database the question identified by id.voidDeletes 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:
addin 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:
getAllLazyin 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:
getin interfaceQuestionRepository- Specified by:
getin 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 byidhas been found- See Also:
-
getBySurveyId
Finds the question associated with the survey identified bysurveyId- Specified by:
getBySurveyIdin 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:
getByTextin 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:
getByTextLazyin 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:
getByUserin 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:
getByUserLazyin 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:
getByCategoryin interfaceQuestionRepository- Parameters:
categoryId- the id of the category- Returns:
- a list of Questions
- See Also:
-
getByCategoryLazy
Finds the question associated with the category identified bysurveyIdwith Lazy Loading- Specified by:
getByCategoryLazyin 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:
getAllin interfaceQuestionRepository- Returns:
- a list of Questions
- Throws:
NotFoundException
-
remove
Deletes from the database the question identified by id.- Specified by:
removein interfaceQuestionRepository- Parameters:
id- the id of the question to be deleted- Throws:
NotFoundException- if no question identified byidhas 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:
modifyin interfaceQuestionRepository- Parameters:
entity- the new instance of Question- See Also:
-