Search in sources :

Example 1 with SearchResult

use of com.odysseusinc.arachne.portal.service.impl.solr.SearchResult in project ArachneCentralAPI by OHDSI.

the class BaseExpertFinderController method list.

@ApiOperation("Get expert list")
@RequestMapping(value = "/api/v1/user-management/users", method = GET)
public JsonResult<ExpertListSearchResultDTO> list(@ModelAttribute SearchExpertListDTO searchDTO) throws IOException, SolrServerException, NoSuchFieldException {
    JsonResult result = new JsonResult<ExpertListSearchResultDTO>(NO_ERROR);
    SolrQuery solrQuery = conversionService.convert(searchDTO, SolrQuery.class);
    SearchResult searchResult = userService.search(solrQuery);
    result.setResult(this.conversionService.convert(searchResult, ExpertListSearchResultDTO.class));
    return result;
}
Also used : ExpertListSearchResultDTO(com.odysseusinc.arachne.portal.api.v1.dto.ExpertListSearchResultDTO) SearchResult(com.odysseusinc.arachne.portal.service.impl.solr.SearchResult) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) SolrQuery(org.apache.solr.client.solrj.SolrQuery) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SearchResult

use of com.odysseusinc.arachne.portal.service.impl.solr.SearchResult in project ArachneCentralAPI by OHDSI.

the class BaseDataSourceServiceImpl method search.

public SearchResult<DS> search(SolrQuery solrQuery) throws IOException, SolrServerException, NoSuchFieldException {
    List<DS> dataSourceList;
    QueryResponse solrResponse = solrSearch(solrQuery);
    List<Long> docIdList = solrResponse.getResults().stream().map(solrDoc -> Long.parseLong(solrDoc.get(BaseSolrServiceImpl.ID).toString())).collect(Collectors.toList());
    // We need to repeat sorting, because repository doesn't prevent order of passed ids
    dataSourceList = dataSourceRepository.findByIdInAndDeletedIsNullAndPublishedTrue(docIdList);
    dataSourceList.sort(Comparator.comparing(item -> docIdList.indexOf(item.getId())));
    return new SearchResult<>(solrQuery, solrResponse, dataSourceList);
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) LoggerFactory(org.slf4j.LoggerFactory) SearchResult(com.odysseusinc.arachne.portal.service.impl.solr.SearchResult) SolrServerException(org.apache.solr.client.solrj.SolrServerException) SolrField(com.odysseusinc.arachne.portal.service.impl.solr.SolrField) IDataSource(com.odysseusinc.arachne.portal.model.IDataSource) Predicate(javax.persistence.criteria.Predicate) BaseDataSourceService(com.odysseusinc.arachne.portal.service.BaseDataSourceService) Map(java.util.Map) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) BaseSolrService(com.odysseusinc.arachne.portal.service.BaseSolrService) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) ArachneMailSender(com.odysseusinc.arachne.portal.service.mail.ArachneMailSender) PageRequest(org.springframework.data.domain.PageRequest) PostAuthorize(org.springframework.security.access.prepost.PostAuthorize) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) IUser(com.odysseusinc.arachne.portal.model.IUser) SolrCollection(com.odysseusinc.arachne.portal.model.solr.SolrCollection) Objects(java.util.Objects) BaseDataSourceRepository(com.odysseusinc.arachne.portal.repository.BaseDataSourceRepository) Skill(com.odysseusinc.arachne.portal.model.Skill) List(java.util.List) CollectionUtils(org.springframework.util.CollectionUtils) SolrQuery(org.apache.solr.client.solrj.SolrQuery) NewDataSourceMailMessage(com.odysseusinc.arachne.portal.service.mail.NewDataSourceMailMessage) FieldException(com.odysseusinc.arachne.portal.exception.FieldException) PageImpl(org.springframework.data.domain.PageImpl) FieldList(com.odysseusinc.arachne.portal.service.impl.solr.FieldList) BaseUserService(com.odysseusinc.arachne.portal.service.BaseUserService) TypedQuery(javax.persistence.TypedQuery) BaseRawDataSourceRepository(com.odysseusinc.arachne.portal.repository.BaseRawDataSourceRepository) ArrayList(java.util.ArrayList) DataSource(com.odysseusinc.arachne.portal.model.DataSource) SearchDataCatalogDTO(com.odysseusinc.arachne.portal.api.v1.dto.SearchDataCatalogDTO) DataSourceStatus(com.odysseusinc.arachne.portal.model.DataSourceStatus) Root(javax.persistence.criteria.Root) Logger(org.slf4j.Logger) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) CommonModelType(com.odysseusinc.arachne.commons.api.v1.dto.CommonModelType) IOException(java.io.IOException) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) EntityManager(javax.persistence.EntityManager) PermissionDeniedException(com.odysseusinc.arachne.portal.exception.PermissionDeniedException) WebSecurityConfig(com.odysseusinc.arachne.portal.config.WebSecurityConfig) TenantService(com.odysseusinc.arachne.portal.service.TenantService) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) Subquery(javax.persistence.criteria.Subquery) Comparator(java.util.Comparator) StudyDataSourceLink(com.odysseusinc.arachne.portal.model.StudyDataSourceLink) Collections(java.util.Collections) Transactional(org.springframework.transaction.annotation.Transactional) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SearchResult(com.odysseusinc.arachne.portal.service.impl.solr.SearchResult)

