use of org.mifos.platform.questionnaire.domain.QuestionGroup in project head by mifos.
the class SectionQuestionDaoIntegrationTest method shouldRetrieveSectionQuestionIdByQuestionGroupNameSectionNameQuestionId.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldRetrieveSectionQuestionIdByQuestionGroupNameSectionNameQuestionId() {
String title = "QG1" + currentTimeMillis();
SectionDetail sectionDetail1 = getSection("S1");
SectionDetail sectionDetail2 = getSection("S2");
List<SectionDetail> details = asList(sectionDetail1, sectionDetail2);
QuestionGroupDetail questionGroupDetail = defineQuestionGroup(title, "Create", "Client", details, false);
QuestionGroup questionGroup = questionGroupDao.getDetails(questionGroupDetail.getId());
Integer questionId = questionGroup.getSections().get(1).getQuestions().get(1).getQuestion().getQuestionId();
Integer sectionQuestionId = questionGroup.getSections().get(1).getQuestions().get(1).getId();
List<Integer> sectionQuestionIds = sectionQuestionDao.retrieveIdFromQuestionGroupIdQuestionIdSectionName("S2", questionId, questionGroup.getId());
assertThat(sectionQuestionIds, is(notNullValue()));
assertThat(sectionQuestionIds.size(), is(1));
assertThat(sectionQuestionIds.get(0), is(sectionQuestionId));
}
use of org.mifos.platform.questionnaire.domain.QuestionGroup in project head by mifos.
the class QuestionnaireServiceIntegrationTest method shouldDefineQuestionGroup.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldDefineQuestionGroup() throws SystemException {
String title = TITLE + currentTimeMillis();
QuestionDetail questionDetail1 = defineQuestion(title + 1, QuestionType.NUMERIC, true);
QuestionDetail questionDetail2 = defineQuestion(title + 2, QuestionType.FREETEXT, true);
SectionDetail section1 = getSectionWithQuestionId("S1", questionDetail1);
SectionDetail section2 = getSectionWithQuestionId("S2", questionDetail2);
QuestionGroupDetail questionGroupDetail = defineQuestionGroup(title, "Create", "Client", asList(section1, section2), true);
assertNotNull(questionGroupDetail);
Integer questionGroupId = questionGroupDetail.getId();
assertNotNull(questionGroupId);
QuestionGroup questionGroup = questionGroupDao.getDetails(questionGroupId);
assertNotNull(questionGroup);
Assert.assertEquals(title, questionGroup.getTitle());
Assert.assertEquals(QuestionGroupState.ACTIVE, questionGroup.getState());
Assert.assertEquals(true, questionGroup.isEditable());
List<Section> sections = questionGroup.getSections();
Assert.assertEquals(2, sections.size());
Assert.assertEquals("S1", sections.get(0).getName());
Assert.assertEquals(title + 1, sections.get(0).getQuestions().get(0).getQuestion().getQuestionText());
Assert.assertEquals("S2", sections.get(1).getName());
Assert.assertEquals(title + 2, sections.get(1).getQuestions().get(0).getQuestion().getQuestionText());
verifyCreationDate(questionGroup);
verifyEventSources(questionGroup);
}
use of org.mifos.platform.questionnaire.domain.QuestionGroup in project head by mifos.
the class QuestionnaireServiceFacadeImpl method checkAccessToQuestionGroup.
private boolean checkAccessToQuestionGroup(Integer questionGroupId) {
QuestionGroup questionGroup = this.questionnaireService.getQuestionGroupById(questionGroupId);
boolean result = false;
if (questionGroup != null) {
Short activityID = questionGroup.getActivityId();
try {
result = this.rolesPermissionService.hasUserAccessForActivity(activityID);
} catch (Exception ex) {
result = false;
}
}
return result;
}
Aggregations