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;
}
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;
}
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;
}
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());
}
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());
}
Aggregations