@Override public EntityMetadata<?> getEntityInformation() { final Class<?> domainClass = getDomainClass(); final DocumentDbEntityInformation<Object, String> entityInformation = new DocumentDbEntityInformation(domainClass); this.metadata = new SimpleDocumentDbEntityMetadata<Object>((Class<Object>) domainClass, entityInformation); return this.metadata; }
/** * @param query, the query expression potentially containing a SpEL expression. Must not be {@literal null}.} * @param metadata the {@link EntityMetadata} for the given entity. Must not be {@literal null}. * @param parser Must not be {@literal null}. * @return */ private static String renderQueryIfExpressionOrReturnQuery(String query, EntityMetadata<?> metadata, SpelExpressionParser parser) { Assert.notNull(query, "query must not be null!"); Assert.notNull(metadata, "metadata must not be null!"); Assert.notNull(parser, "parser must not be null!"); if (!containsExpression(query)) { return query; } StandardEvaluationContext evalContext = new StandardEvaluationContext(); evalContext.setVariable(ENTITY_NAME, metadata.getJavaType().getName()); query = potentiallyQuoteExpressionsParameter(query); Expression expr = parser.parseExpression(query, ParserContext.TEMPLATE_EXPRESSION); String result = expr.getValue(evalContext, String.class); if (result == null) { return query; } return potentiallyUnquoteParameterExpressions(result); }
@Override protected FacetPage<?> executeFind(Query query) { Assert.isInstanceOf(FacetQuery.class, query); EntityMetadata<?> metadata = solrQueryMethod.getEntityInformation(); return solrOperations.queryForFacetPage((FacetQuery) query, metadata.getJavaType()); }
protected Page<?> executeFind(Query query) { EntityMetadata<?> metadata = solrQueryMethod.getEntityInformation(); return solrOperations.queryForPage(query, metadata.getJavaType()); }
protected HighlightPage<?> executeFind(Query query) { Assert.isInstanceOf(HighlightQuery.class, query); EntityMetadata<?> metadata = solrQueryMethod.getEntityInformation(); return solrOperations.queryForHighlightPage((HighlightQuery) query, metadata.getJavaType()); }
@Override public Object execute(Query query) { EntityMetadata<?> metadata = solrQueryMethod.getEntityInformation(); return solrOperations.queryForObject(query, metadata.getJavaType()); }
/** * Creates a new {@link ExpressionBasedStringQuery} for the given query and {@link EntityMetadata}. * * @param query must not be {@literal null} or empty. * @param metadata must not be {@literal null}. * @param parser must not be {@literal null}. */ public ExpressionBasedStringQuery(String query, EntityMetadata<?> metadata, SpelExpressionParser parser) { super(renderQueryIfExpressionOrReturnQuery(query, metadata, parser)); }