001    package org.hackystat.projectbrowser.page.sensordata;
002    
003    import java.io.Serializable;
004    import java.util.Calendar;
005    
006    import org.hackystat.projectbrowser.ProjectBrowserSession;
007    import org.hackystat.sensorbase.resource.projects.jaxb.Project;
008    
009    /**
010     * Holds all of the models and other state for the SensorDataPage. This enables users to 
011     * obtain an analysis in the SensorData page, then go to another page, then come back to this page 
012     * and see the page in the same state as when they left it. 
013     * @author Philip Johnson
014     */
015    public class SensorDataSession implements Serializable {
016    
017      /** Support serialization. */
018      private static final long serialVersionUID = 1L;
019    
020      /** The date for this page.  Represented as a long to avoid findbugs errors. */
021      //private long date = (new Date()).getTime();
022      
023      /** The project associated with this page. */
024      private Project project = null;
025    
026      /** Holds the sdtSummaryModel associated with this session. */ 
027      private SdtSummaryModel sdtSummaryModel = new SdtSummaryModel();
028      
029      /** Holds the SensorDataDetails model associated with this session. */
030      private SensorDataDetailsModel sensorDataDetailsModel = new SensorDataDetailsModel();
031      /** Holds the IDataProvider for SensorDataDetails. */
032      private SensorDataDetailsProvider sensorDataDetailsProvider = new SensorDataDetailsProvider();
033      
034      private String sdtName = ""; 
035      private String tool = "";
036      
037      /** The month field in the SensorData form, initialized to the current month. */
038      private Integer month = Calendar.getInstance().get(Calendar.MONTH);
039      /** The year field in the SensorData form, initialized to the current year. */  
040      private Integer year = Calendar.getInstance().get(Calendar.YEAR);
041      
042      private SensorDataTableModel sensorDataTableModel = new SensorDataTableModel();
043      
044      /**
045       * Create a session state instance for this page. 
046       */
047      public SensorDataSession() {
048        // do nothing at the moment. 
049      }
050      
051    //  /**
052    //   * Gets the date associated with this page. 
053    //   * @return The date for this page. 
054    //   */
055    //  public Date getDate() {
056    //    return new Date(this.date);
057    //  }
058      
059    //  /**
060    //   * Sets the date associated with this page. 
061    //   * @param date The date for this page. 
062    //   */
063    //  public void setDate(Date date) {
064    //    if (date == null) {
065    //      System.out.println("Calling setDate with: " + date);
066    //      return;
067    //    }
068    //    this.date = date.getTime();
069    //  }
070      
071    //  /**
072    //   * Returns the current date in yyyy-MM-dd format.  
073    //   * @return The date as a simple string. 
074    //   */
075    //  public String getDateString() {
076    //    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
077    //    return format.format(new Date(this.date));
078    //  }
079      
080    
081      /**
082       * Gets the project associated with this page. 
083       * @return The project for this page. 
084       */
085      public Project getProject() {
086        if (this.project == null) {
087          this.setProject(ProjectBrowserSession.get().getDefaultProject());
088        }
089        return this.project;
090      }
091      
092      /**
093       * Sets the projectName for this page. 
094       * @param project The project for this page. 
095       */
096      public void setProject(Project project) {
097        this.project = project;
098      }
099     
100    
101      /**
102       * Sets the SdtSummaryModel for this page. 
103       * @param sdtSummaryModel The sdtSummaryModel.
104       */
105      public void setSdtSummaryModel(SdtSummaryModel sdtSummaryModel) {
106        this.sdtSummaryModel = sdtSummaryModel;
107      }
108    
109      /**
110       * Returns the current SdtSummaryModel for this page. 
111       * @return The SdtSummaryModel. 
112       */
113      public SdtSummaryModel getSdtSummaryModel() {
114        return this.sdtSummaryModel;
115      }
116    
117      /**
118       * Return the sensor data details model.
119       * @return The sensor data details model.
120       */
121      public SensorDataDetailsModel getSensorDataDetailsModel() {
122        return this.sensorDataDetailsModel;
123      }
124      
125      /**
126       * Set the sensor data details model.
127       * @param model The sensor data details model.
128       */
129      public void setSensorDataDetailsModel(SensorDataDetailsModel model) {
130        this.sensorDataDetailsModel = model;
131      }
132      
133      /**
134       * Return the sensor data details IDataProvider.
135       * @return The sensor data details provider.
136       */
137      public SensorDataDetailsProvider getSensorDataDetailsProvider() {
138        return this.sensorDataDetailsProvider;
139      }
140      
141      /**
142       * Set the sensor data details IDataProvider.
143       * @param model The sensor data details provider
144       */
145      public void setSensorDataDetailsProvider(SensorDataDetailsProvider model) {
146        this.sensorDataDetailsProvider = model;
147      }
148      
149      /**
150       * Gets the sdt name. 
151       * @return The sdt name.
152       */
153      public String getSdtName() {
154        return this.sdtName;
155      }
156      
157      /**
158       * Sets the SDT name.
159       * @param sdtName The sdt name.
160       */
161      public void setSdtName(String sdtName) {
162        this.sdtName = sdtName;
163      }
164      
165      /**
166       * Gets the tool.
167       * @return The tool.
168       */
169      public String getTool() {
170        return this.tool;
171      }
172      
173      /**
174       * Sets the tool.
175       * @param tool The tool.
176       */
177      public void setTool(String tool) {
178        this.tool = tool;
179      }
180      
181      /**
182       * Gets the month. 
183       * @return The month.
184       */
185      public Integer getMonth() {
186        return this.month;
187      }
188    
189      /**
190       * Gets the year. 
191       * @return The year. 
192       */
193      public Integer getYear() {
194        return this.year;
195      }
196      
197      /**
198       * Sets the month. 
199       * @param month The month. 
200       */
201      public void setMonth(Integer month) {
202        this.month = month;
203      }
204      
205      /**
206       * Sets the year. 
207       * @param year The year. 
208       */
209      public void setYear(Integer year) {
210        this.year = year; 
211      }
212      
213      /**
214       * Gets the SensorDataTableModel. 
215       * @return The SensorDataTableModel.
216       */
217      public SensorDataTableModel getSensorDataTableModel() {
218        return this.sensorDataTableModel;
219      }
220      
221      /**
222       * Sets the SensorDataTableModel. 
223       * @param model The model. 
224       */
225      public void setSensorDataTableModel(SensorDataTableModel model) {
226        this.sensorDataTableModel = model;
227      }
228      
229      
230    }