Search in sources :

Example 1 with DocumentElement

use of com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement in project cia by Hack23.

the class DocumentElementDAOImpl method checkDocumentElement.

@Override
public boolean checkDocumentElement(final String documentId) {
    final CriteriaQuery<DocumentElement> criteriaQuery = getCriteriaBuilder().createQuery(DocumentElement.class);
    final Root<DocumentElement> root = criteriaQuery.from(DocumentElement.class);
    criteriaQuery.select(root);
    final Predicate condition = getCriteriaBuilder().equal(root.get(DocumentElement_.id), documentId);
    criteriaQuery.where(condition);
    final TypedQuery<DocumentElement> typedQuery = getEntityManager().createQuery(criteriaQuery);
    addCacheHints(typedQuery, "checkDocumentElement");
    final List<DocumentElement> resultList = typedQuery.getResultList();
    return !resultList.isEmpty();
}
Also used : DocumentElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement) Predicate(javax.persistence.criteria.Predicate)

Example 2 with DocumentElement

use of com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement in project cia by Hack23.

the class DocumentDataPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();
    final String pageId = getPageId(parameters);
    final DataContainer<DocumentElement, String> documentElementDataContainer = getApplicationManager().getDataContainer(DocumentElement.class);
    final DataContainer<DocumentContentData, String> documentContentDataDataContainer = getApplicationManager().getDataContainer(DocumentContentData.class);
    getApplicationManager().getDataContainer(CommitteeProposalComponentData.class);
    final DocumentElement documentElement = documentElementDataContainer.load(pageId);
    if (documentElement != null) {
        getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId);
        LabelFactory.createHeader2Label(panelContent, DOCUMENT_DATA);
        final List<DocumentContentData> documentContentlist = documentContentDataDataContainer.getAllBy(DocumentContentData_.id, pageId);
        if (!documentContentlist.isEmpty()) {
            final Panel formPanel = new Panel();
            formPanel.setSizeFull();
            panelContent.addComponent(formPanel);
            final FormLayout formContent = new FormLayout();
            formPanel.setContent(formContent);
            final String cleanContent = Jsoup.clean(documentContentlist.get(0).getContent(), "", Whitelist.simpleText(), new OutputSettings().indentAmount(4));
            final Label htmlContent = new Label(cleanContent, ContentMode.HTML);
            formContent.addComponent(htmlContent);
            final DocumentWordCountRequest documentWordCountRequest = new DocumentWordCountRequest();
            documentWordCountRequest.setDocumentId(pageId);
            documentWordCountRequest.setMaxResults(MAX_RESULTS);
            documentWordCountRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
            final DocumentWordCountResponse resp = (DocumentWordCountResponse) getApplicationManager().service(documentWordCountRequest);
            if (resp.getWordCountMap() != null) {
                final Label wordCloud = new Label(createWordCloud(resp.getWordCountMap()), ContentMode.HTML);
                formContent.addComponent(wordCloud);
            }
            panelContent.setExpandRatio(formPanel, ContentRatio.GRID);
        }
        panel.setContent(panelContent);
        getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
    }
    return panelContent;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Label(com.vaadin.ui.Label) DocumentWordCountResponse(com.hack23.cia.service.api.action.user.DocumentWordCountResponse) DocumentWordCountRequest(com.hack23.cia.service.api.action.user.DocumentWordCountRequest) DocumentContentData(com.hack23.cia.model.external.riksdagen.documentcontent.impl.DocumentContentData) Panel(com.vaadin.ui.Panel) OutputSettings(org.jsoup.nodes.Document.OutputSettings) DocumentElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement) VerticalLayout(com.vaadin.ui.VerticalLayout) Secured(org.springframework.security.access.annotation.Secured)

Example 3 with DocumentElement

use of com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement in project cia by Hack23.

the class DocumentDetailsPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();
    final String pageId = getPageId(parameters);
    final DataContainer<DocumentElement, String> documentElementDataContainer = getApplicationManager().getDataContainer(DocumentElement.class);
    final DataContainer<DocumentStatusContainer, String> documentStatusContainerDataContainer = getApplicationManager().getDataContainer(DocumentStatusContainer.class);
    getApplicationManager().getDataContainer(CommitteeProposalComponentData.class);
    final DocumentElement documentElement = documentElementDataContainer.load(pageId);
    if (documentElement != null) {
        getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId);
        final DocumentStatusContainer documentStatusContainer = documentStatusContainerDataContainer.findByQueryProperty(DocumentStatusContainer.class, DocumentStatusContainer_.document, DocumentData.class, DocumentData_.id, pageId);
        LabelFactory.createHeader2Label(panelContent, DOCUMENT_DETAILS);
        if (documentStatusContainer != null && documentStatusContainer.getDocumentDetailContainer() != null && documentStatusContainer.getDocumentDetailContainer().getDocumentDetailList() != null) {
            getGridFactory().createBasicBeanItemGrid(panelContent, DocumentDetailData.class, documentStatusContainer.getDocumentDetailContainer().getDocumentDetailList(), DOCUMENT_DETAILS2, COLUMN_ORDER, HIDE_COLUMNS, null, null, null);
        }
        panel.setContent(panelContent);
        getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
    }
    return panelContent;
}
Also used : DocumentStatusContainer(com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer) DocumentElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement) VerticalLayout(com.vaadin.ui.VerticalLayout) Secured(org.springframework.security.access.annotation.Secured)

