use of org.mifos.platform.questionnaire.service.QuestionGroupDetail 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.QuestionGroupDetail in project head by mifos.
the class QuestionGroupController method defineQuestionGroup.
@SuppressWarnings({ "ThrowableInstanceNeverThrown" })
public String defineQuestionGroup(QuestionGroupForm questionGroupForm, RequestContext requestContext, boolean createMode) {
String result = "success";
if (!questionGroupHasErrors(questionGroupForm, requestContext)) {
QuestionGroupDetail questionGroupDetail = null;
try {
if (createMode) {
questionGroupForm.setActive(true);
}
if (questionGroupForm.isActive()) {
questionGroupDetail = questionnaireServiceFacade.createActiveQuestionGroup(questionGroupForm.getQuestionGroupDetail());
} else {
questionGroupDetail = questionnaireServiceFacade.createQuestionGroup(questionGroupForm.getQuestionGroupDetail());
}
if (containsCreateLoanEventSource(questionGroupForm.getEventSources()) && questionGroupForm.getApplyToAllLoanProducts()) {
questionnaireServiceFacade.applyToAllLoanProducts(questionGroupDetail.getId());
}
List<QuestionLinkDetail> questionLinkDetails = setFilledQuestionDetailForQuestionLinks(questionGroupForm.getQuestionLinks(), questionGroupDetail);
List<SectionLinkDetail> sectionLinkDetails = setFilledSectionDetailForQuestionLinks(questionGroupForm.getSectionLinks(), questionGroupDetail);
questionnaireServiceFacade.createQuestionLinks(questionLinkDetails);
questionnaireServiceFacade.createSectionLinks(sectionLinkDetails);
} catch (AccessDeniedException e) {
constructAndLogSystemError(requestContext.getMessageContext(), new SystemException(QuestionnaireConstants.MISSING_PERMISSION_TO_ACTIVATE_QG, e));
result = "failure";
} catch (SystemException e) {
constructAndLogSystemError(requestContext.getMessageContext(), e);
result = "failure";
}
} else {
result = "failure";
}
return result;
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class QuestionnaireMapperImpl method mapToQuestionGroupInstanceDetail.
@Override
public QuestionGroupInstanceDetail mapToQuestionGroupInstanceDetail(QuestionGroupInstance questionGroupInstance) {
QuestionGroupDetail questionGroupDetail = mapToQuestionGroupDetail(questionGroupInstance.getQuestionGroup());
QuestionGroupInstanceDetail questionGroupInstanceDetail = new QuestionGroupInstanceDetail();
questionGroupInstanceDetail.setId(questionGroupInstance.getId());
questionGroupInstanceDetail.setDateCompleted(questionGroupInstance.getDateConducted());
questionGroupInstanceDetail.setQuestionGroupDetail(questionGroupDetail);
mapQuestionResponses(questionGroupInstance.getQuestionGroupResponses(), questionGroupInstanceDetail.getQuestionGroupDetail());
return questionGroupInstanceDetail;
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail 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);
}
use of org.mifos.platform.questionnaire.service.QuestionGroupDetail in project head by mifos.
the class CreateSavingsAccountTest method testEnterAccountDetailsStep_DetailsEntered_WithQuestionGroup.
/**
* Account info entry step is complete. There is a question group defined
* for "Create Savings" work flow.
*/
@Test
public void testEnterAccountDetailsStep_DetailsEntered_WithQuestionGroup() {
List<QuestionGroupDetail> groups = new ArrayList<QuestionGroupDetail>();
groups.add(new QuestionGroupDetail());
when(formBean.getQuestionGroups()).thenReturn(groups);
setCurrentState("enterAccountDetailsStep");
MockExternalContext context = new MockExternalContext();
context.setEventId("detailsEntered");
resumeFlow(context);
assertCurrentStateEquals("answerQuestionGroupStep");
}
Aggregations