Search in sources :

Example 1 with RESTApprovalEntity

use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.

the class ApprovalController method details.

@RequestMapping("restApproval/id-{id}/details.ftl")
public ModelAndView details(@PathVariable Long id) {
    ModelAndView mav = new ModelAndView("approval/details");
    mav.addObject("waitingForApprovalList", approvalService.getAllWaiting());
    RESTApprovalEntity approval = approvalService.getDetails(id);
    mav.addObject("approval", approval);
    PersonnelInformationDto p = personnelServiceFacade.getPersonnelInformationDto(approval.getCreatedBy().longValue(), null);
    mav.addObject("createdBy", p.getDisplayName());
    if (!approval.getState().equals(ApprovalState.WAITING)) {
        p = personnelServiceFacade.getPersonnelInformationDto(approval.getApprovedBy().longValue(), null);
        mav.addObject("approvedBy", p.getDisplayName());
    }
    return mav;
}
Also used : PersonnelInformationDto(org.mifos.dto.screen.PersonnelInformationDto) RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with RESTApprovalEntity

use of org.mifos.rest.approval.domain.RESTApprovalEntity 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());
    }
}
Also used : RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) DateTime(org.joda.time.DateTime) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with RESTApprovalEntity

use of org.mifos.rest.approval.domain.RESTApprovalEntity 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);
}
Also used : RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) DateTime(org.joda.time.DateTime) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with RESTApprovalEntity

use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.

the class ApprovalServiceTest method testCreate.

@Test
public void testCreate() throws Exception {
    createApprovalMethod();
    RESTApprovalEntity rae = approvalService.getDetails(1L);
    assertNotNull(rae);
    assertEquals(StubRESTController.class.getSimpleName().replace("RESTController", ""), rae.getType());
    assertNotNull(rae.getCreatedOn());
    assertEquals(getCurrentUserId(), rae.getCreatedBy());
    assertNull(rae.getApprovedOn());
    assertNull(rae.getApprovedBy());
    assertEquals(ApprovalState.WAITING, rae.getState());
}
Also used : RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) Test(org.junit.Test)

Example 5 with RESTApprovalEntity

use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.

the class ApprovalServiceTest method testApproveState.

@Test
public void testApproveState() throws Exception {
    createApprovalMethod();
    RESTApprovalEntity rae = approvalService.getAllWaiting().get(0);
    assertNotNull(rae);
    assertEquals(ApprovalState.WAITING, rae.getState());
    approvalService.reject(rae.getId());
    rae = approvalService.getAllNotWaiting().get(0);
    assertEquals(ApprovalState.REJECTED, rae.getState());
    assertNotNull(rae.getApprovedOn());
    assertEquals(getCurrentUserId(), rae.getApprovedBy());
    approvalService.approve(rae.getId());
    rae = approvalService.getAllNotWaiting().get(0);
    assertEquals(ApprovalState.APPROVED, rae.getState());
}
Also used : RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) Test(org.junit.Test)

Aggregations

RESTApprovalEntity (org.mifos.rest.approval.domain.RESTApprovalEntity)9 Test (org.junit.Test)4 Transactional (org.springframework.transaction.annotation.Transactional)4 DateTime (org.joda.time.DateTime)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Ignore (org.junit.Ignore)1 PersonnelInformationDto (org.mifos.dto.screen.PersonnelInformationDto)1 Transactional (org.mifos.framework.hibernate.helper.Transactional)1 ApprovalMethod (org.mifos.rest.approval.domain.ApprovalMethod)1 RESTCallInterruptException (org.mifos.rest.approval.service.RESTCallInterruptException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1