use of org.springframework.transaction.annotation.Transactional in project head by mifos.
the class StandardApprovalService method create.
@Transactional(noRollbackFor = RESTCallInterruptException.class)
@Override
public void create(ApprovalMethod method) throws Exception {
if (!skipCreate) {
RESTApprovalEntity entity = new RESTApprovalEntity();
entity.setApprovalMethod(method);
entity.setState(ApprovalState.WAITING);
entity.setCreatedBy(getCurrentUserId());
entity.setCreatedOn(new DateTime());
approvalDao.create(entity);
throw new RESTCallInterruptException(entity.getId());
}
}
use of org.springframework.transaction.annotation.Transactional in project head by mifos.
the class StandardApprovalService method reject.
@Transactional
@Override
public void reject(Long id) {
RESTApprovalEntity entity = approvalDao.getDetails(id);
entity.setApprovedBy(getCurrentUserId());
entity.setApprovedOn(new DateTime());
entity.setState(ApprovalState.REJECTED);
approvalDao.update(entity);
}
use of org.springframework.transaction.annotation.Transactional in project head by mifos.
the class SectionQuestionDaoIntegrationTest method shouldRetrieveSectionQuestionByQuestionIdSectionId.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldRetrieveSectionQuestionByQuestionIdSectionId() {
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 sectionId = questionGroup.getSections().get(1).getId();
List<SectionQuestion> sectionQuestions = sectionQuestionDao.retrieveFromQuestionIdSectionId(sectionId, questionId);
assertThat(sectionQuestions, is(notNullValue()));
assertThat(sectionQuestions.size(), is(1));
assertThat(sectionQuestions.get(0).getQuestionText(), is(sectionDetail2.getQuestionDetail(1).getText()));
}
use of org.springframework.transaction.annotation.Transactional in project head by mifos.
the class QuestionnaireServiceIntegrationTest method shouldDefineSingleSelectQuestion.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldDefineSingleSelectQuestion() throws SystemException {
String questionTitle = TITLE + currentTimeMillis();
QuestionDetail questionDetail = defineQuestion(questionTitle, QuestionType.SINGLE_SELECT, asList("choice1", "choice2"));
assertNotNull(questionDetail);
Integer questionId = questionDetail.getId();
assertNotNull(questionId);
QuestionEntity questionEntity = questionDao.getDetails(questionId);
assertNotNull(questionEntity);
Assert.assertEquals(questionTitle, questionEntity.getQuestionText());
Assert.assertEquals(AnswerType.SINGLESELECT, questionEntity.getAnswerTypeAsEnum());
assertThat(questionEntity.getChoices(), new QuestionChoicesMatcher(asList(new QuestionChoiceEntity("choice1"), new QuestionChoiceEntity("choice2"))));
}
use of org.springframework.transaction.annotation.Transactional in project head by mifos.
the class QuestionnaireServiceIntegrationTest method shouldSaveQuestionGroupFromDto.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldSaveQuestionGroupFromDto() {
String ques1Title = "Ques1" + currentTimeMillis();
String ques2Title = "Ques2" + currentTimeMillis();
String qgTitle = "QG1" + currentTimeMillis();
createSingleSelectQuestion(ques2Title);
QuestionDto question1 = new QuestionDtoBuilder().withText(ques1Title).withMandatory(true).withType(QuestionType.FREETEXT).withOrder(1).build();
ChoiceDto choice1 = new ChoiceDetailBuilder().withValue("Ch1").withOrder(1).build();
ChoiceDto choice2 = new ChoiceDetailBuilder().withValue("Ch2").withOrder(2).build();
ChoiceDto choice3 = new ChoiceDetailBuilder().withValue("Ch3").withOrder(3).build();
QuestionDto question2 = new QuestionDtoBuilder().withText(ques2Title).withType(QuestionType.SINGLE_SELECT).addChoices(choice1, choice2, choice3).withOrder(2).build();
SectionDto section1 = new SectionDtoBuilder().withName("Sec1").withOrder(1).addQuestions(question1, question2).build();
QuestionGroupDto questionGroupDto = new QuestionGroupDtoBuilder().withTitle(qgTitle).withEventSource("Create", "Client").addSections(section1).build();
Integer questionGroupId = questionnaireService.defineQuestionGroup(questionGroupDto);
assertQuestionGroup(questionGroupDao.getDetails(questionGroupId), qgTitle, ques1Title, ques2Title);
}
Aggregations