Search in sources :

Example 1 with UpdateApplicationConfigurationRequest

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

the class AdminApplicationConfigurationPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout content = createPanelContent();
    final String pageId = getPageId(parameters);
    final int pageNr = getPageNr(parameters);
    getMenuItemFactory().createMainPageMenuBar(menuBar);
    LabelFactory.createHeader2Label(content, ADMIN_APPLICATION_CONFIGURATION);
    final DataContainer<ApplicationConfiguration, Long> dataContainer = getApplicationManager().getDataContainer(ApplicationConfiguration.class);
    final List<ApplicationConfiguration> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, ApplicationConfiguration_.configurationGroup);
    createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
    getGridFactory().createBasicBeanItemGrid(content, ApplicationConfiguration.class, pageOrderBy, APPLICATION_CONFIGURATION, COLUMN_ORDER, HIDE_COLUMNS, new PageItemPropertyClickListener(AdminViews.ADMIN_APPLICATIONS_CONFIGURATION_VIEW_NAME, "hjid"), null, null);
    if (pageId != null && !pageId.isEmpty()) {
        final ApplicationConfiguration applicationConfiguration = dataContainer.load(Long.valueOf(pageId));
        if (applicationConfiguration != null) {
            final VerticalLayout leftLayout = new VerticalLayout();
            leftLayout.setSizeFull();
            final VerticalLayout rightLayout = new VerticalLayout();
            rightLayout.setSizeFull();
            final HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setWidth(ContentSize.FULL_SIZE);
            content.addComponent(horizontalLayout);
            horizontalLayout.addComponent(leftLayout);
            horizontalLayout.addComponent(rightLayout);
            getFormFactory().addFormPanelTextFields(leftLayout, applicationConfiguration, ApplicationConfiguration.class, AS_LIST);
            final UpdateApplicationConfigurationRequest request = new UpdateApplicationConfigurationRequest();
            request.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
            request.setApplicationConfigurationId(applicationConfiguration.getHjid());
            request.setConfigTitle(applicationConfiguration.getConfigTitle());
            request.setConfigDescription(applicationConfiguration.getConfigDescription());
            request.setComponentTitle(applicationConfiguration.getConfigTitle());
            request.setComponentDescription(applicationConfiguration.getComponentDescription());
            request.setPropertyValue(applicationConfiguration.getPropertyValue());
            final ClickListener buttonListener = new UpdateApplicationConfigurationClickListener(request);
            final Panel updateFormPanel = new Panel();
            updateFormPanel.setSizeFull();
            rightLayout.addComponent(updateFormPanel);
            final FormLayout updateFormContent = new FormLayout();
            updateFormPanel.setContent(updateFormContent);
            getFormFactory().addRequestInputFormFields(updateFormContent, request, UpdateApplicationConfigurationRequest.class, AS_LIST2, UPDATE_CONFIGURATION, buttonListener);
        }
    }
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_APPLICATION_CONFIGURATION_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
    return content;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) UpdateApplicationConfigurationClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.UpdateApplicationConfigurationClickListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Panel(com.vaadin.ui.Panel) UpdateApplicationConfigurationRequest(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest) PageItemPropertyClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener) VerticalLayout(com.vaadin.ui.VerticalLayout) ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration) ClickListener(com.vaadin.ui.Button.ClickListener) PageItemPropertyClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener) UpdateApplicationConfigurationClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.UpdateApplicationConfigurationClickListener) Secured(org.springframework.security.access.annotation.Secured)

Example 2 with UpdateApplicationConfigurationRequest

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

the class UpdateApplicationConfigurationService method createApplicationEventForService.

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

Example 3 with UpdateApplicationConfigurationRequest

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

the class UpdateApplicationConfigurationService method processService.

@Override
@Secured({ "ROLE_ADMIN" })
public UpdateApplicationConfigurationResponse processService(final UpdateApplicationConfigurationRequest serviceRequest) {
    final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
    final UpdateApplicationConfigurationResponse inputValidation = inputValidation(serviceRequest);
    if (inputValidation != null) {
        return inputValidation;
    }
    final UserAccount userAccount = getUserAccountFromSecurityContext();
    if (userAccount != null) {
        eventRequest.setUserId(userAccount.getUserId());
    }
    UpdateApplicationConfigurationResponse response;
    final ApplicationConfiguration applicationConfiguration = applicationConfigurationDAO.load(serviceRequest.getApplicationConfigurationId());
    if (applicationConfiguration != null) {
        eventRequest.setElementId(serviceRequest.getApplicationConfigurationId().toString());
        applicationConfiguration.setConfigTitle(serviceRequest.getConfigTitle());
        applicationConfiguration.setConfigDescription(serviceRequest.getConfigDescription());
        applicationConfiguration.setComponentTitle(serviceRequest.getComponentTitle());
        applicationConfiguration.setComponentDescription(serviceRequest.getComponentDescription());
        applicationConfiguration.setPropertyValue(serviceRequest.getPropertyValue());
        applicationConfigurationDAO.persist(applicationConfiguration);
        response = new UpdateApplicationConfigurationResponse(ServiceResult.SUCCESS);
    } else {
        response = new UpdateApplicationConfigurationResponse(ServiceResult.FAILURE);
    }
    eventRequest.setApplicationMessage(response.getResult().toString());
    createApplicationEventService.processService(eventRequest);
    return response;
}
Also used : UpdateApplicationConfigurationResponse(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration) Secured(org.springframework.security.access.annotation.Secured)

