Search in sources :

Example 6 with DocumentElement

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

the class DocumentReferencesPageModContentFactoryImpl 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_REFERENCES);
        if (documentStatusContainer != null && documentStatusContainer.getDocumentReferenceContainer() != null && documentStatusContainer.getDocumentReferenceContainer().getDocumentReferenceList() != null) {
            getGridFactory().createBasicBeanItemGrid(panelContent, DocumentReferenceData.class, documentStatusContainer.getDocumentReferenceContainer().getDocumentReferenceList(), DOCUMENT_REFERENCES2, 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 7 with DocumentElement

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

the class DocumentActivityPageModContentFactoryImpl 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_ACTIVITY);
        if (documentStatusContainer != null && documentStatusContainer.getDocumentActivityContainer() != null && documentStatusContainer.getDocumentActivityContainer().getDocumentActivities() != null) {
            getGridFactory().createBasicBeanItemGrid(panelContent, DocumentActivityData.class, documentStatusContainer.getDocumentActivityContainer().getDocumentActivities(), DOCUMENT_ACTIVITIES, 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 8 with DocumentElement

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

the class RiksdagenDocumentApiImpl method loadAndProcessDocumentList.

/**
 * Load and process document list.
 *
 * @param url
 *            the url
 * @param processStrategy
 *            the process strategy
 * @throws Exception
 *             the exception
 */
private void loadAndProcessDocumentList(final String url, final ProcessDataStrategy<DocumentElement> processStrategy) throws XmlAgentException {
    final DocumentContainerElement dokumentLista = ((JAXBElement<DocumentContainerElement>) xmlAgent.unmarshallXml(riksdagenDocumentListMarshaller, url, HTTP_DOKUMENTLISTA_RIKSDAGEN_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL, null, null)).getValue();
    int resultSize = dokumentLista.getDokument().size();
    processAll(dokumentLista.getDokument(), processStrategy);
    final BigInteger pages = dokumentLista.getTotalPages();
    for (int i = 1; i < pages.intValue(); i++) {
        final DocumentContainerElement otherPagesdokumentLista = ((JAXBElement<DocumentContainerElement>) xmlAgent.unmarshallXml(riksdagenDocumentListMarshaller, url + PAGE_PROPERTY + i, HTTP_DOKUMENTLISTA_RIKSDAGEN_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL, null, null)).getValue();
        resultSize = resultSize + otherPagesdokumentLista.getDokument().size();
        processAll(otherPagesdokumentLista.getDokument(), processStrategy);
        LOGGER.info(LOADING_DOCUMENTS, resultSize, dokumentLista.getHits());
    }
}
Also used : BigInteger(java.math.BigInteger) DocumentContainerElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentContainerElement) JAXBElement(javax.xml.bind.JAXBElement)

Example 9 with DocumentElement

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

the class RiksdagenImportServiceImpl method getDocumentElementMap.

@Override
public Map<String, String> getDocumentElementMap(final Date after, final List<DocumentType> downloadType, final boolean onlyWithDocStatus) {
    final List<DocumentElement> all = documentElementDAO.getAll();
    final List<String> documentTypeValues = new ArrayList<>();
    for (final DocumentType docType : downloadType) {
        documentTypeValues.add(docType.value());
    }
    final Map<String, String> map = new ConcurrentHashMap<>();
    for (final DocumentElement documentElement : all) {
        if (checkIncludeDate(after, documentTypeValues, documentElement) && checkIncludeStatus(onlyWithDocStatus, documentElement)) {
            map.put(documentElement.getId(), documentElement.getDocumentType());
        }
    }
    return map;
}
Also used : DocumentElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement) ArrayList(java.util.ArrayList) DocumentType(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 10 with DocumentElement

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

the class RiksdagenDocumentApiImpl method loadDocumentList.

/**
 * Load document list.
 *
 * @param url
 *            the url
 * @param maxNumberPages
 *            the max number pages
 * @return the list
 * @throws Exception
 *             the exception
 */
private List<DocumentElement> loadDocumentList(final String url, final int maxNumberPages) throws XmlAgentException {
    final List<DocumentElement> result = new ArrayList<>();
    DocumentContainerElement dokumentLista = ((JAXBElement<DocumentContainerElement>) xmlAgent.unmarshallXml(riksdagenDocumentListMarshaller, url, HTTP_DOKUMENTLISTA_RIKSDAGEN_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL, null, null)).getValue();
    result.addAll(dokumentLista.getDokument());
    final BigInteger pages = dokumentLista.getTotalPages();
    for (int i = 1; i < pages.intValue() && i < maxNumberPages; i++) {
        dokumentLista = ((JAXBElement<DocumentContainerElement>) xmlAgent.unmarshallXml(riksdagenDocumentListMarshaller, fixBrokenUrl(dokumentLista.getNextPage()), HTTP_DOKUMENTLISTA_RIKSDAGEN_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL, null, null)).getValue();
        result.addAll(dokumentLista.getDokument());
        LOGGER.info(LOADING_DOCUMENTS, result.size(), dokumentLista.getHits());
    }
    return result;
}
Also used : DocumentElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) DocumentContainerElement(com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentContainerElement) JAXBElement(javax.xml.bind.JAXBElement)

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