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.

TicketModel.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright 2011 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.wicket.models;
  17. import java.io.Serializable;
  18. import java.text.ParseException;
  19. import java.util.ArrayList;
  20. import java.util.Date;
  21. import java.util.List;
  22. public class TicketModel implements Serializable, Comparable<TicketModel> {
  23. private static final long serialVersionUID = 1L;
  24. public String id;
  25. public String name;
  26. public String title;
  27. public String state;
  28. public Date date;
  29. public String handler;
  30. public String milestone;
  31. public String email;
  32. public String author;
  33. public List<Comment> comments;
  34. public List<String> tags;
  35. public TicketModel() {
  36. state = "open";
  37. comments = new ArrayList<Comment>();
  38. tags = new ArrayList<String>();
  39. }
  40. public TicketModel(String ticketName) throws ParseException {
  41. state = "";
  42. name = ticketName;
  43. comments = new ArrayList<Comment>();
  44. tags = new ArrayList<String>();
  45. String[] chunks = name.split("_");
  46. if (chunks.length == 3) {
  47. date = new Date(Long.parseLong(chunks[0]) * 1000l);
  48. title = chunks[1].replace('-', ' ');
  49. }
  50. }
  51. public static class Comment implements Serializable, Comparable<Comment> {
  52. private static final long serialVersionUID = 1L;
  53. public String text;
  54. public String author;
  55. public Date date;
  56. public Comment(String text, Date date) {
  57. this.text = text;
  58. this.date = date;
  59. }
  60. public Comment(String filename, String content) throws ParseException {
  61. String[] chunks = filename.split("_", -1);
  62. this.date = new Date(Long.parseLong(chunks[1]) * 1000l);
  63. this.author = chunks[2];
  64. this.text = content;
  65. }
  66. @Override
  67. public int compareTo(Comment o) {
  68. return date.compareTo(o.date);
  69. }
  70. }
  71. @Override
  72. public int compareTo(TicketModel o) {
  73. return date.compareTo(o.date);
  74. }
  75. }