11/*
2- * Copyright (C) 2010-2015 Stichting Akvo (Akvo Foundation)
2+ * Copyright (C) 2010-2017 Stichting Akvo (Akvo Foundation)
33 *
44 * This file is part of Akvo FLOW.
55 *
1616
1717package org .waterforpeople .mapping .app .web ;
1818
19- import java .io .ByteArrayOutputStream ;
20- import java .io .IOException ;
21- import java .util .ArrayList ;
22- import java .util .List ;
23- import java .util .Map ;
24- import java .util .Properties ;
25- import java .util .Random ;
26- import java .util .TreeMap ;
27-
28- import javax .servlet .http .HttpServletRequest ;
29- import javax .servlet .http .HttpServletResponse ;
30- import javax .xml .bind .JAXBException ;
31-
32- import org .apache .commons .lang .StringEscapeUtils ;
33- import org .apache .log4j .Logger ;
34- import org .waterforpeople .mapping .app .web .dto .SurveyAssemblyRequest ;
35- import org .waterforpeople .mapping .dao .SurveyContainerDao ;
36-
3719import com .gallatinsystems .common .domain .UploadStatusContainer ;
3820import com .gallatinsystems .common .util .PropertyUtil ;
3921import com .gallatinsystems .common .util .S3Util ;
4325import com .gallatinsystems .framework .rest .RestResponse ;
4426import com .gallatinsystems .messaging .dao .MessageDao ;
4527import com .gallatinsystems .messaging .domain .Message ;
46- import com .gallatinsystems .survey .dao .CascadeResourceDao ;
47- import com .gallatinsystems .survey .dao .QuestionDao ;
48- import com .gallatinsystems .survey .dao .QuestionGroupDao ;
49- import com .gallatinsystems .survey .dao .SurveyDAO ;
50- import com .gallatinsystems .survey .dao .SurveyGroupDAO ;
51- import com .gallatinsystems .survey .dao .SurveyUtils ;
52- import com .gallatinsystems .survey .dao .SurveyXMLFragmentDao ;
53- import com .gallatinsystems .survey .dao .TranslationDao ;
54- import com .gallatinsystems .survey .domain .CascadeResource ;
28+ import com .gallatinsystems .survey .dao .*;
29+ import com .gallatinsystems .survey .domain .*;
5530import com .gallatinsystems .survey .domain .Question ;
5631import com .gallatinsystems .survey .domain .QuestionGroup ;
57- import com .gallatinsystems .survey .domain .QuestionHelpMedia ;
58- import com .gallatinsystems .survey .domain .QuestionOption ;
59- import com .gallatinsystems .survey .domain .ScoringRule ;
6032import com .gallatinsystems .survey .domain .Survey ;
61- import com .gallatinsystems .survey .domain .SurveyContainer ;
62- import com .gallatinsystems .survey .domain .SurveyGroup ;
63- import com .gallatinsystems .survey .domain .SurveyXMLFragment ;
6433import com .gallatinsystems .survey .domain .SurveyXMLFragment .FRAGMENT_TYPE ;
65- import com .gallatinsystems .survey .domain .Translation ;
66- import com .gallatinsystems .survey .domain .xml .AltText ;
67- import com .gallatinsystems .survey .domain .xml .Dependency ;
68- import com .gallatinsystems .survey .domain .xml .Help ;
69- import com .gallatinsystems .survey .domain .xml .Level ;
70- import com .gallatinsystems .survey .domain .xml .Levels ;
71- import com .gallatinsystems .survey .domain .xml .ObjectFactory ;
72- import com .gallatinsystems .survey .domain .xml .Option ;
73- import com .gallatinsystems .survey .domain .xml .Options ;
74- import com .gallatinsystems .survey .domain .xml .Score ;
75- import com .gallatinsystems .survey .domain .xml .Scoring ;
76- import com .gallatinsystems .survey .domain .xml .ValidationRule ;
34+ import com .gallatinsystems .survey .domain .xml .*;
7735import com .gallatinsystems .survey .xml .SurveyXMLAdapter ;
7836import com .google .appengine .api .backends .BackendServiceFactory ;
7937import com .google .appengine .api .datastore .Text ;
8038import com .google .appengine .api .taskqueue .Queue ;
8139import com .google .appengine .api .taskqueue .QueueFactory ;
8240import com .google .appengine .api .taskqueue .TaskOptions ;
8341import com .google .appengine .api .utils .SystemProperty ;
42+ import org .apache .commons .lang .StringEscapeUtils ;
43+ import org .apache .log4j .Logger ;
44+ import org .waterforpeople .mapping .app .web .dto .SurveyAssemblyRequest ;
45+ import org .waterforpeople .mapping .dao .SurveyContainerDao ;
46+
47+ import javax .servlet .http .HttpServletRequest ;
48+ import javax .servlet .http .HttpServletResponse ;
49+ import javax .xml .bind .JAXBException ;
50+ import java .io .ByteArrayOutputStream ;
51+ import java .io .IOException ;
52+ import java .util .*;
8453
8554public class SurveyAssemblyServlet extends AbstractRestApiServlet {
8655 private static final Logger log = Logger
@@ -156,7 +125,6 @@ protected RestResponse handleRequest(RestRequest req) throws Exception {
156125 .getQueue ("surveyAssembly" );
157126 queue .add (options );
158127 } else {
159- // assembleSurvey(importReq.getSurveyId());
160128 assembleSurveyOnePass (importReq .getSurveyId ());
161129 }
162130
@@ -295,6 +263,7 @@ private void assembleSurveyOnePass(Long surveyId) {
295263 String surveyGroupId = "" ;
296264 String surveyGroupName = "" ;
297265 String registrationForm = "" ;
266+ String surveyIdKeyValue = "surveyId=\" " +surveyId +"\" " ;
298267 if (sg != null ) {
299268 surveyGroupId = "surveyGroupId=\" " + sg .getKey ().getId () + "\" " ;
300269 surveyGroupName = "surveyGroupName=\" " + StringEscapeUtils .escapeXml (sg .getCode ())
@@ -307,7 +276,8 @@ private void assembleSurveyOnePass(Long surveyId) {
307276 String surveyHeader = "<?xml version=\" 1.0\" encoding=\" UTF-8\" standalone=\" yes\" ?><survey"
308277 + " name=\" " + StringEscapeUtils .escapeXml (name )
309278 + "\" " + " defaultLanguageCode=\" " + lang + "\" " + versionAttribute + " " + app
310- + registrationForm + " " + surveyGroupId + " " + surveyGroupName + ">" ;
279+ + registrationForm + " " + surveyGroupId + " " + surveyGroupName + " "
280+ + surveyIdKeyValue + ">" ;
311281 String surveyFooter = "</survey>" ;
312282 QuestionGroupDao qgDao = new QuestionGroupDao ();
313283 TreeMap <Integer , QuestionGroup > qgList = qgDao
0 commit comments