Class Get

java.lang.Object
com.ubs.backend.services.Get

@Path("get") public class Get extends Object
All Services which return some JSON Object or List of Database Entries
Since:
17.07.2021
Author:
Tim Irmler, Marc, Magnus, Sarah
  • 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 to
      tagLimit - the max amount of tags
      em - 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

      @GET @Produces("application/json") @Path("/randomquestion") public String 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

      private String generateJSONResponseAllFiles(List<UploadFile> files)
      Generates a JSON String for all Files
      Parameters:
      files - the list of all files
      Returns:
      the JSON String
      Since:
      17.07.2021
    • generateJSONResponseAnswerTypes

      private String generateJSONResponseAnswerTypes(AnswerType neededAnswerType)
      Parameters:
      neededAnswerType -
      Returns:
      Since:
      17.07.2021
    • generateJSONResponseAutoCompleteList

      private String generateJSONResponseAutoCompleteList(List<Tag> tags)
      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

      private String generateJSONResponseAllAnswers(List<TempAnswer> answers)
      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

      public String generateJSONResponseAllTags(List<TempTag> tags)
      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

      private String generateJSONResponseSingleTag(TempTag tempTag)
    • generateAllAnswersJson

      private String generateAllAnswersJson(List<TempAnswer> tempAnswers, String listName)
      Parameters:
      tempAnswers -
      listName -
      Returns:
      Since:
      20.08.2021
    • generateSingleAnswerJson

      private String generateSingleAnswerJson(TempAnswer answer, String answerTypeJSON)
      Parameters:
      answer -
      answerTypeJSON -
      Returns:
      Since:
      20.08.2021
    • generateJSONResponseAllBlackList

      private String generateJSONResponseAllBlackList(List<BlacklistEntry> blacklistEntries)
      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

      private String generateJSONResponseAllMatches(List<Match> matches)
      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

      private String generateJSONResponseAllDefaultQuestion(List<DefaultQuestion> defaultQuestions)
      generate the JSON string for all default question
      Parameters:
      defaultQuestions -
      Returns:
      the JSON string
      Since:
      17.07.2021
    • listContainsAnswerID

      private boolean listContainsAnswerID(List<TempAnswer> arrayList, long id)
      Method for checking if array list already contains an answer with this id.
      Parameters:
      arrayList - the array list containing all the answers to check
      id - 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

      private Integer listContainsTagID(List<TempTag> arrayList, long id)
      Method for checking if array list already contains an tag with this id.
      Parameters:
      arrayList - the array list containing all the tags to check
      id - 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

      private void mergeDuplicateTags(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 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 want
      request -
      Returns:
      json object with single user
      Since:
      03.08.2021
    • generateJSONResponseAllUsers

      private String generateJSONResponseAllUsers(List<UserLogin> userLogins, long loggedInUserID)
      Generates the JSON Response for a List of multiple Users
      Parameters:
      userLogins - the List of Users
      loggedInUserID -
      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

      private String buildSingleAnsweredQuestionJsonResponse(TempAnsweredQuestion tempAnsweredQuestion)
      Parameters:
      tempAnsweredQuestion -
      Returns:
      Since:
      20.08.2021
    • buildSingleAnsweredQuestionJsonResponse

      private String buildSingleAnsweredQuestionJsonResponse(TempAnsweredQuestion tempAnsweredQuestion, boolean withAnswers)
      Parameters:
      tempAnsweredQuestion -
      withAnswers -
      Returns:
    • buildAnsweredQuestionJsonResponse

      private String buildAnsweredQuestionJsonResponse(List<TempAnsweredQuestion> tempAnsweredQuestions)
      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)