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