View Javadoc

1   package org.apache.maven.plugin.trac;
2   
3   import java.text.ParseException;
4   import java.text.SimpleDateFormat;
5   import java.util.Calendar;
6   import java.util.Date;
7   
8   /*
9    * Licensed to the Apache Software Foundation (ASF) under one
10   * or more contributor license agreements.  See the NOTICE file
11   * distributed with this work for additional information
12   * regarding copyright ownership.  The ASF licenses this file
13   * to you under the Apache License, Version 2.0 (the
14   * "License"); you may not use this file except in compliance
15   * with the License.  You may obtain a copy of the License at
16   *
17   *   http://www.apache.org/licenses/LICENSE-2.0
18   *
19   * Unless required by applicable law or agreed to in writing,
20   * software distributed under the License is distributed on an
21   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22   * KIND, either express or implied.  See the License for the
23   * specific language governing permissions and limitations
24   * under the License.
25   */
26  
27  /**
28   * A Trac Ticket.
29   *
30   * @author Noriko Kinugasa
31   * @version $Id: TracTicket.html 816588 2012-05-08 12:37:27Z hboutemy $
32   */
33  public class TracTicket
34  {
35      private String id;
36  
37      private String link;
38  
39      private Date timeCreated;
40  
41      private Date timeChanged;
42  
43      private String type;
44  
45      private String summary;
46  
47      private String status;
48  
49      private String resolution;
50  
51      private String milestone;
52  
53      private String owner;
54  
55      private String priority;
56  
57      private String reporter;
58  
59      private String component;
60  
61      public String getComponent()
62      {
63          return component;
64      }
65  
66      public void setComponent( String component )
67      {
68          this.component = component;
69      }
70  
71      public String getPriority()
72      {
73          return priority;
74      }
75  
76      public void setPriority( String priority )
77      {
78          this.priority = priority;
79      }
80  
81      public String getReporter()
82      {
83          return reporter;
84      }
85  
86      public void setReporter( String reporter )
87      {
88          this.reporter = reporter;
89      }
90  
91      public TracTicket()
92      {
93      }
94  
95      public String getId()
96      {
97          return id;
98      }
99  
100     public void setId( String id )
101     {
102         this.id = id;
103     }
104 
105     public String getMilestone()
106     {
107         return milestone;
108     }
109 
110     public void setMilestone( String milestone )
111     {
112         this.milestone = milestone;
113     }
114 
115     public String getOwner()
116     {
117         return owner;
118     }
119 
120     public void setOwner( String owner )
121     {
122         this.owner = owner;
123     }
124 
125     public String getResolution()
126     {
127         return resolution;
128     }
129 
130     public void setResolution( String resolution )
131     {
132         this.resolution = resolution;
133     }
134 
135     public String getStatus()
136     {
137         return status;
138     }
139 
140     public void setStatus( String status )
141     {
142         this.status = status;
143     }
144 
145     public String getSummary()
146     {
147         return summary;
148     }
149 
150     public void setSummary( String summary )
151     {
152         this.summary = summary;
153     }
154 
155     public String getType()
156     {
157         return type;
158     }
159 
160     public void setType( String type )
161     {
162         this.type = type;
163     }
164 
165     public Date getTimeChanged()
166     {
167         return timeChanged;
168     }
169 
170     public void setTimeChanged( String timeChanged )
171     {
172         this.timeChanged = parseDate( timeChanged );
173     }
174 
175     public Date getTimeCreated()
176     {
177         return timeCreated;
178     }
179 
180     public void setTimeCreated( String timeCreated )
181     {
182         this.timeCreated = parseDate( timeCreated );
183     }
184 
185     private Date parseDate( String timeCreated )
186         throws RuntimeException
187     {
188         try
189         {
190             long millis = Long.parseLong( timeCreated );
191             Calendar cld = Calendar.getInstance();
192             cld.setTimeInMillis( millis * 1000l );
193             return cld.getTime();
194         }
195         catch ( NumberFormatException e )
196         {
197             SimpleDateFormat format = new SimpleDateFormat( "EEE MMM dd HH:mm:ss z yyyy" );
198             try
199             {
200                 return format.parse( timeCreated );
201             }
202             catch ( ParseException e1 )
203             {
204                 throw new RuntimeException( "Failed to parse date '" + timeCreated + "' as a date.", e1 );
205             }
206         }
207     }
208 
209     public String getLink()
210     {
211         return link;
212     }
213 
214     public void setLink( String link )
215     {
216         this.link = link;
217     }
218 
219 }