use of io.vertigo.lang.VUserException in project vertigo by KleeGroup.
the class RamLuceneIndex method executeQuery.
private DtList<D> executeQuery(final Query query, final int skip, final int top, final Optional<Sort> optSort) throws IOException {
try (final IndexReader indexReader = DirectoryReader.open(directory)) {
final IndexSearcher searcher = new IndexSearcher(indexReader);
// 1. Exécution des la Requête
final TopDocs topDocs;
if (optSort.isPresent()) {
topDocs = searcher.search(query, skip + top, optSort.get());
} else {
topDocs = searcher.search(query, skip + top);
}
// 2. Traduction du résultat Lucene en une Collection
return translateDocs(searcher, topDocs, skip, top);
} catch (final TooManyClauses e) {
throw (VUserException) new VUserException(Resources.DYNAMO_COLLECTIONS_INDEXER_TOO_MANY_CLAUSES).initCause(e);
}
}
use of io.vertigo.lang.VUserException in project vertigo by KleeGroup.
the class RamLuceneIndex method executeQuery.
private DtList<D> executeQuery(final Query query, final int skip, final int top, final Optional<Sort> optSort) throws IOException {
try (final IndexReader indexReader = DirectoryReader.open(directory)) {
final IndexSearcher searcher = new IndexSearcher(indexReader);
// 1. Exécution des la Requête
final TopDocs topDocs;
if (optSort.isPresent()) {
topDocs = searcher.search(query, skip + top, optSort.get());
} else {
topDocs = searcher.search(query, skip + top);
}
// 2. Traduction du résultat Lucene en une Collection
return translateDocs(searcher, topDocs, skip, top);
} catch (final TooManyClauses e) {
throw (VUserException) new VUserException(Resources.DYNAMO_COLLECTIONS_INDEXER_TOO_MANY_CLAUSES).initCause(e);
}
}
use of io.vertigo.lang.VUserException in project vertigo by KleeGroup.
the class AbstractSqlExceptionHandler method handleTooLargeValueSqlException.
/**
* @param sqle Exception base de données
*/
protected final VUserException handleTooLargeValueSqlException(final SQLException sqle) {
final MessageKey key = Resources.DYNAMO_SQL_CONSTRAINT_TOO_BIG_VALUE;
LOGGER.warn(MessageText.of(key).getDisplay(), sqle);
// On se contente de logger l'exception cause mais on ne la lie pas à l'erreur utilisateur.
return new VUserException(key);
}
use of io.vertigo.lang.VUserException in project vertigo by KleeGroup.
the class ESStatement method remove.
/**
* Supprime des documents.
* @param query Requete de filtrage des documents à supprimer
*/
void remove(final ListFilter query) {
Assertion.checkNotNull(query);
// -----
try {
final QueryBuilder queryBuilder = ESSearchRequestBuilder.translateToQueryBuilder(query);
final DeleteByQueryRequestBuilder deleteByQueryAction = DeleteByQueryAction.INSTANCE.newRequestBuilder(esClient).filter(queryBuilder);
deleteByQueryAction.source().setIndices(indexName).setTypes(typeName);
final BulkByScrollResponse response = deleteByQueryAction.get();
final long deleted = response.getDeleted();
LOGGER.debug("Removed {0} elements", deleted);
} catch (final SearchPhaseExecutionException e) {
final VUserException vue = new VUserException(SearchResource.DYNAMO_SEARCH_QUERY_SYNTAX_ERROR);
vue.initCause(e);
throw vue;
}
}
use of io.vertigo.lang.VUserException in project vertigo by KleeGroup.
the class ESStatement method loadList.
/**
* @param indexDefinition Index de recherche
* @param searchQuery Mots clés de recherche
* @param listState Etat de la liste (tri et pagination)
* @param defaultMaxRows Nombre de ligne max par defaut
* @return Résultat de la recherche
*/
FacetedQueryResult<I, SearchQuery> loadList(final SearchIndexDefinition indexDefinition, final SearchQuery searchQuery, final DtListState listState, final int defaultMaxRows) {
Assertion.checkNotNull(searchQuery);
// -----
final SearchRequestBuilder searchRequestBuilder = new ESSearchRequestBuilder(indexName, typeName, esClient).withSearchIndexDefinition(indexDefinition).withSearchQuery(searchQuery).withListState(listState, defaultMaxRows).build();
LOGGER.info("loadList " + searchRequestBuilder);
try {
final SearchResponse queryResponse = searchRequestBuilder.execute().actionGet();
return new ESFacetedQueryResultBuilder(esDocumentCodec, indexDefinition, queryResponse, searchQuery).build();
} catch (final SearchPhaseExecutionException e) {
final VUserException vue = new VUserException(SearchResource.DYNAMO_SEARCH_QUERY_SYNTAX_ERROR);
vue.initCause(e);
throw vue;
}
}
Aggregations