Example 4 with UpdateApplicationConfigurationRequest

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

the class AbstractServiceFunctionalIntegrationTest method updateApplicationConfiguration.

/**
 * Update application configuration.
 *
 * @param createTestApplicationSession
 *            the create test application session
 * @param applicationConfiguration
 *            the application configuration
 * @param propertyValue
 *            the property value
 */
private void updateApplicationConfiguration(final CreateApplicationSessionRequest createTestApplicationSession, final ApplicationConfiguration applicationConfiguration, final String propertyValue) {
    final UpdateApplicationConfigurationRequest serviceRequest = new UpdateApplicationConfigurationRequest();
    serviceRequest.setApplicationConfigurationId(applicationConfiguration.getHjid());
    serviceRequest.setSessionId(createTestApplicationSession.getSessionId());
    serviceRequest.setComponentDescription(applicationConfiguration.getComponentDescription());
    serviceRequest.setConfigDescription(applicationConfiguration.getConfigDescription());
    serviceRequest.setConfigTitle(applicationConfiguration.getConfigTitle());
    serviceRequest.setComponentTitle(applicationConfiguration.getComponentTitle());
    serviceRequest.setPropertyValue(propertyValue);
    final UpdateApplicationConfigurationResponse response = (UpdateApplicationConfigurationResponse) applicationManager.service(serviceRequest);
    assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
}
Also used : UpdateApplicationConfigurationRequest(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest) UpdateApplicationConfigurationResponse(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse)

Example 5 with UpdateApplicationConfigurationRequest

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

the class UpdateApplicationConfigurationServiceITest method successTest.

/**
 * Success test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void successTest() throws Exception {
    setAuthenticatedAdminuser();
    final CreateApplicationSessionRequest createTestApplicationSession = createTestApplicationSession();
    final String randomUUID = UUID.randomUUID().toString();
    final ApplicationConfiguration applicationConfigurationToUpdate = applicationConfigurationService.checkValueOrLoadDefault("UpdateApplicationRequestTest property", "UpdateApplicationRequestTest should be set to true/false", ConfigurationGroup.AUTHORIZATION, UpdateApplicationConfigurationServiceITest.class.getSimpleName(), "UpdateApplicationConfigurationService ITest", "FunctionalIntegrationTest", "UpdateApplicationRequestTest." + randomUUID, "true");
    final UpdateApplicationConfigurationRequest serviceRequest = new UpdateApplicationConfigurationRequest();
    serviceRequest.setApplicationConfigurationId(applicationConfigurationToUpdate.getHjid());
    serviceRequest.setSessionId(createTestApplicationSession.getSessionId());
    serviceRequest.setComponentDescription("componentDescription");
    serviceRequest.setConfigDescription("configDescription");
    serviceRequest.setConfigTitle("configTitle");
    serviceRequest.setComponentTitle("componentTitle");
    serviceRequest.setPropertyValue("false");
    final UpdateApplicationConfigurationResponse response = (UpdateApplicationConfigurationResponse) applicationManager.service(serviceRequest);
    assertNotNull(EXPECT_A_RESULT, response);
    assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
    final ApplicationConfiguration applicationConfigurationUpdated = applicationConfigurationService.checkValueOrLoadDefault("UpdateApplicationRequestTest property", "UpdateApplicationRequestTest should be set to true/false", ConfigurationGroup.AUTHORIZATION, UpdateApplicationConfigurationServiceITest.class.getSimpleName(), "UpdateApplicationConfigurationService ITest", "FunctionalIntegrationTest", "UpdateApplicationRequestTest." + randomUUID, "true");
    assertEquals("false", applicationConfigurationUpdated.getPropertyValue());
    assertEquals("configTitle", applicationConfigurationUpdated.getConfigTitle());
    assertEquals("configDescription", applicationConfigurationUpdated.getConfigDescription());
    assertEquals("componentTitle", applicationConfigurationUpdated.getComponentTitle());
    assertEquals("componentDescription", applicationConfigurationUpdated.getComponentDescription());
}
Also used : UpdateApplicationConfigurationRequest(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest) CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) UpdateApplicationConfigurationResponse(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse) ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Aggregations

UpdateApplicationConfigurationRequest (com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest)4 ApplicationConfiguration (com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)3 UpdateApplicationConfigurationResponse (com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse)3 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)2 Secured (org.springframework.security.access.annotation.Secured)2 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)1 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)1 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)1 PageItemPropertyClickListener (com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener)1 UpdateApplicationConfigurationClickListener (com.hack23.cia.web.impl.ui.application.views.pageclicklistener.UpdateApplicationConfigurationClickListener)1 ClickListener (com.vaadin.ui.Button.ClickListener)1 FormLayout (com.vaadin.ui.FormLayout)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Panel (com.vaadin.ui.Panel)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Test (org.junit.Test)1