EMMA Coverage Report (generated Tue Mar 05 16:36:55 GMT 2013)
[all classes][org.springframework.data.elasticsearch.repository.query]

COVERAGE SUMMARY FOR SOURCE FILE [ElasticsearchPartQuery.java]

nameclass, %method, %block, %line, %
ElasticsearchPartQuery.java100% (1/1)100% (3/3)86%  (56/65)90%  (9/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ElasticsearchPartQuery100% (1/1)100% (3/3)86%  (56/65)90%  (9/10)
execute (Object []): Object 100% (1/1)74%  (25/34)80%  (4/5)
ElasticsearchPartQuery (ElasticsearchQueryMethod, ElasticsearchOperations): void 100% (1/1)100% (20/20)100% (4/4)
createQuery (ParametersParameterAccessor): CriteriaQuery 100% (1/1)100% (11/11)100% (1/1)

1/*
2 * Copyright 2013 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.springframework.data.elasticsearch.repository.query;
17 
18 
19import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
20import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
21import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
22import org.springframework.data.elasticsearch.repository.query.parser.ElasticsearchQueryCreator;
23import org.springframework.data.mapping.context.MappingContext;
24import org.springframework.data.repository.query.ParametersParameterAccessor;
25import org.springframework.data.repository.query.parser.PartTree;
26 
27/**
28 *  ElasticsearchPartQuery
29 *
30 * @author Rizwan Idrees
31 * @author Mohsin Husen
32 */
33public class ElasticsearchPartQuery extends AbstractElasticsearchRepositoryQuery{
34 
35    private final PartTree tree;
36    private final MappingContext<?, ElasticsearchPersistentProperty> mappingContext;
37 
38 
39    public ElasticsearchPartQuery(ElasticsearchQueryMethod method, ElasticsearchOperations elasticsearchOperations) {
40        super(method, elasticsearchOperations);
41        this.tree = new PartTree(method.getName(), method.getEntityInformation().getJavaType());
42        this.mappingContext = elasticsearchOperations.getElasticsearchConverter().getMappingContext();
43    }
44 
45    @Override
46    public Object execute(Object[] parameters) {
47        ParametersParameterAccessor accessor = new ParametersParameterAccessor(queryMethod.getParameters(), parameters);
48        CriteriaQuery query = createQuery(accessor);
49        if(queryMethod.isPageQuery()){
50            return  elasticsearchOperations.queryForPage(query, queryMethod.getEntityInformation().getJavaType());
51        }
52        return elasticsearchOperations.queryForObject(query, queryMethod.getEntityInformation().getJavaType());
53    }
54 
55    public CriteriaQuery createQuery(ParametersParameterAccessor accessor) {
56        return new ElasticsearchQueryCreator(tree, accessor, mappingContext).createQuery();
57    }
58}

[all classes][org.springframework.data.elasticsearch.repository.query]
EMMA 2.0.5312 (C) Vladimir Roubtsov