use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class SectionQuestionDaoIntegrationTest method getSection.
private SectionDetail getSection(String name) throws SystemException {
SectionDetail section = new SectionDetail();
section.setName(name);
section.addQuestion(new SectionQuestionDetail(defineQuestion("Question1" + name + currentTimeMillis(), QuestionType.NUMERIC), true));
section.addQuestion(new SectionQuestionDetail(defineQuestion("Question2" + name + currentTimeMillis(), QuestionType.DATE), true));
section.addQuestion(new SectionQuestionDetail(defineQuestion("Question3" + name + currentTimeMillis(), QuestionType.FREETEXT), false));
return section;
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionGroupForm method initSections.
private List<SectionDetailForm> initSections() {
List<SectionDetailForm> sectionDetailForms = new ArrayList<SectionDetailForm>();
if (questionGroupDetail != null) {
for (SectionDetail sectionDetail : questionGroupDetail.getSectionDetails()) {
SectionDetailForm sectionDetailForm = new SectionDetailForm(sectionDetail);
sectionDetailForm.setInitialCountOfQuestions(sectionDetail.getCountOfQuestions());
sectionDetailForms.add(sectionDetailForm);
}
}
this.initialCountOfSections = sectionDetailForms.size();
return sectionDetailForms;
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionGroupForm method addCurrentSectionToSections.
private void addCurrentSectionToSections() {
for (SectionDetailForm section : sections) {
if (StringUtils.equalsIgnoreCase(section.getName(), currentSection.getName())) {
currentSection = section;
return;
}
}
List<SectionDetail> sectionDetails = new ArrayList<SectionDetail>();
for (SectionDetailForm sectionDetailForm : sections) {
SectionDetail sectionDetail = sectionDetailForm.getSectionDetail();
sectionDetail.setSequenceNumber(sectionDetail.getSequenceNumber() + 1);
sectionDetails.add(sectionDetail);
}
currentSection.getSectionDetail().setSequenceNumber(0);
sectionDetails.add(0, currentSection.getSectionDetail());
sections.add(0, currentSection);
questionGroupDetail.setSectionDetails(sectionDetails);
sectionsToAdd.add(currentSection.getName());
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionGroupForm method moveSectionDown.
public void moveSectionDown(String sectionName) {
for (SectionDetailForm sectionForm : sections) {
SectionDetail section = sectionForm.getSectionDetail();
if (StringUtils.equalsIgnoreCase(sectionName, section.getName())) {
int actualSeqNumber = section.getSequenceNumber();
if (actualSeqNumber < sections.size() - 1) {
SectionDetailForm sectionToSwap = sections.remove(actualSeqNumber + 1);
section.setSequenceNumber(sectionToSwap.getSectionDetail().getSequenceNumber());
sectionToSwap.getSectionDetail().setSequenceNumber(actualSeqNumber);
sections.add(actualSeqNumber + 1, sectionForm);
sections.set(actualSeqNumber, sectionToSwap);
List<SectionDetail> sectionDetails = new ArrayList<SectionDetail>();
for (SectionDetailForm sectionDetailForm : sections) {
sectionDetails.add(sectionDetailForm.getSectionDetail());
}
questionGroupDetail.setSectionDetails(sectionDetails);
}
break;
}
}
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionGroupForm method moveSectionUp.
public void moveSectionUp(String sectionName) {
for (SectionDetailForm sectionForm : sections) {
SectionDetail section = sectionForm.getSectionDetail();
if (StringUtils.equalsIgnoreCase(sectionName, section.getName())) {
int actualSeqNumber = section.getSequenceNumber();
if (actualSeqNumber > 0) {
SectionDetailForm sectionToSwap = sections.remove(actualSeqNumber - 1);
section.setSequenceNumber(sectionToSwap.getSectionDetail().getSequenceNumber());
sectionToSwap.getSectionDetail().setSequenceNumber(actualSeqNumber);
sections.add(actualSeqNumber - 1, sectionForm);
sections.set(actualSeqNumber, sectionToSwap);
List<SectionDetail> sectionDetails = new ArrayList<SectionDetail>();
for (SectionDetailForm sectionDetailForm : sections) {
sectionDetails.add(sectionDetailForm.getSectionDetail());
}
questionGroupDetail.setSectionDetails(sectionDetails);
}
break;
}
}
}
Aggregations