Skip to content

Instantly share code, notes, and snippets.

@iperdomo
Created May 22, 2020 09:37
Show Gist options
  • Save iperdomo/59843af81ec56ebe827deb04a91fff3d to your computer and use it in GitHub Desktop.
Save iperdomo/59843af81ec56ebe827deb04a91fff3d to your computer and use it in GitHub Desktop.
diff --git a/GAE/src/com/gallatinsystems/survey/domain/WebForm.java b/GAE/src/com/gallatinsystems/survey/domain/WebForm.java
index 048d779fa..4db033575 100644
--- a/GAE/src/com/gallatinsystems/survey/domain/WebForm.java
+++ b/GAE/src/com/gallatinsystems/survey/domain/WebForm.java
@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
public class WebForm {
- public static Set<String> unsupportedQuestionTypes(){
+ public static Set<String> unsupportedQuestionTypes() {
Set<String> unsupportedTypes = new HashSet<String>();
unsupportedTypes.add(Question.Type.GEOSHAPE.toString());
unsupportedTypes.add(Question.Type.SIGNATURE.toString());
@@ -31,19 +31,23 @@ public class WebForm {
return unsupportedTypes;
}
- public static boolean validQuestionGroups(final Survey survey){
+ public static boolean validQuestionGroups(final Survey survey) {
return survey.getQuestionGroupMap().values().stream().filter(i -> i.getRepeatable()).collect(Collectors.toList()).size() == 0;
}
- public static boolean validSurveyGroup(final Survey survey, final SurveyGroup surveyGroup){
+ public static boolean validSurveyGroup(final Survey survey, final SurveyGroup surveyGroup) {
return surveyGroup.getNewLocaleSurveyId() != null && surveyGroup.getNewLocaleSurveyId().equals(survey.getKey().getId());
}
- public static boolean validWebForm(final SurveyGroup surveyGroup, final Survey survey, final List<Question> questions){
+ public static boolean validWebForm(final SurveyGroup surveyGroup, final Survey survey, final List<Question> questions) {
boolean validQuestionGroups = validQuestionGroups(survey);
- if (!validQuestionGroups) { return false; }
+ if (!validQuestionGroups) {
+ return false;
+ }
boolean validSurveyGroup = validSurveyGroup(survey, surveyGroup);
- if (!validSurveyGroup) { return false; }
+ if (!validSurveyGroup) {
+ return false;
+ }
List<Question> validQuestions = questions.stream().filter(i -> !unsupportedQuestionTypes().contains(i.getType().toString())).collect(Collectors.toList());
return validQuestions.size() == questions.size();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment