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 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.models.TicketModel.Priority;
  26. import com.gitblit.models.TicketModel.Severity;
  27. import com.gitblit.utils.StringUtils;
  28. /**
  29. * Represents the results of a query to the ticket index.
  30. *
  31. * @author James Moger
  32. *
  33. */
  34. public class QueryResult implements Serializable {
  35. private static final long serialVersionUID = 1L;
  36. public String project;
  37. public String repository;
  38. public long number;
  39. public String createdBy;
  40. public Date createdAt;
  41. public String updatedBy;
  42. public Date updatedAt;
  43. public String dependsOn;
  44. public String title;
  45. public String body;
  46. public Status status;
  47. public String responsible;
  48. public String milestone;
  49. public String topic;
  50. public Type type;
  51. public String mergeSha;
  52. public String mergeTo;
  53. public List<String> labels;
  54. public List<String> attachments;
  55. public List<String> participants;
  56. public List<String> watchedby;
  57. public List<String> mentions;
  58. public Patchset patchset;
  59. public int commentsCount;
  60. public int votesCount;
  61. public int approvalsCount;
  62. public Priority priority;
  63. public Severity severity;
  64. public int docId;
  65. public int totalResults;
  66. public Date getDate() {
  67. return updatedAt == null ? createdAt : updatedAt;
  68. }
  69. public boolean isProposal() {
  70. return type != null && Type.Proposal == type;
  71. }
  72. public boolean isOpen() {
  73. return !status.isClosed();
  74. }
  75. public boolean isClosed() {
  76. return status.isClosed();
  77. }
  78. public boolean isMerged() {
  79. return Status.Merged == status && !StringUtils.isEmpty(mergeSha);
  80. }
  81. public boolean isWatching(String username) {
  82. return watchedby != null && watchedby.contains(username);
  83. }
  84. public List<String> getLabels() {
  85. List<String> list = new ArrayList<String>();
  86. if (labels != null) {
  87. list.addAll(labels);
  88. }
  89. if (topic != null) {
  90. list.add(topic);
  91. }
  92. Collections.sort(list);
  93. return list;
  94. }
  95. @Override
  96. public boolean equals(Object o) {
  97. if (o instanceof QueryResult) {
  98. return hashCode() == o.hashCode();
  99. }
  100. return false;
  101. }
  102. @Override
  103. public int hashCode() {
  104. return (repository + number).hashCode();
  105. }
  106. @Override
  107. public String toString() {
  108. return repository + "-" + number;
  109. }
  110. }