use of org.mifos.platform.questionnaire.service.SectionQuestionDetail 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.SectionQuestionDetail in project head by mifos.
the class QuestionGroupForm method moveQuestionDown.
public void moveQuestionDown(String sectionName, String questionId) {
for (SectionDetailForm section : sections) {
if (StringUtils.equalsIgnoreCase(sectionName, section.getName())) {
List<SectionQuestionDetail> questions = section.getSectionQuestionDetails();
for (SectionQuestionDetail question : questions) {
if (Integer.parseInt(questionId) == question.getQuestionId()) {
int actualSeqNumber = question.getSequenceNumber();
if (actualSeqNumber < questions.size() - 1) {
SectionQuestionDetail questionToSwap = questions.get(actualSeqNumber + 1);
question.setSequenceNumber(questionToSwap.getSequenceNumber());
questionToSwap.setSequenceNumber(actualSeqNumber);
questions.set(actualSeqNumber, questionToSwap);
questions.set(actualSeqNumber + 1, question);
}
break;
}
}
break;
}
}
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class QuestionGroupController method setQuestionLinkDetail.
public QuestionLinkDetail setQuestionLinkDetail(QuestionGroupForm questionGroupForm, String sourceQuestionId, String affectedQuestionId, String value, String additionalValue, String linkType, String linkTypeDisplay) {
QuestionLinkDetail questionLinkDetail = new QuestionLinkDetail();
SectionQuestionDetail sourceQuestion = findQuestionDetailById(questionGroupForm.getQuestionGroupDetail(), sourceQuestionId);
questionLinkDetail.setSourceQuestion(sourceQuestion);
SectionQuestionDetail affectedQuestion = findQuestionDetailById(questionGroupForm.getQuestionGroupDetail(), affectedQuestionId);
questionLinkDetail.setAffectedQuestion(affectedQuestion);
questionLinkDetail.setValue(value);
questionLinkDetail.setLinkType(Integer.valueOf(linkType));
questionLinkDetail.setLinkTypeDisplay(linkTypeDisplay);
questionLinkDetail.setState(false);
if (additionalValue != null)
questionLinkDetail.setAdditionalValue(additionalValue);
return questionLinkDetail;
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class QuestionnaireMapperImpl method mapToSectionQuestions.
private List<SectionQuestion> mapToSectionQuestions(List<SectionQuestionDetail> sectionQuestionDetails, Section section) {
List<SectionQuestion> sectionQuestions = new ArrayList<SectionQuestion>();
for (int i = 0, sectionQuestionDetailsSize = sectionQuestionDetails.size(); i < sectionQuestionDetailsSize; i++) {
SectionQuestionDetail sectionQuestionDetail = sectionQuestionDetails.get(i);
sectionQuestions.add(mapToSectionQuestion(sectionQuestionDetail, i, section));
}
return sectionQuestions;
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class ClientCustActionTest 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;
}
Aggregations