diff --git a/GAE/src/org/waterforpeople/mapping/app/web/SurveyedLocaleServlet.java b/GAE/src/org/waterforpeople/mapping/app/web/SurveyedLocaleServlet.java index 06dd12fbdd..48e1b1dd27 100644 --- a/GAE/src/org/waterforpeople/mapping/app/web/SurveyedLocaleServlet.java +++ b/GAE/src/org/waterforpeople/mapping/app/web/SurveyedLocaleServlet.java @@ -27,6 +27,7 @@ import com.gallatinsystems.survey.domain.Survey; import com.gallatinsystems.surveyal.dao.SurveyedLocaleDao; import com.gallatinsystems.surveyal.domain.SurveyedLocale; +import com.google.api.server.spi.config.Nullable; import org.akvo.flow.domain.DataUtils; import org.codehaus.jackson.map.ObjectMapper; import org.waterforpeople.mapping.app.web.dto.SurveyInstanceDto; @@ -150,7 +151,7 @@ private List getSurveyedLocaleDtosList(List s private SurveyedLocaleDto createSurveyedLocaleDto(Long surveyGroupId, QuestionDao questionDao, HashMap questionTypeMap, SurveyedLocale surveyedLocale, Map> questionAnswerStoreMap, - List surveyInstances) { + @Nullable List surveyInstances) { SurveyedLocaleDto dto = new SurveyedLocaleDto(); dto.setId(surveyedLocale.getIdentifier()); dto.setSurveyGroupId(surveyGroupId); @@ -159,13 +160,15 @@ private SurveyedLocaleDto createSurveyedLocaleDto(Long surveyGroupId, QuestionDa dto.setLon(surveyedLocale.getLongitude()); dto.setLastUpdateDateTime(surveyedLocale.getLastUpdateDateTime()); - for (SurveyInstance surveyInstance : surveyInstances) { - Long surveyInstanceId = surveyInstance.getObjectId(); - List answerStores = questionAnswerStoreMap - .get(surveyInstanceId); - SurveyInstanceDto siDto = createSurveyInstanceDto(questionDao, questionTypeMap, - answerStores, surveyInstance); - dto.getSurveyInstances().add(siDto); + if (surveyInstances != null) { + for (SurveyInstance surveyInstance : surveyInstances) { + Long surveyInstanceId = surveyInstance.getObjectId(); + List answerStores = questionAnswerStoreMap + .get(surveyInstanceId); + SurveyInstanceDto siDto = createSurveyInstanceDto(questionDao, questionTypeMap, + answerStores, surveyInstance); + dto.getSurveyInstances().add(siDto); + } } return dto; } @@ -173,7 +176,6 @@ private SurveyedLocaleDto createSurveyedLocaleDto(Long surveyGroupId, QuestionDa /** * Returns a map of QuestionAnswerStore lists, * keys: surveyInstanceId, value: list of QuestionAnswerStore for that surveyInstance - * @param surveyInstanceMap */ private Map> getQuestionAnswerStoreMap( Map> surveyInstanceMap) { @@ -243,8 +245,9 @@ private List getSurveyedLocalesIds(List slList) { } private SurveyInstanceDto createSurveyInstanceDto(QuestionDao qDao, - HashMap questionTypeMap, List questionAnswerStores, - SurveyInstance surveyInstance) { + HashMap questionTypeMap, + @Nullable List questionAnswerStores, + @Nullable SurveyInstance surveyInstance) { SurveyInstanceDto surveyInstanceDto = new SurveyInstanceDto(); if (surveyInstance != null) { surveyInstanceDto.setUuid(surveyInstance.getUuid());