use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class LoanAccountActionTest method getSectionDetail.
private SectionDetail getSectionDetail(String name, String title, List<String> answerChoices) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
QuestionDetail questionDetail = new QuestionDetail(111, title, QuestionType.SINGLE_SELECT, true, true);
List<ChoiceDto> choiceDtos = new ArrayList<ChoiceDto>();
for (String answerChoice : answerChoices) {
choiceDtos.add(new ChoiceDto(answerChoice));
}
questionDetail.setAnswerChoices(choiceDtos);
sectionDetail.setQuestionDetails(asList(new SectionQuestionDetail(questionDetail, true)));
return sectionDetail;
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireServiceImpl method removeInActiveSectionsAndQuestions.
private void removeInActiveSectionsAndQuestions(QuestionGroupDetail questionGroupDetail) {
for (Iterator<SectionDetail> sectionDetailIterator = questionGroupDetail.getSectionDetails().iterator(); sectionDetailIterator.hasNext(); ) {
SectionDetail sectionDetail = sectionDetailIterator.next();
removeInActiveQuestions(sectionDetail);
if (sectionDetail.hasNoActiveQuestions()) {
sectionDetailIterator.remove();
}
}
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireMapperImpl method mapToQuestionGroupDetail.
@Override
public QuestionGroupDetail mapToQuestionGroupDetail(QuestionGroup questionGroup) {
List<SectionDetail> sectionDetails = mapToSectionDetails(questionGroup.getSections());
List<SectionLink> sectionLinks = new ArrayList<SectionLink>();
List<SectionQuestionLink> sectionQuestionLinks = new ArrayList<SectionQuestionLink>();
for (SectionDetail sectionDetail : sectionDetails) {
for (SectionQuestionDetail sectionQuestionDetail : sectionDetail.getQuestionDetails()) {
if (!sectionLinkDao.retrieveDependentSectionLinksFromQuestion(sectionQuestionDetail.getId()).isEmpty())
sectionLinks.addAll(sectionLinkDao.retrieveDependentSectionLinksFromQuestion(sectionQuestionDetail.getId()));
if (!sectionQuestionLinkDao.retrieveDependentSectionQuestionLinksFromQuestion(sectionQuestionDetail.getId()).isEmpty())
sectionQuestionLinks.addAll(sectionQuestionLinkDao.retrieveDependentSectionQuestionLinksFromQuestion(sectionQuestionDetail.getId()));
}
}
List<EventSourceDto> eventSourceDtos = mapToEventSource(questionGroup.getEventSources());
return new QuestionGroupDetail(questionGroup.getId(), questionGroup.getTitle(), eventSourceDtos, sectionDetails, questionGroup.isEditable(), QuestionGroupState.ACTIVE.equals(questionGroup.getState()), questionGroup.isPpi(), mapToQuestionLinkDetails(sectionQuestionLinks), mapToSectionLinkDetails(sectionLinks));
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionGroupForm method removeSection.
public void removeSection(String sectionName) {
SectionDetail sectionToDelete = null;
for (Iterator<SectionDetailForm> iterator = sections.iterator(); iterator.hasNext(); ) {
SectionDetailForm section = iterator.next();
if (StringUtils.equalsIgnoreCase(sectionName, section.getName())) {
sectionToDelete = section.getSectionDetail();
iterator.remove();
break;
}
}
if (sectionToDelete != null) {
List<SectionDetail> sectionDetails = new ArrayList<SectionDetail>();
int sequence = 0;
for (SectionDetailForm sectionDetailForm : sections) {
SectionDetail sectionDetail = sectionDetailForm.getSectionDetail();
sectionDetail.setSequenceNumber(sequence++);
sectionDetails.add(sectionDetail);
}
markQuestionsOptionalAndReturnToPool(sectionToDelete);
questionGroupDetail.setSectionDetails(sectionDetails);
for (int i = 0; i < sectionsToAdd.size(); i++) {
String name = sectionsToAdd.get(i);
if (name.equals(sectionName)) {
sectionsToAdd.remove(i);
break;
}
}
for (Iterator<SectionLinkDetail> iterator = sectionLinks.iterator(); iterator.hasNext(); ) {
SectionLinkDetail sectionLinkDetail = iterator.next();
if (sectionLinkDetail.getAffectedSection().getName().equals(sectionToDelete.getName()))
iterator.remove();
for (SectionQuestionDetail sectionQuestionDetail : sectionToDelete.getQuestionDetails()) {
if (sectionLinkDetail.getSourceQuestion().getQuestionDetail().getId().equals(sectionQuestionDetail.getQuestionDetail().getId()))
iterator.remove();
}
}
for (SectionQuestionDetail sectionQuestionDetail : sectionToDelete.getQuestionDetails()) {
for (Iterator<QuestionLinkDetail> iterator = questionLinks.iterator(); iterator.hasNext(); ) {
QuestionLinkDetail questionLinkDetail = iterator.next();
if (questionLinkDetail.getSourceQuestion().getQuestionDetail().getId().equals(sectionQuestionDetail.getQuestionId()))
iterator.remove();
if (questionLinkDetail.getAffectedQuestion().getQuestionDetail().getId().equals(sectionQuestionDetail.getQuestionId()))
iterator.remove();
}
}
}
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireFlowAdapterTest method getQuestionGroups.
private List<QuestionGroupDetail> getQuestionGroups() {
List<QuestionDetail> questions = Arrays.asList(new QuestionDetail(12, "Question1", QuestionType.FREETEXT, true, true));
List<SectionDetail> section = Arrays.asList(getSectionDetailWithQuestions("Section1", questions, null, true));
QuestionGroupDetail questionGroup = getQuestionGroupDetail("Group1", "Create", "Loan", section);
return Arrays.asList(questionGroup);
}
Aggregations