Search in sources :

Example 51 with DataContainer

use of com.hack23.cia.service.api.DataContainer in project cia by Hack23.

the class PartyDataSeriesFactoryImpl method createChartTimeSeriesCurrentCommitteeByParty.

@Override
public DataSeries createChartTimeSeriesCurrentCommitteeByParty() {
    DataSeries dataSeries = new DataSeries();
    final DataContainer<ViewRiksdagenParty, String> dataContainer = applicationManager.getDataContainer(ViewRiksdagenParty.class);
    final DataContainer<ViewRiksdagenPartySummary, String> partySummarydataContainer = applicationManager.getDataContainer(ViewRiksdagenPartySummary.class);
    partySummarydataContainer.getAll();
    for (final ViewRiksdagenParty data : dataContainer.getAll()) {
        final ViewRiksdagenPartySummary summary = partySummarydataContainer.load(data.getPartyId());
        if (summary != null && summary.isActive()) {
            dataSeries = dataSeries.newSeries().add(data.getPartyName(), summary.getTotalActiveCommittee());
        }
    }
    return dataSeries;
}
Also used : ViewRiksdagenParty(com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty) ViewRiksdagenPartySummary(com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries)

Example 52 with DataContainer

use of com.hack23.cia.service.api.DataContainer in project cia by Hack23.

the class PartyDataSeriesFactoryImpl method createPartyChartTimeSeriesAll.

@Override
public DataSeries createPartyChartTimeSeriesAll() {
    DataSeries dataSeries = new DataSeries();
    final DataContainer<ViewRiksdagenParty, String> dataContainer = applicationManager.getDataContainer(ViewRiksdagenParty.class);
    for (final ViewRiksdagenParty data : dataContainer.getAll()) {
        dataSeries = dataSeries.newSeries().add(data.getPartyName(), data.getHeadCount());
    }
    return dataSeries;
}
Also used : ViewRiksdagenParty(com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries)

Example 53 with DataContainer

use of com.hack23.cia.service.api.DataContainer 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)

Example 54 with DataContainer

use of com.hack23.cia.service.api.DataContainer in project cia by Hack23.

the class CommitteeDataSeriesFactoryImpl method createCommitteeChartTimeSeriesAll.

@Override
public DataSeries createCommitteeChartTimeSeriesAll() {
    DataSeries dataSeries = new DataSeries();
    final DataContainer<ViewRiksdagenCommittee, String> dataContainer = applicationManager.getDataContainer(ViewRiksdagenCommittee.class);
    for (final ViewRiksdagenCommittee data : dataContainer.getAll()) {
        dataSeries = dataSeries.newSeries().add(data.getEmbeddedId().getDetail(), data.getTotalAssignments());
    }
    return dataSeries;
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) ViewRiksdagenCommittee(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee)

Example 55 with DataContainer

use of com.hack23.cia.service.api.DataContainer in project cia by Hack23.

the class ManageUserAccountServiceITest method manageUserAccountSuccessLockTest.

@Test
public void manageUserAccountSuccessLockTest() throws Exception {
    setAuthenticatedAnonymousUser();
    final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();
    final RegisterUserRequest createAccountRequest = new RegisterUserRequest();
    createAccountRequest.setCountry("Sweden");
    createAccountRequest.setUsername(UUID.randomUUID().toString());
    createAccountRequest.setEmail(createAccountRequest.getUsername() + "@email.com");
    createAccountRequest.setUserpassword("Userpassword1!");
    createAccountRequest.setUserType(UserType.PRIVATE);
    createAccountRequest.setSessionId(createSessionRequest.getSessionId());
    final RegisterUserResponse response = (RegisterUserResponse) applicationManager.service(createAccountRequest);
    assertNotNull("Expect a result", response);
    assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
    setAuthenticatedAdminuser();
    final DataContainer<UserAccount, Long> userContainer = applicationManager.getDataContainer(UserAccount.class);
    final List<UserAccount> firstCreatedUsed = userContainer.getAllBy(UserAccount_.username, createAccountRequest.getUsername());
    assertEquals(1, firstCreatedUsed.size());
    final ManageUserAccountRequest deleteAccountRequest = new ManageUserAccountRequest();
    deleteAccountRequest.setSessionId(createSessionRequest.getSessionId());
    deleteAccountRequest.setAccountOperation(AccountOperation.LOCK);
    deleteAccountRequest.setUserAcountId(firstCreatedUsed.get(0).getUserId());
    final ManageUserAccountResponse deleteAccountResponse = (ManageUserAccountResponse) applicationManager.service(deleteAccountRequest);
    assertNotNull(EXPECT_A_RESULT, deleteAccountResponse);
    assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, deleteAccountResponse.getResult());
    final List<UserAccount> allByAfterDelete = userContainer.getAllBy(UserAccount_.username, createAccountRequest.getUsername());
    assertEquals(1, allByAfterDelete.size());
    assertEquals(allByAfterDelete.get(0).getUserLockStatus(), UserLockStatus.LOCKED);
}
Also used : CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) RegisterUserRequest(com.hack23.cia.service.api.action.application.RegisterUserRequest) ManageUserAccountRequest(com.hack23.cia.service.api.action.admin.ManageUserAccountRequest) RegisterUserResponse(com.hack23.cia.service.api.action.application.RegisterUserResponse) ManageUserAccountResponse(com.hack23.cia.service.api.action.admin.ManageUserAccountResponse) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Aggregations

VerticalLayout (com.vaadin.ui.VerticalLayout)75 Secured (org.springframework.security.access.annotation.Secured)75 ViewRiksdagenParty (com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty)19 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)17 ViewRiksdagenCommittee (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee)15 ViewRiksdagenPolitician (com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician)13 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)13 RegisterUserRequest (com.hack23.cia.service.api.action.application.RegisterUserRequest)13 RegisterUserResponse (com.hack23.cia.service.api.action.application.RegisterUserResponse)13 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)13 Test (org.junit.Test)13 ViewRiksdagenMinistry (com.hack23.cia.model.internal.application.data.ministry.impl.ViewRiksdagenMinistry)11 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)11 DocumentElement (com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement)10 PersonData (com.hack23.cia.model.external.riksdagen.person.impl.PersonData)10 PerfTest (org.databene.contiperf.PerfTest)10 DocumentStatusContainer (com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer)8 ViewRiksdagenPartySummary (com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary)7 LoginRequest (com.hack23.cia.service.api.action.application.LoginRequest)7 LoginResponse (com.hack23.cia.service.api.action.application.LoginResponse)7