Example 3 with SearchResult

use of com.odysseusinc.arachne.portal.service.impl.solr.SearchResult in project ArachneCentralAPI by OHDSI.

the class BaseUserServiceImpl method search.

public SearchResult<U> search(SolrQuery solrQuery) throws IOException, SolrServerException, NoSuchFieldException {
    List<U> userList;
    QueryResponse solrResponse = solrSearch(solrQuery);
    List<Long> docIdList = solrResponse.getResults().stream().map(solrDoc -> Long.parseLong(solrDoc.get(BaseSolrServiceImpl.ID).toString())).collect(Collectors.toList());
    userList = userRepository.findByIdIn(docIdList);
    userList = userList.stream().sorted(Comparator.comparing(item -> docIdList.indexOf(item.getId()))).collect(Collectors.toList());
    SearchResult<U> searchResult = new SearchResult<>(solrQuery, solrResponse, userList);
    searchResult.setExcludedOptions(getExcludedOptions());
    return searchResult;
}
Also used : UserSpecifications.withNameOrEmailLike(com.odysseusinc.arachne.portal.repository.UserSpecifications.withNameOrEmailLike) UserSpecifications(com.odysseusinc.arachne.portal.repository.UserSpecifications) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Autowired(org.springframework.beans.factory.annotation.Autowired) UserStudy(com.odysseusinc.arachne.portal.model.UserStudy) SearchResult(com.odysseusinc.arachne.portal.service.impl.solr.SearchResult) SolrServerException(org.apache.solr.client.solrj.SolrServerException) ArachnePasswordData(com.odysseusinc.arachne.portal.security.passwordvalidator.ArachnePasswordData) Map(java.util.Map) Sort(org.springframework.data.domain.Sort) ArachnePasswordValidationResult(com.odysseusinc.arachne.portal.security.passwordvalidator.ArachnePasswordValidationResult) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) User(com.odysseusinc.arachne.portal.model.User) Resource(org.springframework.core.io.Resource) BaseSolrService(com.odysseusinc.arachne.portal.service.BaseSolrService) UserNotFoundException(com.odysseusinc.arachne.portal.exception.UserNotFoundException) Tenant(com.odysseusinc.arachne.portal.model.security.Tenant) ArachneMailSender(com.odysseusinc.arachne.portal.service.mail.ArachneMailSender) Transactional(javax.transaction.Transactional) MetadataException(com.drew.metadata.MetadataException) JavaMailSender(org.springframework.mail.javamail.JavaMailSender) NotNull(javax.validation.constraints.NotNull) Page(org.springframework.data.domain.Page) IUser(com.odysseusinc.arachne.portal.model.IUser) Skill(com.odysseusinc.arachne.portal.model.Skill) Stream(java.util.stream.Stream) WrongFileFormatException(com.odysseusinc.arachne.portal.exception.WrongFileFormatException) SolrQuery(org.apache.solr.client.solrj.SolrQuery) UserStudyRepository(com.odysseusinc.arachne.portal.repository.UserStudyRepository) TRUE(java.lang.Boolean.TRUE) Metadata(com.drew.metadata.Metadata) ProfessionalTypeService(com.odysseusinc.arachne.portal.service.ProfessionalTypeService) CountryRepository(com.odysseusinc.arachne.portal.repository.CountryRepository) UserSpecifications.userEnabled(com.odysseusinc.arachne.portal.repository.UserSpecifications.userEnabled) Value(org.springframework.beans.factory.annotation.Value) Secured(org.springframework.security.access.annotation.Secured) RegistrationMailMessage(com.odysseusinc.arachne.portal.service.mail.RegistrationMailMessage) SearchExpertListDTO(com.odysseusinc.arachne.portal.api.v1.dto.SearchExpertListDTO) BaseUserRepository(com.odysseusinc.arachne.portal.repository.BaseUserRepository) ExifIFD0Directory(com.drew.metadata.exif.ExifIFD0Directory) MessageSource(org.springframework.context.MessageSource) StateProvince(com.odysseusinc.arachne.portal.model.StateProvince) Specifications(org.springframework.data.jpa.domain.Specifications) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) ImageMetadataReader(com.drew.imaging.ImageMetadataReader) IOException(java.io.IOException) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) File(java.io.File) TenantService(com.odysseusinc.arachne.portal.service.TenantService) PasswordValidationException(com.odysseusinc.arachne.portal.exception.PasswordValidationException) Paths(java.nio.file.Paths) DECLINED(com.odysseusinc.arachne.portal.model.ParticipantStatus.DECLINED) UserSearch(com.odysseusinc.arachne.portal.model.search.UserSearch) ParticipantStatus(com.odysseusinc.arachne.portal.model.ParticipantStatus) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) Date(java.util.Date) UserSpecifications.emailConfirmed(com.odysseusinc.arachne.portal.repository.UserSpecifications.emailConfirmed) LoggerFactory(org.slf4j.LoggerFactory) SolrField(com.odysseusinc.arachne.portal.service.impl.solr.SolrField) Scalr(org.imgscalr.Scalr) UserPublication(com.odysseusinc.arachne.portal.model.UserPublication) ImageIO(javax.imageio.ImageIO) Pageable(org.springframework.data.domain.Pageable) ImageProcessingException(com.drew.imaging.ImageProcessingException) BufferedImage(java.awt.image.BufferedImage) Password(edu.vt.middleware.password.Password) UUID(java.util.UUID) UserRegistrantService(com.odysseusinc.arachne.portal.service.UserRegistrantService) Collectors(java.util.stream.Collectors) SolrCollection(com.odysseusinc.arachne.portal.model.solr.SolrCollection) Objects(java.util.Objects) CommonFileUtils(com.odysseusinc.arachne.commons.utils.CommonFileUtils) List(java.util.List) UserIdUtils(com.odysseusinc.arachne.commons.utils.UserIdUtils) Principal(java.security.Principal) AnalysisUnlockRequestRepository(com.odysseusinc.arachne.portal.repository.AnalysisUnlockRequestRepository) Role(com.odysseusinc.arachne.portal.model.Role) Optional(java.util.Optional) Authentication(org.springframework.security.core.Authentication) Invitationable(com.odysseusinc.arachne.portal.model.Invitationable) RemindPasswordMailMessage(com.odysseusinc.arachne.portal.service.mail.RemindPasswordMailMessage) FilenameUtils(org.apache.commons.io.FilenameUtils) ROLE_ADMIN(com.odysseusinc.arachne.portal.service.RoleService.ROLE_ADMIN) Specifications.where(org.springframework.data.jpa.domain.Specifications.where) NotUniqueException(com.odysseusinc.arachne.portal.exception.NotUniqueException) FieldList(com.odysseusinc.arachne.portal.service.impl.solr.FieldList) APPROVED(com.odysseusinc.arachne.portal.model.ParticipantStatus.APPROVED) ClassPathResource(org.springframework.core.io.ClassPathResource) StateProvinceRepository(com.odysseusinc.arachne.portal.repository.StateProvinceRepository) StudyDataSourceLinkRepository(com.odysseusinc.arachne.portal.repository.StudyDataSourceLinkRepository) BaseUserService(com.odysseusinc.arachne.portal.service.BaseUserService) BaseSkillService(com.odysseusinc.arachne.portal.service.BaseSkillService) ValidationException(com.odysseusinc.arachne.portal.exception.ValidationException) ArachneSystemRuntimeException(com.odysseusinc.arachne.portal.exception.ArachneSystemRuntimeException) BaseUserLinkService(com.odysseusinc.arachne.portal.service.BaseUserLinkService) ArachnePasswordValidator(com.odysseusinc.arachne.portal.security.passwordvalidator.ArachnePasswordValidator) Qualifier(org.springframework.beans.factory.annotation.Qualifier) UserRegistrant(com.odysseusinc.arachne.portal.model.UserRegistrant) DataSourceStatus(com.odysseusinc.arachne.portal.model.DataSourceStatus) LinkedList(java.util.LinkedList) BaseUserPublicationService(com.odysseusinc.arachne.portal.service.BaseUserPublicationService) BaseRawUserRepository(com.odysseusinc.arachne.portal.repository.BaseRawUserRepository) Logger(org.slf4j.Logger) HttpServletResponse(javax.servlet.http.HttpServletResponse) FileInputStream(java.io.FileInputStream) ProfessionalType(com.odysseusinc.arachne.portal.model.ProfessionalType) PermissionDeniedException(com.odysseusinc.arachne.portal.exception.PermissionDeniedException) WebSecurityConfig(com.odysseusinc.arachne.portal.config.WebSecurityConfig) UserLink(com.odysseusinc.arachne.portal.model.UserLink) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) EntityUtils(com.odysseusinc.arachne.portal.util.EntityUtils) RoleRepository(com.odysseusinc.arachne.portal.repository.RoleRepository) MultipartFile(org.springframework.web.multipart.MultipartFile) Country(com.odysseusinc.arachne.portal.model.Country) Comparator(java.util.Comparator) Collections(java.util.Collections) InputStream(java.io.InputStream) StringUtils(org.springframework.util.StringUtils) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SearchResult(com.odysseusinc.arachne.portal.service.impl.solr.SearchResult)

