Search in sources :

Example 1 with DataContainer

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

the class DecisionChartDataManagerImpl method getCommitteeDecisionTypeMap.

/**
 * Gets the committee decision type map.
 *
 * @return the committee decision type map
 */
private Map<String, List<ViewRiksdagenCommitteeDecisionTypeDailySummary>> getCommitteeDecisionTypeMap() {
    final DataContainer<ViewRiksdagenCommitteeDecisionTypeDailySummary, RiksdagenCommitteeDecisionTypeSummaryEmbeddedId> committeeBallotDecisionPartyDataContainer = getApplicationManager().getDataContainer(ViewRiksdagenCommitteeDecisionTypeDailySummary.class);
    final Date now = new Date();
    final Date notBefore = new GregorianCalendar(2000, Calendar.JANUARY, 1).getTime();
    return committeeBallotDecisionPartyDataContainer.getAll().parallelStream().filter(t -> t != null && !t.getEmbeddedId().getDecisionDate().after(now) && !notBefore.after(t.getEmbeddedId().getDecisionDate())).collect(Collectors.groupingBy(t -> t.getEmbeddedId().getDecisionType()));
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) SimpleDateFormat(java.text.SimpleDateFormat) Collectors(java.util.stream.Collectors) DecisionChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.DecisionChartDataManager) ViewRiksdagenCommitteeDecisionTypeOrgDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary) Objects(java.util.Objects) RiksdagenCommitteeDecisionTypeOrgSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenCommitteeDecisionTypeOrgSummaryEmbeddedId) DCharts(org.dussan.vaadin.dcharts.DCharts) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Calendar(java.util.Calendar) ViewRiksdagenCommitteeDecisionTypeDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary) RiksdagenCommitteeDecisionTypeSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenCommitteeDecisionTypeSummaryEmbeddedId) Locale(java.util.Locale) Service(org.springframework.stereotype.Service) Map(java.util.Map) Series(org.dussan.vaadin.dcharts.options.Series) Entry(java.util.Map.Entry) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) RiksdagenCommitteeDecisionTypeSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenCommitteeDecisionTypeSummaryEmbeddedId) ViewRiksdagenCommitteeDecisionTypeDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date)

Example 2 with DataContainer

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

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

the class AdminApplicationEventsPageModContentFactoryImpl 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_ACTION_EVENT);
    final DataContainer<ApplicationActionEvent, Long> dataContainer = getApplicationManager().getDataContainer(ApplicationActionEvent.class);
    final List<ApplicationActionEvent> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, ApplicationActionEvent_.createdDate);
    createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
    getGridFactory().createBasicBeanItemGrid(content, ApplicationActionEvent.class, pageOrderBy, APPLICATION_ACTION_EVENT, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
    if (pageId != null && !pageId.isEmpty()) {
        final ApplicationActionEvent applicationActionEvent = dataContainer.load(Long.valueOf(pageId));
        if (applicationActionEvent != null) {
            getFormFactory().addFormPanelTextFields(content, applicationActionEvent, ApplicationActionEvent.class, AS_LIST);
        }
    }
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_APPLICATION_EVENTS_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
    return content;
}
Also used : ApplicationActionEvent(com.hack23.cia.model.internal.application.system.impl.ApplicationActionEvent) VerticalLayout(com.vaadin.ui.VerticalLayout) Secured(org.springframework.security.access.annotation.Secured)

Example 4 with DataContainer

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

the class AdminApplicationSessionPageModContentFactoryImpl 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_SESSION);
    final DataContainer<ApplicationSession, Long> dataContainer = getApplicationManager().getDataContainer(ApplicationSession.class);
    final List<ApplicationSession> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, ApplicationSession_.createdDate);
    createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
    getGridFactory().createBasicBeanItemGrid(content, ApplicationSession.class, pageOrderBy, APPLICATION_SESSION, COLUMN_ORDER, HIDE_COLUMNS, new PageItemPropertyClickListener(AdminViews.ADMIN_APPLICATIONS_SESSION_VIEW_NAME, "hjid"), null, new ListPropertyConverter[] { new ListPropertyConverter("page", "events", "actionName") });
    if (pageId != null && !pageId.isEmpty()) {
        final ApplicationSession applicationSession = dataContainer.load(Long.valueOf(pageId));
        if (applicationSession != null) {
            final VerticalLayout rightLayout = new VerticalLayout();
            rightLayout.setSizeFull();
            final HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setWidth(ContentSize.FULL_SIZE);
            content.addComponent(horizontalLayout);
            content.setExpandRatio(horizontalLayout, ContentRatio.GRID);
            getFormFactory().addFormPanelTextFields(horizontalLayout, applicationSession, ApplicationSession.class, AS_LIST);
            horizontalLayout.addComponent(rightLayout);
            horizontalLayout.setExpandRatio(rightLayout, ContentRatio.GRID);
            getGridFactory().createBasicBeanItemGrid(rightLayout, ApplicationActionEvent.class, applicationSession.getEvents(), APPLICATION_ACTION_EVENT, COLUMN_ORDER2, HIDE_COLUMNS2, new PageItemPropertyClickListener(AdminViews.ADMIN_APPLICATIONS_EVENTS_VIEW_NAME, "hjid"), null, null);
        }
    }
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_APPLICATION_SESSION_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
    return content;
}
Also used : ApplicationSession(com.hack23.cia.model.internal.application.system.impl.ApplicationSession) PageItemPropertyClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener) VerticalLayout(com.vaadin.ui.VerticalLayout) ListPropertyConverter(com.hack23.cia.web.impl.ui.application.views.common.converters.ListPropertyConverter) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Secured(org.springframework.security.access.annotation.Secured)

Example 5 with DataContainer

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

the class AdminCountryPageModContentFactoryImpl 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_COUNTRY);
    final DataContainer<CountryElement, Long> dataContainer = getApplicationManager().getDataContainer(CountryElement.class);
    final List<CountryElement> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, CountryElement_.countryName);
    createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
    getGridFactory().createBasicBeanItemNestedPropertiesGrid(content, CountryElement.class, pageOrderBy, COUNTRY2, null, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
    if (pageId != null && !pageId.isEmpty()) {
        final CountryElement country = dataContainer.load(Long.valueOf(pageId));
        if (country != null) {
            getFormFactory().addFormPanelTextFields(content, country, CountryElement.class, AS_LIST);
        }
    }
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_COUNTRY_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
    return content;
}
Also used : VerticalLayout(com.vaadin.ui.VerticalLayout) CountryElement(com.hack23.cia.model.external.worldbank.countries.impl.CountryElement) Secured(org.springframework.security.access.annotation.Secured)

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