Skip to content

Commit 3ab9cb4

Browse files
committed
#24 Remove obsolete Google visualisation code
1 parent 90e7e20 commit 3ab9cb4

File tree

3 files changed

+10
-100
lines changed

3 files changed

+10
-100
lines changed

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131

3232
<dependencyManagement>
3333
<dependencies>
34-
<dependency>
35-
<groupId>com.google.visualization</groupId>
36-
<artifactId>visualization-datasource</artifactId>
37-
<version>1.1.1</version>
38-
</dependency>
3934
<dependency>
4035
<groupId>de.flapdoodle.embed</groupId>
4136
<artifactId>de.flapdoodle.embed.mongo</artifactId>

web/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@
6767
<optional>true</optional>
6868
</dependency>
6969

70-
<dependency>
71-
<groupId>com.google.visualization</groupId>
72-
<artifactId>visualization-datasource</artifactId>
73-
</dependency>
74-
7570
<dependency>
7671
<groupId>de.flapdoodle.embed</groupId>
7772
<artifactId>de.flapdoodle.embed.mongo</artifactId>

web/src/main/java/com/austenconstable/web/trend/TrendController.java

Lines changed: 10 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,16 @@
1212
import com.fasterxml.jackson.core.JsonProcessingException;
1313
import com.fasterxml.jackson.databind.ObjectMapper;
1414
import 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;
2315
import org.springframework.beans.factory.annotation.Autowired;
2416
import org.springframework.http.HttpStatus;
2517
import org.springframework.http.ResponseEntity;
2618
import org.springframework.mobile.device.Device;
2719
import org.springframework.stereotype.Controller;
2820
import 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

3126
import java.math.BigDecimal;
3227
import java.math.RoundingMode;
@@ -35,8 +30,6 @@
3530
import java.time.ZoneOffset;
3631
import java.time.ZonedDateTime;
3732
import java.time.format.DateTimeFormatter;
38-
import java.time.format.TextStyle;
39-
import java.time.temporal.TemporalField;
4033
import java.time.temporal.WeekFields;
4134
import 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

Comments
 (0)