Example 4 with DocumentElement

use of com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement in project cia by Hack23.

the class DocumentOverviewPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();
    final String pageId = getPageId(parameters);
    final DataContainer<DocumentElement, String> documentElementDataContainer = getApplicationManager().getDataContainer(DocumentElement.class);
    final DataContainer<DocumentStatusContainer, String> documentStatusContainerDataContainer = getApplicationManager().getDataContainer(DocumentStatusContainer.class);
    final DocumentElement documentElement = documentElementDataContainer.load(pageId);
    if (documentElement != null) {
        getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId);
        final DocumentStatusContainer documentStatusContainer = documentStatusContainerDataContainer.findByQueryProperty(DocumentStatusContainer.class, DocumentStatusContainer_.document, DocumentData.class, DocumentData_.id, pageId);
        LabelFactory.createHeader2Label(panelContent, OVERVIEW);
        getFormFactory().addFormPanelTextFields(panelContent, documentElement, DocumentElement.class, AS_LIST);
        if (documentStatusContainer != null) {
            getFormFactory().addFormPanelTextFields(panelContent, documentStatusContainer, DocumentStatusContainer.class, AS_LIST3);
            getFormFactory().addFormPanelTextFields(panelContent, documentStatusContainer.getDocument(), DocumentData.class, AS_LIST2);
        }
        final VerticalLayout overviewLayout = new VerticalLayout();
        overviewLayout.setSizeFull();
        panelContent.addComponent(overviewLayout);
        panelContent.setExpandRatio(overviewLayout, ContentRatio.LARGE_FORM);
        getDocumentMenuItemFactory().createOverviewPage(overviewLayout, pageId);
        panel.setContent(panelContent);
        getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
    }
    return panelContent;
}
Also used : DocumentStatusContainer(com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer) DocumentElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement) VerticalLayout(com.vaadin.ui.VerticalLayout) Secured(org.springframework.security.access.annotation.Secured)

Example 5 with DocumentElement

use of com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement in project cia by Hack23.

the class DocumentPageVisitHistoryPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();
    final String pageId = getPageId(parameters);
    final DataContainer<DocumentElement, String> documentElementDataContainer = getApplicationManager().getDataContainer(DocumentElement.class);
    getApplicationManager().getDataContainer(CommitteeProposalComponentData.class);
    final DocumentElement documentElement = documentElementDataContainer.load(pageId);
    if (documentElement != null) {
        getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId);
        createPageVisitHistory(NAME, pageId, panelContent);
        panel.setContent(panelContent);
        getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
    }
    return panelContent;
}
Also used : DocumentElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement) VerticalLayout(com.vaadin.ui.VerticalLayout) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

DocumentElement (com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement)15 Secured (org.springframework.security.access.annotation.Secured)11 VerticalLayout (com.vaadin.ui.VerticalLayout)10 DocumentStatusContainer (com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer)7 ArrayList (java.util.ArrayList)3 DocumentContentData (com.hack23.cia.model.external.riksdagen.documentcontent.impl.DocumentContentData)2 DocumentContainerElement (com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentContainerElement)2 BigInteger (java.math.BigInteger)2 JAXBElement (javax.xml.bind.JAXBElement)2 DocumentType (com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentType)1 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)1 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)1 DocumentWordCountRequest (com.hack23.cia.service.api.action.user.DocumentWordCountRequest)1 DocumentWordCountResponse (com.hack23.cia.service.api.action.user.DocumentWordCountResponse)1 SearchDocumentResponse (com.hack23.cia.service.api.action.user.SearchDocumentResponse)1 AbstractServiceComponentAgentFunctionalIntegrationTest (com.hack23.cia.service.component.agent.impl.AbstractServiceComponentAgentFunctionalIntegrationTest)1 FormLayout (com.vaadin.ui.FormLayout)1 Label (com.vaadin.ui.Label)1 Panel (com.vaadin.ui.Panel)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1