use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class QuestionGroupControllerTest method getQuestionGroupFormWithOneSectionQuestion.
private QuestionGroupForm getQuestionGroupFormWithOneSectionQuestion(String qgTitle, int questionId) {
QuestionGroupForm questionGroupForm = getQuestionGroupForm(qgTitle, "Create.Client");
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName("Sec1");
sectionDetail.setQuestionDetails(asList(new SectionQuestionDetail(getQuestionDetail(questionId, "Q3", QuestionType.FREETEXT), true)));
questionGroupForm.getQuestionGroupDetail().getSectionDetails().add(sectionDetail);
return questionGroupForm;
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class AuditLogServiceImpl method addAuditLogRegistry.
@Override
public void addAuditLogRegistry(QuestionGroupDetail questionGroupDetail, QuestionGroupDetail oldQuestionGroupDetail, int creatorId, int entityId, String source, String event) {
PersonnelBusinessService pbs = new PersonnelBusinessService();
String modifierName;
if (oldQuestionGroupDetail != null && event.toLowerCase().equals(CREATE)) {
String questionGroupName;
String sectionName;
String fieldName;
String fieldValue;
try {
modifierName = pbs.getPersonnel((short) creatorId).getDisplayName();
} catch (ServiceException e) {
modifierName = "";
}
questionGroupName = questionGroupDetail.getTitle();
AuditLog auditLog = new AuditLog(entityId, EntityType.getEntityValue(source.toUpperCase()), modifierName, new DateTimeService().getCurrentJavaSqlDate(), (short) creatorId);
Set<AuditLogRecord> auditLogRecords = new HashSet<AuditLogRecord>();
for (int sectionPosition = 0; sectionPosition < questionGroupDetail.getSectionDetails().size(); sectionPosition++) {
SectionDetail sectionDetail = questionGroupDetail.getSectionDetails().get(sectionPosition);
sectionName = sectionDetail.getName();
for (int questionPosition = 0; questionPosition < sectionDetail.getQuestions().size(); questionPosition++) {
SectionQuestionDetail sectionQuestionDetail = sectionDetail.getQuestions().get(questionPosition);
fieldName = sectionQuestionDetail.getText();
fieldValue = sectionQuestionDetail.getAnswer();
String oldFieldValue = null;
for (SectionDetail oldSectionDetail : oldQuestionGroupDetail.getSectionDetails()) {
if (oldSectionDetail.getName().equals(sectionName)) {
for (SectionQuestionDetail oldSectionQuestionDetail : oldSectionDetail.getQuestions()) {
if (oldSectionQuestionDetail.getText().equals(fieldName)) {
oldFieldValue = oldSectionQuestionDetail.getAnswer();
break;
}
}
break;
}
}
if (!fieldValue.equals("")) {
if (oldFieldValue != null && !oldFieldValue.equals("")) {
if (!oldFieldValue.equals(fieldValue)) {
auditLogRecords.add(new AuditLogRecord(trimField(questionGroupName + "/" + sectionName + "/" + fieldName, 100), trimField(oldFieldValue, 200), trimField(fieldValue, 200), auditLog));
}
} else {
auditLogRecords.add(new AuditLogRecord(trimField(questionGroupName + "/" + sectionName + "/" + fieldName, 100), "-", trimField(fieldValue, 200), auditLog));
}
}
}
}
if (!auditLogRecords.isEmpty()) {
auditLog.addAuditLogRecords(auditLogRecords);
legacyAuditDao.save(auditLog);
}
}
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail 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.SectionQuestionDetail 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.SectionQuestionDetail in project head by mifos.
the class QuestionGroupController method getAllSectionQuestions.
public List<SectionQuestionDetail> getAllSectionQuestions() {
List<SectionQuestionDetail> sectionQuestionDetails = new ArrayList<SectionQuestionDetail>();
List<QuestionDetail> questionDetails = questionnaireServiceFacade.getAllActiveQuestions();
if (questionDetails != null) {
for (QuestionDetail questionDetail : questionDetails) {
sectionQuestionDetails.add(new SectionQuestionDetail(questionDetail, false));
}
}
return sectionQuestionDetails;
}
Aggregations