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;
}
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;
}
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());
}
}
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;
}
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;
}
Aggregations