View Javadoc

1   package org.codehaus.mojo.dashboard.report.plugin.configuration;
2   
3   /*
4    * Copyright 2007 David Vicente
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.util.Date;
20  
21  /**
22   * @author <a href="dvicente72@gmail.com">David Vicente</a>
23   * 
24   */
25  public class Graph
26  {
27      private String id;
28  
29      private String title;
30      
31      private String timeUnit;
32  
33      private String startPeriod;
34  
35      private String endPeriod;
36  
37      private Date startPeriodDate;
38  
39      private Date endPeriodDate;
40  
41      private String warningMsg;
42  
43      public String getEndPeriod()
44      {
45          return endPeriod;
46      }
47  
48      public String getId()
49      {
50          return id;
51      }
52  
53      public String getStartPeriod()
54      {
55          return startPeriod;
56      }
57  
58      public String getTitle()
59      {
60          return title;
61      }
62  
63      public Date getEndPeriodDate()
64      {
65          if ( endPeriodDate == null )
66          {
67              endPeriodDate = PeriodUtils.getDateFromPattern( endPeriod );
68          }
69          return endPeriodDate;
70      }
71  
72      public Date getStartPeriodDate()
73      {
74          if ( startPeriodDate == null )
75          {
76              startPeriodDate = PeriodUtils.getDateFromPattern( startPeriod );
77          }
78          return startPeriodDate;
79      }
80  
81      public boolean isPeriodsValid()
82      {
83          boolean valid = false;
84          getStartPeriodDate();
85          getEndPeriodDate();
86          if ( startPeriodDate != null && endPeriodDate != null && startPeriodDate.before( endPeriodDate ) )
87          {
88              valid = true;
89          }
90          else
91          {
92              StringBuffer buff = new StringBuffer();
93              buff.append( "The graph Configuration (id = " );
94              buff.append( this.id );
95              buff.append( ") is wrong. startPeriod (" );
96              buff.append( getStartPeriod() + " = " + startPeriodDate );
97              buff.append( ") is not before the endPeriod (" );
98              buff.append( getEndPeriod() + " = " + endPeriodDate );
99              buff.append( ")." );
100             warningMsg = buff.toString();
101         }
102         return valid;
103     }
104 
105     public String getWarningMessage()
106     {
107         return warningMsg;
108     }
109 
110     public String getTimeUnit()
111     {
112         return timeUnit;
113     }
114 
115     public void setTimeUnit( String timeUnit )
116     {
117         this.timeUnit = timeUnit;
118     }
119 
120 }