Search in sources :

Example 11 with DocumentElement

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

the class RiksdagenDocumentElementWorkConsumerImplITest method onMessageSuccessTest.

/**
 * On message success test.
 *
 * @throws JMSException
 *             the JMS exception
 */
@Test
@Transactional
public void onMessageSuccessTest() throws JMSException {
    final ObjectMessage message = mock(ObjectMessage.class);
    when(message.getObject()).thenReturn(new DocumentElement().withId("2a6fd34d-969f-48b5-b472-363ee61cdb96"));
    messsageListener.onMessage(message);
    verify(message, atLeastOnce()).getObject();
}
Also used : DocumentElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement) ObjectMessage(javax.jms.ObjectMessage) Test(org.junit.Test) AbstractServiceComponentAgentFunctionalIntegrationTest(com.hack23.cia.service.component.agent.impl.AbstractServiceComponentAgentFunctionalIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with DocumentElement

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

the class SearchDocumentService method processService.

@Override
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_ANONYMOUS" })
public SearchDocumentResponse processService(final SearchDocumentRequest serviceRequest) {
    final SearchDocumentResponse inputValidation = inputValidation(serviceRequest);
    if (inputValidation != null) {
        return inputValidation;
    }
    LOGGER.info("{}:{}", serviceRequest.getClass().getSimpleName(), serviceRequest.getSearchExpression());
    final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
    final UserAccount userAccount = getUserAccountFromSecurityContext();
    if (userAccount != null) {
        eventRequest.setUserId(userAccount.getUserId());
    }
    final SearchDocumentResponse response = new SearchDocumentResponse(ServiceResult.SUCCESS);
    final List<DocumentElement> searchResultTitles = documentElementDAO.search(serviceRequest.getSearchExpression(), serviceRequest.getMaxResults(), "id", "title", "subTitle");
    if (!searchResultTitles.isEmpty()) {
        response.setResultElement(searchResultTitles);
    } else {
        final List<DocumentContentData> searchResultContent = documentContentDataDAO.search(serviceRequest.getSearchExpression(), serviceRequest.getMaxResults(), "id", "content");
        if (!searchResultContent.isEmpty()) {
            final List<DocumentElement> searchResultTitlesForContent = new ArrayList<>();
            for (final DocumentContentData documentContent : searchResultContent) {
                searchResultTitlesForContent.add(documentElementDAO.load(documentContent.getId()));
            }
            response.setResultElement(searchResultTitlesForContent);
        }
    }
    eventRequest.setApplicationMessage(response.getResult().toString());
    createApplicationEventService.processService(eventRequest);
    return response;
}
Also used : DocumentElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement) SearchDocumentResponse(com.hack23.cia.service.api.action.user.SearchDocumentResponse) ArrayList(java.util.ArrayList) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) DocumentContentData(com.hack23.cia.model.external.riksdagen.documentcontent.impl.DocumentContentData) Secured(org.springframework.security.access.annotation.Secured)

Example 13 with DocumentElement

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

the class DocumentDecisionPageModContentFactoryImpl 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_DECISION);
        if (documentStatusContainer != null && documentStatusContainer.getDocumentProposal() != null && documentStatusContainer.getDocumentProposal().getProposal() != null) {
            getFormFactory().addFormPanelTextFields(panelContent, documentStatusContainer.getDocumentProposal().getProposal(), DocumentProposalData.class, AS_LIST);
        }
        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 14 with DocumentElement

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

the class DocumentPersonReferencesPageModContentFactoryImpl 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, PERSON_REFERENCES);
        if (documentStatusContainer != null && documentStatusContainer.getDocumentPersonReferenceContainer() != null && documentStatusContainer.getDocumentPersonReferenceContainer().getDocumentPersonReferenceList() != null) {
            getGridFactory().createBasicBeanItemGrid(panelContent, DocumentPersonReferenceData.class, documentStatusContainer.getDocumentPersonReferenceContainer().getDocumentPersonReferenceList(), DOCUMENT_PERSON_REFERENCES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, 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 15 with DocumentElement

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

the class DocumentsOverviewPageModContentFactoryImpl 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 int pageNr = getPageNr(parameters);
    getDocumentMenuItemFactory().createDocumentsMenuBar(menuBar);
    LabelFactory.createHeader2Label(panelContent, OVERVIEW);
    final DataContainer<DocumentElement, String> documentElementDataContainer = getApplicationManager().getDataContainer(DocumentElement.class);
    final List<DocumentElement> pageOrderBy = documentElementDataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, DocumentElement_.createdDate);
    createPagingControls(panelContent, NAME, pageId, documentElementDataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
    getGridFactory().createBasicBeanItemGrid(panelContent, DocumentElement.class, pageOrderBy, DOCUMENT, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
    panel.setContent(panelContent);
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENTS_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