Package com.ubs.backend.classes
Class TempTag
java.lang.Object
com.ubs.backend.classes.TempTag
Tag used for temporary saving a tag and building JSON objects.
- Since:
- 17.07.2021
- Author:
- Tim Irmler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ArrayList<TempAnswer>All Answers that use this tagprivate intamount of answers using this tagprivate intAmount of downvotes this tag in this context has receivedprivate longthe answer this specific tag belongs to in a result setprivate TagThe tagprivate inthow often the tag has been usedprivate intAmount of upvotes this tag in this context has received -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnswers(ArrayList<TempAnswer> answers)adds the givenTempAnswers to this instancevoidaddAnswersWithUsefulness(ArrayList<TempAnswer> tempAnswers, AnswerDAO answerDAO, javax.persistence.EntityManager em)calculates the average usefulness of every given answer and adds it to this instanceintintlonggetTag()intgetTempAnswersFromAnswers(List<Answer> answers)intfloatgetUsefulness(TempAnswer tempAnswer, AnswerDAO answerDAO, javax.persistence.EntityManager em)method to calculate the average usefulness of an answer by accessing the DBvoidincreaseAllValues(TempTag tag)voidincreaseAmountAnswers(int value)voidincreaseDownvotes(int value)voidincreaseTagUsages(int value)voidincreaseUpvotes(int value)voidsetAllAnswers(ArrayList<TempAnswer> allAnswers)voidsetAllAnswers(List<Answer> answers)voidsetAmountAnswers(int amountAnswers)voidsetDownvotes(int downvotes)voidsetSingleAnswerID(long singleAnswerID)voidvoidsetTagUsages(int tagUsages)voidsetUpvotes(int upvotes)toString()
-
Field Details
-
tag
The tag- Since:
- 17.07.2021
- See Also:
Tag
-
upvotes
private int upvotesAmount of upvotes this tag in this context has received- Since:
- 17.07.2021
-
downvotes
private int downvotesAmount of downvotes this tag in this context has received- Since:
- 17.07.2021
-
tagUsages
private int tagUsageshow often the tag has been used- Since:
- 17.07.2021
-
amountAnswers
private int amountAnswersamount of answers using this tag- Since:
- 17.07.2021
-
singleAnswerID
private long singleAnswerIDthe answer this specific tag belongs to in a result set- Since:
- 17.07.2021
- See Also:
TempAnswer
-
allAnswers
All Answers that use this tag- Since:
- 17.07.2021
- See Also:
TempAnswer
-
-
Constructor Details
-
TempTag
public TempTag()default constructor -
TempTag
used when we need to figure out to what specific result and answer this tag belongs to- Parameters:
tag- the default tag we want to savesingleAnswerID- the id of the answer in the db to which this tag belongs toupvotes- the amount of upvotes this tag has in the db in this result setdownvotes- the amount of downvotes this tag has in the db in this result settagUsages- how often this tag has been used with this answer- Since:
- 17.07.2021
-
TempTag
save tag but only with its id and its name.- Parameters:
tag- the tag we want to save- Since:
- 17.07.2021
-
-
Method Details
-
increaseAllValues
- Parameters:
tag- theTempTagfrom where we take its values and increase ours by- Since:
- 17.07.2021
-
getTag
- Returns:
- the tag of this instance
- Since:
- 17.07.2021
-
setTag
- Parameters:
tag- the tag to set- Since:
- 17.07.2021
-
getSingleAnswerID
public long getSingleAnswerID()- Returns:
- the ID of the Answer
- Since:
- 17.07.2021
-
setSingleAnswerID
public void setSingleAnswerID(long singleAnswerID)- Parameters:
singleAnswerID- the ID of the new Answer- Since:
- 17.07.2021
-
getAllAnswers
- Returns:
- a List of all Answers
- Since:
- 17.07.2021
-
setAllAnswers
- Parameters:
allAnswers- the new List of Answers- Since:
- 17.07.2021
-
setAllAnswers
- Parameters:
answers- all- Since:
- 28.07.2021
-
addAnswers
adds the givenTempAnswers to this instance- Parameters:
answers- a list of all theTempAnswers- Since:
- 28.07.2021
-
addAnswersWithUsefulness
public void addAnswersWithUsefulness(ArrayList<TempAnswer> tempAnswers, AnswerDAO answerDAO, javax.persistence.EntityManager em)calculates the average usefulness of every given answer and adds it to this instance- Parameters:
tempAnswers- everyTempAnswerthat we want to add and calculate the usefulness fromanswerDAO- the answerDAO to access the DBem- the entity manager- Since:
- 28.07.2021
-
getTempAnswersFromAnswers
- Parameters:
answers- theAnswers of whichTempAnswers should be created from- Returns:
- a list of the newly created
TempAnswers - Since:
- 28.07.2021
-
getUsefulness
public float getUsefulness(TempAnswer tempAnswer, AnswerDAO answerDAO, javax.persistence.EntityManager em)method to calculate the average usefulness of an answer by accessing the DB- Parameters:
tempAnswer- the tempAnswer to get the usefulness fromanswerDAO- the DB access object to get the information from the DBem- the entity manager- Returns:
- the average usefulness of the answer as a floating point number
- Since:
- 28.07.2021
- See Also:
AnswerDAO.getAverageUsefulness(long, EntityManager)
-
getUpvotes
public int getUpvotes()- Returns:
- the amount of Upvotes
- Since:
- 17.07.2021
-
setUpvotes
public void setUpvotes(int upvotes)- Parameters:
upvotes- the new Amount of upvotes- Since:
- 17.07.2021
-
increaseUpvotes
public void increaseUpvotes(int value)- Parameters:
value- the value by which the upvotes should be increased- Since:
- 17.07.2021
-
getDownvotes
public int getDownvotes()- Returns:
- the amount of Downvotes
- Since:
- 17.07.2021
-
setDownvotes
public void setDownvotes(int downvotes)- Parameters:
downvotes- the new amount of Downvotes- Since:
- 17.07.2021
-
increaseDownvotes
public void increaseDownvotes(int value)- Parameters:
value- the value by which the amount of Downvotes should be increased- Since:
- 17.07.2021
-
getTagUsages
public int getTagUsages()- Returns:
- the amount of TagUsages
- Since:
- 17.07.2021
-
setTagUsages
public void setTagUsages(int tagUsages)- Parameters:
tagUsages- how often this tag has been used- Since:
- 17.07.2021
-
increaseTagUsages
public void increaseTagUsages(int value)- Parameters:
value- the value the Tag Usages should be increased by- Since:
- 17.07.2021
-
getAmountAnswers
public int getAmountAnswers()- Returns:
- the amount of Answers this TempTag has
- Since:
- 17.07.2021
-
setAmountAnswers
public void setAmountAnswers(int amountAnswers)- Parameters:
amountAnswers- the amount of answers- Since:
- 17.07.2021
-
increaseAmountAnswers
public void increaseAmountAnswers(int value)- Parameters:
value- the value the AmountAnswers should be increased by- Since:
- 17.07.2021
-
toString
-