Example 4 with SearchResult

use of com.odysseusinc.arachne.portal.service.impl.solr.SearchResult in project ArachneCentralAPI by OHDSI.

the class BaseUserServiceImpl method getExcludedOptions.

private Map<String, List<String>> getExcludedOptions() throws IOException, SolrServerException, NoSuchFieldException {
    SolrQuery solrQuery = conversionService.convert(new SearchExpertListDTO(true), SolrQuery.class);
    QueryResponse solrResponse = solrSearch(solrQuery);
    SearchResult<Long> searchResult = new SearchResult<>(solrQuery, solrResponse, Collections.<Long>emptyList());
    return searchResult.excludedOptions();
}
Also used : QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SearchResult(com.odysseusinc.arachne.portal.service.impl.solr.SearchResult) SearchExpertListDTO(com.odysseusinc.arachne.portal.api.v1.dto.SearchExpertListDTO) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Example 5 with SearchResult

use of com.odysseusinc.arachne.portal.service.impl.solr.SearchResult in project ArachneCentralAPI by OHDSI.

the class BaseGlobalSearchServiceImpl method search.

@Override
public // TODO refactor, move out converting code
GlobalSearchResultDTO search(final Long userId, final SearchGlobalDTO searchDTO) throws SolrServerException, NoSuchFieldException, IOException {
    searchDTO.setResultFields(ID, SYSTEM_ID, TITLE, TYPE, BREADCRUMBS);
    final String[] collections = calculateCollections(searchDTO);
    searchDTO.setCollections(collections);
    final String tenantId = TenantContext.getCurrentTenant().toString();
    final SolrQuery query = conversionService.convert(searchDTO, SolrQuery.class);
    query.setQuery(buildSearchString(searchDTO.getQuery(), userId, tenantId));
    setupHighlight(searchDTO.getQuery(), query);
    final QueryResponse response = solrService.search(collections[0], query);
    final SearchResult<SolrDocument> searchResult = new SearchResult<>(query, response, response.getResults());
    return conversionService.convert(searchResult, GlobalSearchResultDTO.class);
}
Also used : SolrDocument(org.apache.solr.common.SolrDocument) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SearchResult(com.odysseusinc.arachne.portal.service.impl.solr.SearchResult) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Aggregations

