use of com.hack23.cia.service.api.action.user.SearchDocumentResponse in project cia by Hack23.
the class SearchDocumentClickListener method buttonClick.
@Override
public void buttonClick(final ClickEvent event) {
final SearchDocumentResponse response = (SearchDocumentResponse) ApplicationMangerAccess.getApplicationManager().service(reqisterRequest);
if (ServiceResult.SUCCESS == response.getResult()) {
LOGGER.info(LOG_MSG_SEARCH_DOCUMENT, reqisterRequest.getSearchExpression());
Notification.show(SEARCH_SUCCESS, "Found :" + response.getResultElement().size(), Notification.Type.HUMANIZED_MESSAGE);
responseHandler.handle(response);
} else {
Notification.show(SEARCH_FAILED, ERROR_MESSAGE, Notification.Type.WARNING_MESSAGE);
LOGGER.info(LOG_MSG_SEARCH_DOCUMENT_FAILURE, reqisterRequest.getSearchExpression());
}
}
use of com.hack23.cia.service.api.action.user.SearchDocumentResponse 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.SearchDocumentResponse 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;
}
Aggregations