org.hackystat.projectbrowser.page.telemetry.datapanel
Class TelemetryChartDataModel

java.lang.Object
  extended by org.hackystat.projectbrowser.page.telemetry.datapanel.TelemetryChartDataModel
All Implemented Interfaces:
java.io.Serializable, Processable

public class TelemetryChartDataModel
extends java.lang.Object
implements java.io.Serializable, Processable

Data model to hold state of the telemetry chart.

Author:
Shaoxuan Zhang
See Also:
Serialized Form

Constructor Summary
TelemetryChartDataModel()
           
 
Method Summary
 void addStreamToChart(SelectableTelemetryStream stream, double minimum, double maximum, GoogleChart googleChart)
          Add the given stream to the google chart.
 void cancelDataLoading()
          Cancel the data loading process.
 void changeSelectionForAll(boolean flag)
          Change all selected flags of streams to the given flag.
 java.lang.String getChartUrl(java.util.List<SelectableTelemetryStream> streams)
          Return the google chart url that present all streams within the given list.
 java.util.List<java.lang.String> getDateList()
          Return the date list inside this model.
 java.util.List<java.lang.String> getDateList(java.util.List<org.hackystat.telemetry.service.resource.chart.jaxb.TelemetryPoint> points)
          Return the date list within the list of points.
 int getHeight()
           
 java.lang.String getParameterAsString()
          Return the comma-separated list of parameters in String.
 java.lang.String getProcessingMessage()
           
 java.lang.String getSelectedChart()
           
 java.util.List<org.hackystat.sensorbase.resource.projects.jaxb.Project> getSelectedProjects()
           
 java.lang.String getTelemetryName()
           
 java.util.List<SelectableTelemetryStream> getTelemetryStream(org.hackystat.sensorbase.resource.projects.jaxb.Project project)
          Return the list of TelemetryStream associated with the given project.
 int getWidth()
           
 boolean isChartEmpty()
           
 boolean isComplete()
           
 boolean isEmpty()
          Returns true if this model does not contain any data.
 boolean isInProcess()
           
 boolean isSizeWithinRange()
          Check if the size of the chart is within range.
 void loadData()
          Load data from Hackystat service.
 void setHeight(int height)
           
 void setModel(java.util.Date startDate, java.util.Date endDate, java.util.List<org.hackystat.sensorbase.resource.projects.jaxb.Project> selectedProjects, java.lang.String telemetryName, java.lang.String granularity, java.util.List<org.apache.wicket.model.IModel> parameters, java.lang.String telemetryHost, java.lang.String email, java.lang.String password)
           
 void setWidth(int width)
           
 boolean updateSelectedChart()
          update the selectedChart.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TelemetryChartDataModel

public TelemetryChartDataModel()
Method Detail

setModel

public void setModel(java.util.Date startDate,
                     java.util.Date endDate,
                     java.util.List<org.hackystat.sensorbase.resource.projects.jaxb.Project> selectedProjects,
                     java.lang.String telemetryName,
                     java.lang.String granularity,
                     java.util.List<org.apache.wicket.model.IModel> parameters,
                     java.lang.String telemetryHost,
                     java.lang.String email,
                     java.lang.String password)
Parameters:
startDate - the start date of this model..
endDate - the end date of this model..
selectedProjects - the project ofs this model.
telemetryName - the telemetry name of this model.
granularity - the granularity of this model, Day or Week or Month.
parameters - the list of parameters
telemetryHost - the telemetry host
email - the user's email
password - the user's passowrd

loadData

public void loadData()
Load data from Hackystat service.


cancelDataLoading

public void cancelDataLoading()
Cancel the data loading process.


getTelemetryName

public java.lang.String getTelemetryName()
Returns:
the telemetryName

isEmpty

public boolean isEmpty()
Returns true if this model does not contain any data.

Returns:
True if no data.

getTelemetryStream

public java.util.List<SelectableTelemetryStream> getTelemetryStream(org.hackystat.sensorbase.resource.projects.jaxb.Project project)
Return the list of TelemetryStream associated with the given project.

Parameters:
project - the given project.
Returns:
the list of TelemetryStream.

updateSelectedChart

public boolean updateSelectedChart()
update the selectedChart.

Returns:
true if the chart is successfully updated.

getChartUrl

public java.lang.String getChartUrl(java.util.List<SelectableTelemetryStream> streams)
Return the google chart url that present all streams within the given list.

Parameters:
streams - the given stream list.
Returns:
the URL string of the chart.

addStreamToChart

public void addStreamToChart(SelectableTelemetryStream stream,
                             double minimum,
                             double maximum,
                             GoogleChart googleChart)
Add the given stream to the google chart. And return the maximum value of the stream.

Parameters:
stream - the given stream.
maximum - the maximum value of the range this stream will be associated to.
minimum - the minimum value of the range this stream will be associated to.
googleChart - the google chart.

getDateList

public java.util.List<java.lang.String> getDateList(java.util.List<org.hackystat.telemetry.service.resource.chart.jaxb.TelemetryPoint> points)
Return the date list within the list of points.

Parameters:
points - the point list.
Returns:
the date list.

getDateList

public java.util.List<java.lang.String> getDateList()
Return the date list inside this model.

Returns:
the date list.

getSelectedProjects

public java.util.List<org.hackystat.sensorbase.resource.projects.jaxb.Project> getSelectedProjects()
Returns:
the selectedProjects

getParameterAsString

public java.lang.String getParameterAsString()
Return the comma-separated list of parameters in String.

Returns:
the parameters as String

getWidth

public int getWidth()
Returns:
the width

getHeight

public int getHeight()
Returns:
the height

isSizeWithinRange

public boolean isSizeWithinRange()
Check if the size of the chart is within range.

Returns:
true if multiple of width and height is not bigger than MAX_SIZE.

getSelectedChart

public java.lang.String getSelectedChart()
Returns:
the selectedChart

isChartEmpty

public boolean isChartEmpty()
Returns:
true if the chart is empty.

changeSelectionForAll

public void changeSelectionForAll(boolean flag)
Change all selected flags of streams to the given flag.

Parameters:
flag - the boolean flag.

isInProcess

public boolean isInProcess()
Specified by:
isInProcess in interface Processable
Returns:
the inProcess

isComplete

public boolean isComplete()
Specified by:
isComplete in interface Processable
Returns:
the isComplete

getProcessingMessage

public java.lang.String getProcessingMessage()
Specified by:
getProcessingMessage in interface Processable
Returns:
the message

setWidth

public void setWidth(int width)
Parameters:
width - the width to set

setHeight

public void setHeight(int height)
Parameters:
height - the height to set