Package com.ubs.backend.services
Class Get
java.lang.Object
com.ubs.backend.services.Get
All Services which return some JSON Object or List of Database Entries
- Since:
- 17.07.2021
- Author:
- Tim Irmler, Marc, Magnus, Sarah
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate TempAnsweraddTagsToTempAnswer(Answer answer, int tagLimit, javax.persistence.EntityManager em)allAnsweredQuestions(long answerID)allAnsweredQuestions(String timeRangeString, String withAnswersString, javax.servlet.http.HttpServletRequest request)allUnansweredQuestions(String timeRangeString, javax.servlet.http.HttpServletRequest request)javax.ws.rs.core.Responseprivate StringbuildAnsweredQuestionJsonResponse(List<TempAnsweredQuestion> tempAnsweredQuestions)private StringbuildAnsweredQuestionJsonResponse(List<TempAnsweredQuestion> tempAnsweredQuestions, boolean withAnswers)private StringbuildAnsweredQuestionPerAnswerJsonResponse(List<TempAnsweredQuestionTimesResult> tempAnsweredQuestionTimesResults)private StringbuildSingleAnsweredQuestionJsonResponse(TempAnsweredQuestion tempAnsweredQuestion)private StringbuildSingleAnsweredQuestionJsonResponse(TempAnsweredQuestion tempAnsweredQuestion, boolean withAnswers)private StringbuildUnansweredQuestionJsonResponse(List<TempUnansweredQuestion> unansweredQuestions)javax.ws.rs.core.ResponsecheckCanMatchBlacklist(String word)defaultQuestionRandom(String amountQuestionsString)service to get random default questions with a set amountjavax.ws.rs.core.Responsefind()Service to get all Tags in the Databaseprivate StringgenerateAllAnswersJson(List<TempAnswer> tempAnswers, String listName)private StringgenerateJSONResponseAllAnswers(List<TempAnswer> answers)Generates the JSON Response for a List of multiple Answersprivate StringgenerateJSONResponseAllBlackList(List<BlacklistEntry> blacklistEntries)Generates a JSON Object with a List of blacklistEntriesprivate StringgenerateJSONResponseAllDefaultQuestion(List<DefaultQuestion> defaultQuestions)generate the JSON string for all default questionprivate StringgenerateJSONResponseAllFiles(List<UploadFile> files)Generates a JSON String for all Filesprivate StringgenerateJSONResponseAllMatches(List<Match> matches)Generates a JSON Object with a List of blacklistEntriesgenerateJSONResponseAllTags(List<TempTag> tags)Generates a JSON Object with a List of Tagsprivate StringgenerateJSONResponseAllUsers(List<UserLogin> userLogins, long loggedInUserID)Generates the JSON Response for a List of multiple Usersprivate StringgenerateJSONResponseAnswerTypes(AnswerType neededAnswerType)private StringBuilds a JSON Object of all tag Stringsprivate StringgenerateJSONResponseSingleTag(TempTag tempTag)private StringgenerateSingleAnswerJson(TempAnswer answer, String answerTypeJSON)javax.ws.rs.core.ResponsegetAllAnswers(String tagLimitString)Restful service that returns all answers with a max set amount of tags.javax.ws.rs.core.ResponsegetAllAnswersWhereTagId(String tagLimitString)javax.ws.rs.core.Responseservice to get all blacklistentriesjavax.ws.rs.core.Responseservice to get all default wuestionsjavax.ws.rs.core.Responseservice to get all matchesjavax.ws.rs.core.Responseservice to get all tags with their valuesjavax.ws.rs.core.ResponsegetAllTagsByTypeWithInfos(String typeValueString)getAllTagsWithExtraInformationsByType(AnswerType type, javax.persistence.EntityManager em)getAllTagsWithExtraInformationsFromGroupedTypeTagByType(AnswerType type, javax.persistence.EntityManager em)getAllTagsWithExtraInformationsFromResultByType(AnswerType type, javax.persistence.EntityManager em)javax.ws.rs.core.ResponsegetAllTypedTagsByType(String typeValueString)returns all tags with a specific type from the table typedTags as simple stringsjavax.ws.rs.core.ResponsegetAllUser(javax.servlet.http.HttpServletRequest request)Get all usersjavax.ws.rs.core.ResponseGet Max Lengths for input fieldsjavax.ws.rs.core.ResponsegetSingleAnswer(long answerID)Get a single answer with all the tags it's usingjavax.ws.rs.core.ResponsegetSingleBlacklistEntry(long id)javax.ws.rs.core.ResponsegetSingleDefaultQuestion(long defaultQuestionId)returns a json object containing a single questionjavax.ws.rs.core.ResponsegetSingleTag(long tagID)Service to get a Single Tag from the Databaseprivate TempTaggetSingleTagWithExtraInformations(long tagID, AnswerType type, boolean withAnswers, javax.persistence.EntityManager em)private TempTaggetSingleTagWithExtraInformationsFromGroupedTypeTagByType(long tagID, AnswerType type, boolean withAnswers, javax.persistence.EntityManager em)get one specific tag with a specific type and all its additional informationsprivate TempTaggetSingleTagWithExtraInformationsFromResultByType(long tagID, AnswerType type, boolean withAnswers, javax.persistence.EntityManager em)get single result with specified type and tagjavax.ws.rs.core.ResponsegetSingleUser(long userID, javax.servlet.http.HttpServletRequest request)Get a single userjavax.ws.rs.core.Responseprivate booleanlistContainsAnswerID(List<TempAnswer> arrayList, long id)Method for checking if array list already contains an answer with this id.private IntegerlistContainsTagID(List<TempTag> arrayList, long id)Method for checking if array list already contains an tag with this id.javax.ws.rs.core.ResponseService to get all files from the Databaseprivate voidmergeDuplicateTags(List<TempTag> tempTagsToCheck, List<TempTag> tempTagsToMergeIn)method to check if list tempTagsToMergeIn already contains a tag from list tempTagsToCheck if tag already exists, merge the tag and its values togetherquestionSuggestions(String amountQuestionsString)Service to get a list of suggested Questionsrun()Service to get random Questions from the Databaseprivate voidsetUpAndDownvote(javax.persistence.EntityManager em, AnswerDAO answerDAO, TempTag tempTag, ResultParent result, Answer answer)private voidsetUpAndDownvote(javax.persistence.EntityManager em, AnswerDAO answerDAO, TempTag tempTag, ResultParent result, List<Answer> answers)singleAnsweredQuestion(long questionID)topQuestionSuggestions(String amountQuestionsString)
-
Constructor Details
-
Get
public Get()
-
-
Method Details
-
getSingleAnswer
@GET @Produces("application/json") @Path("/singleAnswer") public javax.ws.rs.core.Response getSingleAnswer(@QueryParam("answerID") long answerID)Get a single answer with all the tags it's using- Parameters:
answerID- the id of the answer that we want- Returns:
- a TempTag object
- Since:
- 17.07.2021
-
getSingleDefaultQuestion
@GET @Produces("application/json") @Path("singleDefaultQuestion") public javax.ws.rs.core.Response getSingleDefaultQuestion(@QueryParam("defaultQuestionId") long defaultQuestionId)returns a json object containing a single question- Parameters:
defaultQuestionId- the id of the question to be returned- Returns:
- json object with single question
- Since:
- 17.07.2021
-
getSingleTag
@GET @Produces("application/json") @Path("/singleTag") public javax.ws.rs.core.Response getSingleTag(@QueryParam("tagID") long tagID)Service to get a Single Tag from the Database- Parameters:
tagID- the ID of the Tag from Path- Returns:
- the Tag as a JSON Object
- Since:
- 17.07.2021
-
getAllAnswersWhereTagId
@GET @Produces("application/json") @Path("/allAnswersWhereTagId") public javax.ws.rs.core.Response getAllAnswersWhereTagId(@QueryParam("tagId") String tagLimitString)- Parameters:
tagLimitString- defines the maximum number of tags that will be returned per answer.- Returns:
- Since:
- 20.07.2021
-
getAllAnswers
@GET @Produces("application/json") @Path("/allAnswers") public javax.ws.rs.core.Response getAllAnswers(@QueryParam("tagLimit") String tagLimitString)Restful service that returns all answers with a max set amount of tags.- Parameters:
tagLimitString- defines the maximum number of tags that will be returned per answer.- Returns:
- returns a json object containing all answers with corresponding tags.
-
addTagsToTempAnswer
private TempAnswer addTagsToTempAnswer(Answer answer, int tagLimit, javax.persistence.EntityManager em)- Parameters:
answer- the answer to add the tags totagLimit- the max amount of tagsem- the entitymanager- Returns:
- Since:
- 17.07.2021
-
getAllTags
@GET @Produces("application/json") @Path("/allTags") public javax.ws.rs.core.Response getAllTags()service to get all tags with their values- Returns:
- return response with all tags and their upvotes/downvotes/usages etc
- Since:
- 17.07.2021
-
getAllTypedTagsByType
@GET @Produces("application/json") @Path("/allTypeTagsByType") public javax.ws.rs.core.Response getAllTypedTagsByType(@QueryParam("type") String typeValueString)returns all tags with a specific type from the table typedTags as simple strings- Parameters:
typeValueString- the type as a string, needs to be a number (the ordinal of the enum type)- Returns:
- all tags as simple string, no extra informations
- Since:
- 17.07.2021
-
getAllTagsByTypeWithInfos
@GET @Produces("application/json") @Path("/allTagsByTypeWithInfos") public javax.ws.rs.core.Response getAllTagsByTypeWithInfos(@QueryParam("type") String typeValueString)- Parameters:
typeValueString-- Returns:
- Since:
- 17.07.2021
-
getAllBlackList
@GET @Produces("application/json") @Path("/allBlackList") public javax.ws.rs.core.Response getAllBlackList()service to get all blacklistentries- Returns:
- return response with all BlackListEntries
- Since:
- 17.07.2021
-
getAllDefaultQuestion
@GET @Produces("application/json") @Path("/allDefaultQuestion") public javax.ws.rs.core.Response getAllDefaultQuestion()service to get all default wuestions- Returns:
- return response with all default question
- Since:
- 17.07.2021
-
getAllMatches
@GET @Produces("application/json;charset=utf-8") @Path("/allMatches") public javax.ws.rs.core.Response getAllMatches()service to get all matches- Returns:
- return response with all Matches
- Since:
- 17.07.2021
-
defaultQuestionRandom
@GET @Produces("application/json") @Path("/randomDefaultQuestion") public String defaultQuestionRandom(@QueryParam("amountQuestions") String amountQuestionsString)service to get random default questions with a set amount- Parameters:
amountQuestionsString-- Returns:
- a list containing random questions in a random order
- Since:
- 17.07.2021
-
questionSuggestions
@GET @Produces("application/json") @Path("/questionSuggestions") public String questionSuggestions(@QueryParam("amountQuestions") String amountQuestionsString)Service to get a list of suggested Questions- Parameters:
amountQuestionsString-- Returns:
- a List of a limited amount of suggested Questions
- Since:
- 17.07.2021
-
topQuestionSuggestions
@GET @Produces("application/json") @Path("/topQuestionSuggestions") public String topQuestionSuggestions(@QueryParam("amountQuestions") String amountQuestionsString)- Parameters:
amountQuestionsString-- Returns:
- Since:
- 16.08.2021
-
singleAnsweredQuestion
@GET @Produces("application/json") @Path("/singleAnsweredQuestion") public String singleAnsweredQuestion(@QueryParam("questionID") long questionID)- Parameters:
questionID-- Returns:
- Since:
- 20.08.2021
-
allAnsweredQuestions
@GET @Produces("application/json") @Path("/allAnsweredQuestions") public String allAnsweredQuestions(@QueryParam("timeRange") String timeRangeString, @QueryParam("withAnswers") String withAnswersString, @Context javax.servlet.http.HttpServletRequest request)- Parameters:
timeRangeString-withAnswersString-- Returns:
- Since:
- 18.08.2021
-
allAnsweredQuestions
@GET @Produces("application/json") @Path("/allAnsweredQuestionsPerAnswer") public String allAnsweredQuestions(@QueryParam("answerID") long answerID)- Parameters:
answerID-- Returns:
- Since:
- 25.08.2021
-
allUnansweredQuestions
@GET @Produces("application/json") @Path("/allUnansweredQuestions") public String allUnansweredQuestions(@QueryParam("timeRange") String timeRangeString, @Context javax.servlet.http.HttpServletRequest request)- Parameters:
timeRangeString-- Returns:
- Since:
- 19.08.2021
-
getStatus
@GET @Produces("application/json") @Path("/status") public javax.ws.rs.core.Response getStatus()- Returns:
- Since:
- 17.07.2021
-
run
Service to get random Questions from the Database- Returns:
- a JSON Object with a list of random Questions from the Database
- Since:
- 17.07.2021
-
find
@GET @Path("/autocompleteList") @Produces("application/json") public javax.ws.rs.core.Response find()Service to get all Tags in the Database- Returns:
- a JSON Object with a List of all Tags in the Database as simple string (just the name of the tags)
- Since:
- 17.07.2021
-
listFiles
@GET @Path("/files") @Produces("application/json") public javax.ws.rs.core.Response listFiles()Service to get all files from the Database- Returns:
- JSON Object with all Files
- Since:
- 17.07.2021
-
answerTypes
@GET @Path("/answerTypes") @Produces("application/json") public javax.ws.rs.core.Response answerTypes()- Returns:
- all answer types
- Since:
- 17.07.2021
-
getSingleBlacklistEntry
@GET @Path("/singleBlacklistEntry") @Produces("application/json") public javax.ws.rs.core.Response getSingleBlacklistEntry(@QueryParam("id") long id)- Parameters:
id-- Returns:
- Since:
- 22.07.2021
-
generateJSONResponseAllFiles
Generates a JSON String for all Files- Parameters:
files- the list of all files- Returns:
- the JSON String
- Since:
- 17.07.2021
-
generateJSONResponseAnswerTypes
- Parameters:
neededAnswerType-- Returns:
- Since:
- 17.07.2021
-
generateJSONResponseAutoCompleteList
Builds a JSON Object of all tag Strings- Parameters:
tags- the list of all Tags- Returns:
- the JSON Object Stringified
- Since:
- 17.07.2021
-
generateJSONResponseAllAnswers
Generates the JSON Response for a List of multiple Answers- Parameters:
answers- the List of Answers- Returns:
- the JSON Object containing the List of Answers
- Since:
- 17.07.2021
-
generateJSONResponseAllTags
Generates a JSON Object with a List of Tags- Parameters:
tags- the List of Tags- Returns:
- the JSON Object containing a List of Tags
- Since:
- 17.07.2021
-
generateJSONResponseSingleTag
-
generateAllAnswersJson
- Parameters:
tempAnswers-listName-- Returns:
- Since:
- 20.08.2021
-
generateSingleAnswerJson
- Parameters:
answer-answerTypeJSON-- Returns:
- Since:
- 20.08.2021
-
generateJSONResponseAllBlackList
Generates a JSON Object with a List of blacklistEntries- Parameters:
blacklistEntries- the List of blacklistEntries- Returns:
- the JSON Object containing a List of blacklistEntries
- Since:
- 17.07.2021
-
generateJSONResponseAllMatches
Generates a JSON Object with a List of blacklistEntries- Parameters:
matches- the List of matches- Returns:
- the JSON Object containing a List of blacklistEntries
- Since:
- 17.07.2021
-
generateJSONResponseAllDefaultQuestion
generate the JSON string for all default question- Parameters:
defaultQuestions-- Returns:
- the JSON string
- Since:
- 17.07.2021
-
listContainsAnswerID
Method for checking if array list already contains an answer with this id.- Parameters:
arrayList- the array list containing all the answers to checkid- the id we want to check if it already is in the array list- Returns:
- boolean true if id is in array, false if id is not in array
- Since:
- 17.07.2021
-
listContainsTagID
Method for checking if array list already contains an tag with this id.- Parameters:
arrayList- the array list containing all the tags to checkid- the id we want to check if it already is in the array list- Returns:
- true if id is in array, false if id is not in array
- Since:
- 17.07.2021
-
getAllTagsWithExtraInformationsByType
private List<TempTag> getAllTagsWithExtraInformationsByType(AnswerType type, javax.persistence.EntityManager em)- Parameters:
type-em-- Returns:
- Since:
- 17.07.2021
-
getSingleTagWithExtraInformations
private TempTag getSingleTagWithExtraInformations(long tagID, AnswerType type, boolean withAnswers, javax.persistence.EntityManager em)- Parameters:
tagID-type-em-- Returns:
- Since:
- 27.07.2021
-
mergeDuplicateTags
method to check if list tempTagsToMergeIn already contains a tag from list tempTagsToCheck if tag already exists, merge the tag and its values together- Parameters:
tempTagsToCheck-tempTagsToMergeIn-- Since:
- 19.07.2021
-
getSingleTagWithExtraInformationsFromGroupedTypeTagByType
private TempTag getSingleTagWithExtraInformationsFromGroupedTypeTagByType(long tagID, AnswerType type, boolean withAnswers, javax.persistence.EntityManager em)get one specific tag with a specific type and all its additional informations- Parameters:
tagID-type-em-- Returns:
- Since:
- 27.07.2021
-
getAllTagsWithExtraInformationsFromGroupedTypeTagByType
private List<TempTag> getAllTagsWithExtraInformationsFromGroupedTypeTagByType(AnswerType type, javax.persistence.EntityManager em)- Parameters:
type-em-- Returns:
- Since:
- 17.07.2021
-
getSingleTagWithExtraInformationsFromResultByType
private TempTag getSingleTagWithExtraInformationsFromResultByType(long tagID, AnswerType type, boolean withAnswers, javax.persistence.EntityManager em)get single result with specified type and tag- Parameters:
tagID-type-withAnswers-em-- Returns:
- Since:
- 27.07.2021
-
setUpAndDownvote
private void setUpAndDownvote(javax.persistence.EntityManager em, AnswerDAO answerDAO, TempTag tempTag, ResultParent result, List<Answer> answers) -
setUpAndDownvote
private void setUpAndDownvote(javax.persistence.EntityManager em, AnswerDAO answerDAO, TempTag tempTag, ResultParent result, Answer answer)- Parameters:
em-answerDAO-tempTag-result-answer-- Since:
- 29.07.2021
-
getAllTagsWithExtraInformationsFromResultByType
private List<TempTag> getAllTagsWithExtraInformationsFromResultByType(AnswerType type, javax.persistence.EntityManager em)- Parameters:
em-- Returns:
- Since:
- 17.07.2021
-
getAllUser
@GET @Produces("application/json") @Path("/allUsers") public javax.ws.rs.core.Response getAllUser(@Context javax.servlet.http.HttpServletRequest request)Get all users- Parameters:
request-- Returns:
- json object with all user
- Since:
- 02.08.2021
-
getSingleUser
@GET @Produces("application/json") @Path("/singleUser") public javax.ws.rs.core.Response getSingleUser(@QueryParam("userID") long userID, @Context javax.servlet.http.HttpServletRequest request)Get a single user- Parameters:
userID- the id of the user that we wantrequest-- Returns:
- json object with single user
- Since:
- 03.08.2021
-
generateJSONResponseAllUsers
Generates the JSON Response for a List of multiple Users- Parameters:
userLogins- the List of UsersloggedInUserID-- Returns:
- the JSON Object containing the List of Users
- Since:
- 02.08.2021
-
getMaxLength
@Path("/maxInputLength") @GET @Produces("application/json") public javax.ws.rs.core.Response getMaxLength()Get Max Lengths for input fields- Returns:
- Max Lengths
-
buildSingleAnsweredQuestionJsonResponse
- Parameters:
tempAnsweredQuestion-- Returns:
- Since:
- 20.08.2021
-
buildSingleAnsweredQuestionJsonResponse
private String buildSingleAnsweredQuestionJsonResponse(TempAnsweredQuestion tempAnsweredQuestion, boolean withAnswers)- Parameters:
tempAnsweredQuestion-withAnswers-- Returns:
-
buildAnsweredQuestionJsonResponse
- Parameters:
tempAnsweredQuestions-- Returns:
- Since:
- 20.08.2021
-
buildAnsweredQuestionJsonResponse
private String buildAnsweredQuestionJsonResponse(List<TempAnsweredQuestion> tempAnsweredQuestions, boolean withAnswers)- Parameters:
tempAnsweredQuestions-- Returns:
- Since:
- 17.08.2021
-
buildAnsweredQuestionPerAnswerJsonResponse
private String buildAnsweredQuestionPerAnswerJsonResponse(List<TempAnsweredQuestionTimesResult> tempAnsweredQuestionTimesResults)- Parameters:
tempAnsweredQuestionTimesResults-- Returns:
- Since:
- 25.08.2021
-
buildUnansweredQuestionJsonResponse
private String buildUnansweredQuestionJsonResponse(List<TempUnansweredQuestion> unansweredQuestions)- Parameters:
unansweredQuestions-- Returns:
- Since:
- 19.08.2021
-
checkCanMatchBlacklist
@GET @Path("/checkNewBlacklist") public javax.ws.rs.core.Response checkCanMatchBlacklist(@QueryParam("word") String word)
-