use of com.hack23.cia.service.api.action.user.SearchDocumentRequest in project cia by Hack23.
the class SearchDocumentServiceITest method Test.
/**
* Test.
*
* @throws Exception
* the exception
*/
@Test
public void Test() throws Exception {
setAuthenticatedAnonymousUser();
final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();
final SearchDocumentRequest serviceRequest = new SearchDocumentRequest();
serviceRequest.setSessionId(createSessionRequest.getSessionId());
serviceRequest.setMaxResults(10);
serviceRequest.setSearchExpression("kan");
final SearchDocumentResponse response = (SearchDocumentResponse) applicationManager.service(serviceRequest);
assertNotNull(EXPECT_A_RESULT, response);
assertTrue(EXPECT_A_RESULT, response.getResultElement().size() > 0);
}
use of com.hack23.cia.service.api.action.user.SearchDocumentRequest 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.service.api.action.user.SearchDocumentRequest in project cia by Hack23.
the class SearchDocumentService method createApplicationEventForService.
@Override
protected CreateApplicationEventRequest createApplicationEventForService(final SearchDocumentRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
eventRequest.setEventGroup(ApplicationEventGroup.USER);
eventRequest.setApplicationOperation(ApplicationOperationType.READ);
eventRequest.setActionName(SearchDocumentRequest.class.getSimpleName());
eventRequest.setSessionId(serviceRequest.getSessionId());
return eventRequest;
}
use of com.hack23.cia.service.api.action.user.SearchDocumentRequest in project cia by Hack23.
the class SearchDocumentPageModContentFactoryImpl 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);
documentMenuItemFactory.createDocumentsMenuBar(menuBar);
final VerticalLayout searchLayout = new VerticalLayout();
searchLayout.setSizeFull();
panelContent.addComponent(searchLayout);
final VerticalLayout searchresultLayout = new VerticalLayout();
searchresultLayout.setSizeFull();
final Panel formPanel = new Panel();
formPanel.setSizeFull();
searchresultLayout.addComponent(formPanel);
final FormLayout formContent = new FormLayout();
formPanel.setContent(formContent);
panelContent.addComponent(searchresultLayout);
panelContent.setExpandRatio(searchresultLayout, ContentRatio.LARGE);
final SearchDocumentRequest searchRequest = new SearchDocumentRequest();
searchRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
searchRequest.setMaxResults(MAX_RESULT_SIZE);
searchRequest.setSearchExpression("");
getFormFactory().addRequestInputFormFields(formContent, searchRequest, SearchDocumentRequest.class, AS_LIST, SEARCH, new SearchDocumentClickListener(searchRequest, new SearchDocumentResponseHandlerImpl(getGridFactory(), formPanel, searchresultLayout)));
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
return panelContent;
}
Aggregations