use of org.mifos.platform.questionnaire.service.SectionLinkDetail in project head by mifos.
the class QuestionGroupController method setSectionLinkDetail.
public SectionLinkDetail setSectionLinkDetail(QuestionGroupForm questionGroupForm, String sourceQuestionId, String affectedSectionName, String value, String additionalValue, String linkType, String linkTypeDisplay) {
SectionLinkDetail sectionLinkDetail = new SectionLinkDetail();
SectionQuestionDetail sourceQuestion = findQuestionDetailById(questionGroupForm.getQuestionGroupDetail(), sourceQuestionId);
sectionLinkDetail.setSourceQuestion(sourceQuestion);
SectionDetail affectedSection = findSectionDetailByName(questionGroupForm.getQuestionGroupDetail(), affectedSectionName);
sectionLinkDetail.setAffectedSection(affectedSection);
sectionLinkDetail.setValue(value);
sectionLinkDetail.setLinkType(Integer.valueOf(linkType));
sectionLinkDetail.setLinkTypeDisplay(linkTypeDisplay);
sectionLinkDetail.setState(false);
if (additionalValue != null)
sectionLinkDetail.setAdditionalValue(additionalValue);
return sectionLinkDetail;
}
use of org.mifos.platform.questionnaire.service.SectionLinkDetail in project head by mifos.
the class QuestionnaireMapperImpl method mapToSectionLinkDetails.
public List<SectionLinkDetail> mapToSectionLinkDetails(List<SectionLink> sectionLinks) {
List<SectionLinkDetail> sectionLinkDetails = new ArrayList<SectionLinkDetail>();
for (SectionLink sectionLink : sectionLinks) {
SectionLinkDetail sectionLinkDetail = new SectionLinkDetail();
sectionLinkDetail.setValue(sectionLink.getQuestionGroupLink().getValue());
sectionLinkDetail.setAdditionalValue(sectionLink.getQuestionGroupLink().getAdditionalValue());
sectionLinkDetail.setLinkType(sectionLink.getQuestionGroupLink().getConditionTypeId());
sectionLinkDetail.setProperLinkTypeDisplay(sectionLink.getQuestionGroupLink().getConditionType());
sectionLinkDetail.setLinkId(sectionLink.getId());
sectionLinkDetail.setQuestionGroupLinkId(sectionLink.getQuestionGroupLink().getId());
sectionLinkDetail.setState(true);
SectionQuestion sectionQuestion = sectionLink.getQuestionGroupLink().getSourceSectionQuestion();
sectionLinkDetail.setSourceQuestion(mapToSectionQuestionDetail(sectionQuestion, sectionQuestion.isRequired(), sectionQuestion.isShowOnPage(), (mapToQuestionDetail(sectionQuestion.getQuestion(), mapToQuestionType(sectionQuestion.getQuestion().getAnswerTypeAsEnum())))));
sectionLinkDetail.setAffectedSection(mapToSectionDetail(sectionLink.getAffectedSection()));
sectionLinkDetails.add(sectionLinkDetail);
}
return sectionLinkDetails;
}
use of org.mifos.platform.questionnaire.service.SectionLinkDetail in project head by mifos.
the class QuestionnaireServiceImpl method createSectionLinks.
public void createSectionLinks(List<SectionLinkDetail> sectionLinks) {
for (SectionLinkDetail sectionLinkDetail : sectionLinks) {
QuestionGroupLink questionGroupLink = questionnaireMapper.mapToQuestionGroupLink(null, sectionLinkDetail);
questionGroupLinkDao.saveOrUpdate(questionGroupLink);
SectionLink sectionLink = questionnaireMapper.mapToSectionLink(sectionLinkDetail, questionGroupLink);
sectionLinkDao.saveOrUpdate(sectionLink);
}
}
use of org.mifos.platform.questionnaire.service.SectionLinkDetail in project head by mifos.
the class QuestionGroupController method addLink.
public String addLink(QuestionGroupForm questionGroupForm, String sourceQuestionId, String linkType, String appliesTo, String affectedQuestionId, String affectedSectionName, String value, String additionalValue, Map<String, String> linkTypes, RequestContext requestContext) {
String result = "success";
if (!questionGroupLinkHasErrors(questionGroupForm, requestContext, sourceQuestionId, linkType, appliesTo, affectedQuestionId, affectedSectionName, value, additionalValue)) {
if (appliesTo.equals("question")) {
QuestionLinkDetail questionLink = setQuestionLinkDetail(questionGroupForm, sourceQuestionId, affectedQuestionId, value, additionalValue, linkType, linkTypes.get(linkType));
questionGroupForm.getQuestionLinks().add(questionLink);
} else {
SectionLinkDetail sectionLink = setSectionLinkDetail(questionGroupForm, sourceQuestionId, affectedSectionName, value, additionalValue, linkType, linkTypes.get(linkType));
questionGroupForm.getSectionLinks().add(sectionLink);
}
} else {
result = "failure";
}
return result;
}
use of org.mifos.platform.questionnaire.service.SectionLinkDetail in project head by mifos.
the class QuestionGroupController method setFilledSectionDetailForQuestionLinks.
public List<SectionLinkDetail> setFilledSectionDetailForQuestionLinks(List<SectionLinkDetail> sectionLinkDetails, QuestionGroupDetail questionGroupDetail) {
for (SectionLinkDetail sectionLinkDetail : sectionLinkDetails) {
sectionLinkDetail.setSourceQuestion(findQuestionDetailByNickname(questionGroupDetail, String.valueOf(sectionLinkDetail.getSourceQuestion().getQuestionDetail().getNickname())));
sectionLinkDetail.setAffectedSection(findSectionDetailByName(questionGroupDetail, sectionLinkDetail.getAffectedSection().getName()));
}
return sectionLinkDetails;
}
Aggregations