use of org.mifos.platform.questionnaire.service.dtos.SectionDto in project head by mifos.
the class QuestionnaireServiceTest method getQuestionGroupDto.
private QuestionGroupDto getQuestionGroupDto() {
QuestionDto question1 = new QuestionDtoBuilder().withText("Ques1").withMandatory(true).withType(QuestionType.FREETEXT).build();
ChoiceDto choice1 = new ChoiceDetailBuilder().withValue("Ch1").withOrder(1).build();
ChoiceDto choice2 = new ChoiceDetailBuilder().withValue("Ch2").withOrder(2).build();
ChoiceDto choice3 = new ChoiceDetailBuilder().withValue("Ch3").withOrder(3).build();
QuestionDto question2 = new QuestionDtoBuilder().withText("Ques2").withType(QuestionType.SINGLE_SELECT).addChoices(choice1, choice2, choice3).build();
SectionDto section = new SectionDtoBuilder().withName("Sec1").withOrder(1).addQuestions(question1, question2).build();
return new QuestionGroupDtoBuilder().withTitle("QG1").withEventSource("Create", "Client").addSections(section).build();
}
use of org.mifos.platform.questionnaire.service.dtos.SectionDto in project head by mifos.
the class QuestionnaireValidatorForDtoTest method getQuestionGroupDto.
private QuestionGroupDto getQuestionGroupDto() {
String ques1Title = "Ques1" + currentTimeMillis();
String ques2Title = "Ques2" + currentTimeMillis();
String ques3Title = "Ques3" + currentTimeMillis();
String ques4Title = "Ques4" + currentTimeMillis();
String qgTitle = "QG1" + currentTimeMillis();
QuestionDto question1 = new QuestionDtoBuilder().withText(ques1Title).withMandatory(true).withType(QuestionType.FREETEXT).withOrder(1).build();
ChoiceDto choice1 = new ChoiceDetailBuilder().withValue("Ch1").withOrder(1).build();
ChoiceDto choice2 = new ChoiceDetailBuilder().withValue("Ch2").withOrder(2).build();
ChoiceDto choice3 = new ChoiceDetailBuilder().withValue("Ch3").withOrder(3).build();
QuestionDto question2 = new QuestionDtoBuilder().withText(ques2Title).withType(QuestionType.SINGLE_SELECT).addChoices(choice1, choice2, choice3).withOrder(2).build();
SectionDto section1 = new SectionDtoBuilder().withName("Sec1").withOrder(1).addQuestions(question1, question2).build();
QuestionDto question3 = new QuestionDtoBuilder().withText(ques3Title).withMandatory(false).withType(QuestionType.DATE).withOrder(1).build();
QuestionDto question4 = new QuestionDtoBuilder().withText(ques4Title).withMandatory(true).withType(QuestionType.NUMERIC).withOrder(2).build();
SectionDto section2 = new SectionDtoBuilder().withName("Sec2").withOrder(2).addQuestions(question3, question4).build();
return new QuestionGroupDtoBuilder().withTitle(qgTitle).withEventSource("Create", "Client").addSections(section1, section2).build();
}
use of org.mifos.platform.questionnaire.service.dtos.SectionDto in project head by mifos.
the class QuestionnaireServiceImpl method activateQGWithQuestions.
private void activateQGWithQuestions(QuestionGroupDto questionGroupDto) {
questionGroupDto.setActive(true);
for (SectionDto section : questionGroupDto.getSections()) {
for (QuestionDto question : section.getQuestions()) {
question.setActive(true);
question.setEditable(true);
}
}
}
use of org.mifos.platform.questionnaire.service.dtos.SectionDto in project head by mifos.
the class QuestionnaireValidatorImpl method allSectionsHaveUniqueOrders.
private boolean allSectionsHaveUniqueOrders(List<SectionDto> sections) {
boolean result = true;
Set<Integer> sectionOrders = new HashSet<Integer>();
for (SectionDto section : sections) {
Integer order = section.getOrder();
if (sectionOrders.contains(order)) {
result = false;
break;
} else {
sectionOrders.add(order);
}
}
return result;
}
Aggregations