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.

TicketLabel.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.List;
  19. import com.gitblit.utils.StringUtils;
  20. /**
  21. * A ticket label.
  22. *
  23. * @author James Moger
  24. *
  25. */
  26. public class TicketLabel implements Serializable {
  27. private static final long serialVersionUID = 1L;
  28. public final String name;
  29. public String color;
  30. public List<QueryResult> tickets;
  31. public TicketLabel(String name) {
  32. this.name = name;
  33. this.color = StringUtils.getColor(name);
  34. }
  35. public int getTotalTickets() {
  36. return tickets == null ? 0 : tickets.size();
  37. }
  38. public int getOpenTickets() {
  39. int cnt = 0;
  40. if (tickets != null) {
  41. for (QueryResult ticket : tickets) {
  42. if (!ticket.status.isClosed()) {
  43. cnt++;
  44. }
  45. }
  46. }
  47. return cnt;
  48. }
  49. public int getClosedTickets() {
  50. int cnt = 0;
  51. if (tickets != null) {
  52. for (QueryResult ticket : tickets) {
  53. if (ticket.status.isClosed()) {
  54. cnt++;
  55. }
  56. }
  57. }
  58. return cnt;
  59. }
  60. @Override
  61. public String toString() {
  62. return name;
  63. }
  64. }