Skip to content

Commit

Permalink
Merge branch 'issue/2244-npe-fix' into release/1.9.22.2
Browse files Browse the repository at this point in the history
  • Loading branch information
valllllll2000 committed Sep 8, 2017
2 parents 2f2a08a + d6f9841 commit 8c7ad6b
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -150,7 +151,7 @@ private List<SurveyedLocaleDto> getSurveyedLocaleDtosList(List<SurveyedLocale> s
private SurveyedLocaleDto createSurveyedLocaleDto(Long surveyGroupId, QuestionDao questionDao,
HashMap<Long, String> questionTypeMap, SurveyedLocale surveyedLocale,
Map<Long, List<QuestionAnswerStore>> questionAnswerStoreMap,
List<SurveyInstance> surveyInstances) {
@Nullable List<SurveyInstance> surveyInstances) {
SurveyedLocaleDto dto = new SurveyedLocaleDto();
dto.setId(surveyedLocale.getIdentifier());
dto.setSurveyGroupId(surveyGroupId);
Expand All @@ -159,21 +160,22 @@ private SurveyedLocaleDto createSurveyedLocaleDto(Long surveyGroupId, QuestionDa
dto.setLon(surveyedLocale.getLongitude());
dto.setLastUpdateDateTime(surveyedLocale.getLastUpdateDateTime());

for (SurveyInstance surveyInstance : surveyInstances) {
Long surveyInstanceId = surveyInstance.getObjectId();
List<QuestionAnswerStore> 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<QuestionAnswerStore> answerStores = questionAnswerStoreMap
.get(surveyInstanceId);
SurveyInstanceDto siDto = createSurveyInstanceDto(questionDao, questionTypeMap,
answerStores, surveyInstance);
dto.getSurveyInstances().add(siDto);
}
}
return dto;
}

/**
* Returns a map of QuestionAnswerStore lists,
* keys: surveyInstanceId, value: list of QuestionAnswerStore for that surveyInstance
* @param surveyInstanceMap
*/
private Map<Long, List<QuestionAnswerStore>> getQuestionAnswerStoreMap(
Map<Long, List<SurveyInstance>> surveyInstanceMap) {
Expand Down Expand Up @@ -243,8 +245,9 @@ private List<Long> getSurveyedLocalesIds(List<SurveyedLocale> slList) {
}

private SurveyInstanceDto createSurveyInstanceDto(QuestionDao qDao,
HashMap<Long, String> questionTypeMap, List<QuestionAnswerStore> questionAnswerStores,
SurveyInstance surveyInstance) {
HashMap<Long, String> questionTypeMap,
@Nullable List<QuestionAnswerStore> questionAnswerStores,
@Nullable SurveyInstance surveyInstance) {
SurveyInstanceDto surveyInstanceDto = new SurveyInstanceDto();
if (surveyInstance != null) {
surveyInstanceDto.setUuid(surveyInstance.getUuid());
Expand Down

0 comments on commit 8c7ad6b

Please sign in to comment.