1212import com .fasterxml .jackson .core .JsonProcessingException ;
1313import com .fasterxml .jackson .databind .ObjectMapper ;
1414import com .fasterxml .jackson .databind .ObjectWriter ;
15- import com .google .visualization .datasource .base .TypeMismatchException ;
16- import com .google .visualization .datasource .datatable .ColumnDescription ;
17- import com .google .visualization .datasource .datatable .DataTable ;
18- import com .google .visualization .datasource .datatable .TableCell ;
19- import com .google .visualization .datasource .datatable .TableRow ;
20- import com .google .visualization .datasource .datatable .value .DateValue ;
21- import com .google .visualization .datasource .datatable .value .ValueType ;
22- import com .google .visualization .datasource .render .JsonRenderer ;
2315import org .springframework .beans .factory .annotation .Autowired ;
2416import org .springframework .http .HttpStatus ;
2517import org .springframework .http .ResponseEntity ;
2618import org .springframework .mobile .device .Device ;
2719import org .springframework .stereotype .Controller ;
2820import org .springframework .ui .Model ;
29- import org .springframework .web .bind .annotation .*;
21+ import org .springframework .web .bind .annotation .GetMapping ;
22+ import org .springframework .web .bind .annotation .PathVariable ;
23+ import org .springframework .web .bind .annotation .RequestParam ;
24+ import org .springframework .web .bind .annotation .ResponseBody ;
3025
3126import java .math .BigDecimal ;
3227import java .math .RoundingMode ;
3530import java .time .ZoneOffset ;
3631import java .time .ZonedDateTime ;
3732import java .time .format .DateTimeFormatter ;
38- import java .time .format .TextStyle ;
39- import java .time .temporal .TemporalField ;
4033import java .time .temporal .WeekFields ;
4134import java .util .*;
4235
@@ -69,81 +62,8 @@ public static double round(double value, int places) {
6962 return bd .doubleValue ();
7063 }
7164
72- @ Deprecated
73- @ RequestMapping ("/trend/monthly/{team}" )
74- @ ResponseBody
75- public String rollingMonthlyTrend (Model model , @ PathVariable String team ) {
76-
77- DataTable data = new DataTable ();
78-
79- data .addColumn (new ColumnDescription ("month" , ValueType .DATE , "Month" ));
80- data .addColumn (new ColumnDescription ("happiness" , ValueType .NUMBER , "Happiness" ));
81- data .addColumn (new ColumnDescription ("responses" , ValueType .NUMBER , "Responses" ));
82-
83- try {
84- ArrayList <TableRow > rows = new ArrayList <>();
85-
86- ArrayList <HappinessTrend > trends = trendService .getMonthlyTrendData (team );
87-
88- for (HappinessTrend trend :trends ) {
89- TableRow tr = new TableRow ();
90- tr .addCell (new TableCell (new DateValue (trend .getTrendDate ().getYear (), trend .getTrendDate ().getMonth ().getValue () - 1 , 1 )
91- , trend .getTrendDate ().getMonth ().getDisplayName (TextStyle .SHORT , Locale .ENGLISH )));
92- tr .addCell (trend .getAvgHappinessRating ());
93- tr .addCell (trend .getResponseCount ());
94- rows .add (tr );
95- }
96-
97- data .addRows (rows );
98-
99- } catch (TypeMismatchException e ) {
100- System .out .print (e );
101- }
102-
103- return JsonRenderer .renderDataTable (data , true , true , false ).toString ();
104-
105- }
106-
107- @ Deprecated
108- @ RequestMapping ("/trend/weekly/{team}" )
109- @ ResponseBody
110- public String rollingWeeklyTrend (Model model , @ PathVariable String team ) {
111-
112- DataTable data = new DataTable ();
113-
114- data .addColumn (new ColumnDescription ("week" , ValueType .DATE , "Week" ));
115- data .addColumn (new ColumnDescription ("happiness" , ValueType .NUMBER , "Happiness" ));
116- data .addColumn (new ColumnDescription ("responses" , ValueType .NUMBER , "Responses" ));
117-
118- try {
119- ArrayList <TableRow > rows = new ArrayList <>();
120-
121- ArrayList <HappinessTrend > trends = trendService .getWeeklyTrendData (team );
122-
123- TemporalField woy = WeekFields .of (Locale .getDefault ()).weekOfWeekBasedYear ();
124-
125- for (HappinessTrend trend :trends ) {
126- TableRow tr = new TableRow ();
127- tr .addCell (new TableCell (new DateValue (trend .getTrendDate ().getYear (), trend .getTrendDate ().getMonth ().getValue () - 1 , trend .getTrendDate ().getDayOfMonth ())
128- , "Week " + trend .getTrendDate ().get (woy ) + ", " + trend .getTrendDate ().getMonth ().getDisplayName (TextStyle .SHORT , Locale .ENGLISH )
129- + " " + trend .getTrendDate ().getYear ()));
130- tr .addCell (trend .getAvgHappinessRating ());
131- tr .addCell (trend .getResponseCount ());
132- rows .add (tr );
133- }
134-
135- data .addRows (rows );
136-
137- } catch (TypeMismatchException e ) {
138- System .out .print (e );
139- }
140-
141- return JsonRenderer .renderDataTable (data , true , true , false ).toString ();
142-
143- }
144-
14565 @ GetMapping ("/" )
146- public String index (Device device ) throws Exception {
66+ public String index (Device device ) {
14767
14868 if (device .isMobile () || device .isTablet ()){
14969 return "thankyou" ;
@@ -153,13 +73,13 @@ public String index(Device device) throws Exception {
15373 }
15474
15575 @ GetMapping ("/chart" )
156- public String chart () throws Exception {
76+ public String chart () {
15777 return "trendgraph" ;
15878 }
15979
16080 @ GetMapping ("/thankyou" )
161- public String thankyou (Device device , @ RequestParam (name ="team" , required = true ) String teamId ,
162- @ RequestParam (name ="rating" , required = false ) String rating , Model model ) throws Exception {
81+ public String thankyou (Device device , @ RequestParam (name ="team" ) String teamId ,
82+ @ RequestParam (name ="rating" , required = false ) String rating , Model model ) {
16383
16484 HierarchyEntity team = hierarchyClient .findEntityBySlug (teamId );
16585
@@ -192,7 +112,7 @@ private LineDataset createTrendDataSet(String dataSetName, HashMap<String, Doub
192112 dataset .setPointBackgroundColor (pointsColors );
193113 if (child )
194114 {
195- dataset .setBorderDash (new ArrayList <Integer >(Arrays .asList (new Integer []{ 5 , 5 } )));
115+ dataset .setBorderDash (new ArrayList <Integer >(Arrays .asList (5 , 5 )));
196116 }
197117 dataset .setYAxisID ("y-axis-1" );
198118 return dataset ;
@@ -210,7 +130,7 @@ private LineDataset createCountDataSet(String dataSetName, HashMap<String, Inte
210130 dataset .setPointBackgroundColor (pointsColors );
211131 if (child )
212132 {
213- dataset .setBorderDash (new ArrayList <Integer >(Arrays .asList (new Integer []{ 5 , 5 } )));
133+ dataset .setBorderDash (new ArrayList <Integer >(Arrays .asList (5 , 5 )));
214134 }
215135 dataset .setYAxisID ("y-axis-2" );
216136 return dataset ;
0 commit comments