Search in sources :

Example 1 with RemoveDataRequest

use of com.hack23.cia.service.api.action.admin.RemoveDataRequest in project cia by Hack23.

the class RemoveDataServiceITest method Test.

/**
 * Test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void Test() throws Exception {
    final RemoveDataManager removeDataManager = Mockito.mock(RemoveDataManager.class);
    ReflectionTestUtils.setField(removeDataService, "removeDataManager", removeDataManager);
    setAuthenticatedAdminuser();
    final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();
    for (final DataType dataType : RemoveDataRequest.DataType.values()) {
        final RemoveDataRequest serviceRequest = new RemoveDataRequest();
        serviceRequest.setSessionId(createSessionRequest.getSessionId());
        serviceRequest.setDataType(dataType);
        final RemoveDataResponse response = (RemoveDataResponse) applicationManager.service(serviceRequest);
        assertNotNull(EXPECT_A_RESULT, response);
        assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
    }
    Mockito.verify(removeDataManager).removeApplicationHistory();
    Mockito.verify(removeDataManager).removeCommitteeProposals();
    Mockito.verify(removeDataManager).removeDocuments();
    Mockito.verify(removeDataManager).removeDocumentStatus();
    Mockito.verify(removeDataManager).removePersonData();
}
Also used : CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) RemoveDataRequest(com.hack23.cia.service.api.action.admin.RemoveDataRequest) RemoveDataResponse(com.hack23.cia.service.api.action.admin.RemoveDataResponse) DataType(com.hack23.cia.service.api.action.admin.RemoveDataRequest.DataType) RemoveDataManager(com.hack23.cia.service.data.api.RemoveDataManager) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Example 2 with RemoveDataRequest

use of com.hack23.cia.service.api.action.admin.RemoveDataRequest in project cia by Hack23.

the class RemoveDataService method processService.

@Override
@Secured({ "ROLE_ADMIN" })
public RemoveDataResponse processService(final RemoveDataRequest serviceRequest) {
    final RemoveDataResponse inputValidation = inputValidation(serviceRequest);
    if (inputValidation != null) {
        return inputValidation;
    }
    final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
    final UserAccount userAccount = getUserAccountFromSecurityContext();
    if (userAccount != null) {
        eventRequest.setUserId(userAccount.getUserId());
    }
    final RemoveDataResponse response = new RemoveDataResponse(ServiceResult.SUCCESS);
    switch(serviceRequest.getDataType()) {
        case POLITICIAN:
            removeDataManager.removePersonData();
            break;
        case DOCUMENTS:
            removeDataManager.removeDocuments();
            removeDataManager.removeCommitteeProposals();
            removeDataManager.removeDocumentStatus();
            break;
        case APPLICATION_HISTORY:
            removeDataManager.removeApplicationHistory();
            break;
    }
    eventRequest.setApplicationMessage(response.getResult().toString());
    createApplicationEventService.processService(eventRequest);
    return response;
}
Also used : RemoveDataResponse(com.hack23.cia.service.api.action.admin.RemoveDataResponse) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Secured(org.springframework.security.access.annotation.Secured)

Example 3 with RemoveDataRequest

use of com.hack23.cia.service.api.action.admin.RemoveDataRequest in project cia by Hack23.

the class RemoveDataClickListener method buttonClick.

@Override
public void buttonClick(final ClickEvent event) {
    final RemoveDataRequest serviceRequest = new RemoveDataRequest();
    serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
    serviceRequest.setDataType(dataType);
    ApplicationMangerAccess.getApplicationManager().asyncService(serviceRequest);
    Notification.show(DATA_REMOVED);
}
Also used : RemoveDataRequest(com.hack23.cia.service.api.action.admin.RemoveDataRequest)

Example 4 with RemoveDataRequest

use of com.hack23.cia.service.api.action.admin.RemoveDataRequest in project cia by Hack23.

the class RemoveDataService method createApplicationEventForService.

@Override
protected CreateApplicationEventRequest createApplicationEventForService(final RemoveDataRequest serviceRequest) {
    final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
    eventRequest.setEventGroup(ApplicationEventGroup.ADMIN);
    eventRequest.setApplicationOperation(ApplicationOperationType.DELETE);
    eventRequest.setActionName(RemoveDataRequest.class.getSimpleName() + ":" + serviceRequest.getDataType());
    eventRequest.setSessionId(serviceRequest.getSessionId());
    return eventRequest;
}
Also used : RemoveDataRequest(com.hack23.cia.service.api.action.admin.RemoveDataRequest) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)

Aggregations

RemoveDataRequest (com.hack23.cia.service.api.action.admin.RemoveDataRequest)3 RemoveDataResponse (com.hack23.cia.service.api.action.admin.RemoveDataResponse)2 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)2 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)1 DataType (com.hack23.cia.service.api.action.admin.RemoveDataRequest.DataType)1 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)1 RemoveDataManager (com.hack23.cia.service.data.api.RemoveDataManager)1 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)1 Test (org.junit.Test)1 Secured (org.springframework.security.access.annotation.Secured)1