Search in sources :

Example 1 with AccountOperation

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

the class ManageUserAccountServiceITest method manageUserAccountFailureTest.

@Test
public void manageUserAccountFailureTest() throws Exception {
    final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();
    final ManageUserAccountRequest serviceRequest = new ManageUserAccountRequest();
    serviceRequest.setSessionId(createSessionRequest.getSessionId());
    final ManageUserAccountResponse response = (ManageUserAccountResponse) applicationManager.service(serviceRequest);
    assertNotNull(EXPECT_A_RESULT, response);
    assertEquals(ServiceResult.FAILURE, response.getResult());
    assertEquals("accountOperation must not be null, userAcountId must not be null", response.getErrorMessage());
}
Also used : CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) ManageUserAccountRequest(com.hack23.cia.service.api.action.admin.ManageUserAccountRequest) ManageUserAccountResponse(com.hack23.cia.service.api.action.admin.ManageUserAccountResponse) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Example 2 with AccountOperation

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

the class AdminUserAccountPageModContentFactoryImpl 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_USERACCOUNT);
    final DataContainer<UserAccount, Long> dataContainer = getApplicationManager().getDataContainer(UserAccount.class);
    final List<UserAccount> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, UserAccount_.createdDate);
    createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
    getGridFactory().createBasicBeanItemGrid(content, UserAccount.class, pageOrderBy, USER_ACCOUNT, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
    if (pageId != null && !pageId.isEmpty()) {
        final UserAccount userAccount = dataContainer.load(Long.valueOf(pageId));
        if (userAccount != null) {
            getFormFactory().addFormPanelTextFields(content, userAccount, UserAccount.class, AS_LIST);
            final VerticalLayout overviewLayout = new VerticalLayout();
            overviewLayout.setSizeFull();
            content.addComponent(overviewLayout);
            content.setExpandRatio(overviewLayout, ContentRatio.LARGE);
            final ResponsiveRow grid = createGridLayout(overviewLayout);
            for (final AccountOperation accountOperation : ManageUserAccountRequest.AccountOperation.values()) {
                final ManageUserAccountRequest request = new ManageUserAccountRequest();
                request.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
                request.setAccountOperation(accountOperation);
                request.setUserAcountId(userAccount.getUserId());
                final Button accountOperationButton = new Button(MessageFormat.format(BUTTON_PATTERN, accountOperation), VaadinIcons.BULLSEYE);
                accountOperationButton.addClickListener(new ManageUserAccountClickListener(request));
                accountOperationButton.setId(MessageFormat.format(BUTTON_ID_PATTERN, ViewAction.START_AGENT_BUTTON, accountOperation));
                createRowItem(grid, accountOperationButton, "Will perform useraccount action");
            }
        }
    }
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_USERACCOUNT_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
    return content;
}
Also used : Button(com.vaadin.ui.Button) ResponsiveRow(com.jarektoro.responsivelayout.ResponsiveRow) ManageUserAccountClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.ManageUserAccountClickListener) ManageUserAccountRequest(com.hack23.cia.service.api.action.admin.ManageUserAccountRequest) VerticalLayout(com.vaadin.ui.VerticalLayout) AccountOperation(com.hack23.cia.service.api.action.admin.ManageUserAccountRequest.AccountOperation) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

ManageUserAccountRequest (com.hack23.cia.service.api.action.admin.ManageUserAccountRequest)2 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)1 AccountOperation (com.hack23.cia.service.api.action.admin.ManageUserAccountRequest.AccountOperation)1 ManageUserAccountResponse (com.hack23.cia.service.api.action.admin.ManageUserAccountResponse)1 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)1 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)1 ManageUserAccountClickListener (com.hack23.cia.web.impl.ui.application.views.pageclicklistener.ManageUserAccountClickListener)1 ResponsiveRow (com.jarektoro.responsivelayout.ResponsiveRow)1 Button (com.vaadin.ui.Button)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Test (org.junit.Test)1 Secured (org.springframework.security.access.annotation.Secured)1