Search in sources :

Example 6 with ApplicationSession

use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.

the class ApplicationSessionDAOITest method getPageTest.

/**
 * Gets the page test.
 *
 * @return the page test
 * @throws Exception
 *             the exception
 */
@Test
public void getPageTest() throws Exception {
    final ApplicationSession applicationSession = createApplicationSession();
    final int resultPerPage = 1;
    final List<ApplicationSession> pageList = applicationSessionDAO.getPage(1, resultPerPage);
    assertNotNull(pageList);
    assertFalse(pageList.isEmpty());
    assertEquals(resultPerPage, pageList.size());
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) Test(org.junit.Test)

Example 7 with ApplicationSession

use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.

the class ApplicationSessionDAOITest method deleteTest.

/**
 * Delete test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void deleteTest() throws Exception {
    final ApplicationSession applicationSession = createApplicationSession();
    final List<ApplicationSession> all = applicationSessionDAO.getAll();
    final ApplicationSession firstValue = all.iterator().next();
    final Long hjid = firstValue.getHjid();
    applicationSessionDAO.delete(firstValue);
    final ApplicationSession loadDeleted = applicationSessionDAO.load(hjid);
    assertNull(loadDeleted);
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) Test(org.junit.Test)

Example 8 with ApplicationSession

use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.

the class CreateApplicationEventService method processService.

@Override
public CreateApplicationEventResponse processService(final CreateApplicationEventRequest serviceRequest) {
    final CreateApplicationEventResponse inputValidation = inputValidation(serviceRequest);
    if (inputValidation != null) {
        return inputValidation;
    }
    final ApplicationSession applicationSession = applicationSessionDAO.findFirstByProperty(ApplicationSession_.sessionId, serviceRequest.getSessionId());
    if (applicationSession != null) {
        final ApplicationActionEvent applicationActionEvent = new ApplicationActionEvent();
        applicationActionEvent.setEventGroup(serviceRequest.getEventGroup());
        applicationActionEvent.setCreatedDate(new Date());
        applicationActionEvent.setSessionId(serviceRequest.getSessionId());
        applicationActionEvent.setPage(serviceRequest.getPage());
        applicationActionEvent.setPageMode(serviceRequest.getPageMode());
        applicationActionEvent.setElementId(serviceRequest.getElementId());
        applicationActionEvent.setApplicationOperation(serviceRequest.getApplicationOperation());
        applicationActionEvent.setActionName(serviceRequest.getActionName());
        applicationActionEvent.setUserId(serviceRequest.getUserId());
        if (serviceRequest.getUserId() != null && ApplicationSessionType.ANONYMOUS == applicationSession.getSessionType()) {
            applicationSession.setSessionType(ApplicationSessionType.REGISTERED_USER);
            applicationSession.setUserId(serviceRequest.getUserId());
        }
        applicationActionEvent.setApplicationMessage(serviceRequest.getApplicationMessage());
        applicationActionEvent.setErrorMessage(serviceRequest.getErrorMessage());
        applicationSession.getEvents().add(applicationActionEvent);
        applicationSessionDAO.persist(applicationSession);
        return new CreateApplicationEventResponse(ServiceResult.SUCCESS);
    } else {
        return new CreateApplicationEventResponse(ServiceResult.FAILURE);
    }
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) ApplicationActionEvent(com.hack23.cia.model.internal.application.system.impl.ApplicationActionEvent) CreateApplicationEventResponse(com.hack23.cia.service.api.action.application.CreateApplicationEventResponse) Date(java.util.Date)

Example 9 with ApplicationSession

use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.

the class CreateApplicationSessionService method processService.

@Secured({ "ROLE_ANONYMOUS" })
@Override
public CreateApplicationSessionResponse processService(final CreateApplicationSessionRequest serviceRequest) {
    final ApplicationSession applicationSession = new ApplicationSession();
    applicationSession.setCreatedDate(new Date());
    applicationSession.setSessionId(serviceRequest.getSessionId());
    applicationSession.setIpInformation(serviceRequest.getIpInformation());
    applicationSession.setLocale(serviceRequest.getLocale());
    applicationSession.setTimeZone(serviceRequest.getTimeZone());
    applicationSession.setScreenSize(serviceRequest.getScreenSize());
    applicationSession.setOperatingSystem(serviceRequest.getOperatingSystem());
    applicationSession.setUserAgentInformation(serviceRequest.getUserAgentInformation());
    applicationSession.setSessionType(serviceRequest.getSessionType());
    applicationSession.setEvents(new ArrayList<>());
    applicationSession.setSessionType(ApplicationSessionType.ANONYMOUS);
    applicationSessionDAO.persist(applicationSession);
    LOGGER.info("Create application session:{}", applicationSession);
    return new CreateApplicationSessionResponse(ServiceResult.SUCCESS);
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) CreateApplicationSessionResponse(com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse) Date(java.util.Date) Secured(org.springframework.security.access.annotation.Secured)

Example 10 with ApplicationSession

use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.

the class DestroyApplicationSessionService method processService.

@Override
@Secured({ "ROLE_ANONYMOUS" })
public DestroyApplicationSessionResponse processService(final DestroyApplicationSessionRequest serviceRequest) {
    final DestroyApplicationSessionResponse inputValidation = inputValidation(serviceRequest);
    if (inputValidation != null) {
        return inputValidation;
    }
    final ApplicationSession applicationSession = applicationSessionDAO.findFirstByProperty(ApplicationSession_.sessionId, serviceRequest.getSessionId());
    if (applicationSession != null) {
        LOGGER.info("Destroy Application session: {}", applicationSession.getSessionId());
        applicationSession.setDestroyedDate(new Date());
        applicationSessionDAO.persist(applicationSession);
        return new DestroyApplicationSessionResponse(ServiceResult.SUCCESS);
    } else {
        LOGGER.warn("Failed to destroy Application session, no session found for id: {}", serviceRequest.getSessionId());
        return new DestroyApplicationSessionResponse(ServiceResult.FAILURE);
    }
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) DestroyApplicationSessionResponse(com.hack23.cia.service.api.action.application.DestroyApplicationSessionResponse) Date(java.util.Date) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

ApplicationSession (com.hack23.cia.model.internal.application.system.impl.ApplicationSession)21 Test (org.junit.Test)14 Date (java.util.Date)5 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)4 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)4 Secured (org.springframework.security.access.annotation.Secured)4 ApplicationActionEvent (com.hack23.cia.model.internal.application.system.impl.ApplicationActionEvent)3 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)2 CreateApplicationEventResponse (com.hack23.cia.service.api.action.application.CreateApplicationEventResponse)2 CreateApplicationSessionResponse (com.hack23.cia.service.api.action.application.CreateApplicationSessionResponse)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 PerfTest (org.databene.contiperf.PerfTest)2 Required (org.databene.contiperf.Required)2 ApplicationConfiguration (com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)1 ManageUserAccountRequest (com.hack23.cia.service.api.action.admin.ManageUserAccountRequest)1 ManageUserAccountResponse (com.hack23.cia.service.api.action.admin.ManageUserAccountResponse)1 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)1 DestroyApplicationSessionRequest (com.hack23.cia.service.api.action.application.DestroyApplicationSessionRequest)1 DestroyApplicationSessionResponse (com.hack23.cia.service.api.action.application.DestroyApplicationSessionResponse)1 RegisterUserRequest (com.hack23.cia.service.api.action.application.RegisterUserRequest)1