Skip to content

Commit d313430

Browse files
author
ankur.singhal
committed
code changes, csv issue
1 parent 50bdfd5 commit d313430

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎survey/pom.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@
127127
<version>1.9.13</version>
128128
</dependency>
129129

130+
<dependency>
131+
<groupId>commons-lang</groupId>
132+
<artifactId>commons-lang</artifactId>
133+
<version>2.6</version>
134+
</dependency>
130135

131136
<dependency>
132137
<groupId>javax.servlet</groupId>

‎survey/src/main/java/org/ankur/survey/controller/CSVFileDownloadController.java‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.ankur.survey.pojo.SearchSurveyRequest;
1313
import org.ankur.survey.pojo.SearchSurveyResponse;
1414
import org.ankur.survey.service.AdminService;
15+
import org.apache.commons.lang.StringEscapeUtils;
1516
import org.springframework.stereotype.Controller;
1617
import org.springframework.web.bind.annotation.RequestBody;
1718
import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,14 +25,12 @@ public class CSVFileDownloadController {
2425
private AdminService adminServiceImpl;
2526

2627
@RequestMapping(value = "/downloadCSV")
27-
public void downloadCSV(HttpServletResponse response,
28-
@RequestBody SearchSurveyRequest searchSurveyRequest)
28+
public void downloadCSV(HttpServletResponse response, @RequestBody SearchSurveyRequest searchSurveyRequest)
2929
throws IOException {
3030

3131
response.setContentType("text/csv");
3232
String reportName = "Service_rating.csv";
33-
response.setHeader("Content-disposition", "attachment;filename="
34-
+ reportName);
33+
response.setHeader("Content-disposition", "attachment;filename=" + reportName);
3534

3635
List<String> rows = new ArrayList<String>();
3736
rows.add("Person Name,Service Name,Service Rating,Service Time Rating,Feedback,Optional issue link,Date");
@@ -41,13 +40,13 @@ public void downloadCSV(HttpServletResponse response,
4140
.fetchSurveyDataFilterBased(searchSurveyRequest);
4241

4342
for (SearchSurveyResponse searchSurveyResponse : searchSurveyResponses) {
44-
rows.add(searchSurveyResponse.getUser() + ","
45-
+ searchSurveyResponse.getIssueType() + ","
46-
+ searchSurveyResponse.getServicerating() + ","
47-
+ searchSurveyResponse.getServicetimetating() + ","
48-
+ searchSurveyResponse.getFeedback() + ","
49-
+ searchSurveyResponse.getOptional() + ","
50-
+ searchSurveyResponse.getCreatedDate());
43+
rows.add(StringEscapeUtils.escapeCsv(searchSurveyResponse.getUser()) + ","
44+
+ StringEscapeUtils.escapeCsv(searchSurveyResponse.getIssueType()) + ","
45+
+ StringEscapeUtils.escapeCsv(searchSurveyResponse.getServicerating()) + ","
46+
+ StringEscapeUtils.escapeCsv(searchSurveyResponse.getServicetimetating()) + ","
47+
+ StringEscapeUtils.escapeCsv(searchSurveyResponse.getFeedback()) + ","
48+
+ StringEscapeUtils.escapeCsv(searchSurveyResponse.getOptional()) + ","
49+
+ StringEscapeUtils.escapeCsv(searchSurveyResponse.getCreatedDate()));
5150
rows.add("\n");
5251
}
5352

‎survey/src/main/webapp/htm/application/survey.htm‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<div class="row-fluid boldText marginDiv" >
104104
<label class="lable-align">3. Please provide any other comments about the support of your issue or about the product. <small class="lightText">(click and drag in the
105105
bottom right to resize the text area) <span style="color:red">{{feedbackErr}}</span> </label>
106-
<textarea id="3" rows="6" name="feedback" ng-model = "feedback" style="width: 800px;"></textarea>
106+
<textarea id="3" rows="6" name="feedback" ng-model = "feedback" style="min-width: 800px;"></textarea>
107107
</div>
108108

109109
<div class="row-fluid boldText marginDiv" >

0 commit comments

Comments
 (0)