SearchResult (com.odysseusinc.arachne.portal.service.impl.solr.SearchResult)6 SolrQuery (org.apache.solr.client.solrj.SolrQuery)6 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)5 SearchExpertListDTO (com.odysseusinc.arachne.portal.api.v1.dto.SearchExpertListDTO)2 WebSecurityConfig (com.odysseusinc.arachne.portal.config.WebSecurityConfig)2 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)2 PermissionDeniedException (com.odysseusinc.arachne.portal.exception.PermissionDeniedException)2 DataSourceStatus (com.odysseusinc.arachne.portal.model.DataSourceStatus)2 IUser (com.odysseusinc.arachne.portal.model.IUser)2 Skill (com.odysseusinc.arachne.portal.model.Skill)2 SolrCollection (com.odysseusinc.arachne.portal.model.solr.SolrCollection)2 BaseSolrService (com.odysseusinc.arachne.portal.service.BaseSolrService)2 BaseUserService (com.odysseusinc.arachne.portal.service.BaseUserService)2 TenantService (com.odysseusinc.arachne.portal.service.TenantService)2 FieldList (com.odysseusinc.arachne.portal.service.impl.solr.FieldList)2 SolrField (com.odysseusinc.arachne.portal.service.impl.solr.SolrField)2 ArachneMailSender (com.odysseusinc.arachne.portal.service.mail.ArachneMailSender)2 IOException (java.io.IOException)2 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2