Search in sources :

Example 31 with DataContainer

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

the class ManageUserAccountServiceITest method manageUserAccountSuccessUnLockTest.

@Test
public void manageUserAccountSuccessUnLockTest() 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.UNLOCK);
    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.UNLOCKED);
}
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)

Example 32 with DataContainer

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

the class MinistryDataSeriesFactoryImpl method createMinistryChartTimeSeriesCurrent.

@Override
public DataSeries createMinistryChartTimeSeriesCurrent() {
    DataSeries dataSeries = new DataSeries();
    final DataContainer<ViewRiksdagenMinistry, String> dataContainer = applicationManager.getDataContainer(ViewRiksdagenMinistry.class);
    for (final ViewRiksdagenMinistry data : dataContainer.getAll()) {
        if (data.isActive()) {
            dataSeries = dataSeries.newSeries().add(data.getNameId(), data.getCurrentMemberSize());
        }
    }
    return dataSeries;
}
Also used : ViewRiksdagenMinistry(com.hack23.cia.model.internal.application.data.ministry.impl.ViewRiksdagenMinistry) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries)

Example 33 with DataContainer

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

the class MinistryDataSeriesFactoryImpl method createMinistryChartTimeSeriesAll.

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

Example 34 with DataContainer

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

the class PartyDataSeriesFactoryImpl method createChartTimeSeriesCurrentGovernmentByParty.

@Override
public DataSeries createChartTimeSeriesCurrentGovernmentByParty() {
    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.getTotalActiveGovernment());
        }
    }
    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 35 with DataContainer

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

the class PartyDataSeriesFactoryImpl method createPartyChartTimeSeriesCurrent.

@Override
public DataSeries createPartyChartTimeSeriesCurrent() {
    DataSeries dataSeries = new DataSeries();
    final DataContainer<ViewRiksdagenPartySummary, String> dataContainer = applicationManager.getDataContainer(ViewRiksdagenPartySummary.class);
    for (final ViewRiksdagenPartySummary data : dataContainer.getAllOrderBy(ViewRiksdagenPartySummary_.currentAssignments)) {
        if (data != null && data.isActiveParliament()) {
            dataSeries = dataSeries.newSeries().add(getPartyName(data.getParty()), data.getTotalActiveParliament());
        }
    }
    return dataSeries;
}
Also used : ViewRiksdagenPartySummary(com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries)

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