You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

QueryResult.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright 2013 gitblit.com.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.gitblit.tickets;
  17. import java.io.Serializable;
  18. import java.util.ArrayList;
  19. import java.util.Collections;
  20. import java.util.Date;
  21. import java.util.List;
  22. import com.gitblit.models.TicketModel.Patchset;
  23. import com.gitblit.models.TicketModel.Status;
  24. import com.gitblit.models.TicketModel.Type;
  25. import com.gitblit.utils.StringUtils;
  26. /**
  27. * Represents the results of a query to the ticket index.
  28. *
  29. * @author James Moger
  30. *
  31. */
  32. public class QueryResult implements Serializable {
  33. private static final long serialVersionUID = 1L;
  34. public String project;
  35. public String repository;
  36. public long number;
  37. public String createdBy;
  38. public Date createdAt;
  39. public String updatedBy;
  40. public Date updatedAt;
  41. public String dependsOn;
  42. public String title;
  43. public String body;
  44. public Status status;
  45. public String responsible;
  46. public String milestone;
  47. public String topic;
  48. public Type type;
  49. public String mergeSha;
  50. public String mergeTo;
  51. public List<String> labels;
  52. public List<String> attachments;
  53. public List<String> participants;
  54. public List<String> watchedby;
  55. public List<String> mentions;
  56. public Patchset patchset;
  57. public int commentsCount;
  58. public int votesCount;
  59. public int approvalsCount;
  60. public int docId;
  61. public int totalResults;
  62. public Date getDate() {
  63. return updatedAt == null ? createdAt : updatedAt;
  64. }
  65. public boolean isProposal() {
  66. return type != null && Type.Proposal == type;
  67. }
  68. public boolean isMerged() {
  69. return Status.Merged == status && !StringUtils.isEmpty(mergeSha);
  70. }
  71. public boolean isWatching(String username) {
  72. return watchedby != null && watchedby.contains(username);
  73. }
  74. public List<String> getLabels() {
  75. List<String> list = new ArrayList<String>();
  76. if (labels != null) {
  77. list.addAll(labels);
  78. }
  79. if (topic != null) {
  80. list.add(topic);
  81. }
  82. Collections.sort(list);
  83. return list;
  84. }
  85. @Override
  86. public boolean equals(Object o) {
  87. if (o instanceof QueryResult) {
  88. return hashCode() == o.hashCode();
  89. }
  90. return false;
  91. }
  92. @Override
  93. public int hashCode() {
  94. return (repository + number).hashCode();
  95. }
  96. @Override
  97. public String toString() {
  98. return repository + "-" + number;
  99. }